Initial report by John Schimmel, 25 October 2005

Attach:foo.jpg Δ

This Compass Module made exclusively by Parallax is a dual-axis magnetic field sensor built around the Hitachi HM55B IC. Parallax has made this compass IC accessible by providing Hitachi’s surface mount sensor chip with a 3 V onboard voltage regulator and resistor protection, all in a 0.3” wide 6-pin DIP module. Acquiring measurements from the module is made easy with a synchronous serial interface, and even easier with the commands SHIFTIN and SHIFTOUT. This paragraph is pulled from the parallax compass documentation


Parallax Compass Module

The compass module is ideally made for the Parallax's Basic Stamp but remember that the Stamp is just a glorified PIC! So anything you can do on a Basic Stamp you can do on a typical PIC with PICBasic - for example the SHIFTIN and SHIFTOUT commands are identical, along with many other commands.

The documentation that Parallax provides is incredibly useful, read it completely - several times. The first problem you'll encounter is that the code written for the Basic Stamp uses the arctan (ATN) function, PICBasic Pro has no arctan() function, some alternative solutions will be provided below as they are found. So don't worry about the missing PICBasic arctan, you really only need it for applications that need precise direction/degree information.

Applications

  • Mobile robot direction sensor
  • Handheld electronic compass
  • Weathervane indicator for remote weather stations
  • Audible compass for the visually impaired
  • Automotive electronic compass
  • Compass jacket, pants or jewerly

Electrical Characteristics

  • To find out about the compass from the manufacturer - Hitachi's HM55B IC datasheet
  • But the one you want to look at is really at is Parallax's datasheet documentation
  • Buy it here at Parallax's online store
  • Voltages
    • Vcc = Supply Voltage = 4.8 - 5.2 Volts (standard ITP breadboard voltage safe!)
    • Icc = Average active current = 5 mA
    • Icc = Standby current = 2 mA
    • Icc = Peak instanteous current = 30 mA (for about 5 micro-seconds)
  • Magnetic Compass Sensor
    • The compass module detects the magnetic fields parallel to the internal x and y axes. Think of trig class in 10th grade, the x-axis tells us (field strength) * cos(@) and the y-axis tells of the (field strength) * sin(@).
    • The sensor reports both x and y
    • +X = NORTH
    • -X = SOUTH
    • +Y = WEST
    • -Y = EAST
  • TESLA! MICRO-TELSA!
    • The sensors detects microteslas. Tesla is the value of a magnet's flux or power divided by the area.
    • From wikipedia, in the Earth's magnetic field at latitude of 50° is 20 µT (2×10-5 T) and on the equator at a latitude of 0° is 31 µT (3.1×10-5 T).

Pin Descriptions

The 6 pins include:

  1. Din - Data Input Pin - used in SHIFTOUT command
  2. Dout - Data Output Pin - used in SHIFTIN command
  3. GND, Vss - Ground
  4. CLK - Clock Pin - used in SHIFTIN & SHIFTOUT commands
  5. EN - Enable Pin - used in SHIFTIN & SHIFTOUT commands
  6. Vcc, +5 Volts power

There are two ways to wire the compass, the first model uses 3 wires instead of 4

The data lines share a line into the PIC.

But the 4 wire hookup works fine too.

Microcontroller Connections

Code Sample

PICBasic Pro compass code does not provide angles, it simply finds NORTH, SOUTH, EAST & WEST.

Code Sample

Work Arounds for ArcTan in PICBasic Pro

Typical Behavior

Sample data from the PICBasic Pro code:

xy-+x-+yabs(y/x)=abs(y/x)
pointed northwest
512+x+y12/520
313+x+y13/340
412+x+y12/430
pointed north
80+x+y0/80
90+x+y0/90
pointed northeast
-1-9-x-y9/190
-1-10-x-y10/1100
pointed east
-12-11-x-y11/120
-11-12-x-y12/1110
-12-11-x-y11/120
pointed southeast
-23-2-x-y2/230
-24-4-x-y4/240
pointed south
-277-x+y7/270
-268-x+y8/260
pointed southwest
-2018-x+y18/200
-2017-x+y17/200
pointed west
-920-x+y20/920
-1021-x+y21/1020

Application Notes

  • Made a portable compass that indicates N, S, E, W with one LED always illuminated to indicate North.
  • Processing application would be nice, maybe that will be next.
  • The compass is small enough to work nicely with wearable projects.
  • Would like to get the angles and arctan working in the PICBasic Pro environment.