MotionMC calibration fails (all params have default value)
Hi,
I'm currently trying to use the MotionEC library for an E-Compass application, and to calibrate the Magnetometer with the MotionMC library. I'm using an STM32L1-DISCO with an LSM303AGR. My general idea is to run the calibration algorithm for x seconds, then get the calibration parameters, and apply them to the e-compass calculation.
The MotionEC library works perfectly fine but I ran into troubles with the MotionMC library.
At first, I'm running the MotionMC_Update function with the parameters I'm reading from the Magnetometer. After that, I'm calling MotionMC_GetCalParams to get the calibration parameters. But the library is always returning the following default values:
HI_Bias = {0, 0, 0},
SF_Matrix = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}},
CalQuality = MMC_CALQSTATUSUNKNOWN
Here is my code (based on the ST examples).
// COMPASS_REPORT_INTERVAL = 20
// gets called every 20ms
void doCalibrationStep()
{ SensorAxes_t mag_data_uncompensated; getMagneto(&mag_data_uncompensated);MMC_Input_t data_in;
data_in.Mag[0] = (float) mag_data_uncompensated.AXIS_X / 10.0f; data_in.Mag[1] = (float) mag_data_uncompensated.AXIS_Y / 10.0f; data_in.Mag[2] = (float) mag_data_uncompensated.AXIS_Z / 10.0f;data_in.TimeStamp = timestamp * COMPASS_REPORT_INTERVAL;
// example data_in: Mag = {-64, 5.5, 17.1000004}, TimeStamp = 0
MotionMC_Update(&data_in);MMC_Output_t data_out;
MotionMC_GetCalParams(&data_out);dbg('CalParams X: %f, Y: %f, Z: %f, Quality: %d\r\n', data_out.HI_Bias[0], data_out.HI_Bias[1],
data_out.HI_Bias[2], data_out.CalQuality); // everything has default values, no matter how often I run the algotimestamp++;
}
void doCalibration()
{ MotionMC_Initialize(COMPASS_REPORT_INTERVAL, 1); char lib_version[200];MotionMC_GetLibVersion(lib_version);
dbg(lib_version); // here the correct version is printed<doCalibrationStep() is called repeatedly in 20ms intervals until x seconds elapsed>
MotionMC_GetCalParams(&cal_params); // all parameters are zero
}
I have absolutely no clue what's wrong. Do I miss something?
Thanks
