你好Miroslav,我已经完成了IIS2DH加速器的以下配置。
///////////////////////////示例代码///////////////////// ///////////////////////////////
响应= LIS3DH_GetWHO_AM_I(安培; who_am_i);
如果(who_am_i == IC_READ_SUCCESS){
print('Who AM I%x r n',who_am_i); unsigned char响应,状态;
AxesRaw_t数据;
response = LIS3DH_SetODR(LIS3DH_ODR_10Hz);
如果(响应== 1){
打印( 'SET_ODR_OK r n');
}
response = LIS3DH_SetMode(LIS3DH_LOW_POWER);
如果(响应== 1){
打印( 'SET_MODE_OK r n');
}
response = LIS3DH_SetFullScale(LIS3DH_FULLSCALE_2);
如果(响应== 1){
打印( 'SET_FULLSCALE_OK r n');
}
response = LIS3DH_SetAxis(LIS3DH_X_ENABLE | LIS3DH_Y_ENABLE | LIS3DH_Z_ENABLE);
如果(响应== 1){
打印( 'SET_AXIS_OK r n');
}
response = LIS3DH_SetFilterDataSel(MEMS_ENABLE);
如果(响应== 1){
print('过滤数据选择启用 r n');
}而(1)
{
response = LIS3DH_GetAccAxesRaw(& data);
如果(响应== 1){
data.AXIS_X = data.AXIS_X>> 8;
data.AXIS_Y = data.AXIS_Y>> 8;
data.AXIS_Z = data.AXIS_Z>> 8;
print('x%d y%d z%d r n',data.AXIS_X,data.AXIS_Y,data.AXIS_Z);
}
}}
其他{
print('设备读取失败 r n');
} ///////////////////////////////////// ***** /////// ////////////////////////////////////////////
当我通过软复位重启thr board时,它给出了以下X,Y和Z原始数据:
x -1 y -1 z 0
x 0 y -2 z 1
x -1 y 0 z -2
x 0 y -1 z 1
x -1 y 0 z 0
x 1 y -1 z 0
x 0 y 0 z 0
x 0 y -1 z 0
x -1 y -1 z -1
x -1 y -1 z 0
x 0 y 0 z -1
x 0 y -1 z -1
x 1 y 0 z 0
x 0 y 0 z -2
x 0 y 1 z -2
x 0 y 0 z 0
x -1 y -1 z -2
x -1 y -1 z -1
x 0 y -1 z 0
硬盘重启时,跟随原始数据:
x -2 y 62 z -12
x -1 y 55 z -11
x -1 y 47 z -9
x -1 y 42 z -10
x -1 y 37 z -7
x -2 y 31 z -6
x -1 y 27 z -7
x -1 y 24 z -7
x 0 y 20 z -5
x -1 y 18 z -4
x -1 y 15 z -4
x -1 y 12 z -1
x -1 y 10 z -2
x 0 y 10 z -3
x -2 y 8 z -2
x -1 y 7 z -2
x -1 y 6 z -1
x -2 y 5 z -2
x -1 y 4 z -1
x 0 y 4 z -1
x 0 y 3 z -1
x 0 y 2 z -2
x -1 y 3 z -3
x 0 y 1 z -1
x -1 y 2 z -1
x 0 y 1 z -2
x -1 y 1 z -2
x 0 y 1 z 0
x 0 y 1 z -1
x -2 y 0 z 0
x 0 y 0 z 0
因此,在硬重启读数中,您已经看到前15-20个读数有些不可用,之后它的稳定读数几乎为零。为什么会这样?你能解决一下吗?
以上来自于谷歌翻译
以下为原文
Hello Miroslav, I have done following configura
tion for IIS2DH acceleromenter.
/////////////////////////// Sample Code ////////////////////////////////////////////////////
response=LIS3DH_GetWHO_AM_I(&who_am_i);
if(who_am_i==IC_READ_SUCCESS){
print('Who AM I %xrn',who_am_i);unsigned char response,status;
AxesRaw_t data;
response = LIS3DH_SetODR(LIS3DH_ODR_10Hz);
if(response==1){
print('SET_ODR_OKrn');
}
response = LIS3DH_SetMode(LIS3DH_LOW_POWER);
if(response==1){
print('SET_MODE_OKrn');
}
response = LIS3DH_SetFullScale(LIS3DH_FULLSCALE_2);
if(response==1){
print('SET_FULLSCALE_OKrn');
}
response = LIS3DH_SetAxis(LIS3DH_X_ENABLE | LIS3DH_Y_ENABLE | LIS3DH_Z_ENABLE);
if(response==1){
print('SET_AXIS_OKrn');
}
response = LIS3DH_SetFilterDataSel(MEMS_ENABLE);
if(response==1){
print('Filter Data Selection enablern');
}while(1)
{
response = LIS3DH_GetAccAxesRaw(&data);
if(response==1){
data.AXIS_X = data.AXIS_X >> 8;
data.AXIS_Y = data.AXIS_Y >> 8;
data.AXIS_Z = data.AXIS_Z >> 8;
print('x %d y %d z %drn',data.AXIS_X,data.AXIS_Y,data.AXIS_Z);
}
}}
else{
print('Device Read Failedrn');
}/////////////////////////////////////*****///////////////////////////////////////////////////
When I reboot thr board by soft reset it has given following X,Y and Z raw data:
x -1 y -1 z 0
x 0 y -2 z 1
x -1 y 0 z -2
x 0 y -1 z 1
x -1 y 0 z 0
x 1 y -1 z 0
x 0 y 0 z 0
x 0 y -1 z 0
x -1 y -1 z -1
x -1 y -1 z 0
x 0 y 0 z -1
x 0 y -1 z -1
x 1 y 0 z 0
x 0 y 0 z -2
x 0 y 1 z -2
x 0 y 0 z 0
x -1 y -1 z -2
x -1 y -1 z -1
x 0 y -1 z 0
And following raw data when Hard reboot the board:
x -2 y 62 z -12
x -1 y 55 z -11
x -1 y 47 z -9
x -1 y 42 z -10
x -1 y 37 z -7
x -2 y 31 z -6
x -1 y 27 z -7
x -1 y 24 z -7
x 0 y 20 z -5
x -1 y 18 z -4
x -1 y 15 z -4
x -1 y 12 z -1
x -1 y 10 z -2
x 0 y 10 z -3
x -2 y 8 z -2
x -1 y 7 z -2
x -1 y 6 z -1
x -2 y 5 z -2
x -1 y 4 z -1
x 0 y 4 z -1
x 0 y 3 z -1
x 0 y 2 z -2
x -1 y 3 z -3
x 0 y 1 z -1
x -1 y 2 z -1
x 0 y 1 z -2
x -1 y 1 z -2
x 0 y 1 z 0
x 0 y 1 z -1
x -2 y 0 z 0
x 0 y 0 z 0
So, in that hard reboot readings you have seen that first 15-20 readings are some unusaul and after that it has stable readings nearly to zero. Why this is happened? Can you please give some solution on that.