Robot Line Follower

Robot Line Follower

The described line-follower sensor "interface controller" provides an i2c communications path to a Pololu QTR-MD-08RC reflectance sensor array. This is used as the sensor for a simple line-following robot. The sensor interface can be used as a separate piece on any robot that is capable of talking to i2c

The github repository linked below provides software that runs on an Adafruit ItsyBitsy and uses the Pololu driver library to actually talk to the sensor, and generates a processor-independent i2c interface that your robot can use to read the sensor. The github repo also contains a schematic and Gerber files for the interface board that holds the ItsyBitsy and has a header socket that the Pololu sensor plugs into.

The github repository linked below holds software for a simple demo robot that uses the above sensor interface to follow a line. The robot uses primitive bang-bang control strategy (yeah, it only "barely" follows the, but that's the fault of the robot, not the sensor) and has some menu-driven tools to play with the control parameters. You probably don't want to duplicate the robot, but it does demonstrate how the line sensor interface is used. Review the "device_linesense.py" module (which actually talks to the sensor interface over i2c) and the "mode_followpath.py" module (which actually calls the device_linesense.py module to find the line it follows).

Sorry, there's a lot of other fluff in there that's unrelated to the basic line follower sensor. Note also that some of the CircuitPython code is a little out-dated, but it should at least give an idea of how the interface is used

The interface controller lives at i2c address 0x32; writing a command byte of 0x01 initiates the Pololu calibration routine (which should be performed once whenever the device is powered up); writing a command byte of 0x02 initiates a sensor reading (you should wait for 5 mS before doing a read-register operation to see the result). When initiating an i2c read on the device, expect 7 bytes return buffer. The sixth byte (buffer[5]) will hold a scaled value 0-250 that indicates the estimated position of the line within the sensor window -- a value of 125 indicates centered, 0 suggests the line is fully to the "left" side, 250 suggests its fully to the "right" side.