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 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
mayengbam
Sun Nov 04 2018, 05:41 PM
hello, i am niranjoy, alll the port of my 8051 is always high, even i erase all the program. why is it so happen and what is the problem. any one please help me!
Sun Nov 04 2018, 02:16 PM
BASAVARAJ g kudamble
hi I am interfacing GSM 300 to 8051 microcontroller to receive message from mobile
ExperimenterUK
Sat Sep 29 2018, 06:28 PM
Please post questions in the forum.
Sat Sep 29 2018, 11:26 AM
Ashfaq Ch
hi i have some AT89C51RC microcontrollers already programed. some one help us to how to download from AT89C51RC and after study and edit all corractions reload to AT89C51RC controller

Downloads

Comments

cadetjeff
Fri Dec 07 2018, 10:11 AM
crak0axel
Sun Dec 02 2018, 01:12 AM
AbuHishaam
Thu Nov 29 2018, 03:43 PM
Evgen87
Thu Nov 29 2018, 10:44 AM
akshaykulkarni
Mon Nov 26 2018, 05:18 AM
atalnet
Fri Nov 16 2018, 07:44 AM
genius784
Wed Nov 14 2018, 09:25 AM
katherineamt
Mon Nov 12 2018, 03:14 PM

Online

Guests: 46, Members: 0 ...

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

Members: 38026
Newest member: cadetjeff
Forum Activity
ExperimenterUK Avatar
Posted By ExperimenterUK
Mon Nov 19 2018, 01:11 AM
ExperimenterUK Avatar
Posted By ExperimenterUK
Thu Nov 15 2018, 06:48 PM
Unfortunately I have no experience of LabView,but ...
katherineamt Avatar
Posted By katherineamt
Mon Nov 12 2018, 03:22 PM
I have never used LabView and I have to implement ...
ExperimenterUK Avatar
Posted By ExperimenterUK
Mon Nov 12 2018, 01:21 AM
wimac Avatar
Posted By wimac
Sun Nov 11 2018, 04:03 PM
bgk3678 Avatar
Posted By bgk3678
Sun Nov 11 2018, 07:25 AM
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Nov 06 2018, 06:10 PM
bgk3678 Avatar
Posted By bgk3678
Sun Nov 04 2018, 02:52 PM
bgk3678 Avatar
Posted By bgk3678
Sun Nov 04 2018, 02:48 PM
Xuenan Avatar
Posted By Xuenan
Sat Nov 03 2018, 01:08 PM
Make the 8051 frequency exactly 11.0592 MHz in pro...