All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jonathan.cameron@huawei.com>
To: Alexandru Ardelean <ardeleanalex@gmail.com>
Cc: Phil Reid <preid@electromag.com.au>,
	"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
	<alexandru.ardelean@analog.com>
Subject: Re: iio scale precision
Date: Fri, 25 Jan 2019 10:02:47 +0000	[thread overview]
Message-ID: <20190125100247.000070ca@huawei.com> (raw)
In-Reply-To: <CA+U=DsqtHkZYMVuWKJGYMOsQ3m4N5Cf2B9pj18JZPSvW_aNbzg@mail.gmail.com>

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  



      reply	other threads:[~2019-01-25 10:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

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=20190125100247.000070ca@huawei.com \
    --to=jonathan.cameron@huawei.com \
    --cc=alexandru.ardelean@analog.com \
    --cc=ardeleanalex@gmail.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=preid@electromag.com.au \
    /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 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.