domschl / RaspberryNtpServer

Stratum-1 time server with Raspberry Pi and GPS
MIT License
88 stars 5 forks source link

Why do we set NMEA reflclock delay to 0.2 in chrony.conf? #13

Closed krytie75 closed 7 months ago

krytie75 commented 7 months ago

Excellent guide, very well written and extremely helpful, thank you.

I'm trying to tweak everything to get the most accurate time on my system and I'm a little confused as to why we include the delay of 0.2 in the following line from chrony.conf:

refclock SHM 0 refid GPS precision 1e-1 offset 0.01 delay 0.2 noselect

Chrony docs describes the 'delay' option as:

delay delay This option sets the NTP delay of the source (in seconds). Half of this value is included in the maximum assumed error which is used in the source selection algorithm. Increasing the delay is useful to avoid having no majority in the source selection or to make it prefer other sources. The default is 1e-9 (1 nanosecond).

Presumably we're not doing this to influence the source selection as we also have 'noselect' defined for this reflock so I was wondering why we include the option and how you arrived at the value 0.2.

domschl commented 7 months ago

You're right that it's probably not needed due to noselect. It's (if I remember correctly) an approximate estimation of the error of the serially transmitted time, which would be around 100-200ms, and by declaring that, it's another way to say: this is a 'bad' source on it's own. So, if you would try to synchronize a clock solely based on the serial connection to the GPS device, that's the order of magnitude of error you would end up with.

In terms of the accuracy of your system: that delay value does not matter! The only thing that needs to be correct is the offset value, which needs to be tuned so that the overall offset between PPS pulse and serial time from GPS is within the required boundary of 200ms (this has nothing to do with 0.2 delay value, it's coincidence that the same value appears).

The quality of the PPS signal (which is directly dependent on the number satellites the GPS receiver 'sees') is the determining factor of the overall precision and accuracy of your system.

krytie75 commented 7 months ago

That's really informative and more or less what I was hoping to hear.

Many thanks.