Converting Acceleration to Displacement: Is There a Simple Algorithm?

Click For Summary
SUMMARY

The discussion focuses on converting acceleration data from a single-axis accelerometer to displacement using numerical integration techniques. Participants recommend using methods such as the trapezoid rule and Simpson's rule for integration, emphasizing the importance of handling non-constant acceleration. A detailed iterative formula is provided for calculating velocity and displacement, which includes initial conditions and time intervals. Additionally, the conversation highlights the limitations of double integration due to noise and drift, suggesting alternative approaches like Fourier Transform for improved accuracy.

PREREQUISITES
  • Understanding of numerical integration methods (trapezoid rule, Simpson's rule)
  • Familiarity with Excel or Visual Basic for implementing algorithms
  • Basic knowledge of accelerometer data interpretation
  • Concept of Fourier Transform for frequency domain analysis
NEXT STEPS
  • Learn how to implement numerical integration in Excel using the trapezoid rule
  • Study the Fourier Transform (FFT) and its application in converting acceleration to displacement
  • Explore Kalman filters for improving data accuracy in motion analysis
  • Investigate methods for reducing drift in integrated acceleration data
USEFUL FOR

Engineers, data analysts, and researchers working with motion analysis, particularly those utilizing accelerometers for displacement calculations in various applications such as robotics, biomechanics, and structural monitoring.

timabram
Messages
3
Reaction score
0
Does anyone 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.
 
Engineering news on Phys.org
Just apply s=at, and d=st in separate columns in excel.
 
timabram said:
Does anyone 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.

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?).

russ_watters said:
Just apply s=at, and d=st in separate columns in excel.

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:
  • Like
Likes   Reactions: Naman S Kumar
George, if suitably modified, Russ' approach will work. Given accelerations and an initial velocity, you generate a column of velocities, v_n = v_{n-1} + a_n(t_n-t_{n-1}), 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:
Gokul43201 said:
George, if suitably modified, Russ' approach will work. Given accelerations and an initial velocity, you generate a column of velocities, v_n = v_{n-1} + a_n(t_n-t_{n-1}), ...

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

George Jones said:
Also, a sum (of rectangles) has to be taken, and the t is the time interval between readings, not the time of the readings.

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.

Gokul43201 said:
If the time intervals are all equal, you can simply repeat this procedure to generate displacements.

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

Integrate:

v_{n} = v_{n-1} + a_{n-1}(t_n - t_{n-1}).

Integrate again:

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.

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:
Thank you all

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



Thank you all !
 
George Jones said:
You need to use a routine for numerical integration, like the the trapezoid rule or Simpson's rule.

These don't work that well in this case, because neither speed nor acceleration are constant.
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:
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 ?
 
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.
 
  • #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 :


Integrate:

v_{n} = v_{n-1} + a_{n-1}(t_n - t_{n-1}).

Integrate again:

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.



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?

Thanks!
 

Attachments

  • graph accel.PNG
    graph accel.PNG
    13.5 KB · Views: 1,757
  • #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 don't 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 accommodate this. Anyone like to help?

Cheers Dave Smith
 

Attachments

Last edited:
  • #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.
 
  • #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..
 
  • #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?
thanks
 

Attachments

  • #15
wolfpackdiver said:
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..

Interesting, nice advice!
 
  • #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.
 
  • #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)
 
  • #18
wolfpackdiver said:
...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)

Actually, I was wondering. Thanks for this post. :wink:

I found out the name I was looking for earlier: complimentary filter.
 
  • #19
Good point. Estimation filters also will help your results. Look up Kalman filters in particular. (EKF, UKF, etc.) Thanks for the reminder.
 
  • #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?
 
  • #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.

Sincerely
 
  • #22
wolfpackdiver said:
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..

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.

Sincerely
 
  • #23
Bump.

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.
 
  • #24
wolfpackdiver said:
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..


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

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 isn't 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.
 
  • #26
sam15 said:
Hi,

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 isn't 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.

If you change the accelleration into a 3 equation parametric form (x, y, z), and integrate it twice, you should end up with the total displacement of the wrist in each of the three dimensions. From here, it becomes a distance formula problem. I.e., Displacement = sqrt(deltax^2 + deltay^2 + deltaz^2).

You will have to pardon my poor setup. I'm still new to the forum, and don't know how to express the symbols properly - so I used GameMaker 8 code format. :P
 
  • #27
I don't think you understand my question completely. Even if I do what you said how will the component of gravity separate from the calculation? I tried integrating to get the velocity but the values were inaccurate as the g ( acc due to gravity) played a role in the value if you know what I mean?
 

Similar threads

  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 25 ·
Replies
25
Views
60K
  • · Replies 4 ·
Replies
4
Views
6K
  • · Replies 4 ·
Replies
4
Views
3K
Replies
11
Views
24K
Replies
2
Views
1K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 9 ·
Replies
9
Views
10K
  • · Replies 12 ·
Replies
12
Views
24K
  • · Replies 1 ·
Replies
1
Views
1K