ICM20948_DMP_Arduino icon indicating copy to clipboard operation
ICM20948_DMP_Arduino copied to clipboard

How to save calibration

Open gunarkroeger opened this issue 3 years ago • 1 comments

How do I read the calibration from the imu, so that I can save it to an external flash and write it back onto the sensor on power up?

gunarkroeger avatar Mar 05 '21 17:03 gunarkroeger

These are the ways I tried, by reading the registers directly and the values from the struct. but neither update after it gets calibrated

    uint8_t reg_g_offset[6];
    uint8_t reg_a_offset[6];
    int result = 0;
    //Gyro offset
    result |= inv_icm20948_read_mems_reg(s, REG_XG_OFFS_USRH, sizeof(reg_g_offset), reg_g_offset);

    //Accel offset
    result |= inv_icm20948_read_mems_reg(s, REG_XA_OFFS_H, 2, &reg_a_offset[0]);
    result |= inv_icm20948_read_mems_reg(s, REG_YA_OFFS_H, 2, &reg_a_offset[2]);
    result |= inv_icm20948_read_mems_reg(s, REG_ZA_OFFS_H, 2, &reg_a_offset[4]);

    Serial.println("g_offset");
    for(unsigned i = 0; i < 6; i++)
        Serial.print(String(reg_g_offset[i]) + " ");

    Serial.println("");
    Serial.println("a_offset");
    for(unsigned i = 0; i < 6; i++)
        Serial.print(String(reg_a_offset[i]) + " ");
    Serial.println(String("result:") + result);

    Serial.println("bias");
    for(unsigned i = 0; i < 9; i++)
        Serial.print(String(s->bias[i]) + " ");

    Serial.println("");
    Serial.println("soft_iron_matrix");
    for(unsigned i = 0; i < 9; i++)
        Serial.print(String(s->soft_iron_matrix[i]) + " ");

gunarkroeger avatar Mar 05 '21 18:03 gunarkroeger