In practice, the anti-interference design of the single-chip microcomputer application system is generally achieved through two ways: hardware anti-interference design and software anti-interference design. If the hardware is properly designed, most of the interference can be kept out, but there will still be a small amount of interference, so software measures are indispensable. Since software measures are at the expense of occupying the CPU, if there is no hardware to eliminate most of the interference, the CPU will be exhausted, which seriously affects the work efficiency and real-time performance of the system. Therefore, a single-chip microcomputer application system with good anti-interference performance is composed of hardware design and software development complementing each other.
1. Hardware anti-interference design
① Power supply circuit
The power supply used by the microcontroller system is generally provided by the industrial frequency AC power supply of the power grid after voltage reduction, rectification, filtering and other links. Due to the influence of the power grid and the start and stop of large-capacity electrical equipment at the production site, the AC voltage will contain high-frequency components, surge voltage, spike pulses or large voltage fluctuations. These factors will cause interference to affect the normal operation of the system through the power supply path. If the power supply is well done, the anti-interference work of the entire circuit is more than half completed. Many microcontrollers are very sensitive to power supply noise. Therefore, an anti-interference switching power supply should be used or a filter circuit or voltage stabilizer should be added to the microcontroller power supply to reduce the interference of power supply noise on the microcontroller. In addition to increasing the conductor width as much as possible according to the current size, the layout of the power line should also make the direction of the power line and the ground line consistent with the direction of data transmission. This will help enhance the ability to resist noise. Each type of microcontroller has a stable working voltage range. For example, the working voltage of Lingyang SPCE061A microcontroller is 3.3V~5V. Abnormalities will occur beyond this range.
② Hardware reset circuit
Figure 1 Reset circuit using MAX6827
The reset circuit is the most susceptible to interference (because the impedance of the reset circuit inside the CPU is relatively high, 10~50kΩ), and the impact is also the greatest. Therefore, anti-interference measures must be taken. Figure 1 is the reset and "watchdog" circuit diagram using MAX6827. This circuit has strong anti-interference ability. Since there is no reset capacitor, it is not easy to introduce interference.
③ Pay attention to the wiring of the printed circuit board
The printed circuit board is a high-density collection of devices, signal lines, and power lines in the single-chip system. The quality of the printed circuit board design has a great impact on the system's anti-interference ability. Therefore, the design of the printed circuit board is not only a simple layout arrangement of devices and lines, but also must comply with the anti-interference design principles. Reasonable design of the system circuit board can effectively cut off the propagation path of interference and suppress interference sources. At the same time, it can also improve the anti-interference ability of sensitive components (such as single-chip microcomputers, digital ICs, A/D, D/A, etc., which are easily interfered with). Mainly taken:
[1] Reasonable partitioning of the circuit board, such as strong and weak signal, digital and analog signal partitioning. Keep interference sources (such as motors and relays) as far away from sensitive components as possible. High-power devices should be placed at the edge of the circuit board as much as possible.
[2] When wiring, minimize the area of the loop to reduce inductive noise; the power line and ground line should be as thick as possible. In addition to reducing voltage drop, it is more important to reduce coupling noise; avoid 90-degree bends in connecting lines to reduce high-frequency noise emission.
[3] Do not leave unused microcontroller pins, especially interrupt inputs, floating. Generally, they should be connected to the power supply through pull-up resistors.
[4] Each IC on the circuit board should be connected in parallel with a 0.01μF~0.1μF high-frequency capacitor to reduce the impact of the IC on the power supply.
[5] Pay attention to the crystal oscillator wiring. Keep the crystal oscillator and microcontroller pins as close as possible, isolate (circle) the clock area with a ground wire, and ground and fix the crystal oscillator shell. This measure can solve many difficult problems.
[6] Use a ground wire to isolate the digital area from the analog area, separate the digital ground and analog ground, and finally connect them to the power ground point to form a "star" shape.
In the microcontroller application system, grounding is an important method to suppress interference. Whether the grounding is correct and firm will directly affect the normal operation of the system. If the grounding and shielding can be used correctly together, most interference problems can be solved.
In order to prevent the interference of the internal ground wire of the system, the following measures can be taken when designing the printed circuit board: the ground wire should be as thick as possible. If the ground wire is very thin, the ground potential will change with the change of the current, causing the timing signal level of the computer to be unstable and the anti-noise performance to deteriorate. Therefore, the width of the ground wire should be determined according to the size of the passing current. If possible, the ground line should be thickened and widened as much as possible, preferably not less than 3mm, so that it can pass 3 times the allowable current on the printed circuit board. For multi-level circuits, the dynamic current of each level should be considered during design, and the influence of mutual coupling of ground impedance should be paid attention to. When the operating frequency is lower than 1MHz, one-point grounding is used, and when the operating frequency is higher, multi-point grounding is used.
2. Software anti-interference design
In the single-chip microcomputer application system, although hardware anti-interference measures are taken, the causes of the interference signal are very complex and have great randomness. Therefore, software measures are taken to supplement the hardware anti-interference measures. The following software anti-interference measures are briefly introduced.
① Set up software traps (Trap)
When the microcontroller is disturbed, the program counter PC value is most easily affected. The change of PC value is random, which can completely cause the CPU to leave the correct instruction sequence to execute some content in undefined addresses, or enter the data area, and control the data as an opcode, causing the entire work to be disordered and the system to lose control. This situation is much more serious for the system than the harm caused by a certain data error. The latter only involves a certain function that cannot be realized or has deviations, while the former will paralyze the entire system. The reason for the program out of control is not a problem with the program design itself, but due to external interference or a momentary hardware failure inside the microcontroller, the program counter (PC) deviates from the original value. For example, when an instruction is executed, the program counter PC should add a value of 1, but for some reason, the PC actually adds 2. In this way, the program will confuse the operand and the opcode, causing a series of errors later.
In order to prevent the above situation from happening, the method of setting up software traps can be used to overcome it during software design. The specific method is to set several consecutive cells to "00" (no operation) every few instructions (such as ten or twenty) in ROM or RAM. In this way, when the program goes out of control, as long as the out-of-control microcontroller enters any of the numerous software traps, it will be captured and perform several no operations in succession. After executing these no operations, the program automatically returns to normal and continues to execute the following program. Although this method wastes some memory units, it can ensure that the program will not run away. This method is not transparent to the user, that is, the user cannot feel whether the program has an erroneous operation at all.
② Open up multiple storage areas for anti-interference
In order to prevent RAM errors and lose the most important data, 2 to 3 storage areas are opened for important input and output data to be saved simultaneously. When accessing data, a comparative voting method is adopted to distinguish the false from the true. [page]
③ Time monitor
The time monitor (Watch-Dog Timer), also known as the "watchdog" technology, is used to set up a software trap failure to allow the system to recover from the fault. Because the program that goes out of control due to interference does not necessarily fall into the trap, such as the program's dead loop. The so-called dead loop means that for some reason the program is trapped in an application or interrupt service subroutine and loops endlessly. In this way, the CPU and other system resources are occupied by it and other task programs cannot be executed. In other words, the dead loop makes the program lose normal control, but it will not cause the program control to enter the trap area, so the software trap cannot capture it.
The time monitor consists of two counters, and the counters count by the system clock (or the divided pulse signal). When the counter is full, the counter will generate a reset signal to force the system to reset and re-execute the program. Under normal circumstances, the program clears the counter at a certain interval (determined by the length of the system application execution). In this way, the counter will not be full, and thus no reset will occur.
Figure 2 SPCE061A watchdog structure and timing
For example, the clearing time period of the WatchDog of the Sunplus MCU SPCE061A is 0.75s. Because the overflow reset signal WatchDog_Reset of WatchDog is generated by the 4Hz time base signal after 4 division, that is, every 4 4Hz time base signals (1s) will generate a WatchDog_Reset signal. However, the WatchDog_Clear signal that clears WatchDog can occur at any time point between the 4Hz signals (0.25s). If the WatchDog_Clear signal occurs at 0.01s at the end of the 4Hz signal, that is, at the 0.25s moment, although WatchDog is cleared at this time, since it occurs after the 4Hz signal, after 3 4Hz signals, that is, 0.75s, if there is no WatchDog_Clear signal, a WatchDog_Reset signal will be generated. As shown in Figure 2, if the program runs abnormally, such as falling into an infinite loop, the counter will be full and overflow. This overflow signal is used to generate a reset signal to restart the program. In programming, we only need to write 0X0001H to the P_WatchDog_Clear unit to complete the clearing of the WatchDog operation. If 0X0001H is not written to the P_WatchDog_Clear unit within 0.75 seconds, the CPU will perform a system reset operation, which is what we usually call restarting the system. Watchdogs are often used in delay programs, such as
void Delay()
{
unsigned int j;
for(j=0x7fff;j>0;j--);
*P_Watchdog_Clear = 0x0001;//Clear watchdog
}
④ Adding no operation NOP
In several areas of ROM or RAM, several no operation groups are stored, and the number of no operations is equal to the longest instruction section of the selected CPU chip. In addition to occupying a storage unit and execution time, the no operation instruction NOP has no effect on the working state of the CPU. If you insert 1-2 NOP instructions selectively in a certain place of the program, you can also adjust the content in the PC and return the program to the correct order after being disturbed. The insertion position should be explored, analyzed and experimented during the program debugging process. Generally speaking, inserting NOP instructions before the operation instructions of the peripheral port, multi-byte instructions, transfer instructions, and stack operation instructions will achieve good results. In addition, you can also add a program to handle runaway after the empty operation group, and let the CPU not execute these instruction groups when executing normal programs. These instruction groups are only likely to be encountered when running away. For example:
NOP
NOP
NOP
LJMP FF
FF: ACALL FLY
MOV A, FLG
CJNE A, #11H, RSM
...
⑤ Segmented software anti-interference
Sometimes, the control system needs to execute several different main loop channels in sequence to complete different functions. At this time, anti-interference judgment and self-recovery functions can be compiled in different main loops. This can avoid unnecessary repeated execution to ensure the integrity of the sequence.
⑥ Digital filtering
Digital filtering is to process the input signal of the single-chip microcomputer data acquisition part through program design to achieve the purpose of anti-interference. When the interference is superimposed on the analog signal of the input channel, the data acquisition error is increased, especially when the analog signal of the input channel is weak, this phenomenon is more serious. In order to eliminate the error of data acquisition, the arithmetic mean method, the comparison and selection method, the first-order lag filtering method and the median method are often used. The optimal design method can be adopted according to the law of signal and interference.
Different single-chip microcomputer application systems have their own system requirements and characteristics, and they also have their own characteristics in hardware and software anti-interference design. As a supplement to hardware anti-interference, software anti-interference technology plays a pivotal role in the anti-interference of single-chip microcomputer application systems with its flexibility, practicality and reliability. In engineering practice, several anti-interference technologies are usually used together and complement each other to achieve good anti-interference effects. When we design a single-chip microcomputer application system, we must carefully analyze the interference source, combine software and hardware anti-interference technologies, and improve the system monitoring program, so as to ensure the accurate and reliable operation of the system.
Previous article:Problems that should be paid attention to when developing and designing single-chip microcomputer application systems
Next article:The main interference forms of single chip microcomputer application system
Recommended ReadingLatest update time:2024-11-16 14:39
- Popular Resources
- Popular amplifiers
- Wireless Sensor Network Technology and Applications (Edited by Mou Si, Yin Hong, and Su Xing)
- Modern Electronic Technology Training Course (Edited by Yao Youfeng)
- Modern arc welding power supply and its control
- Small AC Servo Motor Control Circuit Design (by Masaru Ishijima; translated by Xue Liang and Zhu Jianjun, by Masaru Ishijima, Xue Liang, and Zhu Jianjun)
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!
- 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
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Today’s award-winning live broadcast at 10 a.m.: Getting started with ADI’s software-defined radio ADALM-Pluto
- 【TGF4042 signal generator】+ resolution test
- Transplantation of μC/OS-II Real-time Operating System to 51 Single-Chip Microcomputer
- Free download of "A Brief Introduction to Special and General Relativity"
- MSP432 Wireless Sensor Node
- [Raspberry Pi 3B+ Review] PWM breathing light & control 12V motor
- 【RT-Thread Reading Notes】4. RT-Thread Study Chapter 6 Reading Notes (I)
- Power supply dynamic response test, what kind of waveform is considered qualified?
- EEWORLD University Hall----Live Replay: PI helps high reliability and high efficiency industrial measurement solutions
- AFE77xx EVM Evaluation with TSW14J57 Guide