# How to Interpret DS1847/DS1848 Temperature Readings

### Abstract

The DS1847 and DS1848 have an on-chip direct-to-digital temperature sensor. The temperature is stored in address locations E2h and E3h. This application note explains how to convert the digital temperature data into a decimal degrees Celsius value.

### Translating Temperatures from Hex to Decimal

The procedure for converting temperature values for the DS1847 and DS1848 begins with reading the hex values stored in bytes E2h (the MSB of the temperature) and E3h (the LSB of the temperature). These two bytes contain the most recent temperature reading. Once the two bytes have been read, they can be translated into binary. The bit weights are shown in Table 1.

E2h (Temperature MSB) | E3h (Temperature LSB) | ||||||||||||||

S | 2^{7} |
2^{6} |
2^{5} |
2^{4} |
2^{3} |
2^{2} |
2^{1} |
2^{0} |
2^{-1} |
2^{-2} |
2^{-3} |
2^{-4} |
0 |
0 |
0 |

The temperature is stored in the 13 MSBs of the binary data. The MSB is the sign bit and indicates whether or not the 2's complement binary number is positive or negative. If the MSB is 0, then the value is positive. If the MSB is 1, then the value is negative. The next 12 bits contain the value of the temperature and are translated into decimal by different methods for positive and negative values.

### Positive Temperature Translation

The following is an example of how to translate a positive temperature. In this example, address locations E2h and E3h contain 2Ah and 88h, respectively. Combine these two bytes to get 2A88h. Next, translate the hex data into binary. The binary equivalent of 2A88h is 0010 1010 1000 1000. Since the MSB is 0, the temperature is positive. The lower 3 bits of the binary data are ignored, so they are masked with 0s. Table 2 shows the translation from hex to binary and the masking of the lower 3 bits.

HEXIDECIMAL DATA | BINARY DATA | MASKED BINARY DATA |

2A88h | 0010 1010 1000 1000 | 0010 1010 1000 1000 |

Because the temperature is positive, no 2's complement transformation is required. The data can be translated directly into a decimal number using a calculator. The binary number 0010 1010 1000 1000 is equal to the decimal value of 10888. Because the data contains a fractional component, the decimal value has to be divided to attain the true temperature. The decimal value must be divided by 128 (or multiplied by 2^{-7}) to calculate the correct decimal temperature value. Dividing the decimal value 10888 by 128 results in a decimal temperature value of 85.0625°C.

### Negative Temperature Translation

Converting a negative temperature value (MSB = 1) is a little more involved. As an example, addresses E2h and E3h contain the data F8h and 08h. The first step would be to convert the hex values into binary. Again, the lower 3 bits are ignored, so they will be masked with 0s. Table 3 shows the translation from hex to binary and the masking of the 3 lower bits.

HEXIDECIMAL DATA | BINARY DATA | MASKED BINARY DATA |

F808h | 1111 1000 0000 1000 | 1111 1000 0000 1000 |

The next step is to take the 2's complement of the masked binary value. This is done by first inverting the masked binary number, then adding 1 to it. Inverting the binary number 1111 1000 0000 1000 results in the binary number 0000 0111 1111 0111. Adding 1 gives the binary number 0000 0111 1111 1000. This value is equal to the decimal number 2040. Like in the positive temperature example, the translated decimal value is divided by 128, but is also made negative because the temperature is negative as indicated by the MSB. So, when the decimal value 2040 is divided by -128, the result is a decimal temperature value of -15.9375°C.

### Conclusion

This application note demonstrates the two methods of translating the hex data found in addresses E2h and E3h into a decimal degrees Celsius temperature value.