mpu 6050 accelerometer value gives positive and negative values for one movement?

1.8k Views Asked by At

I am using an arduino uno, a gy-521 mpu 6050 and the Jeff Rowberg library. While the code is perfect the results are less than desirable. I am using the RealAccel option but when I move the accelerometer to the right the data is first correctly positive numbers increasing because of the rightward movement. But once I stop moving the device there are negative values appearing. For the most part there is an equal value for both positive and negative values, meaning if I moved the accelerometer the equivalent of '100' in the positive direction once I stopped moving there would also be multiple other negative values adding up to about a '-100'value. I assume this is because for every action there is an opposite and equal reaction but if not I would like to know why this happens and even if this is there case there must be a way around this, right ? I previously solved this by multiple if statements basically saying if any of the last 7 numbers were positive(because of noise) then the next x number of numbers would be zero but I would like to hear any other ideas or solutions for this problem.Thank you.

1

There are 1 best solutions below

0
On

If you accelerate an object in one direction, the object will never slow down or stop. It will keep going in that direction forever. The only way to slow down or stop is to have negative acceleration. You're right about the negatives equaling positives in your case - it's because you're starting at velocity zero and ending at velocity zero.

I think you're actually trying to calculate velocity in that direction, which will start at 0, go above 0, and then return to 0. To get that number, sum (accerations * (time difference)) from time=0 to whatever time you need the velocity. This is called a Riemann sum of accelerations.

For further reading, look for 'kinematics in one dimension'.