一.功能参数简介
bosch Sensortec公司推出的最新BMI160惯性测量单元将最顶尖的16位3轴超低重力加速度计和超低功耗3轴陀螺仪集成于单一封装.MI160采用14管脚LGA封装,尺寸为2.5×3.0×0.8mm3。当加速度计和陀螺仪在全速模式下运行时,耗电典型值低至950µA,仅为市场上同类产品耗电量的50%或者更低。
BMI160传感器的i2c 设备地址是 0x68(当sd0脚接地)/0x69(当sdo 脚拉高)。
二. 重要寄存器
-
芯片ID----R0:CHIPID 寄存器 ,值为 0xd1
-
R0x03:pmu_status— BMI160当前工作模式/状态寄存器
-
加速度Accelerometer field data
X轴16bit加速度数据
r0x12:ACCD_X_LSB acc_x_lsb[7:0] bit0–bit7
r0x13:ACCD_X_MSB acc_x_msb[15:8] bit0–bit7
Y轴16bit加速度数据
r0x14:ACCD_Y_LSB acc_y_lsb[7:0] bit0–bit7
r0x15:ACCD_Y_MSB acc_y_msb[15:8] bit0–bit7
Z轴16bit加速度数据
r0x16:ACCD_Z_LSB acc_z_lsb[7:0] bit0–bit7
r0x17:ACCD_Z_MSB acc_z_msb[15:8] bit0–bit7
- 陀螺仪角速度数据gyroscope field data
X轴角速度数据16 BIT(LSB/°/s)
r0x0c:gyr_x_lsb[7:0] bit0–bit7
r0x0d:gyr_x_msb[15:8] bit0–bit7
Y轴角速度数据16 BIT(LSB/°/s)
r0x0e:gyr_y_lsb[7:0] bit0–bit7
r0x0f:gyr_y_msb[15:8] bit0–bit7
Z轴角速度数据16 BIT(LSB/°/s)
r0x10:gyr_z_lsb[7:0] bit0–bit7
r0x11:gyr_z_msb[15:8] bit0–bit7
-
加速度量程配置寄存器r0x41:ACC_RANGE
0B0011:±2G RANGE;0b0101±4g;0b1000:±8g;0b1100:±16g -
控制寄存器r0x7e
0x11:set pmu mode of accelerometer to normal
0x15:set pmu mode of gyroscope to normal -
建议加速度及陀螺仪模块均使用系统默认参考配置
0x41----0x03 加速度量程±2g
0x40----0x28
0x42----0x28
0x43----0x00 角速度±2000°/s
三. 参考代码
-
3轴加速度数据读取参考代码:
i2c_write_byte(0x7e,0x11);
DelayMs(100);x =( i2c_read_byte(0x12) &0xff) ; x = x|(( i2c_read_byte(0x13) &0xff)<<8); if(x>0x7fff) { x = -(0xffff-x); } x = (x*9.8)/(0x8000/2);//当量程为±2g时,转换为g/s的加速度换算公式 y =( i2c_read_byte(0x14) &0xff) ; y = y|(( i2c_read_byte(0x15) &0xff)<<8); if(y>0x7fff) { y = -(0xffff-y); } y = (y*9.8)/(0x8000/2);//当量程为±2g时,转换为g/s的加速度换算公式 z =( i2c_read_byte(0x16) &0xff) ; z = z|(( i2c_read_byte(0x17) &0xff)<<8); if(z>0x7fff) { z = -(0xffff-z); } z = (z*9.8)/(0x8000/2);//当量程为±2g时,转换为g/s的加速度换算公式
-
3轴陀螺仪数据读取参考代码:
i2c_write_byte(0x7e,0x15);
DelayMs(100);x =( i2c_read_byte(0x0c) &0xff) ; x = x|(( i2c_read_byte(0x0d) &0xff)<<8); if(x>0x7fff) { x = -(0xffff-x); } x = (x*2000)/0x7fff;// range为2000dps时,转换为角速度°/s的公式 y =( i2c_read_byte(0x0e) &0xff) ; y = y|(( i2c_read_byte(0x0f) &0xff)<<8); if(y>0x7fff) { y = -(0xffff-y); } y = (y*2000)/0x7fff;// range为2000dps时,转换为角速度°/s的公式 z =( i2c_read_byte(0x10) &0xff) ; z = z|(( i2c_read_byte(0x11) &0xff)<<8); if(z>0x7fff) { z = -(0xffff-z); } z = (z*2000)/0x7fff; // range为2000dps时,转换为角速度°/s的公式
四. 调试注意事项
-
默认开机后bmi160进入suspend mode,此时bmi160的加速度及陀螺仪功能均处于未工作状态。需配置R0x7e寄存器使得加速度及陀螺仪功能进入正常工作(数据采样)模式。
by default bmi160 accel and gyro are in suspend mode after powering up the device.the device is powering up in less than 10ms. -
每次进行加速度数据检测前,请先执行i2c_write_byte(0x7e,0x11),使得加速度模块进入normal工作模式;
-
每次进行陀螺仪数据检测前,请先执行i2c_write_byte(0x7e,0x15) 使得陀螺仪模块进入normal工作模式;