Single-Chip Microcomputer
For novices, electromagnetic interference may not pay much attention to the influence of circuit design on the input and output of the design itself, but for an electronic engineer, it is self-evident. It is not only related to the ability and accuracy of MCU in control, but also related to the competition of enterprises in the industry.
We mainly deal with the design of electromagnetic interference from the aspects of hardware and software. The following is to introduce the treatment of electromagnetic compatibility from the aspects of PCB design of single chip microcomputer to software treatment.
I. Factors Affecting EMC
1. voltage
The higher the power supply, the greater the voltage amplitude, and the more emissions, while the lower power supply voltage affects the sensitivity.
2. Frequency
High frequency produces more emission, and periodic signal produces more emission. In the high-frequency single-chip microcomputer system, when the device is switched on and off, a current spike signal is generated; In an analog system, when the load current changes, a current spike signal is generated.
3. Grounding
Among all EMC problems, the main problem is improper grounding. There are three signal grounding methods: single point, multipoint and hybrid. When the frequency is lower than 1MHz, the single-point grounding method can be adopted, but it is not suitable for high frequency. In high frequency applications, it is best to use multi-point grounding. Hybrid grounding is the method of single-point grounding for low frequency and multi-point grounding for high frequency. The layout of ground wire 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 wiring of printed circuit board (PCB) is essential to prevent EMI.
5. Power supply coupling
When the device is switched on and off, transient current will be generated on the power line, which must be attenuated and filtered. The transient current from the high di/dt source causes the ground and trace to “emit” voltage, and the high di/dt produces a wide range of high-frequency current, which excites components and cables to radiate. The change of current flowing through the wire and inductance will lead to voltage drop, which can be minimized by reducing the change of inductance or current with time.
Second, the hardware processing method of interference measures
1. electromagnetic compatibility design of printed circuit board (PCB)
It is the support of circuit elements and devices in PCB single chip microcomputer system, and it provides the electrical connection between circuit elements and devices. With the rapid development of electronic technology, the density of PCB becomes higher and higher. The design of PCB has a great influence on the electromagnetic compatibility of single-chip microcomputer system. Practice has proved that even if the circuit schematic design is correct and the printed circuit board design is improper, the reliability of single-chip microcomputer system will be adversely affected. For example, if two thin parallel lines of the printed circuit board are close together, the signal waveform will be delayed and the reflected noise will be formed at the terminal of the transmission line. Therefore, when designing printed circuit boards, we should pay attention to adopting correct methods, observing 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. Electromagnetic compatibility design of input/output
In the single chip microcomputer system, the input/output is also the conductive line of the interference source, and the pick-up and detection source for receiving the RF interference signal. Generally, we should take effective measures when designing:
① Adopt the necessary common mode/differential mode suppression circuit, and at the same time take certain filtering and anti-electromagnetic shielding measures to reduce interference.
② Take various isolation measures (such as photoelectric isolation or magnetoelectric isolation) as far as possible when conditions permit, so as to block the spread of interference.
3. Design of reset circuit of single chip microcomputer.
In the MCU system, the watchdog system plays a particularly important role in the operation of the whole MCU. Because all interference sources can’t be isolated or eliminated, once the CPU interferes with the normal operation of the program, the reset system combined with software processing measures will become an effective barrier for error correction and defense. There are the following two common reset systems:
① External reset system. The external “watchdog” circuit can be designed by itself or built with a special “watchdog” chip. However, they have their own advantages and disadvantages. Most dedicated watchdog chips can’t respond to the low-frequency dog-feeding signal, but the high-frequency dog-feeding signal can respond, so that they can reset under the low-frequency dog-feeding signal but not under the high-frequency dog-feeding signal. In this way, if the program system falls into an infinite loop, and there happens to be a dog-feeding signal in the loop. However, we can design a system with a band-pass “dog feeding” circuit and other reset circuits, which is a very effective external monitoring system.
② Nowadays, more and more single-chip microcomputers have their own on-chip reset systems, so that users can easily use their internal reset timers. However, some models of single-chip microcomputers have too simple reset instructions, so that there will be “dog feeding” instructions like the above-mentioned infinite loop, which will make them lose their monitoring function. Some on-chip reset instructions of single-chip microcomputers do well. Generally, they make the “dog-feeding” signal into a number of instructions in a fixed format to be executed in sequence. If there is a certain error, the “dog-feeding” operation will be invalid, thus greatly improving 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, it is required that the lead of capacitor, crystal or ceramic resonator be connected as short as possible. RC oscillator has latent sensitivity to interference signals, and it can produce a short clock cycle, so it is best to choose crystal or ceramic resonator. In addition, the shell of Shi Ying crystal should be grounded.
5. Lightning protection measures
The problem of lightning protection of the system should be considered when the outdoor single chip microcomputer system is used or the power line and signal line introduced indoors are squeezed out from the outdoor. Commonly used lightning protection devices are: gas discharge tube, TVs (TransientVoltageSuppression), etc. The gas discharge tube is when the voltage of the power supply is greater than a certain value, usually tens or hundreds of volts, and the gas breaks down and discharges, leading the strong impact pulse on the power supply line into the earth. TVS can be regarded as two parallel Zener diodes with opposite directions, which are turned on when the voltage at both ends is higher than a certain value. Its characteristic is that it can transiently pass through hundreds of thousands of A currents.
Third, the software processing method of interference measures
The interference signal generated by the electromagnetic interference source can’t be completely eliminated in some specific situations (such as in some harsh electromagnetic environment), and will eventually enter the core unit of CPU processing, so that some large-scale integrated circuits are often disturbed, resulting in abnormal operation or wrong operation. Especially, devices such as RAM, which use bistable storage, tend to flip under strong interference, so that the original stored “0” becomes “1” or “1” becomes “0”; Some serial transmission timing and data 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 whole system.
1. due to electromagnetic interference, the program will roughly meet the following situations:
① The program runs away.
This kind of situation is the most common interference result. Generally speaking, a good reset system or software frame measurement system is enough, which will not have much impact on the whole running system.
② infinite loop or abnormal program code running.
Of course, this kind of infinite loop and abnormal program code is not intentionally written by the design staff. We know that the program instructions are composed of bytes, some of which are single-byte instructions and some of which are multi-byte. When the interference occurs, the PC pointer changes, thus the original program code is reorganized and unpredictable executable program code is produced. Then, this kind of error is fatal, and 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 this situation. According to the principle of error detection and correction, the main idea is that when data is written in, a certain number of check codes are generated according to the written data, and stored together with the corresponding data; When reading out, the check code is also read out for judgment. If there is a bit error, it will be automatically corrected, the correct data will be sent out, and the corrected data will be written back to cover the original wrong data. If there are two-digit errors, an interrupt report will be generated, and the CPU will be notified to handle the exception. All these actions are completed automatically by software design, which has the characteristics of real-time and automatic completion. Through this design, the anti-interference ability of the system can be greatly improved, thus improving the reliability of the system.
Principle of error detection and correction:
Let’s first look at the basic principles of error detection and correction. The basic idea of error control is to add redundant codes in different ways in the information code group according to certain rules, so that when information is read out, the redundant monitoring codes or correction codes can be used to find or automatically correct errors.
Aiming at the occurrence of error code