Parallax Boe-Bot Assembly page 60

Mini-sumo robotics assembly documentation and programming
Hide thumbs Also See for Boe-Bot:
Table of Contents

Advertisement

Page 50 · SumoBot – Mini Sumo Robotics
DIRS = $0000
GOTO Reset
' -----[ Subroutines ]-----------------------------------------------------
Read_Line_Sensors:
HIGH LLinePwr
HIGH RLinePwr
HIGH LLineIn
HIGH RLineIn
PAUSE 1
RCTIME LLineIn, 1, lLine
RCTIME RLineIn, 1, rLine
LOW LLinePwr
LOW RLinePwr
' convert readings to bits
LOOKDOWN lLine, >=[1000, 0], lbLeft
LOOKDOWN rLine, >=[1000, 0], lbRight
RETURN
Read_IR_Sensors:
FREQOUT LfIrOut, 1, 38500
irLeft = ~LfIrIn
FREQOUT RtIrOut, 1, 38500
irRight = ~RtIrIn
RETURN
Creep_Forward:
FOR pulses = 1 TO 20
PULSOUT LMotor, LFwdSlow
PULSOUT RMotor, RFwdSlow
PAUSE 20
NEXT
RETURN
HOW IT WORKS
After the Reset code for Run/Don't Run developed in the chapter 4, the SumoBot reads
the QTI sensors and calculates a suitable threshold level for the playing field that will be
used during the match. The net effect is to calculate the average sensor reading ((left +
right) / 2) and then divide this value by four. The blackThresh variable holds this level
and is recalculated for each match (this works because the SumoBot starts in near the
center of the ring, over the black surface). Using this strategy, the SumoBot can deal
with variable ambient lighting conditions that may change from match to match.
' disable all outputs
' reset for next round
' activate sensors
' discharge caps
' read left sensor
' read right sensor
' deactivate sensors
' 0 = black, 1 = line
' modulate left IR LED
' read input (1 = target)
' modulate right IR LED
' read input (1 = target)

Advertisement

Table of Contents
loading

This manual is also suitable for:

QuadcrawlerToddlerSumobotHexcrawler

Table of Contents