AnsweredAssumed Answered

MAG3110 x, y, z values change significantly when moving only few cm from calibrated position. Is there a way to compensate this?

Question asked by Justin Kim on Jun 23, 2015
Latest reply on Jun 24, 2015 by Joshevelle

Hello everyone,

 

I am currently playing around with the MAG3110 and developing e-compass and I run into a problem where if I move few cm away from the position where I got my first values of max and min x, y, z readings, the max and min values change significantly in the new positions. So, after I calibrate MAG3110, I get very different angle values when I move the MAG3110 to different positions but keeping the same orientation. If I rotate the orientation on the same position where I calibrated (where I got the max and min values of x, y, z), the angle works perfectly.

 

The MAG3110 is flat on the x-y plane and no tilt occurs.

 

Here is the pseudo code for what I do after I get the x_max, x_min, y_max, y_min:

 

...

setup()

{

     ctrl_reg2 = 0x80; // autoreset

     ctrl_reg1 = 0x01; // active mode

}

 

getReading()

{

   x_scaled = (getX() - ((xmax + xmin) / 2)) * (1.0 / (xmax - xmin))

   y_scaled = (getY() - ((ymax + ymin) / 2)) * (1.0 / (ymax - ymin))

 

   heading = atan2(-y_scaled, x_scaled);

 

   if (heading < 0)

      heading += 2 * PI;

   return heading * 180 / PI;

}

...

 

 

Thank you for your help!

Outcomes