Anti-interference measures of single chip microcomputer in embedded system application

Publisher:HarmoniousVibesLatest update time:2011-08-27 Source: EEWORLD Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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.

Reference address:Anti-interference measures of single chip microcomputer in embedded system application

Previous article:Share the design of camera lens control circuit based on 89C51
Next article:Interface between microcontroller and MMC card

Latest Industrial Control 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号