Page 1 of 1

velocity calculated from accelerometer

Posted: Tue Oct 27, 2009 7:04 pm
by brandonl
I have a three axis accelerometer that has a digital output (spi,i2c). I would like to calculate velocity along the z axis based on the readings using an 8 bit PIC and display it. To calculate the velocity I believe you would integrate the acceleration. It has been years since i have done calculus, and I'm at a loss how I would implement this. Also would be interested if any digital filtering would be required due to small movement on the other axis.

Thanks for any help
Brandon

Re: velocity calculated from accelerometer

Posted: Thu Oct 29, 2009 7:02 am
by MrAl
Hi there,

I think this is usually done by doing something like this:

V=V(0)+a*dt
where
V is the currently computed velocity and
V(0) is the velocity calculated previously (and V(0)=0 at t=0) and
a is the acceleration and
dt is the time duration between samples.

In a sampled system this would look something like this:
V[k+1]=V[k]+a[k+1]*delta_t
or
V[k]=V[k-1]+a[k]*delta_t
might be the more suitable form.
You could work in whatever dimensions are the most convenient.

Working in three dimensions as you seem to need, you would have to calculate
the above for all three directions and then calculate the 3d vector to get the
final results.

I cant say too much about the accuracy of these kinds of techniques however,
as many things come into question like the basic accuracy of the sensor, the
basic resolution of the sensor, the error accumulations, stuff like that.
In control electronics (this isnt exactly that though) this would be a definite no-no,
as any little thing missed over and over again could accumulate to a huge error.
If that was a voltage regulator for example, the output would be anything but
regulated, with an almost unpredictable output.
You might include some kind of calibration phase into the algorithm too.

Re: velocity calculated from accelerometer

Posted: Thu Oct 29, 2009 7:37 am
by CeaSaR
If you can find the article(s) on the Balance Bot, you'll find code, possibly downloadable,
that will show you how to do what you want.

CeaSaR