MCU power failure detection and storage

Publisher:才富五车330Latest update time:2016-09-12 Source: eefocusKeywords:MCU Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
When the microcontroller is working normally, if there is a sudden power failure due to some reason, the data in the data memory (RAM) will be lost. In some applications such as measurement and control, the microcontroller collects and calculates some important data during normal operation, and these important data need to be restored after the next power-on. Therefore, in some microcontroller application systems without a backup power supply system, it is necessary to store these collected or calculated important data in the EEPROM before the system is completely powered off. For this reason, the usual practice is to add a microcontroller power failure detection circuit and a microcontroller power failure data storage to these systems.

Farad capacitors can be used to easily implement power-off detection and data storage for microcontrollers. See the circuit diagram below. Here, 6V power supply (such as 7806) is used first. It is obvious why 6V is used instead of 5V. The diodes in the circuit generally play two roles. One is to clamp 0.6V to ensure that most 51 series microcontrollers can work at a nominal operating voltage between 4.5V and 5.5V. The charge loss time of the 1V voltage between 4.5-5.5 in the 0.47F capacitor is the warning turnaround time that we can plan after the microcontroller power-off detection alarm in the future. The second is to use unidirectional conductivity to ensure unidirectional charging to the energy storage capacitor 0.47F/5.5V.

 

The two 47 ohm resistors have the following functions: First, they limit the current of the microcontroller power supply. Generally, the microcontroller power supply is directly connected to the 7805, which is an unsafe practice. Why? Because the 7805 can provide a power supply current of up to 2A, which is enough to burn the microcontroller chip when abnormal. With the protection of this 47 ohm resistor, the microcontroller and the three-terminal regulator will not be burned even if the chip or polarity is inserted in reverse, but this resistor cannot be too large, and the upper limit should not exceed 220 ohms, otherwise the programming will fail when programming the microcontroller (actually due to insufficient power). Second, it is used together with 47UF and 0.01UF capacitors to strengthen the power supply filtering. Third, for the 0.47F/5.5V energy storage capacitor, the 47 ohm resistor connected in series eliminates the power-on surge of the "huge farad capacitor" to achieve peak current clipping.

 

 

MCU power failure detection and storage - Driver Core - Driver Core
 

 

Now let's calculate that to fully charge a 0.47F capacitor to 5.5V, even if a 5.5A constant current is used to charge the 0.47F capacitor, it will take 0.47 seconds to charge to 5.5V, so we can know:

1. If there is no 47 ohm resistor to limit the current, the three-terminal regulator will inevitably enter self-protection due to the strong overcurrent at the moment of power-on.

2. The slow power-on time of 0.47 seconds (if there is a 5.5A constant current charge) will make the 51 single-chip microcomputer with a differential (RC circuit) reset circuit unable to achieve power-on reset because the power-on time is too slow. (In fact, it often takes several minutes to fully charge a 0.47UF capacitor).

3. Because the power-on time is too slow, it will not match the waiting response time reserved by most of today's mainstream online writing (ISP) type microcontrollers and the upper computer software of the writing chip (generally no more than 500MS), resulting in a loss of response, so it always prompts "communication failure".

Knowing this principle, it is not difficult for you to understand that the diode and resistor at the top of this circuit are connected in series to form a power-on acceleration circuit. A Schottky diode (1N5819) (hollow inside and without blue) is also used here to discharge from the farad capacitor to the microcontroller VCC, and at the same time block the bypass effect of the farad capacitor on the power-on acceleration circuit. The Schottky diode is used based on its conduction voltage of only about 0.2V under low current. The purpose is to minimize the voltage loss of the farad capacitor when the microcontroller is powered off. Leave more power-off maintenance time.

The transistor 9014 and the clamping diode voltage divider resistor pad resistor (470 ohms) form a base-emitter double-ended input comparator to realize the microcontroller power-off detection and issue the highest priority power-off interrupt. The microcontroller saves the program execution when it powers off. This part of the circuit is equivalent to half of the comparator LM393, but the circuit is simpler and consumes less power (the power consumption is less than 0.15MA when the power is off).

The 47K resistor and the 470 ohm diode 1N4148 form a clamping circuit to ensure that the base potential is about 0.65V (which can be calculated as 0.6 (diode conduction voltage) + 5*0.47/47). In this way, if the emitter voltage of 9014 is 0 (at this time, the external power is off), the transistor 9014 is just turned on, and because the high level of P3.2 of the 51 microcontroller is weakly pulled up (about 50UA), at this time 9014 must be turned on and weakly saturated with current, so that the INX0 power-off detection interrupt with the highest hardware priority is sent to the microcontroller.

 

During normal power supply, since there is a voltage of about 6*0.22/2.2=0.6V on the emitter, it is not difficult to find that transistor 9014 must be in the cut-off state, and P3.2 maintains a high level, and the microcontroller power-off preservation interrupt program is not triggered.

Finally, there are two important software and hardware notes:

 

Software: First, INX0 is at the highest priority in hardware (design), and here we must also ensure the highest level of priority in software. This ensures that when the microcontroller loses power, external interrupt 0 can interrupt any other process and be detected and executed with the highest priority. Secondly, when INX0 is powered off, save the entry of the subroutine module and use:

MOV P1, #00H 

MOV P2,#00H

MOV P3,#00H

MOV P0,#00H

SJMP Power-off save

To block the charge of the farad capacitor from leaking out through the microcontroller port line and then jump to the power-off save write subroutine module. (See Hardware Points)

 

Hardware: For any device that drives the external port line of the microcontroller and outputs a high level to drive external devices, its power supply cannot compete with the power supply voltage VCC of the microcontroller (for example, the power supply of the pull-up resistor is not taken from the VCC of the microcontroller). Instead, it should be directly connected in front of the power supply. The 4.7K resistor and the port line PX.Y in the figure is a typical example, and the connection of other port lines PX.Y' and loads is similar. The diode connected in series with the pull-up 4.7K resistor here also has two functions: 1. Clamp off the 0.6V voltage to match the working voltage of the microcontroller, and prevent the port line from pushing back the power to the inside of the microcontroller, causing the function of the microcontroller port line to be disordered. 2. Use the unidirectional power supply characteristics of the diode to prevent the microcontroller from supplying power to the power supply and external devices through the port line after power failure.

 

The above MCU power-off detection circuit, when combined with the power-off saving writing subroutine module, can ensure that during the power-off of the MCU, the accumulated charge on the farad capacitor will not provide unnecessary power to the external circuit that has been powered off and reverse power to the power supply, causing the capacitor energy to be discharged and shorten the power-off maintenance time.

 

With these basics, let's calculate the power-off working time of the microcontroller that can be maintained when the 0.47UF capacitor drops from 5.5V to 4.5V (or even to 3.6V). Here, assuming that the microcontroller operating current is 20MA (the peripheral drive current has been shielded), it is not difficult to calculate: 

T=1V*0.47*1000 (1000 is because the working current is HaoA)/20=23.5 seconds!

Keywords:MCU Reference address:MCU power failure detection and storage

Previous article:PIC series microcontroller reset circuit
Next article:Introduction to important instructions in PIC microcontroller

Recommended ReadingLatest update time:2024-11-16 13:47

Single chip LCD12864 linked list to achieve the greedy snake source code
The microcontroller source program is as follows: #include reg52.h #include stdlib.h #include lcd12864.h #define uchar unsigned char #define uint unsigned int #define Random(x) (rand()%x) #define dgrade 11 #define igrade 15 #define up 9                                    #define down 13                           
[Microcontroller]
What are the characteristics of a single-chip microcomputer? Why should we learn such a weak computer?
Answer: Since the single-chip microcomputer integrates all the main components of the microcomputer on a chip, that is, a chip is a microcomputer. Therefore, the single-chip microcomputer has the following characteristics: 1) Excellent performance-price ratio. At present, in the domestic market, some single-chip mic
[Microcontroller]
Freescale 16-bit MCU (10) - PIT module test
1. Introduction to PIT module PIT is the abbreviation of Periodic Interrupt Timer Module. The PIT timer of XEP100 MCU is an array of 24-bit timers. It can be used to trigger peripheral devices of MCU, and can also be used to generate periodic interrupts. The PIT module of XEP100 MCU has the following features: 1. 8
[Microcontroller]
Freescale 16-bit MCU (10) - PIT module test
What is the functional significance of each flag in the PSW register of the 8051 microcontroller?
The program status word PSW is an 8-bit register used to store the status information of the program running. The status of each bit in PSW is usually automatically formed during the execution of instructions, but it can also be changed by the user using transfer instructions as needed. The meaning of each flag bit is
[Microcontroller]
About the MCU code architecture layering
I recently read an article by a great writer Wu Jianhong. His software architecture is well written, but his coding style is average, with global variables flying everywhere. However, the products he developed are stable and have good performance. In any case, in a company, the boss only pursues results, not processes
[Microcontroller]
MSP430 MCU drives MSM7512 program
#include #define uint unsigned int #define uchar unsigned char              //P1.2 connects to RD (pin 9) #define MOD1_1 P1OUT |= BIT0 //P1.0 connects to MOD1 (pin 14) #define MOD1_0 P1OUT &= ~BIT0 #define MOD2_1 P1OUT |= BIT1 //P1.1 connects to MOD2 (pin 15) #define MOD2_0 P1OUT %= ~BIT1 void SysInit(uint x)
[Microcontroller]
C51 MCU————Bus and system expansion
1. Citation As mentioned above, the characteristics of single-chip microcomputers are small size, full functions, compact system structure, and can meet the requirements of small needs. So what about a slightly larger embedded system? Then it is possible that your data memory, program memory, and IO ports may not be
[Microcontroller]
C51 MCU————Bus and system expansion
Code Optimization Techniques for Eight-Bit Microcontrollers
This article will introduce some optimization techniques that can help designers save up to 10% of code space, allowing limited program memory to support more new features and patches. Good operating methods Many programmers learn to write software on 32-bit processors, such as Intel's Pentium processo
[Microcontroller]
Code Optimization Techniques for Eight-Bit Microcontrollers
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号