0

I have an AHRS (attitude heading reference system) that interfaces with my C++ application. I receive a 50Hz stream of messages via Ethernet from the AHRS, and as part of this message, I get UTC time. My system will also have NTPD running as the time server for our embedded network. The AHRS also has a 1PPS output that indicates the second roll-over time for UTC. I would like to synchronize the NTPD time with the UTC. After some research, I have found that there are techniques that utilize a serial port as input for the 1PPS. From what I can find, these techniques use GPSD to read the 1PPS and communicate with NTPD to synchronize the system time. However, GPSD is expecting a NMEA formatted message from a GPS. I don't have that.

The way I see it now, I have a couple of optional approaches:

  1. Don't use GPSD. Write a program that reads the 1PPS and the Ethernet message contain UTC, and then somehow communicates this information to NTPD.

  2. Use GPSD. Write a program that repackages the Ethernet message into something that can be sent to GPSD, and let it handle the interaction with NTPD.

  3. Something else?

Any suggestions would be very much appreciated.

EDIT: I apologize for this poorly constructed question.

My solution to this problem is as follows: 1 - interface 1PPS to RS232 port, which as it turns out is a standard approach that is handled by GPSD. 2 - write a custom C++ application to read the Ethernet messages containing UTC, and from that build an NMEA message containing the UTC. 3 - feed the NMEA message to GPSD, which in turn interfaces with NTPD to synchronize the GPS/1PPS information with system time.

enter image description here

Bryan Greenway
  • 703
  • 11
  • 30

2 Answers2

0

I dont know why you would want drive a PPS device with a signal that is delivered via ethernet frames. Moreover PPS does not work the way you seem to think it does. There is no timecode in a PPS signal so you cant sync the time to the PPS signal. The PPS signal is simply used to inform the computer of how long a second is.

dfc
  • 792
  • 5
  • 16
  • I don't think I've asked my question clearly. The 1PPS signal is coming from an embedded GPS, and I want to be a consumer of that signal (I should have shown the 1PPS signal connecting to the computer in the diagram above). My understanding is that the 1PPS signal is just a single, digital signal used to indicate, within 1 usec, the second rollover point of UTC time. This allows external systems to accurately synchronize with the UTC time provided by the GPS (in the Ethernet message). – Bryan Greenway Jan 05 '16 at 21:29
  • continued from above: So my imagined scenario would be: I get the latest UTC time (time in seconds since a given epoch) from an Ethernet message, let's call it T1. After getting T1, when the next 1PPS pulse occurs, UTC time will be trunc(T1+1) seconds. – Bryan Greenway Jan 05 '16 at 21:29
0

there are examples that show how a PPS signal can be read in using a serial port, e.g. by attaching it to an interrupt capable pin - that might be RingIndicator (RI) or something else with comparable features. the problem i am seeing there is that any sort of code-driven service of an interrupt has its latencys and jitter. this is defined by your system design (and if you are doing it, by your own system tailored special interrupt handler routine - on a PC even good old ISA bus introduced NMI handlers might see such effects).

to my best understanding people that are doing time sync on a "computer" are using a true hardware timer-counter (with e.g. 64 bits) and a latch that gets triggered to sample and hold the value of the timer on every incoming 1PPS pulse. - folks are doing that already with PTP over the ethernet with the small variation that a special edge of the incoming data is used as the trigger and by this sender and receiver can be synchronized using further program logic that grabs the resulting value from the built in PTP-hardware-latch. see here: https://en.wikipedia.org/wiki/Precision_Time_Protocol

along with e.g. 802.1AS: http://www.ieee802.org/1/pages/802.1as.html described wikipedia in section "Related initiatives" as: "IEEE 802.1AS-2011 is part of the IEEE Audio Video Bridging (AVB) group of standards, further extended by the IEEE 802.1 Time-Sensitive Networking (TSN) Task Group. It specifies a profile for use of IEEE 1588-2008 for time synchronization over a virtual bridged local area network (as defined by IEEE 802.1Q). In particular, 802.1AS defines how IEEE 802.3 (Ethernet), IEEE 802.11 (Wi-Fi), and MoCA can all be parts of the same PTP timing domain."

some article (in German): https://www.elektronikpraxis.vogel.de/ethernet-fuer-multimediadienste-im-automobil-a-157124/index4.html and some presentation: http://www.ieee802.org/1/files/public/docs2008/as-kbstanton-8021AS-overview-for-dot11aa-1108.pdf

my rationale to your question is: yes its possible. but it is a precision limited design due to the various internal things like latency and jitter of the interrupt handler you are forced to use. the achievable overall precision per pulse and in a long term run is hard to say but might be in the range of some 10 ms at startup with a single pulse to maybe/guessed 0,1 ms. - doing it means proving it. long term observations should help you unveiling the true practical caps with your very specific computer and selected software environment.

Alexander Stohr
  • 159
  • 1
  • 18
  • hint: a quite exhaustive set of samples for how to setup and interconnect the software packages you mentioned can be found here: http://www.catb.org/gpsd/gpsd-time-service-howto.html – Alexander Stohr Mar 14 '18 at 16:11
  • for the next level of deepness: the shared memory (SHM) communication between the two components is described here: https://www.eecis.udel.edu/~mills/ntp/html/drivers/driver28.html – Alexander Stohr Mar 14 '18 at 16:39