Need help/advice on a line following bot

Hey all, I am a student at ITT in my 7th (of 8) quarter and am wanting to build a line follower for my final project. I think I have figured out my parts list so far. One stipulation is we have to use the schools 8051 board and use assembly for code. So far parts wise this is what I think I will use.
motor #1585 x2
80mmx10mm wheels #1430
front caster #66
motor driver #tb6612fng
sensor array #961

I am going to build my chassis out of lexan.
Am I going in the right direction or am I way off line.
Thanks all for any input.


I think you can make those parts work, but you might be going bigger than you need to, and your motors could potentially be pushing the abilities of the motor driver you have selected. I would suggest using our 50:1 HP micro metal gearmotors at 6 V with our 42x19mm wheels. This will give you a top speed that is almost three times as fast as the top speed you could get with your selected 25D motors and 80mm wheels with less potential to exceed the capabilities of the TB6612 driver. Note that these motors still have stall currents above what the TB6612 can deliver continuously, so you should take care not to stall them for any prolonged period of time if you use them, or you should go with a more powerful driver if you anticipate such stalling.

The sensor array version you’ve chosen will work (and it is the version we slightly prefer), but note that it might be more difficult to read in assembly than the A (analog) version since it requires generating an output pulse and then timing the resulting voltage decay.

- Ben

Im not so concerned about speed. Next quarter I plan to use the same bot but modified for another class project thats why Im going bigger on the motors. I will look into the parts you have suggested. I think the biggest hurdle to overcome is the programming for this beast. It needs to be in Assembly language which seems to be the least used on the 'net. I have seen plenty of examples of C and other program languages but not much is Assembly.

Assembly will definitely make things harder. At least a basic PID algorithm for following a line is pretty simple, and hopefully the rest of your robot will be about interfacing with existing hardware peripherals on your microcontroller to do timing and generate PWMs.

- Ben

Back to the hardware aspect, the motors I am looking at (1585) say they have a stall current of 2.2A. The driver I am looking at has a peak current of 3A per channel. Are you saying that the motor stall current is too close to the peak current of the driver? I suppose I could go with a different motor but I am building a medium size bot. It will be about 12" x 10".
Thanks again for all the help.


I’m curious, what 8051 assembler will you be using?

If you find example code in C, you could compile it with a C compiler (such as SDCC) and then look at the generated assembly. This will help you learn assembly.


We use proview 32 at school. I have it installed on one of my pcs at home too. I have heard it will not run on 64 bit machines.

If you were to change motor direction from full-speed forward to full-speed reverse, the motor would briefly draw nearly twice the stall current, which would exceed the 3 A rating, so you would need to be careful not to let your program do something like this. I am also concerned by how much the stall current exceeds the driver’s continuous output current. In general, getting a driver with a continuous output current that exceeds the stall current means you don’t have to be as careful about how you drive your motors (it might be nice if your driver doesn’t go into thermal shutdown if your bot accidentally drives into a wall and stalls).

In short, I think you can make the TB6612 work with those motors, but you aren’t leaving yourself much margin for error (unless get that margin back by limiting your maximum duty cycle to something like 50%, which might be ok if you are happy making your line follower slow). For example, if your algorithm is not smooth, your motors could constantly be accelerating, which could put your average current draw much closer to the stall current and strain the drivers.

You could always try it first with one TB6612 driver and upgrade later to a more powerful driver, such as the dual MC33926 driver, if you find you don’t quite have the power you want. Another option is to use both channels of the TB6612 driver in parallel to drive a single motor, which would give you a continuous current rating of 2 A and a peak current rating of 6 A. For this solution, you would need two TB6612 drivers, one for each motor.

- Ben

Well, I will say that I like the price of the 6612 better. :wink:
It would even be cheaper to use 2 if I had to over the other driver you suggested.

Ok, I had just ordered the parts I had listed above including a second motor driver just in case I need to run them in parallel. Now to work on programming and wait for the parts to get to Ohio. Thanks all for the input and Im sure there will be more questions to come.

Thanks for the update (and the order!), and good luck with your project. I look forward to hearing how it turns out.

- Ben

Ok, We got the bot up and running but I have an issue, what started out as a line following bot turned into a type of edge detector. At school We used a black floor and white poster board. The bot will track the white edge of the poster board very well but it seems like the sensors are working backwards somehow. The functions will get us through this school assignment but Im kind of wondering where we went wrong.

What do you mean when you say “the sensors are working backwards”? What microcontroller board are you using to read the sensors?

- Ben

Well, maybe I worded that wrong, but we are working on the program a bit to try to correct the issue we are experiencing. Anyway, the microcontroller is an 8051. I am thinking that we are experiencing difficulties since we have to write the program in Assembly. Next quarter for our Capstone project we are going to use the same bot but with added features and will be able to use C program.

hi ben i am mmilo31’s partner on his line follower.the problem we are having is that (for assembly at least) we have to write a 1 to each bit of the port in order to make it an input to read the sensor,well the mcu cant read the sensor correctly because it already has the high bit thx to writing a 1 to it in the first place…n what mmilo31 means by its working backwards is instead of the sensors running over a white surface and acting accordingly when they go over a black surface,the only way they will work with the program we have is if they are over a glossy black surface and one of the side sensors(we dubbed for sharp left and sharp right turns) is over a white surface,like a piece of white posterboard, the bot will actually follow the edge of the posterboard to keep that one sensor low…any thoughts on this?i have attached a copy of the program we wrote to run the bot so if you know the language can u tell us if u see any errors?thanks
Final Project Program8.4.rtf (8.57 KB)

I don’t understand what you mean by this, but it sounds like you either do not fully understand how to use the digital I/O of your microcontroller or you are doing something wrong. Unfortunately, I don’t have time to try to understand and debug your entire assembly program. Have you tried simplifying to the point where you are just trying to read one sensor to make sure that you are getting reasonable results?

- Ben

well we are still new to the microcontroller so thats always a possibility…lol but yeah using the program i uploaded on the workbench the sensors will output 5V(or close to it) when over a black surface and 0V or close to it when over a white surface and it refreshes pretty quickly but when it was on our course(white posterboard with black tape) it didnt react the same…

I think maybe you don’t understand how the sensors you are using work. Just to be clear, do you have the QTR-8RC (as opposed to the QTR-8A)? If so, you need to measure the discharge time of the sensor to determine the reflectance of the surface. The sensor output will always start out high and will then drop over time until eventually your microcontroller will read it as low. When there is high reflectance (i.e. close to a white surface), the output voltage will drop very quickly; when there is low reflectance (i.e. far from a surface or near a black surface), the output voltage will drop slowly.

You can get a lot of information by timing the sensor’s output pulse, but that might be a bit difficult for you to do in assembly, especially if you are new to microcontrollers. A simpler approach would be charge the sensor’s capacitor, delay for a fixed time, and then read the output to see if it is high or low. If you pick the delay time right, you will measure low when over white and high when over black.

- Ben