All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC] IIO way of representing device operation range ?
@ 2020-04-16  7:49 Berghe, Darius
  2020-04-17  9:19 ` Jonathan Cameron
  0 siblings, 1 reply; 4+ messages in thread
From: Berghe, Darius @ 2020-04-16  7:49 UTC (permalink / raw)
  To: jic23@kernel.org
  Cc: Pop, Cristian, linux-iio@vger.kernel.org, Ardelean, Alexandru,
	Bogdan, Dragos

Hi Jonathan,

Some devices (think DAC or ADC) have selectable contiguous operation
ranges per channel, Rmin...Rmax, where Rmin and Rmax are the range
minimum and maximum values expressed in physical units as in datasheet
(mA, mV, etc).

Example DAC:
        current0 0...50mA 0...100mA 
        current1 0...200mA -60...200mA 0...100mA -60...100mA

physical [mV, mA, etc] = (raw + offset) * scale

One way of approaching this that I could find is let the user select
offset and scale from a list of available offsets and scales. But due
to the formula above, offset has higher priority in the computation and
needs to be selected first. Once the user selects the offset, the list
of scales may be recomputed by the driver. At this point the user may
query available scales and select one.

Usage example, user wants to select -60...200mA:
# cd /sys/bus/iio/devices/iio:device0 
# cat out_current1_offset
0.0
# cat out_current1_scale_available
0.003051757 0.001525878# cat out_current1_offset_available
0.0 -15123.0 -24576.0
# echo -123456.0 > out_current1_offset
# cat out_current1_scale_available
0,003967364
# echo 0,003967364 > out_current1_scale


All this is rather complicated for the user, being a two step
procedure. Also, the user cannot pick a range in physical units as
specified in the datasheet, but in a fractional (dimensionless) scale
or a raw ADC/DAC register (dimensionless) offset.

Is there a direct way to select a contiguous operation range in
physical units (as in datasheet) with the current state of the IIO ? I
would like the user to only care about specifying Rmin and Rmax.

Thanks,
Darius Berghe

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-04-21 10:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-16  7:49 [RFC] IIO way of representing device operation range ? Berghe, Darius
2020-04-17  9:19 ` Jonathan Cameron
2020-04-21 10:26   ` Berghe, Darius
2020-04-21 10:55     ` Jonathan Cameron

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.