Handling of Electromagnetic Compatibility in Single Chip Design Process
“For novices, the influence of electromagnetic interference on the input and output of the design itself may not be paid much attention to in the circuit design of the single-chip microcomputer, but for an Electronic engineer, the relationship is self-evident. It not only It is related to the ability and accuracy of the single-chip microcomputer in the control, and it is also related to the competition of enterprises in the industry.
For novices, the influence of electromagnetic interference on the input and output of the design itself may not be paid much attention to in the circuit design of the single-chip microcomputer, but for an electronic engineer, the relationship is self-evident. It not only It is related to the ability and accuracy of the single-chip microcomputer in the control, and it is also related to the competition of enterprises in the industry.
We mainly design and 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 PCB design of the single-chip microcomputer to the software processing.
1. Factors affecting EMC
Higher supply voltages mean larger voltage amplitudes and more emissions, while lower supply voltages affect sensitivity.
High frequencies produce more emissions, and periodic signals produce more emissions. In a high-frequency microcontroller system, a current spike is generated when the device switches; in an analog system, a current spike is generated when the load current changes.
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, single-point grounding method can be used, but it is not suitable for high frequency; in high-frequency applications, it is best to use multi-point grounding. Hybrid grounding is a single-point grounding method for low frequencies and multi-point grounding for high frequencies. The layout of the ground wire is the key, and the ground circuits of high-frequency digital circuits and low-level analog circuits cannot be mixed as much as possible.
4. PCB Design
Proper printed circuit board (PCB) routing is critical to preventing EMI.
When devices switch, transient currents are generated on the power supply lines and must be attenuated and filtered. Transient currents from high di/dt sources cause ground and traces to “shoot” voltages, and high di/dt generates large-scale, high-frequency currents that excite components and radiate cables. Changes in current flow and inductance through the wire cause a voltage drop, which can be minimized by reducing the inductance or the change in current over time.
Second, the hardware processing method of interference measures
1.Electromagnetic Compatibility Design of Printed Circuit Board (PCB)
The PCB is the support for circuit components and devices in the single-chip microcomputer system, and it provides electrical connections between circuit components 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 design is correct and the printed circuit board is improperly designed, it will also have an adverse effect on the reliability of the single-chip microcomputer system. For example, if two thin parallel lines on a printed circuit board are very close together, there will be a delay in the signal waveform and reflection noise at the end of the transmission line. Therefore, when designing a printed circuit board, attention should be paid to adopting the correct method, complying with the general principles of PCB design, and should meet the design requirements for anti-interference. To obtain the best performance of electronic circuits, the layout of components and wiring is very important.
2.Electromagnetic Compatibility Design of Input/Output
In the single-chip microcomputer system, the input/output is also the conduction line of the interference source, and the pickup source for receiving the radio frequency interference signal. We generally take effective measures when designing:
① Use the necessary common mode/differential mode suppression circuit, and also take certain filtering and anti-electromagnetic shielding measures to reduce the interference.
② Take various isolation measures (such as photoelectric isolation or magnetoelectric isolation) as far as possible to block the spread of interference.
3.Design of Reset Circuit of Single-chip Microcomputer
In the single-chip microcomputer system, the watchdog system plays a particularly important role in the operation of the entire single-chip microcomputer. Since all the sources of interference cannot be isolated or removed, once the CPU interferes with the normal operation of the program, the reset system combined with Software processing measures become a barrier to an effective error correction defense. There are two commonly used reset systems:
①External reset system. The external “watchdog” circuit can be designed by yourself or built with a special “watchdog” chip. However, they have their own advantages and disadvantages. Most of the dedicated “watchdog” chips cannot respond to the low-frequency “feed the dog” signal, but can respond to the high-frequency “feed the dog” signal, so that it can be generated under the low-frequency “feed the dog” signal. The reset action does not occur under the high-frequency “feed the dog” signal. In this way, if the program system falls into an infinite loop, and the loop happens to have the “feed the dog” signal, then the reset circuit cannot realize it. the proper function. However, we can design a system with a band-pass “feed the dog” circuit and other reset circuits that 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 timers. However, some models of single-chip microcomputers have too simple reset instructions, which also There will be “feed the dog” instructions like the above infinite loop, making it lose its monitoring role. Some microcontrollers have better on-chip reset instructions. Generally, they make the “feed the dog” signal into multiple instructions in a fixed format and execute them in sequence. If there is a certain error, the “feed the dog” operation is invalid. The reliability of the reset circuit is improved.
Most microcontrollers have an oscillator circuit coupled to an external crystal or ceramic resonator. On the PCB, it is required that the leads of the external capacitors, crystals or ceramic resonators be as short as possible. RC oscillators have latent sensitivity to interfering signals and can generate very short clock cycles, so it is best to choose a crystal or ceramic resonator. In addition, the case of the quartz crystal should be grounded.
5.Lightning protection measures
The single-chip microcomputer system used outdoors or the power lines and signal lines introduced into the room from the outside should be considered against the lightning strike of the system. Commonly used lightning protection devices are: gas discharge tube, TVS (Transient Voltage Suppression) and so on. The gas discharge tube is when the voltage of the power supply is greater than a certain value, usually tens or hundreds of V, the gas breaks down and discharges, and the strong impulse pulse on the power line is guided into the ground. TVS can be regarded as two zener diodes in parallel and 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 transiently pass currents of hundreds or thousands of A.
3. Software processing method 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 harsh), and will eventually enter the core unit of the CPU processing, so that in some large-scale integration Circuits are often disturbed, causing them not to work properly or to operate in the wrong state. In particular, devices such as RAM that use bistable for storage, tend to flip under strong interference, so that the original stored “0” becomes “1”, or “1” becomes “0”; some serial The timing and data of transmission will change due to interference; more seriously, it will destroy some important data parameters, etc.; 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 be roughly in the following situations due to electromagnetic interference:
①The program runs away.
This situation is the most common interference result. Generally speaking, it is enough to have a good reset system or software frame measurement system, which will not have much impact on the entire running system.
② infinite loop or abnormal program code running.
Of course, this kind of infinite 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 the interference occurs, the PC pointer occurs. Change, so that the original program code is reorganized to produce unpredictable executable program code, then, this kind of error is fatal, it may modify important data parameters, and may produce unpredictable control A series of error states such as output.
2.Measures for 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; Read the code and make a decision. If there is a one-bit error, it will be automatically corrected, the correct data will be sent out, and at the same time, the corrected data will be written back to cover the original wrong data; if there is a two-bit error, an interrupt report will be generated, and the CPU will be notified to handle exceptions. All these actions are automatically completed by software design, and have 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 correction principle:
First, let’s look at the basic principles of error detection and correction. The basic idea of error control is to add redundancy codes in different ways to the information code group according to certain rules, so as to rely on the redundant monitoring code or check code to find or automatically correct errors when the information is read.
According to the characteristics of bit error occurrence, that is, the randomness and randomness of error occurrence, it almost always affects a certain bit (bit) in a certain byte at random. Therefore, if it can be designed to automatically correct a bit error, and Check for two-digit error encoding. It can greatly improve the reliability of the system.
3.Detection of RAM and FLASH (ROM)
When programming, it is best to write some testing programs to test the data codes 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 so that users can go to deal with.
In addition, it is indispensable to add program redundancy when programming. Adding three or more NOP instructions in a certain place can effectively prevent program reorganization. At the same time, flag data and detection state should be introduced in the running state of the program, so as to detect and correct errors in time.