嗨,我遇到了lsm303dlhc的加速度计算问题
我读取寄存器并通过它们,但在x,y,z变量中包含疯狂的值,如果表格上有demoboard,则值必须为x:0,y:0,z:1000,但我得到x:-1499 y: -1499 z:4992。范围+ -2g。如果我有来自寄存器的值,请描述以m / s ^ 2计算加速度的过程
以上来自于谷歌翻译
以下为原文
Hi, I faced with the problem of accelera
tion calculations on lsm303dlhc
I read registers and past them, but in x, y, z variables contain crazy values, if demoboard is on the table, values must be x: 0, y: 0, z: 1000, but i get x: -1499 y : -1499 z: 4992. Range +-2g. Please, describe process of calculating acceleration in m/s^2 if i have values from registers
- HAL_I2C_Mem_Read(&hi2c1, 0x32, 0x28 , 1, (uint8_t*)&aTxBuffer[0], 1, 1);
- HAL_I2C_Mem_Read(&hi2c1, 0x32, 0x29 , 1, (uint8_t*)&aTxBuffer[1], 1, 1);
- HAL_I2C_Mem_Read(&hi2c1, 0x32, 0x2A , 1, (uint8_t*)&aTxBuffer[2], 1, 1);
- HAL_I2C_Mem_Read(&hi2c1, 0x32, 0x2B , 1, (uint8_t*)&aTxBuffer[3], 1, 1);
- HAL_I2C_Mem_Read(&hi2c1, 0x32, 0x2C , 1, (uint8_t*)&aTxBuffer[4], 1, 1);
- HAL_I2C_Mem_Read(&hi2c1, 0x32, 0x2D , 1, (uint8_t*)&aTxBuffer[5], 1, 1);
- pnRawData=((int16_t)((uint16_t)aTxBuffer[2*i+1] << 8) + aTxBuffer[2*i]);
- ////////////////////////////////////////////////////////////////////////////////////
- int16_t x = pnRawData[0];
- int16_t y = pnRawData[1];
- int16_t z = pnRawData[2];