I have acceleration data from a sensor. X Y & Z. I move the senor in the Y axis. Mostly in a straight line. So I ignore x & z.

From the sensor documentation 5.2.1 Acceleration output:

ax=((AxH<<8)|AxL)/32768*16g(g is Gravity acceleration,9.8m/s2)

ay=((AyH<<8)|AyL)/32768*16g(g is Gravity acceleration,9.8m/s2)

az=((AzH<<8)|AzL)/32768*16g(g is Gravity acceleration,9.8m/s2)

The data is in (m/s2)

I need a simple calculation that java or C# can take easily. I want to write something in code that calculates the acceleration over time to maximum velocity and average velocity. I need a "speed" value that I can display. For Ex. Max speed 12MPH and Average Speed 8MPH.

In this data the device was moved from the zero point to about 6 inches away less than 1 second.

Time(s) Acc X   Acc Y   Acc Z
48.547  0.4756  0.0864  1.2207
48.563  0.2051  0.2651  1.3350
48.563  0.0044  0.6621  1.3140
48.578  -0.2876 1.0117  1.4292
48.578  -0.0732 1.5586  1.4653
48.594  -0.0659 1.8984  1.3447
48.594  -0.2344 2.4453  1.4043
48.641  -0.2690 3.2148  1.3677
48.656  -0.4072 3.0083  1.4995
48.656  -0.2573 3.2700  1.3545

migrated from physics.stackexchange.com Jan 29 '18 at 21:44

This question came from our site for active researchers, academics and students of physics.


The equations at the start look like they're converting sensor data (pairs of 8 bit integer values) into floating point numbers. They're irrelevant to your problem.

What you need to do is :

$$v_k = v_{k-1}+a_k(t_k-t_{k-1})$$

For each time $t_k$ and with $t_0$ and $v_0$ the initial time and velocity.

To find the average velocity over the whole time you can do :

$$u=\frac {\sum v_k(t_k-t_{k-1})}{\sum(t_k-t_{k-1})}$$

The sum on the bottom simplifies to $t_N-t_0$.

  • $\begingroup$ For clarification tk = time interval, ak = acceleration interval $\endgroup$ – Steve Coleman Jan 29 '18 at 19:24
  • $\begingroup$ How can I solve for this if I don't know what VK is on the right side?vk=vk−1+ak(tk−tk−1) $\endgroup$ – Steve Coleman Jan 29 '18 at 19:33
  • $\begingroup$ You should know the initial $v_0$ (probably zero ?) and can in turn calculate each $v_k$ from that, so $v_1,\,v_2,\,v_3$ and so on. $\endgroup$ – StephenG Jan 29 '18 at 23:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.