|
各位高手,最近在处理加速度传感器的数据时,发现读取的原始数据有错误。
------x = -254, Y = 51, Z = 297
------x = 1, Y = 60, Z = 284
------x = -256, Y = 76, Z = 261
------x = -254, Y = 50, Z = 287
------x = 2, Y = 41, Z = 252
------x = 2, Y = 33, Z = 277
------x = -255, Y = 72, Z = 221
------x = 0, Y = 50, Z = 245
------x = -256, Y = 35, Z = 292
------x = -255, Y = 44, Z = 280
------x = -256, Y = 53, Z = 237
------x = -256, Y = 57, Z = 252
------x = 255, Y = 20, Z = 228
------x = -255, Y = 82, Z = 258
------x = 3, Y = 37, Z = 266
------x = 1, Y = 39, Z = 212
------x = -251, Y = 25, Z = 224
------x = -256, Y = 53, Z = 255
------x = 1, Y = 45, Z = 246
------x = -255, Y = 44, Z = 250
------x = 255, Y = 12, Z = 233
------x = -253, Y = 89, Z = 270
------x = -4, Y = 48, Z = 301
------x = 1, Y = 46, Z = 251
------x = -252, Y = 71, Z = 299
------x = 0, Y = 51, Z = 242
------x = 1, Y = 32, Z = 232
------x = -253, Y = 49, Z = 205
------x = -255, Y = 65, Z = 253
------x = 2, Y = 53, Z = 285
------x = -254, Y = 42, Z = 281
------x = -255, Y = 54, Z = 289
------x = 1, Y = 39, Z = 268
------x = 1, Y = 52, Z = 262
------x = -254, Y = 67, Z = 272
------x = -254, Y = 30, Z = 258
------x = -249, Y = 49, Z = 256
------x = 2, Y = 44, Z = 229
------x = 1, Y = 37, Z = 251
上面是读取的数据。Z轴由于有重力,所以读取的数据比较大,正常,Y轴也正常,唯独X轴的数据跳变比较严重。
我对原始数据的处理方法与陀螺仪的时候是一样的。
以下是寄存器的设置:
IIC_WriteReg(ACCELERATE_ADDR,DATA_FORMAT,0x0A);
IIC_WriteReg(ACCELERATE_ADDR,BW_RATE,0x0A);
IIC_WriteReg(ACCELERATE_ADDR,POWER_CTL,0x08);
IIC_WriteReg(ACCELERATE_ADDR,INT_ENABLE,0x80);
IIC_WriteReg(ACCELERATE_ADDR,OFSX,0x00);
IIC_WriteReg(ACCELERATE_ADDR,OFSY,0x00);
IIC_WriteReg(ACCELERATE_ADDR,OFSZ,0x00);
IIC_WriteReg(ACCELERATE_ADDR,ACCE_FIFO_CTL,0x9E);
我用了FIFO的STREAM模式,但用其他模式的时候,一样的问题。下面是数据处理的过程。
AcceRawData.x = (short int)( AcceData[1]<<8|AcceData[0]);
AcceRawData.y = (short int)( AcceData[3]<<8|AcceData[2]);
AcceRawData.z = (short int)( AcceData[5]<<8|AcceData[4]);
需要说明的是,在陀螺仪中,我使用的几乎是相同的算法,但是为什么用在这里就不对了呢?求指教 |
阿莫论坛20周年了!感谢大家的支持与爱护!!
曾经有一段真挚的爱情摆在我的面前,我没有珍惜,现在想起来,还好我没有珍惜……
|