0
\$\begingroup\$

I am interested in the DS18B20 temperature sensor from Maxim Integrated. The datasheet is here:

https://datasheets.maximintegrated.com/en/ds/DS18B20.pdf

The datasheet mentions:

  • "Measures Temperatures from -55°C to +125°C"
  • "The resolution of the temperature sensor is user-configurable to 9, 10, 11, or 12 bits, corresponding to increments of 0.5°C, 0.25°C, 0.125°C, and 0.0625°C, respectively."

But when I compute this by hand, I get that, at 12 bits resolution, between -55 and +125 degrees, the resolution in degrees celcius "should" be:

(125+55) / (2**12) = 0.044

(using 2 significant digits).

How to understand the mismatch? Does that mean that only "part of" the 12 bits resolution is really used? Then I guess it is not strictly speaking "12 bits resolution", right?

\$\endgroup\$
0

2 Answers 2

4
\$\begingroup\$

If you look at the DS18B20 datasheet, page 6 you can see that it does not use the entire range of possible values.

With the maximum resolution (12 bits), it could potentially represent values of -127 to +127 °C (7 bits left of the “binary” point, a sign bit, plus the 1 to 4 fractional bits), of which only the values -55 to +125 are used.

The maximum resolution to the right of the “binary” point is 4 bits, which represents 2^-4 (1/16 = 0.0625 °C).

\$\endgroup\$
3
\$\begingroup\$

You calculated your resolution with an assumption that the sensor gives the full temperature range of -55°C to 125°C in full 12-bit code range of between 0 to 4095, or rather, -2048 to +2047, but it doesn't.

The chip is just guaranteed to perform temperature measurements within specifications in the -55°C to +125°C range, which does not tell anything how it represents the measurements in bits.

Since the integer part can be represented in 8 bits, signed 8-bit values can range from -128 to +127, or resolution of 1°C.

  • 8 bits : 1/1 = 1.0 °C steps
  • 9 bits : 1/2 = 0.5 °C steps
  • 10 bits : 1/4 = 0.25 °C steps
  • 11 bits : 1/8 = 0.125 °C steps
  • 12 bits : 1/16 = 0.0625 °C steps

So the full 12-bit code range can encode range of -2048/16 to 2047/16, or -128.0000 °C to +127.9375 °C.

But only the codes for the range representing -55 to +125 are valid measurements, and codes outside that range are not valid.

\$\endgroup\$
1
  • \$\begingroup\$ Thanks! I see that the other answer was first, so accepted it, but thanks for the confirmation :) . \$\endgroup\$
    – Zorglub29
    Commented Aug 4, 2021 at 19:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.