An experiment in accurate timekeeping
In late 2022 ZeptoBars shared an approach in the Sensor Watch community to boost that watch's accuracy through fine calibration and dithered error correction in software. This triggered my curiosity: can I reduce the approach to the bare minimum and build an exceptionally accurate clock using only ordinary components? Here is the result: a clock implemented in 8KB of firmware on an ATmega88V with a 60-cent quartz crystal. The clock is ticking and the experiment is in progress! The CR2032 coin cell battery should power it long enough for us to see how many seconds the clock drifts in a year, with room to spare.
The full source code, schematic, PCB and laser cutter design files are available in the Github repository. Some WIP threads from Mastodon are here and here.
User interface
Just like any old quartz clock, RAQC's user interface consists of a simple LCD display and a few buttons. In its default mode, when it's showing the current time, it looks like this:
The clock has a set of screens that you can navigate with short and long presses of the MODE button. The settings screens use the UP and DOWN buttons to change values.
Fine-tuning and calibrating
What makes RAQC different from a conventional digital clock is that you can set the time with sub-second precision without the need for good reflexes. Every time you you calibrate this way, RAQC updates the calculated error of its quartz crystal and becomes more accurate.
Here's how to calibrate the clock:
- When you first insert a battery and start the clock, set the current time the usual way on the Set hours, Set minutes and Seconds to 0 screens.
- Then go to the Adjust seconds screen and fine-tune using the method explained below. Long-press DOWN on the Delta error screen to apply the change.
- Wait one or two days, until the clock drifts by up to a few seconds. Go to Adjust seconds and fine-tune. Long-press UP to apply the change and also update the calculated error.
- The clock is now a lot more accurate. Wait a week or two until it drifts by up to a few seconds again. Repeat the previous calibration step. Wait a month or two and re-calibrate.
- Verify the time every once in a while and repeat when the drift becomes noticeable. As the crystal ages, particularly in the first year, it is likely to become slower by about 1ppm per year. You might need to re-calibrate once or twice a year to compensate for this.
Precisely adjusting seconds
To fine-tune the time on RAQC, you need an accurate reference clock that shows seconds updating in real time. The clock on your laptop or cell phone is not good for this purpose, and neither is the time displayed by most websites. All of these update their time regularly so they're never off by a lot, but they're unlikely to be very accurate at any one moment.
Reliable sources of time are specialized websites like time.is; devices that take their time from a GPS signal; or radio clocks that show the time from a long-wave signal like DCF77. The most straightforward of these is time.is.
The photo above shows RAQC's Adjust seconds screen. (The photo was taken at the prototype stage, but this works exactly the same in the final build.) "40" on the right is the current seconds value; it keeps ticking in real time. The value to the left of the dot, -4, is the current adjustment. In the background you can see a part of time.is in a browser window, showing the true seconds value of "39". RAQC's time is a bit ahead of the truth, so we want to turn it back a little.
The adjustment value, which you can change using UP and DOWN, is in multiples of 1/32 seconds (31.25 milliseconds). A value of -4 means we're turning back the clock by 125 milliseconds.
Don't worry about the specific numbers you see here. Just keep adjusting up and down until the seconds on your clock and the seconds from time.is are ticking in perfect synchrony. Then press MODE twice to go to the Delta error screen. There, store...
Read more »