STMicroelectronics / X-CUBE-MEMS1

X-CUBE-MEMS1 is an expansion software package for STM32Cube. The software runs on the STM32 and includes drivers that recognize the sensors and collect temperature, humidity, pressure and motion data.
https://www.st.com/en/embedded-software/x-cube-mems1.html
Other
53 stars 12 forks source link

Accelerometer calibration issue #8

Closed gyurma888 closed 1 year ago

gyurma888 commented 1 year ago

Hi everyone,

I have a problem with the MotionDI library. I tried to calibrate the accelerometer, but it doesn't calculate the Bias and the SF matrix, they are 0.0. The calibration quality is MDI_CAL_OK after the first MotionDI_update function call, but the output values are totally wrong, more of the output values (Roatation[1] and Linear Acceleration) are oscillating. Fun fact, that I tried to calibrate the accelerometer with the MotionAC library, and it worked really good on the same device, the quality was MDI_CAL_GOOD. I tried the 6 point calibration in both cases. Configuration: STM32F413 MotionDI_CM4F_wc32_ot_hard.a ISM330DLC (but I wrote a driver manually, I use only the MotionDI from this repository) Frequency: 100 Hz iKnobs.AccKnob.CalType = MDI_CAL_ONETIME; iKnobs.GyrKnob.CalType = MDI_CAL_CONTINUOUS;

The other knobs are the default, I didn't change it.

What am I doing wrong?

Thank you for your help! Best regards, Zalán Gyuricza

PetrSterbaST commented 1 year ago

Hello, I've tested the DynamicInclinometer sample application in X-CUBE-MEMS1 package, which is using MotionDI and 6-position calibration works well. Could you please send me your datalog with recording of your calibration attempt data? It should include also timestamp for me to be able to replicate your issue. The best would be if you use exactly the format as in attached file. Data_Log_2020_06_26_06_22_33_DI.csv

gyurma888 commented 1 year ago

Hello, thank you for your quick response!

I send you two datalogs. data_export1.csv: I did an attempt to calibrate the library with 6 point calibration method. (+X, -X, +Y, -Y, -Z, +Z) The library was already running for 1 minute before I started to record the data. In this file you can see also the accBiasX, accBiasY, accBiasZ, gyrBiasX, gyrBiasY, and gyrBiasZ columns. I did't change them, just export with the MotionDI_AccCal_getParams and MotionDI_GyrCal_getParams functions. The calQuality column is also shown. The accelerometer calibration quality remains 2 (MDI_CAL_OK) all the time, but the gyroscope calibration quality switched to 3 (MDI_CAL_GOOD) (before I started this record, so it's absolutely okay, I think). The duration of the gyroscope calibration was 2-3 seconds.

data_export2.csv: I gently roteted the device from position -Z to position +Y. This datalog also includes the rotation[0,1,2] array and the linear_acceleration[0,1,2] arrays, so some of the outputs of the library. The diYaw column is correct, but the the others are incorrect, one of them is oscillating, and the other is simply incorrect.

Note: The input of the library is float and, the units are [us], [g] and [dps] in my code. I hope, that it's correct. I just converted the values to another units, to be compatible with your format.

Thank you for your help! Best regards, Zalán

data_export1.csv data_export2.csv

PetrSterbaST commented 1 year ago

I just tried the datalog1 and your data are good enough for AccCal to get level 3, see attached datalog including library output data. I only had to convert your float input to int. I strongly recommend to take a deep look into the code of DynamicInclinometer application in X-CUBE-MEMS1 package which I used for uploading your offline data into the library. Make sure you set the knobs the same as in this application as well as format and units of input data to be the same. Then it should work on your side too. Data_Log_2023_10_13_11_56_18_AccOneTime.csv

gyurma888 commented 1 year ago

Hello, thank you for the test!

I noticed, that my problem is not only the calibration, because your output looks good, while the calibration status is MDI_CAL_OK. It has a small offset, but, it's quite good. But for me it's oscillating, it doesn't matter if it's calibrated or not. I checked the DynamicInclinometer application in the GitHub repository, but I didn't notice any difference between the application and my code. The knobs are the same, and I think, that the inputs are good too.

But the output is still wrong, so I did a test with constant values (I called the MotionDI_update function always with the same float values). Here, the output is also oscillating, although the inputs are constants.

Could you take a look to this test and could you give me an advice why is this happening? Maybe the knobs are wrong, or make I a totally another mistake?

Thank you for your help, have a nice day, Zalán

constant_input.csv

gyurma888 commented 1 year ago

Hello, I found the problem, probably it was not the library's fault. The bug is in connection with the FPU of the microcontroller. I don't know exactly what the problem is, but now I use the MotionDI_CM4F_wc32_ot.a file, I turned off the FPU in the compiler settings (Keil uVision 5.15), and now it works excellent. I think the settings of the FPU is not correct. Maybe I will ask it in the community forum. Now the output isn't oscillating, and the calibration works properly.

Thank you for your quick responses and your help! Have a nice week, Zalán

cparata commented 1 year ago

Perfect! I close this ticket. Best Regards, Carlo