I'm working on the "STEVAL-MKI182V2" mounted on the STEVAL-MKI109V3
development board. Initially, I downloaded the Standard c Drivers from the following link https://github.com/STMicroelectronics/STMems_Standard_C_drivers
where I found the .ioc
file called _prj_MKI109V3
which is specifically developed for the MKI109V3 board.
Then after I have added the ISM330DLC
driver files and example code called ism330dlc_read_data_polling.c
from the following link https://github.com/STMicroelectronics/STMems_Standard_C_drivers/tree/master/ism330dlc_STdC
after adding I was just calling ism330dlc_read_data_polling
function in the main while loop.
We are using the below function to initialise the library
void Gyro_Initialize()
{
/ Gyroscope calibration API initialization function /
MotionGC_Initialize(MGC_MCU_STM32,&sample_freq);
/ Optional: Get version /
MotionGC_GetLibVersion(lib_version);
/ Optional: Get knobs settings /
MotionGC_GetKnobs(&knobs);
/ Optional: Adjust knobs settings /
knobs.AccThr = 0.008f;
knobs.GyroThr = 0.15;
MotionGC_SetKnobs(&knobs);
/ Optional: Set initial gyroscope offset /
start_gyro_bias.GyroBiasX = 0;
start_gyro_bias.GyroBiasY = 0;
start_gyro_bias.GyroBiasZ = 0;
MotionGC_SetCalParams(&start_gyro_bias);
/ Optional: Set sample frequency /
MotionGC_SetFrequency(&sample_freq);
}
After initialising the library we are sending the stored raw data (which we have received by using example code ism330dlc_read_data_polling.c
) as an input to the function MotionGC_Update(&data_in, &data_out, &bias_update);
Now the issue is, after dumping the code I'm able to get the raw data from the sensor immediately after I'm calling the function Gyro_Process()
in which where I'm trying to get the data from the function MotionGC_Update(&data_in, &data_out, &bias_update);
as follows
void Gyro_Process()
{
/** Using gyroscope calibration algorithm **/
MGC_input_t data_in;
MGC_output_t data_out;
int bias_update;
float gyro_cal_x, gyro_cal_y, gyro_cal_z;
data_in.Acc[0] = acceleration_mg[0];
data_in.Acc[1] = acceleration_mg[1];
data_in.Acc[2] = acceleration_mg[2];
data_in.Gyro[0] = angular_rate_mdps[0];
data_in.Gyro[1] = angular_rate_mdps[1];
data_in.Gyro[2] = angular_rate_mdps[2];
// MotionGC_GetCalParams(&start_gyro_bias);
// {
// data_out.GyroBiasX = (int32_t)(data_out.GyroBiasZ -
gyro_bias_to_mdps(start_gyro_bias.GyroBiasX));
// data_out.GyroBiasY = (int32_t)(data_out.GyroBiasY -
gyro_bias_to_mdps(start_gyro_bias.GyroBiasY));
// data_out.GyroBiasZ = (int32_t)(data_out.GyroBiasZ -
gyro_bias_to_mdps(start_gyro_bias.GyroBiasZ));
// }
/ Get acceleration X/Y/Z in g /
// MEMS_Read_AccValue(data_in.Acc[0], data_in.Acc[1],
data_in.Acc[2]);
/ Get angular rate X/Y/Z in dps /
// MEMS_Read_GyroValue(data_in.Gyro[0], data_in.Gyro[1],
data_in.Gyro[2]);
/ Gyroscope calibration algorithm update /
MotionGC_Update(&data_in, &data_out, &bias_update);
/ Apply correction /
gyro_cal_x = (data_in.Gyro[0]-data_out.GyroBiasX);
gyro_cal_y = (data_in.Gyro[1]-data_out.GyroBiasY);
gyro_cal_z = (data_in.Gyro[2]-data_out.GyroBiasZ);
sprintf((char *)tx_buffer,
"Gyroscope [mg] :%4.2f\t%4.2f\t%4.2f\r\n",gyro_cal_x,
gyro_cal_y, gyro_cal_z);
CDC_Transmit_FS( tx_buffer, strlen( (char const *)tx_buffer )
);
// HAL_Delay(500);
}
but here one thing I observed is that the data_out
buffer is always zero which means the calibration buffer is not getting updated with the calibrated data.
Now, this issue I tried to post it on the ST Forum but I haven't got any help from your side felt really disappointed about the response from the ST Forum. Now I really need help because the project is getting delayed and still, we are stuck with this issue for almost 1 and a half months now.
Basically, the way I was sending the input raw data to the Motion GC library was an issue. When I checked the document I observed that the data type that which library function is expecting was different. Also, I tried a few orientation settings in the Library settings then finally it is working now.