main content

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:

$$\omega(t) = \omega_{ideal}(t)   bias_n(t)   bias_b(t)   bias_k(t)$$

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 $\tau_{0}$. form data clusters of durations $\tau_{0}$, $2\tau_{0}$, ..., $m\tau_{0}, (m < (l-1)/2)$ 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 $\tau_{0}$. let $\omega$ 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 $\theta$:

$$\theta(t) = \int^{t}\omega(t')dt'$$

for discrete samples, the cumulative sum multiplied by $\tau_{0}$ can be used.

theta = cumsum(omega, 1)*t0;

next, calculate the allan variance:

$$\sigma^2(\tau) =
\frac{1}{2\tau^2}<(\theta_{k 2m}-2\theta_{k m} \theta_{k})^2>$$

where $\tau = m\tau_{0}$ and $<>$ is the ensemble average.

the ensemble average can be expanded to:

$$\sigma^2(\tau) =
\frac{1}{2\tau^2(l-2m)}\sum_{k=1}^{l-2m}(\theta_{k 2m} - 2\theta_{k m}
  \theta_{k})^2$$

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 $\sigma(t) = \sqrt{\sigma^2(t)}$ 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 $\omega$. the relationship is:

$$\sigma^2(\tau) = 4\int_{0}^{\infty}s_\omega(f)
\frac{sin^4(\pi f\tau)}{(\pi f\tau)^2}df$$

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 $sin^4(x)/(x)^2$. 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 $\tau$. this means that different noise parameters can be identified by changing the filter bandpass, or varying $\tau$.

angle random walk

the angle random walk is characterized by the white noise spectrum of the gyroscope output. the psd is represented by:

$$s_\omega(f) = n^2$$

where

n = angle random walk coefficient

substituting into the original psd equation and performing integration yields:

$$\sigma^2(\tau) = \frac{n^2}{\tau}$$

the above equation is a line with a slope of -1/2 when plotted on a log-log plot of $\sigma(\tau)$ versus $\tau$. the value of n can be read directly off of this line at $\tau = 1$. the units of n are $(rad/s)/\sqrt{hz}$.

% 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:

$$s_\omega(f) = (\frac{k}{2\pi})^2\frac{1}{f^2}$$

where

k = rate random walk coefficient

substituting into the original psd equation and performing integration yields:

$$\sigma^2(\tau) = \frac{k^2\tau}{3}$$

the above equation is a line with a slope of 1/2 when plotted on a log-log plot of $\sigma(\tau)$ versus $\tau$. the value of k can be read directly off of this line at $\tau = 3$. the units of k are $(rad/s)\sqrt{hz}$.

% 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:

$$s_{\omega}(f) = \left\{\begin{array}{lr}(\frac{b^2}{2\pi})\frac{1}{f}
& : f \leq f_0\\0 & : f > f_0\end{array}\right.$$

where

b = bias instability coefficient

$f_0$ = cut-off frequency

substituting into the original psd equation and performing integration yields:

$$\sigma^2(\tau) = \frac{2b^2}{\pi}[\ln{2}   \\
-\frac{sin^3x}{2x^2}(sinx   4xcosx)   ci(2x) - ci(4x)]$$

where

$x = \pi f_0\tau$

ci = cosine-integral function

when $\tau$ is much longer than the inverse of the cutoff frequency, the psd equation is:

$$\sigma^2(\tau) = \frac{2b^2}{\pi}\ln{2}$$

the above equation is a line with a slope of 0 when plotted on a log-log plot of $\sigma(\tau)$ versus $\tau$. the value of b can be read directly off of this line with a scaling of $\sqrt{\frac{2\ln{2}}{\pi}} \approx 0.664$. the units of b are $rad/s$.

% 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

网站地图