# How to remove constant accelerometer velocity offsetting?

For quite some time I have been working on a project and got stuck recently with a problem considering integrating vertical acceleration from a legendary MPU6050 to get vertical velocity. What I have been struggling with is the fact that velocity does not ever come back to 0. After every sequence of movement it just gets more and more off. It doesn't drift linearly anywhere, just stays constant, but wrong. It kind of seems, like the accelerometer was more sensitive detecting the acceleration in one direction than in the opposite one.

What may cause the problem? Is there any way to fix it with software? Switching to an IMU like BNO055, that is capable of doing the integration maths 'in chip' isn't a possibility right now. Thanks for all the help in advance. Have a nice day.

I guess you are sure the device is definitely at rest (v=0) after each event, and not just moving slowly?

If so a couple of possible causes to consider:

NUMERICAL: You might get this type of thing if the integration is inaccurate. Consider reducing sample interval, and use higher order integration. However, I would have expected numerical drift to be sometimes positive, sometimes negative. If it is always negative, numerical seems less likely to me.

INSTRUMENTAL: Does that accelerometer need to be "level"? Is it possible to repeat the experiment with the accelerometer mounted upside down to see if the effect reverses?

An immediate suggestion to better understand the problem (which you have probably already done) is compare the acceleration and velocity plots. As I recall once the system is underway the two curves should be 90 degrees out of phase, so there should be time alignment between peaks and zero crossing as in this sketch.

You could check the time alignment at those points. It might indicate if the drift is arising at a particular part of the cycle (as you suggest).

Pragmatic Adjustment: A perfect correction would require identification of the exact cause. However, depending on what you are using the velocity curve for it might be acceptable to implement a "pragmatic" fix in processing. As one idea, in an ideal world the areas under the two positive peaks (in accel plot) should balance the area above the negative peak. The observed drift (dv in picture) should equate to this difference. Hence for example, you may be able to introduce a percentage boost to the positive acceleration values. With a little thought this should be able to be automated.

However first I'd suggest looking at the time alignment and see if that reveals anything useful.

• @alan-solinski Hi Alan - interested to know if you had any feedback/update on the suggestions above. Thanks Apr 26, 2021 at 2:36