Hi Everyone,
I am using ICM-eMD for ICM20948 and trying to set up the accelerometer and gyro offsets register in the ICM20948. I am calculating the biases by averaging 200 samples then send it by using the library function (inv_device_set_sensor_config). It seems working fine for the Gyro but once I set up the offsets registers for Accelerometer it stops working and keeps sending the value of 4g for the three axes. I am using the code below to do the job:
_______________________________________________________________________
int calibration_AccGyr(void* context){ inv_device_t* device = (inv_device_t*) context;
int numSamples = 0;
inv_sensor_config_offset_t accBias;
inv_sensor_config_offset_t gyrBias;
volatile int8_t rc = 0;
while(numSamples < CALIBRATION_SAMPLES){
numSamples++;
rc = inv_device_poll(device);//each polling takes 2msec
HAL_Delay(3); // added 3 msec to achieve 200Hz rate
accBias.offset[0] = accBias.offset[0] + dmpData.accX;
accBias.offset[1] = accBias.offset[1] + dmpData.accY;
accBias.offset[2] = accBias.offset[2] + dmpData.accZ - 1;
gyrBias.offset[0] = gyrBias.offset[0] + dmpData.gyrX;
gyrBias.offset[1] = gyrBias.offset[1] + dmpData.gyrY;
gyrBias.offset[2] = gyrBias.offset[2] + dmpData.gyrZ;
}
accBias.offset[0] = accBias.offset[0] / CALIBRATION_SAMPLES;
accBias.offset[1] = accBias.offset[1] / CALIBRATION_SAMPLES;
accBias.offset[2] = accBias.offset[2] / CALIBRATION_SAMPLES;
gyrBias.offset[0] = gyrBias.offset[0] / CALIBRATION_SAMPLES;
gyrBias.offset[1] = gyrBias.offset[1] / CALIBRATION_SAMPLES;
gyrBias.offset[2] = gyrBias.offset[2] / CALIBRATION_SAMPLES;
rc = inv_device_set_sensor_config(device,INV_SENSOR_TYPE_GYROSCOPE,INV_SENSOR_CONFIG_OFFSET,gyrBias.offset,sizeof(gyrBias));
rc = inv_device_set_sensor_config(device,INV_SENSOR_TYPE_ACCELEROMETER,INV_SENSOR_CONFIG_OFFSET,accBias.offset,sizeof(accBias));
return rc; // return 1 on success
}
________________________________________________________________________
Is there anything wrong with this implementation leading to such error?
Regards,
Hisham