122-27400 Parallax Inc, 122-27400 Datasheet - Page 38

MANUAL FOR SUMOBOT

122-27400

Manufacturer Part Number
122-27400
Description
MANUAL FOR SUMOBOT
Manufacturer
Parallax Inc
Datasheet

Specifications of 122-27400

Accessory Type
Manual
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
Page 28 · SumoBot – Mini Sumo Robotics
The technique for converting the raw sensor reading to a bit value takes advantage of the
{optional} comparison parameter with the LOOKDOWN function. Without the comparison
parameter, LOOKDOWN uses equality to scan its table for a value match. By using the
comparison parameter, we can test a range of values with a single table entry.
This line:
will put 0 into lbLeft if lLine is greater or equal to 1000, otherwise it will but 1 in lbLine
( lLine is between 0 and 999). This works because the comparison parameter is >= and
the first table entry [index 0] is 1000. LOOKDOWN will transfer the index to the output
variable as soon as a match is found. If the sensor value is less than 1000 (as when on the
border), the index value of 1 is moved into lbLeft .
We could use an IF-THEN-ELSE coding technique to accomplish the same thing:
As you can see, using LOOKDOWN with the comparison parameter is the more elegant
approach. You may be wondering why the value 1000 was used as the black level
threshold. It was selected to allow the QTI to be affected by external light and still return
an accurate reading. Extra light falling on the playing surface will reduce the QTI output
values. By using a value about one-fourth the normal black reading, the program has
plenty of margin for lighting variability. Now let's examine what happens with the output
values.
The bit variables lbLeft and lbRight are aliased into lineBits – this means a change in either
will cause a change in lineBits . We will use this variable with the SELECT-CASE
structure to determine and display which action to take based on the QTI sensor values.
LOOKDOWN lLine, >=[1000, 0], lbLeft
Left_Conv:
IF (lLine >= 1000) THEN
ELSE
ENDIF
lbLeft = 0
lbLeft = 1

Related parts for 122-27400