All of lore.kernel.org
 help / color / mirror / Atom feed
* [lm-sensors] temp1,temp2 calculation in w83781d.c
@ 2005-06-21  9:27 Sukhdeep Johar
  2005-06-21 15:27 ` Jean Delvare
  0 siblings, 1 reply; 2+ messages in thread
From: Sukhdeep Johar @ 2005-06-21  9:27 UTC (permalink / raw)
  To: lm-sensors

Hi, 

I see the temp1 being read as : 
          val*10           ; where val is the value read from the register. 

While temp2 is read as : 
         (val/128) *5.  ; where val is a two byte value read from the
registers.
I understand the reason behind the division by 128. 

But am not able to understand the multiplication by 5 & 10.
Can somebody please help me with this. Or point me to the relevant
material.

regards,
Sukhdeep

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

* [lm-sensors] temp1,temp2 calculation in w83781d.c
  2005-06-21  9:27 [lm-sensors] temp1,temp2 calculation in w83781d.c Sukhdeep Johar
@ 2005-06-21 15:27 ` Jean Delvare
  0 siblings, 0 replies; 2+ messages in thread
From: Jean Delvare @ 2005-06-21 15:27 UTC (permalink / raw)
  To: lm-sensors


Hi Sukhdeep,

On 2005-06-21, Sukhdeep Johar wrote:
> I see the temp1 being read as :
>           val*10
> where val is the value read from the register.
>
> While temp2 is read as :
>          (val/128) *5
> where val is a two byte value read from the registers.
> I understand the reason behind the division by 128.
>
> But am not able to understand the multiplication by 5 & 10.

The temp1 value is read from the chip with LSB = 1 degree C, and it
happens that the driver exports the value with a magnitude of 1 (LSB 0.1 degree C). The multiplication by 10 converts from LSB=1 to LSB=0.1.
We could as well have exported the value with a magnitude of 0, this
would have saved the multiplcation. I can't tell why it was done that
way.

The temp2 value is read from the chip with LSB = 0.5 degree C, and is
exported with a magnitude of 1, so again LSB = 0.1 degree C, thus the
multiplication by 5.

The magnitude is returned by the callback functions (e.g. w83781d_temp)
when called with operation = SENSORS_PROC_REAL_INFO, so you can check
them.

Note that all this was completely reworked in Linux 2.6. All temperatures
are now reported with a magnitude of 3 (resolution of 0.001 degree C),
so the conversions are different there. If you are trying to figure our
how hardware monitoring drivers work, I'd suggest that you don't waste
your time with 2.4 code and learn from 2.6 directly.

Hope that helps,
--
Jean Delvare

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

end of thread, other threads:[~2005-06-21 15:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-21  9:27 [lm-sensors] temp1,temp2 calculation in w83781d.c Sukhdeep Johar
2005-06-21 15:27 ` Jean Delvare

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.