Go Down

Topic: Simple backup power (Read 685 times) previous topic - next topic

perkunas

I was wondering if any of you guys have any simple back up power ideas
I don't like loosing all my settings when the power goes out, I was thinking like a 9v battery.
Guess I need diodes so it it wont get over charged, maybe there is a kit I don't know about.
Thanks

robtillaart


places the settings in EEPROM and read them at startup?
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

perkunas

Well I guess the settings I'm referring to, is the program runs various things 14 plus days, depending on how long some things take. Then the whole thing loops and starts over.I suppose I can store it at what point it was at, in eprom then on startup it can start at that point,  but that sure sounds super complicated.

perkunas

Oh ya, then if you wanted to start it at the beginning instead of at your saved point wow more complicated stuff.

robtillaart

Quote
I can store it at what point it was at, in eprom then on startup it can start at that point,  but that sure sounds super complicated.


Depends on the complexity of the algorithm itself. If your program is essentially a loop that have e.g.  10 variables that change during one iteration of the loop you can simply add some logic to store those ten vars every 2 hour to eeprom. In setup they are read from EEPROM.

Code: [Select]


void setup()
{
  ...
  readStateFromEeprom(...);
}
void loop()
{
  if (millis() - lastStore > 2L * 60L * 60L *1000L)
  {
    lastStor = millis();
    saveStateToEeprom(.....);
  }
  // rest of your code


to make it really fail safe you need to have at least 2 sets of variables in EEPROM including timestamp and a checkbyte to see it the written set is not corrupted due to a blackout during the save.


Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Go Up