0
$\begingroup$

I'm using an HMC5883l compass module to find the angle at which my module is pointed from magnetic North. I found this code as an example with "HMC5883L_Simple.h" library.

enter image description here

And the results I'm getting right now are like this. Is it the angle at which my module is pointed from magnetic North in degrees? If not, How can find the pointing angle

enter image description here

$\endgroup$
1
0
$\begingroup$

I saw the code and yes, it is in degrees. It also would not make sense to be in radians cause it would mean a lot of turns.

$\endgroup$
1
  • $\begingroup$ so, it should be zero when I align my compass module with magnetic north right? But it is not happening. Do we have to do any kind of calibration before start using it? $\endgroup$ – Muhammed Roshan May 15 '19 at 15:51
0
$\begingroup$

In answer to your question the results do appear to be in degrees and unless you’ve entered a declination value then the results should point to magnetic north. If you’ve entered a declination offset for your local area then the magnetometer should point to true north.

In answer to your other question a magnetometer will be distorted by its local environment so if you have any local magnetic disturbances which dominate the earths magnetic field then this will distort the results and the magnetometer will point to this local source. If however the magnitude of the local disturbances are less than the earths magnetic field then there net effect will be to distort the results. These type of effects can be removed by calibrating for what are called hard iron (bias values) and soft iron (scaling values) which should account for the local distortions and ensure the magnetometer operates correctly (providing its local environment doesn’t change). To calibrate the magnetometer, data needs to be recorded whilst rotating the magnetometer (and the platform to which it’s attached) so that the collected data looks like an ellipse (data from all orientations). The collected data then needs to be transformed to a unit sphere. Various algorithms exist for performing this transformation to a unit sphere but a typical approach is a least squares estimation.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.