linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* iio scale precision
@ 2019-01-23  9:07 Phil Reid
  2019-01-25  8:36 ` Alexandru Ardelean
  0 siblings, 1 reply; 3+ messages in thread
From: Phil Reid @ 2019-01-23  9:07 UTC (permalink / raw)
  To: linux-iio@vger.kernel.org

What's the best way to handle scale values for very high precision ADC's.

eg a 24 or even a 32 bit dac with a 2.5v full scale range.

Even using the nV conversion param it looses a fair bit of precision.

Would a option to return a rational number would be better?

Or am I doing something wrong.

-- 
Regards
Phil

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

* Re: iio scale precision
  2019-01-23  9:07 iio scale precision Phil Reid
@ 2019-01-25  8:36 ` Alexandru Ardelean
  2019-01-25 10:02   ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: Alexandru Ardelean @ 2019-01-25  8:36 UTC (permalink / raw)
  To: Phil Reid; +Cc: linux-iio@vger.kernel.org, alexandru.ardelean

On Wed, Jan 23, 2019 at 11:17 AM Phil Reid <preid@electromag.com.au> wrote:
>
> What's the best way to handle scale values for very high precision ADC's.
>
> eg a 24 or even a 32 bit dac with a 2.5v full scale range.
>
> Even using the nV conversion param it looses a fair bit of precision.
>
> Would a option to return a rational number would be better?

Are you saying something like float/double C types ?
Typically those are not allowed in kernel.

Scale values are typically/mostly for informational purposes.
i.e. the driver computes the scales [and the current selected scales]
for the measured values, so that the userspace parts [usually libiio]
can compute actual values

So, you could compute & display scales almost any way you want it,
even just displaying a string representation of the scale value.
It is good to follow some conventions though.

You could take a look at various formats for the scales.
Something like IIO_VAL_INT_PLUS_NANO or IIO_VAL_FRACTIONAL or
IIO_VAL_FRACTIONAL_LOG2 [see __iio_format_value  in
drivers/iio/industrialio-core.c to get some idea ] .
Depends what you really need.

I guess to give a better answer here [I deferred giving one hoping
someone more informed would jump-in], we would also need a more
concrete example.

Thanks
Alex

>
> Or am I doing something wrong.
>
> --
> Regards
> Phil

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

* Re: iio scale precision
  2019-01-25  8:36 ` Alexandru Ardelean
@ 2019-01-25 10:02   ` Jonathan Cameron
  0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2019-01-25 10:02 UTC (permalink / raw)
  To: Alexandru Ardelean
  Cc: Phil Reid, linux-iio@vger.kernel.org, alexandru.ardelean

On Fri, 25 Jan 2019 10:36:19 +0200
Alexandru Ardelean <ardeleanalex@gmail.com> wrote:

> On Wed, Jan 23, 2019 at 11:17 AM Phil Reid <preid@electromag.com.au> wrote:
> >
> > What's the best way to handle scale values for very high precision ADC's.
> >
> > eg a 24 or even a 32 bit dac with a 2.5v full scale range.
> >
> > Even using the nV conversion param it looses a fair bit of precision.
> >
> > Would a option to return a rational number would be better?  
> 
> Are you saying something like float/double C types ?
> Typically those are not allowed in kernel.
> 
> Scale values are typically/mostly for informational purposes.
> i.e. the driver computes the scales [and the current selected scales]
> for the measured values, so that the userspace parts [usually libiio]
> can compute actual values
> 
> So, you could compute & display scales almost any way you want it,
> even just displaying a string representation of the scale value.
> It is good to follow some conventions though.
> 
> You could take a look at various formats for the scales.
> Something like IIO_VAL_INT_PLUS_NANO or IIO_VAL_FRACTIONAL or
> IIO_VAL_FRACTIONAL_LOG2 [see __iio_format_value  in
> drivers/iio/industrialio-core.c to get some idea ] .
> Depends what you really need.

If we are dealing with a 32bit device we may just need to add a pico version
which will generate a pile of leading zeros.  Even smaller types are fine
as well if needed.

As Alex says, it's just formatted to a string (mostly). The exception is
if we have in kernel users in which case it'll be up to the consumer
to figure out how to apply the scale.  We provide some utility functions
but I doubt these high precision ADCs are going to get used by another driver
in kernel.

J
> 
> I guess to give a better answer here [I deferred giving one hoping
> someone more informed would jump-in], we would also need a more
> concrete example.
> 
> Thanks
> Alex
> 
> >
> > Or am I doing something wrong.
> >
> > --
> > Regards
> > Phil  



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

end of thread, other threads:[~2019-01-25 10:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-23  9:07 iio scale precision Phil Reid
2019-01-25  8:36 ` Alexandru Ardelean
2019-01-25 10:02   ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).