[time-nuts] keeping Arduino timekeeping and clock synced up
Jim Lux
jimlux at earthlink.net
Sun Jan 19 20:39:34 UTC 2014
It turns out there's a handy Arduino library for time. And it will
ingest GPS or NTP, etc., as well as run off the internal clock.
One strategy, then, is:
Set the "clock" in the Arduino
then, periodically (once a minute or hour)
look up the date and time
calculate "rate"
set tick rate for external clock driver
Then you have a thing which generates 1pps ticks at the desired rate.
Right now, I have a little interrupt loop that runs once a
second(adjusted by rate) do it.
One could also calculate "solar time" (as UTC + EOT offset) repeatedly
(after all, there's nothing else for the Arduino to do) and whenever the
seconds changes, send a tick to the clock.
This technique doesn't try to keep the integral of ticks aligned with
"UTC + EOT offset", though. If the tick rate were slightly off
(roundoff errors in the math, most likely), then there will be some
relative drift.
So, periodically, one would need to reset both the analog clock AND the
Arduino clock to bring them back to proper alignment.
I suppose that periodically, one could compare "number of ticks sent"
with "UTC + EOT offset" and try to compensate (by dropping ticks or
adding them).
More information about the Time-nuts_lists.febo.com
mailing list