line follower surveillance...

9
Line Follower Surveillance Robot Department of EEE, AHSANULLAH UNIVERSITY OF SCIENCE AND TECHNOLOGY, Dhaka, Bangladesh. 1. Introduction Line follower robot is a basic of all kinds of robot. A robot must follow something to do its desire works. For a line follower robot, a robot must have to follow the line given. 2. Theory (a) Arduino Uno: The Arduino Uno is a microcontroller board based on the ATmega328. It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz ceramic resonator, a USB connection, a power jack, an ICSP header, and a reset button. It contains everything needed to support the microcontroller; simply connect it to a computer with a USB cable or power it with a AC-to-DC adapter or battery to get started. Features of Arduino Uno : Microcontroller : ATmega328 Operating Voltage: 5V Input Voltage: 7-12 V Digital I/O Pins: 14 Analog Pins: 6 DC current per I/O pin: 40ma Flash memory: 32 kb SRAM: 2 kb Clock Speed: 16 MHz Fig : Arduino Uno (b) Adafruit Motor Driver Shield: The motor driver shield is used , is designed by Adafruit where two L293D chips are used to control 4 DC motors and 74HC595N chip is used to control 2 servo motors. It has also a reset button. This motor driver shield is to be set on Arduino uno. Features of Motor Driver Shield: Chipset : Two L293D & One 74HC595N chipset Provided current rate: 0.6A each chipset Analog Pin: 6 Voltage Terminals : 5v & 9v External Supplies: A 2 pin terminal blocks to supply external power to motors. Fig : Adafruit Motor Driver Shield 3. Equipments To build this line follower robot we have used the equipments given below (a) Arduino Uno (b) Adafruit Motor Driver Shield V1 (c) Rover Chassis

Upload: others

Post on 18-Oct-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Line Follower Surveillance Robotfiles.aust-eee-2211-project.webnode.com/200000090-c2ca6c3c6a/Li… · (b) Adafruit Motor Driver Shield: The motor driver shield is used , is designed

Line Follower Surveillance Robot Department of EEE, AHSANULLAH UNIVERSITY OF SCIENCE AND TECHNOLOGY, Dhaka, Bangladesh.

1. Introduction

Line follower robot is a basic of all kinds of robot. A robot

must follow something to do its desire works. For a line

follower robot, a robot must have to follow the line given.

2. Theory

(a) Arduino Uno: The Arduino Uno is a

microcontroller board based on the ATmega328. It

has 14 digital input/output pins (of which 6 can be

used as PWM outputs), 6 analog inputs, a

16 MHz ceramic resonator, a USB connection, a

power jack, an ICSP header, and a reset button. It

contains everything needed to support the

microcontroller; simply connect it to a computer with

a USB cable or power it with a AC-to-DC adapter or

battery to get started.

Features of Arduino Uno :

Microcontroller : ATmega328

Operating Voltage: 5V

Input Voltage: 7-12 V

Digital I/O Pins: 14

Analog Pins: 6

DC current per I/O pin: 40ma

Flash memory: 32 kb

SRAM: 2 kb

Clock Speed: 16 MHz

Fig : Arduino Uno

(b) Adafruit Motor Driver Shield: The motor

driver shield is used , is designed by Adafruit where

two L293D chips are used to control 4 DC motors

and 74HC595N chip is used to control 2 servo

motors. It has also a reset button. This motor driver

shield is to be set on Arduino uno.

Features of Motor Driver Shield:

Chipset : Two L293D &

One 74HC595N chipset

Provided current rate: 0.6A each chipset

Analog Pin: 6

Voltage Terminals : 5v & 9v

External Supplies: A 2 pin terminal blocks to supply

external power to motors.

Fig : Adafruit Motor Driver Shield

3. Equipments

To build this line follower robot we have used the

equipments given below

(a) Arduino Uno

(b) Adafruit Motor Driver Shield V1

(c) Rover Chassis

Page 2: Line Follower Surveillance Robotfiles.aust-eee-2211-project.webnode.com/200000090-c2ca6c3c6a/Li… · (b) Adafruit Motor Driver Shield: The motor driver shield is used , is designed

(d) 2 DC motors

(e) A Servo Motor :

DM-S0090M

(f) LDR

(g) LED

(h) Jump Wires

(i) Plexi Glass

(j) 11.5v Li-po Battery (35c) [3 Cells 2200mAh]

(k) 9V Battery

(l) A Digital Camera

(m) Other necessary tools

4. Circuit Diagram

Fig: Circuit Diagram of Sensor board

Fig: Diagram of a Line follower robot

5. Procedure > At first we have to create a black line with black

tape on a white surface like white sheet.

> Then we will use a rover chassis (built in 2 DC

motors) as a main body of line follower robot.

> We will use a sensor board which is mounted

with black tape at the front of the chassis. In this

sensor board we supplies 5v internally through the 5v

terminal of the motor driver shield.

The main purpose of this robot is to follow the given black

line on a white surface. First we have to take the serial of

each LDR of the sensor board of black line and white

surface through arduino serial monitor using this code.

int sensePin =0;

void setup()

{

analogReference(DEFAULT);

Serial.begin(9600);

}

void loop()

{

Serial.println(analogRead(sensePin));

delay(500

Then we will notice the serial of LDR like this

After getting all the serials of all LDR. We can set

the ranges of them.

>After that we will connect one DC motor with a M1

terminal and another with M4 terminal of the motor

driver shield.

> Then we will connect the servo motor DM-S0090M

at Ser1 terminal.

> We will use 3 Cells 2200mAh Li-po Battery (35c)

to give the motors enough power to operate which should

be connect with the external power supply terminal.

>We use enough plexi glass to decorate the whole

things neatly.

>Then we use Digital camera which is set on the top of

the body , where the servo motor is set to be operated to

press the shutter button of the camera.

> We can use check point where camera is to be

snapped by the servo by using a bit black tape on the line.

> After doing proper code on servo we can run this

robot.

CODE:

Page 3: Line Follower Surveillance Robotfiles.aust-eee-2211-project.webnode.com/200000090-c2ca6c3c6a/Li… · (b) Adafruit Motor Driver Shield: The motor driver shield is used , is designed

#include <AFMotor.h> // Motor Library add

#include <Servo.h> // Servo's Library add

Servo myservo;

Servo myservo2;

int pos = 0;

int count, count2,count3;

AF_DCMotor motor(1); //Left MOTOR

AF_DCMotor motor2(4); //Right MOTOR

int sensePin0 = 0; //Start from left sense pin

int sensePin1 = 1;

int sensePin2 = 2;

int sensePin3 = 3;

int sensePin4 = 4;

int value1, value2,value3, value4, value5;

int convalue1, convalue2,convalue3,

convalue4,convalue5;

void setup()

{

analogReference(DEFAULT);

myservo.attach(9);

myservo2.attach(10);

}

void loop()

{

value1 = analogRead(sensePin0); // Value of

LDR1

value2 = analogRead(sensePin1); // Value of

LDR2

value3 = analogRead(sensePin2); // Value of

LDR3

value4 = analogRead(sensePin3); // Value of

LDR4

value5 = analogRead(sensePin4); // Value of

LDR5

{

{if ( value1 >=1 && value1 <= 8 )

convalue1 = 0 ; //Range of serial of LDR1 on

Black

else if ( value1 >= 9 && value1 <= 20)

convalue1 = 1 ;} //; //Range of serial of LDR1

on White

{if ( value2 >= 1 && value2 <= 8)

convalue2 = 0 ; ; //Range of serial of LDR2 on

Black

else if ( value2 >=9 && value2 <= 20)

convalue2 = 1 ;} //; //Range of serial of LDR2 on

White

{if ( value3 >= 1 && value3 <= 15)

convalue3 = 0 ; ; //Range of serial of LDR3 on

Black

else if ( value3 >= 16 && value3 <= 25)

convalue3 = 1 ;} //; //Range of serial of LDR3 on

White

{if ( value4 >= 1 && value4 <= 8)

convalue4 = 0 ; ; //Range of serial of LDR4 on

Black

else if ( value4 >= 10 && value4 <=20 )

convalue4 = 1 ;} //; //Range of serial of LDR4 on

White

{if ( value5 >= 1 && value5 <= 4)

convalue5 = 0 ; ; //Range of serial of LDR5 on

Black

else if ( value5 >= 5 && value5 <= 20)

convalue5 = 1 ;} //; //Range of serial of LDR5 on

White

Page 4: Line Follower Surveillance Robotfiles.aust-eee-2211-project.webnode.com/200000090-c2ca6c3c6a/Li… · (b) Adafruit Motor Driver Shield: The motor driver shield is used , is designed

} // We assume the position of the LDR like

LDR1-LDR2-LDR3-LDR3-LDR4-LDR5

if (convalue1==1 &&

convalue2==1 &&

convalue3==0 && // Straight

convalue4==1 &&

convalue5==1 ) //Combination 11011

{ motor.setSpeed(120);

motor2.setSpeed(120);

motor.run(FORWARD);

motor2.run(FORWARD);}

else if (convalue1==1 &&

convalue2==0 &&

convalue3==0 && //Bit Left turn

convalue4==1 &&

convalue5==1 ) // Combination 10011

{ motor.setSpeed(60);

motor2.setSpeed(120);

motor.run(FORWARD);

motor2.run(FORWARD);}

else if (convalue1==0 &&

convalue2==0 &&

convalue3==0 && //Sharp Left Turn

convalue4==1 &&

convalue5==1 ) //Combination 00011

{ motor.setSpeed(100);

motor2.setSpeed(120);

motor.run(BACKWARD);

motor2.run(FORWARD);}

else if (convalue1==1 &&

convalue2==1 &&

convalue3==0 && //Bit Right turn

convalue4==0 &&

convalue5==1 ) //Combination 11001

{ motor.setSpeed(120);

motor2.setSpeed(60);

motor.run(FORWARD);

motor2.run(FORWARD);}

else if (convalue1==1 &&

convalue2==1 &&

convalue3==0 &&

convalue4==0 && // Right SHARP TURN

convalue5==0 ) //Combination 11000 {

motor.setSpeed(120);

motor2.setSpeed(100);

motor.run(FORWARD);

motor2.run(BACKWARD);}

else if ( convalue1==1 &&

convalue2==0 && //Left TURN

convalue3==1 &&

convalue4==1 &&

convalue5==1 ) //Combination 10111

{ motor.setSpeed(60);

motor2.setSpeed(150);

motor.run(BACKWARD);

motor2.run(FORWARD);}

else if ( convalue1==1 &&

convalue2==1 &&

convalue3==1 &&

convalue4==0 && //Right TURN

convalue5==1 ) //Combination 11101

{ motor.setSpeed(150);

motor2.setSpeed(60);

motor.run(FORWARD);

motor2.run(BACKWARD);}

else if ( convalue1==1 &&

convalue2==1 && //Bit Right turn

convalue3==1 &&

convalue4==1 &&

convalue5==0 ) //Combination 11110

{ motor.setSpeed(150);

Page 5: Line Follower Surveillance Robotfiles.aust-eee-2211-project.webnode.com/200000090-c2ca6c3c6a/Li… · (b) Adafruit Motor Driver Shield: The motor driver shield is used , is designed

motor2.setSpeed(80);

motor.run(FORWARD);

motor2.run(BACKWARD);}

else if ( convalue1==0 &&

convalue2==1 &&

convalue3==1 &&

convalue4==1 && //Bit Left turn

convalue5==1 ) //Combination 01111

{ motor.setSpeed(80);

motor2.setSpeed(150);

motor.run(BACKWARD);

motor2.run(FORWARD);}

else if ( convalue1==1 &&

convalue2==1 &&//Right Turn

convalue3==1 &&

convalue4==0 &&

convalue5==0 ) //Combination 11100

{ motor.setSpeed(150);

motor2.setSpeed(100);

motor.run(FORWARD);

motor2.run(BACKWARD);}

else if ( convalue1==0 &&

convalue2==0 &&

convalue3==1 && //Left Turn

convalue4==1 &&

convalue5==1 ) //Combination 00111

{ motor.setSpeed(100);

motor2.setSpeed(150);

motor.run(BACKWARD);

motor2.run(FORWARD);}

else if ( convalue1==1 &&

convalue2==1 &&

convalue3==1 && //Backward

convalue4==1 &&

convalue5==1 ) //Combination 11111

{ motor.setSpeed(120);

motor2.setSpeed(120);

motor.run(BACKWARD);

motor2.run(BACKWARD);}

else if ( convalue1==0 &&

convalue2==0 &&

convalue3==0 && //Right Sharp Turn

convalue4==0 &&

convalue5==1 ) //Combination 00001

{ motor.setSpeed(60);

motor2.setSpeed(120);

motor.run(BACKWARD);

motor2.run(FORWARD);}

else if ( convalue1==1 &&

convalue2==0 &&

convalue3==0 && //Left Sharp Turn

convalue4==0 &&

convalue5==0 ) //Combination 10000

{ motor.setSpeed(120);

motor2.setSpeed(60);

motor.run(FORWARD);

motor2.run(BACKWARD);}

else if ( convalue1==0 &&

convalue2==0 &&

convalue3==0 && //Stop

convalue4==0 &&

convalue5==0 ) //Combination 00000

{ motor.setSpeed(0);

motor2.setSpeed(0);

motor.run(FORWARD);

motor2.run(FORWARD);

{ for(pos = 0; pos < 45; pos += 45) // goes from

0 degrees to 45 degrees

{ // Click Down The servo

myservo.write(pos); // tell servo to go to

position in variable 'pos'

delay(1000);

Page 6: Line Follower Surveillance Robotfiles.aust-eee-2211-project.webnode.com/200000090-c2ca6c3c6a/Li… · (b) Adafruit Motor Driver Shield: The motor driver shield is used , is designed

// waits 1s for the servo to

reach the position

}

for(pos = 45; pos>=1; pos-=45) // goes from 45

degrees to 0 degrees

{ // Click up the servo

myservo.write(pos); // tell servo to go to

position in variable 'pos'

delay(1500); // waits 1.5s for the

servo to reach the position

}

{motor.setSpeed(120);

motor2.setSpeed(120);

motor.run(FORWARD);

delay(500);

motor2.run(FORWARD);

delay(500);

}

}

}

}

6. Working Principles

When we put the robot on line, the light of LED will reflect

to the LDR. The rate of reflection from the black line and

white surface are different. From the rate of reflection to

the LDR, (the ranges were preset in the code) the motors

will rotate as we coded. If we assume the reflection ranges

from black line is 0 and the ranges from the white

surface is 1, then to go straight it has to be :

1 1 0 1 1

LDR1 LDR2 LDR3 LDR4 LDR5

Then the rpm of both motors are same.

Then, to turn right side, this combination may be happened

11100, 11000, 11001, 11101, 11110

To turn right side the rpm of right motor should be less than

the left motor. For sharp turn right motor should be run

Backward and left motor should be run Forward at same

rpm.

Then, to turn left side, this combination may be happened

00111, 00011, 10011, 10111, 10000

To turn right side the rpm of left motor should be less than

the right motor. For sharp turn left motor should be run

Backward and right motor should be run Forward at same

rpm.

If there’s no line to follow, like this combination

11111

Both motors will run Backward, to rejoin the line.

We have made a checkpoint, where the LDR combination

will be

00000

When robot will reach the check point, the rpm of both

motors will be 0 that means it’ll stop. Then the servo blade

will click down to the shutter of the camera and push it

over 1 second which is enough to snap a photo.

After 2.5 second both motor will run forward to follow the

line. Then the whole process will be done like decrypted

before.

7. Troubleshooting

(a) At first we build the sensor board, then took the value

of each LDR and with the value of LDR we wrote the code

using the ranges of serial. But our robot did not follow the

line. Then we figure it out that the light of surrounding

interrupted LDR so the value was changing time to time.

To solve this problem we mounted every LED and LDR

with black tape very well and then we mounted the the

whole sensor board.

From then it followed the line perfectly.

(b) At first our robot run too slowly because we were

using a battery which was unable to supply enough power

to run the robot fast.

Then we used Li-Po 14.5v Li-po Battery (35c) [4 Cells

2200mAh] as external power to run the motors. As we

Page 7: Line Follower Surveillance Robotfiles.aust-eee-2211-project.webnode.com/200000090-c2ca6c3c6a/Li… · (b) Adafruit Motor Driver Shield: The motor driver shield is used , is designed

changed the battery the value of LDR changed. So we

again took the value and run the programme. And robot

responded perfectly.

(c) The very next day when we were testing our robot’s

performance. After completing the first Lap of our track

suddenly we saw fire and smoke on the motor shield. Then

we figured out that our motor shield dead.

We were using that battery directly to the motor shield to

run which was excessive. Then we changed the battery

again with 11.5 V Li-po (3 cells) 35c also a new motor

shield. Then we used 7809 voltage regulator IC to regulate

the voltage from 11.5v to 9 v.

(d) After running our robot for some times suddenly it

stopped. And found that the heat of the 7809 was very high

and it was already damaged.

To solve this problem we used heat-sink with a new 7809

and connect again. Then everything was going okay.

(e) After that we set our camera on the top to be operated

by a servo motor. But we purchased a continuous rotating

servo. Which was unable to control by our code.

Then we changed the servo and bought DM-S0090M. It

could be controlled easily by our code.

(f) When we were running our robot with servo we found

that when was operating , the brightness of the LED

decreasesd. As a result the value of LDR changed so it

was not running and robot also didn’t follow the line.

To solve this problem we used an extra 9V battery of

250mA to operate the Arduino and we

7. Application in Future

To monitor a certain area of a city it can be used. It will

capture the footage of different spot of that area which

is helpful to avoid the unsocial activities by monitoring.

To observe the terrorist activity it can be used as a drone in

an area.

To see the condition of an disastrous and dangerous area it

can be used.

It can be used to get footage of places where human can not

access like Underground mine, Narrow Sewerage

tunnel.

8. Images

Page 8: Line Follower Surveillance Robotfiles.aust-eee-2211-project.webnode.com/200000090-c2ca6c3c6a/Li… · (b) Adafruit Motor Driver Shield: The motor driver shield is used , is designed
Page 9: Line Follower Surveillance Robotfiles.aust-eee-2211-project.webnode.com/200000090-c2ca6c3c6a/Li… · (b) Adafruit Motor Driver Shield: The motor driver shield is used , is designed

SUBMITTED BY

Section : A

Semester : 2.2

Group : 2

Group Member :

Rifayet Hasan Sajol (12.01.05.014)

Chowdhury Fakrul Alam

(12.01.05.017)

Shafkat Tasnim (12.01.05.037)

Md. Motiur Rahman Sagar

(12.01.05.038)

Sohan Bin Anwer (12.01.05.049)