Fire Fighting Robot
The purpose of this project is to develop and design a Fire Fighting Robot guided by the objective to design a robot that is able to avoid obstacles, detect fire and extinguish the fire. This project is referring to the design of a robot that is capable to move and extinguish fire automatically. Implementation of this robot is tested with high fire temperature to evaluate the sensitivity of detecting after that expunges the fire by using water mechanism. This model includes IR sensors that also detect obstacles at left and right positions.
Supplies
Here are all the devices used in designing the fire fighting robot:
- Pic Microcontroller(16F877A)
- Servo Motor (SG990)
- Flame Sensor (KY-026)
- Ultrasonic Sensor(HC-SR04)
- Motor Driver Module(L298D)
- Chassis Car of DC 6V &120 mA
- IR Sensor with 5VDC operating voltage & 20 mA supply current
Working
The potential of Fire Fighting Robot acts during extinguishing the flame, including:
· Detection of fire
· Wall avoidance
· Extinguish fire
The robot detects the presence of fire through the sensor within a range of 20 cm to 100cm in designated areas. The sensitivity of sensing the fire is determined by calculating the distance from the robot to fire then the distance will be included in the PIC program. Robots will avoid barriers if there have any obstacles that occur during the process of detecting fire. The distance between the robot and the obstacle is determined through calculations included in the PIC program. The next step is that it will act to go to that place (fire) that has been detected by the sensor after move randomly and extinguish the fire with water. Focus on robot movement is based on the flat surface work area. All robot behavior is controlled by the Programmable Interface Controllers (PIC) as the main control system. PIC will control and give commands to the robot to sense the fire and obstacles. Assembly language is used as the language interface to be programmed in the PIC.
An ultrasonic sensor is used as a sense of sight for the Fire Fighting Robot. It is a sensor that will indicate obstacles in the path of movement. An ultrasonic sensor consists of a transmitter and receiver, transmitting to detect obstacles and receive signals through the receiver. The receiver will inform the PIC if there are obstacles in front of the robot. PIC will command the robot to change the direction of movement to avoid collisions with objects.
In detecting flame, the robot is equipped with the flame sensor mounted on a robot body. This sensor will respond to the presence of fire around 20cm to 100cm and give an interrupt to the PIC, next to giving instructions to the robot to move towards the flame. When the sensor has detected flame, the PIC will activate the pump for water out of the tank. Water will then be channeled to the spray nozzle through a rubber pipe. The robot will act by extinguishing flame using water until erased and return to the task of sensing a flame.
Coding
#define _XTAL_FREQ 20000000
#include <xc.h>
__PROG_CONFIG(1, 0x3F32);
#define trigger RC2
#define echo RC3
void flame_sensor(void);
int calc_distance(void); // Function Declaration
void move_forward(void);
void move_backward(void);
void move_left(void);
void stop_car(void);
void move_right(void);
void servo_motor(void);
void servo_motor_90(void);
void servo_motor_45(void);
void servo_motor_30(void);
void servo_motor_60(void);
unsigned int dist=0;
void main(void)
{
// Create Distance Variable
TRISD=0X00;
PORTD=0X00;
TRISC=0X08;
PORTC=0X00;
//--[ Configure The IO Pins ]--
// Set PORTB To Be Output Port except RB4 &RB5 is input for IR sensors
TRISB = 0xF0;
// Set PORTB To Be LOW For initial State
PORTB = 0x00;
// Set RC2 To Be Output Pin ( Trigger )
RC2 = 0;
// Set RC3 To Be Input Pin ( Echo )
RC3 = 1;
//--[ Configure Timer Module To Operate in Timer Mode ]--
// Clear The Pre-Scaler Select Bits
T1CKPS0=0;
T1CKPS1=0;
// Choose The Local Clock As Clock Source
TMR1CS=0;
// Write The System's Main Routine !
while(1)
{
//RB4 and RB5 pin for IR Sensors.
dist = calc_dist()/5;
if(dist>10&&RB4==1&&RB5==1)
move_forward();
if(dist<10&&RB4==0&&RB5==1)
move_left();
if(dist<10&&RB4==1&&RB5==0)
move_right();
//Constrained
if(dist<10&&RB4==1&&RB5==1)
move_right();
if(dist<10&&RB4==0&&RB5==0)
move_backward();
//RB7 is digital o/p of flame sensor
flame_sensor();
}
return;
}
// Definition Of The calc_dist() Function
int calc_dist(void)
{
int distance=0;
TMR1=0;
// Send Trigger Pulse To The Sensor
trigger=1;
__delay_us(10);
trigger=0;
// Wait For The Echo Pulse From The Sensor
while(!echo);
// Turn ON Timer Module
TMR1ON=1;
// Wait Until The Pulse Ends
while(echo);
// Turn OFF The Timer
TMR1ON=0;
// Calculate The Distance Using The Equation in CM
distance=TMR1/58.82;
return distance;
}
void flame_sensor(void)
{
if(RB7==1||RB6==1)
{
if(dist>25)
{
move_forward();
servo_motor_60();
}
}
//RB7 is digital o/p of flame sensor
if(RB7==1||RB6==1)
{
if(dist>20&&dist<25)
{
stop_car();
//FOR 45 DEGREES ANGLE
servo_motor_45();
RD3=1;
RD4=0;
}
}
if(RB7==1||RB6==1)
{if(dist<15)
{
stop_car();
//FOR 45 DEGREES ANGLE
servo_motor_30();
RD3=1;
RD4=0;
}
}
if(RB7==1||RB6==1)
{
if(dist>15&&dist<20)
{
stop_car();
//FOR 45 DEGREES ANGLE
servo_motor_60();
RD3=1;
RD4=0;
}
}
else
{
RD3=0;
RD4=0;
}
}
void move_forward(void)
{
RB0=1;
RB1=0;
RB2=1;
RB3=0;
}
void move_backward(void)
{
RB0=0;
RB1=1;
RB2=0;
RB3=1;
}
void move_left(void)
{
RB0=1;
RB1=0;
RB2=0;
RB3=1;
}
void move_right(void)
{
RB0=0;
RB1=1;
RB2=1;
RB3=0;
}
void stop_car(void)
{
RB0=0;
RB1=0;
RB2=0;
RB3=0;}
void servo_motor_90(void)
{
for(int i=0;i<30;i++)
{
RD2=1;
__delay_ms(1);
RD2=0;
__delay_ms(20);}
RD2=0;
}
void servo_motor_45(void)
{
for(int i=0;i<30;i++)
{ RD2=1;
__delay_ms(1.5);
RD2=0;
__delay_ms(20);
}
RD2=0;}
void servo_motor_30(void)
{for(int i=0;i<30;i++)
{ RD2=1;
__delay_ms(1.75);
RD2=0;
__delay_ms(20); }
RD2=0;}
void servo_motor_60(void)
{
for(int i=0;i<30;i++)
{
RD2=1;
__delay_ms(1.25);
RD2=0;
__delay_ms(20);
}
RD2=0;
}