CRYSTAL AND OSCILLATORS

Crystal And Oscillators

Article by:
Date Published:
Last Modified:

1. Overview

The page also includes discrete oscillator elements such are crystals.

2. Crystals

Crystals are piezoelectric components which can be used to build an oscillator. Combined with driving circuitry, they form an oscillator which can be made to output a periodic waveform to be used as a clock source for digital logic (e.g. flipflops, microcontrollers, FPGAs, e.t.c.). They can also be called piezoelectric resonators.

crystal schematic
Figure 1. A schematic of a crystal, usually connected to a microcontroller or other digital device that uses a clock. The load capacitance usually varies from 6-25pF per leg (see the crystals datasheet for the correct value).

2.1. Equivalent Circuit

A piezoelectric crystal resonator can be modelled as a series LCR circuit in parallel with a capacitor:

crystal equivalent circuit
Figure 2. The equivalent circuit for a two-lead piezoelectric crystal resonator.

The series components \(C_1\), \(L_1\), and \(R_1\) model the physical properties of the piezoelectric crystal, and are called the motional arm[8]. They are not real physical electronic components inside the crystal. The parallel component \(C_0\) is the lead capacitance[2].

\(L_1\): This models the mechanical mass of the quartz in motion. Lower frequency crystals have a value of \(1-2H\) (yes, that’s whole Henries, much larger than micro/milli-Henries of most real inductors!). This value can drop down to \(1-100mH\) for the higher frequency crystals, which are smaller and therefore less mass.

\(C_1\): This models a number of mechanical properties of the quartz crystal: the stiffness, the area of the electrodes, and the thickness/shape of the wafer. The value for fundamental mode crystals ranges between \(0.005pF\) and \(0.030pF\).

\(R_1\): This models the impedance of the crystal when it is oscillating at it’s series resonant frequency. When a series LC circuit is at resonant frequency, it’s impedance is \(0\Omega\), therefore the impedance (and therefore current) is purely determined by this \(R_1\). \(R_1\) is inversely proportional to the active area of the crystal, therefore smaller crystals have a larger \(R_1\).

\(C_0\): This models the parallel capacitance (a.k.a. shunt capacitance) between the two leads of a crystal. It is the measured capacitance between the two leads when the crystal is not excited (i.e. not vibrating). \(C_0\) typically ranges from \(1-7pF\).

2.2. Series And Parallel Resonant Frequencies

The series resonant frequency \(f_S\) only depends on the motional arm (physical properties of the crystal) as shown in \(Eq.\ \ref{eq:series-res-freq}\)[8].

\[\begin{align} \label{eq:series-res-freq} f_S = \frac{1}{2\pi \sqrt{L_1 C_1}} \end{align}\]

The parallel resonant frequency \(f_P\) also depends on the parallel parasitic capacitance \(C_0\), as shown in \(Eq.\ \ref{eq:parallel-res-freq}\)[8].

\[\begin{align} \label{eq:parallel-res-freq} f_P = \frac{1}{2\pi \sqrt{L_1 C_1}} \cdot \sqrt{1 + \frac{C_1}{C_0}} \end{align}\]

The series and parallel resonant frequencies are usually very close together. Crystals below 30MHz are operated at a frequency somewhere between the series and parallel resonant frequencies[8].

2.3. Quality Factor

The quality factor for crystal oscillators is extremely large, typically 10,000 or greater. This is due to the very low series resistance (typically around \(5\Omega\).

The quality factor is determined by the following equation:

\[\begin{align} Q &= \frac{X_L}{R} \\ &= \frac{2\pi f L}{R} \\ \end{align}\]

where:
\(X_L\) is the impedance of the inductor.

2.4. 32.678kHz Crystals

32.678kHz is a popular frequency for crystals (also just shortened to 32kHz crystals) because it is exactly \(2^{15}\). This means you can use one with a 15-bit binary counter to get a precise 1-second (1Hz) clock or "tick". It is also a good trade-off in terms of power consumption (lower frequency = lower power consumption, great for battery powered devices) and size (higher frequency means smaller crystal package). 32.678kHz crystal are very common in any embedded circuit design which needs a real time clock (RTC). As such, they are also "dirt cheap"!

Many microcontrollers have pins which you can connect a 32.678kHz crystal to, with pin names such as XTAL32, 32K_XP/32K_XN (ESP32). Sometimes the 32 is added to distinguish it from the "main" higher frequency oscillator pins, which typically support crystals in the frequency range from 1-48MHz. The microcontroller has an internal oscillator for driving the crystal. A Pierce oscillator is a popular oscillator topology used in microcontrollers to drive these crystals. For example, all of the 32.678kHz oscillators in the MSP430 range of microcontrollers use Pierce oscillators[7].

As shown in Figure 3, 32.678kHz crystals are also called tuning fork crystals, as the crystal is usually cut into the shape of a tuning fork[8] (a vibrates in a similar manner to a larger, metal one).

tuning fork 32.678khz crystal shape
Figure 3. Basic shape of a 32.678kHz "tuning fork" crystal.

2.4.1. Turnover Temperature

Turnover temperature (\(T_O\)) is a term used with 32.768kHz crystals to describe the temperature at which the crystal is at it’s highest oscillation frequency. 32.768kHz crystals have a negative parabolic frequency response to temperature (frequency drops proportionally to the square of the temperature change) at the turnover temperature is at the maxima (at lower or higher temperatures, the frequency begins to drop). Most 32.678kHz crystals have a turnover temperature \(T_O\) between 20 and 30°C and \(\alpha\) of approx. \(-0.034ppm^{\circ}C^2\)[6].

32768khz crystal drift
Figure 4. The common shape of a temperature vs. drift curve for a 32.768kHz crystal, highlighting the turnover point at the maxima. In this model, \(T_O=25^{\circ}C,\ \alpha = -0.034ppm^{\circ}C^2\)

\(Eq.\ \ref{eq:32khz-drift}\) shows how to calculate the drift from the current operating temperature of the crystal.

\[\begin{align} \label{eq:32khz-drift} ppm = \alpha \cdot (T - T_O)^2 \end{align}\]

where:
\(ppm\) is the drift from \(f_O\), the oscillation frequency at the turnover point, in parts-per-million
\(T\) is the operating temperature of the crystal, in \(^{\circ}C\)
\(T_O\) is the temperature at the turnover point, in \(^{\circ}C\)
\(\alpha\) is a part specific co-efficient, specified in the datasheet, in \(ppm^{\circ}C^{-2}\). If no coefficient is listed, \(\alpha=-0.034ppm^{\circ}C^{-2}\) is a good assumption

Rather than using \(ppm\), \(Eq.\ \ref{eq:32khz-drift-as-ratio}\) shows how you can instead write is a ratio of \(\frac{f}{f_O}\).

\[\begin{align} \label{eq:32khz-drift-as-ratio} \frac{f}{f_O} = \frac{\alpha}{1e^6} \cdot (T - T_O)^2 \end{align}\]

where:
\(f\) is the actual oscillation frequency
\(f_O\) is the oscillation frequency at the turnover point, typically \(32.678kHz\)

2.5. The Negative Resistance Test

The negative resistance test can be used to find the oscillator load safety margin present on your circuit design. The test is performed by inserting a potentiometer in series between the crystal and the oscillator (which may be inside a microcontroller). You then slowly increase the resistance until you find the point at which the oscillator fails to start-up correctly[8].

2.6. Oven-Controlled Crystal Oscillators (OCXOs)

High-performance crystal oscillators are kept with temperature-controlled environments to increase the stability of the oscillator. They are called oven-controlled crystal oscillators (OCXOs).

n4a series oven controlled crystal oscillator ocxo photo
Figure 5. A photo of an N4A series OCXO. Image from http://www.bliley.com/.

The crystals are designed to have a turning-point, a point of greatest stability, close to the oven temperature. OCXOs, rather than having a temperature stability in the ppm (parts-per-million) range like normal crystals, have a stability in the ppb (parts-per-billion) range (20ppb would be a viable stability).

Peltier devices can be used as the "oven" to keep the crystal’s temperature constant.

The HC-49/U package is a popular choice for older through-hole crystals.

Newer crystals come in small, custom SMD packages, with typically either 2 or 4 pins (with the 4-pin packages usually have two GND pins).

2.8. Simulation

Crystal oscillators can be difficult to simulate accurately in most SPICE-based programs[3]. Most SPICE programs use the Newton-Raphson algorithm for converging to a solution. Unfortunately, the Newton-Raphson algorithm is not suitable for very high Q circuits, of which a crystal resonantor is definitely one (Q values of \(10,000\) or more!). The time step has to be set so small for accurate simulation of crystal resonantor circuits that it can take days of simulation to "start-up" the ceramic resonantor (i.e. reach steady-state oscillation from power-on).

2.9. Crystal Component Packages

For info on crystal component packages, see the Crystal Packages page.

3. Oscillators

This site uses the word oscillator to represent a component with an self-contained oscillating feature that has power, ground, and signal out pins. This site uses the word crystal to represent an component which contains a oscillating element (in the form of a crystal), which requires an external oscillation circuit before it useful.

3.1. Designators

A common designator prefix to use for oscillators is \(Y\) (e.g. \(Y1\)). I do not recommend using the prefix \(XC\) as this should be reserved for crystal oscillators.

3.2. Important Parameters

3.2.1. Phase Noise

Phase noise is a way of describing the stability of the crystal in the frequency domain.

3.2.2. Start-Up Time

Symbol: \(T_{SU}\)

The start-up time for most oscillators is within the range 2-20ms. This start-up time can be important in low-power designs when the start/stop time of the crystal results in wasted energy.

4. MEMS Oscillators

MEMS oscillators are built using small mechanical structures (less than 0.1mm in any dimension) that vibrate at set frequencies when electrostatic forces are applied. This mechanical vibratory part of a MEMS oscillator is called the MEMS resonator. This is etched into a silicon die, and surrounding electronics contain both the driving, measuring, and compensation circuitry.

They use less power than a crystal-based oscillator, making them suitable for battery-powered devices. They are manufactured using standard IC manufacturing processes, so they are also more durable. They typically have better frequency stability over their operating temperature range, with common values being 10ppm at room temperature and 100pm over their entire operating temperature range.

MEMS oscillators do not like ultrasonic cleaning baths. Ultrasonic baths may permanently damage the oscillator or cause long term reliability issue[1].

4.1. Packaging

MEMS oscillators have been made in packages which are also commonly used for crystal packages, such as the 2012 SMD package.

mems vs crystal oscillator package size
Figure 6. A comparison between MEMS and crystal-based oscillators in CSP and larger 2012 SMD packages. Note how the MEMS oscillator sneaks in two extra pins between the standard 2012 pads for power and ground.

Some common industry sizes for oscillators include:

  • 1612: 1.6 mm × 1.2 mm

  • 2016: 2.0 mm × 1.6 mm

  • 2520: 2.5 mm × 2.0 mm

  • 3225: 3.2 mm × 2.5 mm

  • 5032: 5.0 mm × 3.2 mm

  • 7050: 7.0 mm × 5.0 mm

5. Wien Bridge Oscillator

The Wien bridge oscillator is a relatively simple oscillator that can generate reasonably accurate sine waves. It is named after a bridge circuit designed by Max Wien in 1891 for the measurement of impedances. William R. Hewlett (of Hewlett-Packard fame) designed the Wein bridge oscillator using the Wein bridge circuit and the differential amplifier.

schematic traditional as bridge
Figure 7. Schematics of a Wien bridge oscillator circuit, drawn in the traditional way with the RC and R networks shown as a bridge.

However the modern way to draw this is to split up the non-inverting and inverting feedback circuits like this:

schematic modern
Figure 8. The modern way to draw the Wien bridge oscillator circuit, separating the non-inverting and inverting feedback sections.

In my opinion this is a clearer way of drawing the circuit. Wien bridge oscillators are used in audio applications.

The series RC and parallel RC circuits form high-pass and low-pass circuit elements, respectively.

5.1. Wien Bridge Equations

Let’s first look at the series and parallel RC circuits that provide the positive feedback.

The impedance \(Z_S\) of the series RC circuit is:

\[\begin{align} Z_S &= R + X_C \nonumber \\ \label{eqn:zs} &= R + \frac{1}{j\omega C} \end{align}\]

The impedance \(Z_P\) of the parallel RC circuit is:

\[\begin{align} Z_P &= R \; || \; X_C \nonumber \\ &= R \; || \; \frac{1}{j\omega C} \nonumber \\ &= \frac{R \frac{1}{j\omega C}}{R + \frac{1}{j\omega C}} && \small \text{Rule for impedances in parallel.} \nonumber \\ \label{eqn:zp} &= \frac{R}{j\omega RC + 1} && \small \text{Multiplying top and bottom by \(j\omega C\)} \end{align}\]

We can then write an equation for the voltage at the non-inverting pin of the op-amp in terms of the output voltage, and then describing it as a ratio we can get the gain of the RC network, \(\beta\) (the symbol \(\beta\) used here is consistent with the Barkhausen stability criterion):

\[\begin{align} v_{\text{non-inv}} &= \frac{Z_P}{Z_P + Z_S} v_{out} && \tiny\text{Resistor divider rule} \nonumber \\ \frac{v_{\text{non-inv}}}{v_{out}} &= \beta = \frac{Z_P}{Z_P + Z_S} \nonumber \\ &= \frac{ \frac{R}{j\omega RC + 1} }{ \frac{R}{j\omega RC + 1} + R + \frac{1}{j\omega C} } && \tiny\text{Subs in \(Eq. \ref{eqn:zs}\) and \(Eq. \ref{eqn:zp}\)} \nonumber \\ &= \frac{ R }{ R + R(j\omega RC + 1) + \frac{j\omega RC + 1}{j\omega C} } && \tiny\text{Multiplying top and bottom by \(j\omega RC\)} \nonumber \\ &= \frac{ j\omega RC }{ j\omega RC + j\omega RC(j\omega RC + 1) + j\omega RC + 1 } && \tiny\text{Multiplying top and bottom by \(j\omega C\)} \nonumber \\ &= \frac{ j\omega RC }{ j\omega RC + (j\omega RC)^2 + j\omega RC + j\omega RC + 1 } && \tiny\text{Expanding brackets} \nonumber \\ &= \frac{ j\omega RC }{ (j\omega RC)^2 + 3j\omega RC + 1 } && \tiny\text{Collecting terms} \nonumber \\ \label{eqn:beta} &= \frac{ j\omega RC }{ -(\omega RC)^2 + 3j\omega RC + 1 } && \tiny\text{Using the identity \(j^2 = -1\)} \\ \end{align}\]

Now if we focus on the purely resistive feedback network to the inverting pin of the op-amp, you should recognize this as the standard non-inverting gain configuration, where the gain is:

\[\begin{align} \label{eqn:op-amp-gain-non-inv} A &= 1 + \frac{R_3}{R_4} && \small \text{Gain equation for non-inverting op-amp.} \\ \end{align}\]

In steady-state oscillation, the reduction in amplitude of \(v_{out}\) to \(v_{non-inv}\) as to be exactly "countered" by the gain provided from \(v_{non-inv}\) to \(v_{out}\). This is also known as the Barkhausen criterion:

\[\begin{align} | \beta A | &= 1 \\ \left(1 + \frac{R_3}{R_4}\right)\left(\frac{ j\omega RC }{ -(\omega RC)^2 + 3j\omega RC + 1 }\right) &= 1 && \small \text{Subs. in \(Eq. \ref{eqn:beta}\) and \(Eq. \ref{eqn:op-amp-gain-non-inv}\)} \end{align}\]

Now lets aim to separate the real and imaginary terms and write it as an equation which equals 0:

\[\begin{align} \left(1 + \frac{R_3}{R_4}\right) j\omega RC = -(\omega RC)^2 + 3j\omega RC + 1 \nonumber \\ \left[ \left(\frac{R_3}{R_4} - 2\right) \omega RC \right] j + \left[ \omega^2 R^2 C^2 - 1 \right] = 0 \\ \end{align}\]

For this equation to hold true, both the real and imaginary parts must be equal to 0. If we focus on the real part first we can find \(\omega\) in terms of \(R\) and \(C\):

\[\begin{align} \omega^2 R^2 C^2 - 1 &= 0 \nonumber \\ \omega &= \frac{1}{RC} && \text{Re-arranging for \(\omega\)} \end{align}\]

Or in terms of natural frequency rather than angular frequency:

\[\begin{align} f = \frac{1}{2\pi RC} \end{align}\]

We can now look at the real part of the equation, which also must be 0. This gives us criterion for the ratio of the resistors \(R_3\) and \(R_4\):

\[\begin{align} \left(\frac{R_3}{R_4} - 2\right) \omega RC &= 0 \nonumber \\ \frac{R_3}{R_4} - 2 &= 0 \nonumber \\ \label{eqn:r3-2-r4} R_3 &= 2R_4 \\ \end{align}\]

We can plug this back into the equation for the non-inverting gain of the amplifier so see what gain this results in:

\[\begin{align} A_{\text{non-inv}} &= 1 + \frac{R_3}{R_4} \nonumber \\ &= 1 + \frac{2R_4}{R_4} && \text{Subs. in \(Eq. \ref{eqn:r3-2-r4}\)} \nonumber \\ &= 3 \end{align}\]

5.2. Realistic Wien Bridge Oscillator Circuits

There is a problem with the above Wien Bridge oscillator circuits which limits them to the realm of theory only. It all comes back to the requirement that the Wien Bridge oscillator must have a loop gain of exactly 1 to function properly (Barkhausen stability criterion). If the gain is less than this, the oscillator will not start (or will stop if already started). If it is more than 1, the oscillator output will saturate and your sine wave output will start looking more like a square wave. Wien bridge oscillators typically need a non-linear component (a component which has a resistance which changes with applied voltage) to actively limit the loop gain and keep it at 1.

Common methods of actively limiting the gain include using:

  • Incandescent bulb (resistance increases as it heats up)

  • Diodes across in parallel with feedback resistors (resistance decreases as voltage increases)

  • JFETs.

Wien bridge oscillators can also be made from a single supply[5].

5.3. Diode Limited Example And SPICE Simulation

NoteI have just used the calculated capacitance and resistance values, and not picked the nearest realistic E96 value so that it’s easier to keep track of where the values come from.

The first thing is to choose an oscillation frequency. Let’s choose \(1kHz\). We will also choose an arbitrary capacitance of \(C = 10nF\). It’s good to keep the capacitance somewhat low and use ceramic NP0/C0G type dielectrics, as they will introduce the lowest amount of distortion. This means we need a resistance of:

\[\begin{align} R &= \frac{1}{2\pi fC} \\ &= \frac{1}{2\pi 1kHz \cdot 10nF} \\ &= 15.9k\Omega \\ \end{align}\]

Let’s use diodes as our non-linear element to make sure the loop gain stays at 1. The trick is to put the diodes in parallel with a portion of the \(R_3\) resistance, and make the inverting feedback gain slightly larger than 3 before the diodes begin to conduct.

Ignoring the diodes for a moment, let’s aim for a inverting gain of 3.2 and pick an arbitrary value for \(R_4\) of \(1k\Omega\).

\[\begin{align} R_4 = 1k\Omega \\ \end{align}\]
\[\begin{align} A &= 1 + \frac{R_3}{R_4} \\ 3.2 &= 1 + \frac{R_3}{1k\Omega} \\ R_3 &= 2.2k\Omega \end{align}\]

Now, we want the oscillations at \(v_{out}\) to reach a decent proportion of the supply voltage before the diode kicks in. Since we are running of \(\pm 12V\) supplies, lets make the diodes begin to conduct at \(5V\). Let’s calculate how much current is flowing through the series leg of \(R_3\) and \(R_4\) when there is \(1V\) at the output:

\[\begin{align} I &= \frac{1V}{R_3 + R_4} \\ &= \frac{1V}{1k\Omega + 2.2k\Omega} \\ &= 0.312mA \\ \end{align}\]

Assuming the diodes begin to conduct at \(0.6V\), with \(0.312mA\) of current flowing this would be across a resistance of:

\[\begin{align} R_{3,diode} &= \frac{0.6V}{0.312mA} \\ &= 1.92k\Omega \\ \end{align}\]

So we need to split \(R_3\) into two resistors in series, one of \(1.92k\Omega\) with the diodes across it \(R_{3,diode}\) and one of:

\[\begin{align} R_{3, no-diode} &= R_3 - R_{3,diode} \\ &= 2.2k\Omega - 1.92k\Omega \\ &= 280\Omega \\ \end{align}\]
schematics
Figure 9. Wien Bridge oscillator circuit.

We can then simulate the circuit using ngspice (an open-source SPICE-like circuit simulator):

v sine out
Figure 10. SPICE simulation results for the Wien Bridge oscillator circuit shown above. Note how the circuit takes approx. 350ms to start-up, relying on noise (which SPICE does simulate) for the initial 'kick' to begin oscillating.

You can count 6 cycles in approx. 6ms, which puts the simulated frequency at:

\[\begin{align} f &= \frac{6}{6ms} \\ &= 1kHz \end{align}\]

which agrees well with what we designed for!

You can download the following assets:

5.4. JFET Gain-Limited Example

Using a JFET to partially switch in another resistor in parallel with the ground-connected gain resistor \(R_4\) in the Wien bridge oscillator circuit is another method for preventing the oscillator for saturating (as opposed to the diode method shown above). This JFET gain-limited approach is meant to introduce less distortion than the diode-limited approach above, as the RC circuit driving the JFET’s gate does not change much over a single cycle (assuming a suitable large RC time constant is picked).

Schematics of this technique are shown below, with the circuit setup to oscillate at the same frequency as the diode gain-limited variant mentioned above.

schematics
Figure 11. A practical Wien bridge oscillator circuit using a JFET (Q1) as the non-element to actively limit the gain and prevent the oscillator from saturating.

Note the diode and RC circuit controlling the JFET’s gate. When the circuit is first powered up, the gate is at ground and hence the gate-source voltage \(V_{GS} = 0V\). Therefore the JFET is almost fully on (remember, JFETs are depletion mode devices), and \(R_5\) is in parallel with \(R_4\), increasing the gain of the op-amp. As the output voltage beings to oscillate, on the negative part of the cycle, diode \(D_1\) will conduct and charge the RC low-pass filter \(C_3\) and \(R_6\) with a negative voltage. This will decrease \(V_{GS}\) below \(0V\), which will begin to turn the JFET off. This will then increase the equivalent resistance of \(R_5\) in parallel with \(R_4\) and decrease the op-amp gain. This will continue until the system reaches a steady-state and oscillates forever.

And below are the simulation results for this circuit:

v sine out
Figure 12. SPICE simulation results for the JFET gain-limited Wien bridge oscillator circuit shown above. Notice the ringing on the gain that takes a few hundred milliseconds to stabilize.

6. Ring Oscillators

A ring oscillator (a.k.a. RO) is an electronic oscillator made up of a chain of an odd-number of digital logic NOT gates. The output of the last NOT gate is fed into the input of the first. The oscillator relies on the propagation delay from the input of the first NOT gate to the output of the last NOT gate to set the oscillation frequency.

schematic
Figure 13. The world’s most basic ring oscillator, using one NOT gate.

6.1. Simulation

simulation
Figure 14. KiCad schematic of a three stage ring oscillator (ready for simulation).

I ran into convergence issues when using the 74HCU04 SPICE model I found floating around on the internet (located in a file called [74HCng.lib](ring-oscillator-single/74HCng.lib)). Simulating one instance of the inverter worked fine, but I got the dreaded doAnalyses: TRAN: Timestep too small error when connecting the second/third/e.t.c inverter in the ring. The convergence issue still occurred even when driving the first inverter instance from a slow frequency PULSE voltage source (rather than the driving it from the output of the last inverter), indicating it wasn’t a problem with the ring structure.

I then looked harder around the internet and found the MyHCU04 SPICE model [posted on Google Groups by the late Jim Thompson](https://groups.google.com/g/sci.electronics.basics/c/k93fFgwnw-s?pli=1):

On popular request, 74HCU04 Spice Model rescued from 1993 archives and posted on the Device Models & Subcircuits page of my website…​

This SPICE model for an inverter fixed the convergence issues I was having (if anyone else is interested in this file, I’ve saved it [here](ring-oscillator-triple/MyHCU04.lib)). Hurrah!

out
Figure 15. It’s working! Simulated output of the three stage ring oscillator schematic shown above.

7. Manufacturer Part Numbers

  • SiT1533AI: SiTime standard clock oscillators and MEMS oscillators.

  • SiT1533AI-H4-D14-32.768G: MEMS clock oscillator.

References


Authors

Twitter

Related Content:

Tags:

comments powered by Disqus