English
Language : 

AN897 Datasheet, PDF (6/16 Pages) Microchip Technology – Thermistor Temperature Sensing with MCP6SX2 PGAs
AN897
FLOWCHARTS
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
Read ADC
PGA Hysteresis
Was PGAgain
Changed?
Yes
No
Perform PwLI
Send °C to Strip Chart
FIGURE 15:
Design.
End
Flowchart for Second
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.
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.
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.
PGA Hysteresis
IF
IF
PGAgain = 1
PGAadc < 113
Y
Y
N
N
IF
IF
PGAgain = 8
PGAadc < 226
Y
Y
N
N
IF
PGAadc > 960
Y
N
Set PGAgain = 8
Set PGAgain = 32
Set PGAgain = 1
IF
PGAgain = 32
Y
N
IF
PGAadc > 960
N
Set PGAgain = 8
Y
Return 0
Return 1
FIGURE 16:
Flowchart for Second Design’s PGA Hysteresis Subroutine.
DS00897B-page 6
 2004 Microchip Technology Inc.