1 Introduction
-
Many friends often deal with the problem of converting the raw data of accelerometers and gyroscopes into other units when working on projects. This article will sort out and deduce it. 1) The common conversion units used in the application of the raw data of the accelerometer are: g, m/s^2, angle 2) The common conversion units used in the application of the raw data of the gyroscope are: °/s, red/s, angle
-
This is an update to the document "Comparison of Several Commonly Used Acceleration Sensing Parameters". In this article, the comparison of sensor parameters and accuracy parameters of different participants are written together. This article focuses on accuracy parameters and unit conversion.
2 Measurement range and accuracy
The measurement range and measurement accuracy of accelerometers and gyroscopes are given in MEMS sensing data sheets. The measurement accuracy can be calculated based on the measurement range. Whether it is acceleration or gyroscope, the data register is 16 bits. Since the highest bit is the sign bit, the output range of the data register is -7FFF-7FFF (-32767~32767). Gyroscope: If we choose the measurement range of the gyroscope to be ±2000, in the data sheet 16.4 LSB/(°/s) is 32767/2000 = 16.4. Then the corresponding relationship between the register number and the measurement range is calculated: for example
, The value of the gyroscope read through the register is 1000, then we find the angular
velocity Correspondence between the number in the register and the measurement range:
For example, if the value of the gyroscope read from the register is 1000, then we find the acceleration of gravity XX = 1000 / 2048 = 0.49g
3 Calculation unit conversion
- Calculation of accuracy under different ranges. The accelerometer range is: ±2g. The acquired accelerometer data is divided by 16384. The accelerometer range is: ±4g. The acquired accelerometer data is divided by 8192. The accelerometer range is: ±8g. The acquired accelerometer Divide the data by 4096. The accelerometer range is: ±16g. Divide the obtained accelerometer data by 2048.
2. Can be converted into data with physical units, unit: g(m/s^2)
2. Can be converted into angle through trigonometric relationship
float tanalpha = 0,tanbeta = 0,tangamma = 0;
tanalpha = (float)data->rawx / sqrt( ((float)data->rawy * (float)data->rawy + (float)data->rawz * (float)data->rawz) );
data->anglex = (float)atan(tanalpha)*57.3;
tanbeta = (float)data->rawy / sqrt( ((float)data->rawx * (float)data->rawx + (float)data->rawz * (float)data->rawz) );
data->angley = (float)atan(tanbeta)*57.3;
tangamma = (float)data->rawz / sqrt( ((float)data->rawy * (float)data->rawy + (float)data->rawx * (float)data->rawx) );
data->anglez = (float)atan(tangamma)*57.3;
- Calculation of accuracy under different ranges. The gyroscope range is: ±250 dps. The acquired gyroscope data is divided by 131. The gyroscope range is: ±500 dps. The acquired gyroscope data is divided by 65.5. The gyroscope range is: ±1000dps. Divide the gyroscope data by 32.8. The gyroscope range is: ±2000dps. Divide the obtained gyroscope data by 16.4 2. It can be converted into data with physical units, unit: rad/s
//原始数据
raw_data[AXIS_X] = (buf[0] << 8) | buf[1];
raw_data[AXIS_Y] = (buf[2] << 8) | buf[3];
raw_data[AXIS_Z] = (buf[4] << 8) | buf[5];
//坐标map转换
remap_data[icm_dev.cvt.axis[AXIS_X]] = icm_dev.cvt.sign[AXIS_X] * raw_data[AXIS_X];
remap_data[icm_dev.cvt.axis[AXIS_Y]] = icm_dev.cvt.sign[AXIS_Y] * raw_data[AXIS_Y];
remap_data[icm_dev.cvt.axis[AXIS_Z]] = icm_dev.cvt.sign[AXIS_Z] * raw_data[AXIS_Z];
//重力加速度计算 unit: m/s2
data->x = (float)remap_data[AXIS_X] * KSCALE_ACC_16G_RANGE;
data->y = (float)remap_data[AXIS_Y] * KSCALE_ACC_16G_RANGE;
data->z = (float)remap_data[AXIS_Z] * KSCALE_ACC_16G_RANGE;
//red/s
data->x = (float)remap_data[AXIS_X] * KSCALE_GYRO_2000_RANGE;
data->y = (float)remap_data[AXIS_Y] * KSCALE_GYRO_2000_RANGE;
data->z = (float)remap_data[AXIS_Z] * KSCALE_GYRO_2000_RANGE;
4. Simple verification of data correctness
From what I understand, if the accelerometer sensitivity is set to 16g, the value is 2048 = 1g. When the device is lying flat on a table, I expect to see the x and y accelerometer values close to zero, and z around 1g (i.e. 2048 raw values), which is what I've seen on other devices, but not this new one equipment. See the example in the attached screenshot.
Reprinted at: Reprinted 1
Reprinted at: Reprinted 2