Electronic – How to improve I2C RTC accuracy

clocki2cmicrocontrollerrtc

I´m using a PCF 8583 I2C RTC for one of my projects (i´m not a professional, just an amateur). The clock delays about an hour per day, which I find unacceptable.

I´m using a 32768 Hz, 12.5 pf, 50 Kohm crystal with the RTC. Acording to the datasheet, the capacitance is OK (5 min, 20 max, 10 typical), but the resistance is a bit high. They don´t provide minimum nor typical values for that, but state a maximum 40 Kohm for the crystal.

Can this be the cause?

I personally think something else must be wrong. I used the same components and program code for another project, and it is not as bad as this one (it also delays, but about 3 minutes per day).

My last effort was to add a wire connecting the crystal package to ground. It improved, but not enough.

Any thoughts on how to improve accuracy?

Best Answer

3 min per day is:

$$ 24\cdot60= 1440min$$

$$ \frac {3}{1440}= 2083ppm$$

Your Xtal is more than 2000ppm off its nominal frequency. Even here there is an issue. But 3 hours per day is more than 4% ! There is a design issue here. For sure.

The Xtal frequency depends on the load capacitance and this is the common root cause of a wrong frequency.

Are you sure you computed your C1 and C2 correctly? The formula is:

$$ C_L = \frac {C_1 C_2}{C_1+C_2}+C_{stray} $$

With

  • CL = the load capacitance given by the manufacturer
  • C1 and C2 = The added capacitors on the xtal pins
  • Cstray = the stray capacitance of the tracks, pins etc...

If you have access to a spectrum analyzer, you may measure the frequency of the xtal using a near field probe (don't touch the xtal tracks with a probe, it changes the capacitance and thus the frequency) and adjust the load capacitors to get the correct frequency.

EDIT:

In the PCF8583 datasheet of NXP: "Chapter 11.1 Quartz frequency adjustment". It is explained here that you should add an external capacitor to your Xtal to fine tune the frequency.