12-23-2020 11:54 AM
Hallo everyone
I have obtained the originaldata from BMI270, but these data are not processed. How to convert these data into data with standard units. For example: m/s^2 (accelerometer) and rad/s (gyroscope).
Thank you very much.
Accel_x | Accel_y | Accel_z | Gyr_x | Gyr_y | Gyr_z |
19 | -426 | 16660 | 1 | 4 | 1 |
10 | -421 | 16646 | 1 | 4 | 1 |
2 | -438 | 16671 | 2 | 3 | 1 |
205 | -580 | 16675 | 0 | 3 | -22 |
-818 | 889 | 17469 | 131 | -537 | -128 |
2022 | -591 | 16579 | 333 | -937 | 78 |
3457 | 1511 | 17143 | 961 | -97 | 177 |
2104 | 4447 | 15315 | 849 | 173 | -113 |
-113 | 6224 | 15604 | 383 | 880 | 5 |
-1441 | 4980 | 15571 | -276 | 1401 | -454 |
-3889 | 4206 | 14484 | -785 | 900 | -792 |
-6001 | 772 | 16052 | -1714 | -758 | -587 |
-3700 | -402 | 16576 | -1230 | -909 | -234 |
-3414 | -3738 | 17029 | -896 | -1380 | 127 |
1718 | -2842 | 16151 | 836 | -904 | 189 |
2032 | 787 | 18560 | 1090 | -179 | 217 |
Solved! Go to Solution.
12-23-2020 04:49 PM
Hello Eason,
There were example code in github.
For accelerometer, you could example file "https://github.com/BoschSensortec/BMI270-Sensor-API/blob/master/examples/bmi270/accel/accel.c".
/*!
* @brief This function converts lsb to meter per second squared for 16 bit accelerometer at
* range 2G, 4G, 8G or 16G.
*/
static float lsb_to_mps2(int16_t val, float g_range, uint8_t bit_width)
{
float half_scale = ((float)(1 << bit_width) / 2.0f);
return (GRAVITY_EARTH * val * g_range) / half_scale;
}
For gyroscope, you could example file "https://github.com/BoschSensortec/BMI270-Sensor-API/blob/master/examples/bmi270/gyro/gyro.c".
/*!
* @brief This function converts lsb to degree per second for 16 bit gyro at
* range 125, 250, 500, 1000 or 2000dps.
*/
static float lsb_to_dps(int16_t val, float dps, uint8_t bit_width)
{
float half_scale = ((float)(1 << bit_width) / 2.0f);
return (dps / ((half_scale) + BMI2_GYR_RANGE_2000)) * (val);
}