go_away

Author Topic: advance line following robot  (Read 739 times)

0 Members and 1 Guest are viewing this topic.

Offline shreyanshTopic starter

  • Jr. Member
  • **
  • Posts: 9
  • Helpful? 0
advance line following robot
« on: December 18, 2012, 11:08:50 AM »
please some one help me to programme advance line following robot.I have spent a lot of money on making it.



thanks.


Offline happytriger2000

  • Beginner
  • *
  • Posts: 4
  • Helpful? 0
Re: advance line following robot
« Reply #1 on: December 20, 2012, 05:54:54 AM »
Tips for you:
 search Parallax for BoeBot, it uses PID control on 2 led receiver

Offline jwatte

  • Supreme Robot
  • *****
  • Posts: 1,343
  • Helpful? 81
Re: advance line following robot
« Reply #2 on: December 20, 2012, 11:29:07 AM »
Write a program to:

1) Read sensors
2) Give motor control based on sensor readings
3) Repeat

Without more information about what controller you're using for the robot, what the sensors are, or anything else about the robot, we can't really help any more than that.

Offline billhowl

  • Supreme Robot
  • *****
  • Posts: 375
  • Helpful? 32
  • Your success is in your hands.
Re: advance line following robot
« Reply #3 on: December 22, 2012, 04:19:23 AM »
Is it this advance line following robot
http://www.societyofrobots.com/member_tutorials/node/350
Here is the source code
http://www.societyofrobots.com/member_tutorials/files/Code%20V2.2(SOR)_0.zip

Code: [Select]
#include "LotL.h"

SIGNAL (SIG_INTERRUPT0) // left switch
{
delay(0.3);

switch(menu)
{
case 0:
if(pause == true)
pause = false;
menu = 10;
break;
case 10:
if(pause == false)
pause = true;
menu = 0;
break;
case 20:
menu = 80;
break;
case 30:
case 40:
case 50:
case 60:
case 70:
case 80:
menu -= 10;
break;
case 25:
maxspeed--;
break;
case 35:
basespeed--;
break;
case 45:
Kp--;
break;
case 55:
Ki--;
break;
case 65:
Kd--;
break;
}
DispMenu(menu);
}

SIGNAL (SIG_INTERRUPT2) // middle switch
{
delay(0.3);
switch(menu)
{
case 20:
case 30:
case 40:
case 50:
case 60:
case 70:
menu += 5;
break;
case 80:
menu = 0;
break;
case 25:
case 35:
case 45:
case 55:
case 65:
case 75:
menu -= 5;
break;
}
DispMenu(menu);



}

SIGNAL (SIG_INTERRUPT1) // right switch
{
delay(0.3);

switch(menu)
{
case 0:
case 10:
menu = 20;
break;
case 20:
case 30:
case 40:
case 50:
case 60:
case 70:
menu += 10;
break;
case 80:
menu = 20;
break;
case 25:
maxspeed++;
break;
case 35:
basespeed++;
break;
case 45:
Kp++;
break;
case 55:
Ki++;
break;
case 65:
Kd++;
break;
}
DispMenu(menu);
}

int main(void)
{
unsigned int p;

//call all initializing functions
InitPorts();
InitInterrupts();
InitPWM();
InitLCD(0); //LS_BLINK|LS_ULINE
LCDClear();
sei(); //enables interrupts

//prints the openning screen
BacklightOn();
LCDClear();
LCDGotoXY(0,0);
LCDWriteString("Lord ofthe Lines");
delay(1);

LCDGotoXY(3, 1);
LCDWriteString("pratheek");
delay(1);
DispMenu(0); //displays home screen

while(true)
{
if(pause == false)
{
CalcError();

if((s1+s2+s3+s4+s5+s6+s7+s8) == 0) //robot has overshot
{
if(lastreading == 'r') //checks if the last sensor to the activated was right
{
RightMB(); //turn right at full speed
LeftMF();
OCR1A = 255;
OCR1B = 255;
}

else if(lastreading == 'l') //checks if the last sensor to the activated was left
{
RightMB(); //turn left at full speed

LeftMF();
OCR1A = 255;
OCR1B = 255;
}
}


else  //robot on line
{
P = error * Kp;

I += error;
I = I * Ki;

D = error - perror;

correction = P + I + D;

rightpulse =  basespeed + correction;
leftpulse = basespeed - correction;

LeftMF();
RightMF();


if(leftpulse > 255)
leftpulse = 255;

if(rightpulse > 255)
rightpulse = 255;

OCR1A = leftpulse;
OCR1B = rightpulse;
}
}

_delay_ms(10);
}

}

void DispMenu(int m)
{
switch(m)
{
case 0:

LCDClear();
LCDGotoXY(0, 0);
LCDWriteString("Lord ofthe Lines");

LCDGotoXY(0 ,1);
LCDWriteString("Start");
LCDGotoXY(8 ,1);
LCDWriteString("Settings");
break;

case 10:
LCDClear();
LCDGotoXY(0, 0);
LCDWriteString("Lord ofthe Lines");

LCDGotoXY(0 ,1);
LCDWriteString("Pause");
LCDGotoXY(8 ,1);
LCDWriteString("Settings");
break;

case 20:
LCDClear();
LCDGotoXY(0, 0);
LCDWriteString("Settings");

LCDGotoXY(0, 1);
LCDWriteString("1. Max Speed");
break;

case 30:
LCDClear();
LCDGotoXY(0, 0);
LCDWriteString("Settings");

LCDGotoXY(0, 1);
LCDWriteString("2. Base Speed");
break;

case 40:
LCDClear();
LCDGotoXY(0, 0);
LCDWriteString("Settings");

LCDGotoXY(0, 1);
LCDWriteString("3. Propotional");
break;

case 50:
LCDClear();
LCDGotoXY(0, 0);
LCDWriteString("Settings");

LCDGotoXY(0, 1);
LCDWriteString("4. Integral");
break;

case 60:
LCDClear();
LCDGotoXY(0, 0);
LCDWriteString("Settings");

LCDGotoXY(0, 1);
LCDWriteString("5. Derivative");
break;

case 70:
LCDClear();
LCDGotoXY(0, 0);
LCDWriteString("Settings");

LCDGotoXY(0, 1);
LCDWriteString("7. Adjust Sensor");
break;

case 80:
LCDClear();
LCDGotoXY(0, 0);
LCDWriteString("Settings");

LCDGotoXY(0, 1);
LCDWriteString("6. Done");
break;

case 25:
LCDClear();
LCDGotoXY(0, 0);
LCDWriteString("Settings");

LCDGotoXY(0, 1);
LCDWriteString("Max Speed: ");
LCDWriteInt(maxspeed, 3);
break;

case 35:
LCDClear();
LCDGotoXY(0, 0);
LCDWriteString("Settings");

LCDGotoXY(0, 1);
LCDWriteString("Base Speed: ");
LCDWriteInt(basespeed, 3);
break;

case 45:
LCDClear();
LCDGotoXY(0, 0);
LCDWriteString("Settings");

LCDGotoXY(0, 1);
LCDWriteString("Propotional: ");
LCDWriteInt(Kp, 2);
break;

case 55:
LCDClear();
LCDGotoXY(0, 0);
LCDWriteString("Settings");

LCDGotoXY(0, 1);
LCDWriteString("Integral: ");
LCDWriteInt(Ki, 2);
break;

case 65:
LCDClear();
LCDGotoXY(0, 0);
LCDWriteString("Settings");

LCDGotoXY(0, 1);
LCDWriteString("Derivative: ");
LCDWriteInt(Kd, 2);
break;
case 75:
LCDClear();
LCDGotoXY(0, 0);
LCDWriteString("Sensors");
DispAdjustmentMenu();
break;
}
}

void DispAdjustmentMenu(void)
{

LCDGotoXY(0, 1);
LCDWriteInt(s1, 1);

LCDGotoXY(2, 1);
LCDWriteInt(s2, 1);

LCDGotoXY(4, 1);
LCDWriteInt(s3, 1);

LCDGotoXY(6, 1);
LCDWriteInt(s4, 1);

LCDGotoXY(9,1);
LCDWriteInt(s5, 1);

LCDGotoXY(11, 1);
LCDWriteInt(s6, 1);

LCDGotoXY(13, 1);
LCDWriteInt(s7, 1);

LCDGotoXY(15, 1);
LCDWriteInt(s8, 1);


}

Offline jwatte

  • Supreme Robot
  • *****
  • Posts: 1,343
  • Helpful? 81
Re: advance line following robot
« Reply #4 on: December 22, 2012, 08:13:43 PM »
What particular step are you stuck at?
What are you doing?
What do you expect to happen?
What is actually happening?

 


Get Your Ad Here