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 DecimalThe 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.Table 1. Bit weight from page 5 of the DS1847 and DS1848 data sheets
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 TranslationThe 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.Table 2. Positive number (MSB = 0) translation
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 TranslationConverting 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.Table 3. Negative number (MSB = 1) translation
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. ConclusionThis application note demonstrates the two methods of translating the hex data found in addresses E2h and E3h into a decimal degrees Celsius temperature value. Any questions about this document can be directed to the Mixed-Signal Applications Group at <script language=javascript> var name = "MixedSignal.Apps@"; var domain = "dalsemi.com"; document.write ("" + name + domain + ""); </script>[email protected]. |