Introduction: Arduino Line Follower Robot With Pololu QTR-8RC and L293D Motor Driver
Thank you to all that helped me.
Materials used in this project:
A genuine Arduino UNO
DC Gearmotors - https://www.amazon.com/Yosoo-Smart-Robot-Plastic-A..
QTR-8RC Infrared sensor array by Pololu - https://www.pololu.com/product/961
3-cell li-poly battery pack - http://www3.towerhobbies.com/cgi-bin/wti0001p?&I=...
Step 1: Printed a Chassis With Treads
http://www.thingiverse.com/thing:972768 ProtoTank by timmiclark (Thanks for posting!)
https://www.amazon.com/Yosoo-Smart-Robot-Plastic-A...These were the fastest motors I could find in this form factor. In testing I ran it at 7.4v for about three-quarters of the duration of the test runs. I overvolted them, however, at 11.1v for the remainder of testing. Motors were not warm. I feel it is safe to run them at 11.1v if it is not in a pushing or stalling situation. I ran all 4 that the chassis with treads are designed to handle. You can run only 2 motors as well, on any of the 6 cogs (the "wheels" under treads).
http://www3.towerhobbies.com/cgi-bin/wti0001p?&I=L...The batteries were recycled from a 1lb antweight combat bot. They just didn't have quite the power I needed in that platform, but is perfect for this application. I like the ability to put a jumper in the balance plug to easily switch the voltage you are inputting. Testing is a good time to run lower voltages.
My first step in the process of building this line follower was to make a cool frame. I found this already-designed frame on thingiverse. The 'ProtoTank.' I decided to print this. I used a Lulzbot Mini for most of the parts, except for the baseplate frame member, which I had to use an Ultimaker 2 I also have access to.
The body printed fairly easy with colorfabb PLA. The treads were a bit more tricky. Since there are so many, I wanted to print in large batches. I tried that, and had mixed success. I determined that 4 tread pieces at a time was my maximum to not waste material from a sliding piece, and not waste the time on a failed print. 4 pieces at 50% infill, and a .4mm solid top and bottom, with a .4mm shell. I wanted them to be fairly solid, not knowing how much stress turning might have on the latching eyelets of the treads. On the Lulzbot mini, it was about 2.5 hours for each batch of 4 treads. As you can see, that is a lot of hours, not including the failed prints early on.
I used medium-thickness paperclips to latch them together temporarily, and will eventually upgrade to tiny (4-40 or similar) long bolts. I mounted the baseplate to the side panels with 10-24 bolts. I tapped the baseplate, and ran the 10-24's up through it, not needing a nut on the top end.
I then tried to use Flex Seal to give myself some extra traction. So I sanded the PLA of the treads a bit on the outside, and painted some Flex Seal on. I gave it about 24 hours to dry well. I will say it had amazing traction until it started to peel off. That may be because I only did one thick-ish coat, and only on the top flat side. It started coming off, and when it was all together, was leaving black pieces on the test-track, which obviously is not good for a black-line-following robot. It veered off in weird directions. I had to stop that so I sanded it all back off. (Fun times)
Step 2: Wiring in the Motor Driver
Inspired by guibot's tutorial on using the L293D chip. I started by getting the simpler parts done first. Chassis, then getting the motors running autonomously with functions, before moving on to adding the infrared emitter/receiver array. This chip requires 6 digital arduino pins as output to function for 2 motors/2 directions. I recommend using an Arduino Mega 2560.
These were the fastest motors I could find specs for in this form factor. In testing I ran it at 7.4v for about three-quarters of the duration of the test runs, including the video I posted here. I over-volted them, however, at 11.1v for the remainder of testing (as of this writing). Motors were not warm. I feel it is safe to run them at 11.1v if it is not in a pushing or stalling situation. I ran all 4 that the chassis with treads are designed to handle. You can use only 2 motors as well, on any of the 6 cogs (the "wheels" under treads).
The batteries were recycled from a 1lb antweight
combat bot. They just didn't have quite the power I needed in that platform, but is perfect for this application. I like the ability to put a jumper in the balance plug to easily switch the voltage you are inputting. Testing is a good time to run lower voltages.
Step 3: Sensor Array
The sensor board:
This sensor is very attractive and convenient, as it has both emitter and receiver paired and 8-wide.
I used only digital inputs, and since the motor driver took so many of my UNO's pins, I decided to use 5 of the 8 sensors, and so that many of the inputs on the digital side of the board. This did offset my center line just a bit. In hindsight I could have use the analog as well.
Here is the print that holds the sensor array. I only printed the one part that directly cradles the sensor. I actually mounted it underneath the body with Gorilla hot glue, instead of mounting the gravity-held 4-bar linkage system of the source of the file:
Step 4: Code:
I had to download the library for this sensor board to make life easier.
I believe I installed it through the library manager in the Arduino IDE itself. Typing in 'QTR' solicited the search result I was looking for.
Here's my code. I will clean it up (and add comments) for you soon. I am (obviously, when you see it) borrowing heavily from the array's library. There is a calibration sequence of about 10 seconds when you turn the robot's power switch on, or otherwise provide power. During that time, calibration should be performed. That looks like holding your robot's sensor close the the black line and white surrounding and slowly reciprocate across the line a few times. After those 10 second, this code initiated driving forward. I recommend a switch in line with your battery.
We have a be nice policy.
Please be positive and constructive.
What if there is an overlap of tracks for example two lines perpendicular forming a track in some point of the track/ junction? Which path shall the robot take?
That's a well built robot. Can we use normal wheels instead? When we compile the program/sketch it says
'' taking address of temporary array''
(exit status 1
taking address of temporary array")
I'm new to this. Can you please reply to my query?