Hi
I am building a breadboard arduino (to me moved to a pcb). I am in the UK so cant source the crystal I was advised to use as it is not easily attainable in quantities less than 1000.
So I found what I think is a suitable substitute.

The load capacitance of the crystal is 20pF. My working for the Capacitors is

CL=((C1 x C2) / (C1 + C2)) + Cstray

20pF = ((30pF x 30pF) / (30pF + 30pF)) + 5pF

So i need 2x 30pF caps.
I have read that it is a good rule of thumb for stray capacitance to be 5pF
Dose this seem correct or have i missed something.

load capacitance of the crystal is 20pF...good rule of thumb for stray capacitance to be 5pF

That sounds about right. What are the stability/tolerance specifications for the crystal? 16 MHz crystals with 50-100ppm specifications are typically cut for 18-20 pF load capacitance. Ones with tighter specifications seem to have lower loads specified, but...

Note that the "stray" capacitance actually includes the capacitance that the ATmega presents to the XTAL pins, so it may vary a little. I have no way of measuring it, and I haven't seen any actual specification for the ATmega capacitance. My experience with other CPUs is that it tends to vary from batch to batch. The oscillator circuitry inside the CPU is not really a tightly controlled oscillator circuit. It's just a couple of transistors whose actual characteristics are not actually measured, controlled, or guaranteed by the manufacturer for each and every batch of chips that they produce.

My rule of thumb: If your capacitance is off by a few pF, the frequency may be affected by a few parts per million.

Putting it another way: If the crystal has a specification of 50 parts per million at 20 pF load anything from 15-30 pF may give a total frequency error of something like 60 parts per million.

I suggest that if your application can't tolerate a CPU frequency error of a few hundred parts per million, you have two options: (See Footnote.)

1. Use an external oscillator designed to be an oscillator rather than depending on the rather loosely controlled characteristics of CPU XTAL pins.

2. Expect to have to fine tune the frequency by selecting capacitors for each circuit that you build so that you can get the required frequency.

Sometimes people design their PC boards with parallel sets of pads for each capacitor. Then, as a part of a rather expensive manufacturing test procedure they start with a value slightly less than the nominal value and put additional capacitors on the order of a few pF until the frequency is "close enough." Note that it's usually not practical to measure the frequency directly since putting an instrument on the crystal will add capacitance and will affect the frequency.

Regards,

Dave

Footnote: Do you have an application that requires your CPU frequency to be accurately known to within a few tens of parts per million?

For example: I am using an Arduino setup to create a 50 kHz output signal using a Timer2 interrupt every 10 uSec. The program is doing other stuff, so the normal millis() interrupt timer is also running.

I measured the period of my nominal 50 kHz square wave with a frequency counter. (Hasn't been calibrated for a while, but I think it's "pretty accurate")

With a "real" Arduino Duemilanove, the average period is something like 19.9995 usec. I have no idea as to what the specification of the crystal is, but I consider a 25 ppm error to be outstandingly close.

With homebrew circuits using parts on hand (50 ppm 20 pF crystal and 22 pF caps) I get almost the same results (19.99912 usec period).

In a Solarbotics Ardweeny with a ceramic resonator, I get a period of something like 20.0077 usec, which is an error of 385 ppm. That's .0385%, and is totally acceptable for my application.

If I look at the square wave (all of the circuits) on a 'scope, I see jitter on the order of a hundred of nanoseconds or so. That's acceptable for my application, but it could be a show-stopper for some.

Some jitter is inevitable for any software-generated signal, but it could be smaller than this if there are no other interrupts being serviced, and it could be a lot smaller if the signal is generated by counting instructions in a loop and not using a timer interrupt at all.

In this case you (probably) wouldn't be using a high-level language at all, and you almost certainly wouldn't be using any interrupts of any kind.

So: What are your real requirements? How accurate do you need the clock to be for your application?

Hi, Thank you for the replay. It was very helpful. The tolerance is 50ppm. Just to clarify the data sheet specifiers 20pF Load capacitance.

I don't think the frequency error will be an issue.

I am in the UK so cant source the crystal I was advised to use

What sort of crystal. The arduino is very tolerant of what crystal it has there should be no problem with any crystal almost. Where in the UK are you looking, Farnell are good:- http://uk.farnell.com/jsp/home/homepage.jsp

Hi I could not source the crystal form the guide I was using.

I will take a look at farnell too.

My experience with fine tuning is that it is quite hard to get better than 50ppm. The issue is that the caps will often have a tolerance of 10%. And then there is temperature influence as well.

My solutions are:

1. Get somewhat close (<100ppm) and compensate the rest in software. Depending on your application this may not be an option.
2. Buy a TXCO (but I am still searching for a 16MHz version that is cheap).
3. Use an RTC for long term timing.

Udo

My experience with fine tuning is that it is quite hard to get better than 50ppm.

Just use an atomic resonator.. ;D

My experience with fine tuning is that it is quite hard to get better than 50ppm.

I should have written

My experience with fine tuning crystals is that it is quite hard to get better than 50ppm.

but I thought this would have been clear from the context.

I have something like this http://cgi.ebay.com/EFRATOM-LPRO-101-Rubidium-10MHZ-Frequency-Standard-/300282896608 at home. However the power consumption is somewhat increased ;)

Udo