I use the freescale compass ic mag3110 and have problems with the mag calibration.
The reason:
when I move the compass in all directions I get the following values:
2880 < X < 3740
-3780 < Y > -2830
540 < Z < 1510
1LSB = 0.1 uT, so the deltas of all axis are between 86 and 97 uT, I think that's ok but the problem is the offset on all axis.
No axis goes throught zero!
So for the X and Z axis the startvalue of magZeroTempMin never changed and for the Z axis the startvalue of magZeroTempMax never changed.
For a correct calibration I have init the startvalues instead of zero with the actual values.
Code: Select all
...
magADC[ROLL] = magADC[ROLL] * magCal[ROLL];
magADC[PITCH] = magADC[PITCH] * magCal[PITCH];
magADC[YAW] = magADC[YAW] * magCal[YAW];
if (calibratingM == 1) {
tCal = t;
// for(axis=0;axis<3;axis++) {magZero[axis] = 0;magZeroTempMin[axis] = 0; magZeroTempMax[axis] = 0;}
for(axis=0;axis<3;axis++) {magZero[axis] = 0;magZeroTempMin[axis] = magADC[axis]; magZeroTempMax[axis] = magADC[axis];}
calibratingM = 0;
}
if (magInit) { // we apply offset only once mag calibration is done
...
With this modification the compass works fine.
Have someone of your made similar experience with it's compass ic ?
JayBee