|
最近有客户在使用YBX-BMI088模块时,可以读取到加速度计数据,但是数据有些异常,三轴加速度采集的数据,无法转换到正常Z轴9.8m/s2。陀螺仪及温度数据可正常读取。
BMI088模块支持SPI通讯方式,并且板载LDO电源,支持3.3V和5V电源输入。客户使用GD32F303开发板进行测试,并且根据帖子“NULCEO-G070RB开发板通过SPI方式使用BMI088加速度传感器的方法”中的硬件图进行连接,CSB1连接至PD11,CSB2连接至PB12。连接实物图如下:
单步调试代码,查看读取数据的变量值:
用串口打印输出加速度值:
可以明显看出加速度计的数据跳动比较大,不是有效的数据。
查看计算加速度计数据的公式,代码中:
设置的量程在6G,所以公式是正确的。
最后发现是读取的原始数据有问题,读取加速度计数据时,返回的第一个数据时假数据,第2个数据之后才是真实数据。 在BMI088手册第6.1.2 SPI interface of accelerometer part章节中: In case of read operations of the accelerometer part, the requested data is not sent immediately, but instead first a dummy byte is sent, and after this dummy byte the actual reqested register content is transmitted. This means that – in contrast to the description in section 6.1.1 – a single byte read operation requires to read 2 bytes in burst mode, of which the first received byte can be discarded, while the second byte contains the desired data.
返回的数据#2到#7对应0x12-0x17的加速度数据,在代码中进行调整后数据正常。
YBX-BMI088(SPI)加速度传感器模块的淘宝链接:https://item.taobao.com/item.htm?id=591903885679
|