From: David Lechner <dlechner@baylibre.com>
To: Jonathan Cameron <jic23@kernel.org>
Cc: "Miclaus, Antoniu" <Antoniu.Miclaus@analog.com>,
"conor+dt@kernel.org" <conor+dt@kernel.org>,
"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-pwm@vger.kernel.org" <linux-pwm@vger.kernel.org>
Subject: Re: [PATCH v5 6/6] iio: adc: ad4851: add ad485x driver
Date: Mon, 11 Nov 2024 10:03:21 -0600 [thread overview]
Message-ID: <182b9144-9a68-4e60-9a1b-4284731ab367@baylibre.com> (raw)
In-Reply-To: <20241109153946.4f4df9d2@jic23-huawei>
On 11/9/24 9:39 AM, Jonathan Cameron wrote:
> On Thu, 7 Nov 2024 10:47:52 -0600
> David Lechner <dlechner@baylibre.com> wrote:
>
>> On 11/7/24 10:13 AM, David Lechner wrote:
>>> On 11/7/24 4:51 AM, Miclaus, Antoniu wrote:
>>
>>
>>>>> I'm pretty sure that calibscale and calibbias also need to take into
>>>>> account if resolution boost is enabled or not.
>>>>
>>>> Can you please detail a bit on this topic? I am not sure what I should do.
>>>>
>>>
>>> We haven't implemented oversampling yet in ad4695 yet, so I don't know
>>> exactly what we need to do either. ;-)
>>>
>>> But this is how I would test it to see if it is working correctly or
>>> not. We will need to test this with a 20-bit chip since that is the
>>> only one that will change the _scale attribute when oversampling is
>>> enabled.
>>>
>>> First, with oversampling disabled (_oversampling_ratio = 1), generate
>>> a constant voltage of 1V for the input. Read the _raw attribute. Let's
>>> call this value raw0. Read the _scale attribute, call it scale0 and
>>> the _offset attribute, call it offset0.
>>>
>>> Then we should have (raw0 + offset0) * scale0 = 1000 mV (+/- some
>>> noise).
>>>
>>> Then change the offset calibrate to 100 mV. To do this, we reverse
>>> the calculation 100 mV / scale0 = calibbias (raw units). Write the
>>> raw value to the _calibbias attribute. Then read the _raw
>>> attribute again, call it raw0_with_calibbias.
>>>
>>> This time, we should have (raw0_with_calibbias + offset0) * scale0
>>> = 1100 mV (+/- some noise).
>>>
>>> Then set _calibbias back to 0 and repeat the above by setting the
>>> _calibscale attribute to 0.90909 (this is 1 / 1.1, which should
>>
After a bit more testing, I realized I was testing with a
differential channel, this math only applies to that.
For a single ended channel, applying a calibscale of 1.1 with
a generated signal of 1V will cause the measured value to change
from 1V to 1.1V as one might expect.
>> Now that I have written this, this has me second-guessing if I
>> implemented calibscale correctly on ad4695. It would seem more
>> logical that if we have an actual input voltage of 1 V and a
>> calibscale of 1.1, then the resulting processed value we read
>> should be 1100 mV.
>>
>> Jonathan, can you set me straight? The sysfs ABI docs aren't
>> clear on this point.
>
> Deliberately vague in this case. calibbias is kind of the wild west
> of ABI. Often we have no meaningful information on what the tweak
> register settings actually do beyond 'up vs down'. In some cases
> the datasheets even refer to them as taps up or taps down.
>
> I don't think we've ever said if it should be consistent as you
> change other parameters. If you care about calibration you probably
> need to redo it for your new settings anyway and tweak the calibbias
> /calibscale till it gives the right values.
>
> Obviously that is easier to do if you have a consistent scheme for
> a given device and if possible allow calibrating at just one setting
> but I don't think we can apply general rules.
>
Thanks for the clarification.
> Jonathan
>
>>
>>> add 10% to the measured raw value). Read, the _raw attribute again,
>>> call it raw0_with_caliscale.
>>>
>>> This time, we should have (raw0_with_caliscale + offset0) * scale0
>>> = 1100 mV (+/- some noise).
>>>
>>> Set _calibscale back to 0. Then set _oversampling_ratio to 2. Read
>>> _scale and _offset again, call these scale1 and offset1.
>>>
>>> Then repeat the steps above using scale1 and offset1 in the
>>> calculations. The raw values will be different but the resulting
>>> processed values (mV) should all be the same if the attributes
>>> are implemented correctly.
>>>
>
next prev parent reply other threads:[~2024-11-11 16:03 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-01 11:23 [PATCH 0/7] *** Add support for AD485x DAS Family *** Antoniu Miclaus
2024-11-01 11:23 ` [PATCH v5 1/6] iio: backend: add API for interface get Antoniu Miclaus
2024-11-01 19:17 ` David Lechner
2024-11-01 11:23 ` [PATCH v5 2/6] iio: backend: add support for data size set Antoniu Miclaus
2024-11-01 19:23 ` David Lechner
2024-11-01 11:23 ` [PATCH v5 3/6] iio: adc: adi-axi-adc: add interface type Antoniu Miclaus
2024-11-01 19:26 ` David Lechner
2024-11-01 11:23 ` [PATCH v5 4/6] iio: adc: adi-axi-adc: set data format Antoniu Miclaus
2024-11-01 19:52 ` David Lechner
2024-11-01 21:00 ` David Lechner
2024-11-01 11:23 ` [PATCH v5 5/6] dt-bindings: iio: adc: add ad4851 Antoniu Miclaus
2024-11-01 11:23 ` [PATCH v5 6/6] iio: adc: ad4851: add ad485x driver Antoniu Miclaus
2024-11-01 15:21 ` Jonathan Cameron
2024-11-01 19:14 ` David Lechner
2024-11-07 10:51 ` Miclaus, Antoniu
2024-11-07 16:13 ` David Lechner
2024-11-07 16:47 ` David Lechner
2024-11-09 15:39 ` Jonathan Cameron
2024-11-11 16:03 ` David Lechner [this message]
2024-11-08 12:50 ` Miclaus, Antoniu
2024-11-02 14:58 ` Jonathan Cameron
2024-11-01 15:17 ` [PATCH 0/7] *** Add support for AD485x DAS Family *** 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=182b9144-9a68-4e60-9a1b-4284731ab367@baylibre.com \
--to=dlechner@baylibre.com \
--cc=Antoniu.Miclaus@analog.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
/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