How do I filter my accelerometer data so that when I integrate it I have no drift?
104 ビュー (過去 30 日間)
古いコメントを表示
Hi all,
I'm attempting to integrate my accelerometer data x2 to get displacement. I need to design a filter in order to avoid drift and I've done an fft of my data to view the signal in the frequency domain and don't really know where to go from there. I implemented a high pass filter but ut it dropped my data to a mean of around zero when I should be at least be having around 1 G in my data.

I see a have an asymmetrical signal at 0 Hz but don't know how to interpret it.

My raw acceleration data is above and when I integrate my raw data I have discrepencies.
How should I design my filter?
0 件のコメント
回答 (2 件)
Star Strider
2022 年 4 月 10 日
The fft plot does not make sense.
Before you do any signal processing (including the fft), first be certain that the signal is sampled with consistent sampling intervals. One way to do that is to calculate:
sigstd = std(diff(t))
where ‘t’ is the time vector. It should be close to zero. If not, then use the resample function to resample it to a consistent sampling frequency.
I would re-calculate the fft, and then use a bandpass filter (such as this one) to filter the signal. That will eliminiate the gravity offset (that would otherwise be integrated as well). Determine the passband from the fft result.
Fs = 125; % Supply Correct Sampling Frequency
Fn = Fs/2;
Wp = [0.03 0.2]/Fn; % Supply Correct Passband
Ws = Wp.*[0.95 1.05]; % Calculated Stopband
Rs = 50;
Rp = 1;
[n,Wn] = ellipord(Wp,Ws,Rp,Rs);
[z,p,k] = ellip(n,Rp,Rs,Wp); % Design Elliptic Filter
[sos,g] = zp2sos(z,p,k);
figure
freqz(sos, 2^16, Fs)
% set(subplot(2,1,1), 'XLim',[0 0.5]) % Zoom Axis (Optional) Choose The Correct Limnits
% set(subplot(2,1,2), 'XLim',[0 0.5]) % Zoom Axis (Optional) Choose The Correct Limnits
signal_filt = filtfilt(sos, g, signal);
It will be necessary to experiment with this to get the result you want.
.
2 件のコメント
Star Strider
2022 年 4 月 10 日
My pleasure!
It would help to have the original data.
The highpass filter will eliminate the gravity offset.
Creating a highpass filter using my ellpitic filter would be preferable to a Butterworth design. Use filtfilt, not filter, since filtfilt is phase-neutral (no phase distortion or delay).
The second-order-section realisation creates a stable filter. The transfer function realisation does not.
There appears to be high-frequency noise in the signal (the ‘constant’ sections at the beginning of the signal appear to display high-frequency noise). so a bandpass filter might be more appropriate.
I do not see any specific trend in the signal, so detrending it may not be appropriate.
Walter Roberson
2022 年 4 月 10 日
I need to design a filter in order to avoid drift
That is not going to work. Errors in accelerometers are not symmetric. Any system of position measurement that depends only on accelerometers will either exhibit drift or else will be inaccurate for actual measurements.
Suppose your accelerometer can measure down to 1/100 g. Suppose you have measurement noise that is mostly on the order of 1/1000 g. Suppose 1 time in 10000, the measurement noise adds up to +1/100 g . If the measurement system was continuous, then two -1/200g noises would balance out the +1/100g. But -1/200g is below the measurement limit so anything of less magnitude than -1/100g is not going to counter-balance the +1/100g noise.
This is the sort of reason that missile navigation systems for longer distances never use dead reconning based just on acceleration measurements.
2 件のコメント
Walter Roberson
2022 年 4 月 10 日
"Even the best accelerometers, with a standard error of 10 micro-g, would accumulate a 50-meter error within 17 minutes"
参考
カテゴリ
Help Center および File Exchange で Filter Analysis についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!