Parallax Penguin Manual page 22

Table of Contents

Advertisement

' Parallax Penguin Robot
' Penguin-CompassTest.bpx
' {$STAMP BS2px}
' {$PBASIC 2.5}
Compass
PIN
Clock
PIN
Enable
PIN
Reset
CON
Measure
CON
Report
CON
Ready
CON
NegMask
CON
x
VAR
y
VAR
Heading
VAR
status
VAR
DEBUG CLS, "Heading:"
DO
GOSUB ReadCompass
DEBUG CRSRXY, 9, 0, DEC Heading, "°
PAUSE 150
LOOP
ReadCompass:
HIGH Enable
LOW Enable
SHIFTOUT Compass, Clock, MSBFIRST, [Reset\4]
HIGH Enable
LOW Enable
SHIFTOUT Compass, Clock, MSBFIRST, [Measure\4]
status = 0
DO
HIGH Enable: LOW Enable
SHIFTOUT Compass, Clock, MSBFIRST, [Report\4]
SHIFTIN
Compass, Clock, MSBPOST,
LOOP UNTIL status = Ready
SHIFTIN
Compass,Clock,MSBPOST,[x\11,y\11] ' Get x & y axis values
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
RETURN
Copyright © Parallax Inc.
15
13
14
%0000
%1000
%1100
%1100
%1111100000000000
Word
Word
x
x
"
[Status\4]' Get Status
Penguin Robot (#27313-27316)
' 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
v1.4 2/16/2010 Page 22 of 23

Advertisement

Table of Contents
loading

This manual is also suitable for:

27313273142731527316

Table of Contents