Interrupt for powerloss and save Data into EEPROM

Status
Not open for further replies.

walle

Member
I have a little Question,
Is it possible to get a low power Interrupt when I unplug the USB Cable? And then in the ISR write some Bytes into EEPROM.
Or do I need a big capacitor/ external voltage divider...?

Thanks,
Lars
 
A large cap and voltage divider is what is done where I work when we want to do a shutdown before power is lost (we like to turn off the gate drivers before we loose power).

Here is what we do, we have a resistor and schottky diode in parallel with a cap in series. The resistor slowly charges the cap during power up and when power is removed the voltage passes through the schottky, giving you time to shutdown. The size of the cap is dependent on the Load of your system, you should pick a diode with a low voltage drop. Use a voltage divider to read the 5V line, as soon as it drops below say 4.3V start backing up. We use much larger caps at work since we have to allow for over an amp worth of consumption. We also have a larger voltage range, we run 24V nominal and we have to have the system shutdown before we reach 18V.

In order for this to work you need a good idea of how long you have from when you detect the falling voltage to when you hit say 3.7V on the 5V line which is dependent on the Diode/Cap Size vs RLoad. You also need to know how long you actually need to save your data. It also helps to be reading the Voltage fairly regularly.

My below example will realistically only give you a few mS before you run out of juice, its very dependent on load.

Discharge backup.JPG
 
The Teensy does have a configurable interrupt for power going below a threshold. It also has wear leveling on the EEPROM, so you might consider periodically saving state regardless of the power status. And there is an internal signal for reading the power so you don't have to use up an external pin.
 
Status
Not open for further replies.
Back
Top