velocity calculated from accelerometer

Electronics Computer Programming Q&A
Post Reply
brandonl
Posts: 5
Joined: Tue May 19, 2009 1:32 pm
Contact:

velocity calculated from accelerometer

Post 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
User avatar
MrAl
Posts: 3862
Joined: Fri Jan 11, 2002 1:01 am
Location: NewJersey
Contact:

Re: velocity calculated from accelerometer

Post 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.
LEDs vs Bulbs, LEDs are winning.
User avatar
CeaSaR
Posts: 1950
Joined: Sat Nov 08, 2003 1:01 am
Location: Phoenixville, PA USA
Contact:

Re: velocity calculated from accelerometer

Post 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
Hey, what do I know?
Post Reply

Who is online

Users browsing this forum: No registered users and 48 guests