Electromagnetic compatibility solution designed by single chip microcomputer
The design of electromagnetic interference is mainly designed and processed from hardware and software. The following is the introduction of electromagnetic compatibility from the PCB design of the microcontroller to the software processing.
First, the factor affecting EMC
The higher the supply voltage, the greater the voltage amplitude, the more emissions, and the lower supply voltage affects the sensitivity.
High frequencies produce more emissions, and periodic signals produce more emissions. In a high-frequency single-chip system, a current spike is generated when the device is switched; in an analog system, a current spike is generated when the load current changes.
In all EMC topics, the main topic is caused by improper grounding. There are three ways to signal ground: single point, multiple points, and hybrid. When the frequency is lower than 1MHz, a 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 in which the low frequency is grounded at a single point and the high frequency is grounded at multiple points. The ground wire layout is the key, and the grounding circuit of the high-frequency digital circuit and the low-level analog circuit cannot be mixed.
4. PCB design
Proper printed circuit board (PCB) routing is critical to preventing EMI.
5. Power supply coupling
When the device is switched, transient currents are generated on the power line and these transient currents must be attenuated and filtered out. Transient currents from high di/dt sources cause ground and trace "emission" voltages, and high di/dt produces a wide range of high frequency currents that excite components and cable radiation. Current changes and inductance through the wire can cause a voltage drop that can be minimized by reducing inductance or current changes over time.
Second, the hardware processing method for interference measures
1. Electromagnetic compatibility design of printed circuit boards (PCBs)
A PCB is a support for circuit components and devices in a microcontroller system that provides electrical connections between circuit components and devices. With the rapid development of electronic technology, the density of PCBs is getting higher and higher. The quality of the PCB design has a great impact on the electromagnetic compatibility of the single-chip system. Practice has confirmed that even if the schematic design of the circuit is correct and the printed circuit board is not properly designed, it will adversely affect the reliability of the single-chip system. For example, if the two thin parallel lines of the printed circuit board are close together, a delay in the signal waveform is formed, and reflected noise is formed at the end of the transmission line. Therefore, when designing a printed circuit board, you should pay attention to the correct method, comply with the general principles of PCB design, and should meet the anti-interference design requirements. In order to get the best performance of the electronic circuit, the layout of the components and the layout of the wires are very important.
2. Input/output electromagnetic compatibility design
In the MCU system, the input/output is also the transmission line of the interference source, and the source of the detection of the RF interference signal. We must take effective measures when designing:
1 Use the necessary common mode / differential mode suppression circuit, and also take certain filtering and anti-electromagnetic shielding measures to reduce the interference.
2 Whenever possible, take various isolation measures (such as optical isolation or magnetoelectric isolation) to block the spread of interference.
3. Design of single chip reset circuit
In the single-chip microcomputer system, the watchdog system plays a particularly important role in the operation of the whole single-chip microcomputer. Since all the interference sources cannot be completely isolated or removed, once the CPU interferes with the normal operation of the program, the reset system is combined. Software processing has become an effective barrier to correcting defenses. There are two commonly used reset systems:
1 external reset system. The external "watchdog" circuit can be designed by itself or by a special "watchdog" chip. However, they have their own advantages and disadvantages. Most of the dedicated "watchdog" chips can't respond to low-frequency "feeding dog" signals, while high-frequency "feeding dogs" signals can respond, resulting in low-frequency "feeding dogs" signals. The reset action does not generate a reset action under the high frequency "feed dog" signal, so that if the program system is stuck in an infinite loop, and the loop happens to have a "feed dog" signal, then the reset circuit cannot implement it. The proper function. However, we can design a system with a bandpass "feed dog" circuit and other reset circuits to be a very effective external monitoring system.
2 Now more and more single-chip computers have their own on-chip reset system, so users can easily use their internal reset timer, but there are some models of microcontrollers whose reset instructions are too simple, so There will be a "feed dog" command like the above-mentioned infinite loop, which will cause it to lose its monitoring role. Some on-chip reset instructions of the MCU are better. Generally, they use the "feed dog" signal as a fixed format to execute multiple instructions in sequence. If there is a certain error, the "feed dog" operation is invalid. The reliability of the reset circuit is improved.
Most microcontrollers have an oscillator circuit that is coupled to an external crystal or ceramic resonator. On the PCB, it is required that the external leads are capacitors, crystals or ceramic resonators as short as possible. The RC oscillator has a latent sensitivity to interfering signals, which can produce very short clock cycles, so it is best to choose a crystal or ceramic resonator. In addition, the outer casing of the quartz crystal should be grounded.
5. Lightning protection measures
The outdoor-use single-chip system or the power cord and signal line that is introduced from the outside to be introduced into the room should consider the lightning protection problem of the system. Commonly used lightning protection devices are: gas discharge tube, TVS (Transient Voltage Suppression) and the like. The gas discharge tube is a gas breakdown discharge when the voltage of the power source is greater than a certain value, usually tens of V or hundreds of V, and the strong shock pulse on the power line is led into the earth. TVS can be viewed as two parallel and opposite Zener diodes that conduct when the voltage across the terminals is above a certain value. It is characterized by the ability to transiently pass hundreds of thousands of currents.
Third, the software processing method for interference measures
The interference signal generated by the electromagnetic interference source can not be completely eliminated under certain circumstances (such as in some cases where the electromagnetic environment is relatively bad), and the ultimate will enter the core unit of the CPU processing, so that in some large-scale integration Circuits are often subject to interference, resulting in malfunction or malfunction. In particular, devices such as RAM that use bistable storage tend to flip under strong interference, causing the original stored "0" to become "1", or "1" becomes
“0”; the timing and data of some serial transmissions will change due to interference; more serious will destroy some important data parameters, etc.; the consequences are often very serious. In this case, the quality of the software design directly affects the anti-interference ability of the entire system.
1. The program will roughly look at several situations due to electromagnetic interference:
1 program runs away.
This situation is the most common interference result. Generally speaking, there is a good reset system or software frame measurement system, which will not have much impact on the entire operating system.
2 dead loops or abnormal program code runs.
Of course, this kind of infinite loop and abnormal program code is not intentionally written by the designer. We know that the program instructions are composed of bytes, some are single-byte instructions and some are multi-byte instructions. When the interference is generated, the PC pointer is generated. Changes, so that the original program code has been reorganized to produce unpredictable executable program code, then, this error is fatal, it may modify important data parameters, it may produce unguessable control Output a series of error states.
2. Measures for the storage of important parameters
In general, we can use error detection and correction to effectively reduce or avoid this situation. According to the principle of error detection and error correction, the main idea is to save the data with a certain number of bits according to the written data when the data is written in, and save it together with the corresponding data; when reading, it will also be verified. The code is read out and the decision is made. If a bit error occurs, it will be automatically corrected, and the correct data will be sent out, and the corrected data will be written back to overwrite the original error data; if two errors occur, an interrupt report will be generated to notify the CPU of the exception handling. All of these actions are done automatically by software design, with real-time and auto-complete features. 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 correction principle:
First, let's take a look at the basic principles of error detection and correction. The basic idea of error control is to add different ways of redundancy codes in the information code group to find or automatically correct errors when the information is read out by relying on redundant monitoring codes or calibration codes.
Regarding the characteristics of the occurrence of errors, that is, the randomness and smallness of the occurrence of errors, it almost always randomly affects a bit in a certain byte, so if it can be designed to automatically correct a bit error, Check the encoding of the two errors. It can greatly improve the reliability of the system.
3. Detection of RAM and FLASH (ROM)
When programming, we should write some test programs to test the RAM and FLASH (ROM) data code to see if there is any error. If it happens, it should be corrected immediately. If it can't be corrected, it should give an error indication in time for the user to go. deal with.
In addition, it is indispensable to add program redundancy when programming. Adding three or more NOP commands to a certain place has a very effective effect on the reorganization of the program. At the same time, the flag data and detection status should be introduced in the running state of the program, so as to timely discover and correct the error.