Skip to contentSkip to conversation

W1: w1_slave units, standardize 1C or .001C? Break API

DISCUSSION David Fries 3 participants 8 messages Jan 21, 2008 – Jan 23, 2008

lore
Share & tools
lore
#0 lore raw

The ds18b20 one wire temperature sensor conversion routine is returning the units in degrees C while the ds1820 (ds18s20) is returning it in .001 degrees C. 20C vs 20312C. Once you know the units I'm liking the latter as it gives a higher precision. Time to break user applications so the driver can give the temperature in the same units for both sensors.

I only have the ds18b20 sensor model. Here is the current output from the sys file for this sensor. /sys/devices/w1_bus_master1/28-0000000e84a2/w1_slave
45 01 4b 46 7f ff 0b 10 84 : crc=84 YES
45 01 4b 46 7f ff 0b 10 84 t=20

I ran the example data from the specification for the ds1820 through it's conversion routine and found that t= was 1000 times the value. What should the displayed units be?

This is the same ds18b20 conversion *1000. Is everyone ok or is any objecting to .001 degrees C for the units? Patch will follow. The .001 C does truncate one bit of precision from the ds18b20 by the way.

45 01 4b 46 7f ff 0b 10 84 : crc=84 YES
45 01 4b 46 7f ff 0b 10 84 t=20312

Signature · 2 lines
David Fries <[email protected]>
http://fries.net/~david/ (PGP encryption key available)
#1 lore raw
Quoted 13 lines · David Fries

The ds18b20 one wire temperature sensor conversion routine is returning the units in degrees C while the ds1820 (ds18s20) is returning it in .001 degrees C. 20C vs 20312C. Once you know the units I'm liking the latter as it gives a higher precision. Time to break user applications so the driver can give the temperature in the same units for both sensors.

I only have the ds18b20 sensor model. Here is the current output from the sys file for this sensor. /sys/devices/w1_bus_master1/28-0000000e84a2/w1_slave
45 01 4b 46 7f ff 0b 10 84 : crc=84 YES
45 01 4b 46 7f ff 0b 10 84 t=20

Quoted 7 lines

I ran the example data from the specification for the ds1820 through
it's conversion routine and found that t= was 1000 times the value. What should the displayed units be?

This is the same ds18b20 conversion *1000. Is everyone ok or is any objecting to .001 degrees C for the units? Patch will follow. The .001 C does truncate one bit of precision from the ds18b20 by the way.

Millikelvins would have the nice property of never being negative. :)

-hpa

#2 lore raw
Quoted 14 lines · H. Peter Anvin
Quoted 13 lines · David Fries

The ds18b20 one wire temperature sensor conversion routine is returning the units in degrees C while the ds1820 (ds18s20) is returning it in .001 degrees C. 20C vs 20312C. Once you know the units I'm liking the latter as it gives a higher precision. Time to break user applications so the driver can give the temperature in the same units for both sensors.

I only have the ds18b20 sensor model. Here is the current output from the sys file for this sensor. /sys/devices/w1_bus_master1/28-0000000e84a2/w1_slave
45 01 4b 46 7f ff 0b 10 84 : crc=84 YES
45 01 4b 46 7f ff 0b 10 84 t=20

Quoted 8 lines
Quoted 5 lines

I ran the example data from the specification for the ds1820 through
it's conversion routine and found that t= was 1000 times the value. What should the displayed units be? This is the same ds18b20 conversion *1000. Is everyone ok or is any objecting to .001 degrees C for the units? Patch will follow. The
.001 C does truncate one bit of precision from the ds18b20 by the way.

Millikelvins would have the nice property of never being negative. :)

Alternatively, centikelvins would fit nicely in 16 bits if anyone cares...

655.35 K = 382.20 °C = 719.96 °F

-hpa

#3 lore raw
Quoted 6 lines · H. Peter Anvin
Quoted 2 lines

Millikelvins would have the nice property of never being negative. :)

Alternatively, centikelvins would fit nicely in 16 bits if anyone cares...

655.35 K = 382.20 °C = 719.96 °F

I have no objection on adding new sysfs files which will return temperature relative to one on Mars or Venus :)

Signature · 1 line
	Evgeniy Polyakov
#4 lore raw
Quoted 10 lines · Evgeniy Polyakov
Quoted 6 lines · H. Peter Anvin
Quoted 2 lines

Millikelvins would have the nice property of never being negative. :)

Alternatively, centikelvins would fit nicely in 16 bits if anyone cares...

655.35 K = 382.20 °C = 719.96 °F

I have no objection on adding new sysfs files which will return temperature relative to one on Mars or Venus :)

Even more, what about possibility of changing of the base, relative to which temperature is displayed? By default I vote for centigrades, those, who live behind the oceans, can setup Fahrenheit, Kelvin or anything else, but please in a new file :)
David will this work for you?

Signature · 1 line
	Evgeniy Polyakov
#5 lore raw
In reply to H. Peter Anvin
Quoted 2 lines · H. Peter Anvin
Quoted 1 line · H. Peter Anvin

Millikelvins would have the nice property of never being negative. :)

True, but the sensor returns the value as a signed integer in C. That is where the earlier negative number problem was, it would have to do yet another conversion to go to Kelvin, and it would be just one more potential for error. Everyone knows that a bad conversion doomed at least one space craft, let's stick to Centigrade.

Quoted 3 lines

Alternatively, centikelvins would fit nicely in 16 bits if anyone cares...

655.35 K = 382.20 ?C = 719.96 ?F

The range for the sensor is -55 to 125 C, if an application didn't care about precision they could store it in a signed 8 bit value just fine.

Signature · 2 lines
David Fries <[email protected]>
http://fries.net/~david/ (PGP encryption key available)
#6 lore raw
Quoted 10 lines · David Fries
Quoted 2 lines · H. Peter Anvin
Quoted 1 line · H. Peter Anvin

Millikelvins would have the nice property of never being negative. :)

True, but the sensor returns the value as a signed integer in C. That is where the earlier negative number problem was, it would have to do yet another conversion to go to Kelvin, and it would be just one more potential for error. Everyone knows that a bad conversion doomed at least one space craft, let's stick to Centigrade.

Uhm... the conversion is exact as long as you have at least centikelvin precision (0 °C = 273.15 K by definition, and the multiplier is 1.)

Quoted 7 lines
Quoted 3 lines

Alternatively, centikelvins would fit nicely in 16 bits if anyone cares...

655.35 K = 382.20 °C = 719.96 °F

The range for the sensor is -55 to 125 C, if an application didn't care about precision they could store it in a signed 8 bit value just fine.

This was more a comment as to it possibly being a convenient format for more than this particular sensor.

The nice thing with kelvins is no need to worry about negative numbers and something misparsing them, that's all.

I certainly did not imply that we should even consider use °F. That's obviously ridiculous.

-hpa

#7 lore raw
In reply to David Fries

Hi David.

Quoted 6 lines · David Fries

The ds18b20 one wire temperature sensor conversion routine is returning the units in degrees C while the ds1820 (ds18s20) is returning it in .001 degrees C. 20C vs 20312C. Once you know the units I'm liking the latter as it gives a higher precision. Time to break user applications so the driver can give the temperature in the same units for both sensors.

What about instead of breaking application just add new sysfs file, which will only return temperature instead of full rom content. It can be millidegrees Centigrade, another one can be millikelvins :)

Actually it is already posible for applications to decode whatever precision they like from the rom content displayed, although that can be not very convenient.

Signature · 1 line
	Evgeniy Polyakov