AN897
fixed decimal point degrees Celsius value. The fixed
decimal point format reports degrees Celsius in tenths
of a degree. Performing the piece-wise linear interpola-
tion in tenths of a degree provides better resolution of
degrees Celsius. Finally, the 16-bit degrees Celsius
value is sent to the Signal Analysis PC Program for
display on the real-time strip chart graph.
0.0
-0.5
-1.0
-1.5
-2.0
-2.5
10-bit ADC
DC Error ≤ 3.5 LSb
In the final design, the designer can elect to report in
tenths of a degree or round up in whole degrees.
Design # 1
G = +1
RA = 10 kΩ
Start
-50 -25
0
25
50
75 100 125 150
Get Real Time Sample
Thermistor Temperature (°C)
FIGURE 6:
Resolution.
ADC’s Temperature
Read ADC
10
9
Perform PwLI
Design # 1
G = +1
RA = 10 k:
8
7
6
5
4
3
2
1
0
Send Temperature in
°C to Strip Chart
ADC Error
RA Error
PGA Error
End
FIGURE 8:
Flowchart for First Design.
-50 -25
0
25
50
75 100 125 150
PIECE-WISE LINEAR INTERPOLATION TABLE
Thermistor Temperature (°C)
A piece-wise linear interpolation table [9] is used to
convert ADC codes to estimated temperature. The
ADC’s codes were divided into 64 segments, with 16
codes per segment. The codes in the table are at end
points between segments. Table 1 shows the end
points chosen for this design.
FIGURE 7:
Analog Circuit Errors.
Digital Design
The PIC16F684 microcontroller (discussed in
Appendix A.2.5 “Signal Analysis PICtail Daughter
Board”) handles several important tasks. It communi-
cates with the PGA to set its input channel, can aver-
age the measured signal to reduce noise and converts
the result into the temperature at the thermistor using a
piece-wise linear interpolation table. The microcontrol-
ler can either have a SPI™ port built in or the SPI
interface can be implemented in software on the
microcontroller [7].
TABLE 1:
INTERPOLATION TABLE END
POINTS.
Gain
(V/V)
ADC Code
(LSb)
TTH
(°C)
RTH
(Ω)
VOUT
(V)
1
1008
16
-49.4
156.1
630 k
159
4.922
0.078
Values given for RTH, when the temperature is outside
the thermistor’s specified range (-40°C to +150°C), are
estimates only; they are not supported by actual data.
The thermistor self-heating error correction has been
included in Table 1.
FLOWCHART
The flowchart in Figure 8 shows the program flow for
the first design. The firmware is available in
00897.zip file in the Design 1 directory. The firmware
was written in relocatable assembly code. main.asm
controls the overall program flow. The PGA routines
are in pga.inc and pga.asm. The thermistor routines
The table’s entries go outside of the -40°C to +150°C
range to ensure proper functioning of the piece-wise
linear interpolation table when the reading overflows. In
this algorithm (Appendix A.2.6 “Firmware for the
Signal Analysis PICtail Daughter Board”), the table
values outside the valid range take on the nearest valid
value. This means that when ADC code > 1008, the
table returns a value of -49.3°C. When ADC code < 16,
the table returns a value of 156.1°C.
are
located
in
Therm_PGA1.inc
and
Therm_PGA1.asm.
The Signal Analysis PC Program commands the
PIC16F684 firmware to perform a real-time sample.
The firmware reads the ADC value and passes it to the
Piece-wise Linear Interpolation (PwLI) routine. The
PwLI routine converts the 10-bit ADC value into a 16-bit
2004 Microchip Technology Inc.
DS00897B-page 3