Show Posts
Pages: [1]
1  Using Arduino / Sensors / Re: Calibration of a HMC5843 compass on: February 12, 2011, 09:52:44 am
Thank you for your quick answer robtillaart

I have the HMC library from this page:
I have read the document. Maybe I can try it with this selftest but I don't know if this will calibrate the HMC.
 I thought about a code from somebody how has got the same problem.

In this thread was a discussion about it, but it ended without a result and it is closed now:

I will try the self test on monday, if there are no other ideas how to calibrate it
2  Using Arduino / Sensors / Calibration of a HMC5843 compass on: February 12, 2011, 09:08:52 am
Hello Arduino Community,
We have build a roboter-car which shall automatically turn to one direction (e.g. north) and drive into that direction. While it is driving into this direction it shall always adjust the measurement of the HMC5843 with the given value (e.g north or 0 degree).
We use this code to get the values from the HMC

#include <HMC.h>

float dir;
const float pi = 3.14159265;

void setup()  {
  delay(5); // The HMC5843 needs 5ms before it will communicate

void loop()
  int x,y,z,xb,yb,quadrat;
  delay(2000); // There will be new values every 100ms
  dir = 0;
  dir = atan2(float(y),float(x))*180/pi;


But the problem is, that the values that are given by the compass aren't approxamitly exact.
If I turn the compass by 90° the value given by the HMC changes by 70° or 100° or 110°.
I read about calibrating the compass to get more exact values. But I don't know how to do it.
Has somedoy of you a calibrating-code for the HMC?
Or has somebody an idea how to do it?
Pages: [1]