Re: [PATCH 3/4] iio: adc: mcp3422: add hardware gain attribute

From: Mitja Špes
Date: Sat Nov 12 2022 - 16:19:43 EST


Hi Jonathan,

On Sat, Nov 12, 2022 at 6:20 PM Jonathan Cameron <jic23@xxxxxxxxxx> wrote:
> How are the separate? We normally only use hardwaregain if
> changing it has no input on the scale that we need to apply in userspace
> to raw channels. This normally happens for two reasons
> 1) There is a micro controller on the sensor that is doing a bunch of
> maths so whilst changing the PGA value changes the range measurable it
> doesn't affect the representation when we read from the device.
> 2) The hardware gain is controlling say the sensitivity of a light sensor
> in a time of flight device - it affects if we can get a measurement, but
> not the measurement itself.
>
> Any of that true here?
No. I see I misunderstood the hardwaregain attribute. For me this is a user
friendly way of setting the gain and subsequently scale.

What I don't understand is why set scale at all? It's a result of sampling
rate and gain settings. Using it as a setting, for which input value range also
changes depending on another attribute is quite cumbersome.
To use a sensor the program has to do this:
1. set the sampling rate
2. read available scales for this sampling rate
3. set the scale according to desired gain
or know the scales for each sampling rate in advance...which makes available
scales attribute quite useless.

Kind regards,
Mitja