Go Down

Topic: Crystal vs. Resonator (Arduino Uno) (Read 21197 times) previous topic - next topic

jkenny23

Hi all, I'm a third year EE student at Cal Poly San Luis Obispo, and I've owned an Arduino Uno for a few months now, and I've got a suggestion for the next revision, with some evidence to support it.

I would like to suggest that the 16MHz ceramic resonator used to clock the ATmega328P be removed, and replaced with a cuttable solder jumper to the ATmega8U's CLK0 (Clock Output) pin.

For precise timing, such as running real time clocks and waveform generation applications, it is desirable to use a clock reference with the highest available accuracy. Typically crystal oscillators are selected for a good balance between accuracy and cost.

Here is a comparison between the 16MHz resonator and 16MHz crystal on the Arduino Uno:


As you can see, the resonator has a stable frequency of 15.9331MHz, a -0.42% difference, as well as a jitter of about 7ns over a 30s period, 1ms from the trigger. The crystal oscillator has a stable frequency of 16.0000MHz (as well as my Rigol scope's frequency counter can tell) and a jitter of about 4ns for the same conditions.

Assuming a +/-30ppm frequency tolerance for the crystal, a clock based on such a crystal would be accurate to within about 1 minute and 19 seconds per month. For the resonator, however, such a clock would be off by 3 hours and 3 minutes by the end of the month.

Thankfully, the fix (to my knowledge) seems fairly simple. The ATmega8U (as well as most AVR microcontrollers) have a clock output fuse which can output a buffered version of the input clock on one of the pins, in this case, PC7.


(p.77 in the ATmega8U datasheet)

(p.35 in the ATmega8U datasheet)

So all that is needed is to set the corresponding fuses on both devices, and route a trace from the ATmega8U to the ATmega328P. The end-user would still have the option of cutting the trace and installing a different frequency crystal or resonator to their liking, but this change saves on the part count and provides a much more accurate default clock source for the microcontroller.


(p.35 in the ATmega328P datasheet)

Granted, this is all through the eyes of a hardware engineer, so there may be specific software considerations that are preventing this from being possible, but to me, this seems the obvious solution.

Finally, I have attached the modified board (I tried to make as little changes as possible to the rest of the board, although I had to shift around a few traces, it still passes the DRC file I commonly use).

graynomad

I often wondered why they didn't make use of the free (and more accurate) clock from the 8U but never even bothered to look and see if it was available.

Maybe that big chunky 16MHz signal running half way across the board would be an issue for EME certification.
_______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

mowcius


I often wondered why they didn't make use of the free (and more accurate) clock from the 8U but never even bothered to look and see if it was available.

I hadn't thought of that before to be honest - an interesting idea for sure!

EME? EMC?
I wouldn't have thought there'd be any issues but presumably any issues could be resolved.

graynomad

Quote
any issues could be resolved.

Yep, I doubt they'd be the first with a clock signal running around a board.

EME => ElectroMagnetic Emissions.

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

Coding Badly

As an added bonus that would free PB7 for other uses.

rbtying

Based on what I remember, the resonator was added because using the same clock source for the 8U2 and the main CPU would cause the Arduino to fail the FCC specifications. 

mowcius


Quote
any issues could be resolved.

Yep, I doubt they'd be the first with a clock signal running around a board.

EME => ElectroMagnetic Emissions.

Ahh I see - yeah that comes under the EMC regulations (Electro-magnetic Compatibility)

ozmo

FCC issues aside, if a design were to be made where the 328p also used the 8u's crystal, is there any advantage to taking the crystal's output from the 8u2's PC7 pin, rather than directly from the crystal output pin?

My first guess would be that the output wouldn't be enough to drive two clock inputs at once, and that you couldn't just connect XTAL1 outputs to the same terminal of the same crystal. But then I looked through a couple random 16 MHz crystal datasheets, and they seem to have a wide tolerance for different drive levels. And the output shouldn't be affected much, since the whole purpose is to act as a filtering resonator and only produce whatever frequency it's rated for.

Any thoughts? Like the OP, i'm also taking a closer look at various components on the Uno board as an exercise for understanding circuit design better.

graynomad

Quote
is there any advantage to taking the crystal's output from the 8u2's PC7 pin, rather than directly from the crystal output pin?

I would think so, that's what it's designed for AFAIK. The normal 328 data sheet calls it a "buffered clock output", so it should drive heaps of stuff. I don't have an 8u2 data sheet but see no reason they would be different in this respect.

Quote
My first guess would be that the output wouldn't be enough to drive two clock inputs at once

It would only be driving one wouldn't it? The main processor. And anyway as I said, it's supposed to be buffered.

Quote
you couldn't just connect XTAL1 outputs to the same terminal of the same crystal.

I wouldn't bet on that working but it might. The output of an oscillator is normally just the output of an inverter, however unlike normal inverters it's probably not designed to drive extra stuff but it still might work. Even if it did I think though that this would be a flaky design.

______
Rob

Rob Gray aka the GRAYnomad www.robgray.com

pluggy

Come back, Duemilanove, all is forgiven..........
http://pluggy.is-a-geek.com/index.html

ggs91

Does anyone have a specification for the frequency accuracy of the resonator used on the Uno?

On the two boards I have, I'm measuring about the same error -- in the range of -0.5%, or 5000 parts per million. I'm wondering what I could expect, statistically, from a number of boards.

ggs


ericthemantis

Old thread, but unanswered question. From what I saw on Sparkfun, their ceramic resonators are +/-.5%, which would match what you were seeing on your two boards. Not sure why the 8u2 gets crystal and the 328p gets ceramic. Doesn't make sense to me. The difference in cost would only be a few cents for an extra cap, right?

pjrc

Come back, Duemilanove, all is forgiven..........
Somehow I suspect many people will never forgive FTDI for recent anti-counterfeit measures.

CrossRoads

I suspect 8U2 gets a crystal to support the high speed USB clock rate.

I have no problem continuing to use FTDI Modules from reputable suppliers.  Folks buying cheap stuff from e-bay may continue to have problems with counterfeit parts.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

CrossRoads

Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Go Up