Go Down

Topic: incorrect z_axis data of hmc5883l (Read 138 times) previous topic - next topic


hello every one,
i use hmc5883 and i use calibrate arduino code to get heading.
i have a problem:
when i turn and move my sensor in a flat desk, the data of z_axis is change and the big differences are shown.
you know, at a flat desk, the x and y axis can be changed because of the change of heading(row). how can i fix my problem and make correct the z_axis data?
thank you


Find your  LAT / LON.  Check how earths mag. field is at your location..

You'll probably see that all three axis change when sensor is horisontal and rotated slowly


@ knut_ny
 you know, if we move and rotate the sensor ate a flat desk, just the heading(yaw) angle is changed, so the value of x and y are changed too.
but the value of z must be almost constant. because we do not change the pitch and roll of the sensor.
i use the calbration code and can calibrate my sensor to show the heading. but i dont know how can i calibrate the z axis?
how can i fix this problem?


but the value of z must be almost constant.
Not if there are nearby iron-containing objects, current carrying wires or other sources of magnetic fields.

i use the calbration code
What calibration code and what were the results?


thank you. my code is attached. and my results after calibrating heading and move at  a flat desk, is like the picture i attached.
the values are in micro tesla.
this code use x0ff and y0ff. by the simple formula like this:

Vector mag = compass.readRaw();

  // Determine Min / Max values
  if (mag.XAxis < minX) minX = mag.XAxis;
  if (mag.XAxis > maxX) maxX = mag.XAxis;
  if (mag.YAxis < minY) minY = mag.YAxis;
  if (mag.YAxis > maxY) maxY = mag.YAxis;

  // Calculate offsets
  offX = (maxX + minX)/2;
  offY = (maxY + minY)/2;

it doesnt offz. so i change the software and add z_off. and change the .cpp and .h files too. but it doesn't work. so i have to use this simple code  i attached.


That library is very limited. To learn how to calibrate your compass properly, study this tutorial.

Go Up