Acceleration to Velocity to Position

In summary, the speaker is working on a project using tri-axis accelerometers to track position. They initially assumed they could convert the data to appropriate units and numerically integrate to calculate velocity and position, but this resulted in nonsensical data. They then tried lifting the accelerometer straight up and integrating only the z-axis data using the trapezoidal method. However, this also did not provide accurate results and the graphs of acceleration, velocity, and position all looked the same. The speaker is unsure of their mistake and requests any insight or advice. They also mention using integration constants and ensuring accurate data sampling as potential issues. The speaker shares their MATLAB script for integration and acknowledges it is a simple approach but does not provide expected results. They are
  • #1
TOONCES
24
0
Hi everybody,

I'm currently working on a project using tri-axis accelerometers to track position. Initially I assumed I would just take the data given in G's, convert to m/s^2 or the English equivalent, and integrate the data numerically to get velocity and position with time. However, I have done this only to get nonsensical velocity and position data.

What I am doing is taking the accelerometer and lifting it straight up about 12 inches. Then taking only the z-axis acceleration data and converting it to English units, I integrate it numerically using the trapezoidal method. I am aware that this is not the best method of integration, but I assumed it would give a reasonable approximation of the position with time. The objective overall is to be able to pinpoint the position (with reasonable accuracy) at a given point in time. So, I wrote a MATLAB program to integrate over the data and spit out a value at each successive point. The main issue that I can see is that the graphs of acceleration, velocity, and position are all the same, just factored down to a certain degree.

I feel like I am just making a simple mistake, but I can't see it right now. Any insight is appreciated. Some success in this area or a journal paper would be great as well.

Thank you
 
Physics news on Phys.org
  • #2
don't forget to first subtract the acceleration due to gravity, and double integrate. I would suggest using SI units and converting the displacement as the final step.
 
  • #3
I have the accelerometer set to ignore the acceleration due to gravity. I have considered using SI units (I think i may have at one point), but the initial tests were just to see if the position found was similar to the actual position of the accelerometer.
 
  • #4
Not sure if this is homework. Can you show the math you are using as pseudo code?
 
  • #5
I'll assume you zero the initial velocity and displacement and make sure it's not moving when you start things up. Obviously, when you integrate from acceleration, you also need the integration constants, and without sensors for them, you must assume 0s at the start and keep track of current values as you go.

I'm sure seeing some graphs and knowing what you were doing at the time would help. I have worked on such things before (train control software) and accelerometers alone will accumulate error. I had the advantage that a train is a massive object that doesn't change acceleration very quickly during normal operation (if all goes well!), and we also counted the revolutions of the wheels for displacement. Probably not the case for you.

You'd have to ask yourself what is it measuring? Average acceleration since last time you read it's output? Or, most likely, the instantaneous acceleration at the time you read it? Assuming that was representative of the average acceleration since you last read the value might be a poor assumption at times. The more data points, generally, the better.

For example, if it stops moving right before a data sampling, you might think it wasn't accelerating for that entire interval, but for most of it, it was. It's now going faster than you think it is.

One other thing that can really mess things up is jitter in sampling the data. If you mean for it to be read every 100ms, for example, but it's sometimes 60ms, sometimes 130ms, etc, that can really mess with the integrator. Errors propagate to velocity and acceleration, and accumulate over time.

Of course I'm assuming no coding error, or error in hooking them up. :smile:

I wouldn't hold my hopes up for any amazing accuracy with this method, and it only gets worse with time, sorry to say. Good luck and have fun with it, though! Fun things to play with.
 
  • #6
Grep said:
I'll assume you zero the initial velocity and displacement and make sure it's not moving when you start things up. Obviously, when you integrate from acceleration, you also need the integration constants, and without sensors for them, you must assume 0s at the start and keep track of current values as you go.

I have thought about the integration constants, but I'm nt too sure of what to be using for them or how. I would say just taking the last value i calculated and adding it to the current value being calculated (?) or something to that effect. Like keeping a tally going for each finite integration i have sum that value with each successive integration...I am going to try that now and see how it works.

Grep said:
One other thing that can really mess things up is jitter in sampling the data. If you mean for it to be read every 100ms, for example, but it's sometimes 60ms, sometimes 130ms, etc, that can really mess with the integrator.

I have some documentation that shows that the accelerometer I am using is fairly reliable for sampling rate accuracy and the documentation that is provided with the accelerometer states that the measurements are quite accurate themselves. I guess I probably should do some baseline experiments to double check that but for the current scope any accuracy within +/- 15% would be reasonable.


rcgldr said:
Not sure if this is homework. Can you show the math you are using as pseudo code?

Here is the MATLAB script I am using to integrate the data. where Az is the vector of acceleration given in accelerometer counts, az is the converted acceleration in ft/s^2, vz, is the velocity after integration, xz is the position after integration, the while loops are the actual integration, and the rest is a couple of coding variables.

Nothing too fancy, I know, just an initial step that I thought would give value that i can work with. Which did not happen.

t=time;
az=(Az/16384)*32.174;
P=length(az);
vz(length(Az),:)=0;
xz(length(Az),:)=0;
i=1;
j=1;
while (i<P)
vz(i,:)=(t(i+1)-t(i))*((az(i)+az(i+1))/2);
i=i+1;
end

while (j<P)
xz(j,:)=(t(j+1)-t(j))*((vz(j)+vz(j+1))/2);
j=j+1;
end

plot(xz)


If someone requests graphs of my data I will provide but for now I will hold off on that. I don't feel like they are of much use.

Thank you for your input
 
  • #7
TOONCES said:
t=time;
az=(Az/16384)*32.174;
P=length(az);
vz(length(Az),:)=0;
xz(length(Az),:)=0;
i=1;
j=1;
while (i<P)
vz(i,:)=(t(i+1)-t(i))*((az(i)+az(i+1))/2);
i=i+1;
end

while (j<P)
xz(j,:)=(t(j+1)-t(j))*((vz(j)+vz(j+1))/2);
j=j+1;
end

plot(xz)
You need to include the current velocity and position in your calculations. I'm not sure of the syntax, but wouldn't vz(i,:) mean all the number in vz from 1 to i?

t=time;
az=(Az/16384)*32.174;
P=length(az);
vz(length(Az),:)=0;
xz(length(Az),:)=0;
i=1;
vz(i)=0+((t(i+1)-t(i))*((az(i)+az(i+1))/2));
i=i+1;
while (i<P)
vz(i)=vz(i-1)+((t(i+1)-t(i))*((az(i)+az(i+1))/2));
i=i+1;
end

j=1;
xz(j)=0+((t(j+1)-t(j))*((vz(j)+vz(j+1))/2));
j=j+1;
while (j<P)
xz(j)=xj(j-1)+((t(j+1)-t(j))*((vz(j)+vz(j+1))/2));
j=j+1;
end

plot(xz)
 
  • #8
rcgldr said:
You need to include the current velocity and position in your calculations. I'm not sure of the syntax, but wouldn't vz(i,:) mean all the number in vz from 1 to i?

I'm actually working on adding the current velocity and position into the code right now. I believe, for matlab, I need to have it formatted at vz(i,:) because it is a matrix and in order to place a new number in each successive slot the colon needs to be there. I have tried it without the colon and it doesn't work. I haven't used the program in awhile though.

I will try adding the current states in and update my progress. Thank you.
 
  • #9
The graphs look way better now just a bit of an issue with the magnitude. For an 8 inch test in one direction the results are giving me 2.5 feet. I was only able to change the code just slightly and not really look it over so I may still have some mistakes. I will run some more tests later today and post if my problems are fixed. Thank you guys for your help.
 
  • #10
HI TOONCES,
I´m working in something similar, need to capture/mesure the position x,y,z in time t1,t2,t3...etc. I´m using a 3axis accelerometer. How did your test go??, could you give me some tips to start figure it out.

Thanks for advance.
 
  • #11
HI TOONCES
i happen to use the accelerometer to trace the motion of the pen.
However we are not getting the desired output. Could you please provide us with the graphs of your data?
And a little bit of help with the MATLAB code would be appreciated. Currently we are trying to double integrate the acceleration values to get the displacement vector
Please guide us
Thank you in advance
 
  • #12
I think most of my data is on the accelerometers still. Which belong to the school.. But I may have something useful buried in my flash drive (or hard drive). I'll look around for it because I'm still very interested in this project, I just don't have much time to work on it.

Now, if you could tell me a few things about your project:

-What type of accelerometer are you using? (is it 3-axis, what's the name of it, etc.)
-What type of data does it output? (is the data in G's or does it need to be converted, does it give accel in each axis and a vectored accel or one of those)
-Could you give me a brief description on the settings that you have your accelerometer set too? (some have high/low pass filters, sampling rate, anything that may be relevant)
-Does your accelerometer account for the gravitational acceleration? (does it read 1G when standing still)

Now, as far as MATLAB goes, I need all the information above to help much more, but if you could give me an idea of the kind of code/methods you are using to integrate that would help a lot.


Also, tracing the motion of a pen seems like a very sensitive (a stat sheet on the accelerometer would be nice) task. I would suggest starting off with more controlled experiments with the accelerometer to get the motion stuff down. What I wanted to do but couldn't was get something that will move at a constant positive controllable acceleration. This will make the analysis much more reliable. Finally, the movement of a pen seems like a small gyroscope might be helpful. A gyroscope in tandem with an accelerometer is why the iphone can do some of the things that it can do. These are also moderately expensive, and that sort of project is fairly difficult/time consuming.

I hope all of that helps. I will try to find my info and post it, if it is helpful at all.
 
  • #13
We are using MMA7260QT, which has variable sensitivity (1.5g,2g,4g and 6g).
Its output is in volts giving output along each axis one by one.
As such only sensitivity has to be set, it has onboard single-pole switched capacitor filters.

We actually used the code that you have posted in your earlier reply, to integrate.
And when still, it does not give a zero value..but the value at rest changes every time we check.

Thank You, for your efforts.

We tried plotting the values and we did get some plots but they are nowhere close to the path that the accelerometer actually moves along.
 

FAQ: Acceleration to Velocity to Position

1. What is the difference between acceleration, velocity, and position?

Acceleration refers to the rate of change of an object's velocity over time. Velocity is the rate of change of an object's position over time. Position is the location of an object in space at a particular time.

2. How is acceleration related to velocity and position?

Acceleration is directly related to both velocity and position. An object's acceleration affects its velocity, which in turn affects its position over time. This relationship can be described using the equations of motion.

3. What is the formula for calculating acceleration?

The formula for acceleration is a = (vf - vi) / t, where a represents acceleration, vf represents final velocity, vi represents initial velocity, and t represents time.

4. How does acceleration affect an object's motion?

Acceleration can cause an object to speed up, slow down, or change direction. The direction of an object's acceleration is in the same direction as the net force acting on the object.

5. How is acceleration measured and represented?

Acceleration is typically measured in units of meters per second squared (m/s²). It can be represented using positive or negative values, depending on whether the object is speeding up or slowing down, respectively.

Back
Top