0
\$\begingroup\$

I have a question concerning low pass filtering of IMU acceleration and gyro data. To choose a reasonable cut-off frequency, I thought about making some observations in the spectrum.

Now I have some interpretation problems. In my original thoughts, I assumed there'd be some major peaks. E.g. one peak where the frequency of a rotational movement lies. There wouldn't be much high frequencies and I could clearly see a place, where I could cut it off.

That was wrong... Since the FFT is taken over a complete measurement of about 30 seconds, the plot had nothing to do with what I had in mind.

How do I have to interpret the FFT over a complete measurement? I see now, that it isn't like watching a music live through a spectrum analyzer.

Is it even a good solution, to take the FFT for choosing a cut-off frequency? If not, which are better ways to do that?

Edit 1:

After a few good inputs I add some more information.

The idea was to kill some noise generated by the IMU. Since the IMU is mounted on a vehicle or on moving parts in the vehicle (e.g. the steering wheel), I assumed the fastest reasonable movement should be known.

The used filter function was this one:

function Hd = lp_equiripple2
%LP_EQUIRIPPLE2 Returns a discrete-time filter object.

% MATLAB Code
% Generated by MATLAB(R) 9.2 and the Signal Processing Toolbox 7.4.
% Generated on: 29-Mar-2018 11:37:08

% Equiripple Lowpass filter designed using the FIRPM function.

% All frequency values are in Hz.
Fs = 100;  % Sampling Frequency

Fpass = 10;               % Passband Frequency
Fstop = 20;               % Stopband Frequency
Dpass = 0.0057563991496;  % Passband Ripple
Dstop = 0.0001;           % Stopband Attenuation
dens  = 20;               % Density Factor

% Calculate the order from the parameters using FIRPMORD.
[N, Fo, Ao, W] = firpmord([Fpass, Fstop]/(Fs/2), [1 0], [Dpass, Dstop]);

% Calculate the coefficients using the FIRPM function.
b  = firpm(N, Fo, Ao, W, {dens});
Hd = dfilt.dffir(b);

% [EOF]

The FFT was received and displayed this way:

plot( ( 0:length(acc) - 1) / length(acc) * 100, abs( fft( gyr(:,:) ) ) )

which I know, is indeed a bit of spaghetti code.

As an example I'll attach this image received by this plot. Blue red yellow equals rotation around x, y and z axis.

The whole image is zoomed in since DC is about 2.5e5

gyro fft plot

Edit 2:

I've just seen that there is no huge DC. If I zoom in, it's a really huge peak at 3 Hz which makes a lot of sense. In the gyro plot this frequency is clearly visible:

gyro plot

The spectrogram was a good visualization too. Although, I still can't see a good place to cut off. Not sure if I even should anymore...

Edit 3:

As asked, I'll show you some spectrogram plot. For now I have decided to leave the data unfiltered, since it's not completely clear what's really noise. The bias of the IMU data is of course the much greater problem.

spectrogram plot

On the left you can see the gyro data of the y-axis, whilst on the right side the rotation on the z-axis is shown.

If someone's coming up with a good idea of filtering it tell me, I'll try it out :)

Otherwise I'd say this one is closed.

\$\endgroup\$
  • \$\begingroup\$ The answer would depend entirely on the desired application (what frequencies "make sense" to filter out?). Nothing wrong with using FFT of test data as well. It can give you an estimate of the signal band, as in the highest frequencies to which there is still some "information" regarding the movement. Post up some more details of application, a plot of your FFTs and the code used for plotting, so we can better weigh in. \$\endgroup\$ – Vicente Cunha Apr 4 '18 at 9:32
  • \$\begingroup\$ Of course, I guess that would clearifiy alot. Plot, code and context will follow \$\endgroup\$ – Mr.Sh4nnon Apr 4 '18 at 16:18
  • 1
    \$\begingroup\$ What is your objective? Of course there's a tradeoff between bandwidth and noise, so depending on the use case your filter would differ. This becomes specially important in transients, your filter would slow transients, is this ok? \$\endgroup\$ – Andrés Apr 8 '18 at 16:14
  • \$\begingroup\$ @Andrés thats why i stopped filtering. can‘t really say whats noise and what isn‘t. i later integrate from that data the attitude/position. therefor it has to be as precise as possible. LP filtering improved one data set, but the same cut off frequency made the second data set worse. so it was just luck... \$\endgroup\$ – Mr.Sh4nnon Apr 8 '18 at 16:20
1
\$\begingroup\$

When you are doing an FFT over a large signal sample you obtain the peaks at the frequencies that the FFT encountered over that sample. However, the amplitude that you see for each peak is proportional to the 'time' that specific frequency component existed during the whole signal sample.

Imagine for example you have two acquisitions: one with a 1-second vibration at 10 Hz, and another with same 10 Hz vibration occurring for 30 seconds. The amplitude of the 10 Hz peak for the first acquisition is expected to be 30 times less than for the second acquisition.

I expect that the largest component you have is DC, which has a much higher amplitude than the other frequency components you may have. One quick hack is to remove the DC component from your signal, before doing the FFT. Calculate the mean of x and then x = x-mean.

You may also use a spectrogram, which calculates the FFT for smaller windows. This will give you a 2D plot with the time in one axis and frequency in the other, and the color corresponds to the amplitude.

\$\endgroup\$
  • \$\begingroup\$ Thank you! Good explenation. I‘ll try that out this evening. \$\endgroup\$ – Mr.Sh4nnon Apr 4 '18 at 16:16
  • \$\begingroup\$ From what I see from your results, it seems you have several frequency components up to 5 Hz. Since the IMU is attached to the steering wheel, I suppose the main component is related to the rotation of the wheel. Try rotating and vibrating the weel as fast as you can. If you don't see any other useful frequency component above 5 Hz, maybe this is a good cutoff frequency for your application. What do you think? \$\endgroup\$ – daguiam Apr 5 '18 at 18:26
  • \$\begingroup\$ Already tried several cut off frequencies. 10 worked best. 8,12,15 didn't, which made me sceptic. after you mentioned the spectrogram I tried that. looks like there are sometimes frequencies up to 45 Hz. especially when the gyro is turning... looks like I'm not going to LP filter it at all. \$\endgroup\$ – Mr.Sh4nnon Apr 5 '18 at 18:30
  • \$\begingroup\$ Do you have a figure of the spectrogram that you can share? That would be interesting to see how it evolves. Also, what do you think is the noise of the IMU? \$\endgroup\$ – daguiam Apr 6 '18 at 14:06
  • \$\begingroup\$ yes i‘ll add that tonight. the actuall problem is the bias, but that‘s another problem. my oppinion was, that there has to be several noise in the imu data. temperature noise and e.g. small vibrations. the imu can even sense whene someone is stamping on the ground 2m away... \$\endgroup\$ – Mr.Sh4nnon Apr 6 '18 at 14:16
1
\$\begingroup\$

Without YOUR choice of system bandwidth, any ADC will always under-sample the incoming spectral content and fold-down (alias) the broadband energy. YOU need to control the bandwidth, and understand the filter rolloff is not perfect. Thus energy 10X or 100X or 1,000X higher will still enter the ADC sampler, to be folded.

As you explore and learn, you now encounter the responsibility of the system designer: what degree of precision must you achieve? And how fast must the system respond?

\$\endgroup\$
  • \$\begingroup\$ Since all data is pre recorded, speed/delay isn't much of a concerne. The idea was to chancel out noise produced by the IMU. \$\endgroup\$ – Mr.Sh4nnon Apr 4 '18 at 18:53
  • \$\begingroup\$ And what precision, what bandwidth, do you need? \$\endgroup\$ – analogsystemsrf Apr 9 '18 at 16:46
  • \$\begingroup\$ highest possible precision of the integrated position. bandwith isn‘t a problem (yet) \$\endgroup\$ – Mr.Sh4nnon Apr 9 '18 at 19:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.