Pages: [1]   Go Down
Author Topic: Arduino Clock Speed  (Read 1343 times)
0 Members and 1 Guest are viewing this topic.
Cape Town, South Africa
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 150
Posts: 5638
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

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

Switzerland
Offline Offline
Sr. Member
****
Karma: 6
Posts: 375
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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).
Logged

Cape Town, South Africa
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 150
Posts: 5638
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Logged

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

Cape Town, South Africa
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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".
Logged

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 227
Posts: 6637
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

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.

Fort Lauderdale, FL
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6144
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.c

0
Offline Offline
Faraday Member
**
Karma: 24
Posts: 3495
20 LEDs are enough
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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/.
Logged

Check out my experiments http://blog.blinkenlight.net

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1]   Go Up
Jump to: