Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

GSM interfacing with Virtual Serial Port Emulator in Proteus

Status
Not open for further replies.

ananthrajv

Newbie level 1
Joined
Oct 3, 2015
Messages
0
Helped
0
Reputation
0
Reaction score
0
Trophy points
0
Activity points
0
Hi,

I have written the code for GSM integrating with PIC and connected the GSM to the pc through VSPE. the code is working fine except the last portion of the transitter section.
the normal GSM code is working fine but integrating with few extra peripherals like keypad and LCD its not working .

my code simply if we enter 3 digits in the keypad if its is correct the output will display correct.

if not it has send the message to the number.

The GSM initializing is doing correct but the message transmission is not working .

I have pasted the code below ..

please help

#if defined(__PCM__)
#include <16F877A.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use DELAY(CLOCK=16000000)
#use rs232 (baud = 9600, xmit = PIN_C6, rcv = PIN_C7)

#define C1 PIN_c0
#define C2 PIN_c1
#define C3 PIN_c2


#BYTE PORTA = 0X05
#BYTE TRISA = 0X85

char keypad();
void display_enter();
void display_correct();
void display_wrong();
char M[3],x,c;
int i,j,k;

char at[]="AT";
char cmgf[]="AT+CMGF=1";
char cnmi[]="AT+CNMI=2,2,0,0,0";
char cmgs[]="AT+CMGS="+919500808111"";
char msg1[]="WELCOME";

void lcd_init();
void comand(char c);
void gsm_tx();
void gsm_init();

void main()
{
gsm_init();
delay_ms(1000);
lcd_init();
delay_ms(1000);

while(1)
{
display_enter();
delay_ms(1000);
lcd_init();


while(1)
{
for(i=0;1<=3;i++)
{
M=keypad();
printf("%c",M);
comand('*');
delay_ms(100);
if(i==2)
{
if((M[0]=='0')&&(M[1]=='1')&&(M[2]=='2'))
{
printf("open");
lcd_init();
display_correct();
output_bit(pin_b0,1);
}
else
{
lcd_init();
display_wrong();
output_bit(pin_b2,1);
gsm_tx();
}
}
}
}
}
}

char keypad()
{
int a=0;
char C;
do
{
//ROW 1
output_a(0xfe);// ROW 1 1111 1110
delay_ms(5);
if((PORTa|0xfe)==0xfe)
{
if(input(C1)==0)
{
C='1';
a=1;
while(input(C1)==0);
}
if(input(C2)==0)
{
C='2';
a=1;
while(input(C2)==0);
}
else if(input(C3)==0)
{
C='3';
a=1;
while(input(C3)==0);
}
}


// ROW 2
output_a(0xfd);
delay_ms(5);
if((PORTa|0xfd)==0xfd)// 1111 1101
{
if(input(C1)==0)
{
C='4';
a=1;
while(input(C1)==0);
}
else if(input(C2)==0)
{
C='5';
a=1;
while(input(C2)==0);
}
else if(input(C3)==0)
{
C='6';
a=1;
while(input(C3)==0);
}
}


//ROW 3
output_a(0xfb);// ROW 1 1111 1011
delay_ms(5);
if((PORTa|0xfb)==0xfb)
{
if(input(C1)==0)
{
C='7';
a=1;
while(input(C1)==0);
}
if(input(C2)==0)
{
C='8';
a=1;
while(input(C2)==0);
}
else if(input(C3)==0)
{
C='9';
a=1;
while(input(C3)==0);
}
}

//ROW 4
output_a(0xf7);// ROW 1 1111 0111
delay_ms(5);
if((PORTa|0xf7)==0xf7)
{
if(input(C1)==0)
{
C='*';
a=1;
while(input(C1)==0);
}
else if(input(C2)==0)
{
C='0';
a=1;
while(input(C2)==0);
}
else if(input(C3)==0)
{
C='#';
a=1;
while(input(C3)==0);
}
}
}while(a==0);
return(C);
}


void lcd_init()
{
output_bit(pin_e0,0);//register select - Control Register
delay_ms(10);
comand(0x01); //Clear Display
delay_ms(1);
comand(0x06); // Entry mode
comand(0x38); // Function set
comand(0x80); // Starting Address for 1 row
comand(0x0F); // c on d on b on
output_bit(pin_e0,1); //Data register
}


void comand(char c)
{
output_d(c);//d=data
output_bit(pin_e1,1);//enable to send data to LCD
delay_ms(1);
output_bit(pin_e1,0);
}

void display_enter()
{
char a[]="enter the keypad";
for(i=0;i<=16;i++)
{
comand(a);
delay_ms(10);
}

}

void display_correct()
{
char a[]="correct password";
for(i=0;i<=16;i++)
{
comand(a);
}
}

void display_wrong()
{
char a[]="wrong password";
for(i=0;i<=16;i++)
{
comand(a);
}
}
void gsm_init()
{
//at
putc('\n');

delay_ms(2000);
for(i=0;i<2;i++)
{
putc(at);
x=getch();

}
putc(0x0d);
do{
x=getch();

}while(x!='K');
output_bit(pin_b7,1);
delay_ms(2000);
output_bit(pin_b7,0);
delay_ms(2000);
delay_ms(10);

//cmgf


for(i=0;i<9;i++)
{
putc(cmgf);
x=getch();

}
putc(0x0d);
do{
x=getch();

}while(x!='K');
output_bit(pin_b7,1);
delay_ms(2000);
output_bit(pin_b7,0);
delay_ms(2000);
delay_ms(10);

//cnmi
for(i=0;i<17;i++)
{
putc(cnmi);
x=getch();

delay_ms(3);
}
putc(0x0d);
do{
x=getch();

}while(x!='K');
output_bit(pin_b7,1);
delay_ms(2000);
output_bit(pin_b7,0);
delay_ms(2000);
delay_ms(20);
}

void gsm_tx()
{
i=0;
//cmgs
for(i=0;i<23;i++)
{
putc(cmgs);
x=getch();

delay_ms(3);
}
putc(0x0d);
do{
x=getch();

}while(x!='>');
delay_ms(20);
//message

for(i=0;msg1!='!';i++)
{
putc(msg1);
x=getch();
delay_ms(3);
}
putc(0x1a);

do{
x=getch();
}while(x!='K');

do{
x=getch();
}while(x!=0x0a);

output_bit(pin_b7,1);
delay_ms(2000);
output_bit(pin_b7,0);
delay_ms(2000);
}

please help to move on this..
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top