only requires two GPIO pins (not
including power and ground):
one for the SCL signal and one
for the SDA signal. From this
two-wire bus, we can connect
as many sensors as we want, up
to the addressing limits
mentioned previously.
This new VEX Cortex
feature seems to leave all the
VEX 0.5 microcontroller users
out in the cold, unfortunately,
since it does not provide a
dedicated I2C port. Still, we can
do something about this state
of affairs in that we can
simulate this interface on the
original VEX v0.5 microcontroller
using a technique known as bit
banging (this will be
demonstrated in Part 2). When
using bit banging on the VEX
0.5 microcontroller, the data
rates will be considerably slower
than those referred to above,
but we should still be able to
read most of the devices with
no problems.
In fact, the EasyC firmware provided for the VEX 0.5
microcontroller can easily be adapted to run on the VEX
Cortex and the VEX Pro (ARM9) microcontrollers using their
I2C bus. This means some minor changes to the application
are required to use direct EasyC I2C instructions supported
by those controllers instead of the bit banged instructions.
In fact, only the main routine controlling the compass
would need to be converted.
We mentioned that an electronic compass such as the
HMC6352 module can be interfaced to the VEX
microcontroller (what better way to get your robot to travel
in a specific direction than by using an electronic compass).
Using it, we can tell our robot to simply move north 20
inches from its current position, then move east 20 inches,
then move south 20 inches, then move west 20 inches, and
then move north another 20 inches back to its original
position. It will have traveled in a square trajectory path.
What does all this information mean for VEX users?
The I2C port on the Cortex microcontroller opens a whole
array of new sensors from both IFI and third-party vendors.
These are sensors that require little or no calibration. They
can also be auto-configured for your VEX robotics
application using the device ID and device configuration
information stored in the sensor’s local non-volatile memory
(usually EEPROM). Just think of how many sensors you can
use on your robot using only one I2C port.
THE grEAT COMPASS EXPEriMENT
In this experiment, we will show you how to make your
FigurE 5. Setup with
the I2C interface connected
to a typical microcontroller.
own electro-magnetic compass using some VEX
components and an I2C based electronic compass to
interface to the HMC6352 electronic compass. The
connection to the compass module using a VEX v0.5
microcontroller is shown in Figure 5.
The bill of materials used in this experiment is shown in
Table 1. Be sure to connect the ground wire and power to
QT Y
1
1
1
1
1
1
TABLE 1. Bill of materials for the VEX
electromechanical compass.
DESCRIPTION SOURCE
VEX microcontroller Innovation First, Inc. (IFI) www.vexforum.com
7. 2 volt battery IFI
Wire-wrap cable RadioShack www.radioshack.com
IFI
SparkFun
www.sparkfun.com
IFI
1
IFI
1
IFI
1
VEX bumper switch
HMC6352 electronic
compass
12-tooth gears: 0.5"
( 12. 7 mm) pitch dia.
36-tooth gears: 1.5"
( 38.1 mm) pitch dia.
60-tooth gears: 2. 5"
( 63. 5 mm) pitch dia.
84-tooth gears: 3. 5"
(88.9 mm) pitch dia.
VEX quadrature encoder
IFI
1
IFI
4
Square metal shafts
IFI
1
VEX three-wire motor
IFI
SERVO 01.2013 55