[Physics] Calculating Velocity from Acceleration (Accelerometer)

accelerationkinematicssensorvelocity

I am using the Accelerometer in an Android Device to track and detect certain motions, using only one axis as the motions are linear along that axis.

I am using a simple filter to remove the noise from the accelerometer data:

ouput = ouput + alpha * (input - output)

The result looks like I would expect and seems usable for my purposes:

Acceleration X Axis

I want to calculate velocity from the accelerometer data I'm getting, but this is where I run into problems, as can be seen here:

Calculated Velocity X Axis

As with the acceleration, the velocity curve looks plausible, but it doesn't return to zero after each repetition and falls off into negative values.

For now, I'm just writing the raw accelerometer data to a file and later modify and analyze it using spreadsheets, so these calculations are all done by hand.

  • It is raw data, and thus includes the effect of gravity, which I just subtract (I'm using the average of the values of the short period at the beginning in which there is no movement, in this case it was 9.55)
  • I have the timestamp of each data point, so I know the interval between readings
  • I'm using the simple formula V = V0 + A * dt to calculate velocity.
    • V0 is initially zero, then it's set to the previous value
    • A is the adjusted acceleration (i.e. accel - grav)
    • dt is the interval, the difference between the current and previous timestamp

I thought that the issue maybe is that the acceleration does not return to zero either and instead stays slightly below zero (as can bee seen in the first image above), which adds too many negative values that propagate in the calculation. So I set grav to be a smaller number, and there seems to be a sweet spot. In this example, large values for grav lead to the velocity dropping into negative, small values reverse the effect, with the velocity curve rising toward higher positive values.
Right around grav = 9.3 (9.32 in this image), the graph seems to be most plausible. This interval is very small, 9.28 and 9.35 already show significant tendency to go up or down, respectively.

Calculated Velocity X Axis with grav=9.32

What could be the reason for this? Where does the ~9.32 come from? Why is it not the ~9.55 that I observe during the initial motionless period? Is there some way I could modify the calculations to get more consistent values? For example between each repetition there should be a short period of V = 0.

Best Answer

Calibrate and validate. These are two words you need whenever you are doing calculations of physical parameters from measurement. You need to know how the device responds to known accelerations in order to determine whether the numbers you are getting are meaningful at the level you want to use them. The easiest would be if the manufacturer provided you with such details. Sadly, these days, devices of this type often come with no documentation whatever.

The fact you are getting 9.3 to 9.5 for gravity is suggestive. It suggests you have either an offset or a scale issue. One way to check this would be to read the values with the device sitting on a table, then turn it upside down and read again. An offset will show as a difference up-to-down. A scale issue will show low values both ways.

If you have a way to put the device in a situation with a known acceleration that would help also. Maybe a turn-table or some such? Though some such devices might be fooled by spinning in too tight a circle.

The steady drift suggests you could have a response issue. It may not be linear with acceleration. A narrow-but-high spike may be clipped, for example. Testing for such gets pretty complicated. You would need known acceleration profiles and then see how the device responds. Correcting for it adds more complication still.