The last couple of weeks I’ve been busy building a
Raspberry Pi 2 Raspberry Pi 3 connected to my Trimble GPSDO using the 1 PPS output. The Trimble unit synchronizes with the atomic clocks onboard the GPS satellites, and the precision is fantastic! I bought the GPSDO to get a 10 MHz lab reference for my measure equipment, but after reading an article about Time-Nuts, people obsessed with measuring time as accurately as possible, and one of my friends showed me pictures of their new Stratum-1 NTP server rack he helped design, I was hooked.
So I started to read as much as I could about a way of setting up my Stratum-1 server using as cheap equipment as possible, but still get good results. And I think I’m on my way of getting good results. I’m currently nudging closer to measuring the errors in nanoseconds instead of µsec.
My first problem was that the output from the Trimble GPSDO’s PPS connector. It was CMOS pulse, with incredible clean edges, but the pulse width was only 10 µs. I tried to connect it directly to one of the Raspberry Pi’s GPIO pins, but the pulse was too short to trigger an interrupt. Usually, GPS units output either a 50% duty cycle square wave. So I needed to increase the length of the on-state of the pulse. After a lot of digging, I found a solution that didn’t add too much delay, or interfere with the razor sharp edges from the Trimble GPSDO unit. I also added over voltage protection on the out pin so that it wouldn’t fry the Raspberry Pi. The result was encouraging. The output square wave was clean as a whistle and just a couple of nanoseconds added to the signal. With my first attempts, I used an eBay DC to DC switching converter, but it introduced a lot of stray noise, so I used my earlier obsession with building a low noise DC converter for Hi-Fi equipment. That sorted that problem.
In the oscilloscope image above, the blue line is the output from my converter. The yellow line is from the GPSO. Yes, the pulse is so short it’s buried in the blue line. My calculations for the circuit was 250 ms, but as you can see it’s 225 ms. Good enough. The Raspberry Pi only uses the leading edge anyway. And now the GPIO pin gets an interrupt signal.
The PPS Converter
So this is the prototype for the converter. It isn’t pretty, but it does the job. I’m designing a PCB with an even faster IC and using surface mount components, and I’ve found an ultra-low noise DC converter that is perfect for this.
I’m almost finished designing the PCB the PCB is completed with better results, which will be housed in a Hammond (god, I love their boxes!”) enclosure. Maybe I can sell a few if there is some interest.
Setting up the kernel was a bit of a challenge. There’s a lot of misleading information on the internet (as usual), but I tried out several tricks, even going so far as to compile an RT-version (no good for this). I currently have mine hooked up as a Stratum-1 server at http://pool.ntp.org, and it’s holding up fine. Been running now for almost a week.
An LCD Display
I had an Adafruit RGB LCD Plate for Raspberry Pi laying around, so I connected it to the NTP server. It’s great for showing the time, current accuracy, number of computers connected and other statistics about the server. I’ve put it up on Github if you want to give it a try. It’s a hack, but it’s been running now for almost a week, and I’m adding features to it when I have time. The program is written in Python, so it’s easy to do your changes.