Home           Info Request           Quote/Order           Contact           Site Map           About           Search           Support/FAQ  

 ARobot Vector 2x Compass App Note
Back to ARobot Projects Page

This application note in PDF format

Vector 2x Compass on ARobot

This application note describes how to connect the Vector 2x compass to ARobot. The Vector 2x has a 2 degree accuracy compared to the Dinsmore compass that only has a 45 degree accuracy. The draw backs are that the Vector 2x costs about $50 and it takes over 200 ms to read it. Select the Vector 2x if you need more precision for navigation.

This application note will require soldering, cabling, and mounting which includes drilling and cutting of metal or plastic.

      Parts List
The Vector 2x compass is manufactured by Precision Navigation and can be purchased from many different places. Jameco http://www.jameco.com is a mail order catalog that sells them. There are also several other places on the web. The wire is generally used for wire wrapping but it makes excellent point to point soldering on circuits. All three colors are not necessary, but it makes it easier to track wires later when trouble shooting. Power wires can be red, signals can be blue, and ground can be white. The compass can be soldered directly into the perf board. This is probably easier to do. However, if the part is somehow damaged in the process of connecting, or improperly connected, it is much more difficult to remove a soldered part. I would suggest using a 20 pin IC socket (we'll discuss this more later). The dual row header and the 10 pin connector are used to attach the compass PCB to the ARobot main controller board. The aluminum brackets are used to mount the compass to the ARobot. Some of these electronic parts can also be found at Mouser Electronics http://www.mouser.com or Digi-Key http://www.digi-key.com.

   Part                   Part #            Price
Compass                  Vector 2x         $50.00
Perf board               RS #276-148        $1.49    RS=Radio Shack
Wire, red 30awg          RS #278-501        $2.99
Wire, white 30awg        RS #278-502        $2.99
Wire, blue 30awg         RS #278-503        $2.99
Dual row 40 pin header   RS #RSU11323813    $1.19
Socket                   RS #RSU11354297    $1.00
10 pin connector         RS #RSU11929643     $.49
40 conductor IDE cable   RS #278-780        $6.99  Or IDE disk drive cable.
Aluminum brackets        Hardware store     $4.00

This circuit will be created on the perf board. The compass will be placed in a socket created from a 20 pin IC socket. Cut the socket in half length-wise. Select an area on the perf board for the compass. Keep in mind that a 10 pin dual row header and a mounting hole will be needing space also. Now insert the two halves into the board so that the Vector will fit into them. Make sure that the compass will fit into the socket before soldering. Solder the sockets into the perf board.

Now cut the dual row header pins down to a total of 10 pins. Cut 5 on each row. Then select space on the PCB to insert the 10 pin header. Solder each pin to the perf board before continuing. Also drill out the mounting hole.

Now solder the circuit. Cut each wire longer than is needed. Strip about 1/10" off each end of the wire. There is no need to tin the wire; it will very quickly accept solder. Solder each connection carefully as to avoid shorting to surrounding pins. Another soldering technique that will save time is to daisy chain the connections. Cut a real long wire. Strip only one end. Attach that end to the PCB, determine length and strip section of wire right there. Attach that exposed wire to the connection point. Repeat until everything on that connection is complete.

GREAT CARE NEEDS TO BE TAKEN when wiring up the Vector 2x. The pins on the compass are not in any logical order. The pins are labeled on top of the Vector 2x module. They do not follow any standard numbering sequence. Check each wire connection before and after soldering. See the Vector 2x manual for additional information.


!! Incorrect wiring will damage compass !!

10 Pin Header Connector Pinout

   1 = GND 
   4 = +5v
   7 = P2  /SS/P/C
   8 = P3  SDO
   9 = P4  SCLK
  10 = P5  /RST

The cable in this example is constructed using a 40 pin IDE disk drive cable which is commonly available at computer stores. You can build your own cable using 40 pin flat cable and a 40 pin dual row header connector. Cut the cable so that the greatest length of cable is attached to one of the 40 pin connectors. The total length will depend on your mount arrangement. Then peel off the first 10 wires of that cable (be sure to start at wire #1). Attach the 10 pin connector to these 10 pins. Be sure to connect wire #1 to pin 1 of the connector (and wire #2 to pin 2, etc.). Now plug the cable into the compass board but NOT ARobot’s controller board yet.

Before the compass is installed into the PCB and before the cable is connected to the expansion connector, testing of the soldering and wiring needs to be performed. Test for continuity between power and ground. There should be NO continuity there. If there is and the power is turned on, ARobot COULD BE DAMAGED! Now check for continuity between the output pins on the compass and the 10 pin connector. You should have only one pin connected to one output. Then check for continuity between power and any of the output pins. There should be NO continuity here. Then connect the cable to ARobot’s expansion connector and turn on power. Check for +5v on the correct compass socket pins. This is very important because incorrect wiring can damage the compass. Now turn power off and install the compass sensor. It doesn’t matter which direction the device is turned. Insure that all pins connect with their socket pin. Try not to bend the leads when inserting the device.

Since the compass sensor uses the Earth’s magnetic field to sense direction, it’s very important to mount the sensor away from motors and speakers – preferably high above them. We suggest building a mast of 4”-12” tall to mount the compass. The mast can be built using aluminum plates and L brackets from a hardware store, or plastic from discarded toys. Minimize the number of steel nuts and screws that are near the sensor.

Use the following software example as a building block for your own program.

You can download this program here.

'vector.bs2    Arrick Robotics   www.robotics.com
'This routine shows how to read data from the 
'Vector 2x compass.

'compass signals.
select con 2		'select signal.
sdo con 3		'serial data out.
sclk con 4		'clock signal.
rst con 5		'reset signal.

speaker con 9		'speaker pin.
heading var word	'heading variable.

        output select	'set pin direction.
        output sclk
        output rst
        input sdo
        low speaker	'shut off the speaker.
        gosub compinit	'initialize the compass.

        gosub getcomp	'get the compass heading.

        debug dec ? heading   'Display heading.

        pause 500	'wait a sec.

        goto main	'loop for ever.

'this routine initializes the Vector 2x compass.
        high sclk
        high select	'make sure this is high.
        low rst	'lower reset pin.
        pause 15	'wait 15 ms.
        high rst	'raise reset pin.
        pause 200	'wait a bit.
        return	'done.

'This routine gets the heading from the Vector 2x
'compass and places it in the variable heading.
        low select	'start the Vector 2x.
        pause 200	'wait for heading.
        heading = 0	'clear variable.
        shiftin sdo,sclk,msbpre,[heading\16]
	'get the data from Vector 2x.

        high sclk	'reset pins.
        high select

        return	'done.

If the compass outputs were wired to different input pins then the software will need to be adjusted to achieve the correct directional output. The best place to start on trouble shooting is to check the circuit connections. Pull out the compass and unplug the PCB. "Beep" out every connection to ensure that it is connected to the right place. Next, check for shorts. Turn the board over to the solder side. Examine very closely all solder joints. The cable can also be a source of problems. Check to make sure that pin 1 of the expansion connector connects to pin 1 of the compass PCB connector (check pin 2 to pin 2, pin 3 to pin 3, all the way to 10). Then check for shorts between wires. See if wire 10 is connected to wire 9 (and wire 9 to wire 8, etc).

Here's are some useful sources for parts:

  Home           Info Request           Quote/Order           Contact           Site Map           About           Search           Support/FAQ  
Copyright (c) Arrick Robotics - ArrickRobotics.com