Convert magnetic flux density to degrees

812 Views Asked by At

I have a digital magnetometer (compass) which outputs the following:

  • Magnetic flux density ranging $\pm1229\mu\text{T}$ on the X axis
  • Magnetic flux density ranging $\pm1229\mu\text{T}$ on the Y axis
  • Magnetic flux density ranging $\pm1229\mu\text{T}$ on the Z axis

I would like to convert these values into degrees (relative to the north).

Searching on the web, I found that $\arctan\left(\frac{y}{x}\right)$ should give the answer in Radians.

However, rotating the device on the XY plane, I only get values from $10$ to $60$ degrees.

I believe that I am correctly converting the raw (measured) data into magnetic flux density.

Any idea would be highly appreciated.

Relevant documents can be found at:


Empiric Measurements:

   | North | East  | South | West
---|-------|-------|-------|-------
 X | -75uT | -50uT | -25uT | -50uT
---|-------|-------|-------|-------
 Y | -35uT | -10uT | -35uT | -60uT
---|-------|-------|-------|-------
 Z | 140uT | 140uT | 140uT | 140uT

UPDATE:

I've found the following neat description, which might explain why I keep getting values within only a single quarter of the circle:

$ h(x,y)= \begin{cases} 90 & x = 0 , y\neq0\\ 0 & x\neq0 , y = 0\\ \arctan\left(\frac{y}{x}\right) & x > 0 , y > 0\\ \arctan\left(\frac{y}{x}\right) + 360 & x > 0 , y < 0\\ \arctan\left(\frac{y}{x}\right) + 180 & x < 0 , y\neq0\\ &\\ \end{cases} $

The article also claims that we need to use the accelerometer values in order apply correction on the magnetometers values, before we use them in order to calculate the compass heading, but that is besides my main concern for now:

enter image description here

1

There are 1 best solutions below

6
On

Your magnetometer is giving three cartesian components of the magnetic flux density $\vec{B}$. If you are interested only in the 'degrees with respect to the north', then assuming that your $z$ axis points to the north, you can get it as, \begin{equation} \theta = \cos^{-1}\left(\frac{B_z}{\sqrt{B_x^2 + B_y^2 + B_z^2}}\right) \end{equation} In three dimensions, you may be interested not only in the polar angle (latitude) but also the azimuthal angle (longitude). You can get it as, \begin{equation} \theta = \tan^{-1}\left(\frac{B_y}{B_x}\right) \end{equation}