All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ken Milmore <ken@kenm.demon.co.uk>
To: lm-sensors@vger.kernel.org
Subject: Re: [lm-sensors] Andigilog asc7621 driver: Temperature scaling
Date: Sun, 07 Mar 2010 11:30:13 +0000	[thread overview]
Message-ID: <4B938E45.7040800@kenm.demon.co.uk> (raw)
In-Reply-To: <4B930BB3.6030201@kenm.demon.co.uk>


Example:

The 5V sensor with an input of precisely 5V should give an input MSB 
register value of 192.

Using the "full scale" ratios:

    192 * 6640 / 256 = 4980

Using the 3/4 scale ratios:

    192 * 5000 / 192 = 5000

Error calculation:

    (5000 - 4980) / 5000 = 0.4%

This corresponds to a 1-bit error in the 8 bit voltages, or a 3-bit 
error in the 10 bit voltages, effectively giving only 7-bit accuracy in 
the calculated values.  An unnecessary error I think you'll agree.

Although the full scale values could probably be "tweaked" to make them 
slightly better, the rounding issues inherent with integer arithmetic 
make it difficult to get right on the button near the nominal voltages, 
where highest accuracy is appropriate.  This is easily avoided by using 
the simple 3/4 scale ratios given in the data sheet.


On 07/03/10 10:44, Jean Delvare wrote:
> On Sun, 07 Mar 2010 10:20:13 +0000, Ken Milmore wrote:
>> Regarding the scale factors, I think you'll find that those given for
>> the 2.5V, 3.3V and 5V ranges are far enough wrong introduce a 2-bit
>> error in the 10-bit values.  The driver goes to some trouble to get the
>> full 10 bit precision by combining both the MSB and LSB registers, then
>> throws that precision away in the calculations!
>>
>> You really do need to use the 3/4 scale voltage values, or some
>> equivalent rational scaling, to get the right answers here.  That's why
>> Andigilog provide them in the data sheet! :-)
>
> Whether you use the full scale or 3/4 scale voltage values as the base
> for the calculation doesn't matter, both can work as long as the
> calculation is consistent. What really matters is to multiply before
> you divide.
>
>> I will try and get a patch together as soon as time permits.
>
> Great, thanks.
>

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

  parent reply	other threads:[~2010-03-07 11:30 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-07  2:13 [lm-sensors] Andigilog asc7621 driver: Temperature scaling Ken Milmore
2010-03-07  7:53 ` Jean Delvare
2010-03-07 10:20 ` Ken Milmore
2010-03-07 10:44 ` Jean Delvare
2010-03-07 11:30 ` Ken Milmore [this message]
2010-03-07 12:10 ` Jean Delvare
2010-03-07 14:57 ` Ken Milmore
2010-03-17  7:39 ` Jean Delvare
2010-04-28 12:32 ` Jean Delvare

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=4B938E45.7040800@kenm.demon.co.uk \
    --to=ken@kenm.demon.co.uk \
    --cc=lm-sensors@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 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.