inertial sensor noise analysis using allan variance -凯发k8网页登录
this example shows how to use the allan variance to determine noise parameters of a mems gyroscope. these parameters can be used to model the gyroscope in simulation. the gyroscope measurement is modeled as:
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.
allan variance calculation
the allan variance is calculated as follows:
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;
for each sample, calculate the output angle :
for discrete samples, the cumulative sum multiplied by can be used.
theta = cumsum(omega, 1)*t0;
next, calculate the allan variance:
where and is the ensemble average.
the ensemble average can be expanded to:
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. tau = m*t0; avar = zeros(numel(m), 1); for i = 1:numel(m) mi = m(i); avar(i,:) = sum( ... (theta(1 2*mi:l) - 2*theta(1 mi:l-mi) theta(1:l-2*mi)).^2, 1); end avar = avar ./ (2*tau.^2 .* (l - 2*m));
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.
[avarfromfunc, taufromfunc] = allanvar(omega, m, fs); adevfromfunc = sqrt(avarfromfunc); figure loglog(tau, adev, taufromfunc, adevfromfunc); title('allan deviations') xlabel('\tau') ylabel('\sigma(\tau)') legend('manual calculation', 'allanvar function') grid on axis equal
noise parameter identification
to obtain the noise parameters for the gyroscope, use the following relationship between the allan variance and the two-sided power spectral density (psd) of the noise parameters in the original data set . the relationship is:
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 .
angle random walk
the angle random walk is characterized by the white noise spectrum of the gyroscope output. the psd is represented by:
where
n = angle random walk coefficient
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 n can be read directly off of this line at . the units of n are .
% 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)); % find the y-intercept of the line. b = logadev(i) - slope*logtau(i); % determine the angle random walk coefficient from the line. logn = slope*log(1) b; n = 10^logn % plot the results. taun = 1; linen = n ./ sqrt(tau); figure loglog(tau, adev, tau, linen, '--', taun, n, 'o') title('allan deviation with angle random walk') xlabel('\tau') ylabel('\sigma(\tau)') legend('\sigma', '\sigma_n') text(taun, n, 'n') grid on axis equal
n = 0.0126
rate random walk
the rate random walk is characterized by the red noise (brownian noise) spectrum of the gyroscope output. the psd is represented by:
where
k = rate random walk coefficient
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 . the units of k are .
% 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)); % find the y-intercept of the line. b = logadev(i) - slope*logtau(i); % determine the rate random walk coefficient from the line. logk = slope*log10(3) b; k = 10^logk % plot the results. tauk = 3; linek = k .* sqrt(tau/3); figure loglog(tau, adev, tau, linek, '--', tauk, k, 'o') title('allan deviation with rate random walk') xlabel('\tau') ylabel('\sigma(\tau)') legend('\sigma', '\sigma_k') text(tauk, k, 'k') grid on axis equal
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
b = bias instability coefficient
= cut-off frequency
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 . the units of b are .
% 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)); % find the y-intercept of the line. b = logadev(i) - slope*logtau(i); % determine the bias instability coefficient from the line. scfb = sqrt(2*log(2)/pi); logb = b - log10(scfb); b = 10^logb % plot the results. taub = tau(i); lineb = b * scfb * ones(size(tau)); figure loglog(tau, adev, tau, lineb, '--', taub, scfb*b, 'o') title('allan deviation with bias instability') xlabel('\tau') ylabel('\sigma(\tau)') legend('\sigma', '\sigma_b') text(taub, scfb*b, '0.664b') grid on axis equal
b = 0.0020
now that all the noise parameters have been calculated, plot the allan deviation with all of the lines used for quantifying the parameters.
tauparams = [taun, tauk, taub]; params = [n, k, scfb*b]; figure loglog(tau, adev, tau, [linen, linek, lineb], '--', ... tauparams, params, 'o') title('allan deviation with noise parameters') xlabel('\tau') ylabel('\sigma(\tau)') legend('$\sigma (rad/s)$', '$\sigma_n ((rad/s)/\sqrt{hz})$', ... '$\sigma_k ((rad/s)\sqrt{hz})$', '$\sigma_b (rad/s)$', 'interpreter', 'latex') text(tauparams, params, {'n', 'k', '0.664b'}) grid on axis equal
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.
[avarsim, tausim] = allanvar(omegasim, 'octave', fs); adevsim = sqrt(avarsim); adevsim = mean(adevsim, 2); % use the mean of the simulations. figure loglog(tau, adev, tausim, adevsim, '--') title('allan deviation of hw and simulation') xlabel('\tau'); ylabel('\sigma(\tau)') 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