www.servomagazine.com/index.php?/magazine/article/january2013_Ramirez
for VEX robotic applications as we will demonstrate
in this article. The Honeywell HMC6352 electronic
compass provides headings from 0° to 360° within
a 1° resolution (if the compass is level). This is
excellent resolution and more than adequate for
most robotic applications considering the modest
price of the sensor. There are some sources of
interference that can reduce the theoretical
resolution somewhat; these will be covered below.
More expensive versions of these electronic
compasses can even compensate for tilts so that
they don’t need to be level to give good readings.
GETTING YOUR BEARINGS STRAIGHT
Depending on where the compass is located on
the surface of the Earth, the angle between true
north and magnetic north can vary widely as
mentioned, increasing the farther one is from the prime
meridian of the Earth’s magnetic field. The local magnetic
declination is given on most maps to allow the map to be
oriented with a compass parallel to true north. Users of
such a compass have to know the local value of the
magnetic declination, and adjust the compass accordingly.
For this adjustment, the moving ring on the compass is
used to compensate for declination from true north by
adding or subtracting the declination of the user’s
geographic location (latitude and longitude).
While these abnormalities (mostly caused by the
Earth’s molten core) can cause both magnetic and
electronic compasses problems, they can be adjusted for
using online declination compensation calculators provided
by the National Ocean and Atmospheric Administration
(NOAA)/National Geophysical Data Center (NGDC).
Their online magnetic declination calculator ( www.ngdc.
noaa.gov/geomag/declination.shtml) allows you to
enter your location (or zip code for the USA) and get the
declination value. Remember when using the declination
values that east declination is positive, west is
negative.
How can we correct a compass bearing to a true
bearing? We can compute the true bearing from a
magnetic bearing by simply adding the magnetic
declination to the magnetic bearing. This works as long as
you follow the convention of degrees that west is negative
(i.e., a magnetic declination of 10 degrees west is - 10 and a
bearing of 45 degrees west is - 45). This correction is
applied to both magnetic and electronic compasses, since
they use the Earth’s magnetic field to determine the
direction where magnetic north is located.
Another cause of error in compass readings is taking
them when the compass itself is not level. This source of
error can be reduced by insuring that the compass is
gimbaled.
Having thoroughly covered using analog sensors with
FIGURE 2.
Due to technical
advances in new
GPS technologies,
we now have
low-cost digital
electronic
compasses such
as the one
shown here.
the VEX microcontroller in previous issues of SERVO, in this
installment we will investigate new digital sensors that are
starting to show up in many new consumer products
including the iPhone, iPad, and automobiles (mentioned
previously). We will also show you how you can take
advantage of these exciting new sensors for VEX robotic
applications.
First, let’s cover some new sensors that are not quite
available yet from Innovation First, Inc. (IFI), although the
new VEX Cortex and VEX ARM9 microcontrollers do
support them in hardware through their I2C interface. As of
this writing, there is not yet support for them from the
compiler vendors (RobotC and Easy C Pro), although I’m
sure this is on their radar since these sensors are becoming
very popular for robotics, consumer, and industrial
applications.
JUST WHAT IS I2C?
I²C (“eye-squared cee;” Inter-Integrated Circuit;
generically referred to as a “two-wire interface”) is a multi-master serial single-ended computer bus invented by Philips
that is used to attach low-speed peripherals to a
motherboard, embedded system, cellphone, or other
electronic device. From the mid 1990s, several competitors
(e.g., Siemens AG, Intel Mobile Communications, NEC,
Texas Instruments, STMicroelectronics, Motorola/Freescale,
Intersil, Microchip, etc.) have brought I²C products to
market which are fully compatible with the NXP (formerly
Philips’s semiconductor division) I²C system.
Figure 3 shows a typical I2C connection with one
FIGURE 3. A typical
I2C connection diagram
using a master device
with various I2C devices
networked to it using
the two-wire bus.
SERVO 01.2013 53