Which Crystal Should I Use
Moderators: adafruit_support_bill, adafruit

Which Crystal Should I Use

by guysherman on Thu Feb 07, 2013 10:07 pm

Hi, I'm a Software Enginneer, but relatively new to electronics. Anyhow, I'm working on a hobby project that has been based on an Arduino so far, but the project is rapidly approaching the point where I want to make my own board for it (an ATMega328 on its own is considerably cheaper than an Uno kit).

The project I am working on makes use of the hardware SPI, I2C and UART on the chip, as well as a multiplexing software serial port that I've written, so clock-speed, and timing are important.

Anyhow, I have a few questions around crystals:

1: Which crystal should I use... I think I've narrowed my search down, but there are a few properties I don't quite understand:
Tolerances seem to be quoted in ppm, does 30ppm mean 0.000003 as in 0.0003%?
Load capacitance: the one I'm looking at is 18pf, does this mean I need to put 18pf caps on either side of the crystal?
Would http://nz.element14.com/jsp/search/productdetail.jsp?sku=1640875 be sufficient?

2: Can I use a common crystal for multiple AVRs, or should I use a separate crystal for each

3: Can anyone recommend a resource from which I can learn some of the theory behind these sorts of things.

Many thanks,

Guy Sherman.
http://guysherman.com
guysherman
 
Posts: 3
Joined: Thu Sep 08, 2011 7:42 pm

Re: Which Crystal Should I Use

by Zener on Fri Feb 08, 2013 5:52 pm

I will answer #3 first:

http://foxonline.com/pdfs/xtaldesignnotes.pdf

That answers most of your questions. Now I will answer your questions specifically:

1: Which crystal should I use... I think I've narrowed my search down, but there are a few properties I don't quite understand:
Tolerances seem to be quoted in ppm, does 30ppm mean 0.000003 as in 0.0003%?

Close. It means .000030 as in .003% Keep in mind that is the initial tolerance, and has nothing to do with temperature stability.

Load capacitance: the one I'm looking at is 18pf, does this mean I need to put 18pf caps on either side of the crystal?

The issue of series resonant vs. parallel resonant, and load capacitance, is definitely one of the most misunderstood issues in electronics. Maybe the most misunderstood. The document above does a pretty good job, but I will reiterate. All the terms above, series, parallel, capacitance, have NOTHING TO DO WITH ANY CHARACTERISTIC of the crystal. You can put them all under an electron microscope and they are all exactly the same. You cannot put a capacitance meter on a crystral and measure anything. It has no capacitance. The only difference is in the exact frequency. The terms relate to the circuit design you are using. 99% (or more) or oscillator circuits are the parallel kind with the 2 caps. If you buy a parallel crystal with a cap spec of 18pF and you put it in a parallel circuit and you use 18 pF caps, then it will run at its specified frequency and tolerances. However, the differences are very small. If you run a series crystal in a parallel circuit it will be slightly off the specified frequency, but usually this does not make any difference. Usually when you get into high frequency tight tolerance applications you will use TCXO's anyway. I used to sell lots of crystals, and I probably sold 35% series resonant, even though the circuits were parallel. I told the engineers but they just said "it works so we don't change". The truth is it didn't make any difference in their application.


Yes, but 6 bucks? That must be some exotic one. You should be spending a buck maybe. Less in qty.

2: Can I use a common crystal for multiple AVRs, or should I use a separate crystal for each

Generally easier to put a crystal on each device. Only reason you wouldn't is if they all need to be synchronized exactly. Then you would use an oscillator module or specialized clock generator, which lots of people make, but few average people need. If you are making an Intel motherboard you need them.
Zener
 
Posts: 2630
Joined: Sat Feb 21, 2009 2:38 am

Re: Which Crystal Should I Use

by westfw on Fri Feb 08, 2013 11:56 pm

Load capacitance: the one I'm looking at is 18pf, does this mean I need to put 18pf caps on either side of the crystal?

No; that means that the total load capacitance should be 18pF. That's the two caps in series plus stay capacitance: Cstray + ((C*C)/(C+C)) according to the fox document. That works out to C = 2(Cload - Cstray). Cstray is supposed to be about 6pF for an AVR, so C = 2(18-6) = 24pF

See also this microchip document: http://ww1.microchip.com/downloads/en/a ... 00826a.pdf
User avatar
westfw
 
Posts: 1373
Joined: Fri Apr 27, 2007 1:01 pm
Location: SF Bay area

Re: Which Crystal Should I Use

by Zener on Sat Feb 09, 2013 4:24 am

OK. You got me on that one!
Zener
 
Posts: 2630
Joined: Sat Feb 21, 2009 2:38 am

Re: Which Crystal Should I Use

by guysherman on Sat Feb 09, 2013 8:42 pm

Thanks for the response, that helps quite a bit.

@Zener, that $6 is in NZD as well, so it's like USD$7.50, but that's how it is in New Zealand.

Thanks for your help!
guysherman
 
Posts: 3
Joined: Thu Sep 08, 2011 7:42 pm

Re: Which Crystal Should I Use

by bobs bots on Sat Feb 16, 2013 1:26 am

Hi Guy sherman,
I'm from the West Island.
PS you have the exchange rate backwards $6NZD=$5.1USD.

(a)
The frequency is also important. If you want to use the Arduino bootloader , you are stuck with 16MHz , that's not such a a bad thing, I generally use 16MHz anyway.
If you want to use fast baud rates (above 38400) , you may be better off to use a baud rate crystal, I think 14.132 is popular, but it may be difficult with baud rate crystals to generate "round numbers" from the timer/counters , so you can make 10kHz with a 16.00Mhz clock , and you can make 9.000kHz with the 14.132. I used to use 14.132 , but they are harder to find , and it turns out at 19800bd, the error is only 0.5% with 16MHz.
SPI and I2C don't care about exact frequencies.

(aa) the CPU current draw goes with frequency eg 16mA at 16MHz , something to think about when using batteries.

(aaa) if you want to run interrupts (e.g. so you can have buffered serial , and background timer operation) you generally can't run with a lower frequency clock. For example 8MHz and 38400Baud is very difficult , 16MHz and 19200 is good. At 38400bd, you need to ensure that the ISR for the serial is able to be called at ~4kHz (i.e. each 250uS)
You will have problems for example trying to read all 12channels of an I2C ADC in each time slot, so you need to break it up into two. You may even have trouble reading the internal ADC.

(aaaa) I generally use 16MHz , and run a background ISR that is called at 2.000kHz , this counts up to twenty "phases" or slots, so each of twenty "tasks" runs at 100ms intervals, and one second is then 100 ticks. I can run two serial ports, some I2C parts, the internal ADC , and everything meshes together nicely.

(aaaaa) The fastest baud rate I have used on an AVR is 5Mbaud with a 20MHz crystal , this requires the "turbo" UART mode (This was for an encoder interface, I discarded 99.9% of the packets)

(b) Resonators are usually a better option than crystals, they are way cheaper, Mouser have the AWSCR-16.00MTD for 18c at 1000 off . They occupy less PCB space , and they don't need the fiddly little caps, the accuracy is worse than crystals , like you might lose a minute a day instead of a few seconds , (but an ordinary crystal is not good enough for a stand alone RTC , so why bother)

(c) The Avr's have some fuses that can be blown, you should use the "large swing" option for the crystal , the other option makes them a bit sensitive to touching of the crystal.

(d) Cascading of the Xtal , In theory this is possible, but in practice generally not, unless you use a CPU with a separate clock out pin. I've tried to run a encoder interface using the "output" leg of the crystal, but the capacitance of the PCB trace, and the chip input capacitance eat up the 22pF crystal padding. It was very unreliable.
bobs bots
 
Posts: 1
Joined: Fri Feb 15, 2013 11:09 pm