回复【13楼】 洛阳单片机 :
---------------------------------
res=run_self_test(); //自检
返回值是Flase,
具体到里面
[mw_shl_code=c,true] accel_result = accel_self_test(accel, accel_st);
gyro_result = gyro_self_test(gyro, gyro_st);
result = 0;
if (!gyro_result)
result |= 0x01;
if (!accel_result)
result |= 0x02;
[/mw_shl_code]
具体的accel_result和gyro_result都应该返回0才对,但我的返回值是3和7,
[mw_shl_code=c,true]static int accel_self_test(long *bias_regular, long *bias_st)
{
int jj, result = 0;
float st_shift[3], st_shift_cust, st_shift_var;
get_accel_prod_shift(st_shift);
for(jj = 0; jj < 3; jj++) {
st_shift_cust = labs(bias_regular[jj] - bias_st[jj]) / 65536.f;
if (st_shift[jj]) {
st_shift_var = st_shift_cust / st_shift[jj] - 1.f;
if (fabs(st_shift_var) > test.max_accel_var)
result |= 1 << jj;
} else if ((st_shift_cust < test.min_g) ||
(st_shift_cust > test.max_g))
result |= 1 << jj;
}
return result;
}这是函数原形,看不懂
[/mw_shl_code]
感觉这个函数就是要自检抵消偏差的,不知道对不对,东西本来就是水平放置的,不知道问题出在哪
|