Remarkably Accurate Quartz Clock Is Remarkably Accurate

Low-cost components and clever programming rival expensive RTCs.

James Lewis
11 months agoClocks

There are various solutions to keep track of time in a circuit. Real-time clock (RTC) variations include size, accuracy, power consumption, and cost. RTCs with more accuracy or lower power consumption are generally the most expensive. As an experiment, programmer Gábor Ugray wanted to see if a cheap quartz crystal-based circuit powered by a CR2032 coin cell could make a remarkably accurate clock — and it can!

RAQC keeps accurate time using relatively cheap components. A simple 32.768 kHz quartz crystal drives an 8-bit Microchip ATmega88V microcontroller. A numeric LCD shows the current time. The circuits draw about 15 microamps between sleep and active modes on average. Ugray calculates a projected 1.5-year life with a 200 mAh CR2032 coin cell battery!

Typically the tolerance of a quartz crystal, like the one in RAQC, is ±20 parts per million (ppm.) With some math, that works out to be minutes per year. Comparably, compensated RTCs like the DS3231 vary about one minute per year (across their rated temperature range.) They also cost several dollars per unit!

With some baseline targets, Ugray determined how to achieve accuracy without cost. The solution is error correction.

First, you need a method to compensate for the actual frequency of the crystal. While the nominal frequency is 32.768 kHz, there are manufacturing variations. Over a year, this variation will cause some noticeable drift. But this is a static correction.

On the other hand, temperature causes a dynamic variation. As a crystal's temperature varies from room temperature, so does its frequency. So, RAQC's firmware uses multiple temperature measurements to calculate an offset based on the ambient temperature.

Last, Ugray implemented a clever feature to adjust the current time with sub-second precision. Instead of tapping buttons at the exact right time, RAQC's user interface lets you change an offset. The idea is that you can use a highly accurate reference time to adjust the time over a long period.

Ugray is still determining the accuracy. But of course, that will require more time!

Until then, you can find the KiCad schematic, PCB design, Gerbers, and code in RAQC's GitHub repository. For a detailed explanation, check out this project write-up.

James Lewis
Electronics enthusiast, Bald Engineer, and freelance content creator. AddOhms on YouTube. KN6FGY.
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles