2025-11-11 19:31:34 +08:00
|
|
|
|
# 时间间隔 -- 软件模拟iic的情况下
|
2025-11-10 19:27:37 +08:00
|
|
|
|
|
|
|
|
|
|
目前测试代码如下:
|
|
|
|
|
|
|
|
|
|
|
|
```c
|
|
|
|
|
|
create_process(&test_id, "test",NULL, test, (int)(DELTA_TIME*1000));
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
对于test函数的调用时间设置的是10ms调用一次,test代码如下:
|
|
|
|
|
|
|
|
|
|
|
|
```c
|
|
|
|
|
|
void test(){
|
|
|
|
|
|
signed short acc_data_buf[3] = {0};
|
|
|
|
|
|
signed short gyr_data_buf[3] = {0};
|
|
|
|
|
|
signed short acc_gyro_input[6] = {0};
|
|
|
|
|
|
float Angle_output[3] = {0};
|
|
|
|
|
|
SL_SC7U22_RawData_Read(acc_data_buf,gyr_data_buf);
|
|
|
|
|
|
BLE_send_data = sensor_processing_task(acc_data_buf, gyr_data_buf);
|
|
|
|
|
|
//----省略-----
|
|
|
|
|
|
//一些ble数据发送
|
|
|
|
|
|
|
|
|
|
|
|
memset(&BLE_send_data, 0, sizeof(BLE_send_data_t));
|
|
|
|
|
|
memset(&data, 0, 50);
|
|
|
|
|
|
// xlog("end============\n");
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
sensor_processing_task当中就进行了计算,包括卡尔曼等,在timer设置成10ms的情况下,实际上test函数(或者是sensor_processing_task函数),距离上次调用到本次调用,实际间隔为40ms
|
|
|
|
|
|
|
|
|
|
|
|
计算距离不能直接采用timers设置的时间间隔作为dt来求距离,实际每次计算求速度的时间应该是40ms
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|