加速度及陀螺儀傳感器BMI160

一.功能參數簡介
bosch Sensortec公司推出的最新BMI160慣性測量單元將最頂尖的16位3軸超低重力加速度計和超低功耗3軸陀螺儀集成於單一封裝.MI160採用14管腳LGA封裝,尺寸爲2.5×3.0×0.8mm3。當加速度計和陀螺儀在全速模式下運行時,耗電典型值低至950µA,僅爲市場上同類產品耗電量的50%或者更低。

BMI160傳感器的i2c 設備地址是 0x68(當sd0腳接地)/0x69(當sdo 腳拉高)。


二. 重要寄存器
1. 芯片ID----R0:CHIPID 寄存器 ,值爲 0xd1

2.    R0x03:pmu_status--- BMI160當前工作模式/狀態寄存器


3.    加速度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


4.    陀螺儀角速度數據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


5.    加速度量程配置寄存器r0x41:ACC_RANGE
0B0011:+-2G RANGE;0b0101+-4g;0b1000:+-8g;0b1100:+-16g

6.    控制寄存器r0x7e
0x11:set pmu mode of accelerometer to normal
0x15:set pmu mode of gyroscope to normal


7.    建議加速度及陀螺儀模塊均使用系統默認參考配置
0x41----0x03 加速度量程±2g
0x40----0x28

0x42----0x28
0x43----0x00  角速度±2000°/s

三. 參考代碼
1.  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的加速度換算公式

2.  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的公式


四. 調試注意事項

1.    默認開機後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.

2.    每次進行加速度數據檢測前,請先執行i2c_write_byte(0x7e,0x11),使得加速度模塊進入normal工作模式;
3.    每次進行陀螺儀數據檢測前,請先執行i2c_write_byte(0x7e,0x15) 使得陀螺儀模塊進入normal工作模式;
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章