27404 Parallax Inc, 27404 Datasheet - Page 136

COMPETITION RING FOR SUMOBOT

27404

Manufacturer Part Number
27404
Description
COMPETITION RING FOR SUMOBOT
Manufacturer
Parallax Inc
Datasheet

Specifications of 27404

Accessory Type
Hobby and Education
Product
Microcontroller Accessories
Lead Free Status / RoHS Status
Contains lead / RoHS non-compliant
For Use With/related Products
SumoBot®
Lead Free Status / RoHS Status
Lead free / RoHS Compliant, Contains lead / RoHS non-compliant
ACTIVITY #8: VARIABLE MANAGEMENT FOR LARGE PROGRAMS
When you have a project with a lot of sensors and programmed machine reactions,
variable space can become pretty tight. For example, the program in the previous activity
uses three words and one byte. There's one byte to take each QTI reading, and another to
store the QTI threshold. All three of these bytes are used at the beginning of the
program, but only one (threshold) is accessed repeatedly as the program runs. Since
threshold isn't even changed repeatedly as the program runs, it's not necessarily the best
use of a RAM variable either.
This activity uses the techniques introduced in Chapter 2, Activity #2 to use and reuse
temporary variables. As you go through the activities in this book, you will use the same
few temporary variables to monitor sensors, control servos, log data, and perform a
variety of maneuvers. In virtually every subroutine you build to perform these functions,
the same few variables will be used in different ways. Even after the activities in this
book, you can continue to add functionality to your SumoBot, without worrying that the
next sensor might take up too much RAM.
Incorporating Temporary Variables into SensorsWithByteDisplay.bs2
It's important to modify the sensor testing program (SensorsWithByteDisplay.bs2) so that
it uses the memory management techniques introduced in ThreeVariablesManyJobs.bs2.
Specifically, it has to use and re-use temporary variables and use EEPROM to store and
access values that don't change frequently. After the program has been modified, features
like more sensors, servo control, navigation, and datalogging can be added in many cases
without ever having to declare any more RAM variables.
In order from
detectors - right side, right front, left front, left side. QTI line sensors - right
front, left front, pushbutton.
Start by saving SensorsWithByteDisplay.bs2 as SensorsWithTempVariables.bs2.
Next, the
be commented out. In place of these three variables, you can use two word
variables -
' -----[ Variables ]---------------------------------------------------
' qtiLeft
' qtiRight
qtiLeft
temp
BIT0
(short for temporary) and
,
VAR
VAR
qtiRight
to
BIT6
Word
Word
, and
, test the sensors in this order: infrared object
qtiThreshold
' Stores left QTI time
' Stores right QTI time
multi
(short for multipurpose).
variable declarations need to

Related parts for 27404