DS1302 Drift

Hi

I have a DS1302 implementation that is suffering approximately 2 minutes of drift every 24 hours? Always forwards. Consistent across the last four weeks over varying temperatures.

the circuit is a straightforward copy of the datasheet reference circuit.

I don't have tools to measure the accuracy of the clock oscillator - I guess that may be the issue, but I'm concerned that it is so far off the norm. The crystals I am using are 32.768kHz designed for 6pF. or so they say anyway.

I've tried a couple from the batch I have. both showing the same signs. I have not yet tried a second DS1302.

Any thoughts?

I would remove the fixed capacitor and replace it with a variable capacitance trimmer. Then make small nudge adjustments until it works right just like a cheap electric clock.

...or use a better RTC chip like DS3231

What's the tolerance on the crystal? Crystals are typically 100ppm, which if my calculations are correct is about 8 seconds per day. (The tolerance should be worst case and most 100ppm crystals should be better than 100ppm.)

Did the crystals come from a reliable supplier?

Have you read Maxim App Note 58 on crystals for their RTCs?

I replaced the crystal (unknown type) on a DS1307. The DS1307 is very similar to the 1302 but is designed for a 12.5pF crystal. The one I chose has a tolerance of ±10ppm:

It measured 14ppm fast. That's okay but not stellar. I then replaced the RTC with a PCF85263A. That RTC has a register to adjust the internal capacitance. I used this 6pF crystal which has a ±5ppm tolerance:

It measured slow by 4ppm. That's a lot better. In addition, the PCF85263A has a register for software time adjustment, which I set to add 4ppm. It will, of course, still be affected by temperature. But I didn't want to use one of the much larger chips that have built-in TCXOs. The small 8-pin package is nice.

On another chip I found that noise was messing with my clock crystal circuit. Sometimes it would miss an oscillation (32767 in a second) and other times it would get an extra one (32769). I finally ended up bending the pins on the chip and soldering the crystal directly to it. Problem solved.

Here is what the frequency variation with temperature looks like:

edit:
You should also check your current crystal specifications carefully. When I was ordering I discovered what appears to be an error on Mouser's website. They say that this crystal is 12.5pF while the manufacturer part number indicates it is actually a 6.0pF crystal.

jpadie:
I have a DS1302 implementation that is suffering approximately 2 minutes of drift every 24 hours? Always forwards. Consistent across the last four weeks over varying temperatures.

Most likely it is caused by poor board layout and/or nearby noise sources. Oscillators for watch crystals are very sensitive to noise. External noise pulses are counted same way as if they were legal clock pulses, this is why your clock is always forward.

Pay special attention to the ground near DS1302. Small capacitors between the watch crystal and ground should be connected straight to the DS1302 ground pin, nothing else can be connected to that PCB track.

aarg:
...or use a better RTC chip like DS3231

Has anyone bought those from Chinese sellers on eBay? On eBay they are like $2 for 5 of them or $1 each for modules with them already mounted. At Digikey they are $7-$9 each. Any buyers have good luck with the cheap ones? I am working on a design for a VFD clock now and I have decided to use the PCF2129 chip for this design. I don't trust the Chinese sellers and I don't want to pay the Maxim full freight either. The PCF2129 looks nearly as good, the rating is 3ppm (the Maxim part is 2ppm).

The board is very straightforward. Just the chip the crystal and a battery. The connections to the arduino Ethernet board are directly on headers

No caps for this circuit. Although for course the arduino Ethernet board has decoupling caps. The da1302 doesn't need external caps for the crystal.

The air temp goes between 15 and 36 here (south of France).

The crystal could be off. I bought a bundle of them from China. I've tried a few and they all provide the same skip forward.

I'm wondering whether the skip is gradual or stepwise. I will run a script to quert the time and capture it every minute and see where what comes up. Possibly there is an event that causes extra pulses as there are some ssd relays about 10cm away.

The AppNote referenced in the DS1302 datasheet states that nearby pulsed signals will cause the clock to run more quickly.

sure. but there are not any nearby pulsed signals.

10cm away there are some SSDs. there are eight, of which 6 get fired three times per 24hrs. not pulsed but continuous DC signals.

but it must be something like that.

Faraday cage it like the RF cans you see on a lot of RF boards? Maybe fake it with some aluminum foil and see if that helps?

An old trick is a piece of twisted pair wire across the crystal.
Cat-5 twisted is ~0.5pf per cm.
Start with a few cm untill the clock runs slow.
Cut a few mm each time untill it's running accurate.
That doesn't take care of noise and temp drift ofcourse.
Leo..

http://213.114.140.60/begin/gimmik-0.htm

That's a cool trick. I just ordered a bunch of pF caps to trim crystals and was wondering if there was something sneaky like that which would work in a pinch.

But jpadie's RTC isn't just a little off, it's running way too fast. Something is wrong.

I've been running a scan on the board for a few days now some remote code that queries the timeclock every minute.

there are no spikes at all that would indicate that there are stray signals getting in and triggering a clock pulse.

over 7 days the drift has been linear. now 800 seconds of drift from true.

I guess it can only be a crappy crystal.

happy to share the logs if there is interest. at the moment I will just write a routine to update the clock every hour as this particular use case is not so vital that 13 mins of drift over seven days is fatal. but I do need to resolve this longer term as another project requires precision. i guess using a better chip is the answer ....

@Grumpy_mike

I would remove the fixed capacitor and replace it with a variable capacitance trimmer. Then make small nudge adjustments until it works right just like a cheap electric clock.

this chip does not need external caps to drive the crystal.

this chip does not need external caps to drive the crystal.

Doesn't alter the advice though, the cap will pull the frequency.

um ... there is no cap!
or are you suggesting that a trim caps are added on each of the oscillator legs?
If so, I'm not convinced that that is economically more sensible than changing chip to one with an integrated oscillator.

JoeN:
Has anyone bought those from Chinese sellers on eBay? On eBay they are like $2 for 5 of them or $1 each for modules with them already mounted. At Digikey they are $7-$9 each. Any buyers have good luck with the cheap ones? I am working on a design for a VFD clock now and I have decided to use the PCF2129 chip for this design. I don't trust the Chinese sellers and I don't want to pay the Maxim full freight either. The PCF2129 looks nearly as good, the rating is 3ppm (the Maxim part is 2ppm).

Yes, I have bought many on Ebay (but I'm using DS3231's). At least 15 of them now. None of them had any problem, and I never had any problem with payment, shipping, or product quality.

I've bought hundreds of other small devices that way, and the only problems I ever had, was when they shipped the wrong part. I told them and they sent me a new one (didn't have to return the wrong board, so it was free). That, and one Ethernet shield that had terrible soldering. But as far as RTC's go, I've always received top quality merchandise, in nice anti-static bags - to boot.

jboyton:
It measured 14ppm fast. That's okay but not stellar. I then replaced the RTC with a PCF85263A. That RTC has a register to adjust the internal capacitance. I used this 6pF crystal which has a ±5ppm tolerance:

It measured slow by 4ppm. That's a lot better. In addition, the PCF85263A has a register for software time adjustment, which I set to add 4ppm. It will, of course, still be affected by temperature. But I didn't want to use one of the much larger chips that have built-in TCXOs. The small 8-pin package is nice.

@jboyton Did you have a sketch example for the PCF85263A?

thart:
...

Hi Thart,

This is an old thread from a couple years ago. You might get better answers if you just start a new thread, and explain your needs there.

ps, thanks for dredging it up though. Wawa's comment here is the best 'clock-trimming' technique I have come across!