1.What is the mpu6050?
The MPU6050 is an integrated 6-axis motion processing kit with a three-axis gyroscope and a three-axis accelerometer.
2.The function of MPU6050
Using the DMP hardware acceleration engine, 9-axis fusion data calculation can be output to the application through the main IIC interface.
3.Several important registers of the MPU6050
3.1.Power management registers1
DEVICE_RESET control reset, reset the MPU6050 when set to 1, and automatically clear the bit after the end.
SLEEP controls the MPU6050 operating mode, and after reset, this bit is 1 and enters sleep mode.
TEMP_DIS controls whether the temperature sensor is enabled, set to 0, it is enabled.
CLKSEL selects the clock source (usually set to 001).
3.2.Gyroscope configuration register
FS_SET [1:0] two bits to set the full-scale range of the gyroscope. Generally set to 3(±2000°/s).
3.3.Accelerometer configuration register
AFS_SEL [1:0] The two bits are generally set to 0(±2g).
3.4.FIFO enable registers
When reading simple data, you can use FIFO, and the corresponding bit can be set to 0.
3.5.Gyroscope sample rate divider registers
Set the gyroscope sampling frequency of the MPU6050 as follows: sampling frequency = gyroscope output frequency (1kHz) / (1+SMPLRT - DIV).
3.6.Configure the register
Focus on DLPF_CFG [2:0] these three digits, acceleration and gyroscopes are filtered according to these three configurations.
3.7.Power management registers2
Set the corresponding 6 bits to 0 and enter the working mode.
3.8.Gyroscope data output registers
Output gyroscope sensor data for three axes of x/y/z, with high byte first and low byte last.
3.9.Acceleration sensing data output registers
Output the accelerometer values of the three axes of x/y/z, with the high byte first and the low byte last.
3.10.Temperature sensor data output
Formula: Temperature=36.53+regval/340, where reval is the value read from 0x41 to 0x42.
4.Steps for MPU6050 initialization
4.1.Initialize the IIC interface
4.2.Reset the MPU6050
4.3.Sets the full-scale range of the angular velocity sensor and accelerometer.
4.4.Set other parameters (turn off interrupts, turn off the AUXIIC interface, disable FIFO, set gyroscope sample rate, etc.).
4.5.Configure the system clock and enable the angular velocity sensor and acceleration sensor
5.The use of DMP
DMP can directly convert the original data of the accelerometer and angular velocity sensor into a quaternion output, and after obtaining the quaternion, it can easily calculate the Euler angle, heading angle (yaw), roll angle (roll), pitch angle (pitch).
6.Calculation formula
q0=quat[0]/q30;q1=quat[1]/q30;q2=quat[2]/q30;q3=quat[03]/q30
pitch=asin(-2q1q3+2q0q2)57.3;
roll=atan2(2q2q3+2q0q1,-2q1q1-2q2q2+1)57.3;
pitch=atan2(2(q1q2+q0q3),q0q0+q1q1-q2q2-q3q3)57.3;