PID Based Line Follower

Thanks Simple ! I got those

Thanks Simple ! 
I got those standoffs from Dagu, they fit the M3 screw. :slight_smile:

Sorry, I don’t have the exact measures of the threads. 

rightMotor1, rightMotor2 & leftMotor1, leftMotor2

What is the use of the following constant variable?

#define rightMotor1 5

//#define rightMotor2 4

 #define leftMotor1 6

//#define leftMotor2 13

Aren’t there just 2 motors? What is the 1&2 mean? 

Hello there spdboyz,Yes

Hello there spdboyz,

Yes there are just two motors, but these are dc motors, not servos ( which can be programmed directly ) ,  so we need a motor driver IC to control the speed and direction. Motor driver ICs use something called H-Bridges. Google “H-Bridge” for more info on this. I am sure you will find plenty of information.

As for the code, it mentions:

#define rightMotor1 5

#define rightMotor2 4

#define leftMotor1 6

#define leftMotor2 13

The 1s and 2s, simply put, denote the pins of the motor as each motor has two terminals. We control the direction and speed of these motors by supplying a logic voltage from the microcontroller to the motor driver IC. Thus, the 1s and 2s are control lines to which logic voltage is supplied, not to power up the motors, but just to determine the speed and direction.

As you may notice, there are 4 outcomes.

if 1 is high and 2 is low, your motor rotates clockwise.

if 1 is low and 2 is high, it’s the reverse, and you motor rotates anti-clockwise.

if both the pins are low, then nothing happens, your motor doesn’t rotate.

and if both are high, well, i haven’t tried this, but people say that your motor will get toasted. :smiley:

And programming these motors depends upon the pinouts of the specific motor driver ICs you are using. For example: the L293D and the TB6612FNG have slightly different pinouts. So it all depends on the motor driver you are using.

Google and LMR are your best friends, so good luck.

Ashim

 

Even if im still a begginer

maybe i can help your question “spdboyz”

 

HERE YOU GO!!!

https://fbcdn-sphotos-b-a.akamaihd.net/hphotos-ak-ash3/p480x480/1521416_626562530733370_246119875_n.jpg

 

#define motorPower 8this is

#define motorPower 8

this is the STBY pin from driver?

correct! you need to set it

correct! you need to set it to HIGH for the motors to turn.

thanks Verde. But maybe you

thanks Verde. But maybe you could try posting the whole photo in the comment instead of just the link?

Cheers!

 

1 Like

Where to get parts

Dai, where did you get those parts and components in Nepal…

I don’t think you’ll get the

I don’t think you’ll get the exact same components here in Nepal. Apart from the microcontroller, I ordered the rest from Pololu      (an international robot store). You might want to do a quick google search.  

Its costing alot with so

Its costing alot with so much of shipping charges at pololu website. Just wanna know how much did it cost you for all the required components??

And how did you ordered those?? Did you pay with credit card at their website or used services as harilo.com 

Well, the total cost was the

Well, the total cost was the item price + shipping + tax. (that’s obvious!)

I ordered those via my relatives.

And yes, used a credit card.

If you have more questions, please post in the forum, not here. We can discuss there. 

Doubt, but built it!!

Hai, I built this line follower. But when I tried auto-calibration, it shows ‘turn_right’ was not declared in this scope.

Code

Can you please give me the code for auto-calibration?

4 sensor

I want to make a 4 sensor Line Follower, changing the NUM_SENSORS to 4 and making the appropriate changes in the code will the robot work? , Also i would be using IR array with digital outputs.

Advice

Hey guys, I just got my robot to work and I wanted to share some words of advice with you. Don’t worry, I won’t spoil anything that the author hasn’t already mentioned.

1. The white background and black lane REALLY MATTERS. I thought I could get away with a blue lane on my garage gray floor but it doesn’t work. The black and white contrast can’t be comprimised.

2. All the connections and directions are perfect, the only thing that needs to be changed is the kd and kp.

3. The author is right about the kd being 20 times bigger than the kp. I tried a bunch of different values and it doesn’t seem to matter what values for kd and kp are choosen as long as the ratio is maintained.

Thats all folks, happy robot building.

PID

Hello,

Can somebody help me about PID?

I really do not know how to set up the the cicuit, connections (I might not understand about PID) to get the value for Kp and Kd. Can somebody give me a step by step on how to experimenting the PID? Please. I really need help.

Code modification

Hello sir, this robot is awesome.

im doing this robot to follow black line which the line can be bend on right side as well as left side.

Can you help me by giving the code for the above problem.

Thank you sir.

My e-mail : [email protected]

auto calibration code

//sag  = right
//sol = left

 

 for (int i = 0; i < 250; i++)
     {   if ( 0 <= i && i < 5   )  hafifsagadon();
         if ( 5 <= i && i  < 15   )  hafifsoladon(); 
         if ( 15 <= i && i < 25   )  hafifsagadon();
         if ( 25 <= i && i < 35   )  hafifsoladon(); 
        if ( 35 <= i && i < 45   )  hafifsagadon();
         if ( 45 <= i && i < 55   )  hafifsoladon(); 
         if ( 55 <= i && i < 60   )  hafifsagadon();
         if ( i >= 60  )  {digitalWrite(motorpower,LOW); delay(3);}
         qtrrc.calibrate(); 
       delay(4);
      } 
.
.
.
 

Void loop(){

}

void motorkontrol(int sagmotorpwm, int solmotorpwm){
  digitalWrite(motorpower, HIGH);

  if(sagmotorpwm<=0) {
      sagmotorpwm=abs(sagmotorpwm);
      digitalWrite(sagmotor1, LOW);
      digitalWrite(sagmotor2, HIGH);
      analogWrite(sagmotorpwmpin, sagmotorpwm);
    }
  else {
      digitalWrite(sagmotor1, HIGH);
      digitalWrite(sagmotor2, LOW);
      analogWrite(sagmotorpwmpin, sagmotorpwm);
  }

  if(solmotorpwm<=0) {
     solmotorpwm=abs(solmotorpwm); //
     digitalWrite(solmotor1, LOW);
     digitalWrite(solmotor2, HIGH);
     analogWrite(solmotorpwmpin, solmotorpwm);
    }

   else {
    digitalWrite(solmotor1, HIGH);
    digitalWrite(solmotor2, LOW);
    analogWrite(solmotorpwmpin, solmotorpwm);
   }
}

void frenle(){motorkontrol(0,0);}
void hafifsagadon(){motorkontrol(70,-70);}
void sertsagadon(){motorkontrol(0,250);}
void hafifsoladon(){motorkontrol(-70,70);}
void sertsoladon(){motorkontrol(250,0);}
void sagdan180don(){motorkontrol(-200,200);}
void soldan180don(){motorkontrol(200,-200);}
void geri(){motorkontrol(-200,-200);}

 

contradiction

Just one questions: do you are sure that line sensors that you used are not analog? In your picture we can see QTR-8RC which is connected to analog pins of Arduino board (accordingly to your diagram). All of us know the QTR-8RC is the digital module. Thanx!

questions

1. If the width of the line it is following would change(from thin lines to thick ones/vice versa), what changes should I undergo?

2. How much did you actually spend for the robot?($)

3. How many trials did you make before achieving your goal? (fast and accurate line follower robot)

4. Is it possible to make a shorter codings?

5.Are there any other alternatives in making this robot?

Any response would be very much appreciated.Thanks