English
Language : 

27-400 Datasheet, PDF (38/77 Pages) List of Unclassifed Manufacturers – Assembly Documentation and Programming
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:
LOOKDOWN lLine, >=[1000, 0], lbLeft
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:
Left_Conv:
IF (lLine >= 1000) THEN
lbLeft = 0
ELSE
lbLeft = 1
ENDIF
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.