Download Print this page

Parallax 29115 Manual page 15

Line follower module

Advertisement

Contest Line Follower Program
Line Following competitions are very popular with robotics clubs. A typical contest course consists of a
curvy line that moves across the playing surface, with start and end points are marked with a "T" (see the
photo on page 18). Listing 3 (starts on page 15) is a contest-ready line following program.
Contest code logic:
1. Read the Line Follower module
2. If lfBits = %00100 then BOE-Bot is on course
3. If lfBits = %11111 and BOE-Bot has been on course, then stop
4. Adjust motor speed (steering) based on Line Follower input
5. Save Line Follower input
6. Go to Step 1
Contest Code Program Analysis
Line following contests are timed events, so this program allows for a controlled start and will stop when
the end of the track is detected. These are the two aspects that differentiate this program from the simple
line follower, so that is where the discussion will be focused.
To obtain a controlled start, the program uses a flag value stored in the Stamp's EEPROM. After
download, the value at EEPROM location 0 (RstValue) is $FF. Before initializing, the program reads this
value, inverts all the bits, then writes it back. If the inverted value is greater than zero, the program runs,
otherwise it jumps to the label No_Run and stops in a low-power state.
The next time the Stamp is reset (by pressing the Reset button), the reset flag value is read and inverted
again. This time the inverted value will be $FF and the program will proceed to initialization and the BOE-
Bot will start.
Detection of the end of the course is fairly easy, but not trivial. Simple logic would dictate that a current
Line Follower value of %11111 with a previous reading of %00100 would indicate the end of the course.
While it does, this method is not always successful in application. If the BOE-Bot hits the end marker just
after a curve, the sensor array my not be centered on the course line and the end point will be missed.
This code, then, keeps a flag value called onCourse. After each reading, the value is checked to see if it
is %00100. If it is, the onCourse flag is set to Yes (true). Now, when the Line Follower returns %11111
the program checks to see if the BOE-Bot has been on the course. If yes, then the end has been found
and the motors are stopped.
Before shutting down, zero is written to the RstValue EEPROM location. This will allow the BOE-Bot to
start again when the Reset button is pressed.
This program uses the same steering control routines, but they have been made somewhat more
aggressive than those used in the simple line follower. The turning radius has been shortened to keep
the BOE-Bot closer to course center, reducing the time to move around the course. You may want to fine
tune the steering values to match the code to the particulars of the course to be run.
Parallax, Inc. • Parallax Line Follower (#29115) • 12/2001
Page 14

Advertisement

loading