[EMC/EMI Special Topic] MCU PCB Electromagnetic Interference Design
For the design of electromagnetic interference, we mainly carry out design processing from the hardware and software aspects. The following is an introduction to the processing of electromagnetic compatibility from the PCB design of the microcontroller to the software processing.
1. Factors affecting EMC
1. Voltage
The higher the power supply voltage, the greater the voltage amplitude, the more emissions, and low power supply voltage affects sensitivity.
2. Frequency
High frequencies produce more emissions, and periodic signals produce more emissions. In high-frequency microcontroller systems, current spikes are generated when the device switches; in analog systems, current spikes are generated when the load current changes.
3. Grounding
Among all EMC issues, the main problem is caused by improper grounding. There are three signal grounding methods: single point, multi-point and mixed. When the frequency is below 1MHz, the single-point grounding method can be used, but it is not suitable for high frequencies; in high-frequency applications, multi-point grounding is best used. Mixed grounding is a method of using single-point grounding for low frequencies and multi-point grounding for high frequencies. Ground layout is the key, and the grounding circuits of high-frequency digital circuits and low-level analog circuits should not be mixed.
4. PCB design
Proper printed circuit board (PCB) wiring is crucial to preventing EMI.
5. Power supply decoupling
When the device switches, transient currents will be generated on the power line, which must be attenuated and filtered out. Transient currents from high di/dt sources cause ground and trace voltages to "shoot" and high di/dt generates large-scale high-frequency currents that excite components and cables to radiate. The voltage drop caused by the change in current and inductance flowing through the wire can be minimized by reducing the inductance or the change in current over time.
2. Hardware processing methods for interference measures
1. Electromagnetic compatibility design of printed circuit board (PCB)
PCB is the support of circuit elements and devices in the single-chip microcomputer system, and it provides electrical connections between circuit elements and devices. With the rapid development of electronic technology, the density of PCB is getting higher and higher. The quality of PCB design has a great influence on the electromagnetic compatibility of the single-chip microcomputer system. Practice has proved that even if the circuit schematic is designed correctly, improper design of printed circuit board will also have an adverse effect on the reliability of the single-chip microcomputer system. For example, if the two thin parallel lines of the printed circuit board are very close, it will cause a delay in the signal waveform and form reflected noise at the terminal of the transmission line. Therefore, when designing a printed circuit board, you should pay attention to using the correct method, abide by the general principles of PCB design, and meet the design requirements of anti-interference. In order to achieve the best performance of electronic circuits, the layout of components and the layout of wires are very important.
2. Electromagnetic compatibility design of input/output
In the single-chip microcomputer system, input/output is also the transmission line of the interference source and the pickup source of receiving radio frequency interference signals. We generally take effective measures when designing:
① Use necessary common mode/differential mode suppression circuits, and also take certain filtering and anti-electromagnetic shielding measures to reduce the interference.
② Take various isolation measures (such as photoelectric isolation or magnetic isolation) as much as possible under the condition that conditions permit, so as to block the propagation of interference.
3. Design of single-chip reset circuit
In the single-chip system, the watchdog system plays a particularly important role in the operation of the entire single-chip. Since all interference sources cannot be completely isolated or removed, once the CPU interferes with the normal operation of the program, the reset system combined with software processing measures becomes an effective barrier for error correction and defense. There are two commonly used reset systems:
① External reset system. The external "watchdog" circuit can be designed by yourself or built with a dedicated "watchdog" chip. However, they each have their own advantages and disadvantages. Most dedicated "watchdog" chips cannot respond to low-frequency "feeding dog" signals, but can respond to high-frequency "feeding dog" signals, so that they can generate reset actions under low-frequency "feeding dog" signals and not under high-frequency "feeding dog" signals. In this way, if the program system falls into an infinite loop, and there happens to be a "feeding dog" signal in the loop, then the reset circuit cannot achieve its due function. However, we can design a system consisting of a passband "feeding the dog" circuit and other reset circuits, which is a very effective external monitoring system.
② Now more and more single-chip microcomputers have their own on-chip reset system, so that users can easily use their internal reset timer. However, the reset instructions of some models of single-chip microcomputers are too simple, so there will be "feeding the dog" instructions like the above-mentioned dead loop, which makes it lose its monitoring function. Some single-chip microcomputers have better on-chip reset instructions. Generally, they make the "feeding the dog" signal into multiple instructions in a fixed format and execute them in sequence. If there is a certain error, the "feeding the dog" operation is invalid, which greatly improves the reliability of the reset circuit.
4. Oscillator
Most single-chip microcomputers have an oscillator circuit coupled to an external crystal or ceramic resonator. On the PCB, the leads of the external capacitor, crystal or ceramic resonator are required to be as short as possible. The RC oscillator is potentially sensitive to interference signals and can produce very short clock cycles, so it is best to choose a crystal or ceramic resonator. In addition, the shell of the quartz crystal should be grounded.
5. Lightning protection measures
For single-chip computer systems used outdoors or power lines and signal lines introduced from the outdoors to indoors, lightning protection issues of the system must be considered. Commonly used lightning protection devices include: gas discharge tubes, TVS (Transient Voltage Suppression), etc. When the voltage of the power supply is greater than a certain value, usually tens of V or hundreds of V, the gas in the gas discharge tube breaks down and discharges, directing the strong impulse pulse on the power line into the ground. TVS can be regarded as two parallel Zener diodes in opposite directions, which are turned on when the voltage at both ends is higher than a certain value. Its characteristic is that it can pass hundreds or even thousands of A of current in a transient state.
3. Software processing methods for interference measures
The interference signal generated by the electromagnetic interference source cannot be completely eliminated in some specific cases (such as in some cases where the electromagnetic environment is relatively bad), and will eventually enter the core unit of the CPU processing, so that some large-scale integrated circuits are often interfered, resulting in malfunction or working in an error state. In particular, devices such as RAM that use bistable storage often flip under strong interference, causing the original stored "0" to become "1", or "1" to become "0"; the timing and data of some serial transmissions will change due to interference; more seriously, some important data parameters will be destroyed; the consequences are often very serious. In this case, the quality of software design directly affects the anti-interference ability of the entire system.
1. The program will generally have the following situations due to electromagnetic interference:
① The program will run away.
This situation is the most common interference result. Generally speaking, a good reset system or software frame test system is sufficient, and it will not have much impact on the entire running system.
② Dead loop or abnormal program code operation.
Of course, this kind of dead loop and abnormal program code are not intentionally written by the designers. We know that the instructions of the program are composed of bytes, some are single-byte instructions and some are multi-byte instructions. When interference occurs, the PC pointer changes, so that the original program code is reorganized to produce unpredictable executable program code. Then, this error is fatal. It may modify important data parameters and may produce a series of error states such as unpredictable control output.
2. Measures for the storage of important parameters
In general, we can use error detection and correction to effectively reduce or avoid the occurrence of this situation. According to the principle of error detection and correction, the main idea is that when the data is written, a certain number of check codes are generated according to the written data, and saved together with the corresponding data; when reading, the check code is also read out and judged. If a single error occurs, it will be automatically corrected, the correct data will be sent out, and the corrected data will be written back to cover the original erroneous data at the same time; if two errors occur, an interrupt report will be generated to notify the CPU to perform exception processing. All these actions are automatically completed by software design, with the characteristics of real-time and automatic completion. Through such a design, the anti-interference ability of the system can be greatly improved, thereby improving the reliability of the system.
Error detection and error correction principle:
First, let's look at the basic principles of error detection and error correction. The basic idea of error control is to add different types of redundant codes to the information code group according to certain rules, so that when the information is read out, it can rely on redundant monitoring codes or code correction codes to detect or automatically correct errors.
In view of the characteristics of bit error occurrence, that is, the randomness and small probability of error occurrence, it almost always randomly affects a certain bit in a byte. Therefore, if it is possible to design an encoding method that automatically corrects one bit error and checks two bits of error. It can greatly improve the reliability of the system.
3. Detection of RAM and FLASH (ROM)
When compiling a program, it is best to write some detection programs to test the data code of RAM and FLASH (ROM) to see if there is any error. Once it occurs, it should be corrected immediately. If it cannot be corrected, an error indication should be given in time for the user to handle it.
In addition, it is indispensable to add program redundancy when compiling a program. Adding three or more NOP instructions in certain places has a very effective preventive effect on program reorganization. At the same time, flag data and detection status should be introduced in the running state of the program to detect and correct errors in time.
↓↓↓ Click "Read original text" [View related links in the text]