hey there
I've recently used MPU6050 Accelerometer/Gyroscope sensor to measure rotation angle. I've used complementary filters as explained here
but every time I turn on MPU6050, it has a -20degree offset! so for example at the beginning when I started reading the angles, it was ok(0 degrees) after a while it had -20degrees when was still and had no rotation. and yesterday, the offset was -40degrees(each time around -20degrees as I've said).
I don't know why this happens!
any help?
alaa72:
dear Idahowalker
yes, actually! or it isn't?
When you set the MPU on the table top what does accel Z axis read? Why?
Using all those floats, what is the MCU you are using? Using an Uno and lots of floatties, slow is to be expected.
Complementary filter, taken from my python code.
lastX = K * ( lastX + ( Gx * tDiff ) ) + ( K1 * AxRot )
lastY = K * lastY + ( Gy * tDiff ) ) + ( K1 * ayRot ) )
K = 0.93
K1 = 1 - K
I found K < .70 does a terrible job. You may find lowering the K to the lower 90's may give better results. Learn to use the graphing display in monitor to observe the oscillations and tune K to get the range of oscillations you want
For me calibration is 100 averaged readings with .1S between each reading, then doing the calibration math, storing the calibration data. I apply calibration data for accel during Ax, Ay, Az calculations:
I do not apply gyro offsets before calculating the scaled reading. Apply gyro offsets one step before the filter: Gx += ( GX_OFFSET - X_Rotation_Offest )
Most people determine the gyro offsets every time at startup, by averaging several hundred raw measurements taken while the sensor is held still.
After startup, subtract the average offsets from the raw readings, then apply scale factors. Yaw angles will always be relative to the starting sensor orientation.
Because gyro offsets are temperature and time dependent, the IMU output will still drift, but much more slowly.
First: I've accidently put the configuration part in the loop, so it took a lot of time to process this config part every time.
Second: I set K=0.69! and this responded around 1-2sec! whereas K=0.96(which is recommended) responds within 10sec!
that was my experience! and thanks all for sharing their great help!