Using Digital Sensors With VEX
By Daniel Ramirez
Discuss this article in the SERVO Magazine forums at http://forum.servomagazine.com.
Compasses have been around for over a thousand years. Loadstone (a mineral with magnetic
properties) was used to magnetize a metal pin and has been used in compasses for hundreds of years.
Magnetic compasses were invented during the Chinese Han Dynasty between the second century BC
and first century AD, and were used for navigation by the 11th century. The compass was introduced
to medieval Europe 150 years later, where the dry compass was invented around 1300.This was
supplanted in the early 20th century by liquid-filled magnetic compasses.
Figure 1 shows a modern magnetic compass used for
navigation, travel, or hiking. Notice the red needle that is
pointing north. By aligning the graduated ring with the red
end of the needle, we can read the direction in degrees,
where north is zero degrees. Unfortunately, the Earth's
magnetic poles do not coincide with the rotational poles,
and the positions of the magnetic poles change over time
on a scale that is not extremely long by human standards.
Significant movements happen in a few years. (Over
millions of years, the directions of the true poles also shift
because of continental drift.)
For an observer at any point on the Earth's surface,
there is an angle — called the magnetic declination (or
magnetic variation) — between the directions of magnetic
north and true north. The magnetic declination varies at
different points on the Earth, and also changes with time.
Close to the equator, the magnetic declination is no more
than a few degrees, but in arctic and Antarctic latitudes, it
can be much greater. Some magnetic compasses include
means to compensate for the magnetic declination, so that
the compass shows true directions relative to the Earth's
An electronic compass detects the direction of the
Earth’s magnetic field electronically, so it can obtain a
direction while it is stationary or moving. Electronic
compasses are currently being used in iPhones, iPads, and
Android tablets to provide the user with map directions
while traveling by car or on hikes for navigational purposes.
Electronic compasses are low cost and can be a very useful
sensor for robotics.
Robot navigation algorithms can take advantage of an
onboard electronic compass to let
the robot know which direction it is
heading in while running
autonomously. It can also assist the
operator if the robot is being
maneuvered by remote control. Of
course, GPS can also provide a
vehicle’s current heading if the
robot is moving, but it is more
Thanks to technical advances in
new GPS technologies, however, we
now have low-cost digital electronic
compasses as well, such as the one
based on the Honeywell HMC6352
shown in Figure 2. (You can pick
these up at SparkFun.com for
around $35 dollars.) These
electronic compasses can be used
FIGURE 1. A modern magnetic compass used for navigation, travel, or hiking. Notice the red
needle that is pointing north.
52 SERVO 01.2013