Using GPS 1 PPS to discipline counter to 1 interrupt per second and sync seconds

Hardware: Arduino DUE with Adafruit Ultimate GPS

Project: Controller for Slow Scan TV Camera connected to Amateur Radio transmitter. The controller implements a time window scheme so that multiple cameras can be used on the same RF frequency by staying within their assigned time windows.

The time aspects of this project are designed on the presumption that GPS lock could be lost some times. In that event, the GPS RX stops the 1 PPS signal. Thus I don't want to base my time sync on it being there all the time. Instead, I want to use the 1 PPS signal to discipline (adjust the count value) a counter that generates 1 interrupt per second to drive my time keeping by keeping the seconds synced to the GPS. It would be OK if the 1 PPS signal went away for a while. I won't need high time precision but I do want the clocks in all controllers to be reasonably synced to the second.

I could see checking clock sync a few times a day, but it does not have to be constant.

The research I've done thus far has not revealed someone that has done that, AFAIK. Is this a feasible approach? Any suggestions on how to implement this on a DUE?

Chuck - NA6BR

---------- Edit #1

I've been looking at the SAM spec sheet. It would seem I should use timer capture mode to count the clock freq for the time period of the 1 PPS from the GPS. This should give me a pretty decent idea of the count needed for one second. Doing this at various times of the day would help allow for day/night temp changes.


The part about using the 1 PPS signal to bring your microcontroller's timing back into sync doesn't sound like too difficult a challenge. Presuming your window is a multiple of seconds away, you can keep track of the error and adjust the "next time" to suit. This could be done by hooking up your 1PPS line to your Arduino and using a pin change interrupt (link to Nick Gammon's excellent explanation).

I've read elsewhere here that the internal timer in the Arduino can drift a few seconds a day, and it is susceptible to temperature. So that probably means you'll only have something to do if the GPS loses fix for some hours; and then you'll need to decide whether to round your seconds up or down as the pulse won't tell you anything about the actual time.