I am building a positioner and I store the current position to EEPROM when the move is complete. On start up, I want the positioner to return to the HOME position. I am running an UNO powered from the USB. My problem is that if the Arduino is turned off, I would like to stop the move and store the current position before the Arduino dies.
Note that this would also be relevant to devices like thermostats which remember the set point through a power outage.
Store position in EEPROM at each step. No, that will wear out the EEPROM.
Connect a large capacitor from +5V to Gnd. When this falls below a set level, trigger an interrupt (ISR) that stops motion and stores current position in EEPROM.
- Will #2 work, and how could I program it?
- Any other ideas I am missing?