Kristoph Minchau

Robotics - Measuring Distance with an Accelerometer

By: Kristoph Minchau

ADXL50JH Accelerometer

Summary

A guide to finding the distance travelled with an accelerometer.

In order to view these pages correctly in Internet Explorer, the MathPlayer plugin needs to be downloaded from: www.dessci.com/en/products/mathplayer/download.htm

---Caution! Math and numbers ahead, if you are an Art's major, you may want to turn away now ;-) ----

Fundamental Concept: Math

To measure your distance with the accelerometer, you need the formula (Formula 1):

$d=v_{f}\cdot{}t-0.5\cdot{}a\cdot{}t^2$ (Formula 1)

(d (distance) equals vf (velocity final) multiplied by t (time) subtracted by 0.5 multiplied by a (acceleration) multiplied by t (time) squared)

and the equation:

$a=\frac{(v_{f}-v_{i})}{t}$

re-arranged to (Formula 2):

$v_{f}=v_{i}+a\cdot{}t$ (Formula 2)

(vf (velocity final) equals vi (velocity initial) plus a (acceleration) multiplied by t (time))

In order to measure your distance, you need to keep track of time very well, as well as keeping track of your velocity. You will also have to know what units your accelerometer is using ( e.g. m/s), I will use an example to help illustrate things. Just think of everything in terms of "time periods" where velocity initial (vi) is your velocity at the start of the time period, and velocity final (vf) is your velocity at the end of the time period.

**We all start at time = 0s, we are measuring in 1 second time period and for ease of use, always assume that your initial velocity (vi) and final velocity(vf) is equal to zero initially. Lets say that you are accelerating at a constant rate of 1m/s and our distance is equal to zero.

t=1s

So at the end of the 1 second using the formula 2 you get:

$v_{f}=v_{i}+a\cdot{}t=0+1\cdot{}1=1 \frac{m}{s}$

After 1 second you have accelerated to a velocity of 1m/s. Then plugging in the numbers into formula 1 you get:

$d=v_{f}\cdot{}t-0.5\cdot{}a\cdot{}t^2=1\cdot{}1-0.5\cdot{}1\cdot{}1^2=0.5m$

So at the end of 1 time period (1 second) you have gone 0.5m

** t=2s



$v_{f}=v{i}+a\cdot{}t=1+1\cdot{}1=2 \frac{m}{s}$

So here, remember your velocity initial (vi) is the velocity final (vf) from the previous time period (eg. you were going 1m/s, and you have just accelerated an extra 1m/s, so therefor you must be going 2m/s). Also remember that your time (t) is the length of your time period. Plugging in the numbers into formula 1 you get:

$d=v_{f}\cdot{}t-0.5\cdot{}a\cdot{}t^2=2\cdot{}1-0.5\cdot{}1\cdot{}1^2=1.5m$

So at the end of 2 time periods (2 seconds) you have gone 1.5m

** t=3s



$v_{f}=v{i}+a\cdot{}t=2+1\cdot{}1=3 \frac{m}{s}$

Plugging in the numbers into formula 1 you get:

$d=v_{f}\cdot{}t-0.5\cdot{}a\cdot{}t^2=3\cdot{}1-0.5\cdot{}1\cdot{}1^2=2.5m$

So at the end of 3 time periods (3 seconds) you have gone 2.5m

** t=4s

Lets say  that you now increase your acceleration to 4m/s

$v_{f}=v_{i}+a\cdot{}t=3+4\cdot{}1=7 \frac{m}{s}$

Plugging in the numbers into formula 1 you get:

$d=v_{f}\cdot{}t=0.5\cdot{}a\cdot{}t^2=7\cdot{}1-0.5\cdot{}4\cdot{}1^2=5m$

So at the end of 4 time periods (4 seconds) (after the increase in acceleration) you have gone 5m.

etc.

etc.

This should give you the basic idea of how to use an accelerometer to measure distance.

All you have to do is measure your accelerometer, perform these calculations for each individual axis, and you will get your xy position.

Note: you will also probably have to have some initialization and filtering on the accelerometer for accuracy (i.e. getting a -11 reading while it is staying still).

©2007 Kristoph Minchau