We mainly deal with the design of electromagnetIC interference from the hardware and software aspects, and the following is the introduction of electromagnetic compatibility from the microcontroller to the software processing.
1、 Factors affecting EMC
1. Voltage
The higher the power supply voltage is, the greater the voltage amplitude is, and more EMIssions will occur. The lower the power supply voltage affects the sensitivity.
2. Frequency
High frequency generates more emission, and periodic signal generates more emission. In the high frequency single chip microcomputer system, the current SPIke signal is generated when the device is switched; In an analog system, current spikes are generated when the load current changes.
3. Grounding
Among all EMC problems, the main problem is caused by improper grounding. There are three signal grounding methods: single point, multi-point and mixed. When the frequency is lower than 1MHz, the single point grounding method can be used, but it is not suitable for high frequency; In high-frequency applications, multi-point grounding is preferred. Hybrid grounding is a method of low frequency grounding with single point, while high frequency grounding with multiple points. Ground wire layout is the key. The ground circuit of high frequency digital circuit and low level analog circuit should not be mixed.
4. PCB design
Proper PCB wiring is essential to prevent EMI.
5. Power supply coupling
When the device is switched, transient currents will be generated on the power line, and these transient currents must be attenuated and filtered. The transient current from the high di/dt source leads to the "emission" voltage of the ground and the trace, and the high di/dt generates a large range of high-frequency current to stimulate the radiation of components and cables. The current variation and inductance through the conductor will lead to voltage drop, which can be minimized by reducing the inductance or the change of current over time.
2、 Hardware processing method for interference measures
1. Electromagnetic compatibility design of printed circuit board (PCB)
PCB is the supporting part of circuit components and devices in the microcontroller system, which provides the electrical connection between circuit components and PCB 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 impact on the electromagnetic compatibility of the single-chip microcomputer system. Practice has proved that even if the circuit schematic is correctly designed and the printed circuit board is improperly designed, the reliability of the single-chip microcomputer system will be adversely affected. For example, if two thin parallel lines of the printed circuit board are close together, the delay of the signal waveform will be formed and the reflected noise will be formed at the end of the transmission line. Therefore, when designing printed circuit boards, attention should be paid to adopting correct methods, following the general principles of PCB design, and meeting the anti-interference design requirements. In order to obtain the best performance of electronic circuits, the Layout of components and wires is very important.
2. EMC design of input/output
In the SCM system, the input/output is also the transmission wire of the interference source, and the pickup source for receiving RF interference signals. In general, we should take effective measures when designing:
① Necessary common mode/differential mode suppression PCB circuit shall be adopted, and certain filtering and anti electromagnetic shielding measures shall also be taken to reduce the advance of interference.
② If conditions permit, various isolation measures (such as photoelectric isolation or magnetoelectric isolation) shall be taken as far as possible to block the propagation of interference.
3. PCB design of MCU reset circuit
In the microcontroller system of, the watchdog system plays a particularly important role in the operation of the entire microcontroller. Because all interference sources cannot be isolated or removed, once the CPU interferes with the normal operation of the program, the reset system combined with software processing measures will become an effective error correction defense barrier. There are two common reset systems:
① External reset system. The external "watchdog" circuit can be designed or built with a special "watchdog" chip. However, they have their own advantages and disadvantages. Most of the special "watchdog" chips cannot respond to low-frequency "dog feeding" signals, while high-frequency "dog feeding" signals can respond, so that they can generate reset action under low-frequency "dog feeding" signals and not reset action under high-frequency "dog feeding" signals. In this way, if the program system is trapped in an endless cycle, and there happens to be a "dog feeding" signal in the cycle, Then the reset circuit cannot realize its due function. However, we can design a system consisting of band-pass "dog feeding" 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 systems, so that users can easily use their internal reset timers. However, there are some models of single-chip microcomputers whose reset instructions are too SIMple, so there will also be "dog feeding" instructions like the above endless loop, which makes them lose their monitoring role. Some SCM chip reset instructions do a better job. Generally, they make the "dog feeding" signal into a fixed format of multiple instructions to execute in order. If there is a certain error, the "dog feeding" operation is invalid, which greatly improves the reliability of the reset circuit.
4. PCB oscillator
Most single chip microcomputers have an oscillator circuit coupLED to an external crystal or ceramic resonator. On PCB, it is required that the lead of capacitor, crystal or ceramic resonator should be as short as possible. RC oscillator has a latent sensitivity to interference signals. It can produce very short clock cycles, so crystal or ceramic resonator is the best choice. In addition, the shell of quartz crystal shall be grounded.
5. Lightning protection measures
The lightning protection of the system shall be considered for the single chip microcomputer system used outdoors or the power line and signal line introduced from outdoors. Common lightning protection devices include: gas discharge tube, TVS (Transient Voltage Suppression), etc. When the voltage of the power supply is greater than a certain value, it is usually tens or hundreds of volts. The gas breaks down and discharges, leading the strong impact pulse on the power line to the ground. TVS can be seen as two Zener diodes in parallel and in opposite directions. When the voltage at both ends is higher than a certain value, the TVS will conduct. Its characteristic is that it can transiently pass hundreds or even thousands of amperes.
3、 Software processing method for interference measures
The interference signal generated by the electromagnetic interference source cannot be completely eliminated under some specific circumstances (such as under some harsh electromagnetic environment), and will eventually enter the core unit processed by the CPU. In this way, some large-scale integrated circuits are often interfered, resulting in failure to work normally or in an error state. In particular, devices such as RAM that use bistability for storage tend to flip under strong interference, making the original "0" become "1", or "1" become "0"; The time sequence and data of some serial transmission will change due to interference; More seriously, some important data parameters will be damaged; The consequences are often very serious. In this case, the quality of software design directly affects the anti-interference ability of the whole system.
1. The program will roughly meet the following conditions due to electromagnetic interference:
① The program runs.
This is the most common interference result. Generally speaking, a good reset system or software frame measurement system is enough, and it will not have too much impact on the entire operating system.
② Loop or abnormal program code operation.
Of course, this kind of endless loop and abnormal program code is not intentionally written in by the designer. We know that program instructions 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 generate a series of error states such as unpredictable control output.
2. Measures for storage of important parameters
Generally, we can use error detection and correction to effectively reduce or avoid this situation. According to the principle of error detection and correction, the main idea is that when the data is written in, a check code with a certain number of digits is generated according to the written data and saved together with the corresponding data; When reading, the check code is also read out to make a decision. If an error occurs, it will be corrected automatically, the correct data will be sent, and the corrected data will be written back to overwrite the original error data at the same time; If a two bit error occurs, an interrupt report is generated to notify the CPU to handle the exception. All these actions are automatically completed by software design, with the characteristics of real-time and automatic completion. Through such design, the anti-interference ability of the system can be greatly improved, thus improving the reliability of the system.