Dhananjay Khairnar @. Powered by Blogger.

25 March 2017

Line follower car :

Aim:
Create Arduino based Line follower robot from scratch.

It is a machine that follows a line, either a black line on white surface or vise-versa. For Beginners it is usually their first robot to play with. In this tutorial, we will teach you to make the line follower robot move on the line with a type of feedback mechanism. It’s the most basic example of adding small intelligence to a robot, but it’s actually the designer’s intelligence!!

Requirement:
1) Arduino Uno + Arduino IDE
2) DC geared motors x 2
3) Power bank or 9v or 12v Battery
4) IR sensors (ready made or You can make it by your own)
5) Connecting wires
6) Motor driver ready made or Your own.
Working of sensors:

IR light is invisible to human eyes it can be detected using IR sensore. As shown in picture below IR LED which is act as Transmitter and Photo Diode act as receiver. When Infrared Light strike on white surface its get reflect back and received by photo diode, while in other case IR Light is absorb by black surface so Photo diode is ideal stat.
We need to convert these signals to 0-5v so we use OPAM IC lm358 or ready made sensor.
Software Design:
We are designing algorithm for following  conditions detected by IR sensors.

 
In first condition left sensor detect black line so we need to turn lef so both IR sensors should be on white colour. same in other case if right sensor detect black line turn right to come back both sensor to white surface.
now decide the turn mechanism for robot. 

Truth Table:

For Half Turn:
Sensor Left | Sensor Right | Motor Left |  Motor Right
black             black                    off             off
black             white                   off             on
white             black                     on            off
white              white                   on             on

For Full Turn:
Sensor Left | Sensor Right | Motor Left  | Motor Right
black             black                    off             off
black             white                   reverse        forward
white             black                   forward     reverse
white              white                  forward    forward

In above cases
  • half turn: it is stable and less fluctuate robot while running
  • full turn : suitable for hard and narrow turns.
Here we write code for half turn mechanism you can modify code for full turn.
//motor A
#define M11 5
#define M12 6

//motor b
#define M23 7
#define M24 8

//Sensore
#define lSen 3
#define rSen 4

void setup()
{
  pinMode(M11, OUTPUT);
  pinMode(M12, OUTPUT);
  pinMode(M21, OUTPUT);
  pinMode(M22, OUTPUT);
  pinMode(lSen,INPUT);
  pinMode(rSen,INPUT);
   
  digitalWrite(M11,LOW);
  digitalWrite(M12,LOW);
  digitalWrite(M21,LOW);
  digitalWrite(M21,LOW);

  delay(1000);
}

void loop()
{
  readLsen = digitalRead(lSen);
  readRsen = digitalRead(rSen);

  if((readLsen == 0) && (readRsen == 0))//if both sensors on black colour then stop both motors
  {
     stop();
  }
  else if((readLsen == 1) && (readRsen == 0))//if left sensor on white and right sensor on black turn right
  {
    turnRight();
  }
  else if((readLsen == 0) && (readRsen == 1))//if left sensor on black and right sensor on white turn left
  {
    turnLeft(); 
  }
  else if((readLsen == 1) && (readRsen == 1))//if both sensor on white move forward
  {
     moveForward();
  }
}

void turnRight() {
  digitalWrite(M11, LOW);
  digitalWrite(M12, LOW);
  digitalWrite(M21, HIGH);
  digitalWrite(M22, LOW);
}
void stop () {
  digitalWrite(M11, LOW);
  digitalWrite(M12, LOW);
  digitalWrite(M21, LOW);
  digitalWrite(M22, LOW);
}
void turnLeft() {
  digitalWrite(M11, HIGH);
  digitalWrite(M12, LOW);
  digitalWrite(M21, LOW);
  digitalWrite(M22, LOW);
}
void moveForward() {
  digitalWrite(M11, HIGH);
  digitalWrite(M12, LOW);
  digitalWrite(M21, HIGH);
  digitalWrite(M22, LOW);
}
void reverse(){
  digitalWrite(M11, LOW);
  digitalWrite(M12,HIGH);
  digitalWrite(M21, LOW);
  digitalWrite(M22, HIGH);
}

Upload this sketch in Arduino and go through hardware design.

Hardware Design:


Components and Their use:

  • 12V DC motor: If a DC power is passed on a DC motor, it will produce torque. The torque created will lead to the rotation of the wheels. It will only operate on the direct current. Here, two 12V DC motors are used. -> 300rpm,12v,DC motor 

    • Zero PCB :  it is very rasy to beginners for creating their circuits on Zero PCB.->10x10cm
    • Battery: This robot is powered by a battery. One 9V battery is enough to perform this process. For more usages, four 9V batteries may be required.-> 9v or powerbank
     
    • IR sensor circuit: This process requires two IR sensor circuits. An IR sensor circuit will include an IC LM358N, potentiometer, IR receiver, and IR transmitter for sensing the black lines or go for Ready made sensor here I used one ready made and one is made by me on zero pcb .
     
    • Battery connector: It is used to connect the battery with the circuit.
     
    • IC LM358N: It is an operational amplifier or comparator used to evaluate the voltage current. The high amount of voltage gained will be considered as the output. It is one of the main components of an IR sensor circuit.
    • IC L293D: It allows the DC motor to run in both front and back directions. It consists of up to 16 pins.
    here mine is four motor driver but I am using only two motor driver.
    • Two plastic wheels: The plastic wheels will be connected to the DC motors. As soon as they create the torque, these wheels will help the robot to move.

    • Ball wheel: The castor wheel or ball wheel is used to make the movements easy and quick even it has large components on its top. In this process, a small stainless steel castor could be the best one to use. 
    • Wires (single-core-multi stand & single-core-single stand): single core multi stand wires are implemented for connecting the motor drives, and the single core single stand wires are used to connect on the zero PCB. Two meters of each wire will be required.

    • Chasee mounting :
     Chasee can be made with Metal,Hard Plastic, Plywood or Acrylic sheet. In image I made This chasee with acrylic sheet and drill it to fit L shape motor holding clips.

      Final Connection diagram with Arduino.
      Here I mount L293d motor driver on Arduino but you can use Arduino motor shield instead.



      Make all connections shown in figure and assemble it on chasee use double side tape for attach sensors and battery to chasee or use spacer and screw to tight all parts.

       

      Thank you. if you like post please like it

      About DK

      Hi, My Name is DK. I am a embedded system designer and embedded programmer. I am a certified holder of Diploma in Embedded system designing. We have a team of professinal programmers, developers work together and implement innovative concepts.

      0 comments :

      Post a Comment