Every clock, radio, and microcontroller needs a frequency that does not wander when the temperature changes or the supply voltage sags. An RC oscillator drifts by about 1% — fine for a blinking LED, useless for a clock. A quartz crystal oscillator drifts by about 50 parts per million, roughly 200 times steadier. This article explains why a crystal is so stable, how the Pierce oscillator circuit uses one, and how to choose the two load capacitors that set its exact frequency.
Figure 1: A Pierce crystal oscillator (a) — the 4 MHz crystal sits between the input and output of a logic inverter, with C1 = C2 = 30 pF to ground and a 1 MΩ feedback resistor. The comparison (b) shows the frequency drift at 4 MHz: 40,000 Hz for an RC oscillator against 200 Hz for the crystal. (Schematic, not to scale.)
Why a crystal is so stable
A quartz crystal is a thin slice of quartz that vibrates mechanically when a voltage is applied to it — the piezoelectric effect — and generates a voltage when it vibrates. It behaves electrically like a series LC circuit with an extremely high Q factor: a typical crystal has a Q of 10,000 to 100,000, while a good LC coil-and-capacitor circuit manages a Q of about 100. A high Q means the crystal's impedance changes very sharply with frequency, so the circuit can only oscillate at the crystal's own resonant frequency; a small change in the surrounding components barely moves it. The crystal's resonant frequency is set when it is cut and ground at the factory, and it changes only slightly with temperature — a few tens of parts per million over the normal temperature range.
Worked example — a 4 MHz Pierce oscillator
The Pierce circuit is the most common crystal oscillator: one logic inverter (for example a 74HC04 gate), the crystal connected between its input and output, two capacitors C1 and C2 from each side of the crystal to ground, and a large feedback resistor Rf of about 1 MΩ that biases the inverter into its linear region so it acts as an amplifier. The inverter gives 180° of phase shift, and the crystal with C1 and C2 gives the other 180°, so the loop is in phase and oscillates at the crystal's parallel-resonant frequency.
The crystal's datasheet states a load capacitance, CL — the capacitance the crystal expects to see across its terminals. For a common 4 MHz crystal, CL = 20 pF. The two capacitors and the stray capacitance of the board and the chip pins add up to CL, so each capacitor is:
C1 = C2 = 2 × (CL − Cstray) = 2 × (20 − 5) = 30 pF
Here the stray capacitance is taken as 5 pF, a typical value for a small board. The factor of 2 appears because C1 and C2 are in series across the crystal, so each must be twice the wanted load capacitance.
How steady is it, in hertz?
A crystal rated at ±50 ppm (parts per million) drifts by 50 millionths of its frequency. At 4 MHz that is:
Drift = 4,000,000 × 50 × 10−6 = 200 Hz
An RC oscillator with a 1% tolerance drifts by:
Drift = 4,000,000 × 0.01 = 40,000 Hz
So the crystal is 200 times steadier than the RC oscillator — the difference between a clock that gains a few seconds a month and one that gains minutes a day. (The famous 32,768 Hz watch crystal is chosen because 32,768 = 215, so a 15-stage binary counter divides it down to exactly 1 Hz.)
Pulling the frequency — and a common mistake
The load capacitors do not only complete the circuit; they also fine-tune the frequency. If the load capacitance is smaller than the rated CL, the crystal runs slightly fast; if larger, slightly slow. For a crystal with a typical motional capacitance of 10 fF, changing CL from 20 pF to 12 pF pulls the frequency up by about 667 Hz at 4 MHz, and changing it to 30 pF pulls it down by about 333 Hz. That is why the capacitor values matter: if you fit the common 22 pF capacitors instead of the calculated 30 pF, the load becomes CL = 22 / 2 + 5 = 16 pF, and the crystal runs about 250 Hz fast at 4 MHz. It still oscillates — but a clock built with it would gain about 5 seconds a day. Keep the drive level low as well (well under 1 mW for a small crystal): too much drive makes the crystal drift and can crack it. And above about 30 MHz, crystals are usually used on an overtone — a multiple of their fundamental frequency — because a fundamental-mode crystal that thin would be too fragile to cut.
Key points to remember
- A quartz crystal behaves like a series LC circuit with a Q of 10,000–100,000, so its frequency is set by the crystal itself and barely moves with the surrounding components.
- Worked example: 4 MHz crystal, CL = 20 pF, stray 5 pF → C1 = C2 = 2 × (20 − 5) = 30 pF; Rf = 1 MΩ biases the inverter into its linear region.
- Stability: ±50 ppm at 4 MHz is only 200 Hz of drift, against 40,000 Hz for a ±1% RC oscillator — the crystal is 200× steadier.
- Wrong load capacitors pull the frequency: 22 pF capacitors give CL = 16 pF and the crystal runs about 250 Hz fast at 4 MHz (about 5 seconds a day on a clock).
- Keep the crystal drive level low (well under 1 mW); above about 30 MHz, crystals are used on an overtone of their fundamental frequency.
