PST Logo

SPICE Analysis of Crystal Oscillators
Mike Monett
Jun 26, 2006


Table of Contents

  1. Introduction
  2. Calculating the Crystal Parameters
  3. SPICE Transient Analysis
  4. Setting the Crystal Power Level
  5. Oscillator Startup
  6. Measure Loaded Q
  7. Frequency and Phase Response
  8. Estimating the Startup Time
  9. How It Works
  10. The Initial Startup Transient
  11. Oscillator Limiting
  12. Conclusions
  13. References
  14. Links
  15. Update List

Introduction

Crystal oscillators are one of the most widely used circuits, but the waveforms are extremely difficult to analyze due to the high Q of the quartz resonator. This produces a long startup delay before the oscillator reaches steady-state and the waveforms can be analyzed. There are many reasons why a detailed analysis is essential. Here are some examples:

  1. verify the power delivered to the crystal is correct
  2. adjust the feedback components to optimize the tank Q
  3. ensure the base-emitter voltage is not close to reverse breakdown
  4. ensure the signal is not clipped by forward biasing the base-collector junction
  5. ensure the transistor is not driven into saturation
  6. confirm the oscillator can be adjusted to the correct frequency with variations in component tolerances
  7. verify all requirements are met throughout the range of typical crystal and semiconductor parameters

In some cases, the startup delay is too long to allow practical analysis, and the circuit must be simulated with a low-Q version of the crystal. This produces inevitable discrepancies between the simulated results and the actual circuit, which can be difficult to reconcile.

This paper describes a simple method of starting a high-Q crystal oscillator at full amplitude, where it quickly settles into steady-state operation. The new method can provide high resolution waveforms over 4,000 times faster than before.

Calculating the Crystal Parameters

The design starts with obtaining the crystal parameters. Most of the needed ones are available from the manufacturer's specification or can be estimated. We need the crystal Q, load capacitance, series resistance, and shunt capacitance.

A free equation solver by Roger Schafly makes it easy to calculate the crystal inductance and capacitance. It also allows you to change any parameter and have it solve for the remainder, so you can easily modify the crystal parameters for worst-case analysis. The program is called Mercury and is available at the sites listed in the reference.

Here is the Mercury parameter file for a variety of crystals. We will solve the equations for a 1MHz crystal.

; Typical Crystal Values:
; Freq	  Mode     L1            C1        R1        C0        Q
; 32768   fund   4448 H       5.3e-15    11200      1.84pf    81780
;  1 MHz  fund    3.5 H       0.007 pf     340      3 pf      64679
; 10 MHz  fund    9.8 mH      0.026 pf       7      6.3 pf    87964
; 30 Mhz  3rd    14.9 mH      0.0018 pf     27      6.2 pf   104021
;100 MHz  5th     4.28 mH     0.0006 pf     45      7   pf    59760
;150 MHz  5th     1.9 mH      0.0006 pf     65      4.2 pf    27000

; Variables:
; C0 = Crystal Shunt Capacitance
; C1 = Crystal Motional Capacitance
; CL = Crystal Load Capacitance
; FP = Parallel Resonant Frequency
; FS = Series Resonant Frequency
; L1 = Crystal Motional Inductance
;  Q = Crystal Q factor
; R1 = Crystal Series Resistance

; Equations:
  C1 = 1 / (Q * W0 * R1)		; motional capacitance
  FP = FS * (1 + (C1 / (2 * (C0 + CL)))); parallel resonant frequency
  L1 = (Q * R1) / (W0)			; motional inductance
  pf = C1 * 1e12			; C1 in pf for easy SPICE entry
  W0 = 2 * pi * FS			; series resonant frequency

; Solve for these parameters:
  C0 = 3e-12		; crystal shunt capacitance
  CL = 27e-12		; crystal load capacitance
  FP = 1e6		; parallel resonant frequency
  Q  = 64679		; crystal 'Q' factor
  R1 = 340		; series resistance

The solution is

  C0 = 3.000000000000000E-12
  C1 = 7.2381954594622169E-15
  CL = 2.700000000000000E-11
  FP = 1000000.0000000000
  FS = 999879.377960441
  L1 = 3.5003762943696892
  pf = 0.0072381954594622176
  Q  = 64679.000000000000
  R1 = 340.00000000000000
  W0 = 6282427.4165529059

SPICE Transient Analysis

We enter R1, L1, C1, C0 and CL in the schematic in Fig. 1. The feedback capacitors C3 and C4 are chosen according to the crystal frequency and series resistance. It is desirable to keep C3 at two to five times the value of C4 to help control the shape and timing of the collector current pulse, [1], [2], and also to limit the amplitude of reverse bias applied to the base-emitter junction of Q1. Resistor R5 suppresses high frequency parasitic oscillations due to stray inductance and circuit capacitance.

NoAlt

Fig. 1 Oscillator Schematic

Setting the Crystal Power Level

Crystals have a maximum power specification, which is the power level dissipated in the crystal series resistance, R1. The feedback capacitors, C3 and C4, plus emitter resistor R6, set the desired power level.

Running at maximum power minimizes phase noise, but increases the aging rate. Most applications use lower power to minimize long-term drift and accommodate normal variations in manufacturing tolerances. If the power is too low, the oscillator may not start reliably.

Since the crystal resistance can vary from 1/2 to 2 times the nominal value, selecting the correct power level helps guarantee the oscillator will function with worst-case parameter tolerances, without destroying the crystal at the high end.

Simple Ohms Law gives the power dissipated in the resistor, but you have to remember to convert between peak and rms. Using .IC V(L1)=0.340V in this example results in a power of 240uW, which is a safe level for a 1 mW HC49U crystal. Other types may have lower limits, such as 0.5 mW or 0.1 mW for HC49S and most SMD crystals. 32KHz watch crystals usually specify a maximum power of 1 microwatt and run at 0.1 microwatt.

With such power low levels, it is desirable to verify the power level of a circuit in SPICE to avoid destroying the crystal. Previous methods were very time-consuming, so the full simulation was rarely done.

Oscillator Startup

If we disable the .IC statement and run Transient Analysis, the circuit will take a very long time to begin oscillating, as shown below in Fig. 2. There is no activity even at 200uS. Without help in getting started, the circuit is impossible to analyze due to the high crystal Q.

NoAlt

Fig. 2 Oscillator Startup

Measure Loaded Q

We can estimate the startup time needed if the .IC command were not available. First, we need to measure the loaded Q of the tank. Fig. 3 shows the modifications to the schematic needed for Frequency Analysis. The feedback from the emitter of Q1 is removed, and a new resistor, R7, is added to restore the impedance presented to the crystal. We inject a signal at the bottom end of C4, and look for it to appear at the crystal resistance, R1.

NoAlt

Fig. 3 Schematic to Measure Loaded Q

Frequency and Phase Response

The amplitude response is shown in the top trace (blue) of Fig. 4. It is centered on 1 MHz by increasing the crystal load capacitor, CL, to 30.51 pf. We make the bandwidth measurement by using the half-power points located 20 * log(sqrt(2)) = - 3.01 dB down from the peak response. One marker (yellow) is placed on the peak. Another marker is placed at the upper - 3dB point. The annotation under the graph shows the frequency delta is 9.414 Hz, so the total 3dB bandwidth (BW) is 2 * 9.414 = 18.828 Hz.

The loaded Q is Fr / BW = 1,000,000 / 18.828 = 53,112. This is a relatively small drop from the unloaded Q of 64,679, so the oscillator is not loading the crystal very heavily. It could be a problem, however, with higher Q crystals, or circuit changes that reduce the value of bias and emitter resistances reflected into the tank.

NoAlt

Fig. 4 Frequency and Phase Response

The bottom trace in Fig. 4 (red) shows the phase response of the network. Note that it crosses zero degrees at 1,000,001.73 Hz, which is 1.71 Hz higher than the peak amplitude response shown above.

The Barkhausen criterion for oscillation requires a loop gain greater than unity, and a phase shift of zero or 360 degrees. When both conditions are met, the loop will oscillate at the frequency that produces zero phase shift, instead of the frequency that produces maximum loop gain. So if everything were perfect, this is the frequency the oscillator would run at.

Estimating the Startup Time

If we remove the feedback from an oscillating tank, the amplitude decays exponentially. The relationship between the Q of the tank and the ringdown time constant, tau, is Q = pi * fr * tau, as shown in Fig. 5. For our purpose, it is easier to work with the number of cycles in one time constant: N = Q / pi. The example in Fig. 5 shows about 9.5 cycles in one time constant, so the Q = 9.5 * pi = 29.84.

NoAlt

Fig. 5 Amplitude Ringdown. The amplitude decreases by a factor of e for every tau of time. [3]

The oscillator operates in a similar manner during startup. If we give it a push by injecting a pulse into the tank, we can get a rough estimate of the number of cycles needed to reach steady state. In our example, the loaded Q is 53,112, so the number of cycles for one time constant is N = Q / pi = 53,112 / pi =16,906 cycles.

If we use a rough rule of thumb and wait 5 time constants, we would need approximately 16,906 * 5 = 84,530 cycles, or about 84 milliseconds. This compares favorably with the typical startup specification of 50 to 100 milliseconds for crystal oscillators in this frequency range.

Please note this is just a rough estimate, and is affected by many variables not included here. But it is clear it would take a very long time to get the oscillator running and settled, and this time would have to be repeated for every modification of the circuit parameters. This is why designers often choose to simulate with low-Q versions of the crystal, even though the results may be considerably different from the actual circuit.

However, we can now eliminate this problem by initializing the inductor current with the .IC command. The Transient Analysis may need only 10 to 20 cycles, which is perhaps 4,000 to 8,000 times faster than before.

How It Works

We use the .IC command to set an initial condition that produces the desired current through the inductor. When Transient Analysis begins, the oscillator will start instantly, and after a brief burble at the beginning, it quickly settles down to steady state so we can view the waveforms. We can set the initial current to 1 mA by setting the voltage at node VL in Fig. 1 to 0.340 volts. Note the initial voltage has no effect on the DC operating point of the circuit, since the crystal motional capacitance C1 isolates it from the rest of the circuit.

When SPICE has calculated the DC operating point and begins Transient Analysis, it removes the initial voltage set by the .IC command. The inductor tries to keep the same current flowing, but it is in series with the crystal motional capacitance, C1. Thus the circuit begins oscillating at the point in the cycle where the voltage across the inductor is zero and heading in the opposite polarity from the initial voltage.

The Peak Search feature in Microcap 8 allows you to go from one peak to the next and measure the amplitude with high resolution. The Maximum Time Step can be set to a small portion of a cycle (0.1% or less) to minimize the quantization error and show if the amplitude is increasing or decreasing from one cycle to the next. You can then adjust the feedback or initial current as desired. The small time step provides high resolution which is essential for accurate waveform analysis, but it could not be used before since it slows the analysis. However, this is not a factor when you only need a dozen cycles or so.

Fig. 6 shows the waveforms 200uS after the start of Transient Analysis. From top to bottom, these are the voltage across the crystal, the emitter voltage, the voltage across the series resistor, and the inductor voltage. The schematic is also available here for the location of the waveform names in the plot.

The positive peaks of the voltage across R1 (purple trace) are displayed. These are taken at 194uS and 199uS, and confirm the amplitude is close to the 340 millivolts set by the .IC statement. The amplitude increases 2.978uV in 5 cycles, which is a change of 0.596uV per cycle, or 0.596e-6 / 340e-3 = 1.75 ppm per cycle. The oscillator is very close to steady-state.

This demonstrates how the resolution of the Peak Search feature in MicroCap easily shows if the amplitude is increasing or decreasing from cycle to cycle. This allows you to quickly set the desired parameters for steady state operation.

NoAlt

Fig. 6 Oscillator Waveforms at 200uS

Note also the peaks of the signal across R1 occur slightly later than the one microsecond period of the crystal, and are about 280 picoseconds late. This shows the oscillator is running slow by about 0.28e-9 / 200e-6 = 1.4 ppm. This may be partly due to the setting of the crystal load capacitor, CL, which was increased from 27pf to 30.51pf during the Q measurement in Fig. 4 to center the amplitude response at 1.000 MHz. This illustrates the high precision available in MicroCap SPICE, and the ability to correlate measurements done in different analysis modes.

The Initial Startup Transient

The initial transient at the beginning of Transient Analysis dies out quickly and has little effect on the oscillator phase or amplitude. Fig. 7 shows the tank waveforms during the first 10uS of operation. Note the startup transient in the emitter waveform, V(Q1E), dissipates in the first few cycles. The schematic is available here for the location of the waveform names.

The voltage across the crystal series resistance, V(R1), starts at 340mV and continues as a sine wave. Note also the peaks line up with the 1uS graticules throughout the display, indicating the brief startup transient has negligible effect on the oscillator. This is due to the high Q of the crystal, which prevents it from changing phase or amplitude quickly.

As shown in the bottom trace in Fig. 7, the voltage across the inductor, V(L1), starts out at zero and goes negative. As described earlier, the .IC command initializes the tank to the point in the cycle where the current through the series resistor is maximum, and the voltage across the inductor is zero and heading negative.

NoAlt

Fig. 7 Startup Transient

Oscillator Limiting

Most oscillators limit the amplitude by clipping, for example, when the base-collector junction becomes forward biased or the transistor saturates. This increases the phase noise in the output signal, and it can drive the crystal at a dangerously high power level with the normal manufacturing tolerances in crystal parameters.

The circuit shown in this paper has the advantage that we can control the power dissipation in the crystal by adjusting the emitter resistor, R6, and the feedback divider capacitors, C3 and C4. Notice the emitter waveform in the blue trace, Q1E, second from the top, swings from about 1.4 to 2.9 volts, and the positive peak is not clipped as in other oscillators.

Conclusions

Previous methods of starting oscillators injected a step or pulse into the tank. This rarely brought the oscillator to full amplitude, and often created a separate transient that took a long time to settle. The long startup and settling time often forced the designer to analyze with a low-Q version of the crystal, which can yield discrepancies that are difficult to reconcile. Another option was to forego the analysis entirely, which risked serious problems in manufacturing and customer satisfaction.

A new method uses the SPICE .IC command to introduce exactly the correct amount of energy that will appear in the tank when the circuit is oscillating, and allows it to reach steady state in very few cycles after the analysis begins. As a result, it is no longer necessary to wait hundreds or thousands of cycles to allow the oscillator to reach steady state, and Transient Analysis may need only a dozen cycles or so. It can be done with very fine time resolution to give the high accuracy needed for waveform and timing analysis.

The new method is very fast, especially considering the same analysis may have been impossible before due to the long startup and settling times. It can be over 4,000 times faster, and unlike previous methods, it is relatively independent of the Q of the crystal.

The technique of initializing the current in the tank inductor works in other types of oscillators, such as the Butler, Colpitts and Pierce, as well as other types of high-Q resonators that use an LC model, such as ceramic and SAW. Depending on on the circuit arrangement, it may be necessary to use two .IC commands to set the initial voltage at two points in the circuit.


References

  1. A. Hajimiri and T. H. Lee, `A General Theory of Phase Noise in Electrical Oscillators,' IEEE Journal of Solid-State Circuits, vol. 33, no. 2, pp. 179-194, Feb. 1998.

  2. T. H. Lee and A. Hajimiri, `Phase Noise in Oscillators, A Tutorial,' Invited Paper, IEEE Journal of Solid-State Circuits, vol. 34, no. 3, pp. 326-336, March 2000.

  3. The graph in Fig. 5 is used with permission from "Mechanics Laboratory: Measuring the Mechanical Energy Dissipation of a Pendulum", by Joshua R. Smith, Max-Planck-Institute fur Gravitationsphysik, http://www.aei.mpg.de/~jrsmith/files/qlab.pdf

Links

  1. Roger Schafly's Mercury equation solver:

    http://archives.math.utk.edu/software/msdos/calculus/mrcry209/.html
    http://archives.math.utk.edu/software/msdos/calculus/mrcry209/mrcry209.zip

  2. Mercury Crystal Oscillator Calculations: xtal.mer

  3. Spectrum Software MicroCap 8 SPICE: http://www.spectrum-soft.com/index.shtm

  4. Related MC8 SPICE files:

    Transient Analysis: clap02.cir
    Loaded Q Measurement: clap03.cir