MICROCHIP AN897

AN897
Thermistor Temperature Sensing with MCP6SX2 PGAs
Key specifications include [1, 2]:
Kumen Blake and Steven Bible
Microchip Technology Inc.
INTRODUCTION
This application note shows two designs that use a
precise, negative temperature coefficient (NTC)
thermistor for temperature measurement. The
thermistor is placed in a resistive divider to linearize the
temperature-to-voltage conversion. The voltage is
processed in the analog domain by the MCP6SX2
(MCP6S22 or MCP6S92) Programmable Gain Amplifier
(PGA) before conversion to the digital domain.
The first design is simpler and has a smaller temperature range. The second design changes the PGA’s gain
to achieve a greater temperature range. Both designs
use a piece-wise linear interpolation table to correct the
remaining non-linearity and convert voltage into
degrees Celsius. The design trade-offs between these
approaches will be discussed.
These circuits take advantage of the MCP6SX2’s input
multiplexer (MUX). The PGA is used to process
multiple signals and/or temperatures and digitally sets
the most appropriate gain for each input. This reduces
overall design complexity and allows for temperature
correction of other sensors.
THERMISTOR
The thermistor used in the application note is part
number 2322 640 55103 from BC Components®; see
Figure 1 and Figure 2. This part is selected for its
accuracy and cost. The thermistor’s temperature is
TTH, while the rest of the circuit is at ambient
temperature TA.
1M
Thermistor Resistance (Ω)
1000000
BC Components®
# 2322 640 55103
10 kΩ @ +25˚C
100k
100000
10000
1k
1000
100
100
-25
0
25
50
75
100
125
Thermistor Temperature (˚C)
FIGURE 1:
Thermistor Response.
 2004 Microchip Technology Inc.
2.0
1.8
1.6
1.4
1.2
1.0
0.8
0.6
0.4
0.2
0.0
BC Components®
# 2322 640 55103
10 kΩ @ +25°C
-50
-25
0
25
50
75
100 125 150
Thermistor Temperature (°C)
FIGURE 2:
Thermistor Accuracy.
Thermistors with different price and accuracy trade-offs
may also be used in this application. It is simple to
modify the circuits to match the desired accuracy.
CIRCUIT
The circuit shown in Figure 3 is used for both designs
described later. It is implemented on the Thermistor
PGA PICtail™ Daughter Board (see Appendix A.1
“Thermistor PGA PICtail Daughter Board”).
The resistor RA makes the voltage vs. temperature
response reasonably linear. RB and CB reduce the
noise and act as an anti-aliasing filter for the ADC. The
MCP6SX2 PGA (MCP6S22 [5] or MCP6S92 [6])
buffers the voltage VDIV. The PGA can be digitally
controlled to change its gain or channel (input).
10k
-50
• Resistance at +25°C: 10 kΩ ± 1%
• B25/85 tolerance: ±0.75%
• Operating temperature range: -40°C to +125°C
(to +150°C for short periods)
• Maximum power
- 100 mW, TTH = 0°C to +55°C
- 100% de-rated at TTH = -40°C and +85°C
• Thermal dissipation factor: 2.2 mW/°C
• Response time: 1.7 s (in oil)
Thermistor Error Magnitude
(°C)
Author:
150
The PIC16F684 [8] is on the Signal Analysis PICtail™
Daughter Board (see Appendix A.2.5 “Signal Analysis PICtail Daughter Board”). It has an internal 10-bit
ADC that converts VOUT to the digital domain. It can further process VOUT (e.g., averaging) and convert it to
temperature. It communicates with the PGA via the
SPI™ serial bus.
DS00897B-page 1
AN897
VDD = 5.0V
RA
1%
VDIV
RTH
10 kΩ
VDD
VDD
MCP6SX2
PGA
RB
100 kΩ
CH0
CH1
VREF
CB
1 µF
PIC16F684
VOUT
VIN
10-bit
ADC
VREF
Firmware
3
Other Input
SPI™ Bus
Thermistor PGA Circuit.
The ADC’s voltage reference is powered from the
same voltage as the voltage divider, giving a ratiometric
circuit; errors in VDD will be automatically corrected at
the ADC.
FIRST DESIGN
This design emphasizes simplicity and uses a standard
approach to designing the thermistor circuit. The
traditional op amp is replaced with a PGA so that it can
multiplex multiple inputs.
Analog Design
VDIV = VOUT (V)
The first design keeps the PGA at a gain of +1 V/V for
design simplicity. The resistor RA is set to its nominal
+25°C value (10.0 kΩ) for best performance at room
temperature; this is a very common design choice.
While this is a simpler design, its accuracy is relatively
low, as will be seen. Notice that Figure 4 shows a much
more linear response than Figure 1.
5.0
4.5
4.0
3.5
3.0
2.5
2.0
1.5
1.0
0.5
0.0
Design # 1
G = +1
RA = 10 k:
The thermistor power dissipation causes a self-heating
temperature error. Calculating the thermistor’s power
dissipation across temperature, and then dividing by
the specified 2.2 mW/°C thermal dissipation factor,
gives the self-heating temperature error shown in
Figure 5. This is a small, consistent error. It is simple to
adjust for this error using the piece-wise linear
interpolation table in firmware.
0.30
Self-heating Error (°C)
FIGURE 3:
Design # 1
G = +1
RA = 10 k:
0.25
0.20
0.15
0.10
0.05
0.00
-50
-25
0
25
50
75
100
125
150
Thermistor Temperature (°C)
FIGURE 5:
Error.
Thermistor Self-heating
Analog Error Analysis
Figure 6 displays the ADC’s temperature resolution,
while Figure 7 shows the expected worst-case analog
circuit errors. Both plots are based on these
assumptions:
-50
-25
0
25
50
75
100
125
150
Thermistor Temperature (°C)
FIGURE 4:
Outputs.
Voltage Divider and PGA
Temperatures between +125°C and +150°C can be
included in the design for overtemperature indication
where accuracy is not as important.
DS00897B-page 2
• ADC’s DC Error ≤ ±3.5 LSb
• PGA’s gain error ≤ ±0.1% (G = +1)
• PGA’s input offset error ≤ ±1 mV (including PSRR
and temperature drift)
• Specified thermistor accuracy
This design achieves an ADC temperature resolution of
0.25°C over the -25°C to +73°C temperature range.
The analog circuit accuracy is better than 1.2°C over
the same range. Other temperature ranges will have
different resolutions and accuracies.
 2004 Microchip Technology Inc.
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 interpolation 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.
ADC Temperature Resolution
(°C/LSb)
0.0
10-bit ADC
DC Error ≤ 3.5 LSb
-0.5
-1.0
-1.5
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Ω
-2.0
-2.5
-50
-25
0
25
50
75
Start
Get Real Time Sample
100 125 150
Thermistor Temperature (°C)
Analog Circuit Errors
Magnitude (°C)
FIGURE 6:
Resolution.
10
9
8
7
6
5
4
3
2
1
0
ADC’s Temperature
Read ADC
Perform PwLI
Design # 1
G = +1
RA = 10 k:
Send Temperature in
°C to Strip Chart
ADC Error
RA Error
PGA Error
End
FIGURE 8:
-50
-25
0
25
50
75
100
125
150
Thermistor Temperature (°C)
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 communicates with the PGA to set its input channel, can average the measured signal to reduce noise and converts
the result into the temperature at the thermistor using a
piece-wise linear interpolation table. The microcontroller can either have a SPI™ port built in or the SPI
interface can be implemented in software on the
microcontroller [7].
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
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.
Flowchart for First Design.
PIECE-WISE LINEAR INTERPOLATION TABLE
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.
TABLE 1:
INTERPOLATION TABLE END
POINTS.
Gain
(V/V)
ADC Code
(LSb)
TTH
(°C)
RTH
(Ω)
VOUT
(V)
1
1008
-49.4
630 k
4.922
16
156.1
159
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.
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.
DS00897B-page 3
AN897
1.0
0.8
0.6
0.4
0.2
0.0
-0.2
-0.4
-0.6
-0.8
-1.0
Design # 1
5.0
4.5
4.0
3.5
3.0
2.5
2.0
1.5
1.0
0.5
0.0
Design # 2
RA = 28.0 k:
-50
-25
0
25
50
75 100 125
Thermistor Temperature (°C)
FIGURE 10:
150
Voltage Divider Output.
Temperatures between +125°C and +150°C can be
included in the design for overtemperature indication
when accuracy is not as important.
-50
-25
0
25
50
75
100
125
150
Thermistor Temperature (°C)
FIGURE 9:
Piece-wise Linear
Interpolation Error, Design # 1.
The digital roundoff error will be roughly proportional to
the ADC temperature resolution curve’s envelope (see
Figure 6). If the roundoff error is much less than the
ADC resolution, this error will have little impact.
The total digital error includes both the piece-wise
linear interpolation error and the round-off error.
SECOND DESIGN
This design emphasizes accuracy and resolution. It
uses the PGA’s capability to change gain to overcome
the limitations of the first design. The PGA can
multiplex multiple inputs if needed.
The thermistor power dissipation causes a self-heating
temperature error. Calculating the thermistor’s power
dissipation across temperature, and then dividing by
the specified 2.2 mW/°C thermal dissipation factor,
gives the self-heating temperature error shown in
Figure 11. This is a small, consistent error. It is simple
to adjust for this error using the piece-wise linear
interpolation table in firmware.
0.12
Self-heating Error (°C)
Interpolation Error (°C)
Figure 9 shows the estimated interpolation error for the
interpolation table. This design suffers from poor ADC
resolution at temperature extremes. The accuracy of
this piece-wise linear interpolation table is 0.05°C over
the -25°C to +73°C temperature range. Over the -40°C
to +150°C temperature range, the accuracy degrades
to 1.0°C.
VDIV (V)
Digital Error Analysis
Design # 2
RA = 28.0 k:
0.10
0.08
0.06
0.04
0.02
0.00
-50
-25
0
25
50
75
100 125 150
Thermistor Temperature (°C)
Analog Design
The second design changes the PGA’s gain from +1 to
+8 to +32 V/V. The resistor RA is set to 28.0 kΩ so that
the voltage vs. temperature response is reasonably
linear at low temperatures; see Figure 10 (compare to
Figure 4). The response is nearly flat at higher temperatures, so the PGA’s gain will be increased to compensate. Though this is a more complex design, its
resolution and accuracy are greater than the first
design’s.
DS00897B-page 4
FIGURE 11:
Error.
Thermistor Self-heating
PGA Gain
The sensitivity that VDIV shows to temperature
(Figure 10) is poor at higher temperatures. It is intentionally designed this way so that the PGA can be set
at higher gains as temperature increases (Figure 12).
 2004 Microchip Technology Inc.
AN897
G = +8
Design # 2
RA = 28.0 k:
-50
-25
G = +32
Hysteresis
0
25
50
75 100 125
Thermistor Temperature (°C)
FIGURE 12:
150
PGA Output Voltage.
The gain change points were chosen to make the
ADC’s resolution as good as possible (see Figure 13)
at a reasonable cost. The number of gains was kept
low to minimize the piece-wise linear interpolation
table’s size in firmware.
The maximum voltage allowed in each range is 300 mV
from VDD. This keeps the PGA in its specified output
range and allows some headroom for noise. The
minimum voltage allowed is well above 300 mV from
ground, which keeps the PGA in its most linear region
of operation.
Random noise can make the PGA’s gain change
frequently. Adding hysteresis to the gain-selection
algorithm (in firmware) reduces this problem. The
hysteresis needs to be large enough to compensate for
the PGA’s maximum gain error (±1%).
Figure 12 and Table 2 show a hysteresis of 1.7°C and
2.0°C at the lower temperature and higher temperature
transistions, respectively. The gain-change points are
separated by 6% of VDIV, which is six times larger than
the PGA’s maximum gain error; this ensures proper
functioning of the gain-change algorithm. The
thermistor self-heating error has been corrected in
Table 2.
TABLE 2:
PGA GAIN-CHANGE POINTS
WITH HYSTERESIS.
Gain
(V/V)
Gain
Change
(V/V)
ADC Code
(LSb)
VDIV
(V)
TTH
(°C)
1
1→8
< 113
0.552
50.9
8
8→1
> 960
0.586
49.2
8 → 32
< 226
0.138
94.6
32 → 8
> 960
0.146
92.6
32
 2004 Microchip Technology Inc.
Figure 13 displays the ADC’s temperature resolution
and Figure 14 shows the expected worst-case analog
circuit errors. Both plots are based on these
assumptions:
• ADC’s DC Error ≤ ±3.5 LSb
• PGA’s gain error ≤ ±1% (±0.1% at G = +1)
• PGA’s input offset error ≤ ±1 mV (including PSRR
and temperature drift)
• Specified thermistor accuracy
This design achieves an ADC temperature resolution of
0.27°C over the -40°C to +150°C temperature range.
The analog circuit accuracy is better than 3.0°C over
the same range. Other temperature ranges will have
different resolutions and accuracies.
0.00
ADC Temperature Resolution
(°C/LSb)
G = +1
Design # 2
RA = 28.0 kΩ
-0.05
-0.10
-0.15
-0.20
-0.25
10-bit ADC
DC Error ≤ 3.5 LSb
-0.30
-50
-25
0
25
50
75
100 125 150
Thermistor Temperature (°C)
FIGURE 13:
Resolution.
Analog Circuit Error
Magnitude (°C)
VOUT (V)
Analog Error Analysis
5.0
4.5
4.0
3.5
3.0
2.5
2.0
1.5
1.0
0.5
0.0
2.0
1.8
1.6
1.4
1.2
1.0
0.8
0.6
0.4
0.2
0.0
ADC’s Temperature
Design # 2
RA = 28.0 k:
PGA Error
ADC Error
RA Error
-50
-25
0
25
50
75
100 125 150
Thermistor Temperature (°C)
FIGURE 14:
Analog Circuit Errors.
Digital Design
The PIC16F684 microcontroller (Appendix A.2.5
“Signal Analysis PICtail Daughter Board”) handles
several important tasks. It communicates with the PGA
to set its gain and input channel, can provide averaging
to reduce the noise and converts the result into the temperature at the thermistor using a piece-wise linear
interpolation table. The microcontroller can have either
a SPI port built in or the SPI interface can be
implemented in software on the microcontroller [7].
DS00897B-page 5
AN897
FLOWCHARTS
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
PGA hysteresis routine. Figure 16 shows the detail of
the PGA hysteresis routine. The routine checks to see
what PGA gain is set (the variable “PGAgain”). Based
on PGAgain, the ADC value is tested for end-point
(trip) values. If the ADC value is beyond the trip point
value, PGAgain is set to the next higher or lower gain
setting. Upon exiting the PGA hysteresis routine, the
firmware checks if PGAgain was changed. If there was
no change (Return 0), the program continues. If there
was a change (Return 1), the firmware re-reads the
ADC.
The second design’s flowchart is shown in Figure 15. It
is very similar to the first design program, with the
exception that it has added a PGA hysteresis routine.
The firmware is available in the 00897.zip file. The
firmware was written in relocatable assembly code.
The main.asm file controls the overall program flow.
The PGA routines are in pga.inc and pga.asm. The
thermistor routines are in Therm_PGA2.inc and
Therm_PGA2.asm.
Start
Get Real Time Sample
Once the PGA gain and ADC value are known, both
values are passed to the piece-wise linear interpolation
routine. Based on the PGA gain setting, the correct
look-up table is referenced. The PwLI routine converts
the 10-bit ADC value into a 16-bit fixed decimal point
degrees Celsius value. The fixed decimal point format
reports degrees Celsius in tenths of a degree.
Performing the piece-wise linear interpolation 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.
Read ADC
PGA Hysteresis
Was PGAgain
Changed?
Yes
No
Perform PwLI
In the final design, the designer can elect to receive
reports in tenths of a degree or that they be rounded up
into whole degrees.
Send °C to Strip Chart
End
FIGURE 15:
Design.
Flowchart for Second
PGA Hysteresis
IF
PGAgain = 1
Y
IF
PGAadc < 113
Set PGAgain = 8
Y
N
N
IF
PGAadc < 226
IF
PGAgain = 8
Y
Set PGAgain = 32
Y
N
N
IF
PGAadc > 960
Set PGAgain = 1
Y
N
IF
PGAgain = 32
N
FIGURE 16:
DS00897B-page 6
Y
IF
PGAadc > 960
N
Set PGAgain = 8
Y
Return 0
Return 1
Flowchart for Second Design’s PGA Hysteresis Subroutine.
 2004 Microchip Technology Inc.
AN897
PIECE-WISE LINEAR INTERPOLATION TABLE
TABLE 3:
INTERPOLATION TABLE END
POINTS.
Gain
(V/V)
ADC Code
(LSb)
TTH
(°C)
RTH
(Ω)
VOUT
(V)
1
960
-43.5
420k
4.688
112
51.2
3.44k
0.547
8
960
49.2
3.72k
4.688
224
94.9
787
1.094
32
960
92.6
845
4.688
208
150.9
179
1.016
Values of TTH and RTH beyond the specified temperature range of the thermistor (-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 3.
The table’s entries go outside of -40°C to +150°C 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 G = 1 and ADC code > 960, the
table returns a value of -43.5°C. When G = 32 and
ADC code < 208, the table returns a value of 150.9°C.
The other table entries beyond the end points in Table 3
(e.g., near gain-change points) are zero because the
hysteresis algorithm will prevent them from being read.
This approach has been used for readability.
Digital Error Analysis
Figure 17 shows the estimated interpolation error for
the interpolation table. Changing the PGA’s gain takes
full advantage of the ADC’s resolution. The accuracy of
this piece-wise linear interpolation table is 0.034°C
over the -40°C to +150°C temperature range. The
improved ADC temperature resolution makes this
design’s piece-wise linear interpolation table behave
much better than the first design’s.
 2004 Microchip Technology Inc.
Interpolation Error (°C)
0.04
Design # 2
0.03
0.02
0.01
0.00
-0.01
-0.02
-0.03
-0.04
-50
-25
0
25
50
75
100
125
150
Thermistor Temperature (°C)
FIGURE 17:
Piece-wise Linear
Interpolation Error, Design # 2.
The digital roundoff error will be roughly proportional to
the ADC temperature resolution curve’s envelope (see
Figure 13). If the roundoff error is much less than the
ADC resolution, this error will have little impact.
The total digital error includes both the piece-wise linear interpolation error and round-off error.
DESIGN COMPARISON
Figure 18 shows the thermistor’s specified accuracy. It
contributes the same error to both designs.
Thermistor Error
Magnitude (°C)
Each of the three gains uses a piece-wise linear interpolation table [9] to convert ADC codes to estimated
temperature. Within each table, the ADC’s codes were
divided into 64 segments, with 16 codes per segment.
The tables only include those ADC codes at the end
points between segments. Table 3 shows the extreme
valid table entries for each of the three tables.
2.0
1.8
1.6
1.4
1.2
1.0
0.8
0.6
0.4
0.2
0.0
BC Components®
# 2322 640 55103
10 kΩ @ +25°C
-50
-25
0
25
50
75
100 125 150
Thermistor Temperature (°C)
FIGURE 18:
Thermistor Accuracy.
Figure 19 compares the ADC temperature resolution
between the first and second design. The second
design is better because changing the PGA’s gain
helps improve the ADC temperature resolution.
DS00897B-page 7
Figure 22 compares the total errors (thermistor plus
circuit plus piece-wise linear interpolation) of the first
and second designs. The digital roundoff error has
been excluded for simplicity.
0.0
-0.5
2nd Design
1st Design
-1.0
12
11
10
9
8
7
6
5
4
3
2
1
0
-1.5
-2.0
10-bit ADC
DC Error ≤ 3.5 LSb
-2.5
-50
-25
0
25
50
75
100 125 150
Thermistor Temperature (°C)
FIGURE 19:
Resolution.
Total Design Error
Magnitude (°C)
ADC Temperature Resolution
(°C/LSb)
AN897
ADC Temperature
1st Design
2nd Design
-50
Figure 20 compares the analog circuit errors between
the designs. The second design’s error is better at high
temperatures because the ADC’s temperature resolution is better. It is also better at low temperatures
because RA has been selected to linearize the
temperature-to-voltage conversion there.
-25
FIGURE 22:
Analog Circuit Error
Magnitude (°C)
Design # 1
Design # 2
50
75
25
50
75
100
125
150
Thermistor Temperature (°C)
FIGURE 20:
Comparison.
Analog Circuit Error
The digital piece-wise linear interpolation errors are
compared in Figure 21. The second design has much
better performance because the linear interpolation
table segments cover smaller changes in temperature.
150
Criteria
First
Design
Temperature Range
Medium
High
Low
High
Firmware Size
0
125
TRADE-OFFS.
Discontinuity at gain changes
-25
100
Total Error Comparison.
Temperature Accuracy
-50
Second
Design
—
±0.3°C
Low
Medium
MEASURED RESULTS
Both designs were measured on the bench. The
thermistor was emulated with the variable resistor Rvar
on the board shown in Appendix A.1 “Thermistor
PGA PICtail Daughter Board”. The ADC outputs were
converted to estimated thermistor temperatures using
nominal resistor values. Figure 23 shows the first
design’s measured error, while Figure 24 shows the
second design’s measured error.
4
1.0
0.8
0.6
0.4
0.2
0.0
-0.2
-0.4
-0.6
-0.8
-1.0
3
Design # 1
Design # 2
Measured Error (°C)
Interpolation Error (°C)
25
Other trade-offs between the two designs are
summarized in Table 4.
TABLE 4:
11
10
9
8
7
6
5
4
3
2
1
0
0
Thermistor Temperature (°C)
Design # 1
Thermistor Emulator, Rvar
2
1
0
-1
-2
-3
-4
-50
-25
0
25
50
75
100
125
150
-50
-25
Thermistor Temperature (°C)
FIGURE 21:
Comparison.
DS00897B-page 8
Digital Interpolation Error
0
25
50
75
100
125
150
Thermistor Temperature (°C)
FIGURE 23:
Design # 1.
Measured Errors,
 2004 Microchip Technology Inc.
AN897
Measured Error (°C)
Other Gains
0.5
0.4
0.3
0.2
0.1
0.0
-0.1
-0.2
-0.3
-0.4
-0.5
The second design can be done with other gains.
Increasing the number of gains has the drawback of
needing more piece-wise linear interpolation tables,
increasing the firmware size.
Design # 2
Thermistor Emulator, Rvar
G = +1
-50
-25
0
25
G = +8
50
75
G = +32
100
125
150
Thermistor Temperature (°C)
FIGURE 24:
Design # 2.
Measured Errors,
Note that it was necessary to add a resistor in series
with Rvar at high temperatures in order to have 5°C
spacing between data points.
Both Figure 23 and Figure 24 agree with the design
results; the second design has much better performance. The 1% resistors in Rvar will give roughly the
same error as the thermistor.
The thermistor was then used to measure room temperature using Design # 2. The result was ADC code
281 with a gain of +1, which corresponds to 23.7°C
(74.7°F).
Adding a gain(s) between +1 and +8 increases the
ADC resolution. The decrease in gain accuracy (from
0.1% at G = +1 to 1% at G ≥ +2) reduces the overall
accuracy, especially at a gain of +2. The tradeoffs
depend on the design specifics.
Adding a gain between +8 and +32 improves both the
accuracy and the ADC resolution at higher
temperatures. The choice of +16 is a good one.
Removing the gain of +32 may be attractive for designs
that reach a reduced temperature range (e.g., +125°C).
Changing the gain of +32 to +16, instead of removing
it, is one compromise.
When the gains are related by a common multiplier, the
hysteresis algorithm is simplified. When G = 1, 2, 4, 8,
16, and 32, the multiplier is 2. When G = 1, 4 and 16,
the multiplier is 4. The gain increases all occur at one
ADC code, while the gain decreases all occur at
another ADC code. Thus, the hysteresis algorithm only
has to compare the ADC code to two code values and
change the gain based on the result.
More Input Channels
DESIGN ALTERNATIVES
The references in this application note include information on other design approaches. AN685 [3] covers
more traditional application circuits using thermistors.
AN867 [4] shows an alternative thermistor circuit using
the PGA; it has greater flexibility, but increased design
cost and complexity.
The following sections discuss modifications to the
designs in this application note.
Increased Accuracy
In order to achieve greater accuracy, the analog
components need to be more precise. 12-bit ADCs,
(e.g., the MCP3201) will increase the resolution. A
0.1% tolerance resistor for RA will reduce the circuit
error.
Calibrating the thermistor [1, 2] will cancel most of its
variation over process. It may be beneficial to also
calibrate the circuit. This will increase firmware
complexity and execution time on the microcontroller
unless the corrections are included in the linear
interpolation table(s).
The piece-wise linear interpolation table may need
more entries, especially for the first design. The calculations will require more precision, which results in
slower processing time.
 2004 Microchip Technology Inc.
When more than two inputs (including other temperature sensors) need to be multiplexed into the ADC, the
6-channel MCP6S26 and the 8-channel MCP6S28
PGAs provide additional channels. The thermistor
input can be used to correct other sensors, such as
humidity sensors.
Op Amp Buffer
The MCP6SX2 PGA, shown in Figure 3, can be
replaced with a unity-gain buffer; Microchip’s MCP6001
op amp would be a good choice. The advantages
include simplicity and cost. The disadvantages are the
inability to multiplex multiple input signals and the
improvement in ADC temperature resolution due to
changing the PGA’s gain.
Remote Thermistor Issues
Thermistors that are located remotely from the PGA
(e.g., not on the same PCB) may require design
changes. Possible issues include:
•
•
•
•
Shielding sensor pickup wires
EMI filtering and protection
Wiring resistance voltage drop
Mismatch between thermistor ground and PCB
ground
DS00897B-page 9
AN897
SUMMARY
REFERENCES
Two different circuit designs using the MCP6SX2 PGA
and an accurate NTC thermistor have been shown.
The two designs trade off simplicity, accuracy and
temperature range.
[1]
“2322 640 5... : NTC thermistors, accuracy line,”
Product Data Sheet, BC Components®,
September 27, 2001
(www.bccomponents.com).
The first design is easier to implement, but has a
smaller temperature range. It can be made more
accurate, or cover a wider temperature range, with
more expensive components and analog design effort.
[2]
“Introduction to NTCs: NTC Thermistors,” Data
Sheet, BC Components, March 27, 2001
(www.bccomponents.com).
[3]
AN685, “Thermistors in Single-Supply
Temperature Sensing Circuits,” Bonnie C.
Baker; Microchip Technology Inc., DS00685,
1999.
[4]
AN867, “Temperature Sensing with a
Programmable Gain Amplifier,” Bonnie C.
Baker; Microchip Technology Inc., DS00867,
2003.
[5]
MCP6S21/2/6/8 Data Sheet, “Single-Ended,
Rail-to-Rail I/O, Low-Gain PGA,” Microchip
Technology Inc., DS21117, 2003.
[6]
MCP6S91/2/3 Data Sheet, “Single-Ended,
Rail-to-Rail I/O, Low-Gain PGA,”
Microchip Technology Inc., DS21908, 2004.
[7]
AN248, “Interfacing MCP6S2X PGAs to
PICmicro® Microcontroller,” Ezana Haile;
Microchip Technology Inc., DS00248, 2003.
[8]
PIC16F684 Data Sheet, “14-Pin Flash-Based,
8-Bit MOS Microcontrollers with nanoWatt
Technology,” Microchip Technology Inc.,
DS41202, 2004.
[9]
AN942, “Piecewise Linear Interpolation on
PIC12/14/16 Series Microcontrollers,” John Day
and Steven Bible; Microchip Technology Inc.,
2004.
[10]
“PICkit™ 1 Flash Starter Kit User’s Guide,”
Microchip Technology Inc., DS40051, 2004.
[11]
“Signal Analysis PICtail™ Daughter Board
User’s Guide,” Microchip Technology Inc.,
DS51476, 2004.
[12]
“Thermistor PGA PICtail™ Daughter Board
User’s Guide,” Microchip Technology Inc.,
DS51517, 2004.
While the second design’s firmware takes more space
in firmware, the analog design is very reasonable. It
takes advantage of the PGA’s flexibility and digital
control to reduce the analog errors and increase the
temperature resolution.
The MCP6SX2 PGA’s input MUX and digitallycontrolled gain significantly increase the utility of these
circuits. Multiple sensors and/or input signals can be
processed with one PGA, reducing component count.
It also makes it easier to perform temperature correction on other sensors. The marginal cost of the NTC
thermistor circuits is reasonable in this case.
DS00897B-page 10
 2004 Microchip Technology Inc.
AN897
APPENDIX A:
A.1
SET-UP OVERVIEW
Thermistor PGA PICtail Daughter
Board
The Thermistor PGA PICtail Daughter Board contains
the analog circuitry represented in Figure A-1. The
thermistor converts its temperature to a resistance. The
voltage divider then converts that resistance to voltage
and sends it to the CH0 input of the PGA. The PGA
gains and buffers this voltage and sends it off-board.
Board power is applied at the +5V and GND inputs. The
SPI™ bus makes it possible to control the PGA; its gain
and input channel can be set as desired from the
software.
Thermistor PGA
PICtail™ Daughter Board
Temperature
GND
Test Point
Figure A-2 shows the block diagram of the hardware
and software tools that the Thermistor PGA PICtail™
Daughter Board is designed to work with. More
information on these tools can be found in the
“References” section.
Hardware
Software
PICkit 1 Signal Analysis
PC Program
PC
USB
PICkit 1
Firmware
PICkit™ 1
Flash Starter Kit
Signal Analysis
PICtail Daughter Board
PICA2Dlab.hex
Firmware
14
+5V
Voltage
Divider
CH0 Input
Test Point
CH1 Input
Test Point
Associated Tools
14
Thermistor
+5V
Test Point
A.2
GND
4
PGA
MCP6S22
Thermistor PGA
PICtail™ Daughter Board
FIGURE A-2:
Diagram.
Measurement Setup Block
SPI™ Bus
VOUT
FIGURE A-1:
Thermistor PGA PICtail™
Daughter Board Block Diagram.
The test points make it easier to test key points in the
circuit, change the input signals and to use this board
as a stand-alone board.
• GND Test Point – Connected to the ground plane
and is a convenient ground point for any lab
equipment
• +5V Test Point – Allows measurement of the
positive supply voltage and provides a means to
power this board with a laboratory power supply
• CH0 Test Point – The place to measure the voltage divider’s output (also the PGA’s CH0 input)
• CH1 Test Point – Makes it possible to send any
desired signal to the PGA
More detail on setting up this demonstration board can
be found in the “Thermistor PGA PICtail™ Daughter
Board User’s Guide” [12].
 2004 Microchip Technology Inc.
DS00897B-page 11
AN897
An exploded view of how the different boards connect
is shown in Figure A-3.
Thermistor PGA
PICtail™ Daughter Board
Signal Analysis
PICtail™ Daughter Board
USB Cable
Expansion
Header (J3)
Remove PICmicro® MCU from
Evaluation Socket
PICkit™ 1 Flash Starter Kit
PIC16C745 Firmware
Version 2.0.2 or later
FIGURE A-3:
A.2.1
Board Connections.
PC PLATFORM
The Personal Computer (PC) shown in Figure A-2
needs to run on Windows® 98 SE or later. It provides a
convenient interface for the user, communicates with
the other boards, and provides power through the USB
connection.
A.2.2
PICkit™ 1 SIGNAL ANALYSIS PC
PROGRAM
The PICkit™ 1 Signal Analysis PC Program programs
the PIC16F684 PICmicro® microcontroller on the
Signal Analysis PICtail Daughter Board through the
USB port on the PICkit 1 Flash Starter Kit. It also
imports data through the same connection and displays
the data in Strip Chart, histogram, FFT plot and
oscilloscope plot formats. Data can be output in CSV
format for importing into a spreadsheet program.
A.2.3
A.2.4
PICkit 1 FIRMWARE
This software resides on the PICkit 1 Flash Starter Kit’s
PIC16C745 microcontroller. Use version 2.0.2 or later.
A.2.5
SIGNAL ANALYSIS PICtail
DAUGHTER BOARD
This board is Microchip Development Tool AC164120.
It connects to the PICkit 1 Flash Starter Kit, which it
uses for both power and as a communications link to
the PC. The on-board PIC16F684 has a 10-bit ADC
that converts the Thermistor PGA PICtail Daughter
Board’s output voltage. The results are temporarily
stored on the board’s 25LC640 serial EEPROM chips.
The +5V single-supply voltage from the PICkit 1 Flash
Starter Kit board is bypassed with a bulk 1 µF capacitor
and local 0.1 µF capacitors for each IC.
PICkit 1 FLASH STARTER KIT
The PICkit 1 Flash Starter Kit (DV164101) programs
PICmicro microcontrollers. It uses the PIC16C745’s
USB port to communicate with the PICkit 1 Signal
Analysis PC Program. It connects to the Signal
Analysis PICtail Daughter Board via a header (see
Figure A-3).
This board provides a single +5V supply voltage for the
daughter boards. It can drive up to 5 µF on the supply;
a larger capacitance may interfere with program timing.
DS00897B-page 12
 2004 Microchip Technology Inc.
AN897
A.2.6
FIRMWARE FOR THE SIGNAL
ANALYSIS PICtail DAUGHTER
BOARD
Therm_PGA2.hex implements the second design. It
supports the PICkit 1 Signal Analysis PC Program, but
with reduced functionality; its output can be viewed on
the strip chart only. The results need to be manually
converted to temperatures (codes 0 to 1023 convert to
0.0°C to 102.3°C).
PICA2Dlab.hex is the standard file that supports the
PICkit™ 1 Signal Analysis PC Program. The PGA and
10-bit ADC configuration are selected in the Signal
Analysis PC Program and written to the PIC16F684.
The PIC16F684 then sends the command(s) over the
SPI bus to the PGA.
A.2.7
A more detailed look at how the Thermistor PGA PICtail
Daughter Board interfaces with the other boards is
shown in Figure A-4.
Therm_PGA1.hex implements the first design. It
supports the PICkit 1 Signal Analysis PC Program, but
with reduced functionality; its output can be viewed on
the strip chart only. The results need to be manually
converted to temperatures (codes 0 to 1023 convert to
0.0°C to 102.3°C).
Thermistor PGA
PICtail™ Daughter Board
Temperature
INTERFACE DETAILS
Signal Analysis
PICtail™ Daughter Board
PICkit™ 1
Flash Starter Kit
Thermistor
+5V
Test Point
GND
Test Point
Voltage
Divider
GND
4
+5V
GND
SPI™ Bus
CH0 Input
Test Point
CH1 Input
Test Point
Serial
EEPROM
+5V
4
PGA
MCP6S22
SPI Bus
PIC16F684
2
PIC16F745
USB
to PC
ADC
VOUT
FIGURE A-4:
Detailed Interface Diagram.
 2004 Microchip Technology Inc.
DS00897B-page 13
AN897
APPENDIX B:
THERMISTOR MODEL
The nominal response of the 2322 640 55103
thermistor [1] is shown in Table B-1.
The data in Table B-1 was fit to the following sets of
equations. These equations make it possible to
accurately interpolate values between the table entries,
thus making the designs easier to evaluate.
TABLE B-1:
EQUATION B-1:
NOMINAL THERMISTOR
RESPONSE.
Resistance-to-Temperature Equations:
X = ln(RTH / 1Ω)
z = XSC (X – XCTR)
T0
– T25
TTH ≈
1 + z(A1 + z(A2 + z(A3)))
Thermistor
Temperature (°C)
Thermistor
Resistance (Ω)
-40
332.1 k
-35
240.0 k
-30
175.2 k
-25
129.3 k
-20
96.36 k
-15
72.50 k
-10
55.05 k
-5
42.16 k
0
32.56 k
5
25.34 k
10
19.87 k
15
15.70 k
20
12.49 k
25
10.00 k
30
8.059 k
35
6.535 k
40
5.330 k
z = YSC (Y – YCTR)
45
4.372 k
X ≈ B0 + z(B1 + z(B2 + z(B3)))
50
3.606 k
55
2.989 k
RTH = (1 Ω) eX
60
2.490 k
65
2.084 k
70
1.753 k
75
1.481 k
80
1.256 k
85
1.070 k
90
915.4
95
786.0
100
677.3
105
585.8
110
508.3
115
442.6
120
386.6
125
338.7
130
297.7
135
262.4
140
231.9
145
205.5
150
182.6
DS00897B-page 14
where:
182.6 Ω ≤ RTH ≤ 332.1 kΩ
XSC = -0.266457
XCTR = 8.960245
T0 = 303.960°C
A1 = -0.291639
A2 = 0.010993
A3 = -0.001042
T25 = 273.150°C
EQUATION B-2:
Temperature-to-Resistance Equations:
Y=
1
TTH + T25
where:
-40°C ≤ TTH ≤ +150°C
T25 = 273.150°C
YSC = -1038.499°C
YCTR = 0.003326156 °C-1
B0 = 9.101806
B1 = -3.756408
B2 = -0.141435
B3 = 0.003396
The piece-wise linear interpolation tables also need
values outside of the valid range of Table B-1. These
values are only used for convenience in setting up the
interpolation tables and firmware routine; they are not
based on actual data. While the above equations are
not valid outside of the given ranges, they are good
enough to support the interpolation algorithm.
Both sets of equations are based on a min-max
polynomial fit on the normalized variable z. It is more
difficult to achieve an accurate fit to the data using the
variables X and Y.
 2004 Microchip Technology Inc.
Note the following details of the code protection feature on Microchip devices:
•
Microchip products meet the specification contained in their particular Microchip Data Sheet.
•
Microchip believes that its family of products is one of the most secure families of its kind on the market today, when used in the
intended manner and under normal conditions.
•
There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our
knowledge, require using the Microchip products in a manner outside the operating specifications contained in Microchip’s Data
Sheets. Most likely, the person doing so is engaged in theft of intellectual property.
•
Microchip is willing to work with the customer who is concerned about the integrity of their code.
•
Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not
mean that we are guaranteeing the product as “unbreakable.”
Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of our
products. Attempts to break Microchip’s code protection feature may be a violation of the Digital Millennium Copyright Act. If such acts
allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that Act.
Information contained in this publication regarding device
applications and the like is provided only for your convenience
and may be superseded by updates. It is your responsibility to
ensure that your application meets with your specifications.
MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED,
WRITTEN OR ORAL, STATUTORY OR OTHERWISE,
RELATED TO THE INFORMATION, INCLUDING BUT NOT
LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE,
MERCHANTABILITY OR FITNESS FOR PURPOSE.
Microchip disclaims all liability arising from this information and
its use. Use of Microchip’s products as critical components in
life support systems is not authorized except with express
written approval by Microchip. No licenses are conveyed,
implicitly or otherwise, under any Microchip intellectual property
rights.
Trademarks
The Microchip name and logo, the Microchip logo, Accuron,
dsPIC, KEELOQ, microID, MPLAB, PIC, PICmicro,
PICSTART, PRO MATE, PowerSmart, rfPIC, and
SmartShunt are registered trademarks of Microchip
Technology Incorporated in the U.S.A. and other countries.
AmpLab, FilterLab, MXDEV, MXLAB, PICMASTER, SEEVAL,
SmartSensor and The Embedded Control Solutions Company
are registered trademarks of Microchip Technology
Incorporated in the U.S.A.
Analog-for-the-Digital Age, Application Maestro, dsPICDEM,
dsPICDEM.net, dsPICworks, ECAN, ECONOMONITOR,
FanSense, FlexROM, fuzzyLAB, In-Circuit Serial
Programming, ICSP, ICEPIC, Migratable Memory, MPASM,
MPLIB, MPLINK, MPSIM, PICkit, PICDEM, PICDEM.net,
PICLAB, PICtail, PowerCal, PowerInfo, PowerMate,
PowerTool, rfLAB, rfPICDEM, Select Mode, Smart Serial,
SmartTel and Total Endurance are trademarks of Microchip
Technology Incorporated in the U.S.A. and other countries.
SQTP is a service mark of Microchip Technology Incorporated
in the U.S.A.
All other trademarks mentioned herein are property of their
respective companies.
© 2004, Microchip Technology Incorporated, Printed in the
U.S.A., All Rights Reserved.
Printed on recycled paper.
Microchip received ISO/TS-16949:2002 quality system certification for
its worldwide headquarters, design and wafer fabrication facilities in
Chandler and Tempe, Arizona and Mountain View, California in
October 2003. The Company’s quality system processes and
procedures are for its PICmicro® 8-bit MCUs, KEELOQ® code hopping
devices, Serial EEPROMs, microperipherals, nonvolatile memory and
analog products. In addition, Microchip’s quality system for the design
and manufacture of development systems is ISO 9001:2000 certified.
DS00897B-page 15
 2004 Microchip Technology Inc.
WORLDWIDE SALES AND SERVICE
AMERICAS
ASIA/PACIFIC
ASIA/PACIFIC
EUROPE
Corporate Office
2355 West Chandler Blvd.
Chandler, AZ 85224-6199
Tel: 480-792-7200
Fax: 480-792-7277
Technical Support:
http:\\support.microchip.com
Web Address:
www.microchip.com
Australia - Sydney
Tel: 61-2-9868-6733
Fax: 61-2-9868-6755
India - Bangalore
Tel: 91-80-2229-0061
Fax: 91-80-2229-0062
China - Beijing
Tel: 86-10-8528-2100
Fax: 86-10-8528-2104
India - New Delhi
Tel: 91-11-5160-8632
Fax: 91-11-5160-8632
Austria - Weis
Tel: 43-7242-2244-399
Fax: 43-7242-2244-393
Denmark - Ballerup
Tel: 45-4420-9895
Fax: 45-4420-9910
China - Chengdu
Tel: 86-28-8676-6200
Fax: 86-28-8676-6599
Japan - Kanagawa
Tel: 81-45-471- 6166
Fax: 81-45-471-6122
France - Massy
Tel: 33-1-69-53-63-20
Fax: 33-1-69-30-90-79
China - Fuzhou
Tel: 86-591-750-3506
Fax: 86-591-750-3521
Korea - Seoul
Tel: 82-2-554-7200
Fax: 82-2-558-5932 or
82-2-558-5934
Germany - Ismaning
Tel: 49-89-627-144-0
Fax: 49-89-627-144-44
Atlanta
Alpharetta, GA
Tel: 770-640-0034
Fax: 770-640-0307
Boston
Westford, MA
Tel: 978-692-3848
Fax: 978-692-3821
Chicago
Itasca, IL
Tel: 630-285-0071
Fax: 630-285-0075
Dallas
Addison, TX
Tel: 972-818-7423
Fax: 972-818-2924
Detroit
Farmington Hills, MI
Tel: 248-538-2250
Fax: 248-538-2260
Kokomo
Kokomo, IN
Tel: 765-864-8360
Fax: 765-864-8387
China - Hong Kong SAR
Tel: 852-2401-1200
Fax: 852-2401-3431
China - Shanghai
Tel: 86-21-5407-5533
Fax: 86-21-5407-5066
China - Shenyang
Tel: 86-24-2334-2829
Fax: 86-24-2334-2393
China - Shenzhen
Tel: 86-755-8203-2660
Fax: 86-755-8203-1760
China - Shunde
Tel: 86-757-2839-5507
Fax: 86-757-2839-5571
Singapore
Tel: 65-6334-8870
Fax: 65-6334-8850
Taiwan - Kaohsiung
Tel: 886-7-536-4818
Fax: 886-7-536-4803
Taiwan - Taipei
Tel: 886-2-2500-6610
Fax: 886-2-2508-0102
Italy - Milan
Tel: 39-0331-742611
Fax: 39-0331-466781
Netherlands - Drunen
Tel: 31-416-690399
Fax: 31-416-690340
England - Berkshire
Tel: 44-118-921-5869
Fax: 44-118-921-5820
Taiwan - Hsinchu
Tel: 886-3-572-9526
Fax: 886-3-572-6459
China - Qingdao
Tel: 86-532-502-7355
Fax: 86-532-502-7205
Los Angeles
Mission Viejo, CA
Tel: 949-462-9523
Fax: 949-462-9608
San Jose
Mountain View, CA
Tel: 650-215-1444
Fax: 650-961-0286
Toronto
Mississauga, Ontario,
Canada
Tel: 905-673-0699
Fax: 905-673-6509
09/27/04
DS00897B-page 16
 2004 Microchip Technology Inc.