(1)
In terms of the layout of components, related components should be placed as close as possible. For example, clock generators, crystal oscillators, and CPU clock input terminals are prone to noise, so they should be placed closer together. For those devices that are prone to noise, small current circuits, large current circuits, switching circuits, etc., they should be kept as far away from the logic control circuits and storage circuits (ROM, RAM) of the microcontroller as possible. If possible, these circuits can be made into circuit boards separately, which is conducive to anti-interference and improves the reliability of circuit operation.
(2) Try to install decoupling capacitors next to key components such as ROM, RAM and other chips. In fact, printed circuit board traces, pin connections and wiring may contain large inductance effects. Large inductance may cause severe switching noise spikes on the Vcc trace. The only way to prevent switching noise spikes on the Vcc trace is to place a 0.1uF electronic decoupling capacitor between VCC and the power ground. If surface mount components are used on the circuit board, chip capacitors can be directly placed close to the components and fixed on the Vcc pin. It is best to use ceramic capacitors because this type of capacitor has low electrostatic loss (ESL) and high-frequency impedance. In addition, this type of capacitor has good dielectric stability over temperature and time. Try not to use tantalum capacitors because their impedance is higher at high frequencies.
When placing decoupling capacitors, pay attention to the following points:
· Connect an electrolytic capacitor of about 100uF across the power input end of the printed circuit board. If the volume allows, a larger capacitance is better.
·In principle, a 0.01uF ceramic capacitor should be placed next to each integrated circuit chip. If the gap in the circuit board is too small to place it, a 1~10uF tantalum capacitor can be placed for every 10 chips.
· For components with weak anti-interference ability, large current changes when turned off, and storage components such as RAM and ROM, a decoupling capacitor should be connected between the power line (Vcc) and the ground line.
·The lead of the capacitor should not be too long, especially the high-frequency bypass capacitor cannot have a lead.
(3) In the single-chip microcomputer control system, there are many types of ground wires, including system ground, shielding ground, logic ground, analog ground, etc. Whether the ground wire is laid out reasonably will determine the anti-interference ability of the circuit board. When designing the ground wire and grounding point, the following issues should be considered:
·The logic ground and analog ground should be wired separately and cannot be used together. Their respective ground wires should be connected to the corresponding power ground wire. When designing, the analog ground wire should be as thick as possible, and the grounding area of the lead-out end should be as large as possible. Generally speaking, for analog input and output signals, it is best to isolate them from the single-chip microcomputer circuit through an optical coupler.
·When designing the printed circuit board of the logic circuit, its ground wire should form a closed loop to improve the anti-interference ability of the circuit.
·The ground wire should be as thick as possible. If the ground wire is very thin, the ground wire resistance will be large, causing the ground potential to change with the change of current, resulting in unstable signal level and reduced anti-interference ability of the circuit. If the wiring space allows, the width of the main ground wire should be at least 2 to 3 mm, and the ground wire on the component pin should be about 1.5 mm.
·Pay attention to the selection of grounding points. When the signal frequency on the circuit board is lower than 1MHz, the electromagnetic induction effect between the wiring and the component is small, and the loop current formed by the grounding circuit has a greater impact on interference, so one-point grounding should be used to prevent it from forming a loop. When the signal frequency on the circuit board is higher than 10MHz, due to the obvious inductance effect of the wiring, the ground wire impedance becomes very large, and the loop current formed by the grounding circuit is no longer the main problem. Therefore, multi-point grounding should be used to reduce the ground wire impedance as much as possible.
·In addition to making the power line as thick as possible according to the current, the power line and ground line should be aligned with the data line when wiring. At the end of the wiring, the ground line is used to cover the bottom layer of the circuit board where there is no wiring. These methods are helpful to enhance the anti-interference ability of the circuit.
·The width of the data line should be as wide as possible to reduce the impedance. The width of the data line should be at least 0.3mm (12mil), and it is more ideal if 0.46~0.5mm (18mil~20mil) is used.
·Since a via on the circuit board will bring about a capacitance effect of about 10pF, this will introduce too much interference for high-frequency circuits, so the number of vias should be reduced as much as possible when wiring. In addition, too many vias will also reduce the mechanical strength of the circuit board. The
hardware circuit design of a single-chip microcomputer application system includes two parts: one is system expansion, that is, when the functional units inside the single-chip microcomputer, such as ROM, RAM, I/O, timer/counter, interrupt system, etc., cannot meet the requirements of the application system, they must be expanded outside the chip, and appropriate chips must be selected to design corresponding circuits. The second is the configuration of the system, that is, to configure peripheral devices according to the system functional requirements, such as keyboards, monitors, printers, A/D, D/A converters, etc., and to design appropriate interface circuits. The
expansion and configuration of the system should follow the following principles:
1. Choose typical circuits as much as possible and conform to the conventional usage of single-chip microcomputers. Lay a good foundation for the standardization and modularization of hardware systems.
2. The configuration level of system expansion and peripheral devices should fully meet the functional requirements of the application system, and leave appropriate room for secondary development.
3. The hardware structure should be considered together with the application software solution. The hardware structure and software solution will have a mutual impact. The principle of consideration is: the functions that can be realized by the software should be implemented by the software as much as possible to simplify the hardware structure. However, it must be noted that the hardware functions realized by the software generally have a longer response time than the hardware implementation and occupy CPU time.
4. The relevant devices in the system should match the performance as much as possible. If a CMOS chip single-chip microcomputer is selected to form a low-power system, all chips in the system should choose low-power products as much as possible.
5. Reliability and anti-interference design are an indispensable part of hardware design, which includes chip and device selection, decoupling filtering, printed circuit board wiring, channel isolation, etc.
6. When there are many peripheral circuits of the single-chip microcomputer, its driving capability must be considered. When the driving capability is insufficient, the system will not work reliably. The bus load can be reduced by adding line drivers to enhance the driving capability or reducing the chip power consumption.
7. Try to design the hardware system in the direction of "single chip". The more system devices there are, the stronger the mutual interference between the devices, the greater the power consumption, and the inevitable reduction of the stability of the system. With the increasingly powerful functions integrated in the single-chip microcomputer, a true system-on-chip SoC can be realized. For example, the μPSD32×× series products recently launched by ST integrate 80C32 core, large-capacity FLASH memory, SRAM, A/D, I/O, two serial ports, watchdog, power-on reset circuit, etc. on a single chip.
Commonly used methods for hardware anti-interference of single-chip microcomputer systems in practice
The main factors affecting the reliable and safe operation of single-chip microcomputer systems mainly come from various electrical interferences inside and outside the system, and are affected by system structure design, component selection, installation, and manufacturing process. All these constitute interference factors of the MCU system, which often cause the MCU system to malfunction, affecting product quality and output at the least, or causing accidents and major economic losses at the worst.
There are three basic elements that form interference: (1) Interference source. Refers to the components, equipment or signals that generate interference, which can be described in mathematical language as follows: du/dt. The place where di/dt is large is the interference source. For example, lightning, relays, thyristors, motors, high-frequency clocks, etc. may all become interference sources. (2) Propagation path. Refers to the path or medium through which interference is transmitted from the interference source to the sensitive device. The typical interference propagation path is conduction through wires and radiation in space. (3) Sensitive device. Refers to objects that are easily interfered with. For example, A/D, D/A converters, MCUs, digital ICs, weak signal amplifiers, etc. Classification of interference 1 Classification of interference There are many types of interference, which can usually be classified according to the cause of noise generation, conduction mode, waveform characteristics, etc. According to the cause of generation: it can be divided into discharge noise, high-frequency oscillation noise, and surge noise. According to the conduction mode: it can be divided into common mode noise and series mode noise. According to the waveform: it can be divided into continuous sine wave, pulse voltage, pulse sequence, etc. Interference coupling mode The interference signal generated by the interference source can only affect the measurement and control system through a certain coupling channel. Therefore, it is necessary to look at the transmission mode between the interference source and the interfered object. The interference coupling mode is nothing more than through wires, space, common lines, etc., which can be broken down into the following types: (1) Direct coupling: This is the most direct way and the most common way in the system. For example, the interference signal invades the system through the power line. (2) Common impedance coupling: This is also a common coupling mode. This form often occurs when the currents of two circuits have a common path. In order to prevent this coupling, it is usually considered in circuit design. There is no common impedance between the interference source and the interfered object. (3) Capacitive coupling: Also known as electric field coupling or electrostatic coupling. It is a coupling caused by the existence of distributed capacitance. (4) Electromagnetic induction coupling: Also known as magnetic field coupling. It is a coupling caused by distributed electromagnetic induction. (5) Leakage coupling: This coupling is purely resistive and occurs when the insulation is not good.
Common hardware anti-interference technology mainly adopts the following anti-interference measures for the three elements that form interference. 1 Suppressing interference sources Suppressing interference sources means reducing the du/dt and di/dt of the interference sources as much as possible. This is the most important and most important principle in anti-interference design, and it often achieves twice the result with half the effort. Reducing the du/dt of the interference source is mainly achieved by connecting capacitors in parallel at both ends of the interference source. Reducing the di/dt of the interference source is achieved by connecting an inductor or resistor in series with the interference source loop and adding a freewheeling diode. Common measures to suppress interference sources are as follows: (1) Add a freewheeling diode to the relay coil to eliminate the back electromotive force interference generated when the coil is disconnected. Adding only a freewheeling diode will delay the disconnection time of the relay. After adding a voltage regulator diode, the relay can operate more times per unit time. (2) Connect a spark suppression circuit (usually an RC series circuit, the resistor is generally selected from a few K to tens of K, and the capacitor is selected from 0.01uF) at both ends of the relay contact to reduce the impact of electric sparks. (3) Add a filter circuit to the motor, and pay attention to the capacitor and inductor leads to be as short as possible. (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. Pay attention to the wiring of the high-frequency capacitor. The connection line should be close to the power supply end and as thick and short as possible. Otherwise, it is equivalent to increasing the equivalent series resistance of the capacitor, which will affect the filtering effect. (5) Avoid 90-degree folds when wiring to reduce high-frequency noise emission. (6) Connect an RC suppression circuit at both ends of the thyristor to reduce the noise generated by the thyristor (this noise may break down the thyristor when it is serious). 2 Cut off the interference propagation path. According to the propagation path of interference, it can be divided into two categories: conducted interference and radiated interference. The so-called conducted interference refers to the interference transmitted to the sensitive device through the wire. The frequency band of high-frequency interference noise and useful signals is different. The propagation of high-frequency interference noise can be cut off by adding a filter to the wire, and sometimes an isolation optocoupler can be added to solve it. Power supply noise is the most harmful and should be handled with special attention. The so-called radiated interference refers to the interference transmitted to the sensitive device through space radiation. The general solution is to increase the distance between the interference source and the sensitive device, isolate them with a ground wire, and add a shield to the sensitive device. Common measures to cut off the interference propagation path are as follows: (1) Fully consider the impact of the power supply on the microcontroller. If the power supply is well made, the anti-interference of the entire circuit is mostly solved. Many microcontrollers are very sensitive to power supply noise. It is necessary to add a filter circuit or a voltage regulator to the microcontroller power supply to reduce the interference of power supply noise on the microcontroller. For example, a π-shaped filter circuit can be formed using magnetic beads and capacitors. Of course, 100Ω resistors can also be used instead of magnetic beads when the conditions are not high. (2) If the I/O port of the microcontroller is used to control noisy devices such as motors, isolation should be added between the I/O port and the noise source (add a π-shaped filter circuit). (3) Pay attention to the crystal oscillator wiring. The crystal oscillator and the microcontroller pins should be as close as possible, and the clock area should be isolated with a ground wire. The crystal oscillator shell should be grounded and fixed. (4) Reasonable partitioning of the circuit board, such as strong and weak signals, digital and analog signals. Keep the interference source (such as motors, relays) and sensitive components (such as microcontrollers) as far away as possible. (5) Use ground wires to isolate the digital area from the analog area. The digital ground and analog ground should be separated and finally connected to the power ground at one point. The same principle applies to the wiring of A/D and D/A chips. (6) The ground wires of the microcontroller and high-power devices should be grounded separately to reduce mutual interference. High-power devices should be placed at the edge of the circuit board as much as possible. (7) Using anti-interference components such as magnetic beads, magnetic rings, power filters, and shielding covers at key locations such as the microcontroller I/O port, power line, and circuit board connection line can significantly improve the circuit's anti-interference performance. 3 Improving the anti-interference performance of sensitive devices Improving the anti-interference performance of sensitive devices refers to considering how to minimize the pickup of interference noise from the sensitive device side and how to recover from abnormal conditions as quickly as possible. Common measures to improve the anti-interference performance of sensitive devices are as follows: (1) When wiring, minimize the area of the loop to reduce induced noise. (2) When wiring, 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. (3) For idle I/O ports of the microcontroller, do not leave them floating, but connect them to the ground or power supply. The idle terminals of other ICs are connected to ground or power without changing the system logic. (4) Using power monitoring and watchdog circuits for single-chip microcomputers, such as IMP809, IMP706, IMP813, X5043, X5045, etc., can greatly improve the anti-interference performance of the entire circuit. (5) Under the premise that the speed can meet the requirements, try to reduce the crystal oscillator of the single-chip microcomputer and choose a low-speed digital circuit. (6) IC devices should be directly soldered on the circuit board as much as possible, and IC sockets should be used less. 4 Other common anti-interference measures Use inductor and capacitor filtering at the AC end: remove high-frequency and low-frequency interference pulses. Transformer double isolation measures: connect capacitors in series at the primary input end of the transformer, connect the shield layer between the primary and secondary coils and the center point of the primary capacitor to the ground, and connect the secondary outer shield layer to the printed circuit board ground. This is a key means of hardware anti-interference. Add a low-pass filter to the secondary: absorb the surge voltage generated by the transformer. Use an integrated DC voltage regulator: because there are overcurrent, overvoltage, overheating and other protections. The I/O port is isolated by photoelectric, magnetoelectric and relay, and the common ground is removed. Twisted pair is used for communication line: parallel mutual inductance is eliminated. Optical fiber isolation is the most effective for lightning protection. Isolation amplifier or on-site conversion is used for A/D conversion: reduce error. The shell is connected to the ground: solve personal safety and prevent external electromagnetic interference. Add reset voltage detection circuit. Prevent the CPU from working when the reset is insufficient, especially for devices with EEPROM, insufficient reset will change the content of EEPROM. Printed circuit board process anti-interference: ① The power line is thickened, the wiring and grounding are reasonable, and the three buses are separated to reduce mutual inductance oscillation. ② For main chips such as CPU, RAM, ROM, electrolytic capacitors and ceramic capacitors are connected between VCC and GND to remove high and low frequency interference signals. ③ Independent system structure, reduce connectors and wiring, improve reliability and reduce failure rate. ④ The integrated block is in reliable contact with the socket, and a double spring socket is used. It is best to solder the integrated block directly on the printed circuit board to prevent poor contact failure of the device. ⑤ If conditions permit, use a printed circuit board with more than four layers, and the middle two layers are power supply and ground.