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.
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 long term performance (in this environment) 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 long term performance (in this environment) 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: