Go Down

Topic: Save to eprom at power off diagram. (Read 11832 times) previous topic - next topic


Ah that makes sense now, just needed to wrap my head around it
it would draw less at higher voltage and more at less so maybe a 30ma draw will draw 15ma at 12v and as it goes down to 6 it gets more like 30ma but the whole time the power will be the same 12*.015=6*.030== .18w
Thanks for working out that math, I wouldn't know where to startt, im gonna save these formulas somewhere as they are nice to have instead of doing actual testing and measuring and timing and all that


Jul 02, 2012, 06:26 pm Last Edit: Jul 02, 2012, 06:35 pm by satoer Reason: 1
Hi guy’s. Thank you for all the input, and sorry for the late reaction. It’s been a busy week and this is just a hobby project I do in-between.

I had another idea involving a relay. So the Arduino can switch itself off after its finished writing the eprom.  Its for in a boat and permanent electricity is available.  But winner10920’s advise made me think. If I cycle the eprom I can easily reach more than a million writes. And if I can predict a power off, I can save before it really powers off.

I’ve made a routine that predict the power off. When the speed is lower than 2 kmpu and the distance travelled after the last save is at least 100 meters I save to eprom.  With more than a million writes It will most likely last more than the boat’s lifetime.

I haven’t quit figured out the cycle routine, but the idea is to save an extra “save counter” with the data, and every 1000 saves I move the data to a new address. And save that address location on address 0. So I can always find the save location by reading address 0.


Don't forget that a byte can only store up to the number 255, two byte will bbe needed to store the address so you can cyce the whole eeprom


Unless your storing more than 3 bytes in which one byte will work


and every 1000 saves I move the data to a new address. And save that address location on address 0. So I can always find the save location by reading address 0.

The byte(s) at address 0, being the most written one(s), will go first.


An alternative would be writing an out-of range value to at least one memory location when the program moves on to the next block - maybe a longitude that's out of range, or something.  On startup, the processor would just hunt down the block with an in-range value in the key address, collect the data, and start up.  Using the scheme described earlier, that would make for 1,001 writes before moving to the next block.  I'd bet the boat wears out before the EEPROM.


I did some practical experimentation related to writing data when disconnecting power. With a 680uF cap, a 12v supply, and an Arduino + sensors drawing 40mA, I get 100ms to save data after I detect power loss: plenty of time to write and exit.

I have an Arduino Pro mini 3.3v, GPS, and micro-SD card, which together draw 42mA. With a 680uF capacitor connected across the battery supply line (3x NiMH AA, 3.8v), and the main loop checking in every 20ms, I get only about 20ms warning before shutdown. That is, I can write one record to my uSD card saying 'looks like input voltage is dropping', but only one before shutdown. However with a 12v supply, I get a good 100ms warning; and if I increase to 1800uF I get 300-400ms at 12v, 250-300ms at 9v, and 40ms (two chances to notice in my setup) at 3.8v. Detailed data. (I harvested capacitors from a discarded laptop power brick.)

This is one of the top hits for saving Arduino data on power-off, and has lots of useful advice and theoretical background; hopefully some empirical numbers will benefit other people.

Go Up