Why the factory don't do the magnetometer calibration before openimu300 unit release to customer? How to do the openimu300 unit magnetometer calibration?

Because of the application scenarios diversity, the electromagnetic environments are different, therefore the openimu300 magnetometer sensor should be calibrate accordingly. For instance, user could calibrate magnetometer sensor in application INS/VG-AHAS downloading from aceinna VS code example.

User could do mag calibration following the instructions through openimu300 user serial interface:
Mag Align Commands:
55 55 6D 61 01 00 F1 2E – Mag-Align Status
55 55 6D 61 01 01 E1 0F – Start Mag-Align (autoend)
55 55 6D 61 01 02 D1 6C – Start Mag-Align (w/o autoend)
55 55 6D 61 01 03 C1 4D – Stop Mag-Align (w/o autoend)
55 55 6D 61 01 04 B1 AA – Accept Mag-Align Results (temp)
55 55 6D 61 01 05 A1 8B – Accept Mag-Align Results (write to eeprom)
55 55 6D 61 01 06 91 E8 – Abort Mag-Align
55 55 6D 61 01 07 81 C9 – Get stored values
55 55 6D 61 01 08 70 26 – Restore Mag-Align Defaults

Currently, the docs for both:
"Magnetic Alignment" - https://openimu.readthedocs.io/en/latest/mags/hardiron.html
and "Serial Messaging" - https://openimu.readthedocs.io/en/latest/tutorial/VG_AHRS/SerialMessaging.html
Are not available.

Anyway, I think I was able to send the commands over serial, but how should I interpret the returned data?

Was able to find these 2:
https://openimu.readthedocs.io/en/latest/algorithms/MagneticAlignment.html
https://github.com/Aceinna/docs_aceinna-dmu380/blob/master/tutorial/OpenIMU_Core/SerialMessaging.rst

But still, not sure how to read the returned data, for example from:
55 55 6D 61 01 07 81 C9 – Get stored values

Hi Ron,
Some of the document sections are under construction, sorry for the confusion. Which application are you used in openimu300 currently? You could send the command 55 55 6D 61 01 07 81 C9(Get stored values) through user serial interface to get the mag calibration stored values in eeprom. Please note, the command send from user serial interface should be HEX format.
How to send the calibration command? For instance with the VG-AHRS application downloading from VS code, you could send the command (55 55 6D 61 01 02 D1 6C)Start Mag-Align via user serial interface(115200 baud rate,the first serial com port of the four), and then you could see the log comming from the debug serial com port(230400 baud rate, the third serial com port of the four) with the text " ++++ MA Start ++++" . rotate openimu300 board with 360 degree and finished the magnetometer calibration. After that, the calibrate parameter of the hard-iron and soft-iorn will list from the debug serial com port. Last step, sending the command (55 55 6D 61 01 05 A1 8B)Accept Mag-Align Results from user serial interface, the the mag calibration data could be saved into eeprom.

Hi Li, Thank you for your help.
I was able to issue the mag-align procedure, but I still face some problems.

After I run alignment procedure and save the parameters to the eeprom, I get the following when sending 55 55 6D 61 01 07 81 C9 – Get stored values:
+++++++++++++ Mag-Align Defaults +++++++++++++
Hard-Iron: 0.19534, -0.03507
Soft-Iron Ratio: 0.90309
Soft-Iron Angle: -1.46192

+++++++++++++ Mag-Align Estimates +++++++++++++
Hard-Iron: 0.19534, -0.03507
Soft-Iron Ratio: 0.90309
Soft-Iron Angle: -1.46192

However, after rebooting the IMU, I get:
+++++++++++++ Mag-Align Defaults +++++++++++++
Hard-Iron: 0.19534, -0.03507
Soft-Iron Ratio: 0.90309
Soft-Iron Angle: -1.46192

+++++++++++++ Mag-Align Estimates +++++++++++++
Hard-Iron: 0.00000, 0.00000
Soft-Iron Ratio: 1.00000
Soft-Iron Angle: 0.00000

Will the firmware use the Mag-Align Estimates? If so, I think this is a bug.
I couldn't find how to set the Mag-Align Estimates to be equal to the Mag-Align Defaults, just the other way around with 55 55 6D 61 01 05 A1 8B

Apart from that, after I apply the alignment results, (when the Mag-Align Estimates are correct), the magnetometer data output is still the same. I plot the xMag - yMag and I get the same ellipse that I got without the alignment.
Is it a bug? or is it because the magnetometer output values are raw, and the alignment fix is done only to the heading calculation?

Last question:
Regarding the Heading output for this application - does a value of 0 means that the IMU is facing north? or value 0 is wherever the IMU was facing when it was turned on?

Hi Ron,

  1. The firmware use the Mag-Align Estimates after you finish the magnetometer calibratation, however, when you reset the openimu300 board, the init process will load the gDefaultUserConfig again, you should modify the .hardIron_X/.hardIron_Y/.softIron_Ratio/.softIron_Angle in sturct gDefaultUserConfig with the mag-align value getting from log. Yes, the opensource code init process will be updated about the mag calibration, only use serial command and no firmware modification would be a better choice .
  2. Which type of package are you using? If you want to get the package data and plot the ellipse with x/y value of mag, you should modify the firmware based on current firmware version, check the code in macro CORRECT_IN_BODY_FRAME in file TransformationMath.c for reference and correct for hard/soft-iron effects in body frame, for instance, if you want to get the calibrated mag value from 'z1' package(USR_OUT_DATA1), the code Hard-iron/Soft-iron corrections with macro CORRECT_IN_BODY_FRAME should be added in the API: HandleUserOutputPacket, after get the mag rawdata from API:GetMagData_G.
  3. Regarding the Heading output for application VG-AHRS, user could select the algoType in API: _Algorithm, if the algoType is VG, a value 0 is direction of the IMU was facing when IMU was turned on, and if the algoType is AHRS, a value of 0 means that the IMU is facing north.

Hi Ron,

The output you get over the debug line is debug code that is contained in the calibration code and, unfortunately, not made available to the user. When you issue the 'Get Stored Values' command (55 55 6D 61 01 07 81 C9), the values labeled 'Defaults' are the values currently in memory and stored in the EEPROM while the 'Estimates' are the ones resulting from the Magnetic-Alignment process. If you accept these estimates then they replace the values used to correct for hard/soft-iron effects and are saved to the EEPROM. At startup, they become the default values.

If you issue the 'Get Stored Values' command before you perform an alignment then the estimates are just the initial values for the magnetic-alignment variables. This is why you see the 0.0 and 1.0 values after you issue the command.

As to why you still get an ellipse when you plot the magnetic-field measurements after performing the magnetic-alignment, the hard/soft-iron estimates are only used to form the heading estimate, not correct the raw magnetic field measurements (as you state in your question). Without a full 3D estimate of the magnetic environment it is not possible to adjust the raw signal. The method by which the hard/soft-iron values are used to form the heading estimate is described at https://openimu.readthedocs.io/en/latest/algorithms/MeasurementModel.html#

The heading angle computed using the equation described in the measurement model is angle from magnetic-north. A value of 0.0 indicates that you are pointed north while a value of 90.0 indicates that you are pointed east.

Dear Li,

I have two questions about magnetometer calibration on openIMU300ZA, when I send 55 55 6D 61 01 02 D1 6C to start mag-align, may I need to read any response on user usart port? ( user usart port pins are 3,4 ) it will be any response on the user usart port? or all responses will be on debug port? I am using AHRS program, which pins are related to debug port? (TX and RX pins)

Best regards,
Amin.

@Amin Hi Amin, you could send command to 300ZI unit via User uart interface(VG_AHRS, INS appication), and get the debug log from debug uart interface as below. As for the debug port, OpenIMU user could refer to UART debug port.

bbc0f102-c4ab-4c82-b065-25eccca311f2-image.png

Hi,

I have to calibrate my openIMU300ZI sensor follow the instructions, I have sent Start Mag - Align with auto end command ( byte array 55 55 6D 61 01 01 E1 0F ) to the sensor via user port on baud rate 115200 , but there are no responses on debug port, I have changed debug port's baud rate to 115200 and already tested on baud rate of 230400 with no success. I was add a Hello world message using DebugPrintString((char*)"HelloWorld\r\n"); in main.c just after DebugInterfaceInit(); and before osKernelStart(); to make sure the debug port is okay and working, I can see the HelloWorld message on my debug port.

I have sent byte array from a simple program written in Delphi by myself.

The application is VG-AHRS and version is 200211-193813-VG_AHRS.

do I need to change anything to be able to calibrate magnetometers?

Regards,
Amin.

Hi,

How to use setUserMagAlignParams() ? how to calibrate magnetometer manually and compute hardIron_X , hardIron_Y , softIron_Ratio and softIron_Angle to use with setUserMagAlignParams()? what is your calibration algorithm? please give me an article about your calibration method. the source code of ProcessMagAlignCmds is not available, can you please show me the source code of ProcessMagAlignCmds function?

I was sent start mag align with autoend command to the sensor, I then rotate the sensor in z axis more than 720 degrees, I can confirm that its working but the accept and save to eeprom command is not working. after sending accept and save to eeprom command ( 55 55 6D 61 01 05 A1 8B – Accept Mag-Align Results (write to eeprom) ) it will not save to eeprom, after restart it will start with default values.

please help me to calibrate my openIMU300ZI.

Regards,
Amin.

Log in to reply