cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble runing MotionGC_Update function.

PMach.1
Senior

Hi,

I've been trying to get the calibration values for my gyroscope using MotionGC library. I'm using the sample code available in the MotionGC starter guide but the said function return all the output values as 0. The bias_update variable is also set to 0, meaning that the sensor isn't stable, or so the guide says.

However, I'm being very careful to hold the sensor at a given position and not move it throughout the measurements.

What might be the cause of this issue?

Thanks in advance.

Kind regards,

Pedro Machado

22 REPLIES 22
niccolò
ST Employee

Hi Pedro @Community member​ ,

how are you keeping the sensor during the calibration?

I mean, is it still on a surface or on some place that is susceptible to vibrations?

moreover, are you able to read the right values from the sensor?

Niccolò

Petr S
ST Employee

Hi Pedro,

Also please verify that you pass your accelerometer and gyroscope sensor data to MotionGC library in correct units. You can use functional middleware applications in very latest version of X-CUBE-MEMS1 package v8.3.0 released about a week ago as reference if not done already. If you use different HW than the ones the sample applications are written for, you can also generate the GyroscopeCalibration application using latest STM32CubeMX tool.

Regards,

Petr

Hi,

The sensor is placed on top of a table, not sujected to any vibrations (at least not significant, I would dare to say). The accelerometer's Z axis is aligned with the vertical axis and the reading of this axis is around 980mg, which makes me believe the values are correct.

Hi,

There are no sample applications for the sensor I am testing (LSM9DS1), that's why I am using only the MotionGC middleware and feeding it the "manually" read values. In fact, I just noticed that the units were incorrect. I already corrected them to g and dps. However, it still returns 0 for every axis.

Hi @Community member​ ,

yes, the nominal value should be ok, but I would try to record some samples in a row and plot them to be sure that there are no actual vibrations ongoing.

moreover, the gyro values are important too, can you confirm those?

I'd like you to confirm you are following the user manual instructions, like initializing everything, for example using the function MotionGC_Initialize and calling MotionGC_SetCalParams right after that (I'm talking about page 4 of the user manual).

Niccolò

I still recommend to follow ALL the steps and settings performed in the IKS01A2 resp. IKS01A3 Gyroscope Calibration sample applications in X-CUBE-MEMS1 package since in principle the LSM6DSL resp. LSM6DSO Acc&Gyr combo sensors are similar to your LSM9DS1 Acc&Gyr&Mag combo sensor in terms of basic task like getting values. I still expect the main issue in the flow, mainly library initialization, data feed, ODR, TimeStamp, whatever detail that is too different than in mentioned examples.

Hi,

I double checked the initialization code and found nothing suspicious. In fact, it is based on the example found on the MotionGC user guide (pg. 6), which I've copy and pasted. I've altered both the accelerometer and gyroscope threshold values to their maximum (0.05g and 0.4dps). I've alse recorded several readings for each axis of both accelerometer and gyroscope. The accelerometer showed no great variations, always less than the threshold. However, I couldn't verify this for the gyroscope, as shown below:

0693W000008zNfQQAU.jpg 

Might this be the cause of the issue?

The initialization is performed as follows:

void cal_init(MGC_knobs_t knobs, MGC_output_t start_gyro_bias){

char lib_version[VERSION_STR_LENG];

float sample_freq;

/* Gyroscope calibration API initialization function */

float freq = SAMPLE_FREQUENCY;

MotionGC_Initialize(&freq);

/* Optional: Get version */

MotionGC_GetLibVersion(lib_version);

/* Optional: Get knobs settings */

MotionGC_GetKnobs(&knobs);

/* Optional: Adjust knobs settings */

knobs.AccThr = 0.05f;

knobs.GyroThr = 0.4f;

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 */

sample_freq = SAMPLE_FREQUENCY;

MotionGC_SetFrequency(&sample_freq);

}

Hi Pedro @Community member​ ,

the values of the gyroscope are strange, what is the full scale?

What threshold values did you modify?

The initialization seems right, but if the data in input is right but can you check that the values you modify are really different from before?

for example, before the SetFrequency, check the previous frequency, change it and re-read it to be sure we can rule out the library initialization as the problem.

Niccolò

Hi, Niccolo,

I did as you instructed. The functions MotionGC_GetKnobs() and MotionGC_GetCalParams() indicate that the knobs and the calibration parameters are correctly written. MotionGC library has no function to read the frequency that was previously set, though. In short, it seems to me that the initialization is not the root of the problem.