I have built a couple of arduino based clocks. One used the DS1307 module from Sparkfun and the other the DS3231 (bought from Mouser and mounted on the Sparkfun SOIC-8 to DIP adaptor board). The DS1307 I have is a pretty poor time keeper loosing about 8.5 seconds per day but the DS3231 has only lost 5 seconds per month. Are there other accurate but cheap 8 pin alternatives or suppliers as I need a couple more devices but Mouser charge £12 delivery.
Theoretically the accuracy of the DS1307 would be largely governed by the crystal. I have several around and yes accuracy does vary considerably. Some of mine are decent but I have a couple that are not even within the crystal specs. The DS3231 seriously rocks though. But it is quite a bit pricier.
I've been checking out the Microchip MCP794xx series and they look pretty cool, they have several features that the DS1307 doesn't, including a trimming capability. Of course something similar could be done through software with the DS1307, but it's better to have it done on-chip.
I know it's a 'little overkill' but @ $26.00 a GPS receiver is the BEST available. I bought one just to have a REALLY accurate clock. Ultimate accuracy in America would be the WWVB signal @ 60Khz (Boulder Colorado) using that weird DCF60 time code, takes 3 minutes to get a good signal as the time code and all the rest of the signal repeats once a minute. The 60Khz signal is also deeply affected by sunspots and other low frequency propagation effects (works the best in So. Cal. mornings and evenings at sunrise/set. all I need to do to the data returned from the satellite is correct for my time/date zone. I need to subtract 7 hours and a day, from the data returned from TinyGPS12. Simple quick and accurate.
Doc
NTP works well for me, within a second or so, without even getting fancy trying to factor in network propagation time, etc.
These are very cool too:
http://www.ebay.com/itm/FE-5680A-Rubidium-Atomic-Frequency-Standard-10MHz-out-/280655233263?pt=BI_Cellular_Optical_Television_Test_Equipment&hash=item41585b00ef
as already stated... get a better crystal
You could look at adding a cap to the crystal, variable or fixed.
You could also take the cheap way out and find out how much is lost or gained and adjust the clock by that amount periodically. Add or subtract a second every hour, 12 hours, day, week, month ...
You could do this by directly updating the chip or keep track of the error and adjust the time in the library.
This is actually how it was done in the days of sailing ships. They knew that their time pieces had errors in them. So they would take a reading from the time piece and then adjust the reading. Adding or subtracting so much time per day. They would never change the time of the time piece until they were back in port.
As far as chips. I kind of like the PCF8563. It has most of the features of the DS1307 with an Alarm. The alarm can be used to drive an interrupt and the interrupt can be used wake the processor from a sleep. The chips are will under a dollar in modest volume.
Anything with an external crystal will be suss, I would get an RTC with an internal TCXO, that's the only way to get good accuracy with this sort of technology.
The DS3231 mentioned is such a chip.
Rob
Graynomad:
The DS3231 mentioned is such a chip.
But those things are pricey, about half the cost of an Arduino. I guess if you don't need a lot of them, it is the easy way out.
They are cheap when account for chip, crystal, and time figuring out how inaccurate the 1307 is...
I've used a rtc I think it was an mcp79410, had no problem working with it although it wasn't any more accurate than you are describing, it did have that calibration register which allowed up to +/- 127ppm adjustment which I only played a little with since I bought it more to learn than usefulness
also had an alarm with interupt pin
if you happen to get that I have a library I made for basic functions like reading time, setting time and some others, may be useful to look at
Thanks for all the ideas, after looking at suggested alternative chips datasheets they all use external crystal so put me off. The idea of adjusting DS1307 (and alternatives) accuracy using better crystal, or tweaking chip calibration could be a time consuming job (I had to do it with first DS1307 clock in code and it takes weeks due to temperature fluctuations altering day to day drift).
NTP and GPS time are not really an option due to extra hardware costs and in the case of GPS picking up a signal in the house.
I will just have to suck up the P&P costs and buy some more DS3231 chips from Mouser or the ChronoDot from proto-pic.