There are two network time protocols in use today. One is the NTP protocol, the other is PTP. I have no idea what the PTP looks like, I know that it requires hardware support.
The goal of NTP is to create a local clock that is accurate to less than 1ms from sources that have up to a hundred times that in latency.
The fact that this works at all simply amazes me.
I have 7 servers acting as an NTP cluster. That is to say, they all work to come to a consensus as to what time it is, and then each syncs to that time point.
They do this via actively querying each other every 64 seconds. The protocol knows that the referenced clock time is somewhere within the total time from query to response. Using complex statistics, it can get it much closer than just “somewhere” or “middle”.
As I am writing this, one server believes it knows the time to the network with a standard deviation of less than 500us. It has one nailed down to less than 83us.
Within the local cluster, it believes it knows the time within 50us for all the cluster members. For a few of the cluster members, they agree on the time within 3000ns (3us). That’s not bad.
So what are the problems.
The first problem is that I have a clock that claims to be very accurate, but which I know is slightly wrong.
The clock is fast by 957us with an SD of 57us. I believe it to be worse than that. The issue being that the clock is influencing the rest of the time cluster.
I did that because I had a usable fudge factor for the clock. Now I need to bring it much closer to “real time”.
To that end, I’ve reconfigured the server with the GPS clock to never use the GPS time. Instead, it will use the network servers to converge on “the time”. Once I know “the time” I will be able to adjust the GPS offset better.
The second issue is that USB injects jitter into the signal. We don’t know when the USB port received the time message from the GPS unit. Hopefully, we have a good estimate, but it is still very jittery.
It is nearly impossible to get down to 1ns or less with a clock that has a 500us jitter.
What does this mean? I need to stabilize the time signal. We do that with a PPS. This pulse tells us that the second happened on the rise or fall of the pulse. This is configurable. The second starts on the rising edge of the pulse. With a PPS input, we can reduce jitter to a few nanoseconds.
The issue still is, “What is the offset detecting the leading edge from the “real” start of the second?”
This value comes from the delay along the antenna cable and other such speed of light delays.
Which takes us to the conclusion of this article.
The GPS units I purchased came with a small ceramic antenna. The antenna is about 10 mm on a side. It has a 10 cm connector. This means the unit and the antenna are very close to each other. The antenna isn’t a great antenna.
With this taped to the inside of the window, I was picking up 3 satellites. I replaced it with a cheap, yet “real” antenna. I’m not locking on to 10 or more satellites. More locks mean better time keeping.
If you are doing this yourself, do yourself a favor and order a real antenna to go with your project.
In addition to being “real”, the cable is 3m long, giving me options on where to place it. And it is a water proof unit.
Leave a Reply