Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo


#13 Scaling Error in ds2450.c

Paul Alfille
DS2450 (1)
Peter A. Henning

There seems to be a scaling error in the source code addressing the DS2450 A/D converter.

According to the data sheet of the DS2450, p.22 , its minimum full scale input voltage at 16 bit resolution and 5.12 V range is 5.1199 V.

This means, that at

(65535-0.5)/65536 * 5.120 = 5.11988 (rounded 5.1199) V the binary value becomes 65535.

Each least significant bit therefore weighs 1/65536 * 5.120 = 0.000078125 (rounded 0.000078) V in agreement with the table on page 22 of the data sheet

However, in line 412 ff of owfs-xxx/module/owlib/src/c/ow_2450.c the code reads

V[0] = 7.8126192E-5 * ((((UINT) data[1]) << 8) | data[0]);

(3 lines following are the same).

The floating point number here is

0.000078126192 = 1/65535*5.120 instead of the 0.000078125 we obtained above

Consequently, OWFS weighs each least significant bit slightly more than it should do, and at a binary count of 65535 displays the value 5.120 V, whereas it should display only 65535/65536*5.120 = 5.11992 (rounded 5.1199 ) V.



Cancel   Add attachments