Let's Make Robots!

War Pig - Line Follower Robot

Line follower

Hello,
I'm proud to show you my first robot.
Its name is "War Pig" and it's a line follower.

I'll give you some technical specifications about the project.

Let's start from the electronic schematic.

The core of the circuit is the PIC18F4331. I know it's definitely over sized for the project, but since it came as a free sample, I didn't loose time to find a cheaper one.

Ground color is detected through two photoresistor. The signal is read in the middle of the serie between a 2-20k photoresistor and a 10k resistor: with this configuration the difference of voltage read from the adc is quite high, and can be easily treated like a digital input.

Motors are actioned by the L293D driver. PWM signals move the enable pins and set the velocity of the wheels through a simple algorithm.

Power supply is made with a 9V battery regulated by a standard 7805 voltage regulator. This is the worst part of the project, since I used the same power supply for the microcontroller and the project. I had some difficulties in avoiding the PIC to restart every time a motor was actioned and I finally did it putting a lot of decoupling capacitors near to the microcontroller.

I put the ICSP connector in the back in order to be able to program the robot without removing the PIC from the socket. Very useful idea.

White LEDS allow the robot to "see" the line in a dark room.

Structure is made with Plexiglas and long screws. It's light and simple but it took me a long time to make the several holes in it.

Here are some pictures:

02.jpg

04.jpg

06.jpg

Bill of Materials:
PIC18F4331 Microcontroller – FREESAMPLE
Resistors & Capacitors – €5 (approx.)
Sockets, Connectors & Wires - €3 (approx.)
2 * White Led - €0.80 ea.
2* 2-20k Photoresistors - €0.80 ea.
L293D - €2.5
MC7805 – 1€
9V rechargable battery - €4
2 * Wheels - €3 both
2 * DC Motors - €14 both
Ballcaster - €3.5
Plexiglas - €2.50
Screws - €0.50

Bill of Time:
Construction – 6 hours
Soldering – 6 hours
Programming – 4 hours
Prototyping the circuit on the breadboard – 10 hours

Personal comments:

+ it works
+ it's cheap
+ photodetectors work well even if not well shielded

- bad battery last
- bad power management
- dc motors are not very precise
- quite slow


Please, please post your comments here or on youtube and feel free to ask for any further information about the robot.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

exactly!

use the bill of materials and the schematic in order to complete the circuit.

algorithm is really that simple! you can do better if you are fond of automation and numeric control. i am not.

 

by the way... it's nice to found interest in my work after something like 9 months! thank you!

Just to know, where did you get the plexyglass? which type is it ?

In a normal tool shop... same place where I bought screws...

You buy it in medium size plates: 50*50 m2 costs about €3.

You can cut it simply engraving it with a cutter and splitting it pulling on the edge of the table.

 

:) 

That's a really smooth running robot.  What kind of code did you program it in (BASIC, C, Assembly?) and would you mind posting it?

I've also been dying to know more about that motor assembly.  I was considering buying that set last night from Pololu but don't know the kind of speed, torque and noise they generate.  I especially would like to know how they compare to these:

http://www.solarbotics.com/products/gm9/

Which gearing setup/ratio did you use?  (sorry for all the questions)

Great robot!

Here we go!

 As you can see, it's written in C. I'm not very sure about the comments... I mean sometimes what is called "left" could be "right", but that is the code that works. It's quite short and linear, so I don't think you will have difficulties with it, otherwise, plase ask!

 Motor set is nice. Quite simple to assemble and can run quite fast. Indeed I used the highest gear ratio possible (344.2:1) and I slowed it down further with the PWM control. I don't now speed and torque but, come on, that's a light set... If you put something too heavy on, it will break in peaces before stopping :D

 Are you talking about electrical or sound noise? First should be huge, but uninportant for the kind of application... second is low, something like an electric toy...

 I like the motor you suggested and I was in dubt with it before buying mine. I could try that with my next motor!

 

By the way, Thank You! 

Great info, thanks.  I don't completely understand what torque means but use it to compare 2 motors based on their RPM and torque.  But ultimately, like you said, it doesn't matter as long as it pushes your robot.

I really like that the grearbox gives you the full drive train and body to build from -- no need to stick the individual motors to something.

The C code looks pretty straight forward.  Since I'm new to microcontrollers I'm trying to experiment with PicAxe BASIC, Adruino and now straight PIC with C.  Did you program it with a normal programmer or do some sort of in circuit programming?  I'm still trying to figure out how all this stuff works. :)

 Look at the ICSP (in circuit serial programming) part of the schematic. You can also see the connector in the last picture. That allows me to directly connect my PIC programmer to the robot: five wires are required. In particular I have the PickIT 2 (picture) which has a USB cable to send data from the PC to the programmer.

 I used CSS PIC-C Compiler to generate the .hex (needed to load the controller) file from the .c.

 

You can get the samples from Microchip Technologies, you can get 5 at a time, twice a month and they pay the postage. Sweet. There is much more detail about this in BaseOverApex's Microchip PICs - Getting Started thread.

Facinating!

 

 Maybe you could ad an extra photoresistor to detect the amount of light in the room, making the robot able to turn on the white LED's only when the room is actually dark. I gues that would propably add some extra life time to the battary...(?)

 

 Also,  you say you got the PIC18F4331 as a free sample - that sounds cool (geting something for free always does ;-)  ). I just can't stop my self from asking: how, where and why did you get it for free...?

 

/Dan.