Kerwin's Line Following Robot Page

My line follower bot is a pretty basic design using a differential drive system. I built with Futaba S-148 servo motors mounted to the bottom of the plexiglass. I bolted the hub of the Dave Brown Lite Flite foam wheels to the control horn of the servos. The sensor system consists of an array of 3 matched IR transmit/receive pairs mounted on a circuit board that can be raised or lowered to fine tune the sensitivity. The omni-directional wheel on the front is not really necessary, but it looks cool. I used it because I had it laying around and added color. I made a mounting bracket for it using a PC's PCI blank port cover I pulled out of the trash. Nice soft metal in those things and easy to bend.

The circuit board mounted on top is one of Dennis Clark's AVR based robot boards. The Denver Area Robotics Club bought a bunch of these from him en masse, but any controller would work of course.

The IR sensor array consists of 3 IR transmit/receive pairs that are matched for performance. I got these from Electronic Goldmine, part number G2540. But any similar part would work. I painted the circuit board black and placed some black felt between each pair to cut down light being received from the side rather than as a reflection. The bolts used to adjust height are on each side.
A rough block diagram is shown here. The diode is the IR transmitter and the receiver is the phototransistor. I only show one here for clarity. The microcontroller takes input from sensor array, and drives the servo motors in response.

The output of the phototransistor looks like this. The plot here shows the voltage response over time as the sensor travels from black to white (as the robot loses the line). The output voltage drops from about 3.5V on average to about 0.2V in 18 ms.

The Atmel Botboard I use on this project has 2 A/D channels via an A/D chip. The data from this A/D chip is read by the Atmel 90S2313 by a serial interface. I use the 2 A/D channels for the left and right sensor. The center sensor I run to the 2313's onboard comparator.

I retrieve the data from the A/D channels as a 12 bit digital value that represents the Voltage. 2^12 is 4095, so if I had 5V input, the A/D would report a value of 4094 (decimal). 0V would be a value of 0. 2.5 V would be halfway at 2047. I read the value, and then compare it to a threshold value of about 2050 or so (a little over 2.5V). If the output of either of the A/D channels goes below 2050 then I call that a "white" value and I call that a 0 output. Above that threshold is black, which is a 1.

The center sensor goes to the 2313's onboard comparator. I set the compare or reference voltage with a divider circuit to get 2.5V as a threshold. Then with software I invert the output of the comparator so that a Voltage above 2.5V is an output of 0 (white). Below the ref is a 1 (black).

I take a sample every 20 ms or so since that is the fastest the data can change, and make a decision based on a state table of the possible states of the three sensors. This table is shown to the right.

State Table
L C R Meaning Action
0 0 0 Lost Decide
0 0 1 Rt is on line Right turn
0 1 0 Center on line Go forward
0 1 1 Rt/Cen on line Right turn
1 0 0 Left on line Left turn
1 0 1 Confused Back up,try again
1 1 0 Lft/Cen on line Turn Left
1 1 1 Confused Back up,try again
This photo shows a closeup of the sensors in action. IR light is invisible to the human eye, but not to most video cameras. Any CCD camera can "see" IR light. A CCD camera is a very handy tool to have when debugging and testing an IR circuit. Since you can't see it, you don't know if its on. If you use IR LED's, you should use a CCD if you have one to be sure they are working before you waste a lot of time chasing some other problem that isn't there after all.

click here to see a video clip of the line follower in action

click here to see source code (written in BASCOM BASIC)

click here to go to a page where you can download the BASCOM BASIC compiler for the AVR microcontroller

click here to see a more detailed schematic of how to connect the IR tx/rx pair

click here to go to a page about Dennis Clark's AVR BotBoard. The schematic above shows connections to connectors on this board