Arduino Projects   |   Raspberry Pi   |   Electronic Circuits   |   AVR   |   PIC   |   8051   |   Electronic Projects

serial communication in proteus and hyperterminal

17 posts / 0 new
Last post
Julian
Julian's picture
Offline
Last seen: 2 years 12 months ago
Joined: 16/07/2011 - 07:51
serial communication in proteus and hyperterminal

Hi, I just started some research on serial communication between pc and 8051. But i want to do it on proteus first, meaning hyperterminal will be linked with proteus. If i were to send characters from the pc to the 8051 to be displayed on a LCD, when I simulate on proteus I just type the characters on the terminal and write codes for the microcontroller to receive data serially right? Do I have to write codes for the terminal to send data too?  

 

 

nikhiljain
nikhiljain's picture
Offline
Last seen: 4 months 3 weeks ago
Joined: 29/07/2010 - 22:41
Well don't know whether it

Well don't know whether it will work or not...I think you will have to use the serial port because how will the hyper terminal get connected to Proteus. Check there should be some opiton of using sending or receiving dsta serially in Proteus.

Qaisar
Qaisar's picture
Offline
Last seen: 3 weeks 1 day ago
Joined: 30/06/2011 - 15:47
  hi   yes proteus has built

 

 hi

   yes proteus has built in virtual terminal that works as hyperteminal ..

 

 u can simulate ur code  ...

 u can find virtual terminal in virtual instrument list ...

here i have simple code that sends alphabets(A-Z) to PC..

if u really want to send any data from controller to PC or from PC to controller u need MAX232 between PC and micrcontroller...

 

Code:

 

     

 
/// programme to send alphabetic(A-Z) to PC through serial Port 
 
#include <AT89X51.H>
 
void delay(unsigned int d)
{
unsigned int i,j;
for(i=0;i<=d;i++)
for(j=0;j<=1000;j++);
}
void main(void)
{
unsigned char z;
TMOD=0x20;
TH1=0xF3;
SCON=0x50;
TR1=1;
while(1)
 
{
for(z=65;z<=92;z++)   // 65 is equivalent code for A.
{
SBUF=z;
if(z==92)
{
SBUF=13; /// carriage return
}
 
while(TI==0);
 
 
delay(50);
TI=0;
 
}
 
}

}

Qaisar
Qaisar's picture
Offline
Last seen: 3 weeks 1 day ago
Joined: 30/06/2011 - 15:47
(No subject)

[[wysiwyg_imageupload:2899:]]

Julian
Julian's picture
Offline
Last seen: 2 years 12 months ago
Joined: 16/07/2011 - 07:51
Hi Qaisar, Thx so much 4 your

Hi Qaisar,

 

Thx so much 4 your reply and the code you provided.  Yes, I know there is a virtual terminal in Proteus. Question, are the virtual terminal same as the hyperterminal of windows? Let's say if i were to use the virtual terminal,  i will need a virtual serial port driver right (read this from somewhere else)? The code you provided is to send characters to the virtual terminal from 8051. However, what I am trying to do is to send data from terminal to 8051 uC. Question, I know I wil have to write codes 4 the uC to receive data but do I have to also write codes for the terminal to send data? So is it automatically the virtual port will understand? 

Ya, I know about the max232 and rs232. I'm just very confuse about the terminals. Read through a lot of forums however no one discussed bout this. 

Qaisar
Qaisar's picture
Offline
Last seen: 3 weeks 1 day ago
Joined: 30/06/2011 - 15:47
  hi  no...there is no

  hi 

 

no...

there is no additional driver required to send data from PC hyperterminal to microcntroller..

all the coding has to do in microcontroller end ...

u just write any character in hyperterminal and it to will transfer to SBUF reg in microcontroller.. 

copy the content of SBUF reg and use that data ..

important thing is that the recieved data is in ascii format ..u have to convert to some other format as per ur requirement ..

 

 

regards...

Julian
Julian's picture
Offline
Last seen: 2 years 12 months ago
Joined: 16/07/2011 - 07:51
Hi, So meaning that I just

Hi,

 

So meaning that I just have to write my program in Keil uVision and generate hex file and load into proteus and setup the hyperterminal? 

 

 

Qaisar
Qaisar's picture
Offline
Last seen: 3 weeks 1 day ago
Joined: 30/06/2011 - 15:47
yes it is ...

yes it isyes ...

Julian
Julian's picture
Offline
Last seen: 2 years 12 months ago
Joined: 16/07/2011 - 07:51
Thanks so much for your

Thanks so much for your contribution. I appreciate your guidance =)

Aniket Deshpande
Aniket Deshpande's picture
Offline
Last seen: 3 years 1 month ago
Joined: 29/01/2012 - 00:28
Hi Qaisar,  I tried your code

Hi Qaisar, 

 

I tried your code on Proteus:

1. by connecting 8051 TXD directly to virtual terminal RXD as shown in the figure- I got garbage data on the virtual terminal.

2. by connecting MAX232 and RS232 between 8051 and virtual terminal- no data was recieved on the virtual terminal.

 

Another doubt I have is, shouldn't we enter the ASCII values in hex instead of decimal?

 

Aniket.

AKSHAY KAUNDAL
AKSHAY KAUNDAL's picture
Offline
Last seen: 6 months 1 week ago
Joined: 16/04/2012 - 22:58
how to create a virtual

how to create a virtual terminal

Anonymous (not verified)
Anonymous's picture
Garbage values are due to

Garbage values are due to unmatched baudrates ... set the baudrate of virtual terminal to 4800 ... and You'll get the desired output

mani sankar
mani sankar's picture
Offline
Last seen: 1 year 3 months ago
Joined: 17/06/2011 - 16:23
How to receive data from PC

How to receive data from PC ??

Amrith
Amrith's picture
Offline
Last seen: 1 year 12 months ago
Joined: 23/04/2012 - 16:57
hi mani,you can receive data

hi mani,

you can receive data using hyperterminal.. Go to start--> All Programs-->Accessories-->communication--> HyperTerminal

midhun
midhun's picture
Offline
Last seen: 1 year 5 months ago
Joined: 05/06/2012 - 14:47
Do you know visual basics? if

Do you know visual basics? if yes it will be a very easy task 4 u to do serial communication between PC and controller.  you can make your own GUI to transmit data and also to receive data. it will be very helpful in your future projects too..

ayushman
ayushman's picture
Offline
Last seen: 2 years 6 months ago
Joined: 11/08/2012 - 08:50
i want to do serial

i want to do serial communication from hyperterminal tp 8051 and want to display the text on LCD. all charecters are display correctly bet when i press spacebar the LCD display some garbage value. Is there any solution to to diplay the spacebar correctly on LCD. here is my code

 

 

#include<reg51.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;
}
// / / / / / / / / / / / / / / / / / / / / / / / / / / / / L   C  D VALUE//////////////////////////////////////
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=0,j=0;
 while(*ptr)
 {
 h++;
 if(h<15)
 {
 lcd_data(*ptr++);
 }
 if(h>=15)
 {
 lcdcmd(0xC0+j);
 lcd_data(*ptr++);
 j++;
 }
 }
 }
 // / / / / / / / / / / / / / / / / / / / / / / / / / / U  A  R  T INITIALIZATION///////////////////////////////
void uart_init()
{
TMOD=0x20;
TH1=0xFD;
SCON=0x50;
TR1=1;
}
// / / / / / / / / / / / / / / / / / / / / / / / / / / / L   C  D INITIALIZATION//////////////////////////////
void lcd_init()
{
lcdcmd(0x38);
lcdcmd(0x0E);
lcdcmd(0x01);
lcdcmd(0x06);
lcdcmd(0x80);
}
/////////////////////convert HEX  TO ASCII////////////////////////////
unsigned char convertascii(unsigned char temp)
{
if(temp==' ')
{
return(temp+0x20);
}
else if(temp>=0x0a)
{
return(temp+0x80);
}
}
////////////////////////////////////MAIN/////////////////////////////////////
void main()
{
unsigned char str2[40],*ptr,temp1;
unsigned int i=0;
ptr=str2;
uart_init();
lcd_init();
while(SBUF!=0x0D) //Checking if the enter is pressed or not
{
while(RI==0);
RI=0;
temp1=SBUF;
str2[i]=convertascii(temp1);
i++;
}
str2[i]='\0';
string_lcd(ptr);
while(1);
}
 

 

amit
amit's picture
Offline
Last seen: 2 years 1 month ago
Joined: 13/07/2012 - 06:08
code ofinterface 8051

code of

interface 8051 to

pc(hyperterminal)

 to transfer string of data................

Log in or register to post comments