View Feed
group-icon
Coffee Room
Discuss anything here - everything that you wish to discuss with fellow engineers.
12933 Members
Join this group to post and comment.
Robo-G!RL
Robo-G!RL • Oct 27, 2007

Line Follower Competition..I don't know how to start

Dear CEans,
I'm a student in the field of computer engineering. I'm currently taking an introduction course to robotics and asked to "design and build a mobile device that will follow an optical path on a track in the shortest amount of time while transporting one ping-pong ball."

It is the same as the IEEE line follower competition; however where doing it in our collegeπŸ˜’. The rules and regulations of the contest can be found here https://roboti.cs.siue.edu/competitions/ieeelinefollower/2004/IEEE2004.pdf

I'm wondering if you can help me with that because I'm totaly new to robotics πŸ˜”and don't know what hardware is needed for that project besides the optical sensors (such as LDRs)and how to build the car in such way to achieve high speedπŸ˜•!!

Thanks in advance.

]Robo G!RL[
Robo-G!RL
Robo-G!RL • Oct 28, 2007
15 views but no replys.😭

I really need your help CEans...pleaseπŸ˜”
Elisa
Elisa • Oct 28, 2007
Line following robot has been discussed on forums. Did you try searching for the topic?
xheavenlyx
xheavenlyx • Oct 29, 2007
RoboG, the first thing to do is search google for any information about this topic. Then form a rough idea in your head.

Divide into sections and start working.

Hardware (Sensors, Actuators - Motors, Connections, Microcontroller)
Software (Program for the Microcontroller etc)
Power Source.
Hey there Robo-Girl,
xheavenlyx is right about searching on google. You'll get lots of different ideas there! I recently finished a line following competition, but a simpler one compared to the one you are doing.

For the microcontroller, our group used a PIC16F877a micocontroller. I believe this is under $10. There should be schematics online available on what other components needed to use with this uC. If you are interested, I can upload the one that our seniors gave us for the competition. For example, you will need a voltage regulator, a crystal (for the frequency), capacitors, etc. You will need to know C programming to code the uC.. should be no problem since you are taking Computer Engineering πŸ˜‰ You will also need software to upload the code to the chip. Make sure you have a serial cable ready at hand.

If you dont want to use the uC, you can use Voltage comparators instead. Google them up to find how to use 'em πŸ˜€

For the motors, you can use a Tamiya double-gearbox. You can get it from any Tamiya toy shop. The one we used was:
https://www.tamiyausa.com/product/item.php?product-id=70168
Dont forget to get the matching wheels! You have an option of different gear ratios: 12.7: 1, 38.2:1, 114.7:1, 344.2:1. The smaller the ratio, that faster the wheel turns.. but it also produces little torque power (not good if your robot is kinda heavy). Don't forget, if you make your robot move TOO fast, it can overshoot the black line that it's tracking. We used the 38.2:1 ratio.

To use the motors, you need a motor driver. The L293 IC should be suitable enough πŸ˜€ By the way, each motor powers a wheel. If you instruct one motor to turn one direction and the other motor to turn the other direction, you'll make the robot steer, like a tank.

I suggest you use phototransistors as the sensors.. I THINK its more accurate than LDRs. We had some probs when we used LDRs to detect the 0.5inch black line. If you want to use phototransistors, use Infrared LEDs with it.

Our power source was basically a 9V battery to power the sensors and uC, and also a couple of 1.5V AA batteries (4 of them) in series to power the motor. But they drain real fast, so maybe you should get rechargable AA batteries.

Also, make sure you have these tools in hand with you: Multimeter (you can borrow from lab maybe), soldering gun, lots of solder flux, screwdriver, lots of jumper wires, wire cutter, pincer, small plier. Also get your hands on a prototyping board so you can test some circuits out.

Okay, thats it for now. Feel free to post again if you need more info. In the meantime, me and some friends plan to make a robot boat soon *grin*
Kaustubh Katdare
Kaustubh Katdare • Oct 31, 2007
Ash! Buddy! How about sharing pictures of your team & the robot that you built? πŸ˜€

What say?

-The Big K-
Robo-G!RL
Robo-G!RL • Oct 31, 2007
thanks all for replyingπŸ˜€
ash..Thanx buddy..you realy helped me..😁
I had rough idea about the project but I thought it would be better if I got some other ideas..anyways, I have worked with microcontrollers before and programmed them using C but the question is how to choose the uC?πŸ˜• Can I use any or it should have some specifications?!! for example..as I guess; I will need 4 out ports to control each of the 4 motors, and will need # of in ports equall to the # of LDRs used..right?!!

If you are interested, I can upload the one that our seniors gave us for the competition.
yes please. I will be greatful.

Ash! Buddy! How about sharing pictures of your team & the robot that you built? :smile:
yeah..please. It will be GREAT 😎

]Robo G!RL[
The_Big_K
Ash! Buddy! How about sharing pictures of your team & the robot that you built? πŸ˜€
Unfortunately, we didnt take any pics of us or robot πŸ˜” The robot is partially taken apart now, cause a group of friends need to use the PCB board with its microcontroller for another project of theirs. So now its just wires jutting out, haha. Hopefully when their project is done after a few weeks, i'll assemble it together to take pic. But my group plans to upgrade the line follower to its next version if we have time.

Robo Girl, I'll upload the schematics after next week. At the moment I have final exams so I'm quite busy! Regarding the output, you can just use 2 motors for the rear wheels. They'll act as the steering too. To support the front of your robot you can use an omniwheel, sorta like the ones they use in supermarket trolleys or the chairs that have wheels on them. Also, you are correct about the number of input ports for the sensors. The PIC16F877a has 8 analog pins you can use as inputs, so that means you can have up to 8 LDRs! However, you can also use a number of other ports for digital input. We had planned to put collision detectors on our robot too, which we would have placed at a couple of digital I/O pins (by using a pull-up configuration if anyone was wondering).

Please refer to this link for the datasheet πŸ˜€ The version we used was the 40 pin PDIP.
https://ww1.microchip.com/downloads/en/DeviceDoc/39582b.pdf

Alrighty, will keep you updated next week. Good luck with the robot!
preeste
preeste • Nov 1, 2007
hi ash

i am also very intersted to see the schematics and code to your pic16f877 line follower....could you please post it as soon as possible? desperatly need them in like 2 days if thats possible?
Robo-G!RL
Robo-G!RL • Nov 2, 2007
ok ash..
Good luck with your exams..πŸ˜€

I will be reading more about the uC and try to get the components.

I'll keep you updated.
Ashraf HZ
Ashraf HZ • Nov 8, 2007
Hey, im back! Just done with exams. Sucks like hell πŸ˜” Anywayz, here are the circuits schematics. Many thanks to my seniors at uni! By the way, sorry Preeste for the delay. It was unavoidable.

[​IMG]

What you see is how the PIC is connected to the rest of the circuit. The top left circuit contains a 5V voltage regulator (7805), in which a 9V battery is connected to. The switch is a SPDT slide switch, but im pretty sure any SPST switch would work. That +5V voltage point/node is connected to the rest of the circuits. If you want, add a small heatsink to the 7805 as it gets hot. Theres a hole at the top which you can screw a mini heatsink to the 7805. I didnt know the use of that hole until I saw my seniors line followers with heatsinks, and even mini fans! The circuit on the right shows a hex inverter with a RS232 serial port. You need these to send the program to the PIC from computer if you plan to connect your robot directly to the computer for programming.

I hope the pin connections are clear. You'll notice that you'll need a 20MHz crystal oscillator connected to pins 13 and 15 as shown. The 0.1uF, 10pF capacitors are ceramic type (looks orangy and flat shaped). Also, the PIN numbers are not in order! I guess its done like that for clarity. Make sure you refer to the PIC datasheet, or simply count the pins properly when you connect the circuit. For the ceramic caps used with the 20MHz crystal, our seniors recommended 18pF.

This is the L293 motor circuit that we used:

[​IMG]
There are many versions available on the net, all with their different advantages and disadvantages. This version is simple, but works well. It uses ceramic capacitors instead of diodes for the back EMF and line noise protection. I read somewhere on the net about reducing the line noise more by adding more capacitors, but havent figured out where to add them yet πŸ˜› The motors are standard DC Motors.. which should be supplied with the Tamiya gearbox anyway (if you are ordering it). The L293 is powered by the 5V from the PIC circuit at pin 16. The 6Vdc battery that powers the motors is connected through the L293 at pin 8. I think you can deliver up to 12V for the motors.. but maybe 10V should be the limit, just in case! I've added additional notes in the circuit diagram, be sure to read them! As with the PIC pin layout, the L293 pins are also not in order in the diagram.

Test the circuits out on a prototype/breadboard first before you solder them on a PCB board. Our group did the mistake of immediately soldering them on, and had to keep unsoldering and resoldering components when troubleshooting the errors. Use pin sockets for the PIC (40 pin), hex inverter (14 pin) and L293 (16 pin) so you can remove them easily and use them again for other circuits/projects. To make your life a lot more easier, use connectors too (like the ones used to connect the audio of CD player to the motherboard of a computer) for connecting between the motors, and the light sensors, to the main PIC circuit/motor circuit. Be liberal in the number of connectors used. This way you can take things out modular style without the mess and/or restriction of wires connecting to them.

Anywayz, if you two (Robo_girl and preeste) will go ahead with this circuit, I can later explain how to program the PIC once you get started with the hardware. Please note that im not an expert, but I will try my best to help with whatever I know πŸ˜€ Building robots is a journey, you'll learn so many things! I've only just done one robot, but it was an interesting experience nonetheless.

If you wish to use other types of circuits, (or find out more about info that can help you) please look through these great links! There are many ways to do a line following circuit, such as using other models of PIC microcontrollers, AVR microcontrollers (rival of the PIC), simple voltage comparators etc.

https://www.robotroom.com/ <- Excellent resources. He has done about 3 line followers amongst others

https://www.kmitl.ac.th/~kswichit%20/ROBOT/Robo5.html <- Priyank's AVR Line follower. Download the PDF!! Its loaded with instructions, diagrams, and even component costs. He's from K. J. Somaiya College of Engineering
Mumbai, India.

https://www.wrighthobbies.net/guides/index.htm <- Excellent resources as well. Scroll down to read about sensors and how to assemble the Tamiya gearbox.

https://www.kmitl.ac.th/~kswichit/LFrobot/LFrobot.htm <- If you want to use phototrans with voltage comparators, check Plermjai's line follower here.

https://www.micahcarrick.com/05-27-2006/failurebot-line-following-robot.html <- Humourously named FailureBot5, Micah uses an AVR uC and an interesting method of line detecting. Its worth checking out. His previous versions had the PIC's.

https://www.diylive.net/index.php/2005/12/13/diy-line-following-robot2/ <- Line follower using the PIC 12C672. Good instructions! He uses assembly language, but should be easy to convert to C.

Alrite, good luck with it. Take time to study the circuits carefully. Ask me any questions when you have any doubts. I'll try to get pics of the line follower soon when my friends have done using the PIC circuit. Peace out! πŸ˜‰
Robo-G!RL
Robo-G!RL • Nov 10, 2007
Hey, im back! Just done with exams. Sucks like hell :sad:
Welcome back buddy.. I'm sorry about your examz:sad:

Thanks Ash for the schematics. i'm studying them now in order to help in the design that i'm trying to reach.

I got a qusetion about the shape that I have to put the sensors like.
In our project, beside detecting the line to follow we got to detect a shape on the line that tells us to do an action such as turning right/left (for example if we see a triangle pointing to the right we must turn right). We have 3 shapes; triangle pointing to the right ,triangle pointing to the left & a hexagon (to stop). so what do you thing is the best shape for sensors and how many LDRs do I need? πŸ˜•


]Robo G!RL[
silverscorpion
silverscorpion • Nov 10, 2007
what do you thing is the best shape for sensors and how many LDRs do I need?
hello robo-girl,
First you must optimize the positioning of the sensors in the bot. For that you need the dimension constraints of the bot and that of the line to be followed. And shape recognition like recognizing triangles and hexagons also depend on the positioning of the sensors. You just provide the dimensions of the bot and the line so that i might try to help you out...
Hey Silverscorpion, good to see ya πŸ˜‰

From the PDF she gave:
https://roboti.cs.siue.edu/competitions/ieeelinefollower/2004/IEEE2004.pdf

The line is half-inch thick, and the shapes described at the end. Hopefully Robo-girl can reply soon about the bot dimensions. From the top of my head, I'm guessing if you shape the LDRs as a square (8 LDRs, with a blank in the middle of the square, since you only have 8 analog input ports) you can detect the different shapes easily πŸ˜€

Something like this:
o o o
o X o
o o o

o = LDR
X = empty
Robo-G!RL
Robo-G!RL • Nov 10, 2007
Hello CEans,
Sorry I forgot to mention the dimentions 😳.
The shapes must fit in 2"x2" square & the line has a width of 1/2".
you can detect the different shapes easily :smile:

Something like this:
o o o
o X o
o o o

o = LDR
X = empty
How do you suggest to compare the values from the sensors and decide what shape did I pass on?!!

I thought about using 4 LDRs in the following fashion
o o
X
o o
o = LDR
X = empty

NOTE: X must be in the center, but I don't know how to fix it πŸ˜”
for simlifying, I'll name the LDRs as follows:
1 2
X​
3 4
NOTE: X must be in the center, but I don't know how to fix it πŸ˜”
and for Black=1, White=0
and I'll have a table like this
1 2 3 4
-------------
1 0 1 0 Turn Right (means I have a triangle pointing to the right)
0 1 0 1 Turn Left
0 0 0 0 Stop

Did you get my ideaπŸ˜’ If you need more clarification just let me know, please.

What do you think about it?!!

]Robo G!RL[
preeste
preeste • Nov 12, 2007
hey Ash
Just wanted to thank you a million for putting up your schematics...you have no idea what a big help you have been. Just wanted to say thank you very much πŸ˜€
preeste
preeste • Nov 12, 2007
hey ash.....do you think you could put up your schematic showing the conections to from the photo-transistors, LEDS to the microcontroller? what type of photo-transistors did you use? do you think you could also post your c-code? thanks a lot again for your help....i cant thank you enough!
πŸ˜€
preeste
preeste • Nov 14, 2007
help please!
preeste
preeste • Nov 14, 2007
hey ash....i need to know some more details about your line follower.....how many leds and phototransistors did you use? did you use the whole concept of differential drive to move your robot(ie did you use only two wheels each controlled by a geared motor?)....help!

thanks in advance
πŸ˜€
Robo-G!RL
1 2
X​
3 4
NOTE: X must be in the center, but I don't know how to fix it πŸ˜”
and for Black=1, White=0
and I'll have a table like this
1 2 3 4
-------------
1 0 1 0 Turn Right (means I have a triangle pointing to the right)
0 1 0 1 Turn Left
0 0 0 0 Stop
Shouldn't stop be 1 1 1 1? Since you'll be on top of the black hexagon right. Anywayz, you didnt take into account about actually following the line. If the robot was following the line and it detects 1 0 1 0, it would get confused whether its on the triangle pointing to the right, or whether the left sensors are detecting the line itself. Do you understand my point? Thats why I thought of using 8 of them so it can differentiate from a shape and a line entirely. I modified the shape a little. For example:


 
1 2 3
 4 5
6 7 8
1 2 3 4 5 6 7 8
--------------
1 0 0 1 1 1 0 0 Triangle pointing right
0 0 1 1 1 0 0 1 Triangle pointing left
0 1 0 1 1 0 1 0 Hexagon (stop)

Sensors 4 & 5 are a little indented inwards to the center so that the pointed part of the triangle can be detected (since its a 2" equilateral triangle). Also, you could just use sensor 4 & 5 to detect the line too. Lots of possibilities! πŸ˜€

In line of what silverscorpion said about optimizing the position of the sensors, the distance from the front sensors to the back sensors whould be the length of the triangle (2"). But, using 8 sensors though goes against my "keep it simple" philosophy. If you do plan to use a voltage divider technique for all 8, thats alot of wiring.. plus sensor readings could get a little saturated since all are sharing a common voltage and ground. If you do choose this route of 8 sensors, try it out first on a prototype board. Try checking out the links I posted about different sensor circuit configurations! The one using the demultiplexer could prove handy.

Hey preeste, your welcome! Anyway, I did not use phototransistors on my robot, perhaps only in the 2nd version I plan to use them. I used 3 LEDs and 3 LDRs. I described it here:
https://www.crazyengineers.com/forum/showthread.php?t=1316

I dont think you'll suffer the same problem about the incorrect readings, as long as you properly isolate the LEDs and sensors from each other and also solder the components carefully. Check out the links I posted before for phototransistor sensor layouts.. I hope its there somewhere πŸ˜›

The structure of the code is pretty basic, but if your competition layout has many conditions, the hard thing is to optimize it as the PIC has limited memory. I'll give you some head start. If you want to read a value from a sensor connected to pin A0 and print it out to the Bootloader software:

 
#include <16f877a.h>
#device adc=8
#use delay(clock=20000000) //oscilator frequency
#fuses hs,noprotect,nowdt,nolvp
#use rs232(baud=56000,xmit=PIN_C6,rcv=PIN_C7,parity=N)
main()
{
 int value;
  setup_port_a(ALL_ANALOG);
 setup_adc(ADC_CLOCK_INTERNAL);
 do
 {
  set_adc_channel(0);
  value=read_adc();
  delay_ms(300);
  printf("\nan0:%u",value);
 }while(1);
}
That code sets port A as analog and gets values from the sensor connected to it. If you want to set other ports like Port B as digital I/0, then its like:

 
main()
{
set_tris_b(0)//set all pins of port B as input
set_tris_b(1)// set all pins of port B as output
...
ouput_high(PIN_B0); //output high on pin B0
Also, I did use a differential drive to move the robot. If you look at the schematic, we only used 2 motors.. one for the right and one for the left. You'd have to refer to the L293 datasheet for more info. Please try to do some research for the coding on google. I can't give ALL of it just like that πŸ˜› If you get stuck, then just post what you've found and then we CEans can help you through understanding it!
mahul
mahul • Nov 15, 2007
i dunno if u guys wd b intereested but my photo is that of a line tracker that i built.........n yes i programmed it in assembly language.....check my display image
preeste
preeste • Nov 15, 2007
hey ash....i could not find the post you put up regarding phototransistor sensor layouts....further more i took a look at failurebot5...but the diagrams make no sense in that the labelling is not done properly...can you help me with that....take a look at the sensor board circuit...if i had to built that same circuit, where would the points labelled LED1,2,3,4 etc on the jumper be connected to the pic16f877? would those connections go directly to the analogue pins of the pic? what about the sensor out pin on the jumper? where is that supposed to be connected to? please help
preeste
preeste • Nov 15, 2007
hey mahul...yes i am very interested...did you use the pic16f877? and did you use phototransistors?
preeste
preeste • Nov 15, 2007
hey Mahul....very interested!!! did u use pic16f877? and what about your sensor? did you use phototransistors? let me know...thanks
mahul
mahul • Nov 15, 2007
no i hv used very crude and common place things.......i used ldrs(6 of them) and used the 8051 microcontroller(remember i programmed in assembly).......i also used comparators.....it cd hv been more accurate with more sophisticated hardware bt i did it with very little cash.....that's why
Kaustubh Katdare
Kaustubh Katdare • Nov 15, 2007
Mahul,

How about uploading your pictures to divshare or flickr and posting the link here? (along with the img tag)

-The Big K-
preeste
preeste • Nov 15, 2007
thats sounds cool mahal...you should definetly post your image up
preeste
preeste • Nov 15, 2007
hey ash...you mentioned the website with failurebot5 so i went there...as i posted earlier i need some help to make sense of the schematics on that website.....furthermore have you by any chance looked at the link on that page that allows you to download all source code and schematics? i tried to download it but i can only download part of that file....do you happen to have a copy of those files? if you do could you please post it under this forum? thanks a lot man...and sorry for being such a huge bother! thanks
mahul
mahul • Nov 15, 2007
hey guys if u want to view the pics visit my webpage @ www.mahul.phpnet.us/Album/albumprojects.html
But mind u these images r actually completely non-technical.Contact me if u want any technical support
preeste
preeste • Nov 20, 2007
Hi Ash

Look i have never worked with microcontrollers before .....this line follower i am building is just for fun....not for any project or anything like that...i have the hardware completely setup....now what i need is help with the coding?o

i have three photosensors....now if my vehicle is perfectly over the path only the middle photosensor is over the line and the other two sensors sort of are at the outer edges of the black path over the white area. I have connected the photosensors to A1,A0 and A2 and am going to use adc. but what should i do to initially sense the light in the area....please help me?
preeste
preeste • Nov 20, 2007
How do i move between reading the analog inputs to the motor control code....i mean in terms of coding.....? the coding to read the analog inputs has been done lets say then how do i move to moving the vehicle? please help???
xheavenlyx
xheavenlyx • Nov 20, 2007
ash, sorry no one read your technical piece, which is good. They all seem tobe very very bz in their own thing.

Well, Preeste no one can help you like that, if you want to understand the circuit you gotta READ, READ, REAd and read. If you know someone there who has done something similar ask them, professor, freinds, friends of friends etc etc.

Then Plan, tihnk of what you want, what you expect from your bot, then write it down, research all PC's you might use, the sensors depending on your requirements and then start something.
preeste
preeste • Nov 21, 2007
hey .....there is no one i know who can help me with this....what i need is help understanding how the ADC of the pic works....once i understand that all my problems will be sorted!
Sorry for the timeout. Ok, the ADC of the uC is the analog-to-digital converter pin. The sensor circuit for the Failure Bot 5 is pretty interesting, since he uses only one ADC input. All the phototransistors are connected together in a pull up fashion, I believe. The LEDs are switched on one at a time. At the moment, the current from the supply goes to the ADC pin, so it gives it a 1 logic. Lets say one of the LED is on the line, and it's respective phototrans (the one opposite the LED) detects the reflection, the current goes through the Collector pin of the phototrans and thus the ground, instead of the ADC pin. The ADC pin is now logic 0. The LED's are switched on one by one quickly.. sorta like a scanner.

Anywayz, prestee, since you already have a sensor circuit, I'll guide on the coding. First of all, you need to find the threshold for each sensor.. this means the values of which the sensors would detect the line. The ADC input has a value between 0 to 255. This scales to the level of voltage across the sensor. Are you using the Bootloader software? If you are, you should apply the code I gave earlier to output the values, but this time for A1 and A2 as well. eg..

 
  set_adc_channel(0);
  value=read_adc();
  delay_ms(300);
  set_adc_channel(1);
  value1=read_adc();
  delay_ms(300);
  set_adc_channel(2);
  value2=read_adc();
  delay_ms(300);
  printf("\nan0:%u  an1:%u  an2:%u",value,value1,value2);
 
You'll see three values outputted at the software after each while loop. If the line was under the middle sensor, the reading would be like this:

an0:87  an1:121  an2:85
Place each sensor over the line and record the readings you get. The threshold for each sensor is the average between the lowest and the highest reading. Only after getting these threshold values you can instruct the motors.

Good luck
preeste
preeste • Nov 27, 2007
hey Ash.....

i actually managed to figure out how to do the programming for the sensors(the threshold etc etc) and i have sorted the ADC part of it. What i am struggling with now is the control of the motor. I used the setup you posted for the control of my motor with my motors. The problem is that while i was doing research on the l293d h-bridge i came across the following page:https://www.me.umn.edu/courses/me2011/robot/technotes/L293/L293.html

Now i wanted to know how to do the coding to move the vehicle forward, to stop it, turn it to the right and to the left.
this page shows the logic that needs to be applied to the h-bridge in order to stop the motor, move a motor to the right and also to the left. But nowhere does it mention what logic to apply to move a motor straight ahead. This is really confusing me cause as i said earlier i am using differential drive. My understanding of this is that if i want to turn the line follower to the left, i should stop the left motor and cause the right motor to move forward and similarly to move it to the right. But how do i do that with this information. Please help me. And oh yeah....welcome back and thanks for all the help so far!
preeste
preeste • Nov 27, 2007
And oh yeah i am using CCS compiler and mplab to do the programming
Well, you see, the logic table that was shown in that l293d h-bridge link was for one motor, not two. Left and right meant anti-clockwise and clockwise, assuming you are looking at the wheel from the side. Thats why there was no "forward".

To instruct the motor, you need to apply values to Pins D1, D2, D3, D4 CCP1 and CCP2 of the microcontroller (refer to the table in the motor diagram).
The logic depends on how you connect the motor. Usually you figure out by trial and error.

First off, each motor has 3 inputs from the uC.

For the right motor, its D1, D2 and CCP1. D1 and D2 are logic outputs, and they determine the direction in which the wheel rotates. CCP1 is the PWM output, and this determines the "speed" of the rotation.
For the left motor, its D3, D4 and CCP2.

To make the robot go forward, you have to make both the motors rotate, but at different directions. Think about the rotation of the wheels of a car.. if you look from the right side, the wheels rotate clockwise, but if you look from the left, it rotates anti-clockwise. Same concept applies with the robot.
TO make a turn, you either make one of the motors slower or stop.

I'll give you a snippet of the coding to give you headstart..

 
set_tris_d(0b1110001);// sets D1,D2,D3 and D4 as output
setup_ccp1(CCP_PWM);// sets the CCP pins
setup_ccp2(CCP_PWM);
setup_timer_2(T2_DIV_BY_1,255,1) ;//gives the timing frequency
 
//forward direction setting
output_low(PIN_D1);
output_high(PIN_D2);
output_high(PIN_D3);
output_low(PIN_D4);
 
set_pwm1_duty(255); //forward speed
set_pwm2_duty(255);
If you find your robot reversing instead, just change the coding. To turn right or left, you'd have to apply the appropriate outputs to D1, D2, D3 and D4. To make the robot stop, you have to apply low ouput (logic 0) to all of them.
preeste
preeste • Nov 27, 2007
hey Ash ....thanks for that...now it all makes sense...

okay another question for you....once you program the vehicle and it gets to the end of the line the vehicle obviously stops....iNORDer to start it again do you have to reprogram the pic again?

thanks for the prompt reply
nope, just resetting the robot would be sufficient enough. However, if your robot does behave erratic at times , reflashing the PIC is a good option.
caen_clux
caen_clux • Dec 4, 2007
Line following robot blog.This blog can help person who interested to know it.

For more information about line following robot..visit at https://robotku.blogspot.com
preeste
preeste • Apr 14, 2008
Help......the line follower once again!!!

okay so i finally have a few days to myself again and i have decided to try and finish up this line follower that i had been working on last year. I was using the design ideas that Ash provided under this particular discussion. Ash could you please give me the type of photo transistors and IR Leds you used. Furthermore could you please help me with the coding. I mean i only like have a week to complete this. I am really struggling with the start of the coding.... i mean how do i actually do the sampling initially so that the line follower knows where exactly it is positioned? Please help.......after all this is just something i am doing for fun and if i dont finish it now i never will! Thanks πŸ˜€
Mohit parnami
Mohit parnami • Feb 7, 2010
hi ash...
i am too very much intrested to see the schematics.
can u post your circuit of line follower.actually i have studied abt an individual components but dont know how to get together all the components and make my line follower robotπŸ˜€

Share this content on your social channels -