# Integrating accelerometer data (obtain velocity and distance)

1. Jul 1, 2010

### SrTp

Hi everyone!

I'm trying to work with an accelerometer to measure distances (straight line) but I'm not being very successful..

I've made this experiment: attached the accelerometer to a electric slot car and accelerate it to the maximum until it reached the end of a straight line track with 4.8 meters long.
The sampling was made every 10 milliseconds.
In the end, it crashes into a pillow (:D) but I'm not considering those crash accelerations to the calculus.

The acceleration values are incredibly noisy...and my questions are:
- which initial filter should be applied to the noisy samples? a low pass moving average?
. how do I know which is the best number of samples to consider in the average? 2, 3, 4,..?

- after that I've read that we could apply something like a filtering window to discriminate between "valid" and "invalid/noisy" accelerations. If the acceleration values are in that window they should be changed to 0.0, indicating that there is no movement therefore no velocity and then the distance will not be incremented.
. so...once again, how can I determine the best values for that window? How can I be sure that I'm not excluding important values or including noise?

- I've also read about kalman filters but they might be too difficult for me to understand..I think.

For the integration calculus I'm using a first order approximation - trapezoidal method (hope I'm doing it well...). Btw, is this the best method or there are many others I should try?

With my trapezoidal method applied to raw data and without any filter I'm getting 5.81 meters. I've tried to apply the moving average filter but it doesn't seems to help.
For the filtering window method I'm not sure which values to apply so I'm not getting good results.

If needed I can post the accelerometer raw data...

Hope someone can help me!
Best regards

2. Jul 1, 2010

### schip666!

Your Integration is probably doing exactly what a moving average would do so I don't think that will help. If you consistently come put with 5.81 instead of 4.8 I would think that noise is not an issue, and would just use that run as a calibration for your sensors. Can you try different track lengths and see if the "error" is proportional?

A Kalman filter would be useful if you needed accurate instantaneous acceleration values, but since you are "averaging" them all together the individual reading errorss will tend to cancel each other out.