0% found this document useful (0 votes)
23 views15 pages

Underground Mine Safety System

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views15 pages

Underground Mine Safety System

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

UNDERGROUND MINE SAFETY SYSTEM

#include<reg52.h>

#include<string.h>

#include<stdlib.h>

unsigned char *Phone_No="6385907662",d=0,ph[14],owner_phone[13]="+916385907662";


//the number to which msg will be send if sensor is detected

unsigned char a=0,c=0,slt[15],sl[3],Z=1;

extern unsigned char msg[65],phone_number[10],slot[3],j=0,x;

unsigned char timercount=0;

bit flag=0;

unsigned char n;

unsigned int i,num,numb,p,q;

sbit LCD_en=P3^4;

sbit LCD_rs=P3^5

/*serial prototypes */

void serial_init();

void Tx_Data(unsigned char);

unsigned char Rx_Data (void);

void SCI_String_Tx(unsigned char *string);

void Enter_cmd(void);
/* lcd prototypes*/

void LCD_delay(unsigned char ms);

void LCD_enable();

void LCD_command(unsigned char command);

void LCD_putc(unsigned char ascii);

void LCD_puts(unsigned char *lcd_string);

void LCD_init();

#define LCD_DELAY 1535 /* Delay for 1 ms */

#define LCD_clear() LCD_command(0x1) /* Clear display LCD */

#define LCD_origin() LCD_command(0x2) /* Set to origin LCD */

#define LCD_row1() LCD_command(0x80) /* Begin at Line 1 */

#define LCD_row2() LCD_command(0xC0) /* Begin at Line 2 */

/************************* GSM PROTOTYPES **********************/

#define AT_CMD "AT" //checking the modem

#define ECHO_CMD "ATE0" //makeing echo off

#define CPIN_CMD "AT+CPIN?" //checking the presence of


sim card

#define CMGF_CMD "AT+CMGF=1" //text mode

#define AT_W "AT&W" // save settings


permanently in gsm modem
#define CMGS_CMD "AT+CMGS=" // command for
sending message

void Test_OK(void); // checking modem respone

void PIN_Test_OK(void); // checking pin status

void GSM_Init (void);

void Send_SMS(unsigned char *Phone_No,unsigned char *msg);

void Test_cond(void);

void Delay_1sec(); //Function for 1 second delay

#define ON=1;

#define OFF=0;

void main()

LCD_delay(30); //delay for 30 millisecond


LCD_init(); // LCD initialization

LCD_clear(); // clearing lcd display

serial_init(); // initializing serial communication

LCD_row1(); // setting cursor into first row


of lcd

//LCD_putc(' ');

LCD_puts(" GSM SDK KIT ");

Delay_1sec(); // delay for 1 second

Delay_1sec();

//Delay(10);

LCD_clear();

GSM_Init(); // initializing gsm modem

Delay_1sec();

LCD_clear();

LCD_puts("MODEM INITIALZED");

Delay_1sec();

Delay_1sec();

LCD_clear();

LCD_row1();

LCD_puts("UNDERGROUND");

LCD_row1();
while(1)

LCD_clear();

LCD_puts("MINE SAFETY ");

Delay_1sec();

RI=0;

void GSM_Init (void)

{ // Start SCI
Clock

/*AT Command */

LCD_row1();

LCD_puts(AT_CMD);

SCI_String_Tx(AT_CMD);

Enter_cmd();

Test_OK();

Delay_1sec();

/* Echo Command*/

LCD_row1();

LCD_puts(ECHO_CMD);

SCI_String_Tx(ECHO_CMD);

Enter_cmd();
Test_OK();

Delay_1sec();

/* PIN Status Command*/

LCD_row1();

LCD_puts(CPIN_CMD);

SCI_String_Tx(CPIN_CMD);

Enter_cmd();

PIN_Test_OK();

Delay_1sec();

/* Text Mode */

LCD_row1();

LCD_puts(CMGF_CMD);

SCI_String_Tx(CMGF_CMD);

Enter_cmd();

Test_OK();

Delay_1sec();

/* Save settings */
LCD_row1();

LCD_puts(AT_W);

SCI_String_Tx(AT_W);

Enter_cmd();

Test_OK();

/********** Function for sending msg to a particular number when sensor


detected**************/

void Send_SMS(unsigned char *Phone_No,unsigned char *msg)

/* SMS Format */

/* LCD_row1();

LCD_puts(CMGS_CMD);

SCI_String_Tx(CMGS_CMD);

Enter_cmd();

Test_OK();*/
// Send SMS Command

SCI_String_Tx(CMGS_CMD);//send command

// Phone Number

Tx_Data('"');

SCI_String_Tx(Phone_No);// phone number

Tx_Data('"');

Enter_cmd();//enter

SCI_String_Tx(msg);// message

Tx_Data(0x1a);//^Z (ctrl+Z)

while(Rx_Data()!='K');// waiting for response "ok"

/*void Test_cond(void)

unsigned char a=0;

LCD_row1();

LCD_puts(AT_CMD);

SCI_String_Tx(AT_CMD);

Enter_cmd();

timercount=0;

TR0=1;

while((a=Rx_Data())!='K' &&(timercount<50));

TR0=0;
if(a!='K')

serial_init();

Delay_1sec();

GSM_Init();

LCD_row2();

LCD_putc('K');

}*/

/************* checking modem respone**************/

void Test_OK(void)

while(Rx_Data()!='K');

LCD_row2();

LCD_putc('K');

/****************** checking pin status ****************/

void PIN_Test_OK(void)

while(Rx_Data()!='Y');

LCD_row2();
LCD_putc('Y');

/*********** Fuction for clearing msg array****************/

/*void clear_array()

unsigned char g=0;

for(g=0;g<50;g++)

msg[g]=0;

*/

/*********** Fuction for clearing slot array****************/

/*void clear_slot()

unsigned char i=0;

for(i=0;i<15;i++)

slt[i]=0;

*/
void LCD_delay(unsigned char ms)

// unsigned char n;

// unsigned int i;

for (n=0; n<ms; n++)

for (i=0; i<LCD_DELAY; i++); /* For 1 ms */

void LCD_enable()

LCD_en = 0; /* Clear bit P2.4 */

LCD_delay(1);

LCD_en = 1; /* Set bit P2.4 */

void LCD_command(unsigned char command)

LCD_rs = 0; /* Clear bit P2.5 */

P1 = (P1 & 0x0F)|(command & 0xF0);


LCD_enable();

P1 = (P1 & 0x0F)|(command<<4 & 0xF0);

LCD_enable();

LCD_delay(1);

void LCD_putc(unsigned char ascii)

LCD_rs = 1; /* Set bit P2.5 */

P1 = (P1 & 0x0f)|(ascii & 0xf0);

LCD_enable();

P1 = (P1 & 0x0F)|(ascii<<4 & 0xF0);

LCD_enable();

LCD_delay(1);

void LCD_puts(unsigned char *lcd_string)

while (*lcd_string)

LCD_putc(*lcd_string++);

void LCD_init()
{

LCD_en = 1; /* Set bit P2.4 */

LCD_rs = 0; /* Clear bit P2.5 */

LCD_command(0x33);

LCD_command(0x32);

LCD_command(0x28);

LCD_command(0x0C);

LCD_command(0x06);

LCD_command(0x01); /* Clear */

LCD_delay(256);

void Delay_1sec()

int i=0,j=0;

for(i=0;i<1000;i++)

for(j=0;j<113;j++);

/********** Function for initializing serial communication**************/

void serial_init()

TMOD=0X21;

SCON=0X50;
TH1=0XFD;

TR1=1;

/********* Function for sending a character into seril port************* */

void Tx_Data(unsigned char v)

SBUF=v;

while(TI==0);

TI=0;

/********* Function for receiving a character from seril port************* */

unsigned char Rx_Data (void)

unsigned char in;

while(!RI);

in=SBUF;

RI=0;

return(in);

}
/********* Function for sending a string into seril port************* */

void SCI_String_Tx(unsigned char *string)

while(*string)

Tx_Data(*(string++));

/********* Function for giving enter ************* */

void Enter_cmd(void)

Tx_Data(0x0D);

Tx_Data(0x0A);

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy