Sei sulla pagina 1di 4

adev1 - Allan Deviation Statistics

LeapSecond.com :: Tools
adev1.exe - Allan Deviation Statistics
14-Mar-2006

Description
The Allan Deviation (or Allan Variance) is a key statistic for analyzing the performance and stability of clocks.
There are several programs that compute Allan deviation statistics, including professional tools like Stable32.
Below is a very simple command-line tool that I use for many oscillator stability measurement applications.
As with most clock statistics programs, a plain text file of sequential raw phase measurements is all that is
required to use adev1. The units don't have to be seconds (adev1 can scale input data) and the data rate
does not need to be 1 Hz (adev1 can scale to data collected at slower sample rates). Where you get the file
is a separate issue - some people get phase data over GPIB, or USB, or LAN, or RS232, or floppy, etc. I
usually keep all my data collection programs separate from data analysis. This tool is an analysis tool.
Adev1 works on everything from pendulum clocks to hydrogen masers. The only restrictions are that the data
must be phase (time interval) rather than frequency; the data must be sequential (no gaps); and the data
should be free from glitches or outliers.

Sample 1
In this first example the 1 PPS from a GPSDO is measured with a HP 53132A time interval counter and the
9600 8N1 RS-232 serial output captured to a file. The data file looks like this:
C:\tvb> wc <log23202.txt
1.016 MB, 1041 KB, 1065035 chars, 178272 words, 87840 lines
C:\tvb>
1.239,7
1.240,2
1.240,4
1.239,9
1.240,3
1.239,6
1.240,3
1.239,6
1.240,1
1.240,1

head log23202.txt
us
us
us
us
us
us
us
us
us
us

In time interval mode the 53131/53132A format includes a units suffix (us for microseconds and s for
seconds). Most models also insert commas every three digits. Also in this example 53132A statistics were
enabled so every N seconds the data is interrupted with five lines of text and numbers such as:
1.239,6 us
1.240,1 us
1.239,6 us
N
: 300
STD DEV: 0.000,319 us
MEAN
: 1.240,169 us
MAX
: 1.241,0 us
MIN
: 1.239,4 us
1.240,3 us
1.239,6 us
1.240,3 us

http://www.leapsecond.com/tools/adev1.htm[2011-5-3 15:26:15]

adev1 - Allan Deviation Statistics

Since I use adev1 frequently with the serial output of these HP counters, the program automatically handles
the commas (removed), the time units (data is scaled), and the statistics lines (quietly ignored). Thus,
adev1 can be used directly on raw HP phase data files with no manual editing. Here is an
example:
C:\tvb> adev1 1 <log23202.txt
**
**
**
**

Sampling period: 1 s
Phase data scale factor: 1.000e+000
Total phase samples: 86400
Normal and Overlapping Allan deviation
1
2
5
10
20
50
100
200
500
1000
2000
5000
10000
20000

tau,
tau,
tau,
tau,
tau,
tau,
tau,
tau,
tau,
tau,
tau,
tau,
tau,
tau,

6.0265e-010
2.8217e-010
1.0314e-010
5.3691e-011
2.6617e-011
1.1052e-011
5.6781e-012
3.0238e-012
1.3804e-012
8.0011e-013
6.0141e-013
2.3656e-013
1.4069e-013
8.3392e-014

adev,
adev,
adev,
adev,
adev,
adev,
adev,
adev,
adev,
adev,
adev,
adev,
adev,
adev,

n=86398,
n=43198,
n=17278,
n=8638,
n=4318,
n=1726,
n=862,
n=430,
n=171,
n=85,
n=42,
n=16,
n=7,
n=3,

6.0265e-010
2.8094e-010
1.0339e-010
5.4296e-011
2.7072e-011
1.1085e-011
5.7003e-012
2.9821e-012
1.3755e-012
7.9332e-013
5.1156e-013
2.5303e-013
1.5420e-013
1.0629e-013

oadev,
oadev,
oadev,
oadev,
oadev,
oadev,
oadev,
oadev,
oadev,
oadev,
oadev,
oadev,
oadev,
oadev,

n=86398
n=86396
n=86390
n=86380
n=86360
n=86300
n=86200
n=86000
n=85400
n=84400
n=82400
n=76400
n=66400
n=46400

Both normal Allan deviation (adev) and overlapping Allan deviation (oadev) are calculated. Statistics are
calculated for as many averaging times (tau) as possible given the amount of raw data. By default the
stability for several tau per decade is calculated.
The output also includes the number of sample pairs (the n= number) used by the calculation; usually large
numbers that can be ignored or small numbers that indicate the accuracy of the calculations is limited. A rule
of thumb is that n should be 4 or greater.

Parameters / Options
A file of raw phase data doesn't convey the time interval between measurements. In the raw files seen above
there is no way to tell, for example, if they are 1 second samples, or 60 second samples, or 1000 seconds.
Thus you must tell adev1 what the sample period is. That is the required first parameter.
Not all raw phase files contain data with units of seconds. If you see a file with numbers like 1.234e-6 you
can guess the units are seconds (1.234 microseconds) but a file with numbers like 1.234 could be seconds
or milliseconds or microseconds or nanoseconds or cycle periods or whatever. The second parameter
permits you to scale the input data by a constant factor so that the data is converted into standard units of
seconds as it is read by the program. This parameter is not required for data with time unit suffixes (such as
output from a 53131A).
Many Allan deviation tables or graphs show data points at each decade; for example, at 1 second, 10
seconds, 100 seconds, etc. When plotting it is sometimes nice to have more than one statistic per decade.
Some Allan deviation tools produce data points for tau 1, 2, 4 and 10, 20, 40, etc. The third parameter can be
use to obtain as many or as few data points per decade, including the extreme of one data point for every
possible tau.

Sample 2

http://www.leapsecond.com/tools/adev1.htm[2011-5-3 15:26:15]

adev1 - Allan Deviation Statistics

The next example is a data file from a TSC 5110A time interval analyzer measuring a free-running Austron
2110B. Using a 5 MHz reference the 9600 8N1 RS-232 serial output is a set of phase (integer and fractional
period) values at a data rate of 1 Hz. Units are 200 ns (200e-9), the period of 5 MHz frequency, so the raw
data must be scaled.
The raw data file looks like this:
C:\tvb> dir log24121.txt
LOG24121 TXT

5,047,477

03-15-06 11:47a log24121.txt

C:\tvb> wc <log24121.txt
4.509 MB, 4618 KB, 4728178 chars, 319299 words, 319299 lines
C:\tvb> head log24121.txt
0.0952987
-0.0859472
-0.2671862
-0.4484271
-0.6296708
-0.8109045
-0.9921413
-1.1733808
-1.3546209
-1.5358569

Here is the adev1 output (note use of period and scale parameters):
C:\tvb> adev1 1 200e-9 <log24121.txt
**
**
**
**

Sampling period: 1 s
Phase data scale factor: 2.000e-007
Total phase samples: 319299
Normal and Overlapping Allan deviation

1
2
5
10
20
50
100
200
500
1000
2000
5000
10000
20000
50000
100000

tau,
tau,
tau,
tau,
tau,
tau,
tau,
tau,
tau,
tau,
tau,
tau,
tau,
tau,
tau,
tau,

1.0360e-012
6.9212e-013
4.1615e-013
3.9476e-013
4.1711e-013
4.3894e-013
4.3473e-013
4.4391e-013
4.5632e-013
4.8133e-013
4.9518e-013
5.7621e-013
7.2946e-013
1.2881e-012
3.0409e-012
5.4837e-012

adev,
adev,
adev,
adev,
adev,
adev,
adev,
adev,
adev,
adev,
adev,
adev,
adev,
adev,
adev,
adev,

n=319297,
n=159648,
n=63858,
n=31928,
n=15963,
n=6384,
n=3191,
n=1595,
n=637,
n=318,
n=158,
n=62,
n=30,
n=14,
n=5,
n=2,

1.0360e-012
6.9116e-013
4.1655e-013
3.9512e-013
4.1953e-013
4.3570e-013
4.3403e-013
4.4587e-013
4.5885e-013
4.7183e-013
5.0995e-013
5.5662e-013
7.4078e-013
1.2603e-012
2.8234e-012
4.9924e-012

oadev,
oadev,
oadev,
oadev,
oadev,
oadev,
oadev,
oadev,
oadev,
oadev,
oadev,
oadev,
oadev,
oadev,
oadev,
oadev,

n=319297
n=319295
n=319289
n=319279
n=319259
n=319199
n=319099
n=318899
n=318299
n=317299
n=315299
n=309299
n=299299
n=279299
n=219299
n=119299

The "bin" number is a feature that lets you control how many averaging intervals (tau) should be calculated.
For the most concise output choose a bin value of 1 - meaning only one statistic is calculated per decade, as
in the following example:
C:\tvb> adev1 1 200e-9 1 <log24121.txt
**
**
**
**

Sampling period: 1 s
Phase data scale factor: 2.000e-007
Total phase samples: 319299
Normal and Overlapping Allan deviation

1
10
100
1000
10000
100000

tau,
tau,
tau,
tau,
tau,
tau,

1.0360e-012
3.9476e-013
4.3473e-013
4.8133e-013
7.2946e-013
5.4837e-012

adev,
adev,
adev,
adev,
adev,
adev,

n=319297,
n=31928,
n=3191,
n=318,
n=30,
n=2,

http://www.leapsecond.com/tools/adev1.htm[2011-5-3 15:26:15]

1.0360e-012
3.9512e-013
4.3403e-013
4.7183e-013
7.4078e-013
4.9924e-012

oadev,
oadev,
oadev,
oadev,
oadev,
oadev,

n=319297
n=319279
n=319099
n=317299
n=299299
n=119299

adev1 - Allan Deviation Statistics

Other useful bin numbers are:


0 - every possible tau (not very useful)
1 - only one tau per decade
2 - tau in powers of two (octaves)
3 - two tau per decade (as in 3 dB)
4 - tau 1-2-4 sequence per decade
5 - tau 1-2-5 sequence per decade
10 - ten tau per decade
29 - "many tau" per decade (many nice round numbers)
N - any other number causes exactly N tau to be calculated per decade. E.g., setting bin to 50 means
there will be 50 evenly spaced (logarithmically) tau values in every decade, regardless of how odd the
numbers are.

Usage message:
C:\tvb> adev1
Compute Allan Deviation over all tau from raw phase data
Usage: adev1 period [scale] [bins] < input
Arguments:
period
scale
bins
Examples:
adev1
adev1
adev1
adev1
adev1

- data sample interval (e.g., 1 second, 60 seconds)


- input data scale factor if units aren't seconds
- adev points per decade (special: 0,1,2,3,4,5,10,29)
1 < 1hzdata.txt
100 < hpdata.txt
60 1e-6 < mins.txt
1 200e-9 < tsc.dat
1 2e-7 50 <tsc.dat

[
[
[
[
[

pre-scaled 1 Hz TI readings ]
100 sec HP time interval readings ]
1 minute phase data, 1 us units ]
TSC 5110A 200 ns 1 Hz phase data ]
50 adev points per decade ]

Download
Win32 executable adev1.exe (58 KB)
C source code adev1.c (8 KB)
Return to LeapSecond.com home page.
Comments/questions to tvb.

http://www.leapsecond.com/tools/adev1.htm[2011-5-3 15:26:15]

Potrebbero piacerti anche