Discussion in "Project Addition or Changes" started by    bgk3678    Nov 4, 2018.
Sun Nov 04 2018, 02:48 PM
#1
#include<reg51.h>
unsigned int data_out,command=0x80,temp,r;
sfr lcd_data_pin=0x90; //P1 port
sbit rs=P2^0; //Register select
sbit rw=P2^1; //Read/Write
sbit en=P2^2; //Enable pin
//unsigned char match;
unsigned char m,key,count,index=3,k,i1,x1;
unsigned char x[100];


void delay1(unsigned int itime )
{
unsigned int i,j;

for (i=0;i<itime;i++)
for (j=0;j<1275;j++);
}

void lcd_command(unsigned char comm) //Lcd command funtion
{
lcd_data_pin=comm;
en=1;
rs=0;
rw=0;
delay1(1);
en=0;
}

void lcd_data(unsigned char disp) //Lcd data function
{
lcd_data_pin=disp;
en=1;
rs=1;
rw=0;
delay1(1);
en=0;
}

lcd_string(unsigned char *disp) //Function to send string
{
int x;
for(x=0;disp[x]!=0;x++)
{
lcd_data(disp[x]);
}
}
void lcd_ini() //Function to initialize the LCD
{
lcd_command(0x38);
delay1(5);
lcd_command(0x0F);
delay1(5);
lcd_command(0x80);
delay1(5);
}



void serialcom()
{
TMOD=0x20;
TH1=0xFD;
SCON =0x50;
TR1=1;
}


void serial(unsigned char x)
{
SBUF=x;
while(TI==0);
TI=0;
}
unsigned rx_data(void)
{
while(RI == 0); // WAIT UNTIL DATA IS RECEIVED
RI = 0; // CLEAR FLAG
return SBUF; // RETURN SERIAL DATA

}

void send2gsm(char *aaa)
{
unsigned int i;
for(i=0;aaa[i]!='\0';i++)
{
serial(aaa[i]);
}
}

void main()
{
//int l;
TMOD=0x20; //Enable Timer 1
TH1=0XFD;
SCON=0x50;
TR1=1; // Triggering Timer 1
lcd_ini();
delay1(200);

lcd_command(0x81); //Place cursor to second position of first line
//lcd_string("gsm3 interface: ");
delay1(200);
lcd_command(0x80);
lcd_string(" bgk GSM ");
lcd_command(0xc1);
serialcom();
send2gsm("AT");
serial(0x0D);
serial(0x0A);

delay1(2);
send2gsm("AT+CMGF=1");
serial(0x0D);
serial(0x0A);

delay1(2);








while(1)
{
send2gsm("AT+CMGR=1");
serial(0x0D);
serial(0x0A);





while(rx_data() !='+' );


for(i1=0;i1<40;i1++)

{
x[i]=rx_data();
}
delay1(20);

for(i1=0;i1<40;i1++)
{
lcd_data(x[i]);


delay1(20);


}


}
}
Sun Nov 04 2018, 02:52 PM
#2
sir ,
as I have posted the code ,it is not displaying the message from second line actually message is in second line
Tue Nov 06 2018, 06:10 PM
#3
I got this output in Proteus.



What are you expecting to happen ?


[ Edited Thu Nov 08 2018, 04:50 AM ]
Sun Nov 11 2018, 07:25 AM
#4
sir,Thank you for your response .The bgk GSM is the starting message will display on LCD, after that message sent by mobile will be displayed on LCD.
Sun Nov 11 2018, 04:03 PM
#5
I was just passing through looking for something else and noticed your post.

I'm not familiar with the GSM300 but a couple of things stand out from the code in the first post.

1) Some LCD displays have a small setup time from RS and RW to the leading edge of EN so it would be safer to put "en=1" after setting "rs" and "rw" in lcd_command() and lcd_data().
eg:
rs=0;
rw=0;
en=1;

2) In main() the code uses "i1" as the variable in the for loops but "i" as the variable for indexing the array x[].
This could just be a typing mistake in the first post or possibly the source of the problem.



[ Edited Sun Nov 11 2018, 04:03 PM ]
Mon Nov 12 2018, 01:21 AM
#6


2) In main() the code uses "i1" as the variable in the for loops but "i" as the variable for indexing the array x[].
This could just be a typing mistake in the first post or possibly the source of the problem.

wimac


Thanks for the comments.
Actually the missing "1" is due to the way the website handles text.
For some reason it deletes that "1".


[ Edited Tue Nov 20 2018, 05:39 AM ]
Mon Nov 19 2018, 01:11 AM
#7
I used your code in a Proteus simulation that can simulate a very simple modem.
Here is the result.
The Terminal box on the left is output from the 8051.
At the bottom is the modem's reply.

As you can see, you should get some text on line 2.
Because of the way the LCD displays text, more text would appear on line 4 of a 4 line display.
You have to display the text in chunks ,16 chars for 16 char wide displays, 20 for 20.
Move the cursor to a new line for each chunk.




[ Edited Tue Nov 20 2018, 05:39 AM ]

Get Social

Information

Powered by e107 Forum System

Conversation

ExperimenterUK
Mon Jan 07 2019, 03:31 AM
@REVOCATUS please post in the AVR forum
Mon Dec 24 2018, 09:25 AM
REVOCATUS MATEMU
sorry I mean referee boards for player substitution
Mon Dec 24 2018, 09:24 AM
REVOCATUS MATEMU
hi am.looking how to build referee by using Atmega 328 and its codes
Sat Dec 15 2018, 01:45 PM
Arslan ayoub
Hii ,, can I get the simulation of numeric keypad lock on proteus
ExperimenterUK
Mon Dec 03 2018, 05:17 PM
Please post questions in the forum. The chat box is for chat
Mon Dec 03 2018, 06:43 AM
help!me!
help! I don't understand busy flag!
Sun Dec 02 2018, 08:01 PM
ile
hello
Mon Nov 12 2018, 05:58 AM
Pavan_user
i have seen your replica of I2C programming using AT89C51 but i am unable to understand the "ack_bit" variable usage ...looks like it is always 1...can you elaborate how acknowledgment is working....
bgk3678
Tue Nov 06 2018, 02:36 PM
kindly any one give solution for my problem
ExperimenterUK
Mon Nov 05 2018, 09:48 PM
Pins high is the normal state. You need a program to set them low

Downloads

Comments

the_Doker
Thu Feb 14 2019, 02:21 PM
XanZes
Thu Feb 14 2019, 01:02 AM
dominicchiori
Wed Feb 06 2019, 01:41 AM
tandong
Sun Jan 27 2019, 01:38 PM
Rizz
Fri Jan 25 2019, 06:24 PM
Kheirodin
Tue Jan 22 2019, 11:54 PM
garfield0929
Sun Jan 20 2019, 12:48 AM
servprov
Thu Jan 17 2019, 06:44 AM

Online

Guests: 49, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 05:37 AM

Members: 38045
Newest member: the_Doker
Forum Activity
ExperimenterUK Avatar
Posted By ExperimenterUK
Sat Jan 26 2019, 07:19 PM
Yes that helps a lot.At first sight I can't see th...
Rizz Avatar
Posted By Rizz
Sat Jan 26 2019, 06:43 AM
@ExperimenterUK I have updated the post with more ...
ExperimenterUK Avatar
Posted By ExperimenterUK
Sat Jan 26 2019, 02:30 AM
What is your definition of a Palindrome ?The ones ...
Rizz Avatar
Posted By Rizz
Fri Jan 25 2019, 06:31 PM
I have written a code to check if a number is a pa...
ExperimenterUK Avatar
Posted By ExperimenterUK
Sun Jan 06 2019, 10:37 PM
Which 8051 chip are you using ?
SONACHAI1234 Avatar
Posted By SONACHAI1234
Sun Jan 06 2019, 08:21 AM
Hi,By mistakenly i burn rx program in my 8051 micr...
ExperimenterUK Avatar
Posted By ExperimenterUK
Wed Dec 19 2018, 06:27 PM
Nobody knows?sifirsekizThe problem is that you are...
sifirsekiz Avatar
Posted By sifirsekiz
Wed Dec 19 2018, 12:15 PM
sifirsekiz Avatar
Posted By sifirsekiz
Sun Dec 16 2018, 11:13 PM
Guys pleaseeeee :((
sifirsekiz Avatar
Posted By sifirsekiz
Sat Dec 15 2018, 07:09 PM
HiThe pulse-sensor-amped has an analogue output.Th...