# why capacitors are used with crystal oscillator?

I want to learn 8051 programming so I begin from hardware in which crystal oscillator is connected with capacitors. can anyone please explain why capacitors are used and why those 22pF? how they calculated?

• Just want to point out that most people who program the 8051 probably doesn't care much about why those capacitors are there. – pipe May 28 '18 at 12:57

can anyone please explain why capacitors are used

Firstly, a typical circuit is shown below and on that circuit is marked phase angles to roughly achieve oscillaton: -

• The inverter provides 180°
• R1 and C1 provide about 10°
• The crystal and C2 provide a further 170°

If you didn't have capacitors you wouldn't get a total of 360 degrees phase shift and that means it wouldn't oscillate. If you use a simulation tool and model the crystal you will see something like this (below). This is the combined added phase shift brought about by changing C1 and C2's values: -

The blue horizontal line marks the "added" phase shift of exactly 180° - this would be the point of oscillation. Anything below 10 pF probably wouldn't oscillate so, you need the capacitors to make the overall phase shift around the loop add up to 360°.

and why those 22pF?

Well there are oscillators that will need more and some that will need less. The XTAL data sheet normally indicates what value is required.

how they calculated?

You need to observe the recommendations in the data sheet and also consider the added effect of gate input capacitance.

The bottom line is that an oscillator will only oscillate if the phase shift is 360° (or 0°) and there is enough gain (greater than 1) around the loop.

• Its a too-broad question. Not mentioned is ACpower dissipated by the crystal: too much capacitance can drive too much AC current in a tiny crystal. Including crystal power complicates oscillator design considerably. – glen_geek May 28 '18 at 13:51
• @glen_geek so now is your opportunity to throw your answer in! – Andy aka May 28 '18 at 14:22
• Andy - from where do you know that the first R-C element provides 10 deg phase shift? More than that, I think we have a lagging phase, don`t we? – LvW May 28 '18 at 14:48
• The "+" sign in my answer means there is an increase in phase and yes I understand that this is a lag (of course). The 10 degree from the first stage is just an estimate based on simulations I have done previously and it isn't a hard value by any means however, you need a few degrees but you also don't want too many degrees shift because that then starts to push the XTAL a little too far off its operating frequency and specification. – Andy aka May 28 '18 at 15:05

Simple answer: For the circuit to oscillate we must establish positive feedback (360 deg phase shift within the complete loop, including the 180deg phase shift of the inverter).

That means: We need a feedback network which provides another 180 deg phase shift at the desired oscillation frequency. Fo this purpose we can use a passive third-order lowpass or a passive third order high-pass. A third-order network is necessary because a second-order filter provides 180 deg at infinite frequencies only.

In the shown circuit we have third-order ladder-network (R1-C1-L2-C2) working as a lowpass. Please note that in those cases the crystal works as a high-quality inductance L2 and NOT as a series or parallel resonant circuit. The desired frequency (where the crystal acts as a inductance) is between these two resonant points.

• "In the shown circuit"... Which shown circuit? – MrGerber May 28 '18 at 14:32
• OK - I accept the comment. The circuit is shown in Andy aka´s answer. – LvW May 28 '18 at 14:45

Andy has provided a fine answer. Here's another perspective that looks at power dissipated by the crystal...
From Andy's plots, the oscillator isn't likely to oscillate if the two added capacitors (C1 & C2) have small values. In a simulation, a 74HCU04 10 MHz. crystal oscillator would not start when C1 & C2 were much less than 5 pf. In this circuit, no series resistor was added to the HCU04 output pin, as in Andy's example circuit:(R1).

For C1, C2 = 5pf, oscillations were feeble, and the circuit would be unreliable. AC power dissipated in the crystal's R1 (20 ohms) was 1.25 uW, well within the typical crystal power spec around 100uW. Crystal frequency would be somewhat higher than 10.0 MHz, since C1 & C2 are below the crystal manufacturers' spec of 18 pf.

For larger values of C1 & C2, oscillations start more readily, and build more robustly, to finally settle with larger crystal current (and larger power):

• C1 & C2 = 5.0pf....power 1.25 uW
• C1 & C2 = 8.0pf....power 6.5 uW
• C1 & C2 = 20 pf....power 77 uW
• C1 & C2 = 47 pf....power 314 uW

This last case (C1 & C2 = 47pf) exceeds the recommended manufacturer's power dissipation for the crystal. Oscillator frequency for this case would be on the low-side of 10 MHz. Capacitors C1 & C2 are usually chosen so that oscillator frequency is very close to the crystal manufacturer's target frequency, since frequency is often of prime importance to the circuits that this oscillator drives.
Too little capacitance raises oscillator frequency, and risks a feeble oscillator that refuses to oscillate.
Too much capacitance runs at a lower oscillator frequency, and risks damaging the crystal with too much power. Such a robust oscillator can also potentially run at spurious crystal resonances other than the fundamental frequency. In this simple simulation, only the fundamental crystal resonance is included.