From PCB design to software processing, let’s talk about the electromagnetic compatibility design of the microcontroller system

Previously, we explained the principles and some details that need to be paid attention to in the design of the microcontroller control board. (” rel=”nofollow” target=”_blank”>See details)
The design of electromagnetic interference mentioned in this article mainly deals with hardware and software. The following is an introduction to the processing of electromagnetic compatibility from the PCB design of the microcontroller to software processing.

1.Factors affecting EMC

  1. Voltage: The higher the power supply voltage, the greater the voltage amplitude, the more emission, and the low power supply voltage affects the sensitivity.
  2. Frequency: High frequency produces more emission, and periodic signals produce more emission. In high-frequency microcontroller systems, current spikes are generated when the device switches; in analog systems, current spikes are generated when the load current changes.
  3. Grounding: Among all EMC issues, the main problem is caused by improper grounding. There are three signal grounding methods: single point, multi-point and mixed. In When the frequency is below 1MHz, a single-point grounding method can be used, but it is not suitable for high frequencies; in high-frequency applications, multi-point grounding is best used. Mixed grounding is a method of using single-point grounding for low frequencies and multi-point grounding for high frequencies. Ground layout 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 printed circuit board (PCB) wiring is essential to prevent EMI.
  5. Power decoupling: When the device switches, transient currents are generated on the power line, which must be attenuated and filtered out. Transient currents from high di/dt sources cause ground and trace “emission” voltages, and high di/dt generates a wide range of high-frequency currents, which excite components and cables to radiate. The current changes and inductance flowing through the wire will cause voltage drops, and reducing the inductance or the change of current over time can minimize this voltage drop.

2.Hardware processing methods for interference measures

(1)Electromagnetic compatibility design of printed circuit boards (PCBs)

    PCBs are the support for circuit elements and devices in single-chip microcomputer systems, and they provide electrical connections between circuit elements and devices. With the rapid development of electronic technology, the density of PCBs is getting higher and higher. The quality of PCB design has a great influence on the electromagnetic compatibility of single-chip microcomputer systems.

    Practice has proved that even if the circuit schematic is designed correctly, improper printed circuit board design will have an adverse effect on the reliability of the single-chip microcomputer system. For example, if the two thin parallel lines of the printed circuit board are close to each other, it will cause a delay in the signal waveform and form reflected noise at the terminal of the transmission line.

    Therefore, when designing printed circuit boards, When designing the circuit board, you should pay attention to using the correct method, abide by the general principles of PCB design, and meet the anti-interference design requirements. To achieve the best performance of the electronic circuit, the layout of components and the layout of wires are very important.

    (2)Input/output electromagnetic compatibility design

      In the single-chip microcomputer system, the input/output is also the transmission line of the interference source and the pickup source of the receiving radio frequency interference signal. We generally take effective measures when designing:

      ① Use necessary common mode/differential mode suppression circuits, and also take certain filtering and anti-electromagnetic shielding measures to reduce the entry of interference.

      ② Take various isolation measures (such as photoelectric isolation or magnetoelectric isolation) as much as possible when conditions permit, so as to block the propagation of interference.

      (3)Design of single-chip microcomputer reset circuit

        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 interference sources cannot be completely isolated or removed, once the CPU interferes with the normal operation of the program, the reset system combined with software processing measures becomes an effective error correction defense barrier. There are two commonly used reset systems:

        ① External reset system.

        The external “watchdog” circuit can be designed by yourself or built with a dedicated “watchdog” chip. However, they each have their own advantages and disadvantages. Most dedicated “watchdog” chips cannot respond to low-frequency “feed the dog” signals, but can respond to high-frequency “feed the dog” signals, so that they can generate reset actions under low-frequency “feed the dog” signals but not under high-frequency “feed the dog” signals. In this way, if the program system falls into an infinite loop, and there happens to be a “feed the dog” signal in the loop, then the reset circuit cannot achieve its due function. However, we can design a system consisting of a passband “feed the dog” 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 system, so that users can easily use their internal reset timer, but some models of single-chip microcomputers have too simple reset instructions, so there will be “feed the dog” instructions like the above-mentioned infinite loop, which makes it lose its monitoring function. 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 will be invalid, which greatly improves the reliability of the reset circuit.

        (4)Oscillator

          Most microcontrollers have an oscillator circuit coupled to an external crystal or ceramic resonator. On the PCB, the leads of the external capacitor, crystal or ceramic resonator are required to be as short as possible. The RC oscillator is potentially sensitive to interference signals and can produce a very short clock cycle, so it is best to choose a crystal or ceramic resonator. In addition, the shell of the quartz crystal should be grounded.

          (5)Lightning protection measures

            For microcontroller systems used outdoors or power lines and signal lines introduced from outdoor to indoor, lightning protection issues of the system should be considered. Commonly used lightning protection devices include: gas discharge tubes, TVS, etc. The gas discharge tube is when the voltage of the power supply is greater than a certain value, usually tens of V or hundreds of V, the gas breaks down and discharges, and the strong impact pulse on the power line is guided into the ground. TVS can be seen as two Zener diodes connected 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 pass hundreds or even thousands of A of current in a transient state.

            3.Software processing methods 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 bad), and will eventually enter the core unit of the CPU processing, so that some large-scale integrated circuits are often interfered, resulting in malfunction or working in an error state. In particular, devices such as RAM that use bistable storage often flip under strong interference, causing the original stored “0” to become “1”, or “1” to become “0”; the timing and data of some serial transmissions 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 entire system.

              1. The program will generally have the following situations due to electromagnetic interference:

              ① The program will run away. This situation is the most common interference result. Generally speaking, a good reset system or software frame test system is sufficient, which will not have much impact on the entire running system.

              ② Dead loop or abnormal program code operation. Of course, this dead loop and abnormal program code are not intentionally written by the designer. We know that the instructions of the program 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 produce a series of error states such as unpredictable control output.

              1. Measures for the storage of important parameters
              • In general, we can use error detection and correction to effectively reduce or avoid the occurrence of this situation. According to the principle of error detection and correction, the main idea is that when data is written, a certain number of check codes are generated according to the written data and saved together with the corresponding data; when it is read out, the check code is also read out for judgment.
              • If a single error occurs, it will be automatically corrected, the correct data will be sent out, and the corrected data will be written back to cover the original erroneous data; if two errors occur, an interrupt report will be generated to notify the CPU to perform exception processing. All these actions are automatically completed by software design, with 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 error correction principle:

              First, let’s take a look at the basic principles of error detection and error correction. The basic idea of ​​error control is to add different types of redundant codes to the information code group according to certain rules, so that when the information is read out, it can rely on redundant monitoring codes or code correction codes to detect or automatically correct errors. In view of the characteristics of bit error occurrence, that is, the randomness and small probability of error occurrence, it almost always randomly affects a certain bit in a byte. Therefore, if it is possible to design a coding method that automatically corrects a single error and checks two errors. The reliability of the system can be greatly improved.

              1. Detection of RAM and FLASH (ROM)

              When compiling a program, it is best to write some detection programs to test the data code of RAM and FLASH (ROM) to see if there is any error. If it occurs, it should be corrected immediately. If it cannot be corrected, an error indication should be given in time for the user to handle it.

              Finally, it is indispensable to add program redundancy when compiling a program. Adding three or more NOP instructions in certain places has a very effective preventive effect on program reorganization. At the same time, it is necessary to introduce flag data and detection status in the running state of the program to timely discover and correct errors.

              Similar Posts

              Leave a Reply