MPU-6050的角速度全格感测范围为±250、±500、±1000与±2000°/sec (dps),可准确追踪快速与慢速动作,并且,用户可程式控制的加速器全格感测范围为±2g、±4g±8g与±16g。产品传输可透过最高至400kHz的IIC。MPU-6050可在不同电压下工作,VDD供电电压介为2.5V±5%、3.0V±5%或3.3V±5%,逻辑接口VDDIO供电为1.8V± 5%(MPU6000仅用VDD)。MPU-6050的包装尺寸4x4x0.9mm(QFN),在业界是革命性的尺寸。其他的特征包含内建的温度感测器、包含在运作环境中仅有±1%变动的振荡器。
在很多领域均有应用,比如智手机 平板设备,手持型游戏产品,游戏机,3D遥控器,可携式导航设备等等
简单地说,6050就是一个i2c器件,就像一个微控制器,要使用它,你得了解寄存器,初始化,读取,写入等等。
下面展示部分初始化,读取,写入代码
bool mpu6050_init(uint8_t device_address)
{
bool transfer_succeeded = true;
uint8_t inData[7]={0x00, //0x19
0x00, //0x1A
0x03, //0x6B
0x10, //0x1B
0x00, //0x6A
0x32, //0x37
0x01}; //0x38
uint8_t acc = 0x00;
m_device_address = (uint8_t)(device_address << 1);
// Do a reset on signal paths
uint8_t reset_value = 0x04U | 0x02U | 0x01U; // Resets gyro, accelerometer and temperature sensor signal paths
transfer_succeeded &= mpu6050_register_write(ADDRESS_SIGNAL_PATH_RESET, reset_value);
//设置GYRO
mpu6050_register_write(0x19 , inData[0]); //设置采样率 -- SMPLRT_DIV = 0 Sample Rate = Gyroscope Output Rate / (1 + SMPLRT_DIV)
mpu6050_register_write(0x1A , inData[1]); //CONFIG -- EXT_SYNC_SET 0 (禁用晶振输入脚) ; default DLPF_CFG = 0 => (低通滤波)ACC bandwidth = 260Hz GYRO bandwidth = 256Hz)
mpu6050_register_write(0x6B , inData[2]); //PWR_MGMT_1 -- SLEEP 0; CYCLE 0; TEMP_DIS 0; CLKSEL 3 (PLL with Z Gyro reference)
mpu6050_register_write(0x1B , inData[3]); //gyro配置 量程 0-1000度每秒
mpu6050_register_write(0x6A , inData[4]); // 0x6A的 I2C_MST_EN 设置成0 默认为0 6050 使能主IIC
// 0x37的 推挽输出,高电平中断,一直输出高电平直到中断清除,任何读取操作都清除中断 使能 pass through 功能 直接在6050 读取5883数据
mpu6050_register_write(0x37, inData[5]);
mpu6050_register_write(0x38, inData[6]); //使能data ready 引脚
//设置 ACC
mpu6050_register_write(0x1C,acc); //ACC设置 量程 +-2G s
// Read and verify product ID
transfer_succeeded &= mpu6050_verify_product_id();
return transfer_succeeded;
}
bool mpu6050_register_write(uint8_t register_address, uint8_t value)
{
uint8_t w2_data[2];
w2_data[0] = register_address;
w2_data[1] = value;
return twi_master_transfer(m_device_address, w2_data, 2, TWI_ISSUE_STOP);
}
bool mpu6050_register_read(uint8_t register_address, uint8_t * destination, uint8_t number_of_bytes)
{
bool transfer_succeeded;
transfer_succeeded = twi_master_transfer(m_device_address, ®ister_address, 1, TWI_DONT_ISSUE_STOP);
transfer_succeeded &= twi_master_transfer(m_device_address|TWI_READ_BIT, destination, number_of_bytes, TWI_ISSUE_STOP);
return transfer_succeeded;
}
最后附上MPU6050的驱动代码:https://download.csdn.net/download/m0_37887817/10329768