Go Down

Topic: Arduino Clock Speed (Read 1 time) previous topic - next topic

BerndP

Hi, I'm a newby here, but have been playing with Arduino (Uno and Pro Mini), for over a year now.
I've now built my own pcb, with a Uno chip, external crystal (16MHz)....... I programmed it via an Uno that I have. I loaded a simple code, flashing a LED @ 1 Hz, just to test my board. That's when I noticed that my baord, and the Uno board, don't operate at the same "frequency". The flashing will start at the same time, but after some time (60 secs or more), the flashing goes out of sinc. About 1/2 sec after 2-3 mins. I then programmed 5 x Pro Minis, all with the same code. I can get them all to start at the same time, but they "wander" out of sync. I have not changed any switches for Clock calibration (frankly I don't know how?) All the boards run from a single USB port on my pc, so they all get the same 5Vdc. No other items are connected to the boards (no relays/ transistors / motors / sensors / comms /.......)

I have checked my own pcb, and the voltage for the chip is about 4.92 Vdc, post regulator. I have not checked the voltage on the Pro Mini chips, but they all get + 5.0 Volt pre regulator. There is a slight fluctuation as the LED's pulse, about 0.02 Volts, as measured by "good" DMM (Brymen TBM811).

Why do we get this "out of sinc" situation, and how can it be corrected.
I am using Arduino IDE V 1.0, on Windows XP Pro, hp Compaq laptop, if this is important.


Regards,
Bernd

fungus


Why do we get this "out of sinc" situation


The clocks aren't exactly the same speed. Maybe 16.001 mHz...


and how can it be corrected.


a) Get them to communicate
b) Use the same clock for all of them.
No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

tim7

The error you're seeing is roughly 0.3%.  That's not far from the 0.2% error I measured on an Uno a little while ago:
http://arduino.cc/forum/index.php/topic,69316.msg516645.html#msg516645

If your custom board is using a crystal then it's likely to be much more accurate.  My Freetronics "Eleven" (an Uno clone with a crystal in place of the Uno's resonator) is accurate to roughly 40ppm.

If you can tolerate a small amount of drift, then I'd recommend building a second copy of your custom board, or buying something like the Freetronics Eleven.  If you need better precision and can put the microcontrollers close together on the same board then it's possible to run off a single crystal (beware, the second clock is not wired in the same way as the first).

BerndP

Hi All,
Thanks for the replies.
At this stage the timing is not such a great problem, it just seemed odd that identical boards (5 x Pro Mini), just differ so much.
I read thru the other link posted in tim7's reply, and came to the conclusioon that I should check my Circuit again, as I may have erred in my crystal circuit design.
I'll do some more checking and reply again.
Regards

fungus


Hi All,
Thanks for the replies.
At this stage the timing is not such a great problem, it just seemed odd that identical boards (5 x Pro Mini), just differ so much.
I read thru the other link posted in tim7's reply, and came to the conclusioon that I should check my Circuit again, as I may have erred in my crystal circuit design.
I'll do some more checking and reply again.


What's the tolerance of the capacitors in it? Crystals are usually specified with a few decimals of accuracy but the capacitors might be 1% (or worse). 1% of a minute is significant.

Really though...it's not an 'error'. It's just the way things are.

If you needed to synchronize the LEDs you'd have to connect the devices together, there's no way around it. No amount of fiddling with crystals would solve it.

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

BerndP

Hi Fungus,
I'll have to check the caps. One error I made, was to put a 1Meg Resistor between Xtal1/2. I think I must have mis-interperated the circuit diagrams. That goes for my board. It doesn't explain the "errors" on the Minis. As mentioned before, it's not really an issue for me at this stage, it's just odd that there is such a "big" "error".

dhenry

1/2 second out of 2-3min is an error rate of 5000ppm. Crystals are generally 100ppm (worst case scenario) and typically 20ppm.

So there is something seriously wrong with the setup / code.

dc42

A quick look on the Farnell site for 3-terminal 16MHz ceramic resonators of the sort used on the Uno revealed that they have a frequency tolerance of +/- 0.5%. Your home-made board using a crystal will be more accurate than that. So your Uno is running at a frequency about 0.3% different from its nominal 16MHz, which is within the tolerance of the resonator.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

James C4S


That's when I noticed that my baord, and the Uno board, don't operate at the same "frequency".

Use something more accurate than your eyes to compare the frequency of the boards.

Minor differences in the starting point will eventually cause them to appear out of sync.
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Udo Klein

Just in case someone is interested:
I have several experiments on my webpage that investigate the clock deviation issue in detail http://blog.blinkenlight.net/experiments/measurements/crystal-deviations/.
Check out my experiments http://blog.blinkenlight.net

dhenry

From a retail customer's point of view, it is insensical to use a ceramic resonator over a crystal: the saving is inmaterial vs the potential inaccuracy.

Go Up