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

Thu Dec 12 2019, 09:16 PM
enrexzweuz
qdimekzibi
Thu Nov 21 2019, 12:30 PM
raj2555
how to interface 8051 microcontroller with NRF24L01+ module
ExperimenterUK
Sat Oct 12 2019, 10:23 PM
Log in.. then post your code in the 8051 forum
Sat Oct 12 2019, 10:18 AM
Bhadra Sajikumar
i am doing a countdown timer with 8051 for my project, unfortunately our professor had to take a leave of absence before he could teach us most of it.. can someone explain the .asm code of it for me?
Mon Sep 23 2019, 07:37 AM
Nathaniel
I am doing a project for my schools wireless security system with cameras,sensors and spot lights using 8051 micro controller, could you help me out with the design and its source code.
Wed Sep 18 2019, 08:48 PM
Caryn Kover
Thank you for your time,
ExperimenterUK
Mon Aug 05 2019, 07:09 PM
@Ismail ..post in forum, give details
Mon Aug 05 2019, 04:33 PM
Ismail balghmi
Hello. Please I won't download
ExperimenterUK
Wed Jul 24 2019, 12:47 AM
@BUSTER123 Please post in the forum
Tue Jul 23 2019, 06:13 PM
BUSTER123
hello! newbie here. i am kind of a guy who hates using ready - made existing libraries, so this helped a lot as i was trying to control and write to a character lcd display. however, i can't figure out how to set the cursor position. for example, i want to set it to the 5th column in the first row, so position 5. so according to the table, i am sending 10000101 on the 8 data lines of the lcd (register select pulled low). the cursor does not move there however. and i cant move the cursor left or right too. is it something wrong that i am doing? thank you.

Downloads

Comments

Istika
Thu Dec 12 2019, 12:04 PM
nabiha_anaya
Sun Dec 08 2019, 09:16 AM
ananyagupta
Tue Dec 03 2019, 07:53 AM
wells
Mon Nov 25 2019, 08:25 PM
auwal
Tue Nov 19 2019, 03:13 PM
ANKITPATEL
Mon Nov 18 2019, 11:00 AM
Casmir
Wed Nov 13 2019, 06:25 AM
DeepakBGattani
Mon Nov 11 2019, 01:31 PM

Online

Guests: 42, Members: 0 ...

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

Members: 38109
Newest member: Istika
Forum Activity
ilylily07 Avatar
Posted By ilylily07
Thu Dec 12 2019, 02:26 PM
wil do.thank you for your advice!
ExperimenterUK Avatar
Posted By ExperimenterUK
Thu Dec 12 2019, 07:13 AM
Something like this ?https://www.bing.com/videos/s...
ExperimenterUK Avatar
Posted By ExperimenterUK
Thu Dec 12 2019, 06:58 AM
The layout is a bit different, but it is the same ...
ilylily07 Avatar
Posted By ilylily07
Thu Dec 12 2019, 04:38 AM
https://i.imgur.com/6S5FcwF.png right now im follo...
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Dec 10 2019, 04:49 PM
ilylily07 Avatar
Posted By ilylily07
Sun Dec 08 2019, 01:24 PM
Hi .im humbly ask for your advice as i wrongly pur...
nabiha_anaya Avatar
Posted By nabiha_anaya
Sun Dec 08 2019, 09:19 AM
My teacher assign me a project on "voice control h...
ExperimenterUK Avatar
Posted By ExperimenterUK
Fri Nov 29 2019, 04:24 AM
" Is it possible to interface a fingerprint scanne...
ilylily07 Avatar
Posted By ilylily07
Thu Nov 28 2019, 03:50 PM
You will not find any code for an 8051 as no one w...
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Nov 26 2019, 05:44 PM
You will not find any code for an 8051 as no one w...