Calculating mobile displacement based on acceleration

I have written a mobile app that measures x y z accelerations. I am trying to convert the acceleration results into displacement but dont think a simple $d=\frac 1 2 {a {t^2}}$ will do the job. We have friction forces etc which will possibly effect the calculations. I have included a sample result where I simply push my mobile 5cm on one direction. Even though I push the mobile in 1 direction you can see that the acceleration oscillates around 0 line. You can use this if you think you got the right formulas.

This is the raw data if you need.

-0.002 -0.002 -0.253 13076.385
-0.002 -0.002 -0.228 13108.276
-0.008 0.002 -0.198 13126.648
-0.008 0.002 -0.178 13144.867
-0.007 0.002 -0.160 13161.835
-0.003 0.005 -0.144 13176.514
-0.002 0.001 -0.133 13209.686
0.001 0.001 -0.120 13226.684
0.001 0.004 -0.105 13243.408
0.001 0.004 -0.094 13261.383
-0.003 0.003 -0.085 13278.442
0.005 -0.000 -0.076 13298.523
0.004 -0.000 -0.069 13328.522
0.000 -0.000 -0.065 13344.848
0.000 -0.000 -0.059 13360.870
0.000 -0.000 -0.053 13378.021
0.000 0.003 -0.048 13410.065
0.000 0.003 -0.043 13427.124
-0.003 -0.004 -0.038 13443.146
-0.003 -0.004 -0.035 13460.388
-0.003 -0.000 -0.028 13477.814
-0.002 -0.000 -0.025 13511.169
0.001 -0.000 -0.026 13527.679
-0.002 0.003 -0.016 13543.945
-0.002 0.003 -0.015 13561.249
-0.002 0.003 -0.013 13578.003
-0.005 0.002 -0.015 13610.168
-0.005 -0.001 -0.014 13627.136
-0.001 -0.008 -0.012 13643.951
-0.001 -0.007 -0.011 13660.187
0.006 0.000 -0.010 13676.758
0.006 0.000 -0.009 13708.435
-0.005 0.000 -0.008 13725.311
0.002 -0.003 -0.007 13741.699
0.005 0.004 -0.014 13758.545
0.005 0.004 -0.012 13792.145
0.001 -0.000 -0.011 13809.906
0.001 -0.000 -0.010 13826.629
0.001 -0.000 -0.002 13846.466
-0.003 0.003 -0.002 13861.084
-0.003 0.003 -0.002 13879.639
-0.002 0.003 -0.001 13895.111
0.001 -0.001 -0.001 13927.337
-0.002 -0.001 -0.001 13946.533
-0.002 -0.001 0.002 13963.531
-0.002 -0.001 0.002 13978.943
-0.002 -0.001 -0.008 14011.047
0.006 -0.004 -0.008 14026.855
0.005 -0.004 -0.007 14043.487
-0.006 -0.003 0.004 14062.256
-0.005 -0.003 0.004 14079.651
0.002 -0.003 -0.003 14113.739
-0.002 0.004 -0.007 14131.470
-0.001 0.004 -0.006 14147.766
-0.001 0.004 0.008 14164.734
-0.001 -0.000 0.004 14180.420
-0.001 -0.000 0.004 14196.472
-0.001 -0.000 -0.007 14228.973
-0.001 -0.000 -0.006 14244.812
0.003 0.003 -0.006 14261.444
-0.001 -0.000 0.002 14278.473
-0.001 -0.000 0.002 14311.706
-0.004 -0.000 0.001 14328.094
-0.004 -0.000 0.001 14344.787
0.003 -0.007 0.001 14360.870
0.003 -0.003 -0.002 14376.434
0.003 -0.003 -0.002 14408.722
-0.001 0.004 0.002 14425.567
-0.001 0.004 0.001 14452.057
-0.001 0.004 0.001 14468.384
-0.004 -0.000 0.001 14487.671
-0.004 -0.000 0.001 14502.228
0.004 0.003 0.001 14531.799
-0.000 -0.004 -0.003 14553.741
-0.000 -0.004 -0.002 14580.047
0.007 0.000 -0.006 14600.525
0.006 0.000 -0.005 14600.860
-0.001 0.004 0.002 14617.401
-0.001 -0.004 0.002 14648.224
-0.001 -0.003 0.002 14664.337
-0.005 0.004 -0.002 14683.288
-0.004 -0.003 0.002 14711.212
-0.004 -0.003 0.002 14729.339
0.000 -0.003 -0.002 14748.840
0.000 -0.002 -0.002 14765.533
0.000 0.001 -0.002 14781.921
0.000 0.005 0.002 14798.248
0.000 0.004 0.002 14831.726
0.000 0.000 0.002 14848.175
0.000 0.000 0.001 14863.769
0.000 0.000 0.001 14879.577
0.000 0.000 -0.009 14899.658
0.000 0.000 -0.008 14932.190
-0.110 0.014 0.003 14949.921
-0.058 -0.015 0.003 14966.217
-0.052 -0.013 0.002 14982.849
-0.095 -0.009 0.002 15015.686
-0.086 -0.008 0.002 15016.174
-0.070 -0.004 -0.002 15047.607
-0.001 0.014 0.002 15063.110
-0.001 0.013 0.002 15079.681
-0.001 -0.013 0.002 15095.489
0.030 0.009 -0.002 15128.509
0.027 0.008 -0.002 15144.501
0.069 0.014 0.002 15160.187
0.062 0.013 0.002 15176.910
0.104 0.005 -0.002 15209.717
0.091 0.004 -0.002 15227.020
0.081 0.004 -0.002 15243.652
0.125 0.007 -0.001 15260.254
0.112 0.006 -0.001 15276.794
0.050 0.009 -0.001 15310.028
0.055 -0.023 -0.001 15327.179
0.049 -0.021 -0.001 15342.956
0.024 -0.001 0.003 15360.626
-0.037 -0.001 -0.001 15377.350
-0.033 -0.001 -0.001 15409.363
-0.030 0.003 0.006 15427.917
-0.027 0.002 0.005 15444.519
-0.024 -0.001 0.001 15461.426
-0.022 0.002 0.001 15477.447
-0.020 0.002 0.001 15509.918
-0.021 -0.005 -0.002 15527.801
-0.019 -0.005 -0.002 15544.739
-0.024 -0.008 -0.005 15561.828
-0.018 0.000 -0.001 15578.247
-0.016 0.000 -0.001 15611.084
-0.008 0.003 -0.001 15627.197
-0.011 0.007 0.002 15644.073
-0.010 0.006 0.002 15660.614
-0.012 -0.002 -0.005 15677.246
-0.011 -0.001 -0.004 15709.473
-0.006 0.002 -0.001 15727.173
-0.006 0.002 -0.001 15744.110
-0.005 0.002 -0.000 15761.688
-0.001 -0.002 -0.004 15777.893
-0.004 0.002 0.003 15811.432
-0.004 0.002 0.003 15829.712
-0.004 -0.002 0.003 15845.581
-0.003 -0.002 0.002 15862.915
0.001 -0.002 0.002 15882.110
-0.003 -0.005 -0.001 15896.820
-0.003 -0.004 -0.001 15928.924
0.001 0.003 -0.001 15944.977
0.001 0.003 -0.001 15961.456
0.004 -0.001 -0.004 15978.180
0.004 -0.004 0.006 16010.284
0.003 -0.004 0.006 16029.571
-0.000 -0.000 -0.002 16046.722
-0.000 -0.000 -0.002 16065.216
-0.000 -0.000 -0.001 16081.817
-0.007 -0.000 -0.001 16098.053
-0.006 -0.000 -0.001 16129.150
-0.002 -0.000 0.006 16145.843
-0.002 -0.000 0.005 16163.055
-0.002 -0.000 0.005 16179.565
-0.002 0.003 -0.003 16213.592
-0.002 0.003 -0.002 16230.499
0.006 -0.001 0.005 16247.162

• Area under the acceleration-time plot gives the velocity. The area under the velocity -time plot gives the displacement. Just numerically integrate the values you have using something like Simpsons rule. Remember to use the right units. – biryani Feb 17 '16 at 9:27
• That doesn't quite work. S you can see accelerations are both negative and positive almost same value while I am pushing the mobile only to 1 direction. – Amir Feb 17 '16 at 9:50
• Did you move your phone in the x direction? At what time did you start moving it?. Seems like you turned your sensors on and moved the phone vertically before moving it. – biryani Feb 17 '16 at 10:11
• Where the acceleration is increasing rapidly is when it is moving. Ignore the z one as it is not really much of issue. x and y can be difficult to work out as each android phone may have different way showing it but in this picture X should be the movement direction. – Amir Feb 17 '16 at 10:17
• When I start to push the phone, most likely the sensor is left behind and shows a negative acceleration, when I stop the phone the sensor is accelerating and possibly thats why it shows first negative and then positive even though it is in the same direction. When I use the absolute of the results it seems to be working fairly good. – Amir Feb 17 '16 at 10:18

Now is the perfect moment to get introduced to the world of calculus. Go learn it, specifically, Integration.

The problem with $d=0.5at^2$ is that it is based on the assumption that acceleration $a$ is constant. Look at your graphs... Is any acceleration constant ? No.
So, this equation is useless.

However, you can still approximate the displacement from this jaggy zig-zag accelerations. Calculus+Mechanics will help.

• I was looking for an answer not a lecture. I can do calculus bit in excel and it is not an issue. – Amir Feb 17 '16 at 9:44
• hehehe, sorry I didn't realise. But if you can do all this, then what is your problem, specifically? biryani already suggested Simpson's rule. – AneesAhmed777 Feb 17 '16 at 9:47

What you need is Dead Reckoning with Inertial Navigation Systems. Like others have suggested, you essentially want to do calculus on the data provided. Keep in mind that you need to do the calculus on the x y and z coordinates individually.

In performing the integration, there might be better techniques than a repeated Simpson's rule. A leap frogging or Runge-Kutta might give a smaller cumulative error. You'd need to adjust the standard form for second order differential equations.