# Measuring Oscillators Stability

When I started being interested in Precision Timing, I wanted to know the various methods available to verify a given oscillator's stability.
I asked a question on the time-nuts mailing list (Ref 1) and did I get responses!!!
The following is a summary of what I got.

## What is stability for an oscillator?

That sounds like a simple question. After all, an oscillator is a simple circuit, it provides a signal at a single frequency and at a stable level.
Variations in frequency (and in level) can be very short term, long term or both. Depending on what you are interested in, measuring these variations usually requires different methods.
The definitions below are not absolute, they are intended as a guideline.

### Very Short Term Variations

Very short term variations occur within a second or less. They usually manifests themselves as frequency (or phase) modulation (or amplitude modulation) as used by broadcast stations to send music and voice programs, and they are usually measured in the frequency domain using spectrum analyzers or phase noise meters.

### Short Term Variations

Short term variations occur between one second and several minutes to an hour. Usually we consider short term variations to include the effects of temperature variation, but to exclude the effects of aging for instance.

### Long Term Variations

Long term variations go from minutes to hours or days, sometimes months or more.
This page focusses on short and long term variations, which are usually measured using a frequency counter or a universal counter, sometimes with other equipment.
Please note that the presence of Amplitude Modulation may affect Frequency Modulation or more generally Frequency Stability measurements.
Some test methods are more effective than others at eliminating amplitude modulation effects from frequency stability measurements. This applies to all types of variations, short and long term.

## Acquiring the information

Frequency Counters, or more generally Universal Counters are instruments designed to measure oscillators, so you will need one of those, with a computer interface port of some sort. In most cases, that will be a GPIB (IEEE-488, or HP-IB) port. I have a page about interfacing GPIB equipment (Ref 2) which I recommend you read if you want to do that.
I am familiar with several types of GPIB equipped Universal Counters, the HP 5316A, the HP 5334B and the HP 5370A. The HP 5370A is relatively expensive on eBay compared to the other two, but either will work. The HP 5328A also has the capability to do Time Interval measurements, and some units have the GPIB option, but I have no personal experience with this model. There are lots of other models.
Assuming that the problem of getting the data from the instrument to the PC is resolved, there are other issues to address before selecting a suitable test procedure.
The test procedure will depend on the stability of the oscillator you are trying to measure.

## Measuring free running oscillators

If the oscillator's stability is worse than that of an average crystal oscillator (free running VCO for instance), you can probably simply measure the frequency with the frequency counter and log it to a file. The HP 5328 and HP 5316 have 0.1 Hz resolution (at 10 MHz, with 10 seconds gate time, in overflow mode), and that should be sufficient for a free running VCO.
The others have 0.001 Hz (HP 5334) and 0.0001 Hz resolution (HP 5370). Be aware that once the data is in the PC, you can do manipulations that may increase the resolution of the final measurement (by averaging a number of readings).
Please note that while all frequency counters use a crystal controlled time base for frequency reference, they are not all created equal and as a minimum should be allowed to warm up and stabilize before making any measurement. Check the specs and if possible have the instrument calibrated before assuming it is "perfect".
So if you are trying to measure the stability (drift) of a free running oscillator, you can probably stop reading here.

## Measuring the stability of crystal-referenced oscillators

In general terms, the only way to know how stable an oscillator is is to compare it to a reference of some sort. Let's put aside the measurement method where the signal is fed through a delay line and mixed with itself. This is used to measure phase noise (which is a type of short term variation), but is not the best method to measure long term drift or uncertainty (because the delay line is temperature sensitive, and it is impractical to make a delay line long enough to measure slow variations such as drift).
Since the measurement is a comparison, you will measure the sum of the variations between the two oscillators and you won't be able to discriminate between the two. So you must have a known good, stable frequency reference to check your signal against. In many cases, that will be the reference built into the counter, or it could be an external reference, such as a GPS Disciplined Oscillator (GPSDO) or a Rubidium (or Cesium if you can afford it) oscillator for instance.

If the oscillator you want to check is fairly stable, such as a PLL with a crystal reference, you must make sure your frequency counter has a time base of better stability than the device under test (DUT). All HP counters listed above have a high stability timebase option (either the HP 10544A or the newer HP 10811A, which are both excellent). If you have one of those, you are probably OK. If you have the regular time base, check the specs because if your oscillator under test has stability comparable to the time base in counter, you won't know for sure what you are measuring.

Assuming the oscillator under test is a crystal referenced PLL, and assuming your counter has a time base at least 10 times more stable than the oscillator you are trying to measure, there are several things you may want to measure.

If you simply want to know the long term drift (over several hours), you may be able to use the direct frequency measurement method over a long period of time. Make sure the equipment is at stable temperature, otherwise you will be measuring stability over temperature, which may or may not be what you want to do :-)

For the more curious out there, there is a great tutorial on crystal oscillators by John Vig, that used to be available from the IEEE web site (Ref 6) but as of Dec 06, the link appears dead. I had downloaded a copy which is available on this site (Ref 7).

Here are a couple of charts from the presentation, useful to understand the main mechanisms behind crystal oscillators frequency instabilities:

#### TimeDomainStability-Vig.png

The level of noise one can measure is a function of the observation window (the time interval between measurements).

The left part is the short term noise, essentially white noise, with a typical 1/f power density drop, then the plateau is due to flicker noise and is essentially constant over a range of frequencies (or time periods), then at the right is the aging and random walk chanracteristic.

The short term variations can be better illustrated by this second chart:

#### FrequencyNoise-Vig.png

Increasing the averaging time is equivalent to filtering, and it gets rid of a lot of the shorter term components. Some oscillators have good short term characteristics but show more long term drift and random walk (crystal oscillators, or XOs for instance) and others have more noise in the short term but better long term characteristics (Cesium or GPS for instance).

## Allan Deviation

If you are more interested in short term stability (the wander of the oscillator around its frequency over seconds or minutes, or maybe a few hours), you probably will have to use a statistical tool called Allan Deviation. Search Google for "Allan Deviation" and you will find lots of links. My FAQ #2 has an interesting exchange with Tom VanBaak explaining Allen Deviation in easily understood terms. Also, Ulrich Bangert has written a nice, free program Plotter (Ref 3) that will plot the data and compute the Allan Deviation from a table of Time Interval measurements.

The Allan Deviation (Ref 9) is a statistical tool that calculates how accurately you can predict the occurrence of the next pulse, transition or event, based on measurements made on previous pulses, transitions or events.

For instance, you may have an oscillator that drifts in a predictable way, and it's Allan Deviation would be good (low), or you may have an oscillator that has little drift on average, but wanders a lot around its nominal frequency (phase noise), and its Allan Deviation would be bad (high). In either case, the Plotter program will allow you to display the data so that you can easily visualize both types of variations.

The Allan Deviation is typically computed from a series of Time Interval (TI) measurements against a reference oscillator. Any one of the counters listed above can do this measurement, which simply is the measure of the delay between a signal on Input A (Start channel) and another signal on Input B (Stop channel).

Please note the Plotter program can work with either frequency data or Time Interval data.

***IMPORTANT***
To use the Time Interval method, the signals (the time base and the signal from the DUT) do not need to be at the same frequency, but they must be harmonically related (for instance, one at 1 kHz and one at 1 Hz, or 1 kHz and 500 Hz). If the signals are not at the same frequency, put the lower frequency signal on the Start channel.

If they are not harmonically related, you may have to divide them until you find the greatest common factor between the two (3rd grade math, should not be too hard :-) Building dividers may be more work than you are prepared to do, but the good news is that dividers will not significantly affect the precision of the TI measurement (as long as the dividers work properly). The idea is to get two frequencies that are pretty close to each other so that you can use the TI method.

If the oscillators are not phase locked to each other or to a common reference, they will drift relative to one another. So, if you try to do a Time Interval measurement between, for instance, two 10 MHz signals that drift apart, the time interval will increase until it reaches the period of the signal, then recycle to zero and drift again. This is called "cycle wrapping" or "cycle folding". This will confuse the analysis tool. The more apart the signals are, the more difficult it will be to use the data.

So to do TI measurements between drifty oscillators, you are better off dividing down the signals so that it takes longer for the signals to be apart by one full period. How much you need to divide depends on how far apart the frequencies are and for how long you want to collect data. A rough order of magnitude is as follows: assume you compare two 10 MHz signals that are 1 Hz apart, that's 10e-7 difference, so if you divide both signals down to 1 Hz, it will take 10e7 seconds for them to drift apart by one full second, that's 115 days, so in most cases you won't need nearly that much division.

## Practical Example

I have used an HP 5334B Universal Counter (Ref 4) connected to a computer via the GPIB port to compare the stability of a 10 MHz crystal oscillator to the 1 PPS (Pulse Per Second) output of a GPS Disciplined Oscillator (see FAQ-2.php page).

I fed the 1 PPS from the GPS to the Start channel of the counter, and I divided down the 10 MHz from the OCXO by 256 (two 4 bit counters 74F161) and fed that signal (39.0625 kHz) to the Stop channel, so that cycle wrap would not occur too often.

The computer program simply takes one measurement of the Time Interval every few seconds and saves the data to a file that is fed to the Plotter program. The file format is simply one reading per line, as shown below:

``` .0000000584
.00000005848
.00000005846
.00000005844
.00000005887
.00000005846
```

Since the 10 MHz crystal oscillator was not phase locked to the GPS (and it was off by about one Hz), the Time Interval did cycle wrap every few hours. That was not excessive for the Plotter program, which has capability to clean up such artifacts. Typically, you connect the slower oscillator (which preferably should be the reference, but it will work even if it's the DUT) to the Start Channel, and the faster oscillator to the Stop Channel of the counter.

These plots are intended to show the features of the Plotter program.

HP10811-Thunderbolt-1_raw.png

This plot is the raw data from the HP 5334B, as captured by my GPIB Control program. It shows the HP 10811 having quite a bit of drift (it had only been turned on for about 30 minutes when I started data collection, which ran for about 8 hours). The sample rate was once every 2 seconds in that run. and there are 14075 data points. Since the OCXO was not fully warmed up, and the 10 MHz was only divided by 256 before being fed to the Stop channel, there was significant drift and there were several occurences of cycle wrapping.

Using Plotter's Step Removal tool, it was easy to remove the cycle wraps:

HP10811-Thunderbolt-2_no_steps.png

Using Plotter's Drift Removal tool, it was easy to remove most of the thermal drift due to the fact that the OCXO had only been on for a short time.
Plotter lets you try different types of curve fittings, but does not automatically pick the best match. It does compute the parameters for the curve fitting model you chose though. In most cases, it's easy to select the best fit visually.

HP10811-Thunderbolt-3_remove_drift.png

Here is the final plot with most of the drift removed and the result of the Allan Deviation calculation.

HP10811-Thunderbolt-5_final.png

Please note these plots were made in far less than ideal conditions. They are only here for illustration. The Trimble Thunderbolt GPSDO had been on for a couple of hours only (it had completed self survey) and the HP 10811 was barely warmed up. HP recommends at least 24 hours of warm-up before measuring stability.

Here is another plot taken later, with the HP 10811 fully warmed-up. This plot spans about 4.7 hours (8517 data points taken at 2 seconds spacing).

HP10811-Thunderbolt-6_final.png

To see what HP 10811's can do under optimum conditions (and when compared to state of the art frequency standards), check Tom Van Baak's HP 10811 Stability Comparison page (Ref 5).

## Conclusion

In practical terms, the best way to compare an unknown oscillator to a reference oscillator will be to divide down your reference signal and your test signal sufficiently so that cycle wrap does not occur too often. How much division will depend on how stable the DUT is. Use the guidelines above to figure this out.

If the oscillator you are testing is very clean, the clock shaper and dividers must be designed accordingly so that they do not contribute appreciably to the noise of the oscillator under test. The clock shaper is the circuit that converts the sinewave from the oscillator to a digital signal suitable to drive the dividers. There was a very interesting thread about this on the time-nuts mailing list recently, and I have planned to make a web page out of the best parts of that thread, come back on occasion to see if it's up.

For examples of clock shaper circuits, see Bruce's related pages (Ref 8).

So, there you have it. The HP Universal counters have very interesting capabilities to check the stability of oscillators, but depending on how stable the oscillator under test is, you may have to build some dividers to be able to quantify its stability using the Allan Deviation.