APP105.PDF

(64 KB) Pobierz
Application Note 105
High Resolution Temperature Measurement
With Dallas Direct-to-Digital
Temperature Sensors
www.dalsemi.com
INTRODUCTION
This application note describes the principle of operation of Dallas Semiconductor’s line of direct–to–
digital temperature sensors, and outlines a method of achieving high (<0.05°C) resolution with these
devices. An example C code listing is given for use with the DS1620.
DIRECT–TO–DIGITAL TEMPERATURE SENSOR PRINCIPLE OF OPERATION
The Dallas Direct–to–Digital Temperature Sensors measure temperature through the use of an onboard
proprietary temperature measurement technique. A block diagram of the temperature measurement
circuitry is shown in Figure 1.
Each temperature sensor measures temperature by counting the number of clock cycles that an oscillator
with a low temperature coefficient goes through during a gate period determined by a high temperature
coefficient oscillator. The counter is preset with a base count that corresponds to –55°C. If the counter
reaches zero before the gate period is over, the temperature register, which is also preset to the –55°C
value, is incremented, indicating that the temperature is higher than –55°C.
At the same time, the counter is then preset with a value determined by the slope accumulator circuitry.
This circuitry is needed to compensate for the parabolic behavior of the oscillators over temperature. The
counter is then clocked again until it reaches zero. If the gate period is still not finished, then this process
repeats.
The slope accumulator is used to compensate for the nonlinear behavior of the oscillators over
temperature, yielding a high resolution temperature measurement (0.5°C for almost all the products). This
is done by changing the number of counts necessary for the counter to go through for each incremental
degree in temperature. To obtain the desired resolution, therefore, both the value of the counter and the
number of counts per degree C (the value of the slope accumulator) at a given temperature must be
known.
1 of 20
110899
APPLICATION NOTE 105
TEMPERATURE MEASUREMENT CIRCUITRY
Figure 1
SLOPE ACCUMULATOR
PRESET
COMPARE
LOW TEMPERATURE
COEFFICIENT OSCILLATOR
COUNTER
PRESET
SET/CLEAR
LSB
INC
=0
TEMPERATURE REGISTER
HIGH TEMPERATURE
COEFFICIENT OSCILLATOR
COUNTER
STOP
=0
INCREASING TEMPERATURE RESOLUTION
Most of Dallas’ direct–to–digital temperature sensors provide 0.5°C resolution directly. This is
accomplished by the device determining whether to set or clear the least significant bit (LSB), based on
the actual temperature. The device attempts to keep errors within �½ LSB, by quantizing different
readings into the LSB step size. For example, a part which is ramping up in temperature from 25°C to
+26°C, or down in temperature from –10°C to –11°C, would exhibit this behavior:
ACTUAL
TEMPERATURE
25
25.1
25.2
25.3
25.4
25.5
25.6
25.7
25.8
25.9
26
SET/CLEAR
LSB
Clear
Clear
Clear
Set
Set
Set
Set
Set
Clear
Clear
Clear
DIRECT
READING
25
25
25
25.5
25.5
25.5
25.5
25.5
26
26
26
ACTUAL
TEMPERATURE
-10
-10.1
-10.2
-10.3
-10.4
-10.5
-10.6
-10.7
-10.8
-10.9
-11
SET/CLEAR
LSB
Clear
Clear
Clear
Set
Set
Set
Set
Set
Clear
Clear
Clear
DIRECT
READING
-10
-10
-10
-10.5
-10.5
-10.5
-10.5
-10.5
-11
-11
-11
2 of 20
APPLICATION NOTE 105
This example shows then that every reading is rounded up (in absolute value) by �½ LSB. For most parts,
this is 0.25°C. This is important to remember, since in doing calculations to achieve higher resolutions,
this rounding factor must be taken into account.
With the exception of devices intended for battery management (DS2434 and DS2435), the temperature
sensors can measure temperature over the range of –55°C to +125°C in 0.5°C increments. For Fahrenheit
usage, a lookup table or conversion factor must be used.
Higher resolutions may be obtained by reading the temperature and truncating the least significant bit
from the read value. From the example above, it should be apparent that this must be done on the raw, 9–
bit number, in two’s–complement arithmetic, in order for the correct reading to result. After the
truncation, the number can then be converted into a signed integer. This value is referred to below as
temp_read. The value left in the counter can then be read by issuing a special command protocol to the
sensor. This value is the count remaining (count_remain) after the gate period has ceased. Reading the
value of the slope accumulator (by using another command protocol or set of protocols, as outlined
below) yields the number of counts per degree C (count_per_degree) at that temperature. Once these
parameters are all known, the actual temperature can be calculated from the following equation:
TEMPERATURE=temp_read-
1
/
2
LSB+
(count_per _degree - count_rema in)
count_per_ degree
A simple routine in C, called CalcHiResTemp, is given in the listing of Figure 7.
PROCEDURES FOR READING COUNTER VALUES AND CALCULATING
HIGH RESOLUTION TEMPERATURE READINGS
The following is a list of procedures for performing high resolution temperature readings from various
digital thermometers. For all parts, conversions must be done in oneshot mode (if applicable). XXh refers
to the protocol to send to the part; if two protocols are listed together (e.g., 84h A0h), both protocols
should be sent in the given order, without resetting the part between protocols. A variable name XXX is
designated as “named XXX.”
NOTE:
The high–resolution temperature equation is slightly different for the DS1821 as compared to the
DS1620, DS1623, DS1625, DS2434, and DS2435.
DS1620, DS1623, and DS1625:
1. Issue Start Convert protocol (EEh).
2. When conversion is finished, read 9–bit temperature value (AAh).
3. Truncate half–degree bit from reading.
4. Convert truncated value from 2’s complement to signed integer (named temp_read).
5. Read 9–bit counter value (A0h; named count_remain).
6. Send undocumented Load Counter protocol (41h).
7. Read 9–bit counter value (A0h; named count_per_degree).
3 of 20
APPLICATION NOTE 105
8. Calculate high–resolution temperature using the high resolution temperature equation given in the
previous section. �½ LSB = 0.25.
DS1621, DS1624, and DS1820:
The procedure to find the high resolution temperature parameters and the calculation to use are given in
the respective product data sheets for these products. Note that since the DS1624 already provides a 13–
bit number with 0.03125°C resolution, no further processing is possible to achieve any higher
temperature resolution.
DS1821:
1. Issue Start Convert protocol (EEh).
2. When conversion is finished, read 8–bit temperature value (AAh).
3. Convert value from 2’s complement to signed integer (named temp_read).
4. Read 9–bit counter value (A0h; named count_remain).
5. Send undocumented Load Counter protocol (41h).
6. Read 9–bit counter value (A0h; named count_per_degree).
7. Calculate high–resolution temperature using the high resolution temperature equation given in the
previous section. Note that for the DS1821, �½ LSB = 0.5.
DS2434 and DS2435:
1. Issue Start Convert protocol (D2h).
2. When conversion is finished, read 8–bit temperature value (B2h 61h).
3. Convert temperature value from 2’s complement to signed integer (named temp_read).
4. Read 9–bit counter value (84h A0h; named count_remain).
5. Send undocumented Load Counter protocol (84h 41h).
6. Read 9–bit counter value (84h A0h; named count_per_degree).
7. Calculate high–resolution temperature using the high resolution temperature equation given in the
previous section. �½ LSB = 0.25.
EXAMPLE C CODE
The following example is a simple exerciser for the DS1620 from an IBM–PC compatible computer. It
reads temperature and displays it in both the normal 0.5°C resolution and in high resolution. The DS1620
is inter-faced to the parallel port of the PC using the circuit shown in Figure 2, which is the schematic of
the DS1620K demo kit.
The hardware for the DS1620K demo kit “steals” power from a parallel port using D1, D2, D3, and C3.
Not all PC parallel ports are able to supply sufficient current to make this hardware work, so be advised
that if this circuit does not work, try connecting a +5V power source to the +5V line in this circuit and try
again. R1 and C1 serve to filter the CLK line and prevent negative under-shoots. Likewise, C2 helps
prevent negative under-shoot on the DQ line.
4 of 20
APPLICATION NOTE 105
The code is written in an attempt to make it easy to adapt to any of the digital temperature sensors. All
that needs to be done to use it with other devices is to change the command header file to account for the
protocols and resolution of the device being used, and change the files which manipulate the hardware
interface to the device to account for either 1, 2 or 3–wire interfaces.
DS1620K HARDWARE SCHEMATIC
Figure 2
5 of 20
Zgłoś jeśli naruszono regulamin