War Pig - Line Follower Robot

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:



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.

Line follower

  • Actuators / output devices: DC Motors
  • Control method: autonomous
  • CPU: PIC18F4331
  • Power source: 9v battery
  • Programming language: C
  • Sensors / input devices: Photoresistors
  • Target environment: White ground

This is a companion discussion topic for the original entry at https://community.robotshop.com/robots/show/war-pig-line-follower-robot

Facinating! Maybe you

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 :wink: ). I just can’t stop my self from asking: how, where and why did you get it for free…?

 

/Dan.

PIC Samples

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.

Thank you!I like the idea of

Thank you!

I like the idea of an extra sensor to detect room enlightment… but I don’t think I will get a big improvement in battery performances… LED absorb something like 10mA, while motors absorbs some hundereds… In the best case I would get a 10% last improvement.

 

Here you can find PIC freesamples: http://sample.microchip.com/

You should register with a valid email address (such as your college or company domain) and you will be able to order almost every kind of microcontroller produced by microchip. Just don’abuse of that service :stuck_out_tongue:

 

 

That’s a really smooth

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!

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

PS:

PS: https://www.robotshop.com/letsmakerobots/node/18

/ Fritsl

In a normal tool shop…

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.

 

:slight_smile:

Here we go! As you can see,

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 :smiley:

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

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. :slight_smile:

** Look at the ICSP (in**

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.

 

help me

Hwy man you got a nice line follower there… but can you help me with these:

what exactly we need to build this robot

and the algorithm of the picaxe… please

 

Bill of Materials: Tells you

Bill of Materials: Tells you what you need to make the robot.

As far as an algorithm go straight. If one of the two sensors detects a black line turn left or right slightly depending on which sensor was detecting the line. Line detectors have a pretty easy algorithm. Now if you want all of the code thats a different story. If you haven’t made a robot yet I suggest the START HERE link at the top of the page. That project is laid out in detail so you can duplicate it easily.

exactly!use the bill of

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!

you’re welcome… you’re

you’re welcome… you’re robot is really nice… and thanks for the information you gave…

 

but should I use the same
but should I use the same picaxe you used, and the same sensor you used, or another one??

but you didn’t mention the

but you didn’t mention the type of sensors did you use?

sensor used are

sensors used are photoresistors.

there is no picaxe in it. I used the PIC18F4331 (4431 is good too) microcontroller from microchip, as you can see both in the schematic and in the bill of materials.

Nice Robot

Hi.

I like your design and I am thinking about building one for  my college project but I have never built one before.

I am in the process of writing an evaluation matrix and would like to know how difficult you found it on a scale of 1-5.

Thank you.

Hello, I love it, plus the

Hello, I love it, plus the Black Sabbath song WarPigs, i’m a big fan of them, absolutley cool bot, i want to build my self a one, to join the war pigs army, can i ask for the code and the schematic please :slight_smile: