Close
0%
0%

Remarkably Accurate Quartz Clock

Shooting for 10 sec/year accuracy with an ATmega and software-based, temperature-aware frequency correction

Similar projects worth following
Can I use cheap, everyday components and build a quartz clock that beats specialized RTCs and matches the best commercial timepieces? Let's find out!

32kHz quartz crystals typically have a ±20ppm (parts per million) frequency tolerance, which translates to drift potentially in excess of 10 minutes per year. Specialized RTCs like DS3231 promise ±2ppm, or about ±1 minute per year.

RAQC aims for drift below 10 seconds per year. To achieve this, it implements fine-grained frequency correction in software. It has a screen to adjust time with subsecond precision, and it measures the temperature at 10-minute intervals to compensate for dynamic drift. After calibrating repeatedly at incresingly long intervals, RAQC knows the crystal's static error with a 0.01ppm precision.

Energy-saving programming techniques and a low-power LCD display keep the clock's current draw under 15μA, promising 1.5 years of uptime on a CR2032 coin cell.

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 »

  • Calibration & battery update 2023-04-25

    Gabor05/17/2023 at 14:36 0 comments

    It's been 3 weeks since the last calibration. Clock is about 0.2 sec late (a subjective estimate, holding clock side-by-side with time.is). Drift not large enough for recalibration yet.

    Battery is at 3.006V.

  • Calibration & battery update 2023-04-25

    Gabor04/25/2023 at 10:28 0 comments

    I last calibrated the clock 34 days ago. Today it was about 0.4 sec late, which would translate into under 5 seconds per year. Battery in this time frame went from 3.092V to 3.009V.

View all 2 project logs

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates