Choosing a Crystal for a Microcontroller
Electronics Forum Index Electronics
Circuits, theory, electrons and discussions.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web ElectronicsHelp.net
Choosing a Crystal for a Microcontroller
Goto page Previous  1, 2, 3, 4, 5  Next
 
Post new topic   Reply to topic    Electronics Forum Index -> Design
Author Message
John Larkin
Guest





Posted: Tue Feb 08, 2005 10:25 pm    Post subject: Re: Choosing a Crystal for a Microcontroller Reply with quote

On Tue, 08 Feb 2005 07:20:10 +0000, Pooh Bear
<rabbitsfriendsandrelations@hotmail.com> wrote:

Quote:

John Larkin wrote:

On Tue, 08 Feb 2005 01:23:15 GMT, "Chris Graham" <chrisgr@shaw.ca
wrote:

I'm not clear on what the considerations are for choosing a crystal. I've
looked at electronics reference books and web sites but can't find a clear
answer. I know which microcontroller I want to use (in this case an
ATMEGA8). I also know the frequency (16 mhz).

How would I select a compatible crystal based on factors like the load
capacitance and ESR (equivalent series resistance)?

I this case I need to select the smallest surface mount crystal that will
work. Maybe a Citizen CS10?

Also, how would I determine the capacitors to use with the crystal?

Thanks.

Unless it's for volume production and cost is critical, just use a
surface-mount oscillator. You can have a lot of trouble with uP
on-board oscillator circuit.

Really ?

Would you mind elaborating on that please ?


Well, since you asked so politely...

When you buy an oscillator, it most always oscillates. The mfr makes
the quartz and the circuit and builds millions of them.

When you hang a crystal and a couple of caps on a uC, you have,
generally, a mediocre oscillator circuit that may or may not be happy
with the crystal parasitic C and series R, and you may or may not have
the right caps for the situation. If you really know and understand
all the params, and have the time for serious loop analysis, you can
get it right. If not, you can have all sorts of interesting problems
when the breadboard hits production, and to get stable oscillation you
may wind up spending a great deal of time and pushing the xtal 50 PPM
in the wrong direction or something. And TC is anybody's guess.

Quote:
Low cost uCs even have internal RC oscillators that can be programmed via the
SFRs ( special function registers ) to avoid the need for an external
oscillator source to avoid the cost of *even* a resonator - never mind a
crystal these days. Saves a few pins for I/O too btw !

I don't advocate buying an oscillator if the uP already has one
inside. Unless you care about accuracy.

Quote:
I've *never* had a problem with an uC oscillator circuit except when my
so-called *colleagues* decided not to introduce a 33pF cap into stores and
substituted a 22pF cap instead. It worked fine for about 3 yrs until we got a
batch of 'fussy' crystals' !

Crystals can be fussy; that's the point.


Quote:
Oh - how we laughed ! At least I did - at their infantile stupidity.

Great fun, having stupid infants as co-workers. If your company went
under, I bet that would be even funnier.

I don't have your sense of humor. I like my employees and want
everything to work.

John

Back to top
John Larkin
Guest





Posted: Tue Feb 08, 2005 10:30 pm    Post subject: Re: Choosing a Crystal for a Microcontroller Reply with quote

On Tue, 08 Feb 2005 07:04:40 +0000, Pooh Bear
<rabbitsfriendsandrelations@hotmail.com> wrote:

Quote:
Chris Graham wrote:

I'm not clear on what the considerations are for choosing a crystal. I've
looked at electronics reference books and web sites but can't find a clear
answer. I know which microcontroller I want to use (in this case an
ATMEGA8). I also know the frequency (16 mhz).

How would I select a compatible crystal based on factors like the load
capacitance and ESR (equivalent series resistance)?

I this case I need to select the smallest surface mount crystal that will
work. Maybe a Citizen CS10?

Also, how would I determine the capacitors to use with the crystal?

How may times have we seen this question ?

*Read the damn data sheet for God's sake !*

Normally the uC manufacturer suggests a value for both Cs.

Namely what worked for them with the crystal they bought somewhere.
They probably had an intern figure this out, as all the interesting
problems are digital.


Quote:
Unusually that may
be be required to be changed to suit an unusual crystal.


After the first couple hundred units in the field refuse to start up
when it's cold.

Quote:
Try around 20 - 30
pF. That's usually fine for 16MHz. I use 33 pF for an 80C52 based design @ 16
MHz.


Try various caps and crystals til you find a combination that works.
Then build a few thousand to see if it's reliable.

John
Back to top
John Larkin
Guest





Posted: Tue Feb 08, 2005 10:39 pm    Post subject: Re: Choosing a Crystal for a Microcontroller Reply with quote

On Tue, 8 Feb 2005 11:13:23 -0500, "Dave VanHorn"
<dvanhorn@dvanhorn.org> wrote:

Quote:

Seriously though, IMO the crystal manufacturer knows more about what
caps to use than the datasheet does. The goal is to get the thing to
start reliably and to oscillate within specs. Only the crystal
manufacturer knows how they ground the crystal. Isn't anyone going to
mention series vs. parallel? (:-)

I'm always amazed at the number of people who think this is so damned
difficult to pick two caps, that you should buy a canned oscillator..

The crystal will probably "run" with any reasonable value of cap, somewhere
close to it's loading spec. Indeed, most people seem to pick caps that are
about half what they should be, yet they still "run".

In order to do it right though, you need to estimate your parasitics,
(5pF-ish?) then double the loading spec, and subtract the parasitics.
Populate with that, and check oscillation. I use a good shortwave receiver,
as it does not load the circuit at all. Of course you can do a timing loop
and attach a freq counter there, or whatever else works for the equipment
you have.

Of course nobody would use a series crystal in a parallel circuit, you'd
never be able to get it to sing the right tune! :)

There is a stability check that you should make, so on your protos, add a
resistor between the osc out pin and the crystal, so you can make the test
easily. In production you can zero it, or remove it entirely, as long as you
don't overdrive the crystal.





Seems to me you have presented some great arguments for buying a
complete oscillator for about 50 cents more.

John

Back to top
Rich Webb
Guest





Posted: Wed Feb 09, 2005 6:45 am    Post subject: Re: Choosing a Crystal for a Microcontroller Reply with quote

On Tue, 08 Feb 2005 16:04:09 GMT, "Chris Graham" <chrisgr@shaw.ca>
wrote:

Quote:
Fred Bloggs wrote:

Are you that "Ian Bell" thing?


Something like that. Actually I was design lead and software architect for
Microsoft Excel.

Ahh! The flight simulator easter egg...

--
Rich Webb Norfolk, VA
Back to top
Rich Grise
Guest





Posted: Wed Feb 09, 2005 6:54 am    Post subject: Re: Choosing a Crystal for a Microcontroller Reply with quote

On Tue, 08 Feb 2005 07:06:41 +0000, Pooh Bear wrote:

Quote:

Chris Graham wrote:

I did look in the Atmel data sheet. It gives a range of capacitor values
for each frequency. It doesn't mention the crystal "load capacitance" or
ESR.

Atmels' data sheets are a model of clarity.

If you are incapable of reading one and finding the answer, I suggest a new
career in manageemnt where your skills will be appreciated.


But, the facts are, Atmel's data sheet doesn't mention crystal load
capacitance or ESR, and it does give a range of capacitor values for each
frequency.

Chris Graham simply didn't know how to look up a crystal and relate its
load capacitance to the two caps in the diagram in the DS, and even
looking up a crystal, he's presented with a range of values. How to pick
one? What's a fellow to do?

You can't really fault a programmer for not having experience in
electronics components.

It'd be akin to faulting you for not having a neck like a giraffe. ;-)

Thanks,
Rich
Back to top
Rich Grise
Guest





Posted: Wed Feb 09, 2005 7:01 am    Post subject: Re: Choosing a Crystal for a Microcontroller Reply with quote

On Tue, 08 Feb 2005 12:50:38 +0100, Anders F wrote:

Quote:
"Rich Grise" <richgrise@example.net> wrote in message
news:pan.2005.02.08.05.09.03.310144@example.net...
On Tue, 08 Feb 2005 02:43:14 +0000, Chris Graham wrote:
Can I just pick any crystal and be assured that it will oscillate with
the
approproate capacitors, which I should choose by trial and error?

Pick a crystal you like for freq. and package. The data sheet gives a load
capacitance. Use two capacitors the way they have them in the data sheet;
one on each side of the crystal, with the other ends of both caps
grounded.
The _series_ combination of those two caps should equal that load
capacitance from the crystal spec.

Actually pin/package capacitance of the microcontroller should be counted in
as well. Some micros (MSP430 ie.) even has enough load for low cap xtals...
However this is not a current Atmel feature.

Actually, I thought of this an ohnosecond after sending, and rationalized,
"ah, heck - 33 instead of 36 takes out 3 pf of strays each, right?" ;-)

Quote:
For example, if the crystal load
capacitance is 18 pF, two 36 pF caps in series give that result. 33 pF is
the closest common value, and that'll be close enough.
Ordinary ceramics
are fine; I think in that size range the stable ones aren't that much more
expensive.

Good Luck!

Not that he'll need it of course ;-)

Well, I don't know. He's admitted he's been touched by the Shadows - we
might have to kill him just on GPs. ;-)

Cheers!
Rich
Back to top
Rich Grise
Guest





Posted: Wed Feb 09, 2005 7:23 am    Post subject: Re: Choosing a Crystal for a Microcontroller Reply with quote

On Tue, 08 Feb 2005 11:17:13 +0000, Anthony Fremont wrote:

Quote:

"Rich Grise" <richgrise@example.net> wrote in message

Well, according to the data sheet,
http://www.atmel.com/dyn/resources/prod_documents/doc2486.pdf
it's just the standard uP crystal hook-up. If you take a crystal like
the Digi-Key 535-9103-1-ND, under "ABM3 Series 5.0 x 3.2 SMD
Crystals",
http://dkc3.digikey.com/PDF/T051/0747-0748.pdf
you'l lsee that the recommended load capacitance is 18 pF. This is the
series combination of the two caps in the Atmel data sheet, so they'd
be
36 pf, but 33 pf each should be close enough.

Should I bill you by paypal for my consulting fee? ;-)

Not until you remember to include the 5pF of pin capacitance. ;-)

Seriously though, IMO the crystal manufacturer knows more about what
caps to use than the datasheet does. The goal is to get the thing to
start reliably and to oscillate within specs. Only the crystal
manufacturer knows how they ground the crystal. Isn't anyone going to
mention series vs. parallel? (:-)

You use the series capacitance, even though the crystal is probably
running in parallel mode. ;-) ;-)

I was curious about tempco, and realized while studying the X7R graph,
Hey! These caps aren't the freq. determining thing here, are they? You
just want the crystal to oscillate pretty close to home. ;-)

Interestingly, Digi-key has 33 pF NP0s in 0201 at $0.63, but in 0402
they're $0.28. What????? 0.6 millimeter by 0.3 millimeter??? That's
like, the size of a grain of sand! =:-O

Thanks,
Rich
Back to top
John Larkin
Guest





Posted: Wed Feb 09, 2005 7:29 am    Post subject: Re: Choosing a Crystal for a Microcontroller Reply with quote

On Mon, 7 Feb 2005 23:49:02 -0500, "Dave VanHorn"
<dvanhorn@dvanhorn.org> wrote:

Quote:

Also, how would I determine the capacitors to use with the crystal?

---
Look in the µC data sheet


Arrgghh..
The crystal manufacturers would disagree. The caps are selected, in order
to load the crystal to it's design value, taking into account the parasitics
in the circuit.



The caps perform two functions:

1. Get the crystal to its spec'd resonant frequency

2. Generate the right gain and phase shift around the loop to
guarantee reliable startup and oscillation.

The phase shift also depends on the time delay and output impedance of
the cmos buffer inside the chip. That has potentially different
small-signal and large-signal gain and Zout.

It is always tricky having a single part or two whose values affect
two or more different, important circuit parameters. Sometimes you
can't make everybody happy.

John
Back to top
Terry Given
Guest





Posted: Wed Feb 09, 2005 7:46 am    Post subject: Re: Choosing a Crystal for a Microcontroller Reply with quote

John Larkin wrote:
Quote:
On Tue, 08 Feb 2005 07:04:40 +0000, Pooh Bear
rabbitsfriendsandrelations@hotmail.com> wrote:


Chris Graham wrote:


I'm not clear on what the considerations are for choosing a crystal. I've
looked at electronics reference books and web sites but can't find a clear
answer. I know which microcontroller I want to use (in this case an
ATMEGA8). I also know the frequency (16 mhz).

How would I select a compatible crystal based on factors like the load
capacitance and ESR (equivalent series resistance)?

I this case I need to select the smallest surface mount crystal that will
work. Maybe a Citizen CS10?

Also, how would I determine the capacitors to use with the crystal?

How may times have we seen this question ?

*Read the damn data sheet for God's sake !*

Normally the uC manufacturer suggests a value for both Cs.


Namely what worked for them with the crystal they bought somewhere.
They probably had an intern figure this out, as all the interesting
problems are digital.



Unusually that may
be be required to be changed to suit an unusual crystal.



After the first couple hundred units in the field refuse to start up
when it's cold.


Try around 20 - 30
pF. That's usually fine for 16MHz. I use 33 pF for an 80C52 based design @ 16
MHz.



Try various caps and crystals til you find a combination that works.
Then build a few thousand to see if it's reliable.

John

Freeze spray is your friend, along with a heat gun. Messing with the
micro power supply can be useful too - Vmin to Vmax. A few years ago we
had a whole bunch of Rabbit RCM2200 ethernet modules that killed their
crystals by overdriving them - worked fine for a few months, then
crystals failed completely (its very hard to run ethernet without a
clock). I spent a few hours trying to kick-start them (many different
c's, T etc) to no avail. An analysis of the circuit soon showed the
crystal drive levels were very high, and although a series R was present
the manufacturer used an 0R0 link. 1k was a *MUCH* better choice (IIRC).
I talked to Rabbit, and they acknowledged the design fault, since
rectified (I wasnt the only customer to find this).

To be fair it can be quite tricky to work out what drive level the
crystal can take, as manufacturers can be loath to part with this info.

Cheers
Terry
Back to top
Rich Grise
Guest





Posted: Wed Feb 09, 2005 7:51 am    Post subject: Re: Choosing a Crystal for a Microcontroller Reply with quote

On Tue, 08 Feb 2005 02:51:14 +0000, Chris Graham wrote:

Quote:
Thanks Leon. I've been looking at page 25. Does this mean that ANY crystal
with any load capacitance will work as long as I use capactiors with those
values?

I see some crystals are even offered with more than one choice of load
capacitance, so would it matter if I choose one with say a 18pf capacitance
vs say a 25pf capacitance?

Well, there it is. Recommended range for caps is 12-22 pF. So use 2X 22 pf

and you're done. I guess "1.0 <=" means "1 is less or equal to [frequency]".
With CKOPT low, the Xtal2 output "has a smaller output swing. This reduces
power consumption considerably. This mode has a limited frequency range..."
I guess that's spelled out in the chart. I'm ass-u-me-ing that "limited
frequency range" means "greater than 1 MHz", since the other ones go down
to 400 KHz. They say 5 pf of parasitics, so that'd be 27. 27 || 27 = 13.5,
so try to find a crystal with a load capacitance of 13.5. ;-)
Here ya go: Digi-key CTX646CT-ND or CTX 646TR-ND on Tape and Reel. ;-)
http://dkc3.digikey.com/PDF/T051/0768.pdf

Do I get a piece of the action? ;-P

Good Luck!
Rich
Back to top
Rich Grise
Guest





Posted: Wed Feb 09, 2005 8:40 am    Post subject: Re: Choosing a Crystal for a Microcontroller Reply with quote

On Tue, 08 Feb 2005 23:36:05 -0500, Dave VanHorn wrote:

Quote:

Seems to me you have presented some great arguments for buying a
complete oscillator for about 50 cents more.

I sort of see your point, but the cost delta is much larger than that.
Crystals run about $0.25-ish to $0.49 in moderate quantities, less if you
shop around or order more.

In most of the designs I've done, adding $0.5 to the BOM is a serious
offense.

If you're making 1M of them, then you just spent a couple years salary.

Don't forget the two capacitors, and commensurate pick-and-place; i.e.
it's three parts instead of one.

And where do you get a crystal for $0.49?

Thanks,
Rich
Back to top
Rich Grise
Guest





Posted: Wed Feb 09, 2005 8:40 am    Post subject: Re: Choosing a Crystal for a Microcontroller Reply with quote

On Wed, 09 Feb 2005 14:46:32 +1300, Terry Given wrote:

Quote:
To be fair it can be quite tricky to work out what drive level the
crystal can take, as manufacturers can be loath to part with this info.

That's primarily because nobody really knows. A lot depends on the Q of
the whole circuit, and pesky little detals like gain and phase and stuff.

I'd submit, that, in theory, there can be a person who can know all of the
details and intricacies of circuit design _and_ software design, but they
are few and far between. But I just have a sort of "hunch" that people who
can design spreadsheet programs aren't all that well-versed in the foibles
of actual circuit design. I mean, heck - the guy's already got analysis
paralysis! Sample some crystals, caps, and chips, and build a breadboard,
and putz around!

As to the drive level thing, in a parallel-resonant circuit, which might
or might not look like a Colpitts, what are the proper input and output
impedances, drive levels, gain, phase shift, etc., in the gain block of
the oscillator itself? I imagine they just take a block out of the
library, put it in silicon, and hope for the best, based on the library
writers' experience. So they publish a couple of figures that have proven
to be "good enough". That fluff about ... wait a minute. Let me parse the
data sheet:
"When CKOPT is programmed, the Oscillator output will oscillate a full
rail-to-rail swing on the output. This mode is suitable when operating in
a very noisy environment or when the output from XTAL2 drives a second
clock buffer. This mode has a wide frequency range. When CKOPT is
unprogrammed, the Oscillator has a smaller output seing. This reduces
power consumption considerably. This mode has a limited frequency range
and it cannot be used to drive other clock buffers."

This indicates to me that it's sort of a selection between digital and
analog. So obviously, it's time for another religious war. >:->

Anyway, it goes on:
"For resonators, the maximum frequency is 8 MHz with CKOPT unprogrammed
and 16 MHz with CKOPT programmed. C1 and C2 should always be equal for
both crystals and resonators."

This is a subtle hint/foreshadowing - read on:
"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."

Now, this is a disclaimer if I've ever heard one! "<paraphrase>Use a
crystal in low drive mode, but we don't guarantee it'll operate!
</paraphrase>"

"Some Initial guidelines for choosing capacitors for use with crystals are
given in Table 4."

This seems kind of simple.
"For ceramic resonators, ..." which is non-applicable, since we're not
using ceramic resonators.

But then we get to the infamous table:
"The Oscillator can operate in three different modes, each optimized for a
specific frequency range. ..."
But with CKOPT=1, the three modes all seem to apply to freq. ranges less
than 8 MHZ, and with CKOPT=0, it appears that the three modes are
indistinguishable (unless there's more info in the next paragraph), but
the frequency must be greater than 1.0 MHz.

Y'know, it is terribly, terribly confusing, even to an old fart(tm) like
me. ;-)

Good Luck!
Rich
Back to top
Rich Grise
Guest





Posted: Wed Feb 09, 2005 8:40 am    Post subject: Re: Choosing a Crystal for a Microcontroller Reply with quote

On Tue, 08 Feb 2005 19:25:53 -0800, John Larkin wrote:
Quote:
On Wed, 09 Feb 2005 14:46:32 +1300, Terry Given <my_name@ieee.org
I talked to Rabbit, and they acknowledged the design fault, since
rectified (I wasnt the only customer to find this).

A series R adds (sometimes) valuable phase shift.

To be fair it can be quite tricky to work out what drive level the
crystal can take, as manufacturers can be loath to part with this info.

Horror stories like this are legion. Unless there's volume with huge
cost pressure, it's safer to buy a canned oscillator. If there is
volume with huge cost pressure, you can't afford to not do a thorough
analysis and absolutely maintain control of the crystal motional
parameters.

The funnest case is oscillators that won't start. That can be
sensitive to temperature, emi, mounting (is the can *really* grounded,
or just sometimes?) or power supply startup dV/dT.

Oh, for the good ol' days. I had a need for a quick-n-dirty oscillator
once - I replaced a Chinese LPT chip with a daughterboard with IBM's LPT
on it[0]; unfortunately the Xtal Osc. for the two 16450s was on the
Chinese chip. So I took a plastic 2222, a crystal, a cap, and a collector
choke I made of a bunch of turns of magnet wire on a piece of toothpick
with resistor lead remnants glued in its ends; a couple of resistors to
bias it, and it worked. It's either the "Pierce" or "Clapp" circuit - the
one with the cap and crystal in series from collector to base.

Hey, every now and then one of us seat-of-the-pants techies lucks out!

Cheers!
Rich
[0] I just copied IBM's circuit right out of the PC Tech Ref.
Back to top
Rich Grise
Guest





Posted: Wed Feb 09, 2005 8:40 am    Post subject: Re: Choosing a Crystal for a Microcontroller Reply with quote

On Tue, 08 Feb 2005 19:16:32 -0800, John Larkin wrote:

Quote:
On Wed, 09 Feb 2005 01:51:20 GMT, Rich Grise <richgrise@example.net
wrote:


Well, there it is. Recommended range for caps is 12-22 pF. So use 2X 22 pf
and you're done. I guess "1.0 <=" means "1 is less or equal to [frequency]".
With CKOPT low, the Xtal2 output "has a smaller output swing. This reduces
power consumption considerably. This mode has a limited frequency range..."

Red flag. Translate as "this mode doesn't always work."


So, should he just set CKOPT = 1, and run it balls to the walls with no
capacitors at all? That seems to be the other alternative, even though the
chart only shows CKOPT=1 for frequencies _lower_ than 8.0 MHz? Or is that
for ceramic resonators? And the paragraph at the top of the page seems to
recommend these extreme options only for extreme conditions, like e.g. a
ceramic resonator at some sub-MHz frequency.

And the freq. would be all over the map, with an unknown load capacitance
across the crystal and that kind of overdrive, until the crystal dies of
stress. )-;

And, since it's published in their data sheet, this mode better damn
well be guaranteed to work within the given constraints, or they're liable
for damage.

Thanks,
Rich
Back to top
Rich Grise
Guest





Posted: Wed Feb 09, 2005 8:40 am    Post subject: Re: Choosing a Crystal for a Microcontroller Reply with quote

On Wed, 09 Feb 2005 04:29:27 +0000, Pooh Bear wrote:

Quote:

John Fields wrote:

On Tue, 08 Feb 2005 14:43:23 GMT, "Christopher Graham"
order to get the frequency to be what you want it to be), the drive
level into the crystal and on and on ...

Makes you wonder how those cheap asian network cards we all use ever work !!!!

They have some underpaid weenie like me to actually look stuff up.

Quote:
Sounds like an awful lot of worry over nothing ! I'm sure the asians don't lose
any sleep over such things.

Nor those of us who have learned the invaluable skill of looking stuff up.
:-)

Cheers!
Rich
Back to top
 
Post new topic   Reply to topic    Electronics Forum Index -> Design All times are GMT
Goto page Previous  1, 2, 3, 4, 5  Next
Page 3 of 5

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



Home & Living New Topics
Powered by phpBB