Join jheb93's empire
Home » , , » Fire Extinguisher Robot Program

Fire Extinguisher Robot Program

Archived by :
The aim of the project is to make a robot which can follow a black strip on a white floor and can extinguish the fire on the destined room in a building. The robot can be used in the rescue operation also. Thus the robot can act as a path guider in normal case and as a fire extinguisher in emergency.

This project is designed keeping in view the problem faced by fire fighters when fire broke in huge building. It is difficult to locate the floor and room where exactly fire took place. Through this project we design robots to actually travel up to place where fire is there. Lift mechanism is designed to make robot travel up the floors. In present project we have just implemented 2 floor lift, though it can be extended up to access up levels also.



/*****************************************************
This program was produced by the
CodeWizardAVR V2.04.4a Advanced
Automatic Program Generator
© Copyright 1998-2009 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com
Project :
Version :
Date : 05/05/2011
Author : NeVaDa
Company : DarkOS
Comments:

Chip type : ATmega8535
Program type : Application
AVR Core Clock frequency: 4,000000 MHz
Memory model : Small
External RAM size : 0
Data Stack size : 128
*****************************************************/



#include <mega8535.h>
#include <stdio.h>
#include <delay.h>
#include <stdlib.h>
// Alphanumeric LCD Module functions
#asm
.equ __lcd_port=0x18 ;PORTB
#endasm
#include <lcd.h>
#define ADC_VREF_TYPE 0x00

#define servo PORTC.3
#define uv PINA.1
#define act PINC.0
#define kipas PORTC.1
//inisialisasi ping
//#define in_ping PINA
#define inp1 PINA.2
#define inp2 PINA.3
#define inp3 PINA.4
#define inp4 PINA.5
#define inp5 PINA.6
#define inp6 PINA.7
#define inp7 PINC.6
#define inp8 PINC.7
//#define dirping DDRA
#define dirp1 DDRA.2
#define dirp2 DDRA.3
#define dirp3 DDRA.4
#define dirp4 DDRA.5
#define dirp5 DDRA.6
#define dirp6 DDRA.7
#define dirp7 DDRC.6
#define dirp8 DDRC.7
//#define out_ping PORTA
#define outp1 PORTA.2
#define outp2 PORTA.3
#define outp3 PORTA.4
#define outp4 PORTA.5
#define outp5 PORTA.6
#define outp6 PORTA.7
#define outp7 PORTC.6
#define outp8 PORTC.7
//--------------inisialisasi motor------------------------------------
#define dirA_Ki PORTD.0 // Direction A untuk motor kiri
#define dirB_Ki PORTD.1 // Direction B untuk motor kiri
#define EnKi PORTD.6 // Enable L298 untuk motor kiri
#define EnKa PORTD.7 // Enable L298 untuk motor kanan
#define dirC_Ka PORTD.2 // Direction C untuk motor kanan
#define dirD_Ka PORTD.3


unsigned char a,lpwm,rpwm;
unsigned int crt1,crt2,crt3,crt4,crt5,crt6,crt7, crt8;
unsigned int us1,us2,us3,us4,us5,us6,us7, us8, i;
unsigned char buff[16];
unsigned char Msg1[20], Msg2[20];
// Read the AD conversion result
unsigned int read_adc(unsigned char adc_input)
{
ADMUX=adc_input | (ADC_VREF_TYPE & 0xff);
// Delay needed for the stabilization of the ADC input voltage
delay_us(10);
// Start the AD conversion
ADCSRA|=0x40;
// Wait for the AD conversion to complete
while ((ADCSRA & 0x10)==0);
ADCSRA|=0x10;
return ADCW;
}
// Declare your global variables here
unsigned char baris1[16];
unsigned int sound;

// Timer 0 overflow interrupt service routine
interrupt [TIM0_OVF] void timer0_ovf_isr(void)
{
// Place your code here
a++;
if(a<=lpwm)
{
EnKi=1;
}
else
{
EnKi=0;
}
if(a<=rpwm)
{EnKa=1;
}
else
{
EnKa=0;
}
}

//------------------------sound------------------------------------------------
void suara()
{ sound=read_adc(0);
sprintf(baris1,"sound = %d",sound);
lcd_gotoxy(0,1);
lcd_puts(baris1);
}
//---------------------kendali motor------------------------------------------
void maju()
{

dirA_Ki=1;
dirB_Ki=0;
dirC_Ka=1;
dirD_Ka=0;
}
void maju_lrs()
{
maju();lpwm=100;rpwm=110;
}
void maju_cpt()
{
maju();lpwm=120;rpwm=130;
}
void maju_scan()
{
maju();lpwm=60;rpwm=70 ;
}
void kiri()
{

dirA_Ki=0;
dirB_Ki=1;
dirC_Ka=1;
dirD_Ka=0;
}
void kekiri(){
//kiri();
maju();
rpwm=50;lpwm=70;
}
void kanan()
{

dirA_Ki=1;
dirB_Ki=0;
dirC_Ka=0;
dirD_Ka=1;
}
void belok_kanan()
{
kanan();
lpwm=90;rpwm=70;}
void belok_kiri(){
kiri();
lpwm=70;rpwm=90;
}
void Turnki_1(unsigned char torki, unsigned char torka, unsigned char t)
{
unsigned int i;
belok_kiri();
rpwm=torka; lpwm=torki;
delay_ms(t);
for(i=0;i<200;i++) while(!uv){};
for(i=0;i<200;i++) while(uv){};

}
void Turnka_1(unsigned char torki, unsigned char torka, unsigned char t)
{
unsigned int i;
belok_kanan();
rpwm=torka; lpwm=torki;
delay_ms(t);
for(i=0;i<200;i++) while(!uv){};
for(i=0;i<200;i++) while(uv){};

}
void stop()
{
dirA_Ki=0;
dirB_Ki=0;
dirC_Ka=0;
dirD_Ka=0;
//lpwm=0;rpwm=0;
}
void mandeg()
{
lpwm=0;rpwm=0;
}
void mundur()
{ dirA_Ki=0;
dirB_Ki=1;
dirC_Ka=0;
dirD_Ka=1;
lpwm=60;rpwm=70;
}
void mun()
{ dirA_Ki=0;
dirB_Ki=1;
dirC_Ka=0;
dirD_Ka=1;
lpwm=30;rpwm=40;
delay_ms(500);
}
void kekanan()
{ //kanan();
maju();
rpwm=70;lpwm=50;
}
void lurus(){
maju();
rpwm=80;
lpwm=94;
// for(lpwm=30;lpwm<=74;lpwm++)
// for(rpwm=42;rpwm<=84;rpwm++}
}
void power(){
maju();
// rpwm=110;
// lpwm=110;
for(lpwm=20;lpwm<=100;lpwm++){}
for(rpwm=20;rpwm<=90;rpwm++){}}

//control ping-
void tampil()
{
lcd_clear();
sprintf(buff,"%3d",us1);lcd_gotoxy(0,0);lcd_puts(buff);
sprintf(buff,"%3d",us2);lcd_gotoxy(4,0);lcd_puts(buff);
sprintf(buff,"%3d",us3);lcd_gotoxy(8,0);lcd_puts(buff);
sprintf(buff,"%3d",us4);lcd_gotoxy(12,0);lcd_puts(buff);
sprintf(buff,"%3d",us5);lcd_gotoxy(16,0);lcd_puts(buff);
sprintf(buff,"%3d",us6);lcd_gotoxy(4,1);lcd_puts(buff);
sprintf(buff,"%3d",us7);lcd_gotoxy(8,1);lcd_puts(buff);
sprintf(buff,"%3d",us8);lcd_gotoxy(12,1);lcd_puts(buff);

delay_ms(10);
}
void serv()
{ /*if(uv==1)
{
mundur();
delay_ms(100);
stop();
delay_ms(500);
kipas=1;

lcd_clear();
lcd_gotoxy(0,0);
lcd_putsf("api");
*/

for(i=0;i<50;i++)
{
PORTC.3=1;
delay_us(1200); //2000
PORTC.3=0;
delay_us(18100);
}

for(i=0;i<50;i++)
{
PORTC.3=1;
delay_us(600); //2000
PORTC.3=0;
delay_us(18100);
}
for(i=0;i<50;i++)
{
PORTC.3=1;
delay_us(1200);
PORTC.3=0;
delay_us(18900);
}
for(i=0;i<50;i++)
{
PORTC.3=1;
delay_us(2000);
PORTC.3=0;
delay_us(18900);
}
kipas=0;
delay_ms(300);
stop();
delay_ms(100);

// }
// else
// if(uv==0){
// PORTC.5=0;
// }
}
void ping(){
crt1=0;
dirp1=1; //set as output
outp1=1; //set low
delay_us(5);
outp1=0; //set high
dirp1=0; //set as input
outp1=1;
while (inp1==0)
{};
while(inp1==1)
{ crt1++;}
us1=(crt1*0.034441); // Untuk clock 4,0000 Mhz
delay_ms(10);

crt2=0;
dirp2=1; //set as output
outp2=0; //set low
delay_us(5);
outp2=1; //set high
delay_us(5);
outp2=0; //set low
delay_us(10);
dirp2=0; //set as input
while (inp2==0)
{};
while(inp2==1)
{ crt2++;}
us2=(crt2*0.034442); // Untuk clock 4,0000 Mhz
delay_ms(10);
crt3=0;
dirp3=1; //set as output
outp3=0; //set low
delay_us(5);
outp3=1; //set high
delay_us(5);
outp3=0; //set low
delay_us(10);
dirp3=0; //set as input
while (inp3==0)
{};
while(inp3==1)
{ crt3++;}
us3=(crt3*0.034442); // Untuk clock 4,0000 Mhz
delay_ms(10);
crt4=0;
dirp4=1; //set as output
outp4=0; //set low
delay_us(5);
outp4=1; //set high
delay_us(5);
outp4=0; //set low
delay_us(10);
dirp4=0; //set as input
while (inp4==0)
{};
while(inp4==1)
{ crt4++;}
us4=(crt4*0.034442); // Untuk clock 4,0000 Mhz
delay_ms(10);

crt5=0;
dirp5=1; //set as output
outp5=0; //set low
delay_us(5);
outp5=1; //set high
delay_us(5);
outp5=0; //set low
delay_us(10);
dirp5=0; //set as input
while (inp5==0)
{};
while(inp5==1)
{ crt5++;}
us5=(crt5*0.034442); // Untuk clock 4,0000 Mhz
delay_ms(10);
crt6=0;
dirp6=1; //set as output
outp6=1; //set low
delay_us(5);
outp6=0; //set high
dirp6=0; //set as input
outp6=1;
while (inp6==0)
{};
while(inp6==1)
{ crt6++;}
us6=(crt6*0.034442); // Untuk clock 4,0000 Mhz
delay_ms(10);
crt7=0;
dirp7=1; //set as output
outp7=1; //set low
delay_us(5);
outp7=0; //set high
dirp7=0; //set as input
outp7=1;
while (inp7==0)
{};
while (inp7==1)
{ crt7++;}
us7=(crt7*0.034442); // Untuk clock 4,0000 Mhz
delay_ms(10);
crt8=0;
dirp8=1; //set as output
outp8=1; // set high
delay_us(5);
outp8=0; //set low
dirp8=0;
outp8=1; //set as input
while (inp8==0)
{};
while(inp8==1)
{ crt8++;}
us8=(crt8*0.034442); // Untuk clock 4,0000 Mhz
delay_ms(10);
}
void melaku()
{

if((us7>6)&&(us3>11)&&(us4>7)){
lcd_clear(); lurus(); lcd_gotoxy(0,0); lcd_putsf("maju");
}
if((us7>6)&&(us3<11)||(us7>6)&&(us2<7))//||(us3<11)&&(us2<7))
{
lcd_clear(); belok_kanan(); lcd_gotoxy(0,0); lcd_putsf("belok kanan");
if(us1<3){lcd_clear(); kekanan(); lcd_gotoxy(0,0); lcd_putsf("kekanan");}
}
//if((us7>6)&&(us3<11)&&(us2<10)){lcd_clear(); belok_kanan(); lcd_gotoxy(0,0); lcd_putsf("belok kanan");
// if(us1<3){lcd_clear(); kekanan(); lcd_gotoxy(0,0); lcd_putsf("kekanan");}
// }
if((us7>6)&&(us4<7)||(us7>6)&&(us5<3))//||(us4<7)&&(us5<3))
{
lcd_clear(); belok_kiri(); lcd_gotoxy(0,0); lcd_putsf("belok kiri");
if(us6<2){lcd_clear(); kekiri(); lcd_gotoxy(0,0); lcd_putsf("kekiri");}}
//if((us7>6)&&(us4<7)&&(us5<10)){lcd_clear(); belok_kiri(); lcd_gotoxy(0,0); lcd_putsf("belok kiri");
//if(us6<2){lcd_clear(); kekiri(); lcd_gotoxy(0,0); lcd_putsf("kekiri");}}
if((us7<6)&&(us3<12)||(us7<6)&&(us2<1))//||(us3<12)&&(us2<12))
{
lcd_clear(); belok_kanan(); lcd_gotoxy(0,0); lcd_putsf("belok kanan");}
if(us1<4){lcd_clear(); kekanan(); lcd_gotoxy(0,0); lcd_putsf("kekanan");}
//if((us7<6)&&(us3<12)&&(us2<12)){lcd_clear(); belok_kanan(); lcd_gotoxy(0,0); lcd_putsf("belok kanan");}
// if(us1<4){lcd_clear(); kekanan(); lcd_gotoxy(0,0); lcd_putsf("kekanan");}
if((us7<6)&&(us4<7))//||(us7<6)&&(us5<12))
{
lcd_clear(); belok_kiri(); lcd_gotoxy(0,0); lcd_putsf("belok kiri");
if(us6<4){lcd_clear(); kekiri(); lcd_gotoxy(0,0); lcd_putsf("kekiri");}
}
//if((us7<6)&&(us4<7)&&(us5<12)){lcd_clear(); belok_kiri(); lcd_gotoxy(0,0); lcd_putsf("belok kiri");
// if(us6<4){lcd_clear(); kekiri(); lcd_gotoxy(0,0); lcd_putsf("kekiri");} }
if((us7<6)&&(us3<11)&&(us4<7)||(us7<3)){lcd_clear(); mundur(); lcd_gotoxy(0,0); lcd_putsf("mundur"); delay_ms(400);
if(us1>us6){lcd_clear(); kekanan(); lcd_gotoxy(0,0); lcd_putsf("kanan");}
if(us4<us6){lcd_clear(); kekiri(); lcd_gotoxy(0,0); lcd_putsf("kekiri");}
}
if(us8<3){lcd_clear(); lurus(); lcd_gotoxy(0,0); lcd_putsf("lurus");}
//if(uv==1)
//{lcd_clear(); stop(); kipas=1; serv(); lcd_gotoxy(0,0); lcd_putsf("Api"); delay_ms(2000); }
//if(uv==0)
// {}
}


void main(void){

// Declare your local variables here
// Input/Output Ports initialization
// Port A initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTA=0x02;
DDRA=0x00;
// Port B initialization
// Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=Out
// State7=0 State6=0 State5=0 State4=0 State3=0 State2=0 State1=0 State0=0
PORTB=0x00;
DDRB=0xFF;
// Port C initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTC=0x00;
DDRC=0x2B;
// Port D initialization
// Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=Out
// State7=0 State6=0 State5=0 State4=0 State3=0 State2=0 State1=0 State0=0
PORTD=0x00;
DDRD=0xFF;
// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: 4000,000 kHz
// Mode: Normal top=FFh
// OC0 output: Disconnected
TCCR0=0x01;
TCNT0=0x00;
OCR0=0x00;
// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: Timer 1 Stopped
// Mode: Normal top=FFFFh
// OC1A output: Discon.
// OC1B output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer 1 Overflow Interrupt: Off
// Input Capture Interrupt: Off
// Compare A Match Interrupt: Off
// Compare B Match Interrupt: Off
TCCR1A=0x00;
TCCR1B=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;
// Timer/Counter 2 initialization
// Clock source: System Clock
// Clock value: Timer 2 Stopped
// Mode: Normal top=FFh
// OC2 output: Disconnected
ASSR=0x00;
TCCR2=0x00;
TCNT2=0x00;
OCR2=0x00;
// External Interrupt(s) initialization
// INT0: Off
// INT1: Off
// INT2: Off
MCUCR=0x00;
MCUCSR=0x00;
// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x01;
// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0x80;
SFIOR=0x00;
ADMUX=ADC_VREF_TYPE & 0xff;
ADCSRA=0x82;
SFIOR&=0xEF;
// LCD module initialization
lcd_init(16);
// Global enable interrupts
#asm("sei")
while(1)
{
suara();
if((act==1)||(sound>600))
{
while (1)
{

if(uv==1)
{stop(); lcd_gotoxy(0,0); lcd_putsf("stop"); kipas=1; serv(); lcd_clear();
lcd_gotoxy(8,1); lcd_putsf("api"); lcd_gotoxy(8,0); lcd_putsf("kipas"); delay_ms(2000);
}
else{
ping();
melaku();
}
}
}
}

}





Source:
http://r173xi.blogspot.com/2011/06/program-robot-pemadam-api-ku.html 
http://www.e-yantra.org/home/projects-wiki/item/179-fire-fighting-robot-using-spark-v-robotic-platform

1 Comment's:

  1. Thank you for the article.
    The code looks really nice.
    I think the potential profits come along with new technology and those people or companies who are able to implement it will win the market. According to data room review, virtual data room services are known to replace old-fashioned ineffective physical data rooms.

    ReplyDelete

Please enable / Bitte aktiviere JavaScript!
Veuillez activer / Por favor activa el Javascript![ ? ]

Google+ Followers

The Stalkers

Blog Archive

Ads? Its Donate!



Featured Posts


BTC Address: 1MM2ibRwJnR4GY8XdvTJoGEu1ZzxrpGRdc
 
Copyright © 2015 Blog, JeffArts Inc.