A microcontroller system is electromagnetically compatible if it meets the following three conditions:
① It does not interfere with other systems; ② It is not sensitive to the transmission of other systems; ③ It does not interfere with the system itself.
Even if interference cannot be completely eliminated, it should be minimized. Interference is generated either directly (through conductors, common impedance coupling, etc.) or indirectly (through crosstalk or radiation coupling). Electromagnetic interference is generated through conductors and through radiation. Many electromagnetic emission sources, such as light, relays, DC motors, and fluorescent lamps, can cause interference; AC power lines, interconnecting cables, metal cables, and internal circuits of subsystems can also generate radiation or receive unwanted signals. In high-speed microcontroller systems, clock circuits are often the biggest source of broadband noise, generating harmonic distortion up to 300 MHz, and should be removed from the system. Additionally, in microcontroller systems, reset lines, interrupt lines, and control lines are most susceptible to interference.
01
Interference coupling methods
1. Conductive EMI
One of the most obvious, yet often overlooked, paths that can cause noise in a circuit is through conductors. A wire running through a noisy environment can pick up noise and transmit it to other circuits, causing interference. Designers must prevent wires from picking up noise and remove noise through decoupling before it causes interference. The most common example is noise entering the circuit through power lines. If the power supply itself or other circuits connected to it are sources of interference, they must be decoupled before the power line enters the circuit.
2. Common impedance coupling
Common impedance coupling occurs when currents from two different circuits flow through a common impedance. The voltage drop across the impedance is determined by the two circuits, and ground currents from both circuits flow through the common ground impedance. The ground potential of circuit 1 is modulated by ground current 2, and noise signals or DC compensation are coupled from circuit 2 to circuit 1 through the common ground impedance.
3. Radiative coupling
Coupling via radiation is commonly referred to as crosstalk. Crosstalk occurs when current flows through a conductor, generating an electromagnetic field, which induces transient currents in nearby conductors.
4. Radiated emission
There are two basic types of radiated emissions: differential mode (DM) and common mode (CM). Common mode radiation, or monopole antenna radiation, is caused by an unintentional voltage drop that raises all ground connections in the circuit above the system ground potential. In terms of electric field magnitude, CM radiation is a more serious problem than DM radiation. To minimize CM radiation, the common mode current must be reduced to zero through a practical design.
02
Factors affecting EMC
① Voltage. A higher power supply voltage means a larger voltage amplitude and more emissions, while a low power supply voltage affects sensitivity.
② Frequency. Higher frequencies generate more emissions, and periodic signals generate more emissions. In high-frequency microcontroller systems, current spikes are generated when devices switch on or off; in analog systems, current spikes are generated when the load current changes.
③ Grounding. Of all EMC problems, the primary cause is improper grounding. There are three signal grounding methods: single-point, multi-point, and hybrid. Single-point grounding can be used below 1 MHz, but it is not suitable for high frequencies; in high-frequency applications, multi-point grounding is preferable. Hybrid grounding uses single-point grounding for low frequencies and multi-point grounding for high frequencies. Grounding layout is crucial; ground loops for high-frequency digital circuits and low-level analog circuits must never be mixed.
④ PCB Design. Proper printed circuit board (PCB) routing is crucial for preventing EMI.
⑤ Power supply decoupling. Transient currents are generated on power lines when devices switch on and off. These transient currents must be attenuated and filtered out. Transient currents from high di/dt sources cause ground and trace "emission" voltages. High di/dt generates a wide range of high-frequency currents, exciting components and cables to radiate. Changes in current flowing through conductors and inductance cause voltage drops; reducing inductance or the change in current over time minimizes these voltage drops.
03
Electromagnetic compatibility design of printed circuit boards (PCBs)
A PCB (Printed Circuit Board) is the supporting structure for circuit components and devices in a microcontroller system, providing electrical connections between them. With the rapid development of electronic technology, PCB density is increasing. The quality of PCB design significantly impacts the electromagnetic compatibility (EMC) of a microcontroller system. Experience has shown that even with a correct circuit schematic, improper PCB design can negatively affect the reliability of the microcontroller system. For example, if two thin parallel lines on the PCB are too close together, it can cause signal waveform delays and create reflected noise at the transmission line's termination. Therefore, when designing PCBs, it is crucial to employ correct methods, adhere to general PCB design principles, and meet anti-interference design requirements.
I. General Principles of PCB Design
To achieve optimal performance in electronic circuits, the placement of components and the routing of wires are crucial. To design high-quality, low-cost PCBs, the following general principles should be followed.
1. Layout of special components
First, consider the PCB size: If the PCB is too large, the printed lines are long, impedance increases, noise immunity decreases, and cost increases; if it's too small, heat dissipation is poor, and adjacent lines are easily interfered with. After determining the PCB size, determine the location of special components. Finally, based on the functional units of the circuit, arrange all components.
The following principles should be followed when determining the location of special components:
① Minimize the connections between high-frequency components to reduce their distributed parameters and mutual electromagnetic interference. Components susceptible to interference should not be placed too close to each other, and input and output components should be kept as far apart as possible.
② There may be a high potential difference between some components or wires. The distance between them should be increased to prevent accidental short circuits caused by discharge. High-voltage components should be placed in places that are not easily accessible by hand during debugging.
③ Components weighing more than 15 g should be secured with a bracket before soldering. Large, heavy components that generate a lot of heat should not be mounted on the printed circuit board, but rather on the chassis base plate of the entire machine, and heat dissipation should be considered. Thermistors should be kept away from heat-generating components.
④ The layout of adjustable components such as potentiometers, adjustable inductors, variable capacitors, and microswitches should take into account the overall structural requirements of the machine. If the adjustment is internal, it should be placed in a convenient location on the printed circuit board; if the adjustment is external, its position should be compatible with the position of the adjustment knob on the chassis panel.
⑤ Leave space for the positioning holes of the printing plate and the space occupied by the fixing bracket.
2. General component layout
When arranging all components of a circuit according to its functional units, the following principles should be followed:
① Arrange the positions of each functional circuit unit according to the circuit flow to facilitate signal flow and keep the signals in the same direction as much as possible.
② Center the layout around the core component of each functional circuit. Components should be arranged evenly, neatly, and compactly on the PCB, minimizing and shortening the leads and connections between components.
③ For circuits operating at high frequencies, the distributed parameters between components must be considered. Generally, components should be arranged in parallel as much as possible in circuits. This is not only aesthetically pleasing but also facilitates assembly and soldering, and is conducive to mass production.
④ Components located at the edge of the circuit board should generally be at least 2 mm away from the edge. The optimal shape for the circuit board is rectangular, with an aspect ratio of 3:2 or 4:3. When the circuit board dimensions are greater than 200 mm × 150 mm, the mechanical strength of the circuit board should be considered.
3. Wiring
The principles of wiring are as follows:
① The wires used for input and output terminals should avoid being adjacent and parallel as much as possible. It is best to add a ground wire between the wires to avoid feedback coupling.
② The minimum width of printed circuit board (PCB) conductors is primarily determined by the adhesion strength between the conductor and the insulating substrate and the current flowing through them. When the copper foil thickness is 0.5 mm and the width is 1–15 mm, the temperature rise will not exceed 3°C when a 2 A current flows through it. Therefore, a conductor width of 1.5 mm is sufficient. For integrated circuits, especially digital circuits, a conductor width of 0.02–0.3 mm is typically chosen. Of course, wider lines should be used whenever possible, especially power and ground lines. The minimum spacing between conductors is primarily determined by the worst-case insulation resistance and breakdown voltage. For integrated circuits, especially digital circuits, the spacing can be less than 0.1–0.2 mm, provided the process allows.
③ Printed conductor bends are generally rounded, while right angles or included angles can affect electrical performance in high-frequency circuits. Furthermore, avoid using large areas of copper foil, as prolonged heating can cause the copper foil to expand and detach. If large areas of copper foil must be used, a grid pattern is preferable, as this helps to dissipate volatile gases generated by the adhesive between the copper foil and the substrate when heated.
4. Solder pads
The center hole of the solder pad should be slightly larger than the diameter of the device lead. Too large a solder pad can easily lead to cold solder joints. The outer diameter D of the solder pad is generally not less than (d+1.2) mm, where d is the lead hole diameter. For high-density digital circuits, the minimum solder pad diameter can be (d+1.0) mm.
Electromagnetic compatibility (EMC) includes EMI (interference) and EMS (susceptibility), which are electromagnetic interference and electromagnetic immunity, respectively. With the development of intelligent technologies, the application of microcontrollers is becoming increasingly widespread. Although microcontrollers themselves have a certain degree of interference immunity, control systems based on microcontrollers still face electromagnetic interference issues in application. To prevent external EMI from influencing the system and to ensure the safe and reliable operation of the microcontroller control system, appropriate EMS measures must be taken.
1. Analysis of the causes of EMI
In the operating environment of a microcontroller system, there are often many high-voltage devices, especially motor starting and relay activation, which can cause strong interference to the microcontroller. Using an oscilloscope, obvious glitches and interference can be seen on the power supply voltage waveform. Furthermore, due to limitations, the various parts of the microcontroller control system may be far apart, and data and control lines may use long wires without proper shielding, making it easier for electromagnetic interference to infiltrate the system.
In summary, EMI in microcontroller systems always enters through radiation and power supply loops, primarily via three pathways: First, the input pathway, which distorts analog signals and introduces errors in digital signals. If the system processes these faulty signals, the results will inevitably be incorrect. Second, the output pathway, where interference superimposes on various output signals, causing chaotic output signals that fail to accurately represent the system's processing results. Third, interference from the microcontroller's internal bus, which disrupts internal digital signals on the control, address, and data buses, leading to MCU errors, program crashes, or even complete system shutdowns.
2. Main research directions of EMS technology
In response to the causes and pathways of interference in microcontroller systems, EMS technology mainly focuses on hardware shielding, isolation, filtering, grounding, and software programming.
Shielding is primarily used to cut off the propagation path of electromagnetic noise formed by electrostatic coupling, inductive coupling, or alternating electromagnetic field coupling. Electrostatic shielding, magnetic field shielding, and electromagnetic shielding can be used to address these three types of coupling, respectively. Research directions in shielding technology mainly focus on the shielding effectiveness of various materials such as metals, magnetic materials, and composite materials; the shielding effectiveness of various structures such as multilayer, single-layer, and porous structures; the shielding effectiveness of shields of various shapes; the design of shields; and the relationship between shielding and grounding.
Isolation is used to cut off the propagation path of conducted electromagnetic noise. Research on isolation technology mainly focuses on using AC relays, isolation transformers, or opto-isolators for isolation. Its key feature is that it can separate the ground systems of two circuit parts, cutting off the possibility of coupling through the ground system.
Filtering is a technique used to cut off noise propagation in the frequency domain. Research in filtering technology focuses on using filtering devices such as capacitors and inductors to remove unwanted portions of the spectrum, retaining only the desired signals. For example, a power supply filter might retain only the 50Hz power frequency while filtering out all other high- and low-frequency electromagnetic noise.
Grounding provides a common path for useful signals and electromagnetic noise. Research in grounding technology focuses on grounding methods for safety ground, signal ground, power neutral, and various ground wires within a system. Key considerations include the proper arrangement of digital and analog grounds, the design of grounding electrodes, and the impedance of ground wires at different frequencies.
Hardware anti-interference measures create a basically clean working environment for the microcontroller system, but they cannot guarantee the complete absence of noise. Therefore, software anti-interference measures must be incorporated. Software anti-interference technology involves specific programs within the microcontroller system taking effect when the system is interfered with, enabling the system to reset and resume normal operation, such as a watchdog timer. Alternatively, it can be a programming aid method, such as a digital filter, that filters out interference from input signals using specific programming techniques. This technology offers diverse and flexible programming designs, significantly reduces hardware costs, and simplifies debugging and operation.
3. Specific Applications of EMS Technology
3.1 Application of Hardware EMS Technology
(1) Good grounding method
Microcontroller control systems operate at low frequencies, and the interference frequencies affecting them are mostly below 1MHz. Therefore, a single-point independent grounding is recommended. However, it's important to ensure that the ground wire length does not exceed 1/20 of the wavelength. There are two types of single-point grounding: series grounding and parallel grounding. When using series grounding, to prevent interference, the ground wire between each branch should be as short as possible, and the wire diameter should be sufficiently thick. For lower voltage levels, the ground wire should be placed as close to the power supply as possible. Conversely, parallel grounding ensures that the voltage drops generated by the current in each branch do not affect each other, preventing interference and providing better performance.
(2) Opto-isolation
Using opto-isolators on the input and output channels for information transmission electrically isolates the microcontroller system from various sensors, switches, relays, and other mechanisms, much like a PLC, blocking out most external interference. Useful digital signals can be transmitted without problems using optocouplers, while analog signals can be transmitted using linear optocouplers to ensure quality.
(3) Hardware filtering
When transmitting low-frequency signals to a microcontroller system, using RC low-pass filters can significantly reduce the effects of various high-frequency interference signals. When the microcontroller system has high power supply requirements, a power supply filter can be used to retain only the 50Hz power frequency, filtering out all other high- and low-frequency electromagnetic noise.
(4) Shielding
Shielding is highly effective against interference caused by various forms of electromagnetic induction. Enclosing the microcontroller core system in a metal shell and then grounding the metal shell or metal gate can conduct electromagnetic interference to the ground, thus eliminating it. The grounding point of the shielding shell must be connected to the system signal reference ground point. If signal lines are led out from the microcontroller system surrounded by metal shielding, shielded cables should be used, and their shielding layer and shell should be connected to the system reference point at the same point. Systems with different reference ground points should be shielded separately and should not be housed together in a single metal shielding shell.
3.2 Application of Software EMS Technology
(1) Digital Filters. These use software to suppress noise superimposed on the analog input signal, allowing the extraction of truly useful information. Several commonly used filtering methods include: a. Program-based filtering; b. Median filtering; c. Arithmetic mean filtering; d. Extreme value removal averaging filtering; e. Weighted average filtering; f. Moving average filtering.
(2) Software Interception Techniques. When a program malfunctions due to interference, measures are taken to bring it back to normal. Common anti-interference techniques include: software interception techniques (software traps, etc.), often employing a. NOP instructions; b. unused interrupt zone traps; c. unused EPROM space traps; d. program area traps.
(3) Program Execution Monitoring System (Watchdog): When the program crashes and enters an infinite loop, redundant instructions and software traps are powerless, and the system will be completely paralyzed. Therefore, a program execution monitoring system (watchdog) should be set up, which should have the following characteristics: a. It can work independently and is basically independent of the MCU. b. The MCU interacts with the system once at fixed intervals to indicate that it is currently normal. c. When the MCU enters an infinite loop, it can detect it in time and reset the system.
Other anti-interference measures
Unipolar surges caused by circuit breaks or lightning transient overvoltages are also a key focus of electromagnetic compatibility (EMC) design for power protectors. Adding a zinc oxide varistor between the live and neutral wires of the power supply can significantly reduce surge interference, minimizing its impact on other circuits. When the voltage across the varistor is below its nominal voltage, its resistance is almost infinite; however, once the voltage exceeds the rated value slightly, the resistance drops dramatically, with a response time on the order of nanoseconds.
When designing the PCB board for the residual current device (RCD), all factors that may affect the RCD's performance are comprehensively considered to improve the PCB's ability to suppress interference. High-voltage circuitry is concentrated at one edge of the circuit board and kept at an appropriate distance from low-voltage components. Analog signal processing and digital processing circuits are separated. Since the microcontroller's internal A/D converter cannot be completely separated, the analog and digital grounds are routed to share a common ground at a single point. System power and ground lines are thickened, and blank areas are covered with copper in a mesh structure as part of the digital ground, reducing analog signal interference to the digital processing circuitry. The microcontroller system clock circuit is placed as close as possible to the chip pins and maintained with appropriate space from other components and PCB traces to minimize the impact of high-frequency radiation on the system.
Summarize
Thanks to the correct and effective hardware and software measures adopted, the protector successfully passed the product type test, obtained 3C certification, and operated reliably without any malfunctions. It utilizes microcontroller interrupts to monitor power supply interference and subsequently the AC signal sampling process. Practice has proven that the combination of software and hardware is an effective method for eliminating high-frequency interference in AC sampling systems.