All of lore.kernel.org
 help / color / mirror / Atom feed
* [lm-sensors] How to compute a voltage that may be positive or negative
@ 2014-08-22 22:31 Christopher Cordahi
  2014-08-23 19:11 ` Guenter Roeck
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Christopher Cordahi @ 2014-08-22 22:31 UTC (permalink / raw)
  To: lm-sensors

I'm wondering if this is a valid use case.  I need to perform both a
multiplication and a subtraction to compute an original voltage.

lm sensors 3.2.0 is working fine on Linux 2.6.39.4 reading an ADS1115 ADC
chip that measures a voltage from 0 V to about 2 V.

# uname -srmo
Linux 2.6.39.4 armv5tejl GNU/Linux
# sensors --version
sensors version 3.2.0 with libsensors version 3.2.0
# sensors --bus-list ads1115-i2c-2-4a
bus "i2c-2" "i2c-1-mux (chan_id 0)"
bus "i2c-1" "DaVinci I2C adapter"
# sensors --no-adapter ads1115-i2c-2-4a
ads1115-i2c-2-4a
in4:         +1.14 V
in5:         +1.14 V
in6:         +1.14 V

My problem is that I'd like for the sensor utility to convert the ADC
voltages to the original voltage which are in the range from about -10 V to
about +10 V.

If I modify the sensor configuration as follows, it appears to work
correctly.

root@centaur-3_0009:~# tail -2 /etc/sensors3.conf
chip "ads1115-*"
    compute in4 @*10-10 , (@+10)*10
root@centaur-3_0009:~# sensors --no-adapter ads1115-i2c-2-4a
ads1115-i2c-2-4a
in4:         +1.41 V
in5:         +1.14 V
in6:         +1.14 V

Unfortunately when I adjust the values to their more accurate values, it no
longer converts and reports the original ADC value instead.

root@centaur-3_0009:~# tail -2 /etc/sensors3.conf
chip "ads1115-*"
     compute in4 @*9.72340425532-9.95823902214 ,
(@+9958.23902214)/9.72340425532
root@centaur-3_0009:~# sensors --no-adapter ads1115-i2c-2-4a
ads1115-i2c-2-4a
in4:         +1.14 V
in5:         +1.14 V
in6:         +1.14 V

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

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

* Re: [lm-sensors] How to compute a voltage that may be positive or negative
  2014-08-22 22:31 [lm-sensors] How to compute a voltage that may be positive or negative Christopher Cordahi
@ 2014-08-23 19:11 ` Guenter Roeck
  2014-09-02  8:34 ` Jean Delvare
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Guenter Roeck @ 2014-08-23 19:11 UTC (permalink / raw)
  To: lm-sensors

On Fri, Aug 22, 2014 at 06:31:22PM -0400, Christopher Cordahi wrote:
> I'm wondering if this is a valid use case.  I need to perform both a
> multiplication and a subtraction to compute an original voltage.
> 
> lm sensors 3.2.0 is working fine on Linux 2.6.39.4 reading an ADS1115 ADC
> chip that measures a voltage from 0 V to about 2 V.
> 
> # uname -srmo
> Linux 2.6.39.4 armv5tejl GNU/Linux
> # sensors --version
> sensors version 3.2.0 with libsensors version 3.2.0
> # sensors --bus-list ads1115-i2c-2-4a
> bus "i2c-2" "i2c-1-mux (chan_id 0)"
> bus "i2c-1" "DaVinci I2C adapter"
> # sensors --no-adapter ads1115-i2c-2-4a
> ads1115-i2c-2-4a
> in4:         +1.14 V
> in5:         +1.14 V
> in6:         +1.14 V
> 
> My problem is that I'd like for the sensor utility to convert the ADC
> voltages to the original voltage which are in the range from about -10 V to
> about +10 V.
> 
> If I modify the sensor configuration as follows, it appears to work
> correctly.
> 
> root@centaur-3_0009:~# tail -2 /etc/sensors3.conf
> chip "ads1115-*"
>     compute in4 @*10-10 , (@+10)*10
> root@centaur-3_0009:~# sensors --no-adapter ads1115-i2c-2-4a
> ads1115-i2c-2-4a
> in4:         +1.41 V
> in5:         +1.14 V
> in6:         +1.14 V
> 
> Unfortunately when I adjust the values to their more accurate values, it no
> longer converts and reports the original ADC value instead.
> 
> root@centaur-3_0009:~# tail -2 /etc/sensors3.conf
> chip "ads1115-*"
>      compute in4 @*9.72340425532-9.95823902214 ,
> (@+9958.23902214)/9.72340425532

Maybe the sensors command gets confused with the number of digits.
Can you try with less accuracy ?

Guenter

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

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

* Re: [lm-sensors] How to compute a voltage that may be positive or negative
  2014-08-22 22:31 [lm-sensors] How to compute a voltage that may be positive or negative Christopher Cordahi
  2014-08-23 19:11 ` Guenter Roeck
@ 2014-09-02  8:34 ` Jean Delvare
  2014-09-04  2:19 ` Christopher Cordahi
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Jean Delvare @ 2014-09-02  8:34 UTC (permalink / raw)
  To: lm-sensors

Hi Christopher,

On Fri, 22 Aug 2014 18:31:22 -0400, Christopher Cordahi wrote:
> I'm wondering if this is a valid use case.  I need to perform both a
> multiplication and a subtraction to compute an original voltage.
> 
> lm sensors 3.2.0 is working fine on Linux 2.6.39.4 reading an ADS1115 ADC
> chip that measures a voltage from 0 V to about 2 V.
> 
> # uname -srmo
> Linux 2.6.39.4 armv5tejl GNU/Linux
> # sensors --version
> sensors version 3.2.0 with libsensors version 3.2.0
> # sensors --bus-list ads1115-i2c-2-4a
> bus "i2c-2" "i2c-1-mux (chan_id 0)"
> bus "i2c-1" "DaVinci I2C adapter"
> # sensors --no-adapter ads1115-i2c-2-4a
> ads1115-i2c-2-4a
> in4:         +1.14 V
> in5:         +1.14 V
> in6:         +1.14 V
> 
> My problem is that I'd like for the sensor utility to convert the ADC
> voltages to the original voltage which are in the range from about -10 V to
> about +10 V.
> 
> If I modify the sensor configuration as follows, it appears to work
> correctly.
> 
> root@centaur-3_0009:~# tail -2 /etc/sensors3.conf
> chip "ads1115-*"
>     compute in4 @*10-10 , (@+10)*10
> root@centaur-3_0009:~# sensors --no-adapter ads1115-i2c-2-4a
> ads1115-i2c-2-4a
> in4:         +1.41 V
> in5:         +1.14 V
> in6:         +1.14 V
> 
> Unfortunately when I adjust the values to their more accurate values, it no
> longer converts and reports the original ADC value instead.

I tried but could not reproduce the bug here. I also looked at the
source code and there is no arbitrary limit to the number of digits.

> root@centaur-3_0009:~# tail -2 /etc/sensors3.conf
> chip "ads1115-*"
>      compute in4 @*9.72340425532-9.95823902214 ,
> (@+9958.23902214)/9.72340425532

Note that you have a wrong factor in the second half here, even though
that's not related to your problem.

> root@centaur-3_0009:~# sensors --no-adapter ads1115-i2c-2-4a
> ads1115-i2c-2-4a
> in4:         +1.14 V
> in5:         +1.14 V
> in6:         +1.14 V

Well, 1.142 * 9.72340425532 - 9.95823902214 is 1.145. So I think the
value is properly scaled, just it happens that for your specific value,
the scaled value is almost the same as the original value, and that
confused you.

The limited resolution of "sensors" admittedly does not help here, try
"sensors -u" to see the 3rd digit.

-- 
Jean Delvare
http://jdelvare.nerim.net/wishlist.html

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

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

* Re: [lm-sensors] How to compute a voltage that may be positive or negative
  2014-08-22 22:31 [lm-sensors] How to compute a voltage that may be positive or negative Christopher Cordahi
  2014-08-23 19:11 ` Guenter Roeck
  2014-09-02  8:34 ` Jean Delvare
@ 2014-09-04  2:19 ` Christopher Cordahi
  2014-09-04  3:19 ` Christopher Cordahi
  2014-09-04  8:08 ` Jean Delvare
  4 siblings, 0 replies; 6+ messages in thread
From: Christopher Cordahi @ 2014-09-04  2:19 UTC (permalink / raw)
  To: lm-sensors

Thank you Guenter for your quick response and apologies for my slow
response.

Turns out I was the one confused.


On Sat, Aug 23, 2014 at 3:11 PM, Guenter Roeck <linux@roeck-us.net> wrote:

> On Fri, Aug 22, 2014 at 06:31:22PM -0400, Christopher Cordahi wrote:
> > I'm wondering if this is a valid use case.  I need to perform both a
> > multiplication and a subtraction to compute an original voltage.
> >
> > lm sensors 3.2.0 is working fine on Linux 2.6.39.4 reading an ADS1115 ADC
> > chip that measures a voltage from 0 V to about 2 V.
> >
> > # uname -srmo
> > Linux 2.6.39.4 armv5tejl GNU/Linux
> > # sensors --version
> > sensors version 3.2.0 with libsensors version 3.2.0
> > # sensors --bus-list ads1115-i2c-2-4a
> > bus "i2c-2" "i2c-1-mux (chan_id 0)"
> > bus "i2c-1" "DaVinci I2C adapter"
> > # sensors --no-adapter ads1115-i2c-2-4a
> > ads1115-i2c-2-4a
> > in4:         +1.14 V
> > in5:         +1.14 V
> > in6:         +1.14 V
> >
> > My problem is that I'd like for the sensor utility to convert the ADC
> > voltages to the original voltage which are in the range from about -10 V
> to
> > about +10 V.
> >
> > If I modify the sensor configuration as follows, it appears to work
> > correctly.
> >
> > root@centaur-3_0009:~# tail -2 /etc/sensors3.conf
> > chip "ads1115-*"
> >     compute in4 @*10-10 , (@+10)*10
> > root@centaur-3_0009:~# sensors --no-adapter ads1115-i2c-2-4a
> > ads1115-i2c-2-4a
> > in4:         +1.41 V
> > in5:         +1.14 V
> > in6:         +1.14 V
> >
> > Unfortunately when I adjust the values to their more accurate values, it
> no
> > longer converts and reports the original ADC value instead.
> >
> > root@centaur-3_0009:~# tail -2 /etc/sensors3.conf
> > chip "ads1115-*"
> >      compute in4 @*9.72340425532-9.95823902214 ,
> > (@+9958.23902214)/9.72340425532
>
> Maybe the sensors command gets confused with the number of digits.
> Can you try with less accuracy ?
>
> Guenter
>



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

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

* Re: [lm-sensors] How to compute a voltage that may be positive or negative
  2014-08-22 22:31 [lm-sensors] How to compute a voltage that may be positive or negative Christopher Cordahi
                   ` (2 preceding siblings ...)
  2014-09-04  2:19 ` Christopher Cordahi
@ 2014-09-04  3:19 ` Christopher Cordahi
  2014-09-04  8:08 ` Jean Delvare
  4 siblings, 0 replies; 6+ messages in thread
From: Christopher Cordahi @ 2014-09-04  3:19 UTC (permalink / raw)
  To: lm-sensors

> Well, 1.142 * 9.72340425532 - 9.95823902214 is 1.145. So I think the
> value is properly scaled, just it happens that for your specific value,
> the scaled value is almost the same as the original value, and that
> confused you.

Thank you very much Jean, that explains everything.

I was incorrectly assuming the hidden least significant digit was 0, i.e.
that the input was 1.140 V rather than 1.142 V, so I was expecting the
conversion to result in 1.13 (1.1264).

I should know better than to rely on tests performed on a Friday evening.

> The limited resolution of "sensors" admittedly does not help here, try
> "sensors -u" to see the 3rd digit.

With my sensors version 3.2.0, the -u option changes the output format, but
doesn't provide additional information.

# sensors --no-adapter ads1115-i2c-2-4a
ads1115-i2c-2-4a
in4:         -3.16 V
in5:         +0.70 V
in6:         +0.69 V

# sensors -u --no-adapter ads1115-i2c-2-4a
ads1115-i2c-2-4a
in4:
  in4_input: -3.16
in5:
  in5_input: 0.70
in6:
  in6_input: 0.69

I assume it is supposed to print the raw information obtained from /sys

# sensors --help | grep -- -u
  -u                    Raw output (debugging only)
# cat /sys/bus/i2c/devices/2-004a/in?_input
699
696
692

> Note that you have a wrong factor in the second half

Thanks for catching.  When I first read
http://www.lm-sensors.org/wiki/VoltageLabelsAndScaling I thought the value
was in mV, after using it, I correct its use in first half, but not the
second.


On Tue, Sep 2, 2014 at 4:34 AM, Jean Delvare <jdelvare@suse.de> wrote:

> Hi Christopher,
>
> On Fri, 22 Aug 2014 18:31:22 -0400, Christopher Cordahi wrote:
> > I'm wondering if this is a valid use case.  I need to perform both a
> > multiplication and a subtraction to compute an original voltage.
> >
> > lm sensors 3.2.0 is working fine on Linux 2.6.39.4 reading an ADS1115 ADC
> > chip that measures a voltage from 0 V to about 2 V.
> >
> > # uname -srmo
> > Linux 2.6.39.4 armv5tejl GNU/Linux
> > # sensors --version
> > sensors version 3.2.0 with libsensors version 3.2.0
> > # sensors --bus-list ads1115-i2c-2-4a
> > bus "i2c-2" "i2c-1-mux (chan_id 0)"
> > bus "i2c-1" "DaVinci I2C adapter"
> > # sensors --no-adapter ads1115-i2c-2-4a
> > ads1115-i2c-2-4a
> > in4:         +1.14 V
> > in5:         +1.14 V
> > in6:         +1.14 V
> >
> > My problem is that I'd like for the sensor utility to convert the ADC
> > voltages to the original voltage which are in the range from about -10 V
> to
> > about +10 V.
> >
> > If I modify the sensor configuration as follows, it appears to work
> > correctly.
> >
> > root@centaur-3_0009:~# tail -2 /etc/sensors3.conf
> > chip "ads1115-*"
> >     compute in4 @*10-10 , (@+10)*10
> > root@centaur-3_0009:~# sensors --no-adapter ads1115-i2c-2-4a
> > ads1115-i2c-2-4a
> > in4:         +1.41 V
> > in5:         +1.14 V
> > in6:         +1.14 V
> >
> > Unfortunately when I adjust the values to their more accurate values, it
> no
> > longer converts and reports the original ADC value instead.
>
> I tried but could not reproduce the bug here. I also looked at the
> source code and there is no arbitrary limit to the number of digits.
>
> > root@centaur-3_0009:~# tail -2 /etc/sensors3.conf
> > chip "ads1115-*"
> >      compute in4 @*9.72340425532-9.95823902214 ,
> > (@+9958.23902214)/9.72340425532
>
> Note that you have a wrong factor in the second half here, even though
> that's not related to your problem.
>
> > root@centaur-3_0009:~# sensors --no-adapter ads1115-i2c-2-4a
> > ads1115-i2c-2-4a
> > in4:         +1.14 V
> > in5:         +1.14 V
> > in6:         +1.14 V
>
> Well, 1.142 * 9.72340425532 - 9.95823902214 is 1.145. So I think the
> value is properly scaled, just it happens that for your specific value,
> the scaled value is almost the same as the original value, and that
> confused you.
>
> The limited resolution of "sensors" admittedly does not help here, try
> "sensors -u" to see the 3rd digit.
>
> --
> Jean Delvare
> http://jdelvare.nerim.net/wishlist.html
>



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

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

* Re: [lm-sensors] How to compute a voltage that may be positive or negative
  2014-08-22 22:31 [lm-sensors] How to compute a voltage that may be positive or negative Christopher Cordahi
                   ` (3 preceding siblings ...)
  2014-09-04  3:19 ` Christopher Cordahi
@ 2014-09-04  8:08 ` Jean Delvare
  4 siblings, 0 replies; 6+ messages in thread
From: Jean Delvare @ 2014-09-04  8:08 UTC (permalink / raw)
  To: lm-sensors

Hi Christopher,

On Wed, 3 Sep 2014 23:19:40 -0400, Christopher Cordahi wrote:
> > Well, 1.142 * 9.72340425532 - 9.95823902214 is 1.145. So I think the
> > value is properly scaled, just it happens that for your specific value,
> > the scaled value is almost the same as the original value, and that
> > confused you.
> 
> Thank you very much Jean, that explains everything.
> 
> I was incorrectly assuming the hidden least significant digit was 0, i.e.
> that the input was 1.140 V rather than 1.142 V, so I was expecting the
> conversion to result in 1.13 (1.1264).
> 
> I should know better than to rely on tests performed on a Friday evening.

;-) You're welcome.

> > The limited resolution of "sensors" admittedly does not help here, try
> > "sensors -u" to see the 3rd digit.
> 
> With my sensors version 3.2.0, the -u option changes the output format, but
> doesn't provide additional information.
> 
> # sensors --no-adapter ads1115-i2c-2-4a
> ads1115-i2c-2-4a
> in4:         -3.16 V
> in5:         +0.70 V
> in6:         +0.69 V
> 
> # sensors -u --no-adapter ads1115-i2c-2-4a
> ads1115-i2c-2-4a
> in4:
>   in4_input: -3.16
> in5:
>   in5_input: 0.70
> in6:
>   in6_input: 0.69
> 
> I assume it is supposed to print the raw information obtained from /sys

That's correct. But the 3rd decimal place was only added "recently" by:

------------------------------------------------------------------------
r5877 | khali | 2010-11-03 12:59:55 +0100 (mer. 03 nov. 2010) | 6 lignes

sensors: Display 3 decimal places in raw output.

This will make it easier for us to help users find out correct scaling
factors when needed. Instead of telling them to go read the raw sysfs
attributes, they can just report the output of "sensors -u -c /dev/null".

------------------------------------------------------------------------

so you'd need lm-sensors version >= 3.3.0.

> # sensors --help | grep -- -u
>   -u                    Raw output (debugging only)
> # cat /sys/bus/i2c/devices/2-004a/in?_input
> 699
> 696
> 692
> 
> > Note that you have a wrong factor in the second half
> 
> Thanks for catching.  When I first read
> http://www.lm-sensors.org/wiki/VoltageLabelsAndScaling I thought the value
> was in mV, after using it, I correct its use in first half, but not the
> second.

-- 
Jean Delvare
http://jdelvare.nerim.net/wishlist.html

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

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

end of thread, other threads:[~2014-09-04  8:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-22 22:31 [lm-sensors] How to compute a voltage that may be positive or negative Christopher Cordahi
2014-08-23 19:11 ` Guenter Roeck
2014-09-02  8:34 ` Jean Delvare
2014-09-04  2:19 ` Christopher Cordahi
2014-09-04  3:19 ` Christopher Cordahi
2014-09-04  8:08 ` 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.