Auto-correct after power-fail
phord opened this issue · comments
When power fails we should record the time we last sent to the clock in some NVR region. When power is restored, we can calculate the number of pulses we missed and calculate the correct action to "catch up" the clock to the correct time. We need to be able to run long enough to react to the power failure. A large capacitor should keep the arduino active for a few seconds. A signal line from the 24V coil to a DIO pin can be used to detect the power failure itself.
We can use some clever tricks to minimize looking stupid while we adjust.
delta = time lost
delta %= 12 hours
if ( delta < 11:30 ) advance steps to catch up
else wait until delta = 12:00 and then run normally (might confuse users while we sit idle)
OR --> run as normal (30 minutes fast) and allow auto-correction to align us.