About Hard iron offset compensation.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

About Hard iron offset compensation.

1,469 Views
youngguekim
Contributor III

Hi..

I have a question about Hard iron, Soft iron offset compensation.

 

if i understood exactly.

To compensate Hard iron, I have to give a movement to magnetometer like picture. and This is the first and last time i will do

100203_100203.pngpastedImage_8.png 100202_100202.pngpastedImage_7.png

To compensate Soft iron, the SW have to be executed using a Task( void MagCal_task(uint32_t task_init_data) ) and This is lasting 1 time/min until Power down

 

 

Question.

1. if I do compensation of Hard iron offset at power up, i don't need to compensate Hard iron offset again. is it right?

2. if it is right, After compensation of Hard iron, and  if I write the Hard offset variable to NVM Before Power down , I don't need to compensate Hard iron offset forever?( even after board rebooting)

 

Thank you

Labels (1)
0 Kudos
5 Replies

797 Views
markpedley
NXP Employee
NXP Employee

Both the hard iron and soft iron use measurements in the magnetic buffer. The more sophisticated 7 and 10 element algorithms which do fit the soft iron simply require more measurements than the 4 element algorithm. It's like having just 5 noisy points on a graph. Fitting a straight to 5 points will be ok, fitting a quadratic will be more error prone and fitting a cubic even more error prone. So to get a quick calibration as soon as possible we do the four element calibration which fixes the main magnetic inteference which is the hard iron offset. Then when we have more measurements we move to the more sophsticated solvers and fix the much small soft iron terms.

Magnetometers and magnetic sensors are sensitive to temperature which is the reason for the continual background calibration which is for both hard and soft iron.

Here's what you need to store in NVM: fV[], finvW[][], fFitErrorpc and read in on power up. I use a header byte which has a value different from the 0xFF that would be read from erased NVM so I can distinguish whether the NVM is erased or has data. I do not store the magnetic buffer. That gives an immediate power on calibration and no measurements in the magnetic buffer. Then as soon as enough measurements are available I still perform the  standard 4, 7, 10 element calibration as more measurements come into the magnetic buffer. The reason is that the magnetic calibration could have resulted from a different temperature and therefore be erroneous.

So the only change should in the power on initialization in function fInitMagCalibration where you need to add a test for the presence of stored coefficients and then copy then in if they are available.

797 Views
markpedley
NXP Employee
NXP Employee

Set the thisMagCal.iValidMagCal to a non-zero (C true) value after reading in the calibration from flash so that the software knows to apply the hard and soft iron correction.

In the V5 code we use 0 (C false) to denote no calibration and 4, 7, 10 (C true) to denote a valid calibration and the actual solver used for that calibration.

0 Kudos

797 Views
youngguekim
Contributor III

Hi. Thank you for quick reply.

I tried to store the values of  fV[], finvW[][], fFitErrorpc, gyro offset before Power down. and I read them on power up.

I think that the above process will help me not to do rotation of board for calibration.

but every time I power up, I should rotate the board for the same prior magnetometer yaw value.

Without rotation, the value is differ from the previous value badly

so should I store another value? for example, Magbuffer[] or all Magcalib structure??

- my Environment -

Step 1. Rotating a board for Mag calibration. and Waiting until stabilization of Roll, pitch, yaw.

Step 2. Power down,( Until next power up, the board is same place and The environment is not changed.)

Step 3. Power up. and it have to have a same Roll, Pitch, Yaw ( Error is not considered )

it is important because  I have to fix a development kit not to move from the second Power up

Please Give an advice to me.

Thank you.

0 Kudos

797 Views
michaelestanley
NXP Employee
NXP Employee

Dav,

You are incorrect.  BOTH hard and soft iron effects are computed via the MagCal task.  The equations are such that we optimize the total set of coefficients each time MagCal is run, including both the 3x3 inverse soft iron matrix and the 3x1 hard iron offset.

Some magnetic sensors (ours included) have a non-negligible temperature coefficient, which also can affect these coefficients.  So for mobile applications we recommend that magnetic calibration be run continuously as a background task.  This negates the effects of temperature.

Applications where this is not possible need to be addressed on a case-by-case basis.

FYI, Version 6.00 of the fusion library (currently under development) will add the capability to cache current coefficients to MCU flash so that the device boots with previously computed coefficients.  These will then be replaced as soon as enough data points are available to compute updated numbers.  Some users of the library are already doing this, and we've decided to add generic functions to make it easier going forward.  Look for this version in 1Q2016.

Regards,

Mike

797 Views
a8Chcx
Contributor V

Hi Mike,

I noticed the following issue:

I have saved 10-point calibration data and use them after the system power on/RESET.

Then it keep running calibration routine. I found that the heading is not as good as the saved data.

I checked  that it runs 4-point calibration data in real-time now. I will becomes good again when it is running in 10-point again.

How can I use 10-point data always to make the heading good enough?

Thanks,

Christie