Analysis and Treatment of MPU6050 Common Problems


Preface

This article mainly analyzes and deals with the problems in the process of STM32 using MPU6050, and part of the content is also applicable to other single-chip computers. This article is based on the DMP algorithm that comes with MPU6050. The content of the article is helpful to the debugging process of MPU6050.


The following is the text of this article

One, IIC driver

STM32 hardware IIC has certain problems. Initialization of MPU6050 may cause initialization failure, so software IIC is recommended.

Second, the placement of MPU6050

By default, relative to the carrier coordinate system, rotation around the x-axis is roll (roll), rotation around the y-axis is pitch angle (pitch), and rotation around the z-axis is yaw (yaw). Attention is around.

If you regard the MPU6050 as an airplane, swinging the wings is the roll angle, swinging the nose up and down is the pitch angle, and swinging the nose left and right is the yaw angle.

The placement of the picture below is wrong
Figure 2.1

The placement of the picture below is correct, as described above.
Figure 2.2
Note that Figure 2.2 (the second image above) refers to the default situation. There is such a piece of code in the official DMP driver

static signed char gyro_orientation[9] = {
    
     1, 0, 0,
                                           0, 1, 0,
                                           0, 0, 1};

This is the coordinate matrix of MPU6050, which can be modified according to the actual placement. If you don't modify this matrix, you need to place it according to Figure 2.2, otherwise the value is definitely wrong.

Three, MPU6050 initialization

MPU6050 may get stuck during initialization. You can refer to the routine of punctual atom, and there is no problem in actual measurement.
MPU6050 DMP is with self-check function

		run_self_test();

run_self_test This function is used for self-test. MPU6050 will use the initial state as the Euler angle of 0 degrees. Whether or not it is flattened, the MPU6050 will use the initial state as the Euler angle of 0 degrees. After initialization, the MPU6050 will be calibrated slightly. The second data can be discarded appropriately.
Although the MPU6050 will be slightly calibrated, it must be flat during initialization . If you don't level it, there is a high probability of an error. Of course it is possible to succeed, but the data calibrated by MPU6050 will be biased.

Four, MPU6050 yaw angle (yaw) zero drift

The yaw angle of MPU6050 is abnormal, and it will jump even if it is stationary. This is purely a hardware problem, no matter how powerful the algorithm is, it can't be solved. It can only be solved by adding a magnetometer, or you can use MPU9250 directly, this is a built-in magnetometer. Be careful not to get too close to the motor when using, the magnetic field is easily disturbed.

Five, MPU6050 universal joint lock

Under the default ZYX order, I wonder if you have noticed this problem. When the MPU6050 only rotates the pitch angle, and the pitch angle is close to 90 degrees or equal to 90 degrees, the yaw angle will vary greatly. Then this is the gimbal lock. If you compare it to an airplane, when the airplane is 90 degrees upwards vertically, the airplane can only fly upwards no matter how you change the direction according to the ZYX sequence.
So don't let the pitch angle be vertical, this can reduce bugs.


Conclusion

So the above is all the content of this article.
If there is anything wrong or need improvement in this article, please point out.

Guess you like

Origin blog.csdn.net/qq_46554815/article/details/113121709