Connect with us

Error in the program line follower Atmega16

Discussion in 'Microcontrollers, Programming and IoT' started by roltex_rohit123, Jan 28, 2011.

Scroll to continue with content
  1. roltex_rohit123

    roltex_rohit123

    92
    0
    Oct 12, 2009
    I have made the following program for a line follower, But it shows the following error for AVR studio. can you help me out?
    Below is the program

    /*Connect the Sensors to PortA Pin 0 (Rightmost Sensor) to Pin 4 (Leftmost Sensor)*/
    #include<inttypes.h>
    #include<avr/io.h>
    #include<util/delay.h>
    //#include"stepper.h"
    /* Following are macros which are used for condition checking. Each macro check for a specific
    condition. Read the operations properly to understand how they work. */
    #define STLINE ((PINA&0x11)==0x11)&((PINA&0x1f)!=0x1f)
    #define IDEAL ((PINA&0x1F)==0x1B)
    #define LINELEFT ((PINA&0x1f)==0x03)|((PINA&0x1f)==0x07)
    #define LINERIGHT ((PINA&0x1f)==0x1|((PINA&0x1f)==0x1c)
    #define LEFT90 ((PINA&0x1f)==0x07)|((PINA&0x1f)==0x03)|((PINA&0x1 f)==0x01)
    #define RIGHT90 ((PINA&0x1f)==0x1c)|((PINA&0x1f)==0x1|((PINA&0x1f)==0x10)
    #define JUNC !(PINA&0x1f)
    #define SPEED 30


    void main(void)
    {
    unsigned char turn=0, s; //turn flag remembers the last turn taken. S is to count number of steps
    DDRB = 0x0f;
    DDRD = 0xf0;
    DDRA = 0x00;
    PORTA = 0xff; //Initialize motor and Sensor Port
    while(1)
    {
    while(STLINE) //Follow Straight Line
    {
    if(IDEAL) //Ideal Condition
    {
    lstep_f(SPEED); //Go Straight
    rstep_f(SPEED);
    }
    if(LINELEFT) //Turn Left
    {
    lstep_f(SPEED);
    }
    if(LINERIGHT) //Turn Right
    {
    rstep_f(SPEED);
    }
    }
    if(LEFT90) //90 degree LEFT TURN
    {
    for(s=0;s<=3;s++) //Go 4 steps and recheck condition
    {
    lstep_f(SPEED);
    rstep_f(SPEED);
    }
    if(LEFT90) // If condition is still LEFT90, do this
    {
    for(s=0;s<=20;s++) //Go Forward 21 Steps
    {
    lstep_f(SPEED);
    rstep_f(SPEED);
    }
    for(s=0;s<=10;s++) //Diff Turn Left 11 Steps
    {


    lstep_f(SPEED);
    rstep_r(SPEED);
    }
    while(!(IDEAL|LINELEFT|LINERIGHT)) //Diff turn Left until line is met
    {
    lstep_f(SPEED);
    rstep_r(SPEED);
    }
    turn=0; //Set Turn Flag = Left (0)
    }
    }
    if(RIGHT90) //90 degree RIGHT TURN
    {
    for(s=0;s<=3;s++) //Go 4 steps and recheck condition
    {
    lstep_f(SPEED);
    rstep_f(SPEED);
    }
    if(RIGHT90) // If condition is still Right90, do this
    {
    for(s=0;s<=20;s++) //Go Forward 21 Steps
    {
    lstep_f(SPEED);
    rstep_f(SPEED);
    }
    for(s=0;s<=10;s++) //Diff Turn Left 11 Steps
    {
    rstep_f(SPEED);
    lstep_r(SPEED);
    }
    while(!(IDEAL|LINELEFT|LINERIGHT)) //Diff turn Left until line is met
    {
    rstep_f(SPEED);
    lstep_r(SPEED);
    }
    turn=1; //Set Turn Flag = Right (1)
    }
    }
    if (JUNC) //If Junction is detected,
    {
    for(s=0;s<=20;s++) //Go straight 21 Steps
    {


    lstep_f(SPEED);
    rstep_f(SPEED);
    }
    if (turn==1) //If last turn was right,
    {
    for(s=0;s<=10;s++) //11 Steps Diff Left
    {
    lstep_f(SPEED);
    rstep_r(SPEED);
    }
    while(!(IDEAL|LINELEFT|LINERIGHT)) //Diff turn Left until line is met
    {
    lstep_f(SPEED);
    rstep_r(SPEED);
    }
    turn=0; //Set Turn Flag = Left (0)
    }
    else //If last turn was Left
    {
    for(s=0;s<=20;s++) //11 Steps Diff Right
    {
    lstep_r(SPEED);
    rstep_f(SPEED);
    }
    while(!(IDEAL|LINELEFT|LINERIGHT)) //Diff turn Right until line is met
    {
    rstep_f(SPEED);
    lstep_r(SPEED);
    }
    turn=1; //Set Turn Flag = Right (1)
    }
    }
    }
    }











    Build started 28.1.2011 at 21:16:51
    avr-gcc -mmcu=atmega16 -Wl,-Map=LineFollower.map LineFollower.o -o LineFollower.elf
    C:/WinAVR/bin/../lib/gcc/avr/3.4.5/../../../../avr/lib/avr5/crtm16.o: In function `__vectors':
    ../../../../../avr-libc-1.4.3/crt1/gcrt1.S:51: undefined reference to `main'
    make: *** [LineFollower.elf] Error 1
    Build failed with 1 errors and 0 warnings...
     
  2. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,418
    2,788
    Jan 21, 2010
  3. roltex_rohit123

    roltex_rohit123

    92
    0
    Oct 12, 2009
    that didnt work
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-