Real Time Clocks
I bought two high accuracy RTC (real time clock) modules and wanted to compare them. RTCs are useful for very low power clocks. They can run for years off of a coin cell battery. Both of these modules are special in they claim higher accuracy than your typical RTC.
First module is based on the DS3231 chip (also has an 4KB eeprom on the i2c bus). Datasheet's specs are 2ppm accuracy within 0C to +40C.
The second module is based on the cheaper PCF2129 chip. It has a 2x3 block of female headers for plugging directly into a Raspberry Pi or compatible board. Datasheet's specs are 3ppm accuracy within -15C to +60C
They are both similar in that they have temperature compensation and a programmable output frequency on a dedicated pin. They also both have a frequency adjustment setting.
The DS3231 can be adjusted in roughly 0.1ppm steps while the PCF2129 can be adjusted in roughly 1ppm steps.
This is a measurement of their short-term (1 week) accuracy. For longer time periods, aging becomes a large factor in accuracy.
To measure their accuracy, I had them both output 1 pulse per second, and compared the intervals with a GPS pulse per second. I measured with a custom stm32f030+TCXO board. The stm32's input capture in use was able to measure each intervals' length with a precision of 40.8 nanoseconds. A simple linear regression was taken over 64 seconds worth of data to compare the RTC's PPS with the GPS's. The frequency difference is given in parts per million units.
First up is the DS3231. Before this data starts, I adjusted the frequency to be closest to 0ppm as possible. After adjusting it once, it was allowed to freely run.
This RTC's performance over this week was -0.038ppm +/-0.085 ppm. This is pretty good. This is around 1 second fast per year.
Second up is the PCF2129. I also adjusted it as close to 0ppm as possible.
The y axis scale is much larger in the PCF2129's graph. And you can see that the frequency jumps around during some hours and other hours it's much smoother. Looking at the frequency vs temperature graph explains what's going on here.
Here you can see that when the temperature is around 69.5F and 75F, the frequency jumps. The datasheet mentions the chip switches in load capacitors based on the temperature. In this way, it can keep the built-in crystal's frequency in a specific range even with temperature changes.
The PCF2129's performance over this week was 0.462ppm +/-0.239 ppm. This is also good. This is around 1 second slow per month.
Because my interval counters have a limited number of channels, the DS3231 and PCF2129 were on different units.
The DS3231 interval counter's internal TCXO frequency looked like this:
The PCF2129 interval counter's internal TCXO frequency looked like this:
Temperature readings were provided by a bme280:
The oscillations in temperature are from the heater turning on/off.
Lastly, comparing the second interval counter's frequency vs temperature, with a simple linear fit:
Pete Stephenson decap'd a DS3231 and posted his pictures: https://blog.heypete.com/2017/07/29/a-look-inside-the-ds3231-real-time-clock/
Edward Mallon has a post about using these RTCs: https://edwardmallon.wordpress.com/2014/05/21/using-a-cheap-3-ds3231-rtc-at24c32-eeprom-from-ebay/
The long term performance of these RTCs will be affected by aging: https://blog.dan.drown.org/tcxo-aging-part-2/