this calibration will correct or compensate for the hard iron effects.
hard iron effects are magnetic filed superimpositions on the earth's magnetic field that are fixed in
magnitude and which do not depend on the orientation of the compass.
the compass calibration shall be initiated by a user command that put the compass into the
calibration mode. once in that mode the compass shall be rotated through 360 degrees abouth the
forward or left direction followed by a 360 rotation about the up-down direction. that is, there are
two full rotations required to complete the physical movement required. at the end of the rotations
a command to end the calibration process shall be issued by the user to the compass.
it is important to keep the forward (or left ) axis level during the first rotation and to keep the up-
down axis vertical during the second calibration and until the flu calibration is complete. Failure to
follow these process will result in less than optimal calibration and heading errors are likely.
#define calthreshold 0
int Xmax,Xmin,Ymax,Ymin,Zmax,Zmin;
viod Intialize_Cal_Variables(int MagX, int MagY, int MagZ)
void Calibrate(int MagX, int MagY, int MagZ)
void Compute_and_Save(void)
void Hard_Iron_correction(int Xoff, int Yoff, int Zoff)
viod Intialize_Cal_Variables(int MagX, int MagY, int MagZ)
{
//set Max and Min values of the mag output to the current values
Xmax = MagX;
Xmin = MagX;
Ymax = MagY;
Ymin = MagY;
评论28