IMG_3237 The simplest arrangement for a line follower is probably two sensors with digital outputs. As long as one can see the line and the other can see the background, the controller is happy otherwise it must turn left or right as appropriate. I was after something a bit more sophisticated for Bob the Line follower…

The first task it to examine the behaviour of a single sensor. To this end, a version of the Bob controller was made up on a breadboard and a single TCRT5000 sensor attached to a remote board. Black card has a white stripe added in the same way as the track. That is a single layer of cheap, 19mm white PVC tape. With the card mounted vertically, the sensor can be placed at varying distanced from the vertical track. A piece of perfboard taped to the desk lets me measure the distance between the sensor and the track as well as the lateral displacement. In this way a series of measurements can be taken as the sensor is moved across the track at different distances. All the room lighting is fluorescent with negligible IR content. The emitter is supplied from 5V through a 220 Ohm current limiting resistor. The phototransistor has a 10 kOhm resistor to the collector and thence to the 5V supply. Voltage are measured at the collector. The result of several trials is shown below:

sensor_readings

Dimensions are in inches. The results are entirely predictable. With the sensor close to the track, the edges are more clearly defined and the contrast between on-track and off-track are greatest. Readings across the width of the track are fairly equally matched. Such a response would be ideal for a sensor connected to a schmidt trigger input on a processor and would be likely to give reliable, clean indications of when the sensor was over the track.

As the sensor is moved further away, the response to the track is smaller and the edges less distinct. By the time it gets to be 0.4 inches away, it seems likely that there would not be a large enough response to trigger a processor digital input. Although not shown, very small distances can be quite problematic as these sensors have a tab that prevents the detector from directly seeing the emitter. When that is in contact with the track, although the reflected light is very strong, the tab prevents the detector seeing it.

The really interesting area is between about 0.3 and 0.4 inches above the track. Here we still get a fairly strong response but the reading varies continuously as the track passes in front of the sensor. this is particularly useful as it tells us not just where the edge of the track it but give an indication of how far away from it we are and leads to the possibility of measuring displacement quite accurately. Having only a single sensor, I replicated the results for a distance of 0.3 inches and arranged them in three sets in a spreadsheet to simulate three sensors space 0.5in apart. These results can then be combined in a single graph:

error_calc

At that spacing, you can see that the responses overlap slightly. As the track moves away from the central position with the no.2 sensor directly over it, the adjacent sensor responses grow. the purple line is the difference between the left and right sensors and this result looks particularly promising. It is always positive when we are in error one way and always negative when we are in error the other way. When we are positioned most accurately over the line, the slope of the error is greatest making the controller most sensitive to error. All in all, fro displacements up to about +/- 0.6 inches, this looks like an ideal error function allowing us to calculate  offset to a fine degree. The addition of another two sensors outside these three will extend the range of errors to at least +/- 1 inch. As the robot strays outside the error range indicated in the graph above a different pair of sensors can be used for the correction. It could be as simple as using the sensor either side of the one that is giving the largest reading. With care taken over what happens when only the outermost sensors can see the line, this should give a robust and accurate error function over a wide range of errors. Experiments with the actual sensor array will test this assertion. Or, at least, they will if I can get the serial comms working on Bob…

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.