Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

how to transmit data from RFID to lcd using 8051 in embeddedc language

Status
Not open for further replies.

rockey bhardwaj

Newbie level 1
Newbie level 1
Joined
Sep 6, 2013
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
20
Goodevening everyone


I am making an attendence system using 8051.But Id number is not displaying on the lcd. i am using the controller 8051. But I am fail to receive the data on lcd . If anyone know to display the data on lcd. Then please help me.
this is the code :
//Program to interface RFID with 8051 microcontroller (AT89C51)
#include<reg51.h>
unsigned int data_out,command=0x80,temp;
sfr lcd_data_pin=0xA0; //P2 port
sbit rs=P1^0; //Register select
sbit rw=P1^1; //Read/Write
sbit en=P1^2; //Enable pin
unsigned char card_id[12];

void delay(unsigned int count) //Function to provide delay
{
int i,j;
for(i=0;i<count;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;
delay(1);
en=0;
}

void lcd_data(unsigned char disp) //Lcd data function
{
lcd_data_pin=disp;
en=1;
rs=1;
rw=0;
delay(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);
delay(5);
lcd_command(0x0F);
delay(5);
lcd_command(0x80);
delay(5);
}

void recieve() //Function to recieve data serialy from RS232
{
unsigned char k;
for(k=0;k<12;k++)
{
while(RI==0);
card_id[k]=SBUF;
RI=0;
}
}

void main()
{
int l;
TMOD=0x20; //Enable Timer 1
TH1=0XFD;
SCON=0x50;
TR1=1; // Triggering Timer 1
lcd_ini();
lcd_command(0x81); //Place cursor to second position of first line
lcd_string("UNIQUE CARD ID:");
delay(200);
while(1)
{
recieve();
lcd_command(0xC1); //Place cursor to second position of second line
for(l=0;l<12;l++)
{
lcd_data(card_id[l]);
}
}
}
 

Hi,

Delay may be the problem ..please verify your hardware connection once again..

Code:
void lcd_data(unsigned char disp) //Lcd data function
{
lcd_data_pin=disp;
en=1;
rs=1;
rw=0;
delay(5);
en=0;
}
Try these code..
Code:
#include <reg51.h>       //Define 8051 Registers
#include <stdio.h>       //Define I/O Functions
//#define DATA P0          //Define DATA to Port2
//sbit RS   = P0^0;        //Register Select
//sbit RW   = P0^1;        //LCD Read/Write
//sbit lcd_e = P0^2;       //LCD Enable
unsigned int data_out,command=0x80,temp;
sfr lcd_data_pin=0xA0; //P2 port
 sbit rs=P1^0; //Register select 
sbit rw=P1^1; //Read/Write 
sbit en=P1^2; //Enable pin
code unsigned char msg[]   = (" PS.PRIMER-8051 ");    //Display
code unsigned char msg1[] = (" 2x16 LCD DEMO ");
 
//----------------------------------
//         LCD Functions
//----------------------------------
void lcd_init(void);
void lcd_cmd(unsigned char);
void lcd_display(unsigned char);
void DelayMs(int);
 
//----------------------------------
//       LCD command Function
//----------------------------------
void lcd_cmd(unsigned char cmnd)  
{
    DATA = 0xf0&cmnd;                      //Masking lower 4 Bits
    RS = 0;  RW = 0;
    lcd_e = 1;
    DelayMs(35);
    lcd_e = 0;
 
    DATA = cmnd*16;                             //Masking lower 4
    RS = 0;  RW = 0;
    lcd_e = 1;
    DelayMs(35);
    lcd_e = 0;
 
}
 
//----------------------------------
//       LCD Data Function
//----------------------------------
void lcd_display(unsigned char dat)   
{
    DATA = 0xf0&dat;                            //Masking lower 4
    RS = 1;  RW = 0;
    lcd_e = 1;
    DelayMs(35);
    lcd_e = 0;
 
    DATA = dat*16;                              //Masking lower 4
    RS = 1;  RW = 0;
    lcd_e = 1;
    DelayMs(35);
    lcd_e = 0;
 
 
}
 
//----------------------------------
//       LCD Delay Function
//----------------------------------
void DelayMs(int k)  
    {
    unsigned int a;
    for(a=0;a<=k;a++);
    }
 
//----------------------------------
//       LCD Initialization
//----------------------------------
void lcd_init(void)  
{
    unsigned char i;
   
         lcd_cmd(0x28);                     //2x16 Character 5x7
         DelayMs(15);  //matrix LCD,4-bit format
         lcd_cmd(0x0c);                                     
         DelayMs(15);
         lcd_cmd(0x06);                                     //Shift
         DelayMs(15);
         lcd_cmd(0x01);                                     
         DelayMs(15);
 
//-------------------------------------------
//       First Line Message Display
//-------------------------------------------
         lcd_cmd(0x80);                                     
    DelayMs(35);
         i=0;
         while(msg[i]!='\0')
         {
             lcd_display(msg[i]);
             i++;
         }
    DelayMs(50);
 
//-------------------------------------------
//       Second Line Message Display
//-------------------------------------------
         lcd_cmd(0xc0);                                     //Second
         DelayMs(35);
         i=0;
         while(msg1[i]!='\0')
         {
             lcd_display(msg1[i]);
             i++;
         }
    DelayMs(50);
}
 
 
 
 
 
 
 
 
//----------------------------------
//       LCD Main Program
//----------------------------------
void main(void)
{
    P0 = 0;
    lcd_init();         //LCD Initialization
    DelayMs(1); 
    DelayMs(1); 
    while(1);            //Loop Forever
}

update me.

Best regards,
 

Attachments

  • 8051 8bit LCD CCT.JPG
    8051 8bit LCD CCT.JPG
    65.4 KB · Views: 111
  • lcd_8051.jpg
    lcd_8051.jpg
    35.4 KB · Views: 101
  • lcd8bit.GIF
    lcd8bit.GIF
    12.1 KB · Views: 100

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top