Analog Devices AN-395 Application Notes

AN-395
a
ONE TECHNOLOGY WAY • P.O. BOX 9106
Interfacing the AD22100 Temperature Sensor to a Low Cost
The AD22100 is a new monolithic silicon temperature sensor with several unique attributes. These attributes make it easier to interface the AD22100 to microcontrol­lers than other temperature sensor ICs. Available in both TO-92 and SOIC packages, the AD22100 features single-supply operation, the ability to measure negative temperatures without requiring a negative power sup­ply, and a voltage output that is ratiometric to its power supply, rather than to an absolute voltage.
Other IC temperature sensors rely on the physics of cer­tain silicon circuit topologies to measure temperature. In particular, the AD590, and its successors, make use of the temperature coefficient of the differential voltage between two silicon junctions (operating at different current densities) to produce an output that is propor­tional to absolute temperature. This kind of circuit, often called a PTAT circuit, is the basis of all IC temperature sensors prior to the AD22100.
Single-Chip Microcontroller
APPLICATION NOTE
NORWOOD, MASSACHUSETTS 02062-9106
by Norm Bernstein
measure temperatures in the device’s operating range. More importantly, the output is ratiometric to the power supply, which eliminates the requirement for a precision calibrated reference voltage in the measurement chain.
A simplified schematic of the AD22100 is shown in Fig­ure 1. The temperature sensing resistor is excited by a stable current source; since the temperature coefficient of the sensing resistor is linear, the output is therefore a voltage that is linear with respect to temperature.
V+
Ι
R
T
V
OUT
The PTAT circuit, however, suffers from several liabili­ties. Since the circuit “pivots” at absolute zero, it is nec­essary to suppress an offset term of 273 °C in order to make measurements at 0 °C. More importantly, PTAT circuits are calibrated in output voltages or currents that require a precision measurement with respect to a calibrated reference.
The AD22100 does not use a PTAT circuit as the basis of its measurement technique. Instead, the AD22100 uses the temperature coefficient of a carefully deposited thin film resistance, much like an RTD (Resistance Tempera­ture Detector), as the measuring element. By using this technique, the output of the circuit can be arranged such that there is no need to suppress a large offset term to
absolute
units, and produce
Figure 1. Simplified Schematic
The other resistors in the circuit serve to establish a particular output offset at a specified temperature and power supply voltage (+1.375 V at 0 °C with V+ = 5 V), and provide for a specified gain versus temperature at the output (22.5 mV per °C). Most importantly, the circuit configuration provides for ratiometricity; as the power supply voltage changes, the output will remain at the same ratio to the power supply voltage (assuming tem­perature is constant). This important attribute will be uti­lized in the interface example described in this applications note.
Interfacing the AD22100 to a Microcontroller
Since the output of an AD22100 is a voltage between 0 V and 5 V, an easy interface can be achieved by using a microcontroller with a built in A/D circuit. There are a number of such microcontrollers available on the mar­ket today, often with 8- or 10-bit resolution.
However, this approach, while certainly simple, is not without liabilities. Microcontrollers with built-in A/D capability are more expensive than the more ordinary varieties. They usually do not allow for true ratiometric operation (although a few provide for an external refer­ence input, allowing at least limited ratiometric opera­tion). Since they are usually based upon successive approximation architectures, they don’t provide integra­tion or normal mode rejection. Most importantly, 8 or 10 bits of A/D resolution is insufficient if the application requires 0.1 °C resolution at the output.
The A/D architecture described in this application note is well suited for extracting the best possible performance from the AD22100. Based largely on firmware within the microcontroller, this A/D offers the following attributes:
• true integrating A/D, fully ratiometric
• 14-bit resolution, produces 0.1°C resolution after scaling and calibration
• requires only 2 microcontroller I/O pins, and does not consume any counter-timer or interrupt resources
• uses digital calibration
V
IN
V
FB
C1
COMP
+V
Q1
R1
Q2
IN
MICRO-
CONTROLLER
OUT
Figure 2. Simplified A/D Schematic
In addition to modulating the pulse train density accord­ing to the comparator output signal, the microcontroller also keeps track of the density of the pulse train, as well as the total time duration of the conversion cycle, via the use of counter registers. The ratio of the pulse train den­sity to the total conversion time is proportional to the input voltage.
The A/D Conversion Firmware Loop
The A/D conversion process is controlled by a carefully designed firmware loop. The loop is described in the flowchart of Figure 3 below.
START
TOTAL –COUNT, OUTPUT–COUNT
INITIALIZE
REGISTERS
• extremely low cost
Furthermore, this A/D architecture can be adapted to a wide variety of microcontroller types, including the very low cost OTP (One Time Programmable) types. For the purposes of this application note, we will illustrate the circuit as implemented on an 80C51 Microcontroller (available from Intel Corporation as well as others).
The A/D Circuit
The A/D circuit employed for this application note is an integrating type that utilizes a very small kernel of code (44 bytes) to control the conversion process. A simplified schematic is shown in Figure 2. The input signal is continuously compared to a feedback voltage signal, which is generated by the microcontroller. The microcontroller creates this feedback signal by generat­ing a pulse train at the output pin whose density is pro­portional to the input signal. This pulse train is buffered by Q1 and Q2, and filtered by R1 and C1 to produce a linear voltage (the feedback voltage mentioned above). Whenever the microcontroller senses that the feedback voltage is less than the signal voltage, it increases the density of the output pulse train. In this fashion, the pulse train density is proportional to the input signal.
NO
CLEAR
DAC BIT
TOTAL–COUNT =
TOTAL–COUNT+1
(DELAY TO
EQUALIZE BRANCH
LENGTHS)
NO
IS SIGNAL VOLTAGE > FEEDBACK
VOLTAGE?
TERMINAL
COUNT
REACHED?
STOP
YES
SET
DAC BIT
TOTAL–COUNT =
TOTAL–COUNT+1
OUTPUT–COUNT =
OUTPUT–COUNT+1
YES
Figure 3. A/D Conversion Loop Flowchart
Referring to the flowchart in Figure 3, the conversion is started by initializing the registers storing the total count (used to count the total number of loop iterations) and the registers storing the output count, to zero. Each time
–2–
the loop is entered, the comparator output is tested: if it indicates that the signal voltage is less than the feedback voltage, the output bit (called the “DAC” bit, since it is essentially a one-bit DAC) is set so that the feedback volt­age will rise. If the comparator signal indicates that the signal voltage is greater than the feedback voltage, the DAC bit is cleared so that the feedback voltage will fall. Whenever the DAC bit is set, the output count register is incremented. Regardless of whether the DAC bit is set or
CONVERT:
MOV DPH,#0 ;the DPTR will be used to keep track MOV DPL,#0 ;of the total loop count, so clear it CLR A ;the ACC and B regs will store the raw
MOV B,A ;data, so clear them as well ; ; ; CVLOOP is the inner conversion loop, where the measurement actually ; takes place. In this example, we will loop 16384 times, for a 14 bit ; raw data result. The minimum loop time is 13 cycles, or 13 µs when ; running a 12 MHz clock, resulting in a conversion time of 212.992 ; milliseconds. ; CVLOOP:
JNB CVCMP,CVLOOP_UP ;test the comparator.. if it 2 cyc
CVLOOP_DOWN:
SETB CVFB ;going down, so set the bit... 1 cyc
NOP ; 1 cyc
NOP ;NOP’s equalize the time delays 1 cyc
INC DPTR ;increment the total loop count 2 cyc
SJMP CVLOOP_TEST ;now test for terminal count 2 cyc ; CVLOOP_UP:
CLR CVFB ;going up, so clear the bit.. 1 cyc
ADD A,#1 ;increment the raw data 1 cyc
XCH A,B ;overflow to the B register 1 cyc
ADDC A,#0 ; 1 cyc
XC A,B ;and restore them 1 cyc
INC DPTR ;increment the total loop count 2 cyc ; CVLOOP_TEST:
MOV BITTEST,DPH ;grab the upper byte of the dptr 2 cyc
JNB BITTEST.6,CVLOOP ;repeat until we overflow 14 bits 2 cyc ; ; The conversion is done; let’s leave the state of the feedback ; bit consistent to simplify the precharge process ;
CLR CVFB ; ; At this point, the B|A register pair has the raw data, scaled to ; 12 bits, and it is ratiometric to the power supply. ;
MOV RAWDAT,B ;store the result in RAWDAT
MOV RAWDAT+1,A
cleared, the total count is incremented, thereby keeping track of the number of iterations of the loop. The conver­sion cycle is complete when the loop has executed the desired number of iterations; in our example, the loop is iterated 16,384 times to achieve a 14-bit result.
The loop is carefully constructed so that, regardless of the result of the comparator test, it takes a fixed amount of time to execute. Figure 4 is a listing of the actual code
;is low, we need to go up
Figure 4. The Inner Conversion Loop Firmware
–3–
for the conversion loop, as used in the example project. The loop takes just 13 microseconds to execute (a 12 MHz crystal is used in this example, which results in 1 microsecond instruction cycles). If the terminal count criteria is set for 16,384 iterations, then the output count will be equivalent to a 14-bit conversion. Using these parameters, the total conversion cycle is 212.992 milli­seconds, which is more than fast enough for the vast majority of temperature measurement applications.
The choice of comparator can also affect circuit perfor­mance. In this architecture, the inputs of the comparator are operated in common mode over nearly the entire power supply range of the part. The limited CMRR (Common-Mode Rejection Ratio) of the comparator therefore affects the A/D converter linearity. In this ex­ample, the integral linearity error measured approxi­mately 0.03%; a comparator with better CMRR would reduce this error considerably.
+5V
AD22100
SENSOR
0.22µF
(MYLAR)
LM393P
2
3
+9V
330k
8
4,5,6
1
100
14
2
74HC04
3,5,7,9, 11,13
10k
1µF/35V
+
1
1
8
P1.0
87C51
P1.7
Figure 5. Schematic
With this type of converter architecture, it is easy to ad­just the parameters to trade off resolution for conver­sion speed. This can be done by changing the loop termination criteria. In our example, the loop terminates when there is an overflow out of 14 bits on the total count register, but we could easily modify this for any binary resolution.
Breadboard Circuit Description
The actual schematic of the breadboard constructed for this application note is shown in Figure 5. In place of the discrete FETs shown in the simplified schematic, we chose to use a 74HC04 Hex Inverter, which is quite inexpensive, is widely available, and works well in this application. The comparator used was an LM393 dual comparator (only one half was used), which is also quite inexpensive and widely available. Unfortunately, the LM393 requires a positive supply at least +1.5 volts higher than the highest input signal, forcing the use of a +9 volt power supply. It is possible to substitute a CMOS comparator with rail-to-rail input swing capability, thereby allowing the entire circuit to operate off +5 volts, but at a slightly greater expense. If the LM393 is chosen, the +9 volt supply could possibly be “stolen” from other portions of the actual application circuit, such as the charge pumps commonly used in TTL-to-RS232 con­verter chips.
The low-pass filter for the feedback circuit has a pole at approximately 2 Hz. This setting was chosen so that the ripple of the feedback voltage would be less than 1 LSB at the comparator input. This filter limits the bandwidth of the converter, and requires time to settle before the conversion cycle starts. Because of this, a “precharge” function is required (see “Precharging the Feedback Voltage”).
The power supply for the DAC buffer (the 74HC04) and the AD22100 is separately decoupled from the microcontroller power supply via the 100 series resis­tor and 1 µF shunt capacitor. This is done to minimize noise generated from the microcontroller clock and I/O functions.
Precharging the Feedback Voltage
This A/D converter design has a disadvantage in that the conversion only works properly if the feedback voltage is at (or at least very near) the input voltage at the start of the conversion cycle. When the conversion process is first started, this may not be the case.
There are a number of solutions to this problem, includ­ing the use of a hardware switch between the compara­tor inputs. The switch could be closed briefly to “precharge” the filter capacitor before the conversion cycle starts. This particular solution can’t be used with an AD22100 sensor, because the sensor output structure is configured as a current source with a weak pull-down resistor; “precharging” to a lower voltage would be very slow.
Another solution (and the one that was used in the breadboard for this applications article) is the use of a short “precharge” software loop which balances the comparator inputs just before starting the conversion cycle.
In an actual application, the precharge loop is necessary if the conversion rate is continuous.
–4–
Loading...
+ 8 hidden pages