Home | Gadget | Fuzzy | Lecturer  | Power  | Transceiver



Find more type here...







Store it quickly!


Rainer Reusch


1/2009 elektor


The EEPROM in a microcontroller is often used to store collected data or device settings so that they are still available even if the device is switched off and then on again. However, there is a limit to the number of write cycles that the EEPROM can endure and so it is not always a good idea to store data at the earliest opportunity: an alternative is to store the data away quickly just before power is lost. That leaves the problem of detecting when the on-off switch is flicked or a power failure occurs, a problem which the circuit described here is designed to solve. The circuit is at heart a classical linear power supply consisting of a bridge rectifier, reservoir capacitor and voltage regulator. We have only added an extra diode (D1) in the main supply path. In normal operation smoothed DC levels appear at the output of the voltage dividers, and hence at the inputs to comparator IC1.





The component values in the first voltage divider (R1, R2 and C1) must be selected so that its output voltage, in the range 0.5 V to 1 V, is a little higher than that of the second voltage divider. The output of the comparator is then high. When power is removed the output voltage of the first voltage divider falls very rapidly, as the time constant of the circuit is small. However, the voltage after diode D1 is maintained for some time

thanks to reservoir capacitor C2.During this time the output of the comparator is low, generating an interrupt to the microcontroller. In the microcontroller, the interrupt is used to trigger the storage of essential data in EEPROM, and because it must complete this process using only the energy stored in reservoir capacitor C2, the value of this capacitor must be sufficiently large. The microcontroller can power down any connected loads (relays, LEDs and the like) in order to gain a little more time. The circuit shown is in principle also suitable for devices powered by (rechargeable) batteries, simply by dispensing with the transformer and bridge rectifier. In this case, capacitor C1 can also be dispensed with. Capacitor C2 is also not strictly necessary, but it does suppress a brief low-going pulse on the output of the comparator when power is applied.