mpu6050 icon indicating copy to clipboard operation
mpu6050 copied to clipboard

Soft calibration

Open filmo opened this issue 6 years ago • 8 comments

Performs a software calibration of the 6050 to zero it out. Could possibly be extended to write the calibrations to the 6050 registers with a bit of rework.

filmo avatar Mar 10 '18 23:03 filmo

Wow this looks really neat. Thanks! Before I merge this I want to take a closer look at the code, which I'll do in a few days.

m-rtijn avatar Mar 11 '18 14:03 m-rtijn

Feel free to change or make suggestions. The progress 'print' is for python 3. Could be eliminated or made more flexible to accommodate 2.7 (line 280).

filmo avatar Mar 12 '18 00:03 filmo

Did you test it with python3? As far as I know the python-smbus is not compatible with any python version higher than 2.7.x.

m-rtijn avatar Mar 24 '18 10:03 m-rtijn

I actually only used it on Python 3.5. Didn't test on 2.7. One potential issue is that my print statement for the 'progress' on line 280 is python 3 specific.

Your package is being used on donkey car which is python 3 / raspberry pi oriented.

I'll take a look at smbus specifically this weekend

filmo avatar Mar 24 '18 17:03 filmo

Oh that's pretty interesting. I haven't used my module for a while, but last time I did the smbus module was not available in Python 3. I'm going to test that asap.

m-rtijn avatar Mar 24 '18 18:03 m-rtijn

Hey, I currently don't have any working MPU-6050s on hand (I fried my last working one) to test it, so I'm afraid it will have to wait for some time.

m-rtijn avatar Apr 15 '18 10:04 m-rtijn

Performs a software calibration of the 6050 to zero it out. Could possibly be extended to write the calibrations to the 6050 registers with a bit of rework.

If I understand your code correctly, you calculate the mean of ~200 readings for each sensor axis, to then subtract the value from a scaled reading in get_accel/get_gyro, correct? This simply removes any bias/drift we observe in a still environment?

juliangaal avatar Apr 09 '19 13:04 juliangaal

I wrote similar version to calibrate. It works fine while rotate around same axis. But after active rotation around all axis it stops be precise after some time. I have feeling it should be calibrated in 6 rotations first. And next 6 result offsets should be interpolated at runtime depending on which rotation is closer. Similar to Beta Flight or INAV software.

image

Spirit30 avatar Sep 13 '22 20:09 Spirit30