27.12.2014 Views

Using DS18B20 digital temperature sensor on AVR ... - teslabs

Using DS18B20 digital temperature sensor on AVR ... - teslabs

Using DS18B20 digital temperature sensor on AVR ... - teslabs

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

0 Temperature LSB<br />

1 Temperature MSB<br />

2 TH Register or User Byte 1<br />

3 TL Register or User Byte 2<br />

4 C<strong>on</strong>figurati<strong>on</strong> register<br />

0x5005<br />

(+85ºC)<br />

C<strong>on</strong>tent stored<br />

in EEPROM<br />

5 Reserved (0xff) -<br />

6 Reserved (0x0c) -<br />

7 Reserved (0x10) -<br />

8 CRC -<br />

Table 3.6.A<br />

A useful thing inside the Scratchpad is the C<strong>on</strong>figurati<strong>on</strong> register. As you should know, the<br />

thermometer can work in four different resoluti<strong>on</strong>s (9,10,11 and 12 bits). It comes with a 12-<br />

bit mode selected by default, but it can be changed at any moment using the Write<br />

Scratchpad command (0x4e) and writing there the desired resoluti<strong>on</strong>. In the following tables<br />

the structure of C<strong>on</strong>figurati<strong>on</strong> register and informati<strong>on</strong> of each resoluti<strong>on</strong> is shown<br />

(including necessary values to change it):<br />

CONFIGURATION REGISTER<br />

Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0<br />

0 R1 R0 1 1 1 1 1<br />

R1 R0 Resoluti<strong>on</strong> bits Decimal steps C<strong>on</strong>versi<strong>on</strong> time<br />

0 0 9 0.5 93.75ms<br />

0 1 10 0.25 187.5ms<br />

1 0 11 0.125 375ms<br />

1 1 12 (default) 0.0625 750ms<br />

Table 3.6.C<br />

Table 3.6.B<br />

As I said, the <str<strong>on</strong>g>temperature</str<strong>on</strong>g> is stored in the first 2 bytes of the Scratchpad, but we need to know<br />

how to interpret them. We can obtain three important values from the <str<strong>on</strong>g>temperature</str<strong>on</strong>g> bytes: if it is<br />

positive or negative, the <str<strong>on</strong>g>temperature</str<strong>on</strong>g> integer digit and the number of decimal steps. The<br />

structure is detailed below:<br />

Least Significant Byte<br />

Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0<br />

I 3 I 2 I 1 I 0 D -1 D -2 D -3 D -4<br />

Most Significant Byte<br />

Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0<br />

S S S S S I 6 I 5 I 4<br />

Table 3.6.D<br />

13

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!