Message ID | 20250317115247.3735016-6-u.kleine-koenig@baylibre.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | iio: adc: ad7124: Fix 3dB filter frequency reading | expand |
Hello, On 03/17, Uwe Kleine-König wrote: > The sinc4 filter has a factor 0.23 between Output Data Rate and f_{3dB} > and for sinc3 the factor is 0.272 according to the data sheets for > ad7124-4 (Rev. E.) and ad7124-8 (Rev. F). Potentially dumb question but, how do we get to these factors between ODR and 3dB frequency? Looking at Table 8, Table 18, Table 28, and dividing values from Output Data Rate (SPS) column by respective values from f3dB (Hz) column gives me 4.3478. If the zero latency mode SPS values are used as numerator, the result is 1.0869 for most pairs of SPS and f3dB. > > Fixes: cef2760954cf ("iio: adc: ad7124: add 3db filter") > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com> > --- > drivers/iio/adc/ad7124.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/iio/adc/ad7124.c b/drivers/iio/adc/ad7124.c > index 3ea81a98e455..7d5d84a07cae 100644 > --- a/drivers/iio/adc/ad7124.c > +++ b/drivers/iio/adc/ad7124.c > @@ -301,9 +301,9 @@ static int ad7124_get_3db_filter_freq(struct ad7124_state *st, > > switch (st->channels[channel].cfg.filter_type) { > case AD7124_SINC3_FILTER: > - return DIV_ROUND_CLOSEST(fadc * 230, 1000); > + return DIV_ROUND_CLOSEST(fadc * 272, 1000); > case AD7124_SINC4_FILTER: > - return DIV_ROUND_CLOSEST(fadc * 262, 1000); > + return DIV_ROUND_CLOSEST(fadc * 230, 1000); > default: > return -EINVAL; > } > -- > 2.47.1 > >
Hello, On Wed, Mar 26, 2025 at 03:20:24PM -0300, Marcelo Schmitt wrote: > Hello, > > On 03/17, Uwe Kleine-König wrote: > > The sinc4 filter has a factor 0.23 between Output Data Rate and f_{3dB} > > and for sinc3 the factor is 0.272 according to the data sheets for > > ad7124-4 (Rev. E.) and ad7124-8 (Rev. F). > > Potentially dumb question but, how do we get to these factors between ODR and > 3dB frequency? > Looking at Table 8, Table 18, Table 28, and > dividing values from Output Data Rate (SPS) column by respective > values from f3dB (Hz) column gives me 4.3478. Using the datasheet for AD7124-4 Rev. E in Table 8 we have for example: ODR = 19200 SPS f_{3dB} = 4416 Hz So it's either multiplying with 0.23 (as does my patch) or dividing by 4.3478260869565215 (as you found). But having said that, a definitive formula would be nice instead of guessing that there is a linear correlation between the columns and determining the factor yourself. Note that in Table 10 the f_{3dB} value corresponding to ODR = 15 SPS should be 4.08 Hz. The 5.44 Hz specified there would be the right value for ODR = 20 SPS which is a value that occurs in Tables 8 and 9, but not 10. :-\ > > @@ -301,9 +301,9 @@ static int ad7124_get_3db_filter_freq(struct ad7124_state *st, > > > > switch (st->channels[channel].cfg.filter_type) { > > case AD7124_SINC3_FILTER: > > - return DIV_ROUND_CLOSEST(fadc * 230, 1000); > > + return DIV_ROUND_CLOSEST(fadc * 272, 1000); > > case AD7124_SINC4_FILTER: > > - return DIV_ROUND_CLOSEST(fadc * 262, 1000); > > + return DIV_ROUND_CLOSEST(fadc * 230, 1000); > > default: > > return -EINVAL; > > } Best regards Uwe
On 03/31, Uwe Kleine-König wrote: > Hello, > > On Wed, Mar 26, 2025 at 03:20:24PM -0300, Marcelo Schmitt wrote: > > Hello, > > > > On 03/17, Uwe Kleine-König wrote: > > > The sinc4 filter has a factor 0.23 between Output Data Rate and f_{3dB} > > > and for sinc3 the factor is 0.272 according to the data sheets for > > > ad7124-4 (Rev. E.) and ad7124-8 (Rev. F). > > > > Potentially dumb question but, how do we get to these factors between ODR and > > 3dB frequency? > > Looking at Table 8, Table 18, Table 28, and > > dividing values from Output Data Rate (SPS) column by respective > > values from f3dB (Hz) column gives me 4.3478. > > Using the datasheet for AD7124-4 Rev. E in Table 8 we have for example: > > ODR = 19200 SPS > f_{3dB} = 4416 Hz > > So it's either multiplying with 0.23 (as does my patch) or dividing by > 4.3478260869565215 (as you found). Got it. Thanks for clarifying that out. > > But having said that, a definitive formula would be nice instead of > guessing that there is a linear correlation between the columns and > determining the factor yourself. Note that in Table 10 the f_{3dB} value > corresponding to ODR = 15 SPS should be 4.08 Hz. The 5.44 Hz specified > there would be the right value for ODR = 20 SPS which is a value that > occurs in Tables 8 and 9, but not 10. :-\ I see. Yeah, I feel like datasheets are similar to device drivers in the sense that they tend to get better over time. datasheets for newer parts often have more information and better explanations compared to old ones. Anyways, Reviewed-by: Marcelo Schmitt <marcelo.schmitt@analog.com> Thanks, Marcelo
diff --git a/drivers/iio/adc/ad7124.c b/drivers/iio/adc/ad7124.c index 3ea81a98e455..7d5d84a07cae 100644 --- a/drivers/iio/adc/ad7124.c +++ b/drivers/iio/adc/ad7124.c @@ -301,9 +301,9 @@ static int ad7124_get_3db_filter_freq(struct ad7124_state *st, switch (st->channels[channel].cfg.filter_type) { case AD7124_SINC3_FILTER: - return DIV_ROUND_CLOSEST(fadc * 230, 1000); + return DIV_ROUND_CLOSEST(fadc * 272, 1000); case AD7124_SINC4_FILTER: - return DIV_ROUND_CLOSEST(fadc * 262, 1000); + return DIV_ROUND_CLOSEST(fadc * 230, 1000); default: return -EINVAL; }
The sinc4 filter has a factor 0.23 between Output Data Rate and f_{3dB} and for sinc3 the factor is 0.272 according to the data sheets for ad7124-4 (Rev. E.) and ad7124-8 (Rev. F). Fixes: cef2760954cf ("iio: adc: ad7124: add 3db filter") Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com> --- drivers/iio/adc/ad7124.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)