Inaccurate DS1307

Right, changed the crystal last night, and so far with around 20hours use it's accuracy is better than 1 second against the 40+ seconds for the other crystal. So looks like I have one faulty crystal.

Thanks all :slight_smile:

I have this ds1307 module from sparkfun:

It is wired in that way:
5V --- 5V
GND --- GND
SQW --- (not connected)
SCL --- analog pin 5
SDA --- analog pin 4
(without pull up resistances).

I set up it with real time yesterday, and it was running for 24 hours disconnected form the arduino duemilanove. I connected it again some minutes ago. It have about 6 seconds in difference respect to the time of my control clock (my laptop clock).

I will setup it again and check for other 24 hours to see if this is a regular problem...

If not, any idea about how to made it more accurate?

As for running fast I haven't left my set up on long term yet so I'm not sure if I see the same issue. I'll try and remember to leave it running tonight and see what happens.

I've just got around to checking this. I've powered up my arduino board and the error is less than a minute after leaving it for at least a week. I can't remember how accurately I had it set to begin with but any error seems to be small.

Replace that cheap crystal with a DS32kHz 32.768kHz Temperature-Compensated Crystal Oscillator.

Or maybe just buy a higher quality/better matched crystal.

-j

Ooooh, at 10x the price plus postage, I think I'll give it a miss for now unless I have a need for super accuracy in the future, but thanks for the info. At the moment this second crystal seems to be running at better than 1 second a day which is much better and good enough for me. :slight_smile:

I don't know if this is your issue, but the DS1307 data sheet specifies that exactly how you position the crystal next to the IC is very important too.

I have my crystal right next to the IC as they indicate, and my timing is spot on. I also don't use pull-ups in my application.

For fun, I may put the crystal on some long leads and see what I can do with it...

Thanks for the comments.

I have the ds1307 unplugged from the arduino, just powered with its own battery. I connected it for setup the date and time, unplugged and wired again just only to see how is its accuracy reading it with a simple sketch.

I will test it tomorrow to see if it still have this big error.

So may be Spinlock you are right, and the ds1307 retain a better accuracy when it is working wired to arduino. And the battery remain the date although with a low accurary just in case of lost of power in the arduino.

I will check tomorrow and test also connected to arduino for one day.
Cheers!

I saw that too on the datasheet. I've got the crystal plugged in as close as I physically can to the DS1307. I also tried grounding the crystal casing, but it didn't make a difference.

There is one other crystal specification listed in the Dallas datasheet -- ESR.
Do you know the ESR (effective series resistance) of the crystal? The 1307
states you should have a maximum ESR of 45KOhms. I am not sure the ESR
of your crystal but I have seen a number of crystals that have higher ESR.

(* jcl *)


www: http://www.wiblocks.com
twitter: http://twitter.com/wiblocks
blog: http://luciani.org

OK, how do I find that out - without a datasheet for the crystal? I've tried to test it with my multi-meter, but it seems to show open circuit with the crystal unconnected to anything. Is there a way I can try and read the ESR?

You would need the datasheet for the crystal.

This could be a half-baked idea -- if you set the DS1307 square wave
output to 32768Hz this should output the crystal frequency 1:1. You could
measure the frequency with an oscilloscope (or another Arduino). Any deviation
from 32768 would affect the time keeping accuracy.

(* jcl *)


www: http://www.wiblocks.com
twitter: http://twitter.com/wiblocks
blog: http://luciani.org

Dallas also recommends a separate ground plane for the xtal and related IC pins. Check the datasheet for details.

-j

@jluciani
Unfortunately I neither have access to an oscilloscope nor another Arduino, so testing the output would be hard. To be honest I'm not experienced enough at the moment to do that measurement with an Arduino anyway.

@kg4wsv
I'm very green with regards to electronics at the moment, so if grounding the body of the crystal isn't sufficient to achieve the 'ground plane' then can you point me at a resource so I can learn how to do this correctly.

I've just found a datasheet for the crystal, it has an ESR of 35kOhm, so it should be within tolerance.

Looking at the Frequency Range table it looks like 45K. It does not say whether the values are typical or maximum specifications.

Also mentioned in the datasheet is a special crystal "specifically designed for the Dallas
RTC". Did you get the standard crystal or the special one?

(* jcl *)

I forgot to add the crystals that I like to use with the Dallas/Maxim chips are the
Citizen CFS series. These are specified for a maximum ESR of 35K
(as long as you use a 3x8 or 2x6).

My board is at Loading...

(* jcl *)


www: http://www.wiblocks.com
twitter: http://twitter.com/wiblocks
blog: http://luciani.org

Yeah, on re-reading the datasheet I see that it has an ESR of 35kOhm @32.768kHz..

I have no idea. I have the one linked in the original post, but there is no indication if it's specifically for the RTC or not. However, there are only a very limited range of crystals from that supplier, and I suspect that it's the general one. It's handy for me to use CPC (part of the Farnell group) as they have a warehouse outlet next door to where I work.

All the indications at the moment are that the second crystal is working just fine, it appears that the first one may just be faulty.

Crystals are, er, crystal (quartz crystal), and subject to damage from shock. If it got dropped on a tile or concrete floor, it could be damaged.

A specific crystal ground plane would be something for a custom PCB design.

-j

I have SparFuns pre assembled and mine is of by 6 sec/day, will get a new crystal to see if this one is damaged.
Else i will get a DS3231, both cheaper and has a temp compensation.