MCU power failure detection and preservation

When the MCU is functioning properly, it may suddenly lose power due to various reasons, resulting in the loss of data stored in the RAM. In applications such as measurement and control, the microcontroller often collects and processes critical data during normal operation. After a power failure, this data must be recovered upon re-powering. Therefore, in systems without a backup power supply, it's essential to store important data in EEPROM before the system completely loses power. To achieve this, it's common to implement a power-down detection circuit and a mechanism for saving data during power loss. A pull-up capacitor can be used to detect power loss and save data in the microcontroller. The circuit is shown below. Here, we use a 6V power supply (such as 7806), rather than 5V, because it provides more headroom for stable operation. Diodes in the circuit serve two purposes: they clamp the voltage to around 0.6V, ensuring that most 51-series MCUs operate within their nominal range of 4.5V to 5.5V. Additionally, they ensure one-way charging of the 0.47F capacitor, preventing reverse current flow. Two 47-ohm resistors are used for several reasons. First, they limit the current supplied to the MCU, protecting it from potential damage caused by overcurrent from the 7805 regulator. Without these resistors, a short or reversed polarity could easily damage the MCU or the regulator. These resistors should not be too large—ideally no more than 220 ohms—otherwise, the MCU might fail to power up properly. Second, they work with 47µF and 0.01µF capacitors to improve power supply filtering. Third, the 47-ohm resistor in series with the 0.47F capacitor helps prevent inrush current when the capacitor charges, limiting the peak current and protecting the system. To charge a 0.47F capacitor to 5.5V using a constant current of 5.5A would take about 0.47 seconds. However, without a current-limiting resistor, the three-terminal regulator could enter protection mode due to overcurrent. Moreover, a slow power-up rate could prevent the 51 MCU, which uses an RC reset circuit, from resetting properly. This could lead to communication failures during programming, as ISP devices typically require a response within 500ms. To address this, a diode and resistor are connected in series to create a power-up acceleration circuit. A Schottky diode (1N5819) is used here, as it has a low forward voltage drop (around 0.2V at small currents), minimizing voltage loss and maximizing the time available to save data before the MCU powers down. The 9014 transistor, along with a 470-ohm resistor and a 1N4148 diode, forms a comparator circuit on the base. This setup detects power loss and triggers a high-priority power-down interrupt. The circuit acts like a simplified version of LM393 but is more power-efficient, consuming less than 0.15mA when off. During normal operation, the emitter voltage remains around 0.6V, keeping the transistor off and the P3.2 pin high. When power is lost, the transistor turns on, triggering the power-down interrupt. This ensures that the MCU can execute the necessary data-saving routine before losing power entirely.

86inch Multimedia All-in-One PC

Touch the screen, Multi-touch panel,Intelligent touch display

Jiangsu Qilong Electronic Technology Co., Ltd. , https://www.qilongtouch.com