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.
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
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- Do you understand Geely Group's new logo?
- I'm wondering if anyone has used a similar switch?
- Follow and comment to win gifts! Micron 2022 Taipei International Computer Show keynote speech highlights: Mobile applications and client devices album
- Some Problems of Class D Amplifier
- Why can't AC/DC have a transformer first and then design the circuit?
- How to deal with electromagnetic compatibility issues during single chip microcomputer design
- Modified booster plate + purifier
- Power supply fluctuation problem of portable equipment
- RFID antenna connector classification
- EEWORLD University Hall----Live Replay: Metaverse Testing Seminar Series: Challenges of VR/AR Digital Interface Testing