El anstregdan!!
Páginas: 19 (4506 palabras)
Publicado: 24 de noviembre de 2011
Author:
AN828
THEORY OF OPERATION
The WDT on all PICmicro microcontrollers has a nominal time-out period of 18 ms. The WDT time-out period varies with temperature, VDD and part-to-part process variations. For a given microcontroller, the WDT exhibits a nearly linear correlation between the time-out period and temperature, assuming that VDD is constant. Figure 1 shows the time-out count asa function of temperature for four different devices. Note that while each device differs in counts for a given temperature, the slope of the line for each device is essentially constant, and is similar for all devices. The only real difference is the offset (or y-intercept) for each device. In practical terms, this means that the thermometer circuit must be calibrated with the offset value forits controller. For this application, two temperatures at opposite ends of the expected temperature range are used to derive both slope and y-intercept. The design of the digital WDT thermometer is based on this principle. Without using a separate temperature sensor, it is possible to calculate the temperature with reasonable accuracy using the WDT time-out period.
Measuring Temperature with thePIC16F84A Watchdog Timer
Leena Chaudhari Microchip Technology Inc.
INTRODUCTION
Almost all temperature sensor circuits use some form of discrete component (such as a thermistor or a solidstate sensor) to actually measure the environment’s temperature. It is left to the microcontroller to interpret the reading into a human-friendly form for the user’s benefit. It is possible, however, todesign a digital thermometer without an external sensor, by using a temperature sensitive property of the microcontroller itself. This Application Note shows how to use the Watchdog Timer (WDT) of a PICmicro® microcontroller for temperature measurement.
FIGURE 1:
5500
WATCHDOG TIMER COUNT VS. TEMPERATURE FOR FOUR PIC16F84A DEVICES
5000 Device1 4500
WDT Count
4000 Device2
3500Device3
3000
Device4
2500
2000 -20 -10 0 10 20 Temperature (C) 30 40 50 60
2002 Microchip Technology Inc.
DS00828A-page 1
AN828
To translate the environment temperature into an actual reading, the system must be able to do the following: • Provide a method for establishing time-out to temperature calibration • Count the number of WDT time-outs for a given period of time •Equate the number of time-outs to a temperature The flow charts showing the firmware implementation of all these steps are presented in Figure 2 and Figure 3. For the sake of brevity, we will only discuss the method for counting WDT time-outs and calculating temperature, in detail. The overall system design also includes wake-on-interrupt key scanning and temperature display, which may not be neededby some users. Those who may be interested in examining these other components are encouraged to download the source code and examine it at their leisure.
FIGURE 2:
MAIN FIRMWARE ROUTINE FOR THE WDT THERMOMETER
START POR, BOR, Wake from SLEEP A YES SET key pressed? NO Clear WDTCOUNT and execute CLRWDT YES STATUS = ‘1’ ? NO
WDT Time-out
DEFAULT = ‘1’ ? NO
YES
Load new calibrationtemps and WDT counts from EEPROM
YES
WDT Time-out? NO
Load default temps and WDT counts
Increment
WDTCOUNT
Calculate temp from current WDTCOUNT
Enable PORTB Interrupt-onchange
TEMP key pressed? NO
YES
Display Temperature
NO SLEEP mode
TEMP key pressed within 5 seconds?
YES
END (Return to START on RESETS)
DS00828A-page 2
2002 Microchip Technology Inc.AN828
FIGURE 3: CALIBRATION ROUTINE FOR THE WDT THERMOMETER
A
10-minute key press time-out? NO
YES
B
C
2-minute key press time-out? NO Display current high calibration temp and “HI” (alternate)
YES
B
Display current low calibration temp and “LO” (alternating) C UP key pressed? YES Increment low calibration temperature
C
C UP key pressed? NO YES Increment...
Leer documento completo
Regístrate para leer el documento completo.