Hi, Night_Mode:
Yes, I have done that with Analog Devices accelerometers, but I can't share the code. I can share an overview of my algorithm.
The accelerometer provides you with acceleration (gee, really?). Mathematically, velocity is the integral-over-time of acceleration, and position is the integral-over-time of velocity. So position can be determined by doing a double-integral of the data derived from the accelerometer.
Easier said than done.
To get any accuracy, both the samples must be accurate and the sample rate high. Any errors in the sample will be integrated as well, and can accumulate quickly. Be careful not to loose any precision in your math, as that loss will also be integrated.
You also have to consider the effects of gravity. The three axes will be affected by 32 feet-per-second-per-second of gravitational acceleration. Somehow, you need to determine which direction is down, and subtract out gravity. I did this subtraction as a vector near the tail end of my calculations.
Without additional sensors to close the loop, you will get both velocity and position drift. That is the nature of an integral that is not using perfectly measured samples.
If you instrument can tilt, a pair of inclinometers would help to determine the direction of the gravitational vector.
I could go on and on. There is a lot to the subject.
Message Edited by rocco on 2007-03-2706:07 PM