Learn Robotics-3 - Introductin to a Line Follower..

silverscorpion
@silverscorpion-iJKtdQ • Oct 26, 2024

Hi all,

Sorry for the long break. Been busy..
Well, this is the third part in the series. We'll see a bit about a line follower.
I'll just give a brief intro about what a line follower is and where it might be
used.
I have a lot to say and I might probably need to break up this intro into two
parts. Let's see.
Before we go further, I give you this video from youtube, to help you get an idea of what a line follower is. There are many more videos available. Feel free to browse thru youtube for such videos.


[youtube]PzZhslIrsE0[/youtube]

This robot follows the line and also detects obstacles. We'll see obstacle detection at a later stage. Now, we proceed to the line follower.

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • silverscorpion

    @silverscorpion-iJKtdQ • May 12, 2009

    Introduction to Line Follower​
    A Line follower is a robot that automatically traces a line on the ground,

    preferably a dark line on a light background or vice versa.
    This in itself is a simple concept. Higher end robots like maze solvers and

    micro mice have this line follower as the base.

    Ok, into the line follower. The components are

    1) A sensor circuit to trace the line,
    2) A motor driver circuit to drive the robot thru the line, and
    3) A microcontroller circuit to get input from sensor, make a decision and drive the motor based on the decision.

    Sensor Circuit:

    Basically two types of sensors can be used. One is based on IR (Infra red)

    rays and the other is based on LDR’s (Light Dependent Resistors).


    IR based sensors can be used when the line to be traced is a dark line with

    a light background or vice versa. ie, the principle behind IR sensor is that,

    when IR sensor emits IR rays, different colors absorb IR rays with different

    affinity.

    Black absorbs IR rays. White reflects IR rays. So, if IR rays fall on black,

    nothing is returned. If it falls on white, everything is returned.
    This is true to other dark-light pairs. If black line with yellow background is

    used, black absorbs everything and yellow reflects part of the incident

    energy. This can be used to differentiate the line and the background.


    But if lines like yellow line with violet background is used or some other

    thing where IR rays can’t provide the necessary difference, then LDR based

    sensors are used. Here, the principle used is that, white light is flooded

    over the line. Different colored lines reflect white light in a different way.

    So, the intensity of light that falls on the LDR when it senses yellow is

    different from that when it senses violet.


    In an LDR, the resistance of the device changes with respect to the

    amount of light that falls on it. So, with the different intensities, we can

    differentiate yellow from violet.


    This is the basis of selecting the type of sensor to be used. Next comes the

    calibration part. Here, we use a simple circuit called a “Comparator”. A

    comparator is just an Opamp with two inputs. One is an inverting input and

    the other is a non inverting input. It compares the two inputs. If the

    inverting input is higher, it returns zero. If the non inverting input is higher,

    it returns one. Well, we can make it work the other way around to.


    In a line follower, this is used as follows. We fix a threshold voltage level

    and give it to the inverting input. And we give the output from the sensor

    to the non inverting input. So, whenever the sensor output is higher than

    the threshold voltage, the comparator output is high.

    We measure the highest possible value black can give. This is the

    threshold. If the sensor output is greater than the threshold, then the

    sensor is on white. If it’s less than or equal to threshold, then it’s on black.

    This is the algorithm we are going to use. Note that, the same is possible

    while using LDR based sensors too.


    Then there’s the trivial matter of the number of sensors to use. This varies

    widely based on the characteristics of the line we need to follow. We’ll

    discuss about this later.


    Below is a simple IR based sensor circuit.


    [​IMG]


    This is a simple, plain IR sensor. The one in black color is the IR emitter or IR LED. The white colored thing is the IR receiver or photodetector.
    The IR LED is covered in black tape to provide shielding.


    [​IMG]


    Here also, the tape is provided for shielding. This is a LDR based sensor.


    [​IMG]


    This is an IR range finder. This is a sophisticated IR sensor used for range finding and route mapping. We'll discuss this later.


    That's all about sensors. I thnk this is enough for now. I'll cover motors and controller in the next post. Wat say ya??


    So, how was it this time?? As usual, pour in your doubts, however trivial it may seem to be. And get interested in basic electronics and brush up about simple transistors and all, because we will need those as we go further.


    Till next post, then. Cheers😁😁

  • Harshad Italiya

    @harshad-ukH5ww • May 12, 2009

    wow This is the Final Stage.. for Robot
    Cheers

  • shahrul

    @shahrul-Ex12xz • May 12, 2009

    This is the basic. Good post..

  • silverscorpion

    @silverscorpion-iJKtdQ • May 12, 2009

    Godfather, now you can post your micro line follower here.
    go ahead.

    Thanks!!

  • shalini_goel14

    @shalini-goel14-ASmC2J • May 12, 2009

    Hey Scorpion, sorry for my stupid question but why do it need to trace line on the ground. I couldn't get the idea of this. 😕

  • Ashraf HZ

    @Ash • May 12, 2009

    By tracing, he meant detecting the line. It must be able to distinguish between a dark and light surface, hence the line.. so the sensor can give two different outputs 😀

  • shalini_goel14

    @shalini-goel14-ASmC2J • May 12, 2009

    ashBy tracing, he meant detecting the line. It must be able to distinguish between a dark and light surface, hence the line.. so the sensor can give two different outputs 😀

    Ok then what it do after distinguishing between dark and light surface? I mean what kind of decisions it make -dark for this and light for this?

  • Harshad Italiya

    @harshad-ukH5ww • May 13, 2009

    it will senses the surface and the Value given by the Sensor and according to that value it will be stable on its path...

    if it goes diverted from line then by sensing value it rollback to its original path.

  • shalini_goel14

    @shalini-goel14-ASmC2J • May 13, 2009

    Hey scorpion, one question where all such line followers robots are used? I guess they can be used only when we can provide dark and light lines right? Any real time applications, any ideas?

  • Ashraf HZ

    @Ash • May 13, 2009

    Sorry, I know I'm not scorpion but.. since I also worked on line followers, I hope I can still chip in!

    Line followers in uni's are usually built to allow students to learn the basics of sensors and its callibration, motors, and microcontrollers all in one. Because of the required conditions such as following a path or navigate through a number of them, students will learn the logic behind the algorithms they use. Its also really fun! 😀

    There are indeed real life applications, such as for robots in industrial places. Lines are drawn all over the factory floor.. and supply robots follow them to reach certain destinations and deliver components. They usually use more advanced sensors, but the concept is the same 😀

  • shalini_goel14

    @shalini-goel14-ASmC2J • May 13, 2009

    Ok I see, Thanks for good answer Ash but if I want to make a robot that can move anywhere along any specified lines(like in industries) as well as without lines(other than industries) it would fail right?

  • Ashraf HZ

    @Ash • May 13, 2009

    In general, you can do whatever robot you wish. Its only limited to the number of sensors you can integrate. As SS had said, the decision making process will be made in the microcontroller.

    So, you can still have line sensing circuits as well as other forms of navigation.. such as indoor position systems and proximity sensors. You can code it in such a way that if it reaches a certain position or area, it should rely on the lines for navigation. And as a safety measure.. if the robot goes off the line by accident (which does happen if the robot overshoots), the other forms of navigation will be activated.

  • shalini_goel14

    @shalini-goel14-ASmC2J • May 13, 2009

    Ok thanks Ash for clearing my few stupid doubts. 😀

  • Ashraf HZ

    @Ash • May 13, 2009

    Hey now, in engineering.. there are no such things as stupid doubts. I think 😛

  • paleng

    @paleng-q0EJOc • May 14, 2009

    I thought there must be more, like circuit diagram or sensors specifications or kinda model for line follower......


    Well just for the idea to the line follower makers, if you would add circuitry of the optical mouse it will helps good, see its IC tell about the directivity so it will help us to identify the direction. With the line following we can programmed it for directivity......isnt it.....

    well nice post.....

  • Harshad Italiya

    @harshad-ukH5ww • May 14, 2009

    hey guys if you are going to make one robot then i will post about that here... then you can implement it with the tutorial of Silverscorpian.

  • Harshad Italiya

    @harshad-ukH5ww • May 14, 2009

    i have circuit diagram you have to make its PCB or on general purpose board...
    you have to design mechanical part according to this tutorial you can take this as your homework!! 😉

  • paleng

    @paleng-q0EJOc • May 14, 2009

    Alright, I can throw the effort, i will try...... just give me the Circuits and specs.......

  • paleng

    @paleng-q0EJOc • May 14, 2009

    Is any body else in here with me.......

  • Harshad Italiya

    @harshad-ukH5ww • May 14, 2009

    yes we are with you we are here to make something new..

    Thanks for your Reply

  • shalini_goel14

    @shalini-goel14-ASmC2J • May 14, 2009

    godfatherhey guys if you are going to make one robot then i will post about that here... then you can implement it with the tutorial of Silverscorpian.

    Yeah I would like to make one but honestly speaking I don't know much about it 😔 . Anyways how much it costs around to make a fantastic(an automated one 😛) robot?

  • raj87verma88

    @raj87verma88-ZpL2Wn • May 14, 2009

    A simple Line Follower good enough to win some college competitions will cost around Rs. 3000/=

  • shalini_goel14

    @shalini-goel14-ASmC2J • May 14, 2009

    raj87verma88A simple Line Follower good enough to win some college competitions will cost around Rs. 3000/=

    Oh that's it only. Then I guess I can go for it and will start eating your heads for information soon.😁

    Will linefollower do my works? Hey can a kind of Robot can be made that keep on putting my things itself as reminders , I mean I just don't need to tell that put it as reminder. I talk to it and it keeps it as reminder and do let me know at appropriate time about it. 😕

  • silverscorpion

    @silverscorpion-iJKtdQ • May 15, 2009

    shalini_goel14Will linefollower do my works? Hey can a kind of Robot can be made that keep on putting my things itself as reminders , I mean I just don't need to tell that put it as reminder. I talk to it and it keeps it as reminder and do let me know at appropriate time about it. 😕

    What you are asking is quite a complex one. If I'm not wrong, you're asking for a robot to be sort of your P.A. It should recognize your voice, store what you say to it, and then remind you in the appropriate time. Right?? Complex, difficult, but it can be done. It involves too many things like signal processing and all. May be I can tell you something about it later. Actually I know only a little about signal processing.

  • silverscorpion

    @silverscorpion-iJKtdQ • May 15, 2009

    And I'll include the circuit diagrams for the sensors soon. I didnt do it before as I thought it'd be better if I told you about all the components before going to the circuits part.
    There are still motors and micro controllers to be discussed.
    If you'd like to start right away, and want the circuit dia for sensors alone, ask for it and i'll post it.
    Or, if you decide to know the components fully, wait for that.
    What should I do?

  • sarveshgupta

    @sarveshgupta-txtmu5 • May 15, 2009

    @SS: May sound little foolishand late in addressing but welcome back.. was waiting for the # part in the series.. and unfortunately my exams are still going on till 27th. Trying to follow it.
    Well SS i think i think you must have sorted out the way to proceed with the tutorial part 3. you are the best judge as we are unaware what is going to come next.

    If you think first the concepts and theory portion is important then fine. But another approach is first gripping on one component that is sensors and then moving forward to the motors and microcontrollers part as you will have to anyway discuss this for more clarity. So why not do it now.
    However doing the circuits part altogether will enable to easily integrate and understand after taking a dip on theory we will be all for practical aspect. this is better too.

    So the end result is where we started you have to decide how to proceed.

    Others please help SS take a decison.

  • Harshad Italiya

    @harshad-ukH5ww • May 15, 2009

    yep sounds good Gupta,

    Lets do something Different first of all we make a small part of the Line Follower Roobot..

    as you want to do practice or want to check about Sensors then... we can do one thing... first of we will make the testing module of the sensor and checks weather it is working fine and giving the Range which we are going to use as controlling purpose.

    Say your idea SS!!

  • Harshad Italiya

    @harshad-ukH5ww • May 15, 2009

    shalini_goel14Yeah I would like to make one but honestly speaking I don't know much about it 😔 . Anyways how much it costs around to make a fantastic(an automated one 😛) robot?

    So you are going to enter in Electronics field also... Most Welcome 😁
    Make one Robot! Best Luck buddy

  • shawnmk123

    @shawnmk123-HRHhJN • May 18, 2009

    "If the inverting input is higher, it returns zero." this line in the text seems a bit wrong to me...i learnt that the comparator is like the following

    A comparator circuit compares two voltage signals and determines which one is greater. The result of this comparison is indicated by the output voltage: if the op-amp's output is saturated in the positive direction, the noninverting input (+) is a greater, or more positive, voltage than the inverting input (-), all voltages measured with respect to ground. If the op-amp's voltage is near the negative supply voltage (in this case, 0 volts, or ground potential), it means the inverting input (-) has a greater voltage applied to it than the noninverting input (+).

    thanx to --->>>#-Link-Snipped-#

  • silverscorpion

    @silverscorpion-iJKtdQ • May 20, 2009

    Ok. After some thinking, I've decided to give the circuit diagram of the sensor first. I'll give the circuit. I expect all robotics enthusiasts to try this circuit out in a breadboard and tell me the results. This will be a simple and fun experiment to begin your journey in robotics..

    Here comes the circuit diagram of the transmitter receiver pair.

    [​IMG]


    For a reference, I also give you the finished sensor pair, ready to mount in the robot. I already gave this picture in my previous post.

    [​IMG]

    Happy circuit building.. Shoot me your doubts, if any..

  • silverscorpion

    @silverscorpion-iJKtdQ • May 20, 2009

    Let me explain the circuit.

    First, the components. There are very few components in the circuit:

    1) The IR led. This is the transmitter and it sends out IR rays. It's indicated by outgoing arrows on a diode symbol to signify it's the emitter.

    2) The photo diode. This is the receiver. It gets the IR rays sent by the IR LED. It's indicated by incoming arrows into the diode.

    3) Biasing resistors. If we give the 5 volt supply directly to the IR led, it'll blow. So, we need to bias the IR led and photo diode with resistors. The resistor values are given in the diagram. These are the optimum values. But any other close value may be used.

    4) Power supply: All Vcc are 5V supplies. If you dont have a 5V supply, you can use any higher supply, but remember to regulate the supply to 5V using some regulator IC like 7805.

    5) LM358 - The comparator IC. It's used to compare two analog inputs. I've told about this before. There are many IC's available for this job. One of them is LM358.

    6) The LED at the end of the circuit is used to verify if the circuit is working properly.

    That's all, I think. Any doubts?? And for those new to electronics, this will all appear to be quite confusing and difficult. Be patient. Dont lose heart.
    Ask all your doubts and I'll clear them, however silly they might be.

    So guys, get started with your own robot. Cheers!!! 😀 😀 😀

  • silverscorpion

    @silverscorpion-iJKtdQ • May 21, 2009

    Anyone tried the circuit?? Any results? Any doubts??

    Just hook it up in a breadboard and you're done in 15 min. 😀

  • Ashraf HZ

    @Ash • May 21, 2009

    Good going!

    If I were you SS, I would have started with a normal LED rather than IR. You can at least see where the light reflects off, and what happens when shinning it on the line, at the line periphery, then on the floor.

  • Harshad Italiya

    @harshad-ukH5ww • May 21, 2009

    but ash IR is not too much difficult

  • shahrul

    @shahrul-Ex12xz • May 21, 2009

    godfatherbut ash IR is not too much difficult

    Yes, I agree. IR just simple circuit. Not to worry to much.

  • Ashraf HZ

    @Ash • May 21, 2009

    No, its not about the circuit. We are only replacing one component after all (LED <-> IR). Its about using it on the line. Hence.. seeing the threshold of where the light shines on the line, edge and floor. Makes it easier to introduce the concept of calibration to people new to line followers.

  • silverscorpion

    @silverscorpion-iJKtdQ • May 21, 2009

    Yep. You are right Ash. Thanks for pointing that out.

    Folks, it'll be easy for u to use a plain LED for starters to see if the circuit is working or not. Also, it'll be easy for you to know what happens if the LEd is on the line, on the border of the line or out of the line.

    Also, one good tip I forgot to mention is this:

    You can use your digital camera or your mobile phone camera to view the IR LED to see if it's working. ie, IR rays are not visible to naked eye. But it'll be visible if viewed thru a digital or mobile phone camera. You can use it to test and debug the circuit. Remember this!!
  • ms_cs

    @ms-cs-Ab8svl • Jun 21, 2009

    These discussions are done during my semester examination days.Just now I saw this thread..
    It is wonderful thread.

    Shall I try the IR sensor ? But I have to buy these things..So Now I want the specifications of the components to buy, 😒

  • silverscorpion

    @silverscorpion-iJKtdQ • Jun 21, 2009

    ms_csThese discussions are done during my semester examination days.Just now I saw this thread..
    It is wonderful thread.

    Shall I try the IR sensor ? But I have to buy these things..So Now I want the specifications of the components to buy, 😒

    Good God,
    I forgot about this completely..
    Thanks for reminding me of this..

    And yes, I sure want you to try this circuit.
    The requirements are very simple.

    Just get a bread board, some connecting wires (single strand), and the circuit components. And then hook them up. That's all. The list of components will be clear if you look at the circuit diagram. However, I provide it, still..

    1) A pair of IR LED's and IR photo detectors
    2) A comparator IC - LM358 or LM324 etc. You can also use a normal 741 op-amp. I suggest LM358.
    3) A single red LED for testing.
    4) resistors : 2 330 ohm resistors, a 100 KOhm pot, and a 10 KOhm pot.
    5) And finally, a power supply. If you can get a 5V power supply, good. Otherwise, you can also use 6V. No problem. So, just connect 4 dry cells and you're ready.

    Or, if you feel so, you can also use a voltage regulator. IC7805. You can give upto 24 volts as input to this IC and it'll regulate it to 5V for you. It's damn easy. No big circuitry and all. Just input, ground and output.

    Please try this out and gimme some results and feedback.. Read the above posts on how to test the ckt for working.

  • ms_cs

    @ms-cs-Ab8svl • Jun 22, 2009

    I have some doubts buddy,

    How to choose that resistor value ? Does it based on the circuit components capability(ie LEDs)?

    Whether IR sensors are of more types ? If it varies means which IR sensor should I use?

  • cranky

    @cranky-E9J79q • Jun 22, 2009

    Really nice post..i have got this doubt😕
    is there any difference in the comparators:using LM324 over others or so?

    And can someone explain the ports in atmega8(and the difference in atmega8 and 16)if impossible to type,any links that may be of use

  • silverscorpion

    @silverscorpion-iJKtdQ • Jun 22, 2009

    ms_csI have some doubts buddy,

    How to choose that resistor value ? Does it based on the circuit components capability(ie LEDs)?

    Whether IR sensors are of more types ? If it varies means which IR sensor should I use?


    Well, there's no hard and fast rule for choosing resistor values.
    If you choose too high a value, like 1K or 2K, then most of your 5V supply will drop in that resistor itself and nothing will be available for the IR LED. Put somethin too low, and you run the risk of burning the IR LED. It can't withstand the full 5V.

    So, anything between 150 ohm to around 500 ohm works good. The value in the dia was the value used by me. It worked good for me. That's why. You use it, and then play around with other values also. Rangin from 150 ohm to 50 ohm, test some 3 or 4 values and decide which one's good.

    As I mentioned somewhere before, IR sensors are basically of 2 types. One is the thing mentioned here. IR LED and photo detector. The second type is called the TSOP. It's a little different from this. It's more accurate and effective, but also more difficult to use. So, you start off with this one. May be later I'll tell you how to use TSOP. Clear??

  • silverscorpion

    @silverscorpion-iJKtdQ • Jun 22, 2009

    crankyReally nice post..i have got this doubt😕
    is there any difference in the comparators:using LM324 over others or so?

    No big difference between them.

    You can make a comparator out of a simple 741 op-amp.

    And of the two IC's I mentioned, ie, LM324 and LM258, there are small differences.

    LM358 / LM358A / LM258 / LM258A : All these are the same. These are 8 pin IC's that have 2 comparators inside them.

    LM124 / LM224 / LM324 : All these are same. These are 16 pin IC's that have 4 comparators in them.

    Just download their data sheets and take a look.. You'll be fine.

  • ms_cs

    @ms-cs-Ab8svl • Jun 22, 2009

    silverscorpionWell, there's no hard and fast rule for choosing resistor values.
    If you choose too high a value, like 1K or 2K, then most of your 5V supply will drop in that resistor itself and nothing will be available for the IR LED. Put somethin too low, and you run the risk of burning the IR LED. It can't withstand the full 5V.

    So, anything between 150 ohm to around 500 ohm works good. The value in the dia was the value used by me. It worked good for me. That's why. You use it, and then play around with other values also. Rangin from 150 ohm to 50 ohm, test some 3 or 4 values and decide which one's good.

    As I mentioned somewhere before, IR sensors are basically of 2 types. One is the thing mentioned here. IR LED and photo detector. The second type is called the TSOP. It's a little different from this. It's more accurate and effective, but also more difficult to use. So, you start off with this one. May be later I'll tell you how to use TSOP. Clear??

    Ok. Now cleared😀 Circuit assembly may be a problem for me.. After getting the components I will ask those here...

  • cranky

    @cranky-E9J79q • Jun 23, 2009

    @silver:thanks 😁

    this maybe too early to ask but couldn't stop myself from asking:what are the cons of TSOP?
    and why should i prefer 16 over 8(mcu)and how should i set the reference in 16(pin 32)

  • silverscorpion

    @silverscorpion-iJKtdQ • Jun 23, 2009

    cranky@silver:thanks 😁
    this maybe too early to ask but couldn't stop myself from asking:what are the cons of TSOP?
    and why should i prefer 16 over 8(mcu)and how should i set the reference in 16(pin 32)


    Cons of TSOP: As I told you, configuring and using TSOP is significantly difficult than the simple IR LED pair.

    Ok, let me explain. TSOP is an IR receiver which is most sensitive to IR rays in the frequency range 38 KHz. So, to use TSOP, you first have to generate a 38 KHz wave in your transmitter circuit. You'll have to use a 555 timer for it.

    By this, the receiver also will get a 38 KHz wave. You have to build your circuit based on that. On the other hand, if you use the IR LED pair, you dont have to worry about frequency. Just power it up and you are ready to go.. Clear??

    And about the 8 or 16 pin IC's, it's really your choice. Know how many sensor pairs you are gonna use. If you want to use 4 sensor pairs, it's better to go for 16 pin IC since it has 4 comparators and ur job is over with 1 IC. If you have only 2 sensor pairs, it's enough if you use 8 pin IC. And there's really no big difference, so you can use either.

  • cranky

    @cranky-E9J79q • Jun 23, 2009

    You'll have to use a 555 timer for it.

    By thisCould you please explain as to how to implement 555 in the circuit.😕😕

    And about that reference(pin 32)in 16 too,cpuld you please tell😒

    Can you give some link to work on blinking led in breadboard(using 555) and with mcu16
    thanks

  • shiwa436

    @shiwa436-h94d47 • Jun 24, 2009

    Thankyou mr. silver scorpion for this post....

  • deekshithrao

    @deekshithrao-cdJ9RN • Jun 25, 2009

    Are there any other applications of line tracer?

  • ashutoshglamour

    @ashutoshglamour-YcpJXd • Jul 1, 2009

    Can someone quickly tell me what are the top 10 robotics companies in the world.