NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Basic Electronics » Save state data to EEPROM with power cutoff capacitor value?

May 20, 2011
by gcharris
gcharris's Avatar

I'm looking to build an power cutoff state saver for a project. Basically when the atmega power is cut off this will be trigger an interrupt that will save some state data to eeprom.

What do you guys think would be a sufficient value capacitor to power the atmega for long enough to write a few values to eeprom (three double values and an int)?

May 20, 2011
by gcharris
gcharris's Avatar

I'm guessing I should also have a diode to stop the capacitor from powering other non-processor loads. Any suggestions on a type?

May 20, 2011
by Hexorg
Hexorg's Avatar

Well the current to the uC will be too small to damage any diode, so any regular diode should do.

it's the capacitor I worry about. Let's see... ATmega168's power consumption is about 250mA at 5V... That's 250mA*5V = 1.25mW of power. That means that it will use 1.25mJ per second.

Energy stored on a capacitor is:

W = 1/2 * C * V * V
W = energy stored (Joules)
C = capacitance  (Farad)
V = potential difference (Voltage)

So 1.25mJ = 1/2 * C * V2, and we know that V is 5.0V, making

1.25mJ = 0.5 * C * 5V * 5V
1.25mJ = 0.5 * 25 V^2 * C
1.25mJ = 12.5 V^2 * C
C = 1.25mJ / 12.5 V^2
C = 100uF

You'll probably have to connect 2 47uF electrolytic capacitors in parallel to get 94uF capacitance.

Also, as soon as you detect that the power has been cut off, first thing you should do is set all the pins as inputs. That will cut off any leaking power. From there one second should be enough to save everything. Once that works, you can find out how much exactly it takes to cut off all the pins, and save the data, and from there you should be able to recalculate needed capacitor value to provide you with enough power. But remember, capacitor's charge should still be well above the brown-out voltage, otherwise uC will turn off.

May 24, 2011
by gcharris
gcharris's Avatar

Thanks! I'll keep you posted on my progress.

Post a Reply

Please log in to post a reply.

Did you know that NerdKits has a TV commercial, seen on MythBusters and the Science Channel? Learn more...