Converting acceleration sensor data to displacement in real time?

Hi there, myself and a few care entering a competition where we need to track data on a rocket, and instead of using a gps, we thought of using an accelerometer to find the displacement of this rocket, x and z, in real time, and are going to plot it using excel

The accelerometer in question is the mpu6050, which will provide an x, y and z acceleration, which we should be able to use to more accurately and reliably plot the displacement of the rocket.

The rocket will not go very far, hardly 200m upwards, and the only horizontal force should be wind.

Of course, since this is non constant acceleration, we cannot use suvat, so doing a double integral would be the best option here. Question is, how do we go about doing that? What would the equation of the curve here be?

Many thanks in advance!

This tutorial describes the difficulties with integrating accelerometer data.

In your case the accelerations may be so high that you can ignore the gravity correction. However if the acceleration is higher than 16 g, (quite likely for a model rocket) then the MPU-6050 won't be useful.

Integration in DSP is simply addition, done at a fixed sample rate, something like this:

float velocity = 0.0;
float displacement = 0.0 ;
void update()
{
  float acceleration = readAcceleration() ;
  velocity += acceleration * delta_t ;
  displacement += velocity * delta_t ;
}

Assuming update() is called every delta_t seconds.

Drift is rapidly growing in such a calculation, so you always need a way to
zero it out, perhaps for a rocket you continuously zero it out until the moment of launch.

You can use static pressure to measure the z component.

Also fyi, SUVAT is integration.

This is basically a double integration and basically the same thing as what MarkT posted.

v = int(a) = at + u
p = int(v) = int(int(a)) = 0.5*at^2 + ut + p0

The OP is correct. The SUVAT formulas posted assume constant acceleration and are not applicable.

Since we don’t use SUVAT in this country, I had to google the formulas. This is what I gathered when I saw it. I googled it again and you are right, it says constant acceleration.

However, what difference does this make? In every iteration you can assume a constant acceleration. The constant u and p is just being updated after each iteration. That is exactly what MarkT posted.

Therefore, please prove mathematically why it doesn’t work.

jremington:
This tutorial describes the difficulties with integrating accelerometer data.

In your case the accelerations may be so high that you can ignore the gravity correction. However if the acceleration is higher than 16 g, (quite likely for a model rocket) then the MPU-6050 won't be useful.

I highly doubt our rocket will accelerate faster than 16g at any moment, and i am struggling to think of any other way to calculate the displacement, so we will likely use the accelerometer, unless you would be so kind as to suggest something different.

Do tell us what sort of rocket you have.

Simple numerical integration, such as MarkT's first order Euler method, works well only if the time interval delta_t is short enough that the acceleration can safely be assumed constant during the interval.

If height is your main goal, why not use a pressure sensor? You should be able to measure the displacement to 200m very accurately this way.