Calibrating IMC-20602

By jaclilsys , 14 March 2018

Hi,

We are using our own board for an industrial sensor but I can not figure out how to correctly calibrate it. Everything else works, we are using the SPI interface and the code is based on the "ICM20602_eMD_nucleo_1.7 / icm20602_lite" project.

When data is ready these functions are called:

apply_mouting_matrix(cfg_mounting_matrix, raw_acc, sRacc_data);
apply_mouting_matrix(cfg_mounting_matrix, raw_gyro, sRgyro_data);

Followed by:
algorithms_process(); that contains the following:

		const int32_t raw_accel_q25[3] = {
(sRacc_data[0] * ACC_SENSITIVITY) << (25 - 16),
(sRacc_data[1] * ACC_SENSITIVITY) << (25 - 16),
(sRacc_data[2] * ACC_SENSITIVITY) << (25 - 16),
};
int32_t accel_bias_q25[3];
int32_t accel_cal_q25[3];

Algo_InvnCalibration_AccelCalibrationGyroOptionalFxp_UpdateAcc(sCalAcc.C_buffer.buf, raw_accel_q25, temp_100degC, accel_bias_q25);
accel_cal_q25[0] = raw_accel_q25[0] - accel_bias_q25[0];
accel_cal_q25[1] = raw_accel_q25[1] - accel_bias_q25[1];
accel_cal_q25[2] = raw_accel_q25[2] - accel_bias_q25[2];

sCalAcc.acc_bias_q16[0] = accel_bias_q25[0] >> (25 - 16);
sCalAcc.acc_bias_q16[1] = accel_bias_q25[1] >> (25 - 16);
sCalAcc.acc_bias_q16[2] = accel_bias_q25[2] >> (25 - 16);
sCalAcc.acc_cal_q16[0] = accel_cal_q25[0] >> (25 -16);
sCalAcc.acc_cal_q16[1] = accel_cal_q25[1] >> (25 -16);
sCalAcc.acc_cal_q16[2] = accel_cal_q25[2] >> (25 -16);
sCalAcc.accuracy_flag = Algo_InvnCalibration_AccelCalibrationGyroOptionalFxp_GetAccuracy(sCalAcc.C_buffer.buf);

/* Update GRV algorithm with acc value and acc accuracy */
Algo_InvnOrientation_BodyToWorldFrameFxp_UpdateAcc(sGRV.C_buffer.buf, accel_cal_q25, sCalAcc.accuracy_flag);

My questions are now,
1) Which variables do I need to change, how and in what order to calibrate the acceleration and the gyroscope
2) How can I zero out the gyro values when I know that the sensor is at a steady state? Kinda like a tare 0...

I have tried the ICM20602DoSelfTest() then saving the bias like this:

    inv_icm20602_get_st_bias(&icm_device, get_raw_bias);

for(i = 0; i < 12; i++)
raw_bias[i] = inv_dc_little8_to_int32((const uint8_t *)(&sensor_bias[i * sizeof(uint32_t)]));
idx += sizeof(raw_bias);
//inv_icm20602_set_st_bias(&icm_device, (int *)raw_bias);

int result; //= inv_icm20602_run_selftest(&icm_device);
result = icm20602_run_selftest(&icm_device);

if( icm_device.selftest_done == 1 )
{
store_offsets();
}

But once I load the values at startup it is still off.

Generally I would like to know what each var is doing, but I can't find any documentation on this code.

Thanks for your help,

Jacob

phpbb Topic ID
36799