[comp.arch] Crystal oscillator theory.

root%kilowatt@Sun.COM (Operator) (08/25/89)

Hello net.

	I have question for the informed masses. I need to understand
the theory of how a crystal oscillator works in a digital circut.
After 5+ years of digital design I realized that this is the one
really *gaping* hole in my knowlege of computer hardware.

So, if anyone out there has a good reference, or can give me the basic
theory of operation on this topic I would greatly appreciate it.

Email is the prefered method of communication, but post if you think that
the "net-audience" would benefit from this information.

Steve -Raz- Berry      Disclaimer: I didn't do nutin!
UUCP: sun!kilowatt!raz                    ARPA: raz%kilowatt.EBay@sun.com
"Fate, it protects little children, old women, and ships named Enterprize"

mmm@cup.portal.com (Mark Robert Thorson) (08/27/89)

You can think of a crustal as an inductor with super high Q.
(Obviously, it's an insulator at DC, unlike an inductor;
I'm referring to its AC behavior.)
(Q can be thought of as "frequency selectivity".)

usenet@cps3xx.UUCP (Usenet file owner) (08/29/89)

in article <123232@sun.Eng.Sun.COM>, root%kilowatt@Sun.COM (Operator) says:
$ Keywords: circuit theory where to find info
$ 	I have question for the informed masses. I need to understand
$ the theory of how a crystal oscillator works in a digital circut.
$ After 5+ years of digital design I realized that this is the one
$ really *gaping* hole in my knowlege of computer hardware.
$ 
$ So, if anyone out there has a good reference, or can give me the basic
$ theory of operation on this topic I would greatly appreciate it.
$ 
$ Email is the prefered method of communication, but post if you think that
$ the "net-audience" would benefit from this information.

Please post as I am interested in this also. I've noticed on schematics
the use of one or two caps tied from the crystal to ground and have
never quite understood their function. Back in school in labs we always
just slapped a crystal onto the chip and no one ever said it should be
done different.

John H. Lawitzke           UUCP: Work: ...uunet!frith!dale1!jhl
Dale Computer Corp., R&D         Home: ...uunet!frith!dale1!ipecac!jhl
2367 Science Parkway       Internet:   jhl@frith.egr.msu.edu
Okemos, MI, 48864                             [35.8.8.108]

kenny@m.cs.uiuc.edu (08/30/89)

/* Written  3:19 pm  Aug 24, 1989 by root%kilowatt@Sun.COM in m.cs.uiuc.edu:comp.arch */
/* ---------- "Crystal oscillator theory." ---------- */
	I have question for the informed masses. I need to understand
the theory of how a crystal oscillator works in a digital circut.
/* End of text from m.cs.uiuc.edu:comp.arch */

[Some of the following discussion is plagiarized from the `RCA COS/MOS
Integrated Circuits Manual]

Just as with any oscillator, a crystal oscillator has an amplifier in
a feedback loop.  In typical designs, the amplifier is an inverting
configuration (and hence supplies an inherent 180 degree phase shift);
let the gain of the amplifier be -alpha.  If we apply the amplifier's
output signal to a feedback network that causes an additional 180
degrees of phase shift, oscillation will take place.  Let the gain of
the feedback network be denoted by -beta.

Stable oscillation requires that alpha*beta <= 1.  (Otherwise, the
oscillations diverge, and maybe the circuit even makes smoke).  For
oscillation to begin, though, we mush have alpha*beta > 1.  We solve
this problem by using a non-linear amplifier, such as a CMOS gate
driven to the supply rails.

The feedback network can be constructed with a tank circuit (possibly
varactor-tuned), an active filter, or anything else for which beta
will vary with frequency.  For the purposes of this discussion, we'll
use a crystal.

The effective circuit for a crystal looks like:

             Rs       L      C
	+---'/\/,---ooooo----|(---+
    o---+                         +---o
	+------------|(-----------+
                     Co

The values of these equivalent parameters are often tabulated by the
crystal manufacturer.  Typical values might be:

Freq	Rs	L	C	Co
(KHz)	(ohms)	(H)	(fF)	(pF)
----------------------------------------
  90	15K	137	23.5	3.5
 280	1.35K	 27.7	11.7	6.18
 525	220	  7.8	11.5	6.3
2000	150	  0.785	 1.35	3.95
	(NOTE: fF = femtofarads = farads * 1.0E-15)

Now let the impedance of this equivalent device be Z = Re + jXe.
If we plot |Z|, we find that it has a sharp minimum and maximum at
frequencies fm and fn, respectively.  If we plot Xe alone, we find
that the crystal appears purely resistive at two frequencies, fr (the
resonant frequency) and fa (the antiresonant frequency).  We find that
the impedance angle (the argument of Z) is zero at two frequencies, fs
(the series-resonant frequency) and fp (the parallel-resonant
frequency).

Because Rs in a good crystal is very small with respect to X[Co], we
can derive that

	fm ~ fs ~ fr	and	fa ~ fp ~ fn

(The difference between them is typically a few parts per million).
We also have that

	fa ~ fs (1 + sqrt [C / Co])

C/Co is about .003 in a typical crystal, so fa is typically about
1.0015 * fs.  A typical crystal oscillator will be designed to operate
between fs and fa.

At series resonance, Re ~ Rs.  Manufacturers generally specify
maximum values of Re in a given crystal.

It is important that Re be as low as possible, because the amplifier's
phase shift will not be precisely 180 degrees.  The amplifier's
propagation delay, which is sensitive to temperature and supply
voltage, will also enter into the loop.  We therefore need, for a
stable frequency, a high rate of change of the phase angle with
respect to the frequency.  This rate of change is related directly to
the equivalent circuit's Q = omega*L/Rs.  Q values of 50000-100000 are
easily achieved.

The impedance of the crystal's equivalent circuit increases sharply as
antiresonance is approached.  For this reason, crystal oscillators are
generally designed to operate near the series-resonant frequency.
Another reason that antiresonant operation is impractical is that fa
depends on Co.  Stray capacitance is usually very large compared with
Co, and so the frequency can vary widely with various circuit layouts.
The frequency is completely independent of Co at series resonance.

When a crystal's data sheet says that it is `calibrated at series
resonance', it refers to this configuration, and specifies fs.

We can make antiresonant operation more practical by putting a load
capacitor Cl in parallel with the crystal, effectively increasing Co
substantially and making it large with respect to the stray
capacitance.  Cl also reduces the series impedance of the equivalent
circuit.

We can also put Cl in series with the crystal.  If this is done, the
effective series resistance Re will not change, but the reactance will
become Xe-X[Cl].  The impedance will be minimized when Xe=X[Cl].  We
call this new antiresonant frequency f'a.  To keep the series
resistance Re small, f'a should be close to fs.  At fs, though, Cl
would have to be infinite, and if the value is excessively close, the
large capacitors would be inductive enough to mess up these
calculations.  The compromise is to choose an intermediate value of
Cl, typically 13, 20, or 32pF.  The load capacitance will be tabulated
for these `parallel-resonant' or `anti-resonant' crystals.

Note that the frequency f'a for which Xe = X[Cl] is about equal to the
antiresonant frequency for a crystal with a parallel loading capacitor of
the same size.  The effective impedance, however, is very different,
being several orders of magnitude greater for the parallel load
capacitor.  It is usually, then, a better choice to put the capacitor
in series with the crystal.

Now let's design a practical oscillator.  A CMOS inverter with a 10M
feedback resistor is an inverting amplifier with a gain of about
alpha=5 (10V supply) or 10 (5V supply).  The circuit will oscillate,
then, with any feedback network having an attenuation constant of at
least beta=0.2.  We want there to be a steep rate of change of phase
angle with frequency, and to design the circuit so that it is not
critically dependent on component values.  The usual circuit is a pi
network:

	+---------------------------------------+
	|					|
	+-- 10M --+				|
	|	  |				|
	+-- inv --+---- Rx -----+--- XTAL ------+
				|		|
				Ct		Cy
				|		|
			       GND             GND

Let's use a crystal specified to resonante at 2.4576 MHz, with an
effective series of at most 350 ohms into a 32 pF load.  A 4001 or
4007 inverter has an effective input capacitance of about 10 pF (5V
supply) to 15 pF (10V supply) and an output resistance of about 1000
ohms..  The angular frequency at resonance, omega, will be about
1.5442e+7 inverse seconds.  We choose for a design point beta=0.75.

The pi network is equivalent to:

o--- 1K + Rx --+-- Re -- jXe --+---o Vout
Vin            |               |   
             -jX[Ct]        -jX[Cy + 10pF]
               |               |
              GND             GND

We calculate a voltage gain Ka:

	Ka = (4*Xe + 1.07*Re) / (Xe - 1.07*Re*beta)

Remembering that Xe = X[Cl], we have Xe = 2024 ohms.  Ka is calculated
to be 4.859.

We now substitute in the following equation:

	Xl = Xe / (1 + beta*Ka)

to get Xl (eff) = 435.7 ohms.  X[Ct] is equal to Xl (eff), and so is
also 435.7 ohms.

X[Cy + 10pF] is given by
	X = beta * Xl(eff) * Ka
and is 1588 ohms.

The series resistance (Rx + 1k) is determined by 
	R = (Ka - 1) * ( Xl * Xl / Re)
and is calculated to be 2093 ohms, giving Rx = 1093 ohms.  We use 1.1K
as the nearest standard (5%) value.

The capacitor Ct is calculated as
	Ct = Xe * Cl / XCt
or about 150 pF.

The capacitor Cy is
	Cy = (Xe * Cl / X[Cy+10pF]) - 10pF
or about 30 pF.

To get fine frequency control, we trim Ct, replacing it with a 120 pF
capacitor and an 8-50 pF trimmer.

EXERCISES

Find Rx, Ct, and Cy for crystals with the following specifications:

(1) f'a = 32768 Hz, Cl = 12.5pF, Re = 30K

(2) f'a = 279.611 Hz, Cl = 32 pF, Re = 2.5K

(3) f'a = 1.0000 MHz, Cl = 13 pF, Re = 800

(4) f'a = 6.144 MHz, Cl = 30 pF, Re = 80

APPENDIX

The following short C program calculates component values for a
crystal oscillator based on the CD4001A or 4007:
------------------------------------------------------------------------
#include <stdio.h>
#include <math.h>
double atof ();

main () {
  double beta = 0.75;		/* Desired attenuation constant */
  double f;			/* Operating frequency */
  double Cl;			/* Specified load capacitance */
  double Re;			/* Maximum series resistance */
  char line [81];

  printf ("Operating frequency (MHz): "); 
  fgets (line, 80, stdin);
  f = atof (line) * 1.0e6;
  printf ("Load capacitance (pF): ");
  fgets (line, 80, stdin);
  Cl = atof (line) * 1.0e-12;
  printf ("Maximum series resistance of crystal (ohms): ");
  fgets (line, 80, stdin);
  Re = atof (line);

  {
    double omega = 6.28318 * f;
				/* Angular frequency */
    double Xe = 1. / (omega * Cl);
				/* Effective reactance of xtal */
    double Ka = (4. * Xe + 1.07 * Re) / (Xe - 1.07 * Re * beta);
				/* Voltage gain */
    double Xl = Xe / (1. + beta * Ka);
				/* Load reactance */
    double XCt = Xl;		/* Reactance of Ct */
    double XCs = beta * Xl * Ka;
				/* Reactance of Cs */
    double R = (Ka - 1) * (Xl * Xl / Re);
				/* Series resistor to use */
    double Ct = Xe * Cl / XCt;	/* First capacitor */
    double Cy = (Xe * Cl / XCs);
				/* Second capacitor */
    printf ("Pi network:\n\
o--- %8.0f ohms ---+--- XTAL ---+---o\n\
                      |            |\n\
                %5.0f pF     %5.0f pF\n\
                      |            |\n\
                     GND          GND\n\
", R-1000, Ct * 1e12, Cy * 1e12 - 10);
  }
}
------------------------------------------------------------------------

SOLUTIONS

(1) Rx = 1M, Ct = 51 pF (use a 22 pF and an 8-50 pF trimmer), Cy = 5.6
pF (5V supply -- best to use a gimmick) or omitted (10V supply)

(2) Rx = 22K, Ct = 144 pF (use a 100 or 120 pF and an 8-50 pF
trimmer), Cy = 31 pF (use a 27 or a 33).

(3) Rx = 33K, Ct = 54 pF, Cy = 7 pF (use a 6.8 on a 5V supply, or omit
on a 10V supply)

(4) Rx = 711 (use a 680) Ct = 130 pF (use a 100 pF and an 8-50 pF
trimmer), Cy = 29 pF (use a 27, or maybe a 24 on a 10V supply).

| /         o            Kevin Kenny                             (217) 333-5821
|<  /) |  | | |/\        Illini Space Development Society         o  ,    o  ,
| \ X_  \/  | | |        P.O. Box 2255                          40 07 N 88 13 W
kenny@cs.uiuc.edu        Station A       
uunet!uiucdcs!kenny      Champaign, IL 61825                 AD ASTRA PER ARDUA
k-kenny@uiuc.edu
kenny%cs@uiucvmd.bitnet

gcaw@otter.hpl.hp.com (Greg Watson) (09/18/89)

If people are still interested in more crystal oscillator design info, then
please e-mail me. A colleague of mine has written a short paper on the
subject, containing only a few simple equations - it's more of a hands-on
intuitive guide to designing these circuits. I will snail-mail you a copy,
so please supply a full postal address. Obviously alternatives will have to
be considered if the volume of requests gets too large.

Regards,

Greg Watson

****************************************************************************
Greg Watson                           gcaw@hplb.hp.com
Hewlett-Packard Laboratories          TEL:+44 272 799910 ext 24016
Filton Rd, Stoke Gifford              FAX:+44 272 790554
Bristol BS12 6QZ. UK
*****************************************************************************