Go Down

Topic: Why 22pf capacitors for crystal oscillator? (Read 39840 times) previous topic - next topic

MicrocontrollerGuy

I'm trying to understand why the Duemilanove reference design uses 22pf capacitors for the crystal oscillator circuit. As far as I know, the crystal is designed for a 20pf load capacitance. The equation for this is:

Cl = ((C1 * C2) / (C1 + C2)) + Cs

Where Cl is load capacitance, C1 and C2 are the capacitor values, and Cs is the stray capacitance of the board.

Assuming we want to use two of the same capacitor value, the equation becomes:

Cl = ((C^2)/(2*C)) + Cs

Solving for C gets:

C = 2(Cl - Cs)

Assuming 5pf to 8pf stray capacitance, that gives us a range of C values from 30pf to 24pf. So why use 22pf capacitors in the design instead of a larger value?  I can think of 4 possible reasons, but I don't know which one is right:

1. My math is wrong.
2. My estimate of stray capacitance is wrong.
3. There is an additional source of stray capacitance that I haven't considered.
4. The value isn't that important for accuracy and 22pf capacitors are the easiest value to find.

Which one of these is the cause of the discrepancy? And if it's #4, can you give some estimate of how much of an error a 22pf capacitor would introduce with a 16Mhz crystal as compared with a 30pf capacitor?

Adding to the confusion, Table 8-3 on page 29 of the ATmega328 datasheet lists the recommended capacitor values as 12pf-22pf. It seems like the only way to use those values would be to select a lower load capacitance for the crystal itself. The lowest load capacitance I can find is 18pf. There were some 10pf crystals, but those would seem to take the value of C below the 12pf limit in the datasheet and they aren't made anymore anyway for RoHS reasons.

Can anyone help to untangle my thought process on this?

mpeuser

#1
Aug 30, 2010, 12:27 am Last Edit: Aug 30, 2010, 01:05 am by mpeuser Reason: 1
Just some ideas:

- The general pin capacitance is given as 10pF in the mega8 datasheet... This is high compared to other modern uControllers.. But it need not neccessarily be the capacitance of the XTAL pins, aw the clock driver circuit differs from other I/O..
- by using the CKOPT fuse, an internal capacitance of 36pF can be added, which is recommended for the 32kHz quartzes..
- cheap caps come in 20% accuracy, so there is little use taking other things but E3 values 10 .. 22 .. 47.
22 fits closest...

Edit: some typos..

Jeff K

I think there was another post about this a day or two ago.  To sum it up, the accuracy of capacitance doesn't really matter.

Also I think 22pF is a common and easily attainable value.
Jeff K - JKDevices.com - home of the MegaMini

RuggedCircuits

Quote
4. The value isn't that important for accuracy and 22pf capacitors are the easiest value to find.


Ding!

The value actually is important for accuracy but accuracy isn't that important to most people that buy an Arduino.

If you *really* want the maximum accuracy for your crystal you have to:

* Design and build the board
* Measure the actual frequency and adjust load capacitance and series resistance (often omitted but theoretically still a factor) until you get the frequency you're looking for

Or, throw 22pF capacitors in there, build 100 boards, note that they all oscillate at approximately 16 MHz and call it good.  If XXX% of the  boards fail to oscillate or in general they're all oscillating too slowly, the capacitance is too high.

--
Check out our new shield: http://www.ruggedcircuits.com/html/gadget_shield.html

davekw7x

#4
Aug 30, 2010, 01:00 am Last Edit: Aug 30, 2010, 06:59 am by davekw7x Reason: 1
From the crystal's point of view, C1 and C2 are in series, so the total that the crystal sees is 11 pF.  Stray capacitance and input capacitance on the pins of the '328p may account for 8-10 pF.  (Maybe a little more; possibly a little less.)

The '328P data sheet says


The optimal value of the capacitors depends on the crystal or
resonator in use, the amount of stray capacitance, and the
electromagnetic noise of the environment. Some initial guidelines for
choosing capacitors for use with crystals are given in Table 8-6 on
page 31
.


The table shows "Recommended Range for C1 and C2" is 12-22 pF.

As an example:
If your crystal is cut for 16.0000 MHz +- 50 ppm for a load 20 pF, you may find that the actual frequency is a little high; maybe a little more than 50 ppm.  If it's important, you can make adjustments by padding small values in parallel with C1 and C2 and can probably get the actual frequency (at a given temperature) to within 10 ppm of nominal.

Here's another thing: It's usually not practical to measure the frequency directly.  You make a test program that uses one of the CPU counter/timers to toggle an output pin at some sub-multiple of the clock frequency and measure that with your high-precision frequency counter.

If the initial frequency is too low, then you might want to replace C1 and C2 by 15 pF caps (or 18 pF) and start again.

But first, you may want to ask yourself how important it is to be dead-nuts on.

Also note that crystals from different vendors may have slightly different characteristics even if they are rated for the same load capacitance, so if precision requirements are really, really important (for mass production), qualifying different vendors might have to be done by you in your lab (not just by reading a data sheet or taking some vendor's word about compatibility with whatever you have previously tested).


In other words, Your Mileage May Vary.


Regards,

Dave

MicrocontrollerGuy

Quote
From the crystal's point of view, C1 and C2 are in series, so the total that the crystal sees is 11 pF.  Stray capacitance and input capacitance on the pins of the '328p may account for 8-10 pF.  (Maybe a little more; possibly a little less.)


Now that makes sense! I didn't realize that the crystal saw the caps as being in series. 2 22pf in series = 11pf...plus 9pf stray capacitance equals 20pf. I want my timing to be accurate to about 1%, which I guess is 10,000 ppm. It sounds like the difference of a few pf isn't going to pull the crystal off by that much.

davekw7x

#6
Aug 30, 2010, 01:43 am Last Edit: Aug 30, 2010, 06:59 am by davekw7x Reason: 1
For 1% accuracy, you can "mail it in." Any values that cause the crystal to oscillate will certainly give a frequency accuracy within a few tens of (or, at worst, a few hundred) parts per million.  If a 16 MHz fundamental crystal won't oscillate with 22 pF load capacitors, I'm thinking it's defective.

So...

In the spirit of "Good Enough" engineering:

"Nothing matters very much, and few things matter at all."
---Arthur James Balfour

I know that "Good Enough" engineering doesn't sound right.  I mean, your mom always told you always to "do the best you can." Right?  Well my mom did.

However, with all due respect to mom:

"If it doesn't matter, it doesn't matter."
---davekw7x

cmiyc

#7
Aug 30, 2010, 02:32 am Last Edit: Aug 30, 2010, 02:32 am by cmiyc Reason: 1
Quote
I know that "Good Enough" engineering doesn't sound right.  I mean, your mom always told you always to "do the best you can."


The pursuit of "Better" is the enemy of "Good Enough."
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

davekw7x

#8
Aug 30, 2010, 05:28 am Last Edit: Aug 30, 2010, 06:55 am by davekw7x Reason: 1
@CMiYC
Quote
The pursuit of "Better"...


With all due respect to the author of that aphorism (as well as my mom), and as much as I like bumper-sticker philosophy:

Engineers always want things not to be "good" or "better."  We want things to be perfect.  All of the time.  Every time.

However...

In the so-called "real world" (where profit or loss depends on getting a product out on schedule and without unnecessary costs in materials or production testing), do you think that it is worthwhile having a test bench in at the end of the production line for the purpose "fine tuning" the oscillator circuit to attain a frequency accuracy of ten parts per million if it has been accepted that 1% is OK?

When I use the phrase "Good Enough engineering," I am not trying to recruit to sloppiness.  I am trying to shock.  And, maybe, even to get people to think.  And, maybe, even to offer rebuttal.  Or not.

My mom might not have accepted the idea of "Good Enough" engineering, but she was certainly aware of the meaning of "gilding the lily."


Regards,

Dave

Footnote:
One definition of the idiom to gild the lily:
"To make superfluous additions to what is already complete."

RuggedCircuits

It has been said that the purpose of an engineering manager is to get the engineers to stop optimizing and just ship the darn product.

--
Check out our new shield: http://www.ruggedcircuits.com/html/gadget_shield.html

davekw7x

#10
Aug 30, 2010, 05:44 am Last Edit: Aug 30, 2010, 05:46 am by davekw7x Reason: 1
@RuggedCircuits
Quote
...stop optimizing and just ship...

Old-timers might remember The Soul of a New Machine that won a Pulitzer for Tracy Kidder 29 years ago.  Whippersnappers might even learn a thing or two from it.  Or not.


Regards,

Dave

Footnote:
Twenty-nine years ago?  Was it really?  Where does the time go?

mpeuser

I read it twice and even gave a copy as a gift to friend... But what did I learn from it????

mpeuser

#12
Aug 30, 2010, 09:45 am Last Edit: Aug 30, 2010, 09:46 am by mpeuser Reason: 1
.. and still nearly OT: I read four threads during the last week , which implicitely had addressed the difference between:
- To what respect can I trust what is printed on the thing?
- How does in behave in the circuit under so-and-so environmental conditions?

The second thing is of overwhelming significance, but most people care (only) for the first. Well, they have to do with one another - a little bit. But a dubious design does not improve through the use of perfect parts.....

pluggy

#13
Aug 30, 2010, 12:14 pm Last Edit: Aug 30, 2010, 12:21 pm by stephen_t Reason: 1
Quote

Old-timers might remember The Soul of a New Machine that won a Pulitzer for Tracy Kidder 29 years ago.  Whippersnappers might even learn a thing or two from it.  Or not.


Regards,

Dave

Footnote:
Twenty-nine years ago?  Was it really?  Where does the time go?


That would be me then ;)  I borrowed it from the Library many years ago. Great book....

On topic again, if higher value capacitors slow down a crystal and they are too high a value in the arduino, why do all my crystal arduinos run fast ? :)

They are all good to within a couple of seconds a day, but they all run on the fast side.
http://pluggy.is-a-geek.com/index.html


Go Up