50
RAFIK HARIRI UNIVERSITY FIRE FIGHTING ROBOT WITH OBSTACLE AVOIDANCE Done by ADHAM EL-AYASS FARAH NASREDDINE RAMI NOUREDDINE Submitted to DR NIZAR AWAR This senior project is submitted in partial fulfillment of the requirements of the BS degree in Mechatronics Engineering major at the College of Engineering at Rafik Hariri University MECHREF, LEBANON April 2013

final bs project

Embed Size (px)

Citation preview

Page 1: final bs project

RAFIK HARIRI UNIVERSITY

FIRE FIGHTING ROBOT WITH OBSTACLE AVOIDANCE

Done by

ADHAM EL-AYASS

FARAH NASREDDINE

RAMI NOUREDDINE

Submitted to

DR NIZAR AWAR

This senior project is submitted in partial fulfillment of the requirements of the BS degree

in Mechatronics Engineering major at the College of Engineering

at Rafik Hariri University

MECHREF, LEBANON

April 2013

Page 2: final bs project

Copy right© 2013, All rights reserved

Adham El-Ayass (20100298)

Farah Nasreddine (20090830)

Rami Noureddine(20090069)

Page 3: final bs project

ii

ABSTRACT

This book focuses on a prototype for a fire fighting robot with an advantage of

obstacle avoidance. It relies on a signal from a fire sensor then moves towards the room. It

also detects the exact place of fire in the room and extinguishes it.

This will be of great importance to people whenever implemented in the industrial

field as it provides safety to houses from fires.

This book presents the whole process to implement such robot, with all the

programming codes, the problems we faced and it opens a door for future improvements to

decrease error and provide more safety.

Page 4: final bs project

iii

ACKNOWLEDGEMENTS

We would like to thank all those who have participated to facilitate our work and

those who have contributed to the completion of this project.

Special thanks to Mr Rami ElKhatib for his valuable contribution and continuous

monitoring.

Thanks to Dr Nizar Awar for his precious support and for his noticeable help.

We would like to dedicate this book to the soul of Farah Nasreddine, an amazing

best friend and a great helper. Without her contribution, none of this would be possible.

I would have never done it without you through the university, since the first year

all the way to the final project. Thank you for being there always for me, inside class as a

fellow student and outside class as my best friend. May god bless your precious soul. You

will always be remembered, I promise.

Adham El-Ayass

Page 5: final bs project

iv

TABLE OF CONTENTS

ABSTRACT............................................................................................................................ii

ACKNOWLEDGMENTS .................................................................................................... iii

TABLE OF CONTENTS........................................................................................................ v

LIST OF FIGURES ............................................................................................................ viii

LIST OF TABLES .................................................................................................................. x

Chapter Page

1. INTRODUCTION .............................................................................................................. 1

1.1. The Problem ......................................................................................................... 1

1.2. Literature Review ................................................................................................ 2

1.3. The Proposal ........................................................................................................ 2

2. PROJECT OVERVIEW ..................................................................................................... 4

2.1. Finite State Machine ............................................................................................ 4

2.2. Required Hardware .............................................................................................. 5

2.3. Software and Programming ................................................................................ 6

3. MECHANICAL DESIGN ................................................................................................ 13

3.1. DC Motor .......................................................................................................... 13

3.1.1 Motor Calculations ............................................................................. 14

3.2. Water Pump ...................................................................................................... 15

Page 6: final bs project

v

4. ELECTRICAL DESIGN .................................................................................................. 16

4.1. Microcontroller .................................................................................................. 16

4.1.1. Definition of Microcontroller ............................................................ 16

4.1.2. Why we chose ATMEGA328 ............................................................ 16

4.1.3. Its Characteristics ............................................................................... 17

4.2. Flame Sensor RB-02S022 ................................................................................. 23

4.2.1. Definition ........................................................................................... 23

4.2.2. Functionality ...................................................................................... 23

4.2.3. Its Connections .................................................................................. 24

4.3. Ultrasonic Sensors ............................................................................................. 25

4.3.1. Definition ........................................................................................... 25

4.3.2. Choice of Sensor ................................................................................. 26

4.3.3. Hc-Sr04 pins ...................................................................................... 26

4.3.3.1. Characteristics ..................................................................... 27

4.3.4. Dyp-Me007 pins ................................................................................. 27

4.3.4.1. Characteristics ..................................................................... 27

4.3.5. Functionality ....................................................................................... 27

4.3.6. Its Connections ................................................................................... 29

4.4. H bridge L293D ................................................................................................. 30

4.4.1. Function of H Bridge ......................................................................... 30

4.4.2. Characteristics ..................................................................................... 30

4.4.3. Its Connections .................................................................................. 31

4.4.4. Description ......................................................................................... 31

Page 7: final bs project

vi

5. ASSEMBLING THE SYSTEM ...................................................................................... 32

5.1. Receiving signal from flame sensor................................................................... 32

5.2. Moving toward the room ................................................................................... 32

5.3. Detecting Obstacle ............................................................................................ 33

5.4. Avoiding Obstacle ............................................................................................. 33

5.4.1. Wall Following Technique ................................................................. 33

5.4.2. Path Following Technique .................................................................. 33

5.5. Detecting place of fire ....................................................................................... 34

5.4. Extinguishing fire .............................................................................................. 35

6. PROBLEMS FACED ...................................................................................................... 36

6.1. Temperature ....................................................................................................... 36

6.2. Sensitivity of Flame Sensor ............................................................................... 36

6.3. Low Torque dc motors ...................................................................................... 36

6.4. Some Hardware were hard to find .................................................................... 37

6.5. Choosing the best parts ..................................................................................... 37

6.6. Software Difficulties ......................................................................................... 37

7. RESULTS AND FUTURE IMPROVEMENTS ............................................................. 38

7.1. Results ................................................................................................................ 38

7.2. Future Improvements ......................................................................................... 38

REFERENCES ..................................................................................................................... 39

Page 8: final bs project

vii

LIST OF FIGURES

Figure Page

1. Fire Safety Important ........................................................................................................ 2

2. Finite State Machine .......................................................................................................... 4

3. DC Motor Modeling ......................................................................................................... 13

4. DC Motor Functionality.................................................................................................... 14

5. Block Diagram of ATMEGA32 ....................................................................................... 18

6. Block Diagram of the AVR Architecture ........................................................................ 19

7. The Parallel Instruction Fetches and Instruction Executions ............................................ 20

8. Single Cycle ALU Operation ............................................................................................ 20

9. On-chip Data SRAM Access Cycles ................................................................................ 20

10. MCU Start-up, RESET Tied to VCC ............................................................................ 21

11. MCU Start-up, RESET Extended Externally ................................................................. 21

12. External Reset During Operation ................................................................................... 22

13. Brown-out Reset During Operation ............................................................................... 22

14. Watchdog System Reset During Operation ................................................................... 23

15. Connection of Flame Sensor to Arduino ........................................................................ 24

16. Flame Sensor Terminals ................................................................................................. 24

17. The two Ultrasonic Sensors ............................................................................................ 25

18. Timing diagram of Hc-Sr04 ............................................................................................ 28

19. Timing diagram of dyp-me007 ....................................................................................... 28

20a. Connection of Hc-Sr04 ................................................................................................. 29

Page 9: final bs project

viii

20b. Connection of Hc-Sr04 ................................................................................................. 30

21. H bridge L293D connections .......................................................................................... 31

22. Proteus Simulation .......................................................................................................... 32

23. Wall Following Technique ............................................................................................. 33

24. Path Following Technique .............................................................................................. 34

Page 10: final bs project

ix

LIST OF TABLES

Table Page

1. Hardware and Functions ...................................................................................... 5

2. Comparison between Distance Measuring Sensors ............................................................... 26

Page 11: final bs project

ii

Page 12: final bs project

`1

CHAPTER 1

INTRODUCTION

1.1 The Problem

As we are living a modern life, we are under the risk of fire. Fire can take place in

any house, school, or any place. It is mostly caused by electric short circuits, or

combustible gases we use at home for heating. Fire causes damage to people and property.

In 2011 in the US, statistics say that “370,000 fires have caused 2520 civilian deaths and

13,910 civilian injuries with damages approximated at 6.9 billion dollars.”

Therefore, to protect ourselves, our families and our houses, we need a safe fire

fighting system to detect and extinguish fires before they spread. What we need is a

computerized fire fighting robot assembled with a network of fire sensors to detect the

smallest fire and fight it.

Other than its main purpose to decrease human and property losses, fire fighting

robots could also be a great support to firemen. By using a robot, firemen do not need to

risk their lives to extinguish fires, especially that the robot is replaceable at any time.

“A robot is a mechanical or virtual artificial agent, usually an electromechanical

machine guided by a computer system or an electronic circuit”. “Robotics is the branch of

technology which deals with designing, construction, operation and application of robots”.

As robotics is an evolving industry and robots are constructed to protect and help humans,

using robots to fight fires seems a good idea.

Page 13: final bs project

`2

Figure 1: Fire Safety Important

1.2 Literature Review

Several engineers have tried to implement the idea of a fire fighting robot in the

industrial field to market. Millions of prototypes are created every year with different

innovations. But till now, fire fighting robots are unavailable in the market due to several

reasons. This type of robots needs a high cost to produce and it is hard to implement.

Moreover, the public opinion prefers to take certain precautions against fires rather

than costly fire systems. Hence, it is not a marketing product. This does not encourage the

industrial field to proceed towards this kind of manufacturing.

1.3 The Proposal

After long researches and hard work, we have reached a prototype of a low cost fire

fighting robot. We have tried through our design to build a robot that can be easily

implemented, easily manufactured, and easily marketed due to its simplicity, availability of

all parts, low cost, fast response and most importantly its main objective to provide safety.

This robot is always on alert to detect any fire with accuracy. With the help of fire

sensors spread in different locations in a house, school or any other faculty, the robot

receives a signal from the central station. It is able to proceed towards the place of the fire

Page 14: final bs project

`3

accordingly and extinguish it. Moreover, if any obstacle is present on the way to the fire,

this robot is able to avoid it through a certain mechanism.

In this book, we would like to discuss thoroughly the whole process of our proposal

from blank, through the whole process of designing and implemented the ideas of three

mechatronics engineers to reach the desired result of the robot to secure places against

fires.

Page 15: final bs project

`4

CHAPTER 2

PROJECT OVERVIEW

2.1 Finite State machine

To start designing our robot, we need to point out the different actions which the

robot will undergo. This can be summarized through the following finite states:

Figure 2: Finite State Machine

State idle: No signal from fire sensors is received and the robot is on alert waiting

for a signal.

State 1: The robot receives a fire signal from the flame. The signal is processed and

the path is loaded. The robot starts moving towards the room.

Page 16: final bs project

`5

State 2: The robot checks for obstacles always. When an obstacle is detected, the

robot avoids it.

Sub-State 1: The robot avoids the obstacle through a certain mechanism.

State 6: The robot finds the fire and extinguishes it through pumping water onto the

fire.

2.2 Required Hardware

Hardware Quantity Function

DC motor 6V 2 To control the movement of the car

Robot Body 1 To fix the motors and other hardware to

Water Pump 1 To pump water to extinguish the fire

L293D H bridge 1 To control the motors to rotate in both positive and negative directions

Flame Sensor 2 To detect the presence of the fire To locate the fire

Ultrasonic sensor hc-sr04

1 To be used in detecting and avoiding obstacles mechanism

Ultrasonic sensor dyp-me007

1 To be used in detecting and avoiding obstacles by measuring distance

Arduino uno model ATMEGA328P

1 To operate the sensors and detect the obstacles

To control the operation of the motors and the water pump

5V voltage regulator 1 To convert the voltage from 12V to 5V

Battery 1 12V power supply

Table 1: Hardware and Functions

Page 17: final bs project

`6

2.3 Software and Programming

The vehicle controller programming code using arduino

#define motora1Pin 4

#define motora2Pin 5

#define motorb1Pin 6

#define motorb2Pin 7

#define trigPin 3

#define echoPin 2

#define trigrightPin 12

#define echorightPin 8

#define flamecarPin A0

#define flame2Pin A1

#define pumpPin 13

int distance = 0;

int distanceright = 0;

int counter;

int coun;

int durationright;

int duration;

int flamesignal1;

int flamesignal2;

unsigned long pulseTime = 0; //to be used in the function of the ultrasonic sensor to

calculate the distance through the high level time

Page 18: final bs project

`7

void setup() {

Serial.begin (9600);

pinMode(trigPin, OUTPUT);

pinMode(echoPin, INPUT);

pinMode(motora1Pin, OUTPUT);

pinMode(motora2Pin, OUTPUT);

pinMode(motorb1Pin, OUTPUT);

pinMode(motorb2Pin, OUTPUT);

pinMode(trigrightPin, OUTPUT);

pinMode(echorightPin, INPUT);

pinMode(flamecarPin, INPUT);

pinMode(flame2Pin, INPUT);

}

void loop() {

if (analogRead(flame2Pin>150){ //if flame is detected in room

if (analogRead(flamecarPin)<150){ //if the flame sensor on the car cannot see the flame

findDistance(); //function to calculate the distance from the front ultrasonic sensor

if (distance >= 500 || distance <= 0){

Serial.println("Out of range");

}

else {

Serial.println("sensor1");

Serial.print(distance);

}

if (distance <= 0 || distance >= 30)

{

Forward(); //moves the robot forward

Page 19: final bs project

`8

}

else

{ Stop();

delay(3000); //some time

Right(); //turn right

delay(450);

Stop();

delay(2000);

findDistanceSide(); //function to find the distance on the left

counter=0;

while( distanceright !=0 && distanceright <= 30) {//continue until end of obstacle

Forward();

counter++; //to increment the counter to be used later

delay(1);

findDistanceSide();

Serial.println("sensorside");

Serial.println(distanceright);

}

Stop(); delay(3000); //some time

Backward(); //to decrease the error of the ultrasonic sensor

delay(200);

Left(); //straight again

delay(600);

Stop();

Page 20: final bs project

`9

delay(2000);

findDistanceSide();

while( distanceright !=0 && distanceright <= 50) //continue until obstacle is away

{

Forward();

findDistanceSide();

}

Forward;

delay(800);

Stop(); delay(3000);

Left(); delay(600); //

Stop(); delay(2000);

while(counter!=0) {Forward();

coun= counter-1; //to decrement the counter which was incremented before

counter=coun;

delay(9); }

Forward();

delay(1000);

Stop();

delay(3000); //now back in place

Right(); delay(500); //now back straight

Stop(); delay(3000);

}

Page 21: final bs project

`10

}

else {

Stop();

}

while (analogRead(flamecarPin>150){ //while the fire is on

digitalWrite(pumpPin,HIGH); //pump the water to extinguish the fire

}

}

delay(50);

}

long findDistance() { //function to find the distance in front of the robot

digitalWrite(trigPin, HIGH);

delayMicroseconds(1000);

digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);

distance = (duration/2) / 29.1;

}

long findDistanceSide() { //function to find the distance on the left side of the robot

digitalWrite(trigrightPin, HIGH);

delayMicroseconds(1000);

digitalWrite(trigrightPin, LOW);

durationright = pulseIn(echorightPin, HIGH);

distanceright = (durationright/2) / 29.1;

}

long findflamesignal1() {

Page 22: final bs project

`11

flamesignal1=analogRead(flamecarPin);

}

long findflamesignal2(){

flamesignal2= analogRead(flame2Pin);

}

void Forward() {

digitalWrite(motora1Pin,HIGH);

digitalWrite(motorb2Pin,HIGH);

digitalWrite(motorb1Pin,LOW);

digitalWrite(motora2Pin,LOW);}

void Backward() {

digitalWrite(motora1Pin,LOW);

digitalWrite(motorb2Pin,LOW);

digitalWrite(motorb1Pin,HIGH);

digitalWrite(motora2Pin,HIGH);}

void Right() {

digitalWrite(motora1Pin,HIGH);

digitalWrite(motorb1Pin,HIGH);

digitalWrite(motora2Pin,LOW);

digitalWrite(motorb2Pin,LOW);

}

void Left() {

digitalWrite(motora1Pin,LOW);

Page 23: final bs project

`12

digitalWrite(motorb2Pin,HIGH);

digitalWrite(motorb1Pin,LOW);

digitalWrite(motora2Pin,HIGH);

}

void Stop() {

digitalWrite(motora1Pin,LOW);

digitalWrite(motorb2Pin,LOW);

digitalWrite(motorb1Pin,LOW);

digitalWrite(motora2Pin,LOW); }

Page 24: final bs project

`13

CHAPTER 3

MECHANICAL DESIGN

3.1 DC motor

Figure 3: DC Motor Modeling

A DC motor is a device that transforms electrical energy, mainly direct current (DC)

to mechanical energy in the form of rotation. The stator is always stationery, and it is

usually attached to the casing of the motor. The rotor is switched by the commutator. The

motor has a non rotating magnetic field and a static field winding, but they have a rotating

armature winding where the voltage is applied. When applying a dc source at the armature,

the configuration of the motor is designed so that the static magnetic field from the

permanent magnets and the magnetic field induced by the applied current interact

according to the laws of attraction and repulsion of the magnet. When the arm of the rotor

is rotating across the N pole of the magnet, the magnetic field in the arm changes from S to

Page 25: final bs project

`14

neutral at the middle of the permanent magnet and then to N towards the end. This gives

the rotor which is attached to the axle a rotational push known as torque.

Figure 4: DC Motor Functionality

3.1.1 Calculations

Torque calculations

2* - µ*G0 =

* a0

R=1.5cm , radius of wheel,

µ=0.2,

Assume a=1m/s2,

G0=m0g(mass*gravity)

Assuming a maximum weight of 1 kg, G0=10.

So, Tmin=22.5Nm

As we choose the motors, we should take into consideration the minimum torque

they provide. We choose the 12V geared motors.

Page 26: final bs project

`15

3.2 Water pump

We had to choose between two types of water pump the pump used in the washing

machines and the one used in the car, to wash the glass.

The first one works on a 220V AC source so to use it we need to use a rectifier

circuit to convert the voltage from DC to AC, and to amplify the voltage by using

transformers.

The second one works on a 12V DC source, which needs less work when using it

and it's more efficient if used as a module later because we use less equipments than the

washing machine, and we obtain the same objective.

Therefore, we chose the second water pump, the one they use in the car, and we

connected it to the microcontroller, so that when the flame sensor indicates that the fire is

near it starts working.

Page 27: final bs project

`16

CHAPTER 4

ELECTRICAL DESIGN

4.1 Microcontroller

4.1.1 Definition of microcontroller

A microcontroller is a compressed microcomputer where we apply the

embedded systems in everything related to technology like robots, motors and

machines. A microcontroller contains a memory and processor.

A microcontroller is to ease the electromechanical process. It is use to

optimize the performance and efficiency. In addition, a microcontroller might

regulate the performance of a machine or a motor…

4.1.2 Why we chose ATMEGA328

We had some difficulties by choosing the right pic. In the beginning we

chose 16f877a which is controlled by the mikroC, but it wasn't efficient and we had

a lot of difficulties to obtain our aim for several reasons. At the beginning, we were

using the right program and we were putting it on proteus and everything went

good, but when applying in a real circuit nothing happened. In addition, we applied

an easy program we already used before in control, measurements, and embedded

lab (to light an LED using this ship) and nothing happened. Even when we used a

new pic nothing happens. We also had a great difficulty in operating the flame

sensors and the ultrasonic sensor in mikroC especially that they were arduino

products.

Therefore, we decided to use the other pic atmega328, which is programmed

using arduino. In addition, PIC is an old technology in contrast AVR which is a new

one.

Page 28: final bs project

`17

4.1.3 Its characteristics

You can read from the chip while writing on it

Temperature range is between -40°C and 85°C

Programming Lock for Software Security

Real Time Counter with Separate Oscillator

Six PWM Channels

It has an analogue digital converter

Power-on Reset and Programmable Brown-out Detection

Internal Calibrated Oscillator

External and Internal Interrupt Sources

Six Sleep Modes: Idle, ADC Noise Reduction, Power-save, Power-down,

Standby, and Extended Standby

Speed Grade 0 - 20 MHz @ 1.8 - 5.5V Low Power Consumption at 1 MHz, 1.8V, 25°C Flash: 32K Bytes EEPROM: 1K Bytes RAM: 2K Bytes Interrupt vector size: 2 instruction words/vector

Page 29: final bs project

`18

Figure 5: Block Diagram of ATMEGA32

Page 30: final bs project

`19

Figure 6: Block Diagram of the AVR Architecture

Page 31: final bs project

`20

Figure 7: The Parallel Instruction Fetches and Instruction Executions

Figure 8: Single Cycle ALU Operation

Figure 9: On-chip Data SRAM Access Cycles

Page 32: final bs project

`21

Figure 10: MCU Start-up, RESET Tied to VCC

Figure 11: MCU Start-up, RESET Extended Externally

Page 33: final bs project

`22

Figure 12: External Reset During Operation

Figure 13: Brown-out Reset During Operation

Page 34: final bs project

`23

Figure 14: Watchdog System Reset During Operation

4.2 Flame Sensor RB-02S022

4.2.1 Definition

A flame sensor is a device which uses optical sensors to detect the existence

of a flame. In our case, we use the sensor to measure the intensity of the flame, so

that when the flame intensity exceeds the allowable limit, our system issues an alert

for fire and moves accordingly. We also use the flame sensor to stop the robot when

the robot approaches the fire to an extent that it could be extinguished from that

distance.

4.2.2 Functionality

It detects a light wave length between 760nm and 1100nm.

Measuring angle: 60°

Operating temperature: -25°C and + 85°C

If the flame is close the sensor might be damaged, so the robot shouldn't be

close.

Page 35: final bs project

`24

4.2.3 Its connections

Figure 15: Connection of Flame Sensor to Arduino

Figure 16: Flame Sensor Terminals

Page 36: final bs project

`25

4.3 Ultrasonic Sensor

4.3.1 Definition

An ultrasonic sensor is a transmitter and a receiver sensor that detects an

object using high frequency sound waves. The sensor measures the time between

sending the sound wave and the time when the echo is high, when the wave is

received. With certain calculations and programming, we were able to use this

sensor to detect the distance between the robot and the nearby objects.

Figure 17: The two Ultrasonic Sensors

Page 37: final bs project

`26

4.3.2 Choice of sensor:

SENSOR

TYPE

COST INFORMATION

GATHERED

ISSUES

Infrared ~20$ Distance of objects directly in front of sensor (thin beam width)

Interference between multiple IR sensors

Sonar

~30$

Distance of nearest

object within viewing angle

Interference between multiple sonar sensors.

Errors depending on surface properties of object and angle of

object to sensor Camera

(monocular)

(after

processing)

~50$

Areas of color thought to

correspond to floor

Requires good lighting Assumes floor to be one color

Assumes obstacles to be a different color from the floor

Camera

(stereo)

(after

Processing)

~80$

Distance of objects

from cameras

Requires good lighting Requires objects with sufficient

surface detail

LIDAR

~6000$

Distance of thousands of points in field of view with

millimeter accuracy

High cost

Table 2: Comparison between Distance Measuring Sensors

Since we are using 2 sensors, one in front and the other is on the right side

(no interference) and we don’t need a wide angle range for the sensor, we decided

to use the sonar (ultrasonic sensor).

4.3.3 Hc-Sr04 pins:

VCC

Trigger

Echo

Ground

Page 38: final bs project

`27

4.3.3.1 Characteristics:

The range of detection is from 2 cm to 400 cm

Measuring angle is 15°

Operation temperature: -40°C and + 80°C

4.3.4. Dyp-Me007 pins:

VCC

Trigger

Echo

Out ( we didn't connect it)

Ground

4.4.1. Characteristics:

The range of detection is between 2cm and 400cm.

Measuring angle is 60°

Operation temperature: -40°C and + 85°C

4.3.5. Functionality:

The functionality of both sensors is similar. They use the same mechanism to

send and receive sound waves.

Working current and voltage: 15mA; 5V

The sensor sends a frequency of 40Hz.

The trigger input is high for 10µs.

If there is an object in front of this sensor, the signal will reflect and go back and the

echo is output is high.

Page 39: final bs project

`28

By measuring the time the echoPin is high, and knowing the speed of the waves, we

can calculate the distance from the robot to the obstacles in front of it, if they are

present.

Calculation of the time interval between sending and receiving signal:

Figure 18: Timing diagram of Hc-Sr04

Figure 19: Timing diagram of dyp-me007

Page 40: final bs project

`29

4.3.6. Its connections:

Vcc is connected to 5V provided by the arduino uno board.

Ground is connected to ground of Arduino.

Trig of sensor 1 is connected to pin 3.

Trig of sensor 2 is connected to pin 12.

Echo of sensor 1 is connected to pin 2.

Echo of sensor 2 is connected to pin 8.

Figure 20a: Connection of Hc-Sr04

Page 41: final bs project

`30

Figure 20b: Connection of Hc-Sr04

Note: In our project we defined echo and trigger pins on other pins.

4.4. H Bridge L293D

4.4.1. Function of H bridge

An h bridge is made with MOSFET, transistors, relays or switches. Its function is to

reverse the current, so that the motor can rotate on its both directions (clockwise or

anticlockwise).

4.4.2. Characteristics

Output current 1A per channel.

Peak output current 2A per channel (non repetitive).

High noise immunity.

Separate logic supply.

Over temperature protection.

Page 42: final bs project

`31

4.4.3. Its connections:

Figure 21: H bridge L293D connections

4.4.4. Description

The L293B is a quad push-pull driver capable of delivering output currents to 1Aperchannel.

Each channel is controlled by a TTL-compatible logic input and each pair of drivers (a full

bridge) is equipped with an inhibit input which turns off all four transistors. A separate supply

input is provided for the logic so that it may be run off a lower voltage to reduce dissipation.

Additionally, the L293E has external connection of sensing resistors, for switch mode

control.

The L293Band L293Earepackagein16 and20-pin plastic DIPs respectively ; both use the four

center pins to conduct heat to the printed circuit board.

Page 43: final bs project

`32

CHAPTER 5

ASSEMBLING THE SYSTEM

Figure 22: Proteus Simulation

5.1. Receiving signal from flame sensor

The system is implemented in an apartment; a network of wires connecting the sensor from

each room to the central station is needed. When a fire is detected, the flame sensor sends the

order, a pulse, to the robot, so that it starts functioning.

5.2. Moving towards the room

Once the signal is detected from a room, the path to the room is loaded and the

microcontroller starts giving orders to the motors throughout an H-bridge to switch the motors

forward or backward, so that the robot can move towards the fire destination.

Page 44: final bs project

`33

5.3. Detecting obstacle

During the robot's move, it will always check for an obstacle in front of it using the

ultrasonic sensor mechanism. When the robot reaches an obstacle at most 30 cm far, the

ultrasonic sensor sends a signal to the microcontroller alerting that an obstacle has been detected.

5.4. Avoiding obstacle

Methods of obstacle avoidance:

5.4.1. Wall following technique

Figure 23: Wall Following Technique

5.4.2. Path following technique

The robot moves away from the obstacle and then goes back to the same track.

Due to the application of obstacle avoiding mechanism in a house with relatively known

obstacles, we use path following.

Page 45: final bs project

`34

Figure 24: Path Following Technique

When an obstacle is detected, the ultrasonic sensor sends a signal to the microcontroller

to stop and change the robot's path. Then the microcontroller gives an order to make the left

motor rotate in the other side while the right motor rotates forward, until the the robot turns 90°

to the left, then the robots moves straight in the left direction until the obstacle is clear.

An ultrasonic sensor placed on the right side of the robot starts functioning giving

information about the obstacle's distance while a counter counts the time that it takes the robot to

clear the obstacle. When the obstacle is cleared the robot turns 90° to the right then continuing in

the same process but without a timer to pass the obstacle, afterwards the robot turns 90° to the

right and then moves to the right side by the same counter. Finally the robot stops and turns 90°

to the left thus avoiding the obstacle encountered before, and the robot can complete its path

back again.

5.5. Detecting place of fire

When the robot reaches the place of fire, a flame sensor set on the robot sends a signal to the

microcontroller telling it that it has reached the fire position along with information about the

fire's magnitude.

Page 46: final bs project

`35

5.6. Extinguishing fire

When the robot reaches the fire position, the microcontroller sends a signal to the motors

to stop, while ordering the water pump to spray water towards the fire position until the fire is

off.

Page 47: final bs project

`36

CHAPTER 6

PROBLEMS FACED

6.1. Temperature:

Since we are designing a fire fighting robot, we should take into consideration that the

parts should be able to tolerate fire temperature and heat energy, especially while working with

micro electronics and sensors. The error of the sensors might increase with the change of

temperature.

We should also take into consideration the heat generated as a result of current flow in

the circuit.

As a result, we decided to increase the pump motor so that the robot can extinguish the fire

from a distance so that it won’t be directly affected by the fire. Moreover, we have used a power

supply that gives 12V at 2A maximum, which can be tolerated by the wires and the electrical

parts in the circuit.

6.2. Sensitivity of flame sensor:

The flame sensor is extremely sensitive. Since it works on the detection of the intensity of

light generated from a flame, it is affected by sunrays and home lights.

That’s why we needed to separate the flame sensor from its surroundings, so that it only

measures the intensity of light in front of the robot only.

6.3. Low torque DC motors

We decided at first to use a toy car, but the torque in the motors was not enough to hold the

weight of water and other components, so we used 2 12V-243rpm DC motors.

Page 48: final bs project

`37

6.4. Some hardware were hard to find

Due to the unavailability of some products such as the flame sensors and the ultrasonic

sensors, we had to delay the work and sometimes we had to search for substitutes such as in the

case of the ultrasonic sensor, where we had to use two different sensors.

We also could not have high current H bridges nor UVtron kits.

6.5. Choosing the best parts

We chose the parts according to the following:

1. Its performance and its efficiency.

2. Temperature effect.

3. Its availability in the Lebanese market.

4. Its price.

6.6. Software Difficulties

By using the 16f877a pic at first, we had great difficulty in operating the ultrasonic

sensors and the flame sensors.

We also encountered errors from sensor input signal when the sensor receives no signal.

When the signal does not return to the sensor, the sensor considers it as 0. For example, if we

need the distance to stay less than 30 cm and the ultrasonic sensor does not receive echo, the

ultrasonic sensor would send 0cm to the chip and thus it would be treated as if it was less than

30cm although it is out of range (>30cm).

We faced difficulties also in learning the arduino language although the logic is very

similar to C language, because we had to use the ATMEGA328 rather than the pic 16F877A

which we are used to program using mikroC.

Page 49: final bs project

`38

CHAPTER 7

RESULTS AND FUTURE IMPROVEMENTS

8.1. Results

This robot is a simple prototype of a fire fighting robot that can be used indoors. When a

fire is detected the robot responds directly and starts to move in a mission to stop the fire.

8.2. Future Improvements

Future improvements can be made by using only one ultrasonic sensor. This can be done

by placing the ultrasonic sensor on a rotating pole connected to the robot and controlled by a

stepper motor. When the robot reaches an obstacle, the stepper motor moves 90 degrees to the

right or left to check for an obstacle presence. If the obstacle is found the stepper motor then

moves 180 degrees from its position to the other position to check if an obstacle is found.

When the robot starts moving away towards the direction that no obstacle is found, the stepper

motor than moves to make the ultrasonic sensor face the obstacle that interrupted the robot's

motion till the obstacle is cleared. Than the robot straights again and the stepper motor turns the

ultrasonic to the obstacle side and starts the same process.

Other future improvements can be made by allowing the robot to follow a definite path,

such as a black line that is connected from each room to the robot. When an obstacle is

discovered the robot can move away from the obstacle using the same process stated above.

The robot can be also made to move back to its station, and automatically re fill the water

container whenever the water level decreases inside it. Also the flame sensor found in each room

can be connected wirelessly to the robot.

Mechanical improvements can be made by building a robot than can carry a fire

extinguisher that can extinguish fire more safely than water, such as fire resulting from oil or

electricity.

Page 50: final bs project

`39

REFERENCES

[1] http://www.nfpa.org/itemDetail.asp?categoryID=953&itemID=23071&URL=Research/Fire

%20 statistics/The%20U.S.%20fire%20problem&cookie_test=1

[2] http://en.wikipedia.org/wiki/Robot

[3] http://en.wikipedia.org/wiki/Robotics

[4] http://whatis.techtarget.com/definition/microcontroller

[5] http://www.atmel.com/Images/doc8161.pdf

[6] http://www.datasheetcatalog.org/datasheet/SGSThomsonMicroelectronics/mXurruu.pdf

[7] http://www.talkingelectronics.com/projects/H-Bridge/H-Bridge-1.html

[8] http://www.micropik.com/PDF/HCSR04.pdf

[9] https://code.google.com/p/megapirateng/wiki/dypme007

[10] http://www.ebay.com/itm/Ultrasonic-Module-HC-SR04-Distance-Measuring-Transducer-

Sensor-Arduino-/300743854848

[11] http://www.alsrobot.com/index.php?route=product/product&product_id=121