From: Ben Collins <bcollins@kernel.org>
To: David Lechner <dlechner@baylibre.com>
Cc: "Ben Collins" <bcollins@watter.com>,
"Jonathan Cameron" <jic23@kernel.org>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 5/5] iio: mcp9600: Add support for IIR filter
Date: Thu, 14 Aug 2025 09:06:39 -0400 [thread overview]
Message-ID: <2025081408-umber-axolotl-e6c6dd@boujee-and-buff> (raw)
In-Reply-To: <a9c8457f-a364-46e2-9e31-ceab0e1c9894@baylibre.com>
On Wed, Aug 13, 2025 at 05:52:04PM -0500, David Lechner wrote:
> On 8/13/25 10:15 AM, Ben Collins wrote:
> > MCP9600 supports an IIR filter with 7 levels. Add IIR attribute
...
> > static int mcp9600_read(struct mcp9600_data *data,
> > @@ -186,6 +189,9 @@ static int mcp9600_read_raw(struct iio_dev *indio_dev,
> > case IIO_CHAN_INFO_THERMOCOUPLE_TYPE:
> > *val = mcp9600_tc_types[data->thermocouple_type];
> > return IIO_VAL_CHAR;
> > + case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY:
> > + *val = data->filter_level;
>
> We can't just pass the raw value through for this. The ABI is defined
> in Documentation/ABI/testing/sysfs-bus-iio and states that the value
> is the frequency in Hz.
...
> For example, for 3 Hz sample rate (18-bit samples), I got:
>
> n f_3dB (Hz)
> 1 0.58774
> 2 0.24939
> 3 0.12063
> 4 0.05984
> 5 0.02986
> 6 0.01492
> 7 0.00746
>
> I had to skip n=0 though since that is undefined. Not sure how we
> handle that since it means no filter. Maybe Jonathan can advise?
Thanks for notes. If I'm reading for datasheet formula right,
k = 2 / (2^n + 1)
So n=0 would be k=1. I did this formula for n=[0-7] and get:
n k
0 1.00000
1 0.66667
2 0.40000
3 0.22222
4 0.11765
5 0.06061
6 0.03077
7 0.01550
I'm not versed in filter frequency, but would these be the correct
values to use for the coefficients?
--
Ben Collins
https://libjwt.io
https://github.com/benmcollins
--
3EC9 7598 1672 961A 1139 173A 5D5A 57C7 242B 22CF
next prev parent reply other threads:[~2025-08-14 13:06 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20250813151614.12098-1-bcollins@watter.com>
2025-08-13 15:15 ` [PATCH v2 1/5] dt-bindings: iio: mcp9600: Add compatible for microchip,mcp9601 Ben Collins
2025-08-13 16:15 ` Krzysztof Kozlowski
2025-08-13 21:11 ` David Lechner
[not found] ` <2025081319-abiding-muskox-c434f3@boujee-and-buff>
2025-08-16 18:43 ` David Lechner
2025-08-13 15:15 ` [PATCH v2 2/5] iio: mcp9600: White space cleanup for tab alignment Ben Collins
2025-08-13 16:34 ` Andy Shevchenko
2025-08-13 15:15 ` [PATCH v2 3/5] iio: mcp9600: Add compatibility for mcp9601 Ben Collins
2025-08-13 16:40 ` Andy Shevchenko
2025-08-13 15:15 ` [PATCH v2 4/5] iio: mcp9600: Add support for dtbinding of thermocouple-type Ben Collins
2025-08-13 16:49 ` Andy Shevchenko
2025-08-13 21:19 ` David Lechner
2025-08-13 15:15 ` [PATCH v2 5/5] iio: mcp9600: Add support for IIR filter Ben Collins
2025-08-13 16:53 ` Andy Shevchenko
2025-08-13 22:52 ` David Lechner
2025-08-14 13:06 ` Ben Collins [this message]
2025-08-14 13:38 ` Ben Collins
2025-08-16 9:54 ` Jonathan Cameron
2025-08-16 13:12 ` Ben Collins
2025-08-16 15:08 ` Jonathan Cameron
2025-08-16 15:19 ` Ben Collins
2025-08-16 15:33 ` Ben Collins
2025-08-16 17:16 ` David Lechner
2025-08-17 17:11 ` Jonathan Cameron
2025-08-17 17:13 ` Jonathan Cameron
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2025081408-umber-axolotl-e6c6dd@boujee-and-buff \
--to=bcollins@kernel.org \
--cc=andy@kernel.org \
--cc=bcollins@watter.com \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox