1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Acceleration to Displacement

  1. Jun 7, 2006 #1
    Does any one know of a simple algorithm for converting a time based series of accelerations from a single axis accelerometer to displacement?

    I understand that double integration is the way forward ... but what am I double integrating? and how can I do this say in Excel or Visual Basic ?

    The accelerometer is recording motion of a wave bouy and all I need is a mean displacement.

    Drift of the result is not so much of an issue.
  2. jcsd
  3. Jun 7, 2006 #2


    User Avatar

    Staff: Mentor

    Just apply s=at, and d=st in separate columns in excel.
  4. Jun 7, 2006 #3

    George Jones

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    You need to use a routine for numerical integration, like the the trapezoid rule or Simpson's rule.

    You also need to know the initial speed of the buoy (zero?).

    These don't work that well in this case, because neither speed nor acceleration are constant. Also, a sum (of rectangles) has to be taken, and the t is the time interval between readings, not the time of the readings.
    Last edited: Jun 7, 2006
  5. Jun 7, 2006 #4


    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    George, if suitably modified, Russ' approach will work. Given accelerations and an initial velocity, you generate a column of velocities, [itex]v_n = v_{n-1} + a_n(t_n-t_{n-1})[/itex], with vo given. If the time intervals are all equal, you can simply repeat this procedure to generate displacements. If they are not, you generate new time intervals (that are connected) whose median values are the original set of times and proceed as above.

    This, I imagine, will get you the same result as a trapezoidal summation.
    Last edited: Jun 7, 2006
  6. Jun 7, 2006 #5

    George Jones

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    Yes, I wasn't mathematically explicit, but this is what I meant by

    Your iterated formula treats the acceleration as constant over each each time interval, and thus finds velocity as an area inder the acceleration-time graph by summing a bunch of rectangles, each having acceleration as height, and a time interval as width.

    Yes, this will work, but it would be more accurate to do as much as possible analytically first.

    For example, for example, consider the rectangle rule and one time interval, so a is constant over the time interval, i.e., something like the following. I haven't been particularly careful, so I might have screwed it up a bit


    [tex]v_{n} = v_{n-1} + a_{n-1}(t_n - t_{n-1}).[/tex]

    Integrate again:

    [tex]x_{n} = x_{n-1} + v_{n-1}(t_n - t_{n-1}) + \frac{1}{2} a_{n-1} (t_n - t_{n-1})^2.[/tex]

    Of course, this just results in the standard constant acceleration formulae.

    A third integration is necessary to calculate the mean, but, if equal time intervals are used, I guess a good approximation would be just to take a mean as finite sum.
    Last edited: Jun 7, 2006
  7. Jun 7, 2006 #6
    Thank you all

    Hey ... If only i'd given it a little thought.

    Thank you all !
  8. Jun 7, 2006 #7


    User Avatar

    Staff: Mentor

    My approach is a numerical integration approach using Excel, but I was in a hurry and didn't elaborate. Let me elaborate now:

    The colums are iteration, time, acceleration, speed, and distance.

    Iteration, time, and acceleration are provided by the accelerometer - probably already in spreadsheet form (or iteration is just row number in Excel). Speed takes the time interval (actually 'dt' - I didn't specify that) times the acceleration, plus the previous speed. Distance is calculated the same way.

    Caveat - I'm not sure if this works with a mixture of positive and negative acceleration. I think it would.

    I'm so lazy when it comes to math, I rarely solve an equation that can easily be numerically integrated with Excel.
    Last edited: Jun 7, 2006
  9. Jun 13, 2006 #8
    As you suggested this approach sort of works, as does simpsons (using 5,8,-1 rule)

    But does not seem to handle negative acceleration well.

    I tried a simple dataset ( moving the accelerometer vertically over a known distance)

    and all of the proposals seem to work for +ve accelerations but as the accelerometer slows, -ve accelerations appear as could be expected, summing the integrated velocity results in excell itteratively the velocity rapidly becomes negative. I know this is not the case as the accelerometer only had positive displacemnt and therefore positive velocity.

    any suggestions as to where to look ???
  10. Jun 14, 2006 #9

    George Jones

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    These routines shouldn't have problems handling negative acceleration.

    If you haven't already done so, you should use Excel to plot the acceleration data versus time. Just by eyeballing this plot, you might be able to tell whether the cumulative area under the graph becomes negative.

    How big is your "simple dataset?"

    If you want, I could have a look at the test data, but I might not be able to take a serious look until Friday.
  11. Jul 10, 2009 #10
    Hi i quickly read over this post that was made a long time ago I saw the formula for to calc the acceleration to displacement :


    [tex]v_{n} = v_{n-1} + a_{n-1}(t_n - t_{n-1}).[/tex]

    Integrate again:

    [tex]x_{n} = x_{n-1} + v_{n-1}(t_n - t_{n-1}) + \frac{1}{2} a_{n-1} (t_n - t_{n-1})^2.[/tex]

    I did some acceleration collection on a person walking 20 meters down a hall and in the graph attachement the displacement and velocities looks weird. I sampled the acceleration data 2khz and it's in G-forces. the person is walking about 1-2 hz. Does this calc work for my acceleration data values?


    Attached Files:

  12. Jan 14, 2010 #11
    Hi all

    I'm glad I came across this thread as I have a similar problem.

    I am trying to get a sensible graph of velocity and displacement out of a force time graph of the forces applied to a force plate while walking. I've used integration methods, which are the same as those mentioned above but they don't return a graph that means anything intuitively.
    The graph needs to reflect the change in velocity and displacement of the body's Centre of Mass relative to the ground. The absolute velocity is not required and at present I dont have a starting velocity. It is neccesary to see the velocity and the direction of displacement relative to the ground. I think the problem is that at initial foot contact (start) the CoM velocity is toward the ground and slowing down as the force / acceleration increases then at the propulsive stage the velocity is away from the ground as the acceleration increases. I can't work out how to change the signs to accomodate this. Anyone like to help?

    Cheers Dave Smith

    Attached Files:

    Last edited: Jan 14, 2010
  13. Jan 14, 2010 #12
    Wow, you really: do not want to use the formulas mentioned in this thread. Integrations of accelerations are susceptible to drift and notoriously horrible because you are integrating noise.

    There is away to do this by fusing the sensor data with periodic measurements from other sources. I forgot the name of this thing......I'll post it when I remember.
  14. Mar 10, 2010 #13
    Double integration of raw acceleration data is a pretty poor estimate for displacement. The reason is that at each integration, you are compounding the noise in the data.

    If you are dead set on working in the time-domain, the best results come from the following steps.
    1. Remove the mean from your sample (now have zero-mean sample)
    2. Integrate once to get velocity using some rule (trapezoidal, etc.)
    3. Remove the mean from the velocity
    4. Integrate again to get displacement.
    5. Remove the mean. Note, if you plot this, you will see drift over time.
    6. To eliminate (some to most) of the drift (trend), use a least squares fit (high degree depending on data) to determine polynomial coefficients.
    7. Remove the least squares polynomial function from your data.

    A much better way to get displacement from acceleration data is to work in the frequency domain. To do this, follow these steps...

    1. Remove the mean from the accel. data
    2. Take the Fourier transform (FFT) of the accel. data.
    3. Convert the transformed accel. data to displacement data by dividing each element by -omega^2, where omega is the frequency band.
    4. Now take the inverse FFT to get back to the time-domain and scale your result.

    This will give you a much better estimate of displacement. Hope this helps..
  15. Mar 25, 2010 #14
    I'm looking for suggestions how to convert acceleration into frequency?
    We attached 2 3-axis accelerometers to 20ft. tower to monitor vibrations,however output in fractions of g.How can I get Hz values?
    I attached a file- first column is seconds of measuring,next 3 are original data from DAQ, next 3 I multiplied by g(9.8m/s2) and last 3 I offset to plot a graph.
    Do you also have an idea why is acceleration keep increasing?

    Attached Files:

  16. Mar 25, 2010 #15
    Interesting, nice advice!
  17. Mar 25, 2010 #16
    Look up discrete FFT (Fast Fourier Transform). There are algorithms out there in most languages and even books called Numerical Recipes that will give you FFT algorithms. As for the increasing function...it's called "drift". Try looking for "accelerometer drift" in google.
  18. Mar 25, 2010 #17
    ...and one more thing. If anyone is wondering where the -omega^2 is coming from, try taking the analytical second derivative of a simple sine wave, say "sin(wt+phi)" and see what you get....interesting, huh?

    f(t) = A.sin(wt+phi)
    f'(t) = -Aw.cos(wt+phi)
    f''(t) = -Aw^2.sin(wt+phi)
  19. Mar 25, 2010 #18
    Actually, I was wondering. Thanks for this post. :wink:

    I found out the name I was looking for earlier: complimentary filter.
  20. Mar 30, 2010 #19
    Good point. Estimation filters also will help your results. Look up Kalman filters in particular. (EKF, UKF, etc.) Thanks for the reminder.
  21. May 6, 2010 #20
    very interesting method...using FFT. We've been using the standard double integration with nominally good results (using filters, , removing bias, etc), but would like to try the FFT approach. FYI, we are looking at (very low velocity/energy) impacts on previously damaged composites (honeycomb sandwich and solid laminates), where we know the velocity just before impact, with the end result measuring contact stiffness and impact energy loss to characterize the pre-existing damage.

    How would the process steps listed change if there is an initial velocity?
  22. Jun 11, 2011 #21
    Dear collegues

    i work with a manual shaking table and i need to obtain displacement from acceleration. I`ve learned that it`s better to integrate in frequency domain because double integration of acceleration in time domain is sometimes erroneous, but i don`t know how to calculate
    -omega^2, where omega is the frequency band. i would be most grateful if you could help me solve this problem.

  23. Jun 11, 2011 #22
    Dear collegues

    i work with a manual shaking table and i need to obtain displacement from acceleration. I`ve learned that it`s better to integrate in frequency domain because double integration of acceleration in time domain is sometimes erroneous because the mean value of acceleration is not zero., but i don`t know how to calculate -omega^2, where omega is the frequency band. i would be most grateful if you could help me solve this problem.

  24. Jun 11, 2011 #23

    I'm also trying to determine omega from my data. I'm not sure what the frequency band is exactly or whether I can find it from data.
  25. Aug 23, 2011 #24

    But in this way the fft isn't symmetric anymore, since the acceleration fft is divided by -w^2. Or doens't matter?
  26. Sep 28, 2011 #25

    I have read all the posts in this thread. I am working on a project for kayaking where an accelerometer is gripped on the athletes wrist and he/she starts kayaking the acc data is collected from the run. The problem statement is the characterise events like paddle entry, exit, velocity, displacement etc. I am using a 3 axis accelerometer by I am assuming that when I collect the data g also plays a role and if I integrate it in either domain g will act in a direction unknown and therefore the results for velcoity and displacement will be inaccurate. Mind you there are no gyroscope or orientation reading available. It would be great if someone could give me an idea on how to do this, and also when the paddle hits the water there is acc jerk ( I like to call it)is produced which I used to characterize paddle entry. But since in kayaking the paddle entry and exit is really fast sometimes the jerk isnt much to charaterise these events. I am using matlab to do this. My basic approach is the pass the extrema function to get the maxima of the signal which is point of max acc i.e when the left paddle goes inside water assuming that the right wrist has the accelerometer on it. At this point the right paddle is in the air and almost static. after this when the right paddle goes inside water there is a decrease in acc and then it reaches the lowest point inside water where the acceleration is assumed to be minimum. Also in my calculations I assumed that the the lowst point inside water is the midpoint between the paddle entry and exit and there the paddle exit time was found out. Since the data wasnt very great many paddle entry and exit points were missed out. I tried all this in the time domain. Any suggestions would be appreciated.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook