Numerical integration of data

Hello

i have data blocks of measurement-data from an acceleration sensor. But I need the displacement. By integration of this data two times i should get the displacement. But I have no idea how to write a program in C, that does this job. Who can help me ?

regards
Gerhard
Last edited on
The integration is your smaller problem; just sum the acceleration measurements, if it is only one dimensional:

da_X1 = measured acceleration [m/s^2], in T_SAMPLE [s]

speed_X += (((da_X1 +da_X2)/2) * T_SAMPLE) ; // in [m/s]
da_X2 = da_X1 ;

displacement_X += speed_X * T_SAMPLE ; // in [m]


The bigger problem is that due to the integration your error will be:

displacement_error ~ offsetError_inAcc * t^2 + standardDeviation_ofAcc * t^(1.5)

where t is the length of travel time. So the error in distance estimation can change between 30m/minutes to 3km/minutes!
I guess you have a second order ODE:

d''u/dt = f(); u'(0) = k; u(0) = j

setting x = u' you get a first order system of differential equations like this:

d'x/dt = g
du = x

with u'(0) = x(0) = k; and u(0) = j;

what you should do is pick up a numerical integrator like Euler, sympletic-Euler, Verlet or Runge-Kutta 4 and solve the equations iteratively using the result of iteration n to compute the iteration n+1;

for example using Euler it would be:

Iteration 0:
x(1) = x(0) + dt * g(0);
u(1) = u(0) + dt * x(0);

Iteration 1:
x(2) = x(1) + dt * g(1)
u(2) = u(1) + dt * x(1)

and so on...

Runge-Kutta 4 and verlet are two fourth order integrators so if you want to minimize the error you should pick up one of them .
Last edited on
Topic archived. No new replies allowed.