line follower which is part of robotics and embedded

Upload: nilav-chokshi

Post on 04-Jun-2018

222 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/13/2019 Line Follower which is part of robotics and embedded

    1/19

    ACTIVE FOR UM TOPICS

    Line follower. IR

    sensors

    how can i c reate agame in java

    programming?.

    2009 and we are stillstuck on 256kbps

    broadband

    SNR Margin and Line

    Attenuation - What

    do they mean?

    (Hardware) Do you

    know?

    more

    YOU ARE HERE Line Follower

    Line Follower

    By b O t s k O O l - Posted on 2 1 A p r i l 2 0 0 9

    The line follower is an autonomous bot that canfollow a specific colored line painted on asurface of different contrast, such as white onblack.

    To start with first of all I will be discussing asmall concept of light. I believe you all know thatthe light that strikes any platform is reflected.The reflection and absorption coefficient of lightdepend upon material, color of platform and other factors. In simple words the blacksurface absorbs the light and the white surface reflects it, this is the basic concept

    behind making a line follower.

    So the line follower has an emitter and a reflector. The reflector receives the lightand generates a voltage proportional to the intensity of the light, if this voltage isabove a threshold it means SIGNAL=1 (logic one) else SIGNAL= 0 (logic zero).

    Lets take up an example where we have to move our bOt on black surface havingwhite line. Suppose I have two Infra Red (IR) sensor pairs that are on differenthalves of a bOt with respect to geometrical central axis of the bOt. The sensors areplaced in such a way that the white line lies in between both the sensors when thebOt is placed on the white track painted on black surface to move. Now if the whiteline is between both the sensors while moving forward both the sensors will be onblack surface and the detectors/receivers will receive less amount of light since

    black absorbs light and hence signal provided by both the infra red receivers will below.

    Search

    Login

    Username or e-mail: *

    Password: *

    Log in

    Create new accountRequest new password

    POPULAR C ONTENT

    Today's:Online C/C++

    Compiler

    (Hardware) Do youknow?

    Line Follower

    2x16 LCD And 4x4

    Keypad I nterfacing

    With 8051 in

    Assembly Language

    fourth year minor

    project ideas(electronics)

    All time:Online C/C++

    Compiler

    bOtskOOlSimply Robotics!

    Workshops Sitemap Contact Us

    Home Forum Robotics Computer Programming Online Image Processing User PagesOnline Compilers Games

    7/22/2009 Line Follower | bOtskOOl

    botskool.com/tutorials//line-follower 1/19

  • 8/13/2019 Line Follower which is part of robotics and embedded

    2/19

    GET REGULAR UPDATES

    Enter your email

    address:

    Subscribe

    Delivered by FeedBurner

    POLL

    Which of the

    following is the best

    Linux Distro?:

    Ubuntu

    Red Hat

    Open Suse

    Fedora

    Vote

    Now if the heading/direction of the white line changes one of the sensors will movein the region of white line and will start giving output signal as high. This

    information can be used to turn the bOt and orient itself in the right direction. Forexample in the above figure if the bot is located in position 1, then bOt will moveforward and if the bOt is in position 2 it will have to turn left .

    Lets move on and discuss everything step by step in detail. We wil l be discussingthe making of line follower under three heads:

    1.) Chassis of robot { those familiar can skip this section}2.) Electronics/Hardware Designing3.) Programming/Software Designing

    CHASSIS OF ROBOT

    1.) Base of robot: The base or the material of the platform of robot can be made

    with any easily avai lable material like switch board, wood, acrylic sheet orsteel sheet. As our robot will be very light, you dont have to think a lot onstrength and other such factors. We will just recommend you to make a smallsize and light weight bOt. Here we are using, steel base:

    2.) Motors and Driving Mechanism: We will need a set of two motors that have same rpm (revolution per

    minute). We will be using differential drive for maneuvering our bOt i.e. we

    will have three wheels for our bOt, the front two will be powered andthe rear will be free wheel.

    Building a RF remote

    control

    how to c reate a delay?

    fourth year minor

    project ideas

    (electronics)

    CHATROOM

    22:56:48 hi06:38:18 any onefrom admin17:31:05 any1 frmadmin11:59:05 hii yaar11:59:42 can ugime a circuit for white linefollower12:01:55 any bdyhr12:45:06 post inforum

    Post

    7/22/2009 Line Follower | bOtskOOl

    botskool.com/tutorials//line-follower 2/19

  • 8/13/2019 Line Follower which is part of robotics and embedded

    3/19

    When the bot is moving straight both the motors should have equalspeed.

    For turning, one of the motor is switched off. If we switch off the leftmotor, the bot will turn left and vice versa.

    You can choose a motor of rpm around 100 and a torque of 1kg cm

    3.) Coupling wheels & clamping motors: For clamping the motors you can usepipe clamps or make right angled clamps. The right angle c lamps ensuremore rigidness. To couple the motor ensure that the shaft of motor and holeof wheel have equal diameter (if you cant find one check the tutorial onwheels).

    7/22/2009 Line Follower | bOtskOOl

    botskool.com/tutorials//line-follower 3/19

  • 8/13/2019 Line Follower which is part of robotics and embedded

    4/19

    ELECTRONICS

    This is a flow chart that explains the working of the bOt in sequence:

    The Infra Red sensors are used to interact with the environment. The emittersends a ray which is received by detector in the form of voltage and it then

    7/22/2009 Line Follower | bOtskOOl

    botskool.com/tutorials//line-follower 4/19

  • 8/13/2019 Line Follower which is part of robotics and embedded

    5/19

    amplified by amplifier since the signals are weak (more on this later). Beloware the circuit diagrams of Infra red LED emitter and receiver.

    Op Amplifier (LM324)If the rays received by the IR LED receiver are above a particular threshold thenan amplified signal is generated by the amplifier (LM324). Note that the sensorscannot directly send a signal to the microcontroller as the signal voltagegenerated by them is too low and even when sensors are on white surface signalgenerated by them will interpreted low by the microcontroller.

    Microcontroller (AT89S52)

    7/22/2009 Line Follower | bOtskOOl

    botskool.com/tutorials//line-follower 5/19

  • 8/13/2019 Line Follower which is part of robotics and embedded

    6/19

    The microcontroller receives the signal and responds accordingly. It takes thedecision based on input signal received by both the receiver LEDs. It will givecommand to motors through H bridge to move forward, or take a left turn or aright turn.

    Hbridge (L293B)

    The microcontroller sends a signal to the H bride that acts as a switch. If thesignal received by the H bridge is high it will rotate the motor or else it wont doso. Note that microcontroller only sends a signal to a switch which gives thevoltage required by the motor to rotate. Here we are using L293B which can beused to control two motors.

    Pin connections for H bridge: En1 & En2 are given logic 1 from microcontroller or give 5V from outside

    and are used to activate/deactivate one half of the H bridge. V is the voltage that you want to supply to the motor(s) : 9 or 12V Vcc is the logic 1 or 5V

    The complete circuit diagram with all the integrated circuits required for makinga line follower is shown below:

    7/22/2009 Line Follower | bOtskOOl

    botskool.com/tutorials//line-follower 6/19

  • 8/13/2019 Line Follower which is part of robotics and embedded

    7/19

    Here we are using pins P1.0 and P1.4 for taking inputs from the IR sensors afterbeing amplified by LM324.

    P1.0 Input from left sensor

    P1.4 Input from right sensor

    There are six outputs from AT89S52 microcontroller to the H bridge.

    Pins P0.0 and P0.4 are connected to enable pins of the H bridge. We can use themto deactivate/active the two halves of H bridge i.e. if pins are set to logic 1 thecorresponding half of the H bridge wil l be activated.

    P0.1 will drive the left motor in forward direction

    P0.2 will drive the left motor in reverse direction

    P0.3 will drive the right motor in forward directionP0.5 will drive the right motor in reverse direction

    Programming

    Below is the code in C for the line follower.

    C Code www.botskool.com

    #include

    /* Sensors input port - P1 P1_0 --- --- --> Left sensor P1_4 --- --- --> Right sensor

    Motors output port - P0

    P0_0 --------> Enable pin of the left half of the H-bridge P0_1 -- -- -- --> will drive the left motor in forward direction P0_2 --------> will drive the left motor in reverse direction P0_3 -- -- -- --> will drive the right motor in forward direction

    7/22/2009 Line Follower | bOtskOOl

    botskool.com/tutorials//line-follower 7/19

  • 8/13/2019 Line Follower which is part of robotics and embedded

    8/19

    P0_4 -- -- -- --> Enable pin of the right half of the H-bridge P0_5 -- -- -- --> will drive the right motor in reverse direction*/

    /*Delay function runs an idle loop to create a time delay. If the crystal used is of 11.0592 MHz then the argument passed in delay is in 'milliseconds'.*/void Delay (unsigned int itime)

    { unsigned int i,j; for(i=0;i

  • 8/13/2019 Line Follower which is part of robotics and embedded

    9/19

    P0_3=0; P0_5=0; Delay(50); /*50ms time delay*/ }

    void main()

    {/* The pins which are receiving inputs from the sensors should be initially set to logic1.*/ P1_0=1; /*Left sensor input*/ P1_4=1; /*Right sensor input*/

    //main loop of the program while (1) {

    if ((P1_0==0)&&(P1_4==1)) TurnRight();

    else if ((P1_0==1)&&(P1_4==0)) TurnLeft(); else Forward();

    }}

    Download c program file linefollower.c

    Download hex file linefollower.hex

    Download AT89X52.h header file

    Average:

    Your ra ting: None Average: 4.9 (9 votes)

    Login or register to post comments 2962 reads

    Tags 8051

    Wow!Submitted by Steven (not verified) on Tue, 04/21/20 09 - 19:49.

    Hello! simply super resource

    Login or register to post comments

    superb!Submitted by Michelle (not verified) on Thu, 04 /23/2009 - 00:47.

    simply mind boggling! very informative indeed!

    Login or register to post comments

    7/22/2009 Line Follower | bOtskOOl

    botskool.com/tutorials//line-follower 9/19

  • 8/13/2019 Line Follower which is part of robotics and embedded

    10/19

    Hey guys, I am am final yearSubmitted by mecool.1988 on Wed, 04/29/2009 - 03:16.

    Hey guys,

    I am am final year student working on a l ine follower project and i need some

    advice on how to implement PID for this robot. I am using 6 infrared photodetectors to detect the line. I am taking the analog data from the sensors and

    using the ADC's to get the feedback infor for the PID control. Plz can you help me

    out...

    Login or register to post comments

    Please correct the IC no. toSubmitted by heloitsadi on Mon, 05/04/20 09 - 14:32 .

    Please correct the IC no. to L293D instead of L239B

    Login or register to post comments

    Xtra informationSubmitted by heloitsadi on Mon, 05/04/20 09 - 15:13 .

    This command is wrong...

    else if((P1_0==1)&&(P1_4==1))

    It should be...

    else if((P1_0==1)&&(P1_4==0))

    Please correct it, and if I am wrong correct me.

    Login or register to post comments

    Re: Please correct the IC no. toSubmitted by bOtskOOl on Mon, 05/04/2009 - 15:56.

    Thank you for feedback. The IC being used here is L293B . It was misspelled as

    L239B. It has been updated.

    Login or register to post comments

    Re: Xtra informationSubmitted by bOtskOOl on Mon, 05/04/2009 - 16:01.

    Thank you for pointing this line out. I had overlooked it. Yes obviously it will be

    vice versa of previous condition in the code. It has been updated.

    Login or register to post comments

    7/22/2009 Line Follower | bOtskOOl

    botskool.com/tutorials//line-follower 10/19

  • 8/13/2019 Line Follower which is part of robotics and embedded

    11/19

    Very good job.. Thanx for theSubmitted by heloitsadi on Mon, 05/04/20 09 - 21:44 .

    Very good job.. Thanx for the immediate response.

    Login or register to post comments

    I didn't heard about that IC,Submitted by heloitsadi on Mon, 05/04/20 09 - 21:46 .

    I didn't heard about that IC, i have heard about L293D, L298 only.. i pointed out..

    thanx for correcting me.

    Login or register to post comments

    Its awesome guys!!!Submitted by Dark Knight (not verified) on Tue, 05/05/20 09 - 23:33 .

    Its awesome guys!!!

    Login or register to post comments

    programming in avrSubmitted by aashiqcoolguy21 on Tue, 06/02/2009 - 22:28.

    Please can anybody post the code in AVR .. when Atmega 16 is used and l293d is

    used. i.e. we are working on atmega 16 dev board and we are makin black line

    follower... and how we can c hange the code to obtain .. obstacle detector and edge

    follower please help me out.

    Login or register to post comments

    very niceSubmitted by Guest (not verified) on Sat, 06/13 /2009 - 16:2 8.

    This tutorial i s really very useful for a beginner.

    Login or register to post comments

    @aashiqcoolguy...Submitted by heloitsadi on Sat, 06/13 /2009 - 18:1 2.

    This code will basically do the job.. just change the case conditions as per the

    sensors assembly and their count... Its simple to implement..

    #include

    void main(void)

    7/22/2009 Line Follower | bOtskOOl

    botskool.com/tutorials//line-follower 11/19

  • 8/13/2019 Line Follower which is part of robotics and embedded

    12/19

    {

    unsigned int k, h;

    DDRA=0x00;

    DDRD=0XFF;

    while (1)

    {

    k =~PINA;

    h=k & 0x0F;

    switch (h)

    {

    case 0x0D:

    {

    PORTD=0x89;

    break;

    }

    case 0x07:

    {

    PORTD=0x86;

    break;

    }

    case 0x0B:

    {

    PORTD=0x85;

    break;

    }

    case 0x09:

    {

    PORTD=0x8A;

    break;

    }

    case 0x0A:

    {

    PORTD=0x00;

    break;

    }

    case 0x0E:

    {

    PORTD=0x81;

    break;

    }

    case 0x0C:

    7/22/2009 Line Follower | bOtskOOl

    botskool.com/tutorials//line-follower 12/19

  • 8/13/2019 Line Follower which is part of robotics and embedded

    13/19

    {

    PORTD=0x88;

    break;

    }

    case 0x08:

    {

    PORTD=0x82;

    break;

    }

    case 0x06:

    {

    PORTD=0x88;

    break;

    }

    }

    }

    }

    Login or register to post comments

    awesome tutzSubmitted by vandy on Sat, 06/27/2009 - 14:47.

    hey this tutz is really kool..

    but i have a doubt in the c ode for the mc...

    Delay(50); /* Wait for 50 ms*/ P0_0=0; /*Motors are not running*/ P0_2=0; P0_4=0; P0_6=0; Delay(50); /*Delay of another 50 ms*/ } y is P0_2,P0_4,P0_6 made zero???i request for a reply n kindly excuse if my doubt is silly coz im a beginner..

    Login or register to post comments

    Re: awesome tutzSubmitted by bOtskOOl on Sat, 06/27 /2009 - 17:3 8.

    Hi vandy,

    Thank you for your comment.

    Regarding your doubt -

    What we are doing is that we are powering up motors for 50 milli seconds and thenturning them off for next 50 milli seconds and we keep on doing this repeatedly so

    7/22/2009 Line Follower | bOtskOOl

    botskool.com/tutorials//line-follower 13/19

  • 8/13/2019 Line Follower which is part of robotics and embedded

    14/19

    that our line follower bOt turns slowly and doesn't get out of control on a sharp

    turn.

    So for turning off motor you need to set all the logic lines to 0 which are going to

    H-bridge from microcontroller and that is acheived by setting pins 0, 2, 4 and 6 of

    port 0 (which are connected to the H-bridge) to zero for 50 milliseconds. H ope

    this explanation wil l make everything clear. We are really glad that you posted yourdoubt.

    If there is any further doubt please don't hesistate to ask us. Just post another

    comment .

    All the best

    Login or register to post comments

    hey thankq 4 theSubmitted by vandy on Sat, 06/27/2009 - 21:38.

    hey thankq 4 the reply...

    i think the ports to be made zero are

    either P0_1, P0_2, PO_3 , PO_5 (turning off the motors by making the input data

    zero)

    or

    P0_0 AND P0_4 (turning off the motors by making enable inputs zero)

    WHY IS PO_6 MADE ZERO WHEN IT IS NOT USED? i hope its not used!

    Login or register to post comments

    Re: hey thankq 4 theSubmitted by bOtskOOl on Sat, 06/27 /2009 - 23:0 4.

    Oh my God! That was a terrible mis-print (set of four pins 1,2,3 & 5 was

    misprinted as 0,2,4 & 6). Just now noticed it. First of all I must really thank you for

    pointing this out.

    Thank you vandy .

    Now everything has been corrected. And yes you definately turn off motors by

    setting both the enable inputs zero i.e. P0_0 and P0_4. Here we have done this bymaking pins 1, 2, 3 and 5 of port 0 so that it is easy for beginners to grasp

    everything. But yes it can be definately done by that also and its a much shorter

    code. Even you don't need to set all the four pins of port 0 to logic 0

    because at a time only two pins will have logic 1 out of pins 1,2,3 & 5 but it has

    been done so just to make everything easy to understand.

    Login or register to post comments

    watch out this fast line follower

    7/22/2009 Line Follower | bOtskOOl

    botskool.com/tutorials//line-follower 14/19

  • 8/13/2019 Line Follower which is part of robotics and embedded

    15/19

    Submitted by DeAviator on Mon, 06/29 /2009 - 00:2 6.

    watch it now

    Login or register to post comments

    Thats really very fast... I sSubmitted by heloitsadi on Mon, 06/29/20 09 - 02:38 .

    Thats really very fast... I s it designed by you.. if yes.. how many sensors are usedin this bot... and are you using PWM to maintain the sharp turn accurasy...

    Login or register to post comments

    thankqSubmitted by vandy on Mon, 06/29/2009 - 22:13.

    thankq for the prompt correction.

    i request you to clear the following doubts also.

    1. which of the following combination of sensors would be efficient in terms of

    accuracy and immunity towards external light?

    IR LED +photo transistor (or)

    IR LED + IR reciever (or)

    high intensity red led + photo transistor

    2. is it possible to program a line follower with 3 sensors that can follow a

    blackline on a white surface as well as whiteline on a black surface at the same

    time with the same program? if so, will the following logic work ?

    assuming p1_0,p1_1,p1_2 to be the inputs and p0_1,p0_2,p0_3,p0_5 to be the

    outputs to the mc

    blackline on white surface :

    p1_0 p1_1 p1_2 p0_1 p0_2 p0_3 p0_5 action

    1 0 1 1 0 1 0 forward

    1 0 0 1 0 0 0 right

    0 0 1 0 0 1 0 left

    1 1 1 0 0 0 0 stop

    7/22/2009 Line Follower | bOtskOOl

    botskool.com/tutorials//line-follower 15/19

  • 8/13/2019 Line Follower which is part of robotics and embedded

    16/19

  • 8/13/2019 Line Follower which is part of robotics and embedded

    17/19

    thanks for the comment, this is my line follower Shelby

    Login or register to post comments

    Hey please give me theSubmitted by heloitsadi on Sun, 07/12/20 09 - 19:39 .

    Hey please give me the details about how you increased the speed and the

    accuracy upto that extent... WHat type of sensors and actuators are used by you...

    Are you using PWM...?

    Login or register to post comments

    if i connect the circuit as shown above...can i get output ?Submitted by palla.anilkumar on Tue, 07/14/2009 - 09:10.

    is that circuit working?i need to execute that...so,i am asking whether that circuitis correct or not?pls..reply soon

    Login or register to post comments

    line followerSubmitted by insopor1upiita on Tue, 07/14/2009 - 21:19.

    Hello!

    I use sensors QRD1114, and mosfet for the motors.

    I have not tested the program or the circuit that comes on this page.

    Saludos desde Mxico

    Login or register to post comments

    if i connect the circuit as shown above...can i get output ?Submitted by bOtskOOl on Tue, 07/14/2009 - 21:55 .

    This circuit is absolutely fine and yes it worksIf you have any doubt or if you face any problem during making line follower just

    post your query.

    Keep posted us of you progress

    All the best

    Login or register to post comments

    line followerSubmitted by nileshrockfire on Sun, 07/19 /2009 - 20 :29.

    hi, i m new in the field of robotics ...........

    7/22/2009 Line Follower | bOtskOOl

    botskool.com/tutorials//line-follower 17/19

  • 8/13/2019 Line Follower which is part of robotics and embedded

    18/19

  • 8/13/2019 Line Follower which is part of robotics and embedded

    19/19

    Book PageIntroduction to 8051 Assembly Language Programming

    There a re currently u s e r s and 9 g u e s t s online.

    bOtskOOl website by bOtskOOl is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 2.5 India License .Permissions beyond the scope of this license may be available at http://www.botskool.com/contact .

    bOtskOOl.com Privacy P olicy

    7/22/2009 Line Follower | bOtskOOl