基于openharmony的QMI8658六轴惯性模块开发 原创 精华

再见南丫岛
发布于 2022-4-7 13:02
浏览
2收藏

1、QMI8658介绍

为6轴MEMS 惯性测量单元 (IMU),集成了一个 3 轴陀螺仪和一个 3 轴加速度计。
QMI8658 是一款完整的 6轴 MEMS 惯性测量单元 (IMU),集成了一个 3 轴陀螺仪和一个 3 轴加速度计。将 QMI8658 与 XKF3 9D 传感器融合一起使用时,该系统具有准确的 ±3° 俯仰和滚动方向以及 ±5° 偏航/航向的典型规格。具有 ±3% 的严格板级陀螺仪灵敏度、15 mdps/√Hz 的陀螺仪噪声密度和低延迟,QMI8658 非常适合高性能消费类和工业应用。它提供了一个 UI 接口(支持 I3C、I2C 和 3 线或 4 线 SPI)。QMI8658集成了称为 AttitudeEngine 的高级矢量数字信号处理器 (DSP) 运动协处理器。 AttitudeEngine 以高内部采样率有效地编码高频运动,在较低频率的输出数据速率下保持完全的准确性。这使应用程序能够利用低输出数据速率 (ODR) 或按需(主机轮询),同时仍能获取准确的 3D 运动数据。 AttitudeEngine 可减少主机处理器上的数据处理和中断负载,而不会影响 3D 运动跟踪精度。结果是非常低的总系统功耗和高精度,这对于许多便携式和电池供电的应用程序至关重要。
▪ Low 15 mdps/√Hz gyroscope noise, low-latency,and wide bandwidth for performance applicationssuch robotic vacuums, industrial tilt modules,pedestrian navigation and GNSS augmentation, 5G 、antenna stabilization, inertial navigation, and large industrial UAVs
▪ Low Noise 200µg/√Hz accelerometer
▪ Host (slave) interface supports MIPI™ I3C, I2C, and 3-wire or 4-wire SPI
▪ Accelerometer and gyroscope sensors feature signal processing paths with digitally programmable data rates and filtering
▪ Complete inertial measurement unit (IMU) with sensor fusion library with specified orientation accuracy of ±3ºpitch and roll, ±5ºyaw/heading
▪ High-performance XKF3TM 6/9-axis sensor fusion with in-run calibration for correction of gyroscope bias drift over-temperature and lifetime
▪ 3-axis gyroscope and 3-axis accelerometer in a small 2.5 x 3.0 x 0.86 mm 14-pin LGA package
▪ Integrated Gen 2 AttitudeEngineTM motion coprocessor with vector DSP performs sensor fusion at 1 kHz sampling rate, while outputting data to host processor at a lower rate – improving accuracy while reducing processor MIPS, power, and interrupt requirements
▪ Large 1536-byte FIFO can be used to buffer sensor data to lower system power dissipation
▪ Motion on demand technology for polling-based synchronization

2、代码移植

注意实现寄存器的I2C读和写操作即可。代码如下。

unsigned char qmi8658_write_reg(unsigned char reg, unsigned char value)
{
	uint8_t write_data[3] = {reg,value};
    hi_i2c_data i2c_data = {0};
    i2c_data.send_buf = write_data;
    i2c_data.send_len = 2;
 
    uint32_t result = hi_i2c_write(IIC_INDEX, (QMI8658_addr<<1), &i2c_data);
    if(result == 0){
        result = 1;
    }
	return 0;
}
unsigned char qmi8658_read_reg(unsigned char reg, unsigned char* buf, unsigned short len)
{
	hi_i2c_data i2c_data = {0};
    uint8_t  buffer[1] = {0x00};
    buffer[0] = reg;
    i2c_data.send_buf = buffer;
    i2c_data.send_len = 1;
    i2c_data.receive_buf = buf;
    i2c_data.receive_len = len;
    return hi_i2c_writeread(IIC_INDEX, (QMI8658_addr<<1), &i2c_data);
}

3、代码使用

注意是初始化,然后直接读取加速度计数据和陀螺仪数据即可。因为只是验证了其基本功能,其他的一些复杂的使用。感兴趣的同学可以自行探索。

STATIC mp_obj_t machine_exb_mems_init(mp_obj_t self_in) {
    gboard_exb_obj_t *self = MP_OBJ_TO_PTR(self_in);
    qmi8658_init();//初始化
    return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(machine_exb_mems_init_obj, machine_exb_mems_init);

STATIC mp_obj_t machine_exb_read_acc_gyro(mp_obj_t self_in) {
    gboard_exb_obj_t *self = MP_OBJ_TO_PTR(self_in);
    float acc[3];
    float gyro[3];
    qmi8658_read_sensor_data(acc,gyro);//读数据。
    DEBUG_printf("%f %f %f %f %f %f\r\n",acc[0],acc[1],acc[2],gyro[0],gyro[1],gyro[2]);
    return mp_const_none;
}

4、相关资料

规格书,驱动代码等,见附件。

©著作权归作者所有,如需转载,请注明出处,否则将追究法律责任
标签
QMI8658开发资料.zip 3.93M 1312次下载
4
收藏 2
回复
举报
3条回复
按时间正序
/
按时间倒序
红叶亦知秋
红叶亦知秋

感谢整理分享,学习下楼主的附件

回复
2022-4-7 13:47:25
hufeiying
hufeiying

感谢楼主整理,学习学习。。附件

回复
2022-12-6 13:34:23
细嗅蔷薇05
细嗅蔷薇05

这好像是国产模块,能基本代替6050,下次做小车用这个模块试试。

回复
2022-12-7 19:44:58
回复
    相关推荐