In the application of embedded systems, the anti-interference performance of single-chip microcomputers is an important indicator of system reliability, and anti-interference design is an important content that cannot be ignored in the development of single-chip microcomputer systems. Based on the author's experience in actual work, this paper discusses the anti-interference problem of single-chip microcomputers in embedded system applications, and provides some methods and measures for troubleshooting design and fault-tolerant design.
With the rapid development of science and technology, the application of single chip microcomputers in various fields is becoming more and more extensive. A common problem faced by many application systems is its reliability in the application system, which requires us to take corresponding anti-interference measures in hardware design, circuit board design, software design, etc. according to the specific conditions of the site during design.
1. Measures to prevent power supply interference
Most MCU embedded systems are powered by AC power. A very important interference in the application system comes from the power supply. Various interferences from the AC power supply, such as lightning, start and stop of large-capacity inductive loads, etc., will cause the power supply to be undervoltage or overloaded instantly, and generate interferences such as surges, sags, and spikes. However, we can take the following effective anti-interference measures.
1. Use varistor to suppress spikes and surges
If the voltage across the varistor exceeds its limit, the current will increase rapidly and be in a short-circuit state. Using this feature, it can be used to absorb instantaneous spikes and surge voltages. The varistor is connected in parallel to the primary and secondary of the power transformer. After adding the varistor, the possibility of power supply interference causing the microcontroller program to lose control is reduced. The calculation formula for the varistor voltage is: VIMA = 1.56 × 32 × V~ (V~: AC voltage effective value)
2. Filters suppress high-frequency interference
The mains contains a variety of high-order harmonics, which can easily enter the microcontroller system through the power supply. In addition, some radio frequency emissions, electromagnetic waves, etc. can also be fed back into the microcontroller system through the power line induction to cause interference. Therefore, a low-pass filter circuit is added to the power supply circuit to allow the 50 Hz mains fundamental wave to pass through and suppress high-frequency signals. In addition, a shielding layer is used to isolate the primary and secondary of the power transformer to reduce its distributed capacitance and improve the ability to resist common-mode interference.
Several different forms of filtering circuits are listed in Figure 1.
2. Anti-interference design of printed circuit boards
Printed circuit boards are high-density collections of devices, signals, and power lines in single-chip microcomputer application systems. The quality of printed circuit board design has a great impact on anti-interference capabilities.
1. Design of power line and ground line
In the single-chip microcomputer application system, grounding is an important method to suppress interference. There are both logic circuits and analog circuits on the circuit board, and the ground lines of both should be connected to the ground line of the power supply end respectively. The ground line of the low-frequency circuit should be connected to the ground at a single point in parallel as much as possible, and the high-frequency circuit should be connected to the ground at multiple points in series. If the ground line is very thin, the ground potential will change with the change of current, which will deteriorate the system's anti-noise performance. Therefore, the ground line should be thickened so that it can pass 3 times the allowable current on the printed circuit board.
The power line and the ground line should be as close as possible to reduce the area of the loop surrounded by them, thereby reducing the electric field interference caused by the external magnetic field cutting the loop, and also reducing the external electromagnetic radiation of the loop. The direction of the power line and the ground line is consistent with the direction of data transmission, which also helps to enhance the anti-noise ability.
2. Some special measures
It should be considered a common practice to configure decoupling capacitors at key locations on printed circuit boards. In principle, each integrated circuit chip should be equipped with a 0.01μF ceramic capacitor to eliminate RF coupling interference. The capacitor lead should not be too long and should be close to the power line and ground line of the chip. If the printed circuit space is too small to fit, a 1-10μF tantalum capacitor for noise limitation can be placed for every 4-10 chips. When laying out the circuit board, the oscillating crystal of the microcontroller should be placed as close to the two pins of the microcontroller as possible.
3. Countermeasures for abnormal program operation
The anti-interference measures introduced above are only to minimize interference and improve the reliability of system operation, but the program may still be out of control in a bad working environment: the PC value points to the operand, and the operand is executed as the instruction code; the PC value exceeds the application area, and the random number in the non-program area is run as the instruction code. In any case, it will cause abnormal operation or crash of the program. The watchdog is a special circuit that resets or resets the system when the program runs away or crashes, so that the system can resume normal operation. There are two commonly used watchdogs: software dog and hardware dog.
1. Hardware watchdog
The so-called hardware watchdog is a counter or timer circuit that can send a "reset" signal. Figure 2 is a hardware watchdog circuit. Its working principle is: P1.0 is used as the "feeding dog" signal of the watchdog to give a pulse regularly, and its pulse interval is set to △t<tw<2△t. When the program runs normally, a pulse is output every △t to trigger the CC4098 monostable circuit, making it always low level. If the program is abnormal, it cannot send a "feeding dog" pulse within the tw time, and a positive pulse is generated to reset the microcontroller system so that it can run normally again.
There are now many more advanced new chips that combine power monitoring and "watchdog" functions, such as MAX705, MAX706, MAX813L, etc. Some of them also have power-off detection and automatic switching of backup batteries.
2. Software watchdog
A software watchdog is actually what is commonly called a software trap. It fills all the free addresses in the program memory with a jump instruction. Once the program runs away, as long as the program pointer points to these addresses, it will be forced to jump to the beginning of the program or other specified addresses immediately, so that the program can continue to run normally.
4. Anti-interference measures in software
There are two ways to improve system reliability: error correction design and fault tolerance design. The error correction design mentioned above cannot completely solve the interference. Fault tolerance is to allow the system to fail, and use redundancy technology to automatically offset it, so that the system can operate normally even if the failure exists. The following introduces several commonly used software fault tolerance methods.
1. Software countermeasures for data acquisition errors
For real-time data acquisition systems, in order to eliminate interference signals in sensors, analog filters are often used in hardware to implement frequency filtering of signals. Frequency filtering can also be achieved using the CPU's calculation control function, which is digital filtering (software filtering). Continuously sample a point of data multiple times, calculate its average value, and use the average value as the sampling result of the point. This can reduce the impact of random interference in the system on the acquisition results. According to the situation where the sampling data is too large or too small due to interference, continuously collect multiple signals for a sampling point, compare the sampling values, and take the median as the acquisition result of the point. The algorithm of the RC low-pass filter can also be completed by software, realizing the use of software methods instead of hardware RC filters. The first-order recursive digital filter formula is
Where: Q is the digital filter time constant; Yn is the filter output at the nth sampling; Xn is the filter input at the nth sampling.
2. Time redundancy
Set several checkpoints at appropriate locations in the program, and save all the information and signs obtained by the correct operation of the program before the checkpoint at each checkpoint. If the fault is temporary, the program will roll back to the previous checkpoint and start again, which can completely eliminate the error. Its block diagram is shown in Figure 3. However, it can only detect but not eliminate permanent faults, and it uses time to exchange for reliability.
3. N version programming
N-version programming is to run several programs independently compiled for a certain function at the same time, and the result is obtained by majority voting of the running results of these independent programs. Its structural block diagram is shown in Figure 4. In N-version programming, N versions are particularly emphasized because if each program uses the same structure and the same algorithm, the same error may occur and cause the majority vote to fail.
N-version programming includes redundancy in programming, which trades efficiency for reliability, tolerates design errors, and shields certain types of temporary hardware failures.
Data redundancy protection is also an application of the N-version programming concept. Important data is stored in several non-adjacent storage units at the same time. Since the possibility of non-adjacent storage units being rewritten at the same time due to interference is very small, correct data can be obtained even if one or two storage units are wrong.
4. Waiver rule
When certain necessary conditions for the program to run or continue to run are not met, the requirements for these conditions are abandoned. Instead of waiting, interruption, error or shutdown, skipping, transfer, N-1, default and other methods are used to ensure that the program continues to run. These methods are only applicable to shielding temporary faults, so alarm output is required at the same time to determine whether human intervention is needed to eliminate permanent faults. The waiver rule should first not affect the correctness and adaptability of the program.
(1) Skip
Without affecting the normal operation of the control system, skip the module that is faulty due to lack of conditions and execute downward. This is one of the forms of software failure operation. The so-called software failure operation means that when a fault occurs, the faulty module is first disconnected from the system, and then the remaining modules of the system are reconstructed so that the system can continue to operate, but the functions are reduced, that is, downgraded operation. The improvement of reliability comes at the cost of the loss of certain functions.
(2) N-1 method
The N-1 method is based on the cyclic execution characteristics of the control program, that is, the data of the previous cycle (N-1th) is used to replace the data required for this cycle (Nth) but not present or not available. This method is particularly suitable for slowly changing controlled objects. For example, if a control output is judged to be unreasonable, the output of the previous cycle is used to replace it.
(3) Default
Default is also a form of waiver rule. Unlike skipping, it uses a pre-set reasonable condition to replace the unavailable condition, that is, the default condition exists. For example, an illegal input operation instruction is assumed to be no input, and the original operation continues.
In short, the purpose of the waiver rule is to ensure continuous operation of the control system working in real-time mode, so as to ensure the long-term stable operation of the controlled system, although the system function may be reduced.
There are many software fault-tolerance methods commonly used in control systems, including abnormal rules and fail-safe design, which will not be introduced here one by one. There are also many methods for fault-correction design and fault-tolerance design, and the appropriate method should be selected according to the site conditions. The anti-interference measures introduced above are some experiences explored in long-term practice, and are only presented here for reference.
Previous article:Share the design of camera lens control circuit based on 89C51
Next article:Interface between microcontroller and MMC card
- Popular Resources
- Popular amplifiers
- Molex leverages SAP solutions to drive smart supply chain collaboration
- Pickering Launches New Future-Proof PXIe Single-Slot Controller for High-Performance Test and Measurement Applications
- CGD and Qorvo to jointly revolutionize motor control solutions
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Nidec Intelligent Motion is the first to launch an electric clutch ECU for two-wheeled vehicles
- Bosch and Tsinghua University renew cooperation agreement on artificial intelligence research to jointly promote the development of artificial intelligence in the industrial field
- GigaDevice unveils new MCU products, deeply unlocking industrial application scenarios with diversified products and solutions
- Advantech: Investing in Edge AI Innovation to Drive an Intelligent Future
- CGD and QORVO will revolutionize motor control solutions
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- TI supports Bluetooth technology for high-precision body temperature measurement flexible PCB reference design
- Problems of charging and discharging dual capacitors in peak detectors
- EK140P Linux-4.1.15 Test Manual
- EEWORLD University Hall----Live Replay: HARTING- How to quickly and cost-effectively install cables in electrical control cabinets
- Introduction to Machine Vision Technology
- 【RT-Thread Reading Notes】1. RT-Thread RTOS Preface
- I would like to ask about an EXCEL curve fitting formula. I cannot get the value of Y by substituting the values of X (0, 150, 300). The value of Y is not correct.
- EEWORLD University ---- Sensors and Testing Technology
- The first question after the New Year is how dare I use this IGBT driving current.
- Bluetooth module interfaces