Misunderstandings and Countermeasures in Single Chip Microcomputer System Design

Publisher:chenxiaohong68Latest update time:2012-02-23 Source: 21ICKeywords:MCU Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The application of single-chip microcomputer system in military, industrial and civilian products is becoming more and more widespread. It uses software to complete many functions that were previously implemented by hardware. It is small in size, rich in functions, and intelligent in program. However, it also faces many new problems in terms of reliability. Using the field electromagnetic compatibility (EMC) theory to analyze some traditional concepts in the design of single-chip microcomputer systems, many misunderstandings will be found, and some misunderstandings are still widely present in the engineering community.

1 Myth 1: A watchdog will prevent computer crashes

A freeze means that the CPU program pointer enters an infinite loop and cannot execute the normal program flow. Its external manifestations are often: loss of normal functions, no response to buttons, and frozen display. After the microcontroller freezes, only recovery can get out of the infinite loop and execute the normal program flow. As we all know, the most effective way to overcome freezes is to add a watchdog.

The most widely used watchdog is actually a special timer DogTimer. DogTimer counts at a fixed rate and sends an overflow pulse to reset the microcontroller when the preset time is reached. If DogTimer is forced to reset to zero before DogTimer overflows, no overflow pulse will be sent. The reset pulse is sent by the CPU. In the microcontroller program, a clear DogTimer statement, FeedDog statement, is placed every other statement to ensure that DogTimer will not overflow when the program is running normally. Once the program enters an infinite loop without FeedDog statement, DogTimer will overflow, causing the microcontroller to reset and jump out of the infinite loop. This article calls this watchdog a typical watchdog. Typical watchdogs have been integrated, such as MAX706, MAX791, etc. [1]; there are also many microcontrollers that integrate this watchdog, such as PIC16C57, MC68HC705, etc. For specific circuits, please refer to the technical data of these chips [2].

There is a wrong view: adding a watchdog will prevent the microcontroller from crashing. In fact, the watchdog will be completely ineffective at times. When the program enters a dead loop, and this dead loop contains the FeedDog statement, the DogTimer will never overflow, the microcontroller will never get a reset signal, and the program will never jump out of this dead loop. To address this drawback, the author designed a dual-limit watchdog and a timed reset watchdog. [page]

The dual-time limit watchdog has two timers; one is a short timer and the other is a long timer. The short timer is set to T1 and the long timer is set to T2, 0

Thus, when the program enters a dead loop, if the dead loop contains a short timer FeedDog statement but not a long timer FeedDog statement, the long timer will eventually overflow, causing the microcontroller to reset. By cleverly arranging the position of the long timer FeedDog statement, the probability of a crash can be minimized. This has been demonstrated by a comparative application in a microcomputer control device for a hydropower generator set [3].

At present, almost all watchdogs are dependent on the CPU (dependent on CPU FeedDog). This can be compared to: whether a safety device can play a safety role depends on the behavior of the object it protects. Obviously, a watchdog that relies on the CPU cannot guarantee that the microcontroller will not crash 100%.

In a device that absolutely cannot allow a crash, the author has designed a watchdog that is completely independent of the CPU - a timer reset watchdog. The main body of the timer reset watchdog is also a timer, which sends an overflow pulse at a predetermined time. This overflow pulse forces the microcontroller to reset. The timer reset watchdog does not require a CPU FeedDog.

In short, the timed reset watchdog is to force the MCU to reset at regular intervals. In this way, even if the device crashes, its maximum crash time will not be greater than the timer timing time. Obviously, as long as the hardware is intact, this watchdog can 100% guarantee that the MCU will not crash for a long time. In smart meters (including IC card energy meters, multi-rate energy meters, and multi-function energy meters [4]), a timed reset watchdog is used to force the CPU to reset every 1 second. So far, hundreds of thousands of meters have been running for nearly five years without a single crash report.

It must be pointed out that when using this watchdog, the CPU programming must adapt to the environment of timed reset to ensure that the timed reset does not interrupt programs that cannot be interrupted and does not cause any malfunctions.

2 Myth 2: Adding a power filter can improve EMC performance

In the single-chip microcomputer system, in order to suppress electromagnetic interference (EMI), an electromagnetic filter is often added between the AC power supply line and the power transformer. The commonly used power filter is shown in Figure 1.

Figure 1 is a dual type II LC filter, where C0 is used to bypass differential mode interference. The difference between the two is that in Figure 1 (b), the two capacitors are connected to the ground. Assuming the resistance of the inductor is R, their frequency isolation characteristics are:

When R is very small, the resonant frequencies of the above two filters are:

It can be seen that their amplitude-frequency characteristics are similar, but their resonant frequencies are different. From the perspective of filtering effect, the two are similar in reducing differential mode interference from AC power, but the latter is better in reducing common mode interference. However, for devices using floating ground, since the capacitor cannot be directly connected to the ground, only the latter can be used.

When designing a filter, it is important to make sure that the resonant frequency is much smaller than the interference frequency. If it is not handled properly, it will not only fail to attenuate the interference, but will amplify it. Taking the dual II filter in Figure 1 (a) as an example, if L=1mh, R=1Ω, C=0.47μF (this is the parameter recommended by many materials), f0=5.2kHz can be calculated. The frequency of the fast pulse group in the EMC test is 5.0kHz (2kV) or 2.5kHz (4kV); 5.0kHz just resonates, and 2.5kHz will not be attenuated, as shown by the dotted line in Figure 2. It can be seen that not all power supply filters can improve EMC performance. In engineering, many devices are still difficult to process EMC tests despite the use of expensive filters, and most of the reasons are here.

In fact, if L=30mh, R=5Ω, C=0.47μF, we can calculate f0=0.95kHz, the 5.0kHz pulse group amplitude is reduced to 3.73%, and the 2.5kHz pulse group amplitude is attenuated to 16.78%. At this time, the power supply filter does improve the EMC performance of the system. The solid line in Figure 2 is the amplitude-frequency characteristic of Xiangqing.

3. Myth 3: Optical coupler devices isolate interference thoroughly

Optical couplers are the most commonly used interference isolation devices. For example, after the switch quantity on site is led to the measurement and control device, optical isolation must be added to cut off the conducted interference from the site; the RS485 communication port is connected to the external communication line through an optical isolation to prevent conducted interference from the external communication line.

Many people think that optocoupler devices can completely isolate interference, and that interference will not be eliminated if optocouplers are used. In fact, optoelectronic isolation is not a perfect solution.

First of all, the optocoupler device itself can only isolate the conducted interference, it isolates the continuous radiation and induction interference. Radiation comes from space, and induction comes from adjacent conductors. The most common failure is: when designing the PCB, the input and output circuits of the optocoupler device are laid out together. At this time, the interference cannot pass through the optocoupler device, but it is easy for the input circuit to sense the output circuit.

Secondly, the ability of optical couplers to isolate conducted interference is only about 1kV, and interference or surges above 1kV are generally beyond their ability. For example, in the EMC fast pulse group test, the interference signal amplitude applied is 2kV, 4kV, and 8kV, and optical couplers cannot isolate it. [page]

4 Myth 4: PCB wiring should be horizontal and vertical

When it comes to PCB wiring, many engineers and technicians know a traditional experience: horizontal routing on the front and vertical routing on the back, which is both beautiful and short; another traditional experience is: as long as space allows, the thicker the routing, the better. It can be clearly said that these experiences are outdated today when we pay attention to EMC.

In order to ensure that the MCU system has good EMC performance, PCB design is critical. A PCB with good EMC performance must be designed according to high-frequency circuits - this is unconventional. The reason why the MCU system PCB is designed according to high-frequency circuits is that although the operating frequency of most circuits in the MCU system is not high, the frequency of EMI is high, and the simulated interference frequency of the EMC test is also high [5]. In order to effectively suppress EMI and successfully pass the EMC test, the design of the PCB must take into account the characteristics of the high-frequency circuit. The key points of PCB design according to high-frequency circuits are:

(1) There must be a good ground layer. A good ground layer has equal potential everywhere, will not produce common mode resistance coupling, and will not form a loop through the ground to produce an antenna effect; a good ground layer can make EMI enter the ground through the shortest path and disappear. The best way to establish a good ground layer is to use a multi-layer board, with one layer dedicated to the ground layer; if only a double-sided board can be used, the wiring should be routed from the front as much as possible, and the back should be used as the ground layer, and the wiring should only be passed from the back as a last resort.

(2) Maintain sufficient distance. Maintain sufficient distance between two wires or two groups that may cause harmful coupling or radiation, such as the input and output of a filter, the input and output of an optical coupler, and the AC power line and weak signal line.

(3) Long lines with low-pass filters. The lines should be as short as possible. If long lines have to be run, C, RC or LC low-pass filters should be inserted at reasonable locations.

(4) Except for the ground wire, do not use thick wires when thin wires can be used. Because each trace on the PCB is both a carrier of useful signals and a trunk line for receiving radiation interference. The longer and thicker the trace, the stronger the antenna effect.

5 Myth 5: IC chip packaging does not affect performance

As we all know, IC chip packaging is divided into SMD and DIP. It is generally believed that the difference between SMD and DIP is mainly the size and welding method, which has little effect on system performance. In fact, it is not.

As mentioned earlier, every trace on the PCB has an antenna effect. Now let's say that every component on the PCB also has an antenna effect. The larger the conductive part of the component, the stronger the antenna effect. Therefore, for the same model chip, the antenna effect of a smaller package size is weaker than that of a larger package size. This explains a phenomenon that many engineers have noticed: the same device is easier to pass EMC testing with SMD components than with DIP components.

In addition, the antenna effect is also related to the working current loop of each chip. To weaken the antenna effect, in addition to reducing the package size, the working current loop size, operating frequency and di/dt should be reduced as much as possible. If you pay attention to the pin layout of the latest IC chips (especially single chips), you will find that most of them have abandoned the traditional way - GND in the lower left corner and VCC in the upper right corner, and arranged VCC and GND in adjacent positions in order to reduce the size of the working current loop.

In fact, not only IC chips, but also resistor and capacitor packaging are related to EMC. 0805 packaging has better EMC performance than 1206 packaging, and 0603 packaging has better EMC performance than 0805 packaging. Currently, 0603 packaging is popular internationally.

Keywords:MCU Reference address:Misunderstandings and Countermeasures in Single Chip Microcomputer System Design

Previous article:Low power consumption technology and application of single chip microcomputer
Next article:Experimental study on the irradiation effect of transient electromagnetic pulse on single chip microcomputer and its reinforcement method

Recommended ReadingLatest update time:2024-11-16 15:48

AVR microcontroller (learning) - (IV), ATMEGA16 timer/counter - 05
4. ATMEGA16 Timer/Counter IV-(05) Input capture experiment of T/C1 Or just post pictures: Okay, today I'll finish the fourth chapter~~ There are only so many timers/counters in ATMEGA16~~ It will be useful if you can~~   I actually forgot to post the program: //------------------------------------------------
[Microcontroller]
AVR microcontroller (learning) - (IV), ATMEGA16 timer/counter - 05
NXP releases a new generation of MCX A microcontroller to promote more innovative technologies with upgraded MCU functions and complete development platform
NXP's new generation MCX A series MCU cooperates with the well-known FRDM development platform in the market to comprehensively optimize performance and equip independent peripherals in a cost-effective manner, laying the foundation for creating intelligent edge applications. Shanghai, China - February 1, 2024 - NXP
[Embedded]
Establishing AVR microcontroller development environment under Linux
I have an ATmega128 development board, which has been gathering dust since I used Ubuntu. In fact, it is very convenient to develop avr microcontrollers in linux, just like embedded systems, just change the compiler from arm-linux-gcc to avr-gcc. Main reference: apt-blog.net/developing_avr_under_linux Environment:
[Microcontroller]
PIC microcontroller programming basic format typical program structure framework
When creating a source program, first use the pseudo-instruction TITLE to provide the program title, then give a general description of the entire program, and use the list pseudo-instruction LIST to specify the microcontroller model and file output format used, and then use the INCLUDE pseudo-instruction to read the
[Microcontroller]
PIC microcontroller buzzer and relay
1. Buzzer Experiment In many single-chip computer systems, there are often sound devices in addition to display devices. The most common sound device is a buzzer. Buzzers are generally used in some occasions where the requirements are not high, such as sound alarms and key operation prompts. The shape of a buzzer
[Microcontroller]
PIC microcontroller buzzer and relay
51 MCU-Buzzer
The buzzer is an integrated electronic sounding device, which is mainly divided into two types: piezoelectric buzzer and electromagnetic buzzer. It is widely used as an alarm device in electronic equipment such as computers, printers, copiers, alarms, and telephones. The buzzers used on single-chip microcomputers ar
[Microcontroller]
51 MCU-Buzzer
Share the PWM wave program of stc15 microcontroller
#include  "include.h" /*------------------pwm function initialization-------------------*/ void PWM_GO(void) {         PWMCFG &= 0xBF; //Set CBTADC position to 0, that is, ADC conversion will not be triggered when the PWM counter returns to zero         PWMIF &= 0xBF; //Set CBIF to 0, PWM counter reset interrupt
[Microcontroller]
Design of hardware structure and control system of descending device based on single chip microcomputer control
This paper introduces a hardware structure and control system of a descent control device based on single-chip microcomputer control. The system uses a single-chip microcomputer as the control core of the system and combines photoelectric sensor technology to realize the measurement of the descent speed, thereby achie
[Microcontroller]
Design of hardware structure and control system of descending device based on single chip microcomputer control
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号