Arduino Forum

Using Arduino => Microcontrollers => Topic started by: davivid on Oct 31, 2012, 11:49 am

Title: Barebones ATmega328 - Why use caps on the crystal?
Post by: davivid on Oct 31, 2012, 11:49 am
Why do all minimal Atmega328 designs have caps on the the 16Mhz crystal? I haven't and it seems to run fine! just power to the pins 7&8 and Crystal between 9&10.
Title: Re: Barebones ATmega328 - Why use caps on the crystal?
Post by: dc42 on Oct 31, 2012, 12:29 pm
A minimal atmega328 design doesn't have the crystal either.

With a crystal and no capacitors, you are relying on the stray capacitance of the wiring and the capacitance of the mcu. This may not work reliably, and the frequency will be a little higher than the nominal frequency of the crystal.

I normally use a 3-terminal ceramic resonator, which has the capacitors built-in.
Title: Re: Barebones ATmega328 - Why use caps on the crystal?
Post by: E40racer on Oct 31, 2012, 01:16 pm
Hmm, I once tried to bootload an ATmega328 on a breadboard and had forgotten to connect both caps to ground. I tried several times to burn the bootloader to no avail. Until I realised my mistake, connected the caps to ground and then it worked. I have read a couple of crystal datasheets and they all required caps. I don't think a crystal will work reliably with no caps. Try to do some high speed serial communication and see if it still works...
Title: Re: Barebones ATmega328 - Why use caps on the crystal?
Post by: fungus on Oct 31, 2012, 01:27 pm

Why do all minimal Atmega328 designs have caps on the the 16Mhz crystal? I haven't and it seems to run fine! just power to the pins 7&8 and Crystal between 9&10.


The capacitors make it much more reliable. Without them you depend on random factors like the length of the connection wires, the electrical noise in the room, etc.

Title: Re: Barebones ATmega328 - Why use caps on the crystal?
Post by: dhenry on Oct 31, 2012, 03:51 pm
It works without capacitors. The chip will run slightly faster, like 1Khz on a 4Mhz crystal, due to crystal's low pullability. Also 7pf crystals run much closer to spec than 15pf or 22pf crystals (rare today).

Capacitors become more important for 32Khz crystals.
Title: Re: Barebones ATmega328 - Why use caps on the crystal?
Post by: davivid on Nov 01, 2012, 12:28 pm
Ultimately I plan to implement a high speed serial communications network once I have finished experimenting. Currently I'm just sending a few bytes every second or so.

My crystals have the following specs:
Frequency: 16MHz
Frequency Tolerance: ± 30ppm
Load Capacitance: 18pF
Frequency Stability: ± 30ppm

Should I therefore be using 18pF Caps? I also assume lower is better for Frequency Tolerance and Stability?

Quote
I normally use a 3-terminal ceramic resonator, which has the capacitors built-in.

What would specs should I look for in one of these?
Is this preferred because of the lower part count?
Title: Re: Barebones ATmega328 - Why use caps on the crystal?
Post by: dc42 on Nov 01, 2012, 12:37 pm

Ultimately I plan to implement a high speed serial communications network once I have finished experimenting. Currently I'm just sending a few bytes every second or so.

My crystals have the following specs:
Frequency: 16MHz
Frequency Tolerance: ± 30ppm
Load Capacitance: 18pF
Frequency Stability: ± 30ppm

Should I therefore be using 18pF Caps? I also assume lower is better for Frequency Tolerance and Stability?


To get as close to 16MHz as possible without using a variable capacitor, you should aim for 18pF loading. The 2 capacitors are in series as seen from the crystal, so two 22pF caps gives a loading of 11pF. Add the stray capacitance of the circuit and the capacitance of the IC, and you will be close to 18pF.


Quote
I normally use a 3-terminal ceramic resonator, which has the capacitors built-in.

What would specs should I look for in one of these?
Is this preferred because of the lower part count?


The main advantage is the lower part count. Ceramic resonators also cost slightly less than crystals. The disadvantage is that ceramic resonators have a lower frequency accuracy and stability than crystals - but still good enough for serial comms.
Title: Re: Barebones ATmega328 - Why use caps on the crystal?
Post by: MarkT on Nov 01, 2012, 01:58 pm
Without the right load caps the frequency won't be in-spec for that crystal (they are calibrated for a given load capacitance). 

Load caps make the oscillation frequency much less sensitive to stray circuit capacitances I believe - not necessarily important.

A particular oscillator design may assume a certain range of load capacitance too - without it there might be no guarantee of oscillator start-up?
Title: Re: Barebones ATmega328 - Why use caps on the crystal?
Post by: dhenry on Nov 01, 2012, 02:30 pm
Quote
Without the right load caps the frequency won't be in-spec for that crystal (they are calibrated for a given load capacitance).


Depends on what you meant by "in-spec".

Quote
Load caps make the oscillation frequency much less sensitive to stray circuit capacitances I believe - not necessarily important.


It doesn't make it less sensitive. It makes the frequency closer to spec.

Quote
A particular oscillator design may assume a certain range of load capacitance too - without it there might be no guarantee of oscillator start-up?


Yes, but generally only for low frequency oscillators.
Title: Re: Barebones ATmega328 - Why use caps on the crystal?
Post by: simplex on Nov 04, 2012, 10:52 pm
A Crystal has an equivalent RLC model, see: http://www.eetkorea.com/ARTICLES/2001SEP/2001SEP06_AMD_AN.PDF

The Crystal together with its two capacitors and maybe other components make a filter. You just have cu calculate the resonant frequency of this filter and reach the conclusion that the two added capacitors help in obtaining a precise frequency for the oscillator (filter + inverter).

There is no other explanation.
Title: Re: Barebones ATmega328 - Why use caps on the crystal?
Post by: dc42 on Nov 05, 2012, 12:16 am
The capacitors perform another important function. The combination of capacitors, crystal and the inverting amplifier make up a Colpitts oscillator. Without the capacitors (or sufficient stray and pin capacitance instead), the circuit would not oscillate.
Title: Re: Barebones ATmega328 - Why use caps on the crystal?
Post by: CrossRoads on Nov 05, 2012, 12:26 am
Also helps to read this Atmel Application note, section 5, where it describes what the internals of the OSC1 & OSC2 pins are and how they are to be connected to external components such as crystals.
Title: Re: Barebones ATmega328 - Why use caps on the crystal?
Post by: MarkT on Nov 05, 2012, 12:57 pm

The capacitors perform another important function. The combination of capacitors, crystal and the inverting amplifier make up a Colpitts oscillator. Without the capacitors (or sufficient stray and pin capacitance instead), the circuit would not oscillate.


CMOS inverter is a phase-shift oscillator surely?
Title: Re: Barebones ATmega328 - Why use caps on the crystal?
Post by: dc42 on Nov 05, 2012, 02:54 pm
I suppose you could view it as a phase shift oscilator, but it's more usually viewed as a Colpitts oscillator in which the inductor and most of the capacitance is replaced by a crystal. If you google "colpitts oscillator crystal" you will find lots of references to a Colpitts oscillator that uses a crystal. But when I googled "phase shift oscillator crystal", the hits were mostly describing two different oscillators, not a phase shift oscillator that used a crystal.
Title: Re: Barebones ATmega328 - Why use caps on the crystal?
Post by: mantoui on Dec 10, 2012, 04:41 pm
I've run various experiments to measure frequency offset on various MCU's and RTC's.  I connected 32Khz crystal to oscillator pins on 328p both with and without load capacitors.  Crystal worked in both configurations, though maybe a little more jitter with no capacitors. More than you wanted to know here
 
   https://github.com/manitou48/crystals