MEMS Libraries problems
Hi,
I'm facing several problems while using the MEMS1 package. I have designed a custom board with the L552 mcu and LSM6DSO32 and LIS3MDL sensors on the same SPI bus. The board has a WiFi connectivity, an SD card and a plethora of user IO. The firmware is written in C++ (no STL, no RTTI, no exceptions) and uses ThreadX. All of the ThreadX functionalities are wrapped into thin classes. My goal is to estimate a 3D orientation using MotionFX. I'm also using MotionMC and MotionAC and the results of calibration are stored on the SD card. I'm using the latest CubeIDE.
- My first problem is that I'm forced to use XCUBE-MEMS1 v9.3.0. When I try to use the v9.4.0 I get several Multiple definition of ***. First defined in YYY. problems. Simply put, when using 9.4.0 I cannot link multiple MEMS1 packages into a single project.
- I was not able to pass the Accelerometer calibration (MotionAC) in dynamic mode. My workflow was the following:
- Init MotionAC and its knobs. Set the algorithm frequency Falg.
- Poll the IMU data.
- Memcpy the data into a MAC_input_t structure.
- Update the timestamp with HAL_GetTick.
- Hard coded delay of 1/Falg seconds.
- Repeat 2-5 until the *is_calibrated is 0x01.
I first tried to follow the written instruction in UM2182. Then I tried to follow the graphical instructions. I found those to be quite different, yielding different orientations but whatever. Then I tried to run the 6 point tumble. Again no success, until I found some thread on this forum where the op said that the input to the MotionAC_Update function should in fact be an array of 6 MAC_input_t structs. I tried this approach and it worked somehow - I don't have any means of validating the results yet. Why isn't this explained in the guide? Can someone please explain it to me? One curious thing is that this method works even without setting the timestamp variable (which one of the 6 point should hold the timestamp anyway? all of them? first one? the same timestamp?).
- My (so far) last problem is with the MotionFX library. My program is divided into several threads. There is an SD card thread which loads the wifi settings and the calibration constants (biases and 3x3 matrices for magnetometer and accelerometer). This thread then starts an IMU init thread which of course inits the SPI and the sensors registers. When the calibration settings parsing fails, this thread spawns two new threads - one for mag calibration and one for the accelerometer calib. When these threads are finished, the results are again stored on the SD card and a Fusion thread is finally launched. And here I'm facing a drift problem in horizontal plane (yaw). I'm reading the IMU data at 104 Hz, the magnetometer is updated at 20 Hz. I'm using an INT triggered DMA transfers. I have written an OpenGL app in C++ that visualizes the board's orientation - rotations done usingquaternions from the MotionFX output struct and are being perfomed inside the Shader program. No matter how I rotate the board there seems to be a cumulative drift in the horizontal plane. I say cumulative because it can be unwinded, when rotating in an oposite direction. I suspect the magnetometer to be the cause of this although It'd been calibrated. I tried to alter all of the MotionFX knobs and I wasn't able to mitigate this problem. Some of the settings have very little effect on the problem. I will post links to my videos below showing the problem. (is my question too long now so I cannot and links?).
