About MPU-9250 DMP Arduino Library

Hi. I’m a Japanese high school student.

I’m not used to writing e-mail, so I probably ask some weird questions.

Thank you for providing such a wonderful library for MPU9250.

About this, I have a few questions.

①How does gyro calibration work ? & How to enable gyro calibration?

I wanted to enable gyro calibration, so I wrote:

imu.dmpBegin(DMP_FEATURE_6X_LP_QUAT | // Enable 6-axis quat
               DMP_FEATURE_GYRO_CAL, // Use gyro calibration
              200);

But as I see the serial monitor, the sensor is still drifting.

Additionally, I viewed the definition of dmpBegin(), but I couldn’t understand how it enables calibration.

the definition of dmpBegin() is :

inv_error_t MPU9250_DMP::dmpBegin(unsigned short features, unsigned short fifoRate)
{
    unsigned short feat = features;
    unsigned short rate = fifoRate;

    if (dmpLoad() != INV_SUCCESS)
        return INV_ERROR;
    
    // 3-axis and 6-axis LP quat are mutually exclusive.
    // If both are selected, default to 3-axis
    if (feat & DMP_FEATURE_LP_QUAT)
    {
        feat &= ~(DMP_FEATURE_6X_LP_QUAT);
        dmp_enable_lp_quat(1);
    }
    else if (feat & DMP_FEATURE_6X_LP_QUAT)
        dmp_enable_6x_lp_quat(1);
    
    if (feat & DMP_FEATURE_GYRO_CAL)
        dmp_enable_gyro_cal(1);
    
    if (dmpEnableFeatures(feat) != INV_SUCCESS)
        return INV_ERROR;
    
    rate = constrain(rate, 1, 200);
    if (dmpSetFifoRate(rate) != INV_SUCCESS)
        return INV_ERROR;
    
    return mpu_set_dmp_state(1);
}

and the definition of dmp_enable_lp_quat() is :

int dmp_enable_gyro_cal(unsigned char enable)
{
    if (enable) {
        unsigned char regs[9] = {0xb8, 0xaa, 0xb3, 0x8d, 0xb4, 0x98, 0x0d, 0x35, 0x5d};
        return mpu_write_mem(CFG_MOTION_BIAS, 9, regs);
    } else {
        unsigned char regs[9] = {0xb8, 0xaa, 0xaa, 0xaa, 0xb0, 0x88, 0xc3, 0xc5, 0xc7};
        return mpu_write_mem(CFG_MOTION_BIAS, 9, regs);
    }
}

In the code above, there is “CFG_MOTION_BIAS”,

but I couldn’t find any registers ( and address ) in the datasheet, both Application Note and Register Map.

So I wondered what these descriptions were for.

I have no idea about how gyro calibration works, and what I should do to enable valid calibration.

Please give me some advice.

②How to using DMP via SPI ?

Though this library is very useful, I would like to use DMP via SPI ,

because it communicates faster and stronger against noise than I2C.

But I didn’t succeed in using DMP with SPI.

I would like you to tell me how to do this.

Here is a thread that may help you regarding SPI communication. https://forum.arduino.cc/t/interfacing- … ion/616848

This one may help regarding the Gyro calibration:https://ww2.mathworks.cn/help/supportpk … egyro.html

Thank you for your reply.

I’ll try it once.