28029 Parallax Inc, 28029 Datasheet - Page 135

KIT PARTS SMART SENSORS W/TEXT

28029

Manufacturer Part Number
28029
Description
KIT PARTS SMART SENSORS W/TEXT
Manufacturer
Parallax Inc
Datasheet

Specifications of 28029

Accessory Type
Parts Kit
Product
Microcontroller Accessories
Lead Free Status / RoHS Status
Contains lead / RoHS non-compliant
For Use With/related Products
BASIC Stamp® or Javelin Modules
Lead Free Status / RoHS Status
Lead free / RoHS Compliant, Contains lead / RoHS non-compliant
Other names
28029PAR
DinDout
Clk
En
' -----[ Constants ]----------------------------------------------------------
Reset
Measure
Report
Ready
NegMask
' -----[ Variables ]----------------------------------------------------------
x
y
status
angle
' -----[ Main Routine ]-------------------------------------------------------
DO
LOOP
' -----[ Subroutine - Compass_Get_Axes ]--------------------------------------
Compass_Get_Axes:
GOSUB Compass_Get_Axes
angle = x ATN -y
angle = angle */ 361
DEBUG HOME, "x-axis N(-S) = ",SDEC x,
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
HIGH En: LOW En
SHIFTOUT DinDout,clk,MSBFIRST,[Report\4]
CLREOL, CR, "y-axis W(-E) = ",
SDEC y, CLREOL, CR, CR, "angle = ",
DEC angle, " degrees", CLREOL
PIN
PIN
PIN
CON
CON
CON
CON
CON
VAR
VAR
VAR
VAR
2
0
1
%0000
%1000
%1100
%1100
%1111100000000000
Word
Word
Nib
Word
Chapter 4: Hitachi HM55B Compass Module · Page 123
' P2 transceives to/from Din/Dout
' P0 sends pulses to HM55B's Clk
' P2 controls HM55B's /EN(ABLE)
' Reset command for HM55B
' Start measurement command
' Get status/axis values command
' 11 -> Done, 00 -> no errors
' For 11-bit negative to 16-bits
' x-axis data
' y-axis data
' Status flags
' Store angle measurement
' Main loop
' Get x, and y values
' Convert x and y to brads
' Convert brads to degrees
' Display axes and 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

Related parts for 28029