Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

DS1307 RTC Accuracy Rate

Saeedk9574

Member level 3
Member level 3
Joined
Nov 6, 2023
Messages
66
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Activity points
484
Hello everyone,
Do you Know, how much the tolerance of ds1307 RTC is per day?
Most importantly, is this time tolerance a fix value or it has random error. Can we fix this problem with code?
 
Hello,
No way to correct the DS1307
.. or Maybe by hardware: to add a litle variable capacitor on Quartz 32Khz ?

i observed a drift of +-2 to +-6mn by month on my old numerical clock.
with delta T°Amb. min=17°C to max= 30°C ) Winter/Summer (without clim!)

you better have to replace it by a DS3231 ...
drift becomes 1mn per 6 months for same delta T°Amb.
+-2 to +-3mn per year...

DS3231 has internal correction ... mainly for temperature effect
 
The DS1307 is absolutely precise, always. It is just a counter circuit, some memory and some glue logic.

Time keeping tolerance is entirely controlled by external components, in particular the crystal. If you can find the crystal specification, the same tolerance will apply to the timekeeping.

Brian.

Edit - Paulfjujo beat me to it, use the DS3231 if possible, it has an internal temperature compensated oscillator. Beware though, if you buy one on a development board (often with an EEPROM fitted as well) they have a battery charging circuit which WILL damage the battery if you run it from 5V. Removing some components will save the battery and it should then last at least 5 years.
 
Last edited:
Hello!

As said above, the clock will vary mostly according to temperature, and you can compensate
with capacitors at the crystal. There are probably methods that you can find on the net.
But prior to that, the question is: what are your specs? What accuracy are you aiming at?

Fixing by code? Yes you can. You have to find a nearby clock which is accurate and synchronize
to it. If your clock is by some way linked to the net, there are time servers. If it's not, there are
satellites / GPS. Will it be enough? I don't know, describe your application better!

Dora.

Most importantly, is this time tolerance a fix value or it has random error. Can we fix this problem with code?
 
  1. Do you have a real prototype problem or just need random advice?
  2. How consistent and accurate is your measurement error? ... vs Temp, time, Vdd.
  3. What are your expectations and requirements? Always use [ppm] for specs.
  4. Do you know how 32kHz XO works in that chip? It is based on a 12.5 pF Xtal.
  5. IRQ and bad coding may cause errors, but let's get your error history 1st.

Here is how a good Swiss Xtal spec looks from www.microcrystal.com

Room temp tolerance has a range of specs and price. Then the thermal effect peaks between 20 and 30 deg C. ( mean wristwatch temperature) then has a negative hyperbolic 2nd order negative coefficient below the peak .

1714708461541.png
 
Hello,
No way to correct the DS1307
.. or Maybe by hardware: to add a litle variable capacitor on Quartz 32Khz ?

i observed a drift of +-2 to +-6mn by month on my old numerical clock.
with delta T°Amb. min=17°C to max= 30°C ) Winter/Summer (without clim!)

you better have to replace it by a DS3231 ...
drift becomes 1mn per 6 months for same delta T°Amb.
+-2 to +-3mn per year...

DS3231 has internal correction ... mainly for temperature effect
DS3231 is much expensive, I need a cheaper one. but I hoped to fix this drift with code
--- Updated ---

For DS1307, accuracy is mainly a matter of crystal quality and correct load capacitor dimensioning.
Thanks I have not added caps to the crystal, maybe I should try it
--- Updated ---

Hello!

As said above, the clock will vary mostly according to temperature, and you can compensate
with capacitors at the crystal. There are probably methods that you can find on the net.
But prior to that, the question is: what are your specs? What accuracy are you aiming at?

Fixing by code? Yes you can. You have to find a nearby clock which is accurate and synchronize
to it. If your clock is by some way linked to the net, there are time servers. If it's not, there are
satellites / GPS. Will it be enough? I don't know, describe your application better!

Dora.
I hoped it would have a fix amount of drift per day or month to compensate that with code. But as it does not have fix drift which it is sometime + and some times -, so it is impossible.
--- Updated ---

  1. Do you have a real prototype problem or just need random advice?
  2. How consistent and accurate is your measurement error? ... vs Temp, time, Vdd.
  3. What are your expectations and requirements? Always use [ppm] for specs.
  4. Do you know how 32kHz XO works in that chip? It is based on a 12.5 pF Xtal.
  5. IRQ and bad coding may cause errors, but let's get your error history 1st.

Here is how a good Swiss Xtal spec looks from www.microcrystal.com

Room temp tolerance has a range of specs and price. Then the thermal effect peaks between 20 and 30 deg C. ( mean wristwatch temperature) then has a negative hyperbolic 2nd order negative coefficient below the peak .

View attachment 190523
I have a good prototype to test the accuracy of the ds1307 timer. I have not used any cap for crystal. So based on your explanation 12.5 pf cap would fix problem to some extent.
 
Last edited:
Thanks I have not added caps to the crystal, maybe I should try it

DS1307 datasheet states:
The internal oscillator circuitry is
designed for operation with a crystal having a specified load capacitance (CL) of 12.5pF.
Means a standard watch crystal designed for this load capacitance should work without additional capacitors.
How much deviation do you actually observe? Does your layout follow the datasheet suggestions?

RTC can be software corrected, but not so simple. Besides synchronization to an internet time server (if available for your application), you can determine a correction factor (+/- x seconds per day) and perform periodic correction. If your code doesn't run continuously, you need to remember last correction time stamp in non-volatile memory.
 
Hi,

if you encounter any inaccuracy ...
Most importantly, is this time tolerance a fix value or it has random error.
I give this question back to you.

* if there it is constantly "too slow", then maybe you have a PCB layout problem causing too high capacitive laod.
* if it is constantly "too fast", then maybe you need to add some capacitors.

* but if the error is random, but mainly "too fast", then maybe noise is the problem.

****
Before curing a symptom, I recommend to investigate for the root problem.

Klaus
 
...and if capacitors are needed you will need ones with the correct temperature coefficients to compensate for the crystal and DS1307 itself. Both will change characteristics with temperature. You will get some improvement by choosing capacitors that work in the opposite sense so they counteract the temperature drift. You will find it far harder to compensate for crystal ageing if you need to be that accurate.

Brian.
 
Hi,

The problem is as old as crystal oscillators.
Thus there are known solutions: Like: TCXO, OCXO, MCXO and others.
(Hopefully you did read articles about crystal oscillators before posting, like: https://en.wikipedia.org/wiki/Crystal_oscillator)

All these solutions mean "extra effort" and thus additional cost.

Many wise men already tried to find "low cost - high accuracy" solutions.

Klaus
 
All the specs to answer you were in this comment, but you were too afraid to ask what you need to understand.
First. How fast or slow is it?
Second How accurate do you need it? Or nice to have. 1ppm is about $5 0.001 ppm is is about a hundred times more unless connected to the web.
What can you afford?

There are about 2.6 million seconds in a month, so when it says below the tolerance is from 20 ppm to 100 ppm, that means at nominal room fix temperature. so 100ppm /2.6million = is almost 4 seconds off per month. If it is too fast, that's good, you can trim it slower with a load cap some like <=5 pF for a few seconds slower per mo. 5 pF is really small.

for 4 ppm.Do you have a real prototype problem or just need random advice?
  1. How consistent and accurate is your measurement error? ... vs Temp, time, Vdd.
  2. What are your expectations and requirements? Always use [ppm] for specs.
  3. Do you know how 32kHz XO works in that chip? It is based on a 12.5 pF Xtal.
  4. IRQ and bad coding may cause errors, but let's get your error history 1st.

Here is how a good Swiss Xtal spec looks from www.microcrystal.com

Room temp tolerance has a range of specs and price. Then the thermal effect peaks between 20 and 30 deg C. ( mean wristwatch temperature) then has a negative hyperbolic 2nd order negative coefficient below the peak .

View attachment 190523
 
100ppm /2.6million = is almost 4 seconds off per month.

2.6million
and 100 ppm = 100 per million = 100/1 million = 100/1000000 = 100/1E6.

so it is 100/1E6 * 2.6 * 10E-6 = 260
so 100ppm equals 260 seconds per month, or 4 minutes and 20 seconds.

Klaus
 
oops of course that is correct.

2.6 million sec/mo * 1ppm = 2.6 seconds / month is what I meant for a conversion factor.

These are tuning fork MEMS and tuning to this nominal error would require a 1~5 pF trim cap. and ultrastable reference counter.
20 ppm is pretty good and requires bin sorting or a trim cap. to null the error.

I forgot the question now. lol.
 
All the specs to answer you were in this comment, but you were too afraid to ask what you need to understand.
First. How fast or slow is it?
Second How accurate do you need it? Or nice to have. 1ppm is about $5 0.001 ppm is is about a hundred times more unless connected to the web.
What can you afford?

There are about 2.6 million seconds in a month, so when it says below the tolerance is from 20 ppm to 100 ppm, that means at nominal room fix temperature. so 100ppm /2.6million = is almost 4 seconds off per month. If it is too fast, that's good, you can trim it slower with a load cap some like <=5 pF for a few seconds slower per mo. 5 pF is really small.
DS1307 approximately is 20 seconds faster than real time per a week.
for the second question, the more accurate the better. If I could decrees this drift to its minimum that would be awesome.
Based on the comments, I should add 12.5 pf caps to the crystal. So I have ordered the caps. However, In my country's market there was not 12.5pf and I ordered 12pf and 15pf to test them.
 
Last edited:
Hi,

you have 604,800 seconds in one week. or 0.6 million.
if you now have 15 seconds per week this will equal to 15/0.6 = 25 (ppm)
(Indeed I expected you to do this simple math .. and compare the value with the XTAL datasheet)

We don`t have the datasheet to compare with. .. Regarding initial error and drift.

I should add 12.5 pf caps to the crystal.
Where do you find this information?
Did you read post#9?

Again: the main question should be: Where does this error come from. Then cure the root cause.

It could be the XTAL ... we don´t have any information about type and manufacturer
It could be the PCB layout .. no information either
It could be noise .. no information either
It could be a thermal problem ... same here

You are free to solve the problems your own way.
In my eyes "trial and error" is not solving. It´s hoping.
Maybe it works, maybe it makes things worse, maybe it works for today, but next day you have the same problem (maybe in opposite direction).

Klaus
 
By adding 15 pf caps to the crystal it showed different behavior but it is not still accurate.
Without 15 pf caps, ds1307 was about 20 seconds faster per week.

Then I made two circuits on bread board by 15pf caps.
After one week one of them was 12 seconds slower and another one was 18 second slower.

Do you have any suggestion or circuit schematic,
How can I decrease this drift of ds1307?

By the way this the circuit of mine before adding 15pf caps.

Screenshot 2024-05-21 100719.png
 
After one week one of them was 12 seconds slower and another one was 18 second slower.

DS1307 has internal caps too. Sounds like you need smaller cap values. The 10 ppm difference between both devices seems to indicate initial crystal tolerances.
 
Hi,

... and a breadboard is not suitable for such a circuit. It´s stray capacitance and stray inductance is too high.
And different (brand) breadboards may give different results.

Indeed I don´t expect higher frequency when adding capacitors. This tells me there is a different problem. (PCB layout, power supply noise, coupled noise, temperature ...)

--> For reliable (test) results you need to keep on the design recommendations of both the DS1307 manufacturer as well as the XTAL manufacturer.

Klaus
 

LaTeX Commands Quick-Menu:

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top