gps with pps as ntpd reference clock

general overview of my problem:
The project I work on involves several PCs controlling a ground vehicle, with different controllers/applications running on different machines (from basic actuator control to image processing and navigation). We want to have the clocks synchronised between these PCs as accurately as possible (1ms is okay, 1us would be great but possibly not achievable) so, for example, sensed data can be accurately transformed based on the vehicle’s position/heading/etc. The basic vehicle actuator controller is running QNX 6.3, the vision system runs on Linux (firewire camera, but that’s another story…), apart from the QNX actuator controller, other boxes may be added/removed depending on the application. Other possible controllers/payloads may run on any OS, but QNX where possible. All boxes are linked via 100mbit ethernet LAN.

basic solution:
We can set up ntpd with the QNX actuator controller as a server, and the other boxes can synchronise to this one giving us about 1ms accuracy between boxes. As the vehicle has no internet access this means using the local clock on the actuator controller as the reference…

better solution:
What we really want, is to use the GPS unit we have as a reference clock (NMEA messages accurate to 1s, and a PPS signal are available) however as far as I can tell, using the PPS as a reference clock is not supported by the QNX 6.3 kernel. Ultimately, for the best accuracy, we would like to use the one PPS to synchronise all PCs on the vehicle if this is at all possible (this should give better accuracy than ntp synchronisation over ethernet).

So firstly, have I got anything wrong so far? (i.e. am I actually tackling the problem I think i am) and secondly how would one go about adding PPS support to QNX?

Of course QNX doesn’t support a PPS signal directly in the kernel (that would be a monolithic kernel architecture). Actually, most monolithic OSes don’t even support the PPS signal directly in the kernel (although some do).

I haven’t looked too deeply into this, but think what you need to do is create a QNX driver (not in the kernel :slight_smile: based on the following code ftp://ftp.udel.edu/pub/ntp/software/nanokernel.tar.gz.

This will give you the PPSAPI that ntp expects. On the back-end of your driver you’d be doing ClockAdjust().

There could be a gotcha here, but if your prepared to spend a couple of hours on it, this should get you going.

Let us know what you find.

I implemented a resource manager for Neutrino almost 3 years ago that
uses the PPS signal from a GPS device (the DCD line on the serial port) to discipline the local NTP. It is posted at

cs.nyu.edu/~bacon/pps/

Enjoy!

  dB