# Filter for noisy accelerometer data

I tried to read up and get a filter for a 3-axis accelerometer but this is more confusing than I thought. I have an IMU with a 3-axis accelerometer on the end of a robot link which is rotated around on one axis. When at rest with just gravity acting on it I get these readings:

Now the band of the data is kinda broad and very noisy . I thought that at first I could maybe look at the frequency spectrum and cut out unwanted frequencies but honestly the FFT doesn't tell me anything I could remove. What does initial spike in the spectrum mean and and how would I put a high or low pass filter over the data if it looks like such a mess? Do I need to smooth it in some way?

Preferable I would want a nice arc of the data which follows the movement of the end of the arm but I don't know how to achieve that. Could it be that the arm movement by the motor introduces too much noise?

Thanks for any help!

• What are the units in the acceleration graphs? Apr 21 '16 at 1:56

Most accelerometers suffer from bias --- a non-zero, constant rest measurement. See, for example, this page.

A further imperfection is called zero g bias level, or offset. This is the reading the sensor provides with no acceleration, and, unfortunately, that is rarely zero (in the Z direction it should be 1 g). In fact, the error can be substantial, frequently hundreds of times larger than the device’s resolution.

So you need to remove this DC offset (which is how the bias appears) from all your measurements. If you need to know the $g$ value from the $z$ accelerometer, you will need to calibrate it first in the $x$ or $y$ plane (to remove the effect of gravity).

Have a read through this answer to another question, and try applying a DC blocker to your data.

• Thanks a lot for the answer. I removed the DC offset according to the algorithm and as expected it removed the offset and moved it to zero but the signal stays the same with the same ranges. I should mention that my accelerometer isn't perfectly aligned with gravity so it is OK to have offsets in the axis. My problem is that the data is so spread out while it should in theory follow an arc which I want, or be a point when resting. Are noise ranges of 0.2-0.4 m/s^2 normal and can't I remove them? Am I missing something? Apr 20 '16 at 17:02
• On a different note. What if I convolute the data to smooth it with like e.g. a local mean filter? Apr 20 '16 at 17:23
• Right: most accelerometers are very noisy. Low noise ones tend to be large and expensive. Smoothing using a DC blocker with a low $\alpha$ value (say 0.7) may provide some smoothing "for free".
– Peter K.
Apr 20 '16 at 17:25
• If you removed the DC offset, the spike at 0 in the fft results should disappear. Apr 20 '16 at 20:14
• You can either try Welch's method with shorter windowed FFTs, or perhaps a Kalman filter to get a less noisy estimate. Apr 20 '16 at 20:17