1. 6050 initialization failed
If 6050 fails to initialize, first check whether the read address is wrong
res=MPU_Read_Byte(MPU_DEVICE_ID_REG);
printf("mpu addr=%x\r\n",res);
if(res==MPU_ADDR)//Device ID is correct
{
MPU_Write_Byte(MPU_PWR_MGMT1_REG,0X01); //set CLKSEL,PLL X-axis as reference
MPU_Write_Byte(MPU_PWR_MGMT2_REG,0X00); //Acceleration and gyroscope both work
MPU_Set_Rate(50); //Set the sampling rate to 50Hz
}
else return 1;
I read out here is 0x68, different connection will also lead to different ID, if the address is correct, that is return 0, here for the initialization of the 6050 initialized through.
2, mpu initialization failure
Mpu initialization failure is common to return error code 8, you can step by step into the source code to analyze.
Solution I.
mpu_dmp_init() -> run_self_test() Here is the self-test, jump into the function can be seen, meaning that it needs to be placed horizontally in order to self-test successfully, so only the module can be placed horizontally, if not directly mask this part of the code can be.
Solution two.
Trace the source code: mpu_dmp_init() -> run_self_test() -> mpu_run_self_test(gyro, accel) -> accel_self_test(accel, accel_st)
Both the initialization is successful only when the absolute value of st_shift_var < the value of test.max_accel_var. And the absolute value of st_shift_var is different for different positions of MPU6050 modules. Only when the module is placed horizontally, the absolute value of st_shift_var is closest to the value of test.max_accel_var, if this parameter is not modified, the module needs to be placed horizontally according to method 1 for testing
Here you can print out the absolute value of st_shift_var and the value of test.max_accel_var when debugging, my solution here is to change the initialization value of test.max_accel_var from 0.14 to 0.16. Then the module will be initialized successfully when the module is placed horizontally. This is shown in the figure below:
3. Initialization passed, but the data is 0
Another situation is that all initialization passes, but the Euler angle data is all 0. This situation is because there is a hard delay in the code or the processing of other modules affects 6050, so the data is all 0. The personal test is to mask the data processing screen of a module after the test.
Read More:
- To be solved: one SSD failure, format failure
- Solutions for failure to start Axure RP (including failure to uninstall or install. Net framework)
- Doris query task failed to initialize storage reader
- Vue Error: initialize failed: invalid dom [How to Solve]
- termux Failed to initialize runtime
- Can’t initialize OCI. Error – 1 appears in toad for Oracle
- FileZilla server failed to initialize SSL Library
- Linux boot prompt “failed to initialize Hal!” solution
- [Handling Notes] Alternative reasons for Configuration system failed to initialize exception
- Unable to initialize GTK: could not open display
- Vue references echats and reports an error initialize failed: invalid DOM
- unity 3D:Virtual Reality SDK Oculus failed to initialize.
- MySQL — initialize failed to generate temporary password in error log after initialization
- An error commandnotfounderror (to initialize your shell) is reported when activating the virtual environment
- Network card problem: Unable to initialize Windows Sockets interface
- TIP: Unable to initialize gtk, is DISPLAY set properly?
- Fatal Python error: Py_Initialize: unable to load the file system codec.
- Unity3d open prompt failed to initialize unity graphic
- The app failed to start because there is no Qt platform to initialize
- NPM and cnpm installation failure solution