April
2004, Issue 165
Mini
Rover 7
Electronic Compassing fo Mobile Robotics
by
Joseph Miller
MAGNETIC
MEASUREMENTS
A
magnetometer is an instrument that can measure the flux
density of a magnetic field. It uses one of any number
of types of sensors to convert magnetic flux to voltage,
current, frequency, or some other electronically measurable
form.
There
are numerous types of magnetic field sensors: the saturable
core magnetometer (or fluxgate magnetometer), the Hall
effect sensor, the magneto-resistive sensor, and the
magneto-inductive sensor. A two-axis magnetometer, in
which the two sensors are in quadrature (orthogonal)
orientation, can be used as an electronic compass to
compute heading. When it is parallel with the measured
field, the magnetometer sensor’s output is at maximum
for the given amount of magnetic flux density that is
present. When the magnetometer sensor is perpendicular
to the magnetic lines of flux, the sensor will output
no signal. A plot of the x-sensor output versus the
y-sensor output results in the heading being represented
around the polar axis of the coordinate system origin
(see Figure 2).
|

(Click
here to enlarge)
|
Figure
2—I plotted the magnetometer sensor output versus
the angle. You can also see the x-y plot of the
magnetometer sensor output. |
This
form is preferred as a visual analysis tool for sensor
and system performance analysis and troubleshooting.
Notice that the y-axis is inverted from that of a typical
Cartesian coordinate system. This was done so that the
compass coordinates would be produced in its correct
orientation. When operating with compass coordinates,
it is important to remember to make the proper translations
from a Cartesian coordinate system to a compass coordinate
system, especially after using trigonometric functions.
At
angles between parallel and antiparallel with respect
to the magnetic lines of flux, the sensor’s output signal,
X, is a product of the applied magnetic flux density,
b, and the cosine of the angle, q, of the sensor from
being parallel with the flux lines.
[1]
If
a second sensor is added, and if it is positioned at
a right angle to the first sensor, its output, Y, will
have the same function as X, but will be 90° out of
phase. The y sensor will be in the east position, and
the x sensor will be in the north position. The two
sensors are said to be in quadrature with one another.
The equation for output Y is the following:
[2]
You
now have enough data to compute heading from the output
values of the x and y sensors. Use the trigonometric
identity:
[3]
Combining
Equations 1–3 yields:
[4]
The
arctangent, or inverse tangent (tan–1), is inherently
restricted to ±90°, which covers only two quadrants
of the coordinate system over its entire input range
of –¥ to ¥. This function also operates in the Cartesian
coordinate system, which is rotated 90° from compass
coordinates.
To
convert the Cartesian q to a compass heading coordinate,
a translation must be performed. Table 1 shows the translation
based on the output polarity of the sensors when the
sensors are oriented as shown in Figure 2. Note that
magnetometer polarities may vary depending on the manufacturer.
|
Measured
sensor value
|
Quadrant(s)
|
Heading
Calculation
|
|
X
|
Y
|
|
³
0
|
>
0
|
270–360
|
360
– Arctan (Y/X)
|
|
³
0
|
£
0
|
0–90
|
0
– Arctan (Y/X)
|
|
<
0
|
All
|
90–270
|
180
– Arctan (Y/X)
|
| Table
1—Use this table to convert the limited range, Cartesian
coordinates system output of the Arctan function
into full-range compass coordinates. |
As
demonstrated in Equations 1 and 2, the output signals
of both sensors are proportional to field density (b)
and its angle relative to magnetic north. The field
density can be extracted at any angle of the quadrature
pair by computing the geometric sum of the two sensors
outputs:
[5]
Equation
5 computes the horizontal component of the overall magnetic
field density from the perspective of the robot’s horizontal
plane. By monitoring this value, you can spot magnetic
anomalies and tilting, which effect heading accuracies.