[time-nuts] Clock Display on Linux: Update

Adam Space time.isanapp at gmail.com
Thu Dec 9 01:30:57 UTC 2021


Thanks to everyone who responded to my first thread about getting a
good clock display on a Linux system. I want to try out some of those ideas
that give a higher-end accuracy, but in the meantime I've hacked together
some basic stuff in Python that is accurate within a few ms.

The main problem with GUI stuff in Python is that sleep() functions, or
their implementations in various GUI libraries, can definitely not be
trusted. In fact, I tested tkinter's after() function, which functions like
your basic sleep() function in between display updates, and it drifts on
the order of 500ppm (i.e. every two seconds it loses/gains a ms), which is
quite bad.

The key to getting a good clock which is consistently accurate to system
time within as little as 5ms (and therefore if system time is accurate
to +/- 10ms with NTP you have an overall accuracy of 15ms, at worst), is
just to adjust the clock periodically based on the offset from the display
updates to the system time. In other words, every ten seconds or so,
instead of doing sleep(1000), you can just sleep(1000 - offset). (The units
here are ms). This worked for me quite well.

+/- 5ms is quite sufficient for a system which itself is only accurate
within 10ms with NTP. Now, I just need to figure out how to get a good
display going for a higher accuracy device, in particular a PPS-Raspberry
Pi setup I am trying to get working.

I'm sure some people here have done something similar, but I figured I'd
share.

Adam




More information about the Time-nuts_lists.febo.com mailing list