send data or char 4m hyperterminal to lcd using 89c51

Status
Not open for further replies.

ronkpatell

Member level 5
Joined
Feb 2, 2012
Messages
85
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
ahemdabad
www.epromsis.com
Activity points
1,894
send data or char 4m hyperterminal to 16x2 lcd using 89c51

hi
how i can send data from hyperterminal to lcd via 89c51 .
i have done all hardware connection as well as try some code but they r not working can u suggest me bcz i m newr for 8051.
 

what problem are you facing?
elaborate your question so that everyone can understand what exactly you want.

Have you done with serial communication of 8051 with PC using hyperterminal? or do you have any problem in it?
Have you done with LCD interfacing with 8051?
are you facing problem while combining these tasks??
 
hi jigar
i want to interface rs232 with lcd 16x2 using 89c51. i.e
my main agenda is that what i m written in hyper terminal that text may shown on lcd.
i had try some code but there is no any result .
And i using 8051 project board u can see here **broken link removed**
 

I get what you want ronak, But you've not mention where you had stuck with which problem?
Are you looking for which kind of help??? Regarding the communication between hyperterminal - 8051 or LCD - 8051 or both?
You have mentioned that you had write some code but there is no result! So I am sending you the individual codes for LCD with 8051 & regarding hyperterminal.
you just need to combine them...
I am also posting the proteus files so you can simulate it.
 

Attachments

  • LCD_8051_Hyperterminal.zip
    129.1 KB · Views: 148
yes dude my code was wrong i have both problem of communication between hyperterminal - 8051 and LCD .can u give me that code .
exactly i want send text from pc in 89c51 and that text must show on the a 16x2 LCD get it.
 

No jay .there is no moment on LCD.
plz yaar help .and i did loaded your .hex file in my 89c51 but there is no moment .
and i m also trying for another code also
#include <REGX51.H>
sbit rs= P2^0;
sbit rw= P2^1;
sbit en= P2^2;
////////////////////////////////////Delay////////////////////////////////////
void mdelay(unsigned int itime)
{
unsigned int i,j;
for(i=0;i<itime;i++)
for(j=0;j<1275;j++);
}
/// / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / L C D COMMAND////////////////////////////////////
void lcdcmd(unsigned char value)
{
P1=value;
rs=0;
rw=0;
en=1;
mdelay(1);
en=0;
}
void lcd_data(unsigned char value)
{

P1=value;
rs=1;
rw=0;
en=1;
mdelay(1);
en=0;
}
/////////////////////////////////STRING LCD////////////////////////////////
void string_lcd(unsigned char * ptr)
{
unsigned int h,j=0;
while(*ptr)
{
h++;
if(h<15)
{
lcd_data(*ptr++);
}
if(h>=15)
{
lcdcmd(0xC0+j);
lcd_data(*ptr++);
j++;

}
// *(ptr++);
}
}
//INITIALIZATION///////////////////////////////
void uart_init()
{
TMOD=0x20;
TH1=0xFD;
SCON=0x50;
TR1=1;
}
/// / / / / / / / / / / / / / / / / / / / / / / / / / / / / L C D INITIALIZATION//////////////////////////////
void lcd_init()
{
lcdcmd(0x38);
//mdelay(250);
lcdcmd(0x0E);
//mdelay(250);
lcdcmd(0x01);
//mdelay(250);
lcdcmd(0x06);
lcdcmd(0x80);
} //mdelay(250);

void main()
{

unsigned char str2[40],*ptr;
unsigned int i;
ptr=str2;
uart_init();
lcd_init();

while(SBUF!=0x0D) //Checking if the enter is pressed or not
{
while(RI==0); RI=0; str2=SBUF; i++;
}
str2='\0';
string_lcd(ptr);
// To display on LCD
/* for(i=0;i<6;i++)
{
lcd_data(str2);
}*/
while(1);
}
 
Last edited:

but that is not working.what i m wrote in hyperterminal that is not going to be display on LCD.

What I've sent you is individual code: one is for LCD with 8051 & one is to get echo from 8051 which can be displayed on hyperterminal...
you need to combine them properly... I've used both of them and both are working fine on hardware.
I've also sent you the proteus files of LCD with 8051.
 
Where is the LCD data port configuration in the code? Jigar's file works but you have to change the #defines for RS, RW, EN, and Data pins of LCD.

check the LCD.h file. Everything is defined there... And it'll work without any kind of modification.
If you want to verify then simulate the proteus files first. Just load the .hex file in it & see the result... your circuit may differ with what I've configure in my code and in proteus circuit.

@ ronak patel, I don't know why you are still looking for any code... you have everything.
 
but that hex file i did download same code in 89c51.but not working #include<at89c51xd2.h>
#include<string.h>
#include<stdio.h>
#define DATA P2
sfr16 DPTR=0x82;
sbit RS = P3^2;
sbit RW = P3^3;
sbit E = P3^4;
sbit b = P2^7;
unsigned char d,m;
unsigned int x,y,z,n,var;
float xdata c;
char xdata str[15];

void delay(unsigned char count) //1ms delay
{
for(m=0;m<count;m++)
for(n=0;n<1275;n++);
}

void busy()
{
b=1;
RS=0;
RW=1;
E=0;
delay(1);
E=1;
while(b==1);
{
}
}

void command(unsigned char value)
{
busy();
DATA = value;
RS = 0;
RW = 0;
E = 1;
delay(1);
E = 0;
}

void displayd()
{
d+=0x30;
busy();
DATA = d;
RS = 1;
RW = 0;
E = 1;
delay(1);
E = 0;
}

void displayvalue(value)
{
busy();
DATA = value;
RS = 1;
RW = 0;
E = 1;
delay(1);
E = 0;
}

void displayvariable()
{
DPTR=var;
x=DPTR/10;
y=x/10;
z=y/10;
d=DPTR%10; //D0
command(0x8C);
displayd();
d=x%10; //D1
command(0x8B);
displayd();
d=y%10; //D2
command(0x8A);
displayd();
d=z%10; //D3
command(0x89);
displayd();
d=z/10; //D4
command(0x88);
displayd();
}

void displaystring(unsigned char *s) reentrant
{ unsigned char l,k;
l=strlen(s);
for(k=1;k<=l;k++)
{
displayvalue(*s);
s++;
}
}
void displayfloat()
{
sprintf(str,"%4.2f",c);
displaystring(str);
}




and how that code combine with another code .?
 
Last edited:

and how that code combine with another code .?

You don't have to combine any code for interfacing LCD with 8051...
It'll work as it is.

And by the word "combine" I mean that to display the characters on LCD which you write on Hyperterminal needs a program which can receive the data from UART at 9600 baudrate and then send the data of SBUF on LCD & to do that you can take reference from the two codes which I've posted. 1 is for LCD with 8051 and 2nd is to get echo from 8051 on hyperterminal... By taking the reference from these codes you can achieve your goal.

Regarding the code which you've post is the .h file which I've made it is not the main code... I've just include it as a header file which has some definitions and declarations.
The main code is LCD Header file.c

And regarding your confusion, I think you haven't checked the proteus files yet... have you checked?? Have you arranged your schematic as per the pin definition I've used in my code? (some time such mistakes consume our time).

What I suggest to you is to run the proteus files first which will clear your confusion... After that post your next problem I/any other will help you to solve it.
 

then may i use LCD header file.c for make lcd header file .hex then i have to use that .hex file in 89c51 u said that m i right(1)?and ur .zip file there are two files means 1's lcd header file.c and 2nd is hyperterminal.c m i right(2)?
and how i can use both file to make single .hex file .?i got more confusion .i cant able to understand pls expln me.
and i m also followed your lcd.GIF file .

- - - Updated - - -

Please post you keil project files and Proteus file. I will check it. Zip the files before posting.

and i try also that code as well as @jigar's code .
and my code in posted below in .zipView attachment rs232 to lcd.zip

- - - Updated - - -

Please post you keil project files and Proteus file. I will check it. Zip the files before posting.

and i try also that code as well as @jigar's code .
and my code in posted below in .zipView attachment rs232 to lcd.zip
 

i got more confusion .i cant able to understand pls expln me.
and i m also followed your lcd.GIF file .

okay, I think you're not getting what I mean.

Now, I am sure that you've not even open the proteus files, Am I right???

I think you're not even using that software, am I right?

What I've said to do is, open proteus files and simulate the circuit.
for that you've to download and install proteus v7 or higher. Search for Labcenter Electronics - Proteus ISIS Schematic Capture.

Then open then open the .dsn file I've posted using that software.
double click on the IC of 8051, and using the browse button locate the .hex file in it (the .hex file which you've found in the .zip folder which I've posted)

Now you'll see a "play" button on the screen of that software at left bottom : just click it and watch!

Regarding that .gif file it is a sample schematic digram which I've included in that .zip file, don't make your self confused with it.. that is just an image.

how i can use both file to make single .hex file .?

You have to take a reference from both of those codes and has to make a final code by your own and then build your target and so you'll get the final .hex file, you've to use/refer the logic whic has been used in both the programs and have to make your final code by your own.

But before that, just go for only LCD - 8051 interfacing. After that, go for 8051 - PC (hypreterminal) interfacing and when you successfully complete these both go for the final stage, means PC (Hyperterminal) -> 8051 -> LCD.

I hope you get it now. If you've still any confusion then let me know.

one more thing, If you're new to proteus then I would like to mention that your whole project can be implement on proteus... So you should implement it on proteus first and if it works then go for the hardware.

Hope I am making sense to you.
 
I saw you code. There is no #define LCD_DATA_PORT P2. That is there is no definition of LCD Data Port in the code. Post how your LCD is connected to MCU.
can it possible that l#define LCD_DATA_PORT P2l for lcd that can be add in my code?

- - - Updated - - -

my circuit diagram is in pdf plz check it.
Is it correct or need some changes?
 

Attachments

  • LCD1 crkt.pdf
    9.6 KB · Views: 132

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…