Inertial Sensor Noise Analysis Using Allan Variance - MATLAB & Simulink
Inertial Sensor Noise Analysis Using Allan Variance - MATLAB & Simulink
The three noise parameters N (angle random walk), K (rate random walk), and B (bias instability) are estimated using data
logged from a stationary gyroscope.
Background
Allan variance was originally developed by David W. Allan to measure the frequency stability of precision oscillators. It can
also be used to identify various noise sources present in stationary gyroscope measurements. Consider L samples of data
from a gyroscope with a sample time of . Form data clusters of durations , , ..., and obtain
the averages of the sum of the data points contained in each cluster over the length of the cluster. The Allan variance is
defined as the two-sample variance of the data cluster averages as a function of cluster time. This example uses the
overlapping Allan variance estimator. This means that the calculated clusters are overlapping. The estimator performs
better than non-overlapping estimators for larger values of L.
Log L stationary gyroscope samples with a sample period . Let be the logged samples.
% Load logged data from one axis of a three-axis gyroscope. This recording
% was done over a six hour period with a 100 Hz sampling rate.
load('LoggedSingleAxisGyroscope', 'omega', 'Fs')
t0 = 1/Fs;
maxNumM = 100;
L = size(theta, 1);
maxM = 2.^floor(log2(L/2));
m = logspace(log10(1), log10(maxM), maxNumM).';
m = ceil(m); % m must be an integer.
m = unique(m); % Remove duplicates.
https://www.mathworks.com/help/nav/ug/inertial-sensor-noise-analysis-using-allan-variance.html#d120e593 1/10
8/12/2020 Inertial Sensor Noise Analysis Using Allan Variance - MATLAB & Simulink
tau = m*t0;
Finally, the Allan deviation is used to determine the gyroscope noise parameters.
adev = sqrt(avar);
figure
loglog(tau, adev)
title('Allan Deviation')
xlabel('\tau');
ylabel('\sigma(\tau)')
grid on
axis equal
The Allan variance can also be calculated using the allanvar function.
figure
loglog(tau, adev, tauFromFunc, adevFromFunc);
https://www.mathworks.com/help/nav/ug/inertial-sensor-noise-analysis-using-allan-variance.html#d120e593 2/10
8/12/2020 Inertial Sensor Noise Analysis Using Allan Variance - MATLAB & Simulink
title('Allan Deviations')
xlabel('\tau')
ylabel('\sigma(\tau)')
legend('Manual Calculation', 'allanvar Function')
grid on
axis equal
From the above equation, the Allan variance is proportional to the total noise power of the gyroscope when passed through
a filter with a transfer function of . This transfer function arises from the operations done to create and operate
on the clusters.
Using this transfer function interpretation, the filter bandpass depends on . This means that different noise parameters can
be identified by changing the filter bandpass, or varying .
where
Substituting into the original PSD equation and performing integration yields:
https://www.mathworks.com/help/nav/ug/inertial-sensor-noise-analysis-using-allan-variance.html#d120e593 3/10
8/12/2020 Inertial Sensor Noise Analysis Using Allan Variance - MATLAB & Simulink
The above equation is a line with a slope of -1/2 when plotted on a log-log plot of versus . The value of N can be
read directly off of this line at .
% Find the index where the slope of the log-scaled Allan deviation is equal
% to the slope specified.
slope = -0.5;
logtau = log10(tau);
logadev = log10(adev);
dlogadev = diff(logadev) ./ diff(logtau);
[~, i] = min(abs(dlogadev - slope));
N =
0.0126
https://www.mathworks.com/help/nav/ug/inertial-sensor-noise-analysis-using-allan-variance.html#d120e593 4/10
8/12/2020 Inertial Sensor Noise Analysis Using Allan Variance - MATLAB & Simulink
where
Substituting into the original PSD equation and performing integration yields:
The above equation is a line with a slope of 1/2 when plotted on a log-log plot of versus . The value of K can be read
directly off of this line at .
% Find the index where the slope of the log-scaled Allan deviation is equal
% to the slope specified.
slope = 0.5;
logtau = log10(tau);
logadev = log10(adev);
dlogadev = diff(logadev) ./ diff(logtau);
[~, i] = min(abs(dlogadev - slope));
https://www.mathworks.com/help/nav/ug/inertial-sensor-noise-analysis-using-allan-variance.html#d120e593 5/10
8/12/2020 Inertial Sensor Noise Analysis Using Allan Variance - MATLAB & Simulink
K = 10^logK
K =
9.0679e-05
Bias Instability
The bias instability is characterized by the pink noise (flicker noise) spectrum of the gyroscope output. The PSD is
represented by:
where
= cut-off frequency
https://www.mathworks.com/help/nav/ug/inertial-sensor-noise-analysis-using-allan-variance.html#d120e593 6/10
8/12/2020 Inertial Sensor Noise Analysis Using Allan Variance - MATLAB & Simulink
Substituting into the original PSD equation and performing integration yields:
where
Ci = cosine-integral function
When is much longer than the inverse of the cutoff frequency, the PSD equation is:
The above equation is a line with a slope of 0 when plotted on a log-log plot of versus . The value of B can be read
directly off of this line with a scaling of .
% Find the index where the slope of the log-scaled Allan deviation is equal
% to the slope specified.
slope = 0;
logtau = log10(tau);
logadev = log10(adev);
dlogadev = diff(logadev) ./ diff(logtau);
[~, i] = min(abs(dlogadev - slope));
B =
0.0020
https://www.mathworks.com/help/nav/ug/inertial-sensor-noise-analysis-using-allan-variance.html#d120e593 7/10
8/12/2020 Inertial Sensor Noise Analysis Using Allan Variance - MATLAB & Simulink
Now that all the noise parameters have been calculated, plot the Allan deviation with all of the lines used for quantifying the
parameters.
https://www.mathworks.com/help/nav/ug/inertial-sensor-noise-analysis-using-allan-variance.html#d120e593 8/10
8/12/2020 Inertial Sensor Noise Analysis Using Allan Variance - MATLAB & Simulink
Gyroscope Simulation
Use the imuSensor object to simulate gyroscope measurements with the noise parameters identified above.
% Simulating the gyroscope measurements takes some time. To avoid this, the
% measurements were generated and saved to a MAT-file. By default, this
% example uses the MAT-file. To generate the measurements instead, change
% this logical variable to true.
generateSimulatedData = false;
if generateSimulatedData
% Set the gyroscope parameters to the noise parameters determined
% above.
gyro = gyroparams('NoiseDensity', N, 'RandomWalk', K, ...
'BiasInstability', B);
omegaSim = helperAllanVarianceExample(L, Fs, gyro);
else
load('SimulatedSingleAxisGyroscope', 'omegaSim')
end
Calculate the simulated Allan deviation and compare it to the logged data.
figure
loglog(tau, adev, tauSim, adevSim, '--')
title('Allan Deviation of HW and Simulation')
xlabel('\tau');
ylabel('\sigma(\tau)')
https://www.mathworks.com/help/nav/ug/inertial-sensor-noise-analysis-using-allan-variance.html#d120e593 9/10
8/12/2020 Inertial Sensor Noise Analysis Using Allan Variance - MATLAB & Simulink
legend('HW', 'SIM')
grid on
axis equal
The plot shows that the gyroscope model created from the imuSensor generates measurements with similar Allan
deviation to the logged data. The model measurements contain slightly less noise since the quantization and temperature-
related parameters are not set using gyroparams. The gyroscope model can be used to generate measurements using
movements that are not easily captured with hardware.
References
• IEEE Std. 647-2006 IEEE Standard Specification Format Guide and Test Procedure for Single-Axis Laser Gyros
https://www.mathworks.com/help/nav/ug/inertial-sensor-noise-analysis-using-allan-variance.html#d120e593 10/10