| The Datasheet Archive - 100 Million Datasheets from 7500 Manufacturers. |
THEORY OPERATION PICmicro microcontrollers nominal time-out perio
Top Searches for this datasheetAN828 THEORY OPERATION PICmicro microcontrollers nominal time-out period time-out period varies with temperature, part-to-part process variations. given microcontroller, exhibits nearly linear correlation between time-out period temperature, assuming that constant. Figure shows time-out count function temperature four different devices. Note that while each device differs counts given temperature, slope line each device essentially constant, similar devices. only real difference offset y-intercept) each device. practical terms, this means that thermometer circuit must calibrated with offset value controller. this application, temperatures opposite ends expected temperature range used derive both slope y-intercept. design digital thermometer based this principle. Without using separate temperature sensor, possible calculate temperature with reasonable accuracy using time-out period. Measuring Temperature with PIC16F84A Watchdog Timer Leena Chaudhari Microchip Technology Inc. INTRODUCTION Almost temperature sensor circuits some form discrete component (such thermistor solidstate sensor) actually measure environment's temperature. left microcontroller interpret reading into human-friendly form user's benefit. possible, however, design digital thermometer without external sensor, using temperature sensitive property microcontroller itself. This Application Note shows Watchdog Timer (WDT) PICmicro® microcontroller temperature measurement. FIGURE 5500 WATCHDOG TIMER COUNT TEMPERATURE FOUR PIC16F84A DEVICES 5000 Device1 4500 Count 4000 Device2 3500 Device3 3000 Device4 2500 2000 Temperature 2002 Microchip Technology Inc. DS00828A-page AN828 translate environment temperature into actual reading, system must able following: Provide method establishing time-out temperature calibration Count number time-outs given period time Equate number time-outs temperature flow charts showing firmware implementation these steps presented Figure Figure sake brevity, will only discuss method counting time-outs calculating temperature, detail. overall system design also includes wake-on-interrupt scanning temperature display, which needed some users. Those interested examining these other components encouraged download source code examine their leisure. FIGURE MAIN FIRMWARE ROUTINE THERMOMETER START POR, BOR, Wake from SLEEP pressed? Clear WDTCOUNT execute CLRWDT STATUS<5> Time-out DEFAULT Load calibration temps counts from EEPRO Time-out? Load default temps counts Increment WDTCOUNT Calculate temp from current WDTCOUNT Enable PORTB Interrupt-onchange TEMP pressed? Display Temperature SLEEP mode TEMP pressed within seconds? (Return START RESETS) DS00828A-page 2002 Microchip Technology Inc. AN828 FIGURE CALIBRATION ROUTINE THERMOMETER 10-minute press time-out? 2-minute press time-out? Display current high calibration temp "HI" (alternate) Display current calibration temp "LO" (alternating) pressed? Increment calibration temperature pressed? Increment high calibration temperature DOWN pressed? Decrement high calibration temperature Decrement calibration temperature DOWN pressed? pressed? Store calibration temperature count Store high calibration temperature count pressed? DEFAULT flag TEMP Routine (Calibration Mode) SLEEP mode TEMP pressed? Clear DEFAULT flag (Return START RESETS) Return entry point 2002 Microchip Technology Inc. DS00828A-page AN828 COUNTING TIME-OUTS first step calculate temperature count number time-outs. This done running loop until time-out occurs, then incrementing counter. WDTCOUNT_HI WDTCOUNT_LO 8-bit registers used store 16-bit value count. selection 16-bit counter time-out based both system clock prescaler ratio. system described this application note, clock frequency prescaler ratio used. With this configuration, observed that value count never exceeded bits over entire temperature range (-40°C 85°C). longer time-out period required, prescaler ratio 1:128 assigned under software control writing three Least Significant bits OPTION register. highest setting, time-out period long seconds realized. firmware calculation time-out, well size register, based this clock frequency prescaler ratio. Changing these values requires changes algorithm; addition, increasing prescaler ratio will require longer calculation more time, require larger time-out counter register. user's responsibility determine what appropriate rate timeout register size particular application, make appropriate changes. Note that basic counting method will always stay same. demonstrate this, let's look examples. these cases, following assumptions made: Each four-instruction loop incrementing counter takes five clocks cycles (one each instruction, plus addition cycle GOTO instruction, increments program counter) worst-case Watchdog Timer Reset time (TWDT) (This well outside maximum value specified PIC16F84A; will this value provide margin comfort calculating register size.) system described here, system clock gives clock cycle which means single loop executes µs). prescaler ration gives actual time-to-reset 80,000 Thus, single RESET would generate count 80,000/10, 8,000. this less than 65,536 (216), this means that count accommodated bits, two-byte register. Note: RESETS affect values stored (i.e., WDTCOUNT_HI WDTCOUNT_LO). other hand, let's examine system using clock prescaler ratio 1:128. this case, clock cycle loop executes prescaler ratio yields actual timeto-reset 5120 128), 5,120,000 This gives 5,120,000 counts RESET (5,120,000 µs), which would require minimum bits (223, 8,388,608, being smallest power that larger than value) represent. practical terms, this means three-byte (24-bit) register. start-up, program checks RESET Power-on Reset (POR) time-out. does this checking STATUS register. (See Table details bits their significance.) RESET equal `1'), system determines present temperature measuring time-out time. This done first clearing WDTCOUNT_HI:WDTCOUNT_LO register pair, then doing 16-bit increment within loop. Since cleared loop, will eventually time-out cause Reset. This RESET will cause Program Counter loaded with 0000h Reset will executed PIC16F84A. Subsequently, program will branch back `Start'. When STATUS register checked this time, will `0', indicating that time-out (and POR) occurred. value stored WDTCOUNT_HI:WDTCOUNT_LO register pair corresponds time (and thus present temperature) PIC16F84A. TABLE STATUS BITS THEIR SIGNIFICANCE RESET STATES Unknown Illegal Illegal Brown-out Reset Reset Wake-up MCLR Reset during SLEEP interrupt wakeup from SLEEP Condition Power-on Reset Unknown Unchanged Unchanged MCLR Reset during normal operation DS00828A-page 2002 Microchip Technology Inc. AN828 EXAMPLE Start movf movwf movf movwf btfss goto WDTCOUNT_HI,w TEMP1 WDTCOUNT_LO,w TEMP0 STATUS,NOT_TO MeasureTemp CODE COUNTING TIME-OUTS Main start program (WDTCOUNT_HI:WDTCOUNT_LO)-final value 16-bit counter (TEMP1:TEMP0)- value calculation temperature Reset power-on, count. Reset time-out, calculate present temperature. Select Prescaler OPTION_REG Prescaler assigned Initialization code clrf WDTCOUNT_HI Clear count time-out period clrf WDTCOUNT_LO clrwdt Clear Watch Timer WDT_LOOP incfsz WDTCOUNT_LO,f Lower Time-out count goto CALWDT1 incf WDTCOUNT_HI,f Upper Time-out count CALWDT1 goto WDT_LOOP MeasureTemp Code calculation display temperature other routine CALCULATING TEMPERATURE WITH COUNT calculation temperature based calibrated temperatures their corresponding counts. Since relationship between temperature time nearly straight line, points sufficient determine slope. Both temperatures counts must determined stored EEPROM locations. These values remain same given device. order determine points straight line, user will have find time values known temperatures executing calibration process. obtain most accurate calculation slope, difference between calibration temperatures must least 20°C. production testing, multiple units should tested parallel, using Calibration mode source code. calibrate system, time-out count collected with device precision thermistors different temperatures (13°C 37°C). With time-out counts temperatures different points, temperature between these points calculated simple linear regression. standard equation straight line: where represents count represents temperature, solve give number time-outs degree Celsius: also solve temperature given time-out value with equation: example, that 3208 time-outs were counted 13°C, 3740 were counted 37°C. this case, slope 3740 3208 22.17 temperature with 3300 time-outs, higher known temperature count solve get: 3740 3300 22.17 17.2 which rounds 17°C. 2002 Microchip Technology Inc. DS00828A-page AN828 DESCRIPTION CIRCUIT circuit hardware (schematic shown Figure built around PIC16F84A microcontroller, three sevensegment LEDs display temperature, assorted support components. common anode each connected PORTA<2:0> through transistors, which used source current each digit. entire device operates single battery. Four control keys (SET, TEMP, DOWN) provided display calibrate temperature. keys connected PORTB <7:4> microcontroller. Because these four pins (RB7:RB4) have interrupt-on-change feature, pressing keys wake-up device from SLEEP. PIC16F84A normally SLEEP mode, consuming very little operating current. pressed, `wakes from SLEEP updates count, checks additional presses. there none, returns SLEEP mode. such applications, putting controller into SLEEP mode during inactive states greatly extend battery life. FIGURE THERMOMETER SCHEMATIC LED1 HDSP-7301 anode anode LED2 HDSP-7301 anode anode LED3 HDSP-7301 anode anode MCLR 0.1µF 0.1µF MCLR RB0/INT RA4/T0CKI OSC1/CLKI OSC2/CLKO PIC16F84A 2N3906 2N3906 2N3906 LM7805 DOWN TEMP MCLR MODES OPERATION Thermometer three distinct operating modes. SLEEP Mode: This default mode system starts when power applied, when other modes. There display other sign activity. Display Mode: When TEMP pressed, system wakes LEDs show temperature degrees Centigrade. TEMP pressed again within seconds, system will return SLEEP mode. important note that system will automatically update display with temperature changes that occur while Display mode. update display with current temperature, necessary press TEMP again, after system returned SLEEP mode. DS00828A-page 2002 Microchip Technology Inc. AN828 Calibration Mode: This mode creates calibration values, addition those present firmware. this, necessary place device environment where temperature known, such precision temperature forcing system. ACCURACY SYSTETo verify accuracy design, test system kept under precision temperature forcing system over range temperatures; thermal soak time minutes used each step. When calculated actual temperatures were compared (shown Table found that calculated temperature generally accurate within ±1°C. should noted that these results relatively small sample systems. Results vary across larger sample. Accuracy enhanced using narrower range calibration temperatures, restricted expected operating range system; this restricts measurement more linear part temperature count line, allows more accurate calculation. Note: Before setting temperature, system should allowed equilibrate particular temperature least minutes, proper counts high temperatures; otherwise, correct calibration will possible. calibrate device: Place system temperature forcing system higher calibration temperatures, wait minutes temperature stabilize. Press hold while applying power system. display will alternately flash `HI' current high calibration temperature. Press either DOWN increase decrease displayed temperature setting degree (within range 70), match actual temperature. Press key. high temperature calibration stored data EEPROM. this point, display will alternately flash `LO' current calibration temperature. Change temperature forcing system calibration temperature. Allow minutes temperature stabilize. Press either DOWN increase decrease displayed temperature setting degree (within range 70), match current temperature. Press key. temperature calibration stored data EEPROM, firmware sets flag (Default) indicate that calibration information available. this point, system returns SLEEP mode. return preprogrammed calibration time during this process, press TEMP key. unit ignores calibration data entered, returns SLEEP mode. TABLE CALCULATED ACTUAL TEMPERATURES THERMOMETER Actual Measured Temperature (°C) Calculated Temperature (°C) MEMORY USAGE firmware thermometer uses following memory resources: Program Memory: bytes Data RAM: bytes Data EEPROM: bytes hardware design uses total pins combined interrupt-on-change wake-up). system continuously checks presses during Calibration mode. presses occur minutes during high temperature calibration, minutes during temperature calibration, unit returns SLEEP mode. CONCLUSION There situations where necessary measure temperature with absolute minimum part count. Using PIC16F84A both measure interpret temperature, provides simple solution with very part count good degree accuracy. 2002 Microchip Technology Inc. DS00828A-page AN828 APPENDIX SOFTWARE DISCUSSED THIS APPLICATION NOTE Because overall length, complete source file listing thermometer provided. complete source code available single WinZip archive file, which downloaded from Microchip corporate site www.microchip.com DS00828A-page 2002 Microchip Technology Inc. Note following details code protection feature PICmicro® MCUs. PICmicro family meets specifications contained Microchip Data Sheet. Microchip believes that family PICmicro microcontrollers most secure products kind market today, when used intended manner under normal conditions. There dishonest possibly illegal methods used breach code protection feature. these methods, knowledge, require using PICmicro microcontroller manner outside operating specifications contained data sheet. person doing engaged theft intellectual property. Microchip willing work with customer concerned about integrity their code. Neither Microchip other semiconductor manufacturer guarantee security their code. Code protection does mean that guaranteeing product "unbreakable". Code protection constantly evolving. Microchip committed continuously improving code protection features product. have further questions about this matter, please contact local sales office nearest you. Information contained this publication regarding device applications like intended through suggestion only superseded updates. your responsibility ensure that your application meets with your specifications. representation warranty given liability assumed Microchip Technology Incorporated with respect accuracy such information, infringement patents other intellectual property rights arising from such otherwise. Microchip's products critical components life support systems authorized except with express written approval Microchip. licenses conveyed, implicitly otherwise, under intellectual property rights. Trademarks Microchip name logo, Microchip logo, FilterLab, KEELOQ, MPLAB, PIC, PICmicro, PICMASTER, PICSTART, MATE, SEEVAL Embedded Control Solutions Company registered trademarks Microchip Technology Incorporated U.S.A. other countries. dsPIC, ECONOMONITOR, FanSense, FlexROM, fuzzyLAB, In-Circuit Serial Programming, ICSP, ICEPIC, microID, microPort, Migratable Memory, MPASM, MPLIB, MPLINK, MPSIM, MXDEV, PICC, PICDEM, PICDEM.net, rfPIC, Select Mode Total Endurance trademarks Microchip Technology Incorporated U.S.A. Serialized Quick Turn Programming (SQTP) service mark Microchip Technology Incorporated U.S.A. other trademarks mentioned herein property their respective companies. 2002, Microchip Technology Incorporated, Printed U.S.A., Rights Reserved. Printed recycled paper. Microchip received QS-9000 quality system certification worldwide headquarters, design wafer fabrication facilities Chandler Tempe, Arizona July 1999. Company's quality system processes procedures QS-9000 compliant PICmicro® 8-bit MCUs, KEELOQ® code hopping devices, Serial EEPROMs microperipheral products. addition, Microchip's quality system design manufacture development systems 9001 certified. 2002 Microchip Technology Inc. DS00828A page WORLDWIDE SALES SERVICE AMERICAS Corporate Office 2355 West Chandler Blvd. Chandler, 85224-6199 Tel: 480-792-7200 Fax: 480-792-7277 Technical Support: 480-792-7627 Address: http://www.microchip.com ASIA/PACIFIC Australia Microchip Technology Australia Suite Rawson Street Epping 2121, Australia Tel: 61-2-9868-6733 Fax: 61-2-9868-6755 Japan Microchip Technology Japan K.K. Benex 3-18-20, Shinyokohama Kohoku-Ku, Yokohama-shi Kanagawa, 222-0033, Japan Tel: 81-45-471- 6166 Fax: 81-45-471-6122 Rocky Mountain 2355 West Chandler Blvd. Chandler, 85224-6199 Tel: 480-792-7966 Fax: 480-792-7456 China Beijing Microchip Technology Consulting (Shanghai) Co., Ltd., Beijing Liaison Office Unit Bldg. Chaoyangmen Beidajie Beijing, 100027, China Tel: 86-10-85282100 Fax: 86-10-85282104 Korea Microchip Technology Korea 168-1, Youngbo Bldg. Floor Samsung-Dong, Kangnam-Ku Seoul, Korea 135-882 Tel: 82-2-554-7200 Fax: 82-2-558-5934 Atlanta Sugar Mill Road, Suite 200B Atlanta, 30350 Tel: 770-640-0034 Fax: 770-640-0307 Singapore Microchip Technology Singapore Ltd. Middle Road #07-02 Prime Centre Singapore, 188980 Tel: 65-334-8870 Fax: 65-334-8850 Boston Drive, Suite Westford, 01886 Tel: 978-692-3848 Fax: 978-692-3821 China Chengdu Microchip Technology Consulting (Shanghai) Co., Ltd., Chengdu Liaison Office 2401, 24th Floor, Ming Xing Financial Tower TIDU Street Chengdu 610016, China Tel: 86-28-6766200 Fax: 86-28-6766599 Taiwan Microchip Technology Taiwan 11F-3, Tung North Road Taipei, 105, Taiwan Tel: 886-2-2717-7175 Fax: 886-2-2545-0139 Chicago Pierce Road, Suite Itasca, 60143 Tel: 630-285-0071 Fax: 630-285-0075 Dallas 4570 Westgrove Drive, Suite Addison, 75001 Tel: 972-818-7423 Fax: 972-818-2924 China Fuzhou Microchip Technology Consulting (Shanghai) Co., Ltd., Fuzhou Liaison Office Unit 28F, World Trade Plaza Wusi Road Fuzhou 350001, China Tel: 86-591-7503506 Fax: 86-591-7503521 EUROPE Denmark Microchip Technology Nordic Regus Business Centre Lautrup Ballerup DK-2750 Denmark Tel: 4420 9895 Fax: 4420 9910 Detroit Tri-Atria Office Building 32255 Northwestern Highway, Suite Farmington Hills, 48334 Tel: 248-538-2250 Fax: 248-538-2260 China Shanghai Microchip Technology Consulting (Shanghai) Co., Ltd. Room 701, Bldg. East International Plaza Xian Road Shanghai, 200051 Tel: 86-21-6275-5700 Fax: 86-21-6275-5060 Kokomo 2767 Albright Road Kokomo, Indiana 46902 Tel: 765-864-8360 Fax: 765-864-8387 France Microchip Technology SARL Parc d'Activite Moulin Massy Saule Trapu Batiment Etage 91300 Massy, France Tel: 33-1-69-53-63-20 Fax: 33-1-69-30-90-79 Angeles 18201 Karman, Suite 1090 Irvine, 92612 Tel: 949-263-1888 Fax: 949-263-1338 China Shenzhen Microchip Technology Consulting (Shanghai) Co., Ltd., Shenzhen Liaison Office 1315, 13/F, Shenzhen Kerry Centre, Renminnan Shenzhen 518001, China Tel: 86-755-2350361 Fax: 86-755-2366086 York Motor Parkway, Suite Hauppauge, 11788 Tel: 631-273-5305 Fax: 631-273-5335 Germany Microchip Technology GmbH Gustav-Heinemann Ring D-81739 Munich, Germany Tel: 49-89-627-144 Fax: 49-89-627-144-44 Jose Microchip Technology Inc. 2107 North First Street, Suite Jose, 95131 Tel: 408-436-7950 Fax: 408-436-7955 Hong Kong Microchip Technology Hongkong Ltd. Unit 901-6, Tower Metroplaza Hing Fong Road Kwai Fong, N.T., Hong Kong Tel: 852-2401-1200 Fax: 852-2401-3431 Italy Microchip Technology Centro Direzionale Colleoni Palazzo Taurus Colleoni 20041 Agrate Brianza Milan, Italy Tel: 39-039-65791-1 Fax: 39-039-6899883 Toronto 6285 Northam Drive, Suite Mississauga, Ontario 1X5, Canada Tel: 905-673-0699 Fax: 905-673-6509 India Microchip Technology Inc. India Liaison Office Divyasree Chambers Floor, Wing (A3/A4) O'Shaugnessey Road Bangalore, 025, India Tel: 91-80-2290061 Fax: 91-80-2290062 United Kingdom Arizona Microchip Technology Ltd. Eskdale Road Winnersh Triangle Wokingham Berkshire, England RG41 Tel: 5869 Fax: 44-118 921-5820 01/18/02 DS00828A-page 2002 Microchip Technology Inc. Other recent searchesTLP191B - TLP191B TLP191B Datasheet ROS-70-219+ - ROS-70-219+ ROS-70-219+ Datasheet RLT9830MG - RLT9830MG RLT9830MG Datasheet PM5366 - PM5366 PM5366 Datasheet PM4318 - PM4318 PM4318 Datasheet M466F0404BT2-L - M466F0404BT2-L M466F0404BT2-L Datasheet LM21212-1 - LM21212-1 LM21212-1 Datasheet KK3340 - KK3340 KK3340 Datasheet FCI30 - FCI30 FCI30 Datasheet
Privacy Policy | Disclaimer |