Sample Header Ad - 728x90

Using RTC PPS for syncing computer by NTP

0 votes
1 answer
933 views
I've seen a decent amount of documentation for how one would use a GPS and its PPS signal along with an NTP package (like ntpd or chrony) to synchronize the computer's clock. I have a need similar to this, but different enough that it's been complicated to see a straightforward solution. ### The constraints Note, my environment is inherently without internet access or GPS signal, and the up-time will be very short-lived, a couple hours at a time perhaps. Note, in this case we have an off-board micro-controller and a basic linux machine (likely some single board computer type thing), the ultimate goal is for these to be synchronized. The microcontroller is connected to this RTC (with I2C) and the computer (through USB) and will be handling timekeeping and synchronizing of some external sensors. The computer takes information from the sensors and does various other things with it. Ethernet connection between linux machine and MCU is generally not possible, otherwise I would just use something like PTP or NTP more directly. #### Difference from GPS PPS The main difference here from the GPS PPS, is that the computer needs to read from the microcontroller serial communication for our purposes in addition to the synchronization. From my understanding this means we need modifications from the standard gpsd + ntpd/chrony since these two sources (our application and gpsd) can't simultaneously read from the same USB serial. #### Limitations Note, I am aware that this will not reach GPS levels of drift. What I need is a synchronized time source between my MCU and computer which is accurate to some number of milliseconds. I can accept that this whole systems drifts with 1-3PPM (the RTC) as long as everything drifts together. #### Idea for a solution My idea so far would be upon PPS signal from the external RTC - RTC PPS captured by MCU and linux machines GPIO pins - MCU sends (over serial) corresponding unixstamp to our application node (on linux machine) Our application then makes the PPS signal and unixstamp available to chrony. Which at this point should be able to treat it as if it was a GPS. So I'm basically circumventing gpsd so I don't have to share serial port access. Could this make sense? I have found almost nothing from other people doing something similar
Asked by Morten Nissov (130 rep)
Mar 9, 2023, 09:11 AM
Last activity: Mar 9, 2023, 09:56 AM