122-28029 Parallax Inc, 122-28029 Datasheet - Page 153

GUIDE STUDENT SMART SENSORS

122-28029

Manufacturer Part Number
122-28029
Description
GUIDE STUDENT SMART SENSORS
Manufacturer
Parallax Inc
Datasheet

Specifications of 122-28029

Accessory Type
Manual
Product
Microcontroller Accessories
Lead Free Status / RoHS Status
Contains lead / RoHS non-compliant
For Use With/related Products
Smart Sensors
Lead Free Status / RoHS Status
Lead free / RoHS Compliant, Contains lead / RoHS non-compliant
LOOP
' -----[ Subroutine - Compass_Get_Axes ]--------------------------------------
' This subroutine handles BASIC Stamp - HM55B communication and stores the
' magnetic field strength measurements returned by the device in the x and
' y axis variables.
Compass_Get_Axes:
' -----[ Subroutine - Compass_Correct_Offsets ]-------------------------------
' This subroutine corrects cumulative magnetic field interference that can
' come from sources such as the PCB, jumper wires, a nearby battery, or a
' nearby current source.
' the EEPROM space that was reserved by the CompassOffsets DATA directive.
GOSUB Compass_Get_Axes
GOSUB Compass_Correct_Offsets
angle = x ATN -y
DEBUG HOME, "x-axis N(-S) = ",SDEC x,
GOSUB Compass_Interpolate
DEBUG CR, CR, "angle = ",
angle = angle */ 361
DEBUG CR,"angle = ",
PAUSE 150
HIGH En: LOW En
SHIFTOUT DinDout,clk,MSBFIRST,[Reset\4]
HIGH En: LOW En
SHIFTOUT DinDout,clk,MSBFIRST,[Measure\4]
status = 0
DO
LOOP UNTIL status = Ready
SHIFTIN
HIGH En
IF (y.BIT10 = 1) THEN y = y | NegMask
IF (x.BIT10 = 1) THEN x = x | NegMask
RETURN
HIGH En: LOW En
SHIFTOUT DinDout,clk,MSBFIRST,[Report\4]
SHIFTIN
CLREOL, CR, "y-axis W(-E) = ",
SDEC y, CLREOL
DEC angle, " brads", CLREOL
DEC angle, " degrees", CLREOL
DinDout,clk,MSBPOST,[x\11,y\11]
DinDout,clk,MSBPOST,[Status\4]
This subroutine relies on values stored in
Chapter 4: Hitachi HM55B Compass Module · Page 141
' Get x, and y values
' Correct axis offsetes
' Convert x and y to brads
' Display corrected axes
' Linear interpolation
' Display inrerpolated angle
' ... in brads
' Convert brads to degrees
' Display inrerpolated angle
' ... in degrees
' Debug delay for slower PCs
' Repeat main loop
' Compass module subroutine
' Send reset command to HM55B
' HM55B start measurement command
' Clear previous status flags
' Status flag checking loop
' Measurement status command
' Get Status
' Exit loop when status is ready
' Get x & y axis values
' Disable module
' Store 11-bits as signed word
' Repeat for other axis

Related parts for 122-28029