555 timer chip realizes single chip microcomputer watchdog circuit

Publisher:量子启示Latest update time:2015-04-23 Source: diangon Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
1. Program runaway phenomenon

With the widespread application of single-chip microcomputers in the energy field, the anti-interference problem of single-chip microcomputers has become more and more prominent. The underground environment of coal mines is generally harsh, which will bring various interferences to the single-chip microcomputer control system, so that the system cannot work normally. The anti-interference performance of the single-chip microcomputer application system mainly depends on the anti-interference design of the hardware, but the software
anti-interference design is also very important as the improvement and supplement of the hardware anti-interference, because a large amount of interference usually does not affect the operation of the hardware in the system, but often makes the system software unable to run normally. A prominent problem of single-chip microcomputer application is the program runaway phenomenon that often occurs during the operation of the single-chip microcomputer.
In the single-chip microcomputer system, due to interference, under unexpected circumstances, the value of the program counter PC changes randomly, so that the flow of the program points to an uncertain area, which is the program runaway. After the program runs away, the address code and operation code of the instruction may change, and the PC will execute the operand as an instruction; or the PC value points to an illogical instruction or even a non-program area. The result of the operation often causes the single-chip microcomputer to enter an infinite loop, which is what we often call "freeze". In order to ensure that the microcontroller can automatically recover after a "freeze" when no one is on duty, software traps, external WDT circuits, and software-controlled WATCHDOG are usually used to restore the system to normal (the latter two are commonly known as "watchdogs"). Due to space limitations, we will not explain this specifically. Here we mainly introduce a method of using the 555 timer as a watchdog in combination with software and hardware.
2. 555 timer
In general, the watchdog mainly determines whether the program has entered an infinite loop by constantly monitoring whether the time it takes for the program to run an event exceeds the predetermined time. Therefore, the resettable trigger function of the 555 timer plus a delay circuit can be used to realize the watchdog function. The 555 timer is a multi-purpose single-chip integrated circuit, and the internal circuit is shown in Figure 1.

CO is the control voltage input terminal. Adding control voltage can change the reference voltage of A1 "-" terminal and A2 "+" terminal. If not used, it can be grounded through a small capacitor to prevent bypass high-frequency AC interference; R is the timer direct reset terminal. Adding low level can directly set the timer to "0". At this time, OUT outputs "0", Q is 1", V is turned on, and D terminal is connected to ground; TH is the reset threshold input terminal. When the TH voltage exceeds 2/3UDD (i.e., A1 negative terminal voltage division), A1 outputs "1", OUT outputs "0", and similarly, D terminal is connected to ground; TR is the set input terminal. When the TR voltage is lower than 1/3 UDD (i.e., A2 positive terminal voltage division), A2 outputs "1", the timer is set, and at this time, OUT outputs "1", Q is "0", V is turned off, and D terminal is disconnected from ground.
3. Watchdog circuit and operation instructions are based on INTEL's 16-bit microcontroller 8096 For example, the interface circuit between the 555 timer as a watchdog and the microcontroller can be designed as shown in Figure 2.

First, when the MCU is initialized, use the instruction "ORBPORT1, #01H" to set P1.0 to "1", then the transistor T is turned on, the R of the 555 chip is "1", the TH and TR terminals are charged through R and C, and the potential gradually rises. When the potential is still lower than 1/3 UDD, OUT outputs "1", the D terminal is disconnected from the ground, and the capacitor C is charged normally. (Copyright http://www.diangon.com/) Once the program runs away or enters an infinite loop, when the potential rises to higher than 2/3 UDD, there is still no "feeding the dog", then the OUT output becomes "0", the transistor T pulls down the RESET pin of the MCU, and discharges the reset capacitor. At this time,
the D terminal is short-circuited to the ground, and the capacitor C is also discharged through Rf. When the TH and TR terminal potentials are discharged to less than 1/3 UDD (note), the OUT output becomes "1" again, and the MCU enters the reset state.
"Feeding the dog" means resetting the watchdog. In this circuit, you only need to run the following instructions.
ANDB PORT1, #0FEH; make P1.0 "0"
SKIP; no operation, used for delay
SKIP; so that the voltage of TR drops to 1/3 UDD
ORB PORT1, #01H; make P1.0 "1"
When P1.0 is set to "0", the R end of the 555 timer is "0", and the transistor T is cut off. When the R end is "0", the 555 chip is reset, the OUT output is "0", and the D end is short-circuited to the ground, and the capacitor C is discharged to prepare for re-delay. However, because the transistor is cut off, although the OUT output is also "0" at this time, it does not affect the RESET pin of the microcontroller, and the microcontroller works normally, thus distinguishing the difference between "feeding the dog" and the watchdog action when the system fails.
4. Issues that need attention
There is still one issue that needs attention, that is, the normal operation of the 555 timer is completely dependent on the state of the single-chip microcomputer P1.0. However, in some cases where interference is more serious, the misoperation of the single-chip microcomputer may change the preset state of P1.0. If P1.0 is mistakenly set to "0" before the single-chip microcomputer enters the dead loop, the watchdog
is always in the "fed" state, and the circuit will no longer work. In this case, we can use software redundancy to deal with it, that is, insert the activation instruction of the watchdog multiple times in the key place of the program:
NOP
ORB PORT1, #01H
It is worth reminding that the role of the "NOP" instruction here cannot be ignored, which can put the runaway program back on track and not disperse the key instructions behind. However, despite this, the application of software redundancy still has a prerequisite, that is, the runaway program must fall into the program area, and the redundant instructions can only take effect after being executed. If the runaway program falls into the non-program area, the instruction redundancy technology alone will not be reliable. At this time, we must also rely on the support of other anti-interference technologies, such as software traps, flag technology, and the design of inherent reliability programs. I will not go into details here, but these must all be included in a reliable program - after all, the impact of interference on the microcontroller system is three-dimensional, so our response strategy must also be comprehensive.

Reference address:555 timer chip realizes single chip microcomputer watchdog circuit

Previous article:What is a microcontroller? What is a microcontroller used for?
Next article:Anti-interference design of single-chip computer system for residual current protector

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号