sensors. First, if the robot was placed on the line in its
expected setup position, then all line sensors should be ON
initially (the state of each line sensor is represented by
single bit in the line sensor data). If we rotate the robot a
reasonable amount (perhaps 45° to the left), all of the
sensors should be OFF. If either of these conditions is not
met, then one or more of the line sensors are not working.
If the above conditions are found to be true, we can
assume the line sensors are probably working properly — at
least we know that each sensor will turn both ON and OFF.
We can further verify the operability of the line sensors by
using them to return the robot to its original starting
position. As long as the wheel encoders are somewhat
accurate, at least one of the line sensors should be back on
the line if the robot turns right 45°. If none of the sensors
see the line, the program should simply report the situation
and advise the user to fix the problem (which is probably
related to the wheel encoders).
If some of the sensors are ON after the initial rotation,
the robot should use the sensors to center itself on the line
again. If the robot is unable to position all three sensors on
the line with a reasonable amount of tries, then we must
assume the robot has problems with small movements
(perhaps, for example, the motors are running too fast or
too slow) and the user should correct the problem before
testing can continue.
Of course, as mentioned earlier, if problems are
detected when testing the first sensory subsystem, the
program cannot be absolutely certain if the problem is with
the wheel encoders, the motors, or the line sensors. As
long as the robot is capable of rudimentary maneuverability
though, the described algorithm for testing the line sensors
should be able to ascertain if the sensors are working
correctly. If any portion of the test fails, the user should be
informed of the findings and advised to diagnose and fix
the problem before testing can continue. After all, if the
robot is not capable of basic maneuverability, we cannot
expect it to perform a self-test. For that reason, a successful
test can validate that the line sensors are working and
that there is reasonable maneuverability. If the test fails,
the program can only provide speculation on what might
be wrong.
The code fragment in Figure 2 implements the line
sensor testing algorithm described above. As you can see,
the actual testing is very simple, and most of the code is
just providing the user with the test results. If you
implement this algorithm on an embedded processor with
a limited ability to display text, it could simply report error
codes to indicate each of the possible outcomes.
If the line sensors all turn ON and OFF, and if the
robot can use them to position itself on the line again,
then we can be confident that the sensors are working
properly and that the robot is capable of reasonable
maneuverability. Knowing that the robot has these
minimal abilities allows us to easily test other sensors.
The User Interface
Before we look at additional testing though, let’s
examine the GUI (graphical user interface) used in the
demonstration program to make the simulator testing more
friendly. Figure 3 shows a sample screen from the test
program. Notice it includes the simulator test environment
depicted by Figure 1.
The current test (in this case, the line sensors) is
displayed in the upper left corner of the screen. The lower
center of the figure describes the test and gives the user
any special instructions that are needed. For the line sensor
test, it explains that the robot will rotate to test the sensors
and informs the user that they can click the PERFORM TEST
button to run the current test, or the FULL AUTO button to
perform all the tests in sequence automatically.
If the tests are performed individually, the description
of each test will be displayed while the program waits for
the user to click one of the buttons. The test program
should return the robot to its original position at the end of
each test. Notice also that the program displays the current
status of all the sensors being tested.
Regardless of whether individual or automated testing
is used, the test results will be displayed as shown in Figure
4. A great feature of the RobotBASIC simulator is that you
can force it to add a specified amount of error to its
movements and sensor readings to make it operate more
40 SERVO 12.2016
Figure 4
Figure 3