I'm looking for the datasheet of the 16MHz crystal used in the Arduino. It reads 16.000H9H . Especially I am interested in the std accuracy (is it like 100 ppm ??) and the temperature drift.
let us assume we measure something over a long time with several arduinos. to synchronize the data from the 2 arduinos we need a time stamp. maybe one arduino is quite accurate at a constant temperatur of 25 degrees, but maybe the second one is too fast at a higher temp.
and an inaccuracy of just 100 ppm results in an error of 360 ms per hour. in the worst case scenario one arduino goes faster at 100 ppm, the other one slower at 100 ppm, than we have an error of 720 ms per hour which is almost a second....
if we now measure something over 7 days.... you get the point..
by the way. i compared 3 arduinos. the fastest one is compared to the slowest one 50 ms per hour faster....
maybe we need a better crystal, or use a master clock.... depends on the datasheet....
Good question. I don't have a lot of faith that the caps associated with the arduino are properly sized; there's a sort of "standard" to plunk down a crystal with a couple of 18 or 22 pF caps, but apparently if you want to do it RIGHT, it's a bit more complicated than that (and you'd need the crystal data sheet to start with.) OTOH, I've never much cared about higher accuracy than needed to make serial com work, so I haven't been overly motivated to track anything down...
In general, if you want to synchronize multiple CPUs, you have to come up with a solution other than giving them all infinitely-accurate oscillators.
I de-soldered the crystal and replaced it with a socket. Mainly that was so I could swap crystals for certain frequency-dependent circuits. But it also makes it possible to drive the Arduino with an external clock generator although I haven't tried that yet. It would require reprogramming the fuses for external clock input.
To run many Arduinos synchronously it is possible to get a clock out signal from one, which could then be fed into the socket modification above on other boards. There would still be clock drift though, they will just all drift at the same rate.
For synchronising different Arduinos in different places it would need some kind of external reference clock. I guess the easiest way these days is to use a GPS shield. Or a receiver for long wave clock transmissions.
You just run the two arduinos with the same clock-signal, this is not an option over distance though!
Are you sure about those numbers 100ppm?
I saw this here
A ceramic trimmer capacitor can be added to the crystal oscillator circuit to fine tune the crystal frequency and improve accuracy. Or you could implement a soft' trim function instead with much finer control. The soft' trim function simply adds or subtracts one cycle during each 1 msec interrupt for 'n' number of interrupts during each 1 second interval to improve accuracy. I use this method in a clock with a 16 MHz crystal for accuracy to within approximately 1 second per month. Most of that 'drift' is due to temperature drift and crystal aging.
I guess we would have to know the distances between the various Arduinos that you want to keep in sync to make reasonable suggestions.
If they are physically far apart and in possible different ambient temperature environments, then nothing short of TCXO or OCXO clock oscillators for each board comes to mind.
I already tried a lot to get the timing of my Arduino's better. I even went so far to buy a counter and an efratom time reference. By now I got the point: the crystal spec says +/- 100ppm and it will not get any better. You can try to trim it but you will only get it more accurate at the temperature you trimmed it.
If you need more precision you need something with more accurate specs over the desired temperature range.
I know of several options
go for a 32kHz crystal / RTC. These are designed for much better precision, typically +/- 30 ppm.
1b) add temperatur compensation on your own (very tricky)
Go for a VXCO or TXCO. These can be found for not to much money with +/- 1ppm
Go for a time reference. These get better than 1ppb. Used time references can be found at *bay for 50-100 dollars. Search for "efratom"
(1) consumes least power, and (3) consumes incredible amounts of power compared to the Arduino.
One more idea: in Germany you could use DCF 77 to synchronize them. Probably in the US there is something similar. If not so: GPS could be used for synchronization as well.
However both options will only eliminate long term drift. Short term differences will not be fixed by this.
@Ste Hughes: I replaced crystals. This does not really help. You can not get a +/- 100ppm crystal to +/- 10ppm by means of selection. You can only select for some specific environment conditions and a specific time. It may age and may undergo temperature dependendent changes. And if the caps are not finetuned the crystal change won't help as well.
If precision better 10ppm is needed, then the Arduino (without additional means) is not the proper tool.
Its run almost non stop for 8 months. Its presently been running for just over 20 days since it was last restarted - 486 hours as I write this. It has gained just over 4 seconds in that time. Other ones I've tried have varied by more, but all 3 I own are within a second a day. 4 seconds in 20 days is better than 3 ppm.
Pluggy, this may or may not be due to the crystal. My poor experiences may be due to to boardlayout or improper capacities or any other reasons. My whole point is that Arduino is not a reliable timekeeping devies. Sometimes it is but sometimes not. For me this translates to unreliable.
You can not get a +/- 100ppm crystal to +/- 10ppm by means of selection.
You could replace the crystal with a +/-10ppm one; they seem to be available... though it's still probably a silly idea to try to synchronize multiple systems by trying to make sure they all run at the same clock rate...
That's going to work, and it's simple, but it's expensive. Syncing to one of the clocks is more work, and much less expensive. I would broadcast a time stamp from one of them, and have the others track their clock relative to that. Even better would be a time sync pulse to all of them.