In recent years, microcontrollers have been increasingly used in industrial automation, production process control, intelligent instrumentation and other fields, greatly improving product quality and effectively improving production efficiency. However, the working environment of measurement and control systems is often complex and harsh, especially the electromagnetic environment around the system, which poses a great threat to the reliability and safety of the system. The microcontroller measurement and control system must operate stably and reliably for a long time. Otherwise, the control error will increase, and in severe cases, the system will fail and even cause huge losses. The following focuses on analyzing the impact of interference on the microcontroller application system, and combines personal experience to provide specific solutions from both soft and hard aspects.
2. Impact of interference on microcontroller application systems
The main factors that affect the reliable and safe operation of application systems come from various electromagnetic interferences inside and outside the system, as well as system structural design, component installation, processing technology and external electromagnetic environmental conditions. The interference consequences of these factors on the microcontroller system are mainly reflected in the following aspects:
(1) The measurement data error increases. The
interference invades the input channel of the analog signal of the measurement unit of the microcontroller system and is superimposed on the measurement signal, which will increase the data collection error. , and even the interference signal overwhelms the measurement signal, especially when detecting some weak signals, such as the human body's bioelectrical signals.
(2) Affects the RAM memory and E2PROM of the microcontroller
. In the microcontroller system, programs, tables, and data are stored in the program memory EPROM or FLASH to avoid interference and damage to these data. However, the data in the on-chip RAM, external expansion RAM, and E2PROM may be changed by external interference.
(3) Control system failure
The control signals output by the microcontroller usually depend on the status input signals of certain conditions and the logical processing results of these signals. If these input status signals are interfered with and false status information is introduced, the output control error will increase or even control failure.
(4) Abnormal program operation.
External interference sometimes causes the machine to reset frequently, affecting the normal operation of the program. If external interference causes the microcontroller program counter PC value to change, the normal operation of the program will be destroyed. Since the PC value after interference is random, the program will execute a series of meaningless instructions and finally enter an "infinite loop", which will seriously mess up the output or freeze.
[page]
3. 硬件抗干扰技术
3.1 选择良好的元器件与单片机
硬件抗干扰技术是系统设计时首选的抗干扰措施,它能有效抑制干扰源,阻断干扰传输通道。常用的硬件设计抗干扰措施如下:
① 现在市场上出售的元器件种类繁多,有些元器件可用但性能不佳,有些元器件极易受到干扰,因此在选择关键元器件如译码器、键盘扫描控制器、RAM等时,最好选用性能稳定的工业级产品。
② 单片机的选择不光考虑硬件配置、存储容量等,更要选择抗干扰性能较强的单片机,笔者在使用多种类型的单片机中认为,AVR系列单片机抗干扰能力较强。
③ 外时钟是高频的噪声源,对系统的内外都能产生干扰,因此在满足需要的前提下,选用频率低的单片机是明智之举。
3.2 抑制电源干扰
单片机系统中的各个单元都需要使用直流电源,而直流电源一般是市电电网的交流电经过变压、整流、滤波、稳压后产生的,因此电网上的各种干扰便会引入系统。除此之外,由于交流电源共用,各电子设备之间通过电源也会产生相互干扰,因此抑制电源干扰尤其重要。电源干扰主要有以下几类:
① 电源线中的高频干扰
供电电力线相当于一个接受天线,能把雷电、电弧、广播电台等辐射的高频干扰信号通过电源变压器初级耦合到次级,形成对单片机系统的干扰;
② 感性负载产生的瞬变噪音
切断大容量感性负载时,能产生很大的电流和电压变化率,从而形成瞬变噪音干扰,成为电磁干扰的主要形式;
③ 晶闸管通断时的干扰
晶闸管通断时的电流变化率很大,使得晶闸管在导通瞬间流过一个具有高次谐波的大电流,在电源阻抗上产生很大的压降,从而使电网电压出现缺口,这种畸变了的电压波形含有高次谐波,可以向空间辐射或通过传导耦合,干扰其它设备。此外,还有电网电压波动或电压瞬时跌落产生干扰,等等。
电源干扰的抑制,通常可采用以下几种方法:
① 接地技术
实践证明,单片机系统设备的抗干扰与系统的接地方式有很大关系,接地技术往往是抑制噪音的重要手段。良好的接地可以在很大程度上抑制系统内部噪音耦合,防止外部干扰的侵入,提高系统的抗干扰能力。设备的金属外壳等要安全接地;屏蔽用的导体必须良好接地;
② 屏蔽线与双胶线传输
屏蔽线对静电干扰有强的抑制作用,而双胶线有抵消电磁感应干扰的作用。开关信号检测线和模拟信号检测线可以使用屏蔽双胶线,来抵御静电和电磁感应干扰;特殊的干扰源也可以用屏蔽线连接,屏蔽了干扰源向外施加干扰;
③ 隔离技术
信号的隔离目的之一是从电路上把干扰源和易干扰的部分隔离出来,使监控装置与现场仅保持信号联系,但不直接发生电的联系。隔离的实质是把引进的干扰通道切断,从而达到隔离现场干扰的目的。
一般单片机应用系统既有弱电控制系统又有强电控制系统,通常实行弱电和强电隔离,是保证系统工作稳定、设备与操作人员安全的重要措施。常用的隔离方式有光电隔离、变压器隔离、继电器隔离和布线隔离等。
④ 模拟信号采样抗干扰技术
单片机应用系统中通常要对一个或多个模拟信号进行采样,并将其通过A/D转换成数字信号进行处理。为了提高测量精度和稳定性,不仅要保证传感器本身的转换精度、传感器供电电源的稳定、测量放大器的稳定 、A/D转换基准电压的稳定,而且要防止外部电磁感应噪声的影响,如果处理不当,微弱的有用信号可能完全被无用的噪音信号淹没。在实际工作中,可以采用具有差动输入的测量放大器,采用屏蔽双胶线传输测量信号,或将电压信号改变为电流信号,以及采用阻容滤波等技术。
在许多信号变化比较慢的采样系统中,如人体生物电(心电图、脑电图)采样、地震波记录等,影响最大的是50Hz的工频干扰。因此对工频干扰信号的抑制是保证测量精度的重要措施之一。抑制和消除工频干扰,常用的方法是在A/D转换电路之前加RC滤波器,或者采用采样时间是50Hz的工频周期整数倍的双积分式A/D转换器。
[page]
3.3 Anti-interference technology of digital signal transmission channel
The digital output signal can be used as the driving signal of the controlled equipment of the system (such as relay, etc.), and the digital input signal can be used as the response and command signal of the equipment (such as travel switch, start button, etc.). The digital signal interface part is one of the main channels for external interference to enter the microcontroller system. In engineering design, the anti-interference measures taken for the input/output process of digital signals include: shielding technology for transmission lines, such as using shielded wires, double-glue wires, etc.; adopting signal isolation measures; reasonable grounding. Public impedance interference is formed during the process, and choosing a suitable grounding point can effectively suppress ground wire noise.
3.4 Hardware monitoring circuit
In the microcontroller system, in order to ensure the reliable and stable operation of the system and enhance the anti-interference ability, a hardware monitoring circuit needs to be configured. The function of the hardware monitoring circuit includes the following aspects:
① Power-on reset: ensure that the system is powered on can start correctly when the power supply fails;
② Power-off reset: When the power supply fails or the voltage drops below a certain voltage value, a reset signal is generated to reset the system;
③ Data protection: When the power supply or system works abnormally, necessary data protection Protection, such as write protection, backup battery switching, etc.;
④ Power supply monitoring: When the power supply voltage is abnormal, an alarm indication signal or interrupt request signal is given;
⑤ Hardware watchdog: When the processor encounters interference or the program runs chaotically, a "death" occurs. When "locked", reset the system.
Some well-known semiconductor manufacturers have integrated the above functions, such as MAXIM's MAX690, MAX706, etc.
3.5 Reasonable layout of printed circuit board
Printed circuit board (PCB) is the support for circuit components and devices in electronic products. It provides electrical connections between circuit components and devices. With the rapid development of electronic technology, the density of PCBs is getting higher and higher, and the quality of PCB design has a great impact on the ability to resist interference. Therefore, when designing PCB, the general principles of PCB design must be followed and the requirements of anti-interference design should be met. Two points are highlighted below:
① Key device placement: In terms of device layout, like other logic circuits, related devices should be placed as close as possible to achieve better anti-noise effect. The clock generator, crystal oscillator and clock input terminal of the CPU are all prone to noise and should be kept close to each other; the CPU reset circuit and hardware watchdog circuit should be as close as possible to the corresponding pins of the CPU; devices that are prone to noise and high current circuits should be kept as close as possible Stay away from logic circuits and make a separate circuit board if possible.
② For D/A and A/D conversion circuits, special attention should be paid to the correct connection of the ground wire, otherwise the interference effect will be serious. D/A, A/D chips and sampling chips all provide digital ground and analog ground, with corresponding pins respectively. In the circuit design, the digital ground and analog ground of all devices must be connected respectively, but the digital ground and analog ground are only connected at one point.
In addition, shielding protection can also be used, and shielding can be used to isolate space radiation. Parts that are particularly noisy (such as variable frequency power supplies and switching power supplies) can be covered with metal boxes to reduce the interference of noise sources on the microcontroller. For parts that are susceptible to interference, a shielding cover can be added and grounded to short-circuit the interference signal to the ground.
[page]
4. Principles and methods of
software anti-interference Although we have adopted hardware anti-interference measures, it is difficult to ensure that the system is completely free from interference due to the complex and highly random causes of interference signals. Therefore, on the basis of hardware anti-interference measures, software anti-interference technology is often used to supplement the hardware measures as an auxiliary means. The software anti-interference method has the characteristics of simplicity, flexibility, convenience, and low cost, and is widely used in systems.
4.1 Digital filtering method
Digital filtering is a process of extracting the closest true value data through software algorithms based on multiple sampling of analog signals. The algorithm of digital filtering is flexible and the authority parameters can be selected. The effect is often beyond the reach of hardware filtering circuits.
4.2 Input signal repetition detection method
The interference of the input signal is a series of discrete spikes superimposed on the effective level signal, and the action time is very short. When there is input interference in the control system and it cannot be effectively suppressed by hardware, the software can be used to repeatedly detect the method to achieve the purpose of "removing the false and retaining the true". It will not be effective until two or more consecutive collection results are completely consistent. If the signal is always changing, an alarm signal can be given when the maximum number of times is reached. This input method can be used for signals from various switch-type sensors, such as limit switches, travel switches, operating buttons, etc. If a delay is inserted between successive data acquisitions, wider interference can be dealt with.
4.3 Output port data refresh method
The anti-interference design of the switching output software mainly adopts the method of repeated output, which is an effective measure to improve the anti-interference performance of the output interface. These measures are necessary for control signals that use latch outputs. The data is output repeatedly in the shortest possible period. The correct information arrives before the equipment affected by the interference has time to respond, thus preventing malfunctions in time. In terms of program structure arrangement, a data buffer can be established for output data, and the data can be output in the periodic loop body of the program. For incremental control equipment, data cannot be sent repeatedly in this way. The correctness of data transmission can only be judged from the feedback information of the equipment through the detection channel.
When executing the repeated output function, for the programmable interface chip, the working mode control word and the output status word are repeatedly set together to make the output module work reliably.
4.4 Software interception technology
When the interference that enters the microcontroller system acts on the CPU, the consequences will be more serious and the system will malfunction. The most typical failure is to destroy the state of the program counter PC, causing the program to jump from one area to another, or the program to "fly around" in the address space, or fall into an "infinite loop". Software interception technology can be used to intercept "flying" programs or get the program out of the "infinite loop" and put the running program on track and go to the designated program entrance.
4.5 "Software watchdog" technology
The PC is interfered with and loses control, causing programs to "fly around" and may also cause the program to fall into an "infinite loop". When software interception technology cannot help an out-of-control program get out of the "infinite loop", program monitoring technology WDT TIMER (WDT), also known as "watchdog" technology, is usually used to get the program out of the "infinite loop". WDT is an anti-program runaway measure that combines software and hardware. Its hardware body is a counter or monostable used to generate timing T. This counter or monostable basically operates independently, and its timing output terminal is connected to the reset line of the CPU. , and its timing clearing is controlled by the CPU. Under normal circumstances, after the program starts the WDT, the CPU periodically clears the WDT, so that the WDT timer overflow will not occur, and it will have no effect just like sleep. In the abnormal situation of interference, the CPU timing logic is destroyed and the program execution is chaotic. It is impossible to periodically clear the WDT. In this way, when the WDT timer overflows, its output resets the system and the CPU gets rid of the paralysis caused by temporary interference. status.
5. Conclusion
The above are some common anti-interference measures for single chip microcomputer systems that the author has summarized in practical work. These methods have also been adopted when designing single chip microcomputer systems and have achieved good results.
Previous article:
Next article:Design methods to improve the reliability of single-chip microcomputer systems
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- Rambus Launches Industry's First HBM 4 Controller IP: What Are the Technical Details Behind It?
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- CC3200 Kit OURS-SDK-WFB_Explore - by tinnu
- Chip Manufacturing 3-Semiconductor Slicing
- RISC-V IDE MRS Usage Notes (IV): Link-time Optimization
- Xunwei 3399 development board-PCIE 4G module test-compiler
- 【CH579M-R1】+DHT22 temperature and humidity detection
- 【BLE 5.3 wireless MCU CH582】13. Power consumption in BLE Peripheral mode
- MSP430F5438 Timer TA1 Compare Match CCR0 Summary
- CircuitPython Online Editor
- A must-read summary of drone principles (Part 3) Introduction to the appearance of drones
- [Fudan Micro FM33LG0 Series Development Board Review] PGL Function and Brief Analysis