cancel
Showing results for 
Search instead for 
Did you mean: 

Question about MotionFX error in 9-axis

MPoul.2
Associate II

Hello,

I'm currently working on a project requiring to get X, Y and Z angles from 2 sensors, (IIS2MDC and ISM330DHCX). In order to do so, I use MotionFX and its 2 functions, MotionFX_propagate and MotionFX_update, both used to run Kalman STM's algorithms.

Everything works fine on the X and Y axis.

However, the Z axis is not responding as it should:

While the board is on it's first side, the Z angle is correctly read and computed. If the board is rotated of 90°, the result returned is indeed 90°.

But if the board is fliped on its other side, the angle I get is 60°.

Furthermore, that behavior is no observed if the data is acquired and processed as a 6-axis acquisition.

Has anyone observed such an issue? Could it be a magnetometer calibration or a sensor setup issue?

Many thanks for the help you could provide.

Matthieu

29 REPLIES 29

Hi,

if you don't connect the JTAG/SWD lines then you can not use the ST-Link as programmer. So it is normal then there is the file with error message, this is normal. But the ST-Link will still work as USB/UART bridge so you can use it for communication between your board and the Unicleo-GUI.

Thanks Miroslav, we now have a way to create better logs. I'll let you know when we have news

Hi Miroslav.

After many tests, we improved a lot our results. Now when rotating, we are at most 3 to 4 degres from our 90° rotation angle.

To achieve this result, we change the ATime, MTime and FrTime to attain the best working combination ( we found out this depends on the design of the board, as settings working well with the Nucleo Board didn't perform as well on our board. After that, we used the example project for the magnetometer calibration. This calibration seems to be also done inside motion FX, but implementing it seemed to still have improved the results.

Finally we tried to change the parameter registers of the sensors, by trying to add low pass filters and other parameters that seemed usefull.

However we still have one last issue i could solve yet.

You will find the logs extracted from Unicleo Gui to illustrate what i'm saying.

I start my board which is initialized at an Angle X (yaw axis, here 319°).

Then I rotate (counter clockwise) of -90°. The yaw result is now 217. The rotation angle value is 102° then.

After that i get back to my starting angle. The read Yaw value is now 309°, (so a rotation of 92°).

Now when rotating clockwise of 90° (from start position) I get 45° (so a rotation of 96°)

When getting back to the starting position, i'm now at a yaw angle of 313° (so 92°)

And now i get back counterclockwise to my -90° first rotation.

Guess what. The yaw angle is back to 217° If i were to go to the +90° angle, i would also be back to 45°.

So it seems that our 0° values are kind of shifted after the rotations. Would you know what could be the issue?

 Edit : Note that the Heading and heading error in the data log are used to debug (Heading just returns the result of a register parameter and heading error is the yaw angle calculated from the magnetometer output only (yaw_mag = 180 * atan2(MagValue.y, MagValue.x) / M_PI; ) so they wont be relevant for the issue

You will find here an illustration of the movments performed with noted in blue the read angle and in black the true rotation.0693W00000GYZyDQAX.png

Miroslav BATEK
ST Employee

Hello,

here is response from my colleague who is expert on sensor fusion:

At the start of the MotionFX, heading is initialized with zero degree and will initial the heading value using magnetometer value only when there is a motion.

This is done to make sure magnetometer is calibrated and it can be determined only when there is some rotation. Therefore, the customer is seeing 0 at the beginning but after rotation, it converges to 217 deg.

When I compare the rotation from mag and gyro : Here is the value I am getting

Heading from Magnetometer : [-97 (313->216), 95, 95, -95, -95]

Heading from Gyro integration : [-87,90, 90, -88, -88]

0693W00000GYgVSQA1.png 

The differences in both sensors show some calibration issue with magnetometer but it is acceptable. As MotionFX get more data, it tends to handle the error better due to better observation of error.

MPoul.2
Associate II

Hi Miroslav thank you for your answer.

I understand that the calibration is important in the final result, but i still can't figure how with the same program we can observe such a difference between our board and the ST Nucleo board. I tried to use the registers from the gyroscope to enable its low pass filter, and it seemed to increase the accuracy in the gyroscope integrated angle values. However we still obtains errors of about 7 degrees on the origin point (yaw calculated from MotionFX)

After your message i also tried to get a better calibration, which i did, but even then then the result didn't improve.

[edit] Actually it seems we do have the same behaviour with the STM32 unicleo borad, but the gap between values seems to be a bit smaller. This gap is about 3 to 4° while it can go up du 7° with our board depending on the config parameters and the registers values.

Miroslav BATEK
ST Employee

Hello,

The different behavior between Nucleo and custom platform can be due to soft iron distortion of magnetometer. We can validate if soft iron distortion needs correction if you provide us 3D motion data.

Here is the process:

  1. Data should be collected in a magnetic interference-free environment such as Park /Garden where no ferromagnetic (iron pipes, current carrying wires) material is present. Please make sure Laptop/mobile devices are not close to the subjected device during the test.
  2. During data collection please make sure components such as Wireless antenna (Wi-Fi, GPS, NFC) etc. should be off. Any scanning will cause short and long term shift in the magnetic field.
  3. ODR: raw (uncalibrated) magnetic data at 50 or higher Hz

Data should be collected as follows.

  1. Place the device on the flat surface and slowly rotate the device by 360 degrees two times.
  2. Flip the device and follow the step 1
  3. Rotate the device in the vertical plane (About X and Y both).
  4. Perform 8 pattern rotation 2 times slowly .

Hi Miroslav,

Thank you for your help. You will find attached a .rar file containing both .csv and .xlsx files from the log function of the Unicleo Gui.

I've done 2 measurements for the unicleo as i did too many 8 figures, but the 2nd measurement seems a bit off so maybe we can just crop the 1st measurement data.

I also found that our board results seem better than the nucleo board with the ATime Mtime and Fr time used for those measurements (2.5, 3.5 and 4.5)

However, on Nucleo Board, better results were achieved with the following values : a2.5, m2.5, fr10

The magnetometer ODR was 100Hz.

Also the movements were "handmade" so the values may also be a bit off.

Hello,

I'm sorry for late reply, I was on vacation.

From the datalog we have calculated SI matrix:

   0.9731   0.0103   0.0011

   0.0103   1.0344  -0.0130

   0.0011  -0.0130   1.0256

You can multiply this matrix on uncalibrated data directly before sending it to MotionFX/MotionMC library to reduce SI error.

Example :

Xnew = 0.9731*X_raw + 0.0103*Y_raw + 0.0011*Z_raw

Please note the SI matrix is computed on the data logged and if there is some transformation performed (after motionFX call) then appropriate transformation will be needed before applying the SI matrix.

Hello,

Thank you for the answer and sorry for the late reply too, i did not receive the notification that you answered us.

So I tried to apply this SI matrix as follow. It seemed to have reduced the shift on the origin value but the range of rotation values is now between 100-110° instead of 90°, so i'm not sure i applied it as it should have been.

I applied it as shown upper in the post, by applying the hard iron offset end then applying to the result the matrix as your example says.

I don't have any other transformation applied to the data.