27316 Parallax Inc, 27316 Datasheet - Page 22
![Microcontroller Modules & Accessories Penguin Robot BLACK](/photos/15/95/159532/27316-l_sml.jpg)
27316
Manufacturer Part Number
27316
Description
Microcontroller Modules & Accessories Penguin Robot BLACK
Manufacturer
Parallax Inc
Datasheet
1.27316.pdf
(24 pages)
Specifications of 27316
Product
Microcontroller Accessories
Core Processor
2PX24 Stamp
Lead Free Status / RoHS Status
Lead free / RoHS Compliant
' Parallax Penguin Robot
' Penguin-CompassTest.bpx
' {$STAMP BS2px}
' {$PBASIC 2.5}
Compass
Clock
Enable
Reset
Measure
Report
Ready
NegMask
x
y
Heading
status
DEBUG CLS, "Heading:"
DO
LOOP
ReadCompass:
RETURN
Copyright © Parallax, Inc. • Penguin (#27313-27316) • v1.0 7/12/2007
GOSUB ReadCompass
DEBUG CRSRXY, 9, 0, DEC Heading, "°
PAUSE 150
HIGH Enable
LOW Enable
SHIFTOUT Compass, Clock, MSBFIRST, [Reset\4]
HIGH Enable
LOW Enable
SHIFTOUT Compass, Clock, MSBFIRST, [Measure\4]
status = 0
DO
LOOP UNTIL status = Ready
SHIFTIN
HIGH Enable
IF (y.BIT10 = 1) THEN y = y | NegMask
IF (x.BIT10 = 1) THEN x = x | NegMask
Heading = x ATN -y
Heading = Heading */ 360
HIGH Enable: LOW Enable
SHIFTOUT Compass, Clock, MSBFIRST, [Report\4]
SHIFTIN
Compass,Clock,MSBPOST,[x\11,y\11] ' Get x & y axis values
Compass, Clock, MSBPOST,
PIN
PIN
PIN
CON
CON
CON
CON
CON
VAR
VAR
VAR
VAR
15
13
14
%0000
%1000
%1100
%1100
%1111100000000000
Word
Word
x
x
"
[Status\4]' Get Status
' Transceives to/from Din/Dout
' Sends pulses to HM55B's Clock
' Controls HM55B's /Enable
' 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
' Store Heading measurement
' Status flags
' Compass module subroutine
' Send reset command to HM55B
' HM55B start measurement command
' Clear previous status flags
' Status flag checking loop
' Measurement status command
' Exit loop when status is ready
' Disable module
' Store 11-bits as signed word
' Repeat for other axis
' Convert x and y to brads
' Convert brads to degrees
Page 22 of 24