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.

RFID and MAX232 connection with microcontroller

Status
Not open for further replies.
i refered that website. but its not working
 

i am using AT89C51 only.
 

Last edited:

yes you need to store the data in the array with new updated values of SBUF as it can store only 1 byte of data in it. then you need to compare the array with the predefined array with rfid tag values and perform the required operation, if the new array value and stored array value matches. you need to hard code the rfid card values in the array declared, by getting the data when you test rfid card with pc on hyperterminal.

dont forget Max232 on the controller side. :)
 
  • Like
Reactions: bagya

    bagya

    Points: 2
    Helpful Answer Positive Rating
i attached my code in this..pls check and tell what is the error... i want to compare the RFID ID and want to display 'k' which is in the void get();function.

#include<reg51.h>
#include<intrins.h>
void delay (unsigned char);
void command (unsigned char);
void display (unsigned char);
sbit RS=P2^0;
sbit RW=P2^1;
sbit EN=P2^2;
sbit BUSY=P0^7;
unsigned char c,i,b,a;
unsigned char card_id[8];
void command(unsigned char);
void recieve();
void lcd_string();
void ready();
void get();
unsigned char tag[8]={'1','5','4','2','7','4','1','2'};
unsigned char tag1[8]={'1','5','4','2','8','7','5','2'};
unsigned char disp[3]="ID:";
void main()
{
//unsigned char j,l;
P0=0x00;
TMOD=0x20;
TH1=0XFD;
SCON=0x50;
TR1=1;
command(0x38);
command(0x01);
command(0x0e);
//command(0x06);
command(0x80);
lcd_string();
command(0xc0);
IE=0X90;
while(1);
}
void get()
{
unsigned char j,count=0;
for(j=0;j<8;j++)
{
if(card_id[j]==tag[j])
{
count++;
}
}
if(count==8)
{
display('k');
}
}

void lcd_string()
{
for(i=0;i<3;i++)
{
b=disp;
display(b);
}
}

void receive(void) interrupt 4
{
unsigned char k=0;

if(RI==1)
{
for(k=0;k<8;k++)
{
card_id[k]=SBUF;
}
get();
RI=0;
}
}
void command (unsigned char a)
{
ready();
RS=0;
RW=0;
P0=a;
EN=1;
_nop_();
_nop_();
EN=0;
}

void ready()
{
RS=0;
RW=1;
BUSY=1;
EN=0;
_nop_();
_nop_();
EN=1;
while(BUSY==1);
}

void display(unsigned char b)
{
ready();
RS=1;
RW=0;
P0=b;
EN=1;
_nop_();
_nop_();
EN=0;
}
 

functions are never called in main. and while(1); will permanently stop the execution. you have written the functionality for many functions but never called from main.
is it the final code
 

functions are never called in main. and while(1); will permanently stop the execution. you have written the functionality for many functions but never called from main.
is it the final code
this s not my final code...what function should i call from main and if i did't give while(1); means the program will end correct?
 

bagya;

the functions you have written below the main function like 1. void get() 2. lcd dispaly and all other functions have to be called from main function. Only if they are called from main function they will execute or else the functions will never execute and you will not get any output.
it will be easy for you to understand if you can debug the program step by step in keil. you will understand where you are going wrong and what i am trying to tell you. please call the functions from main.
could you use the debug option in keil to know when the functions you have written are called and what is the output of each function.
let me know if you have any issues
 

check this code sir...
#include<reg51.h>
#include<intrins.h>
void delay (unsigned char);
void command (unsigned char);
void display (unsigned char);
sbit RS=P2^0;
sbit RW=P2^1;
sbit EN=P2^2;
sbit BUSY=P0^7;
unsigned char c,i,b,a;
unsigned char card_id[8];
void command(unsigned char);
void recieve();
void lcd_string();
void ready();
void get();
void main()
{
unsigned char byte;
P0=0x00;
TMOD=0x20;
TH1=0XFD;
SCON=0x50;
TR1=1;
command(0x38);
command(0x01);
command(0x0e);
command(0x06);
//command(0x80);
command(0xc0);
IE=0X90;
while(1)
{
if(byte==8)
{
lcd_string();
}
}
}
void lcd_string()
{
for(i=0;i<8;i++)
{
b=card_id;
display(b);
}
}

void receive(void) interrupt 4
{
unsigned char k=0,byte=0;

if(RI==1)
{
for(k=0;k<8;k++)
{
card_id[k]=SBUF;
byte++;
RI=0;
}
}
}
void command (unsigned char a)
{
ready();
RS=0;
RW=0;
P0=a;
EN=1;
_nop_();
_nop_();
EN=0;
}

void ready()
{
RS=0;
RW=1;
BUSY=1;
EN=0;
_nop_();
_nop_();
EN=1;
while(BUSY==1);
}

void display(unsigned char b)
{
ready();
RS=1;
RW=0;
P0=b;
EN=1;
_nop_();
_nop_();
EN=0;
}
 

maybe you are not comfortable with C programming.

the functions void recieve();
void ready();
void get();
void delay (unsigned char);
void command (unsigned char);
void display (unsigned char);


will never execute because you have not called them from main like you have called void lcd_string();

LCD initialization should be done only once in the beginning of the main function and not every time. your program is initializing the lcd in infinite loop, which on hardware will keep initializing the lcd and you wont see any output.
Am i making it clear for you or am i confusing you?
 

Where is the delay() and get() function definitions? Where is the call for get() function in the main loop as already mentioned. Is you rfid tag 8 bytes? And use code tags to post code here. Build your project step by step. First try to displat "RFID Card Reader" on LCD line 1. if that works then write the code to get the rfid and display it.

I don't know what clock frequency is used in the code I mentioned. The timer was designed according to that clock frequency. If you are using a different clock you have to modify your timer values. Also the code I mentioned uses 8-bit lcd mode. Are you using 4-bit or 8-bit lcd mode?

for lcd code see these http://saeedsolutions.blogspot.in/2012/05/8051-lcd-interfacing-code-in-4bit-mode.html
 
Last edited:

thank u sir...but i can't get where iam intializing lcd in infinite loop...if i give display(); below the lcd_string(); in main means it will work?
 

Lcd code in saeedsolutions is working. I tested it. How does your rfid send data? how many bytes it send. I will try to code.

If you are using port P0 for anything then you have to use pullup resistor on P0 lines.
 

Attachments

  • 4 bit lcd.jpg
    4 bit lcd.jpg
    202.3 KB · Views: 64

while(1)
{
if(byte==8)
{
lcd_string();
}
}
this is the part of code i am talking that you are doing something in infinite loop.
@internetuser: i think you have tested other code as i dont see bagya printing anything in her program, and in your snap shot you are displaying hello world. is it the same program that she has posted, i dont feel.
@bagya: the other functions written below main has to be called from main function to be executed. As i said use debugging option and see that the code you have written below main do not execute because they are not called.
 

Use code mentioned in saeedsolutions and try to display "Unique Card Id" on LCD. Then you can work on Serial Interrupt.
 

thank u...i will change the infinite loop...and also now iam able to display the output in LCD... if any further doubts means i will ask
 

**broken link removed**

This is not fully working. I am getting Logic Contention detected on RxD pin of 8051 in Proteus Simulation. I have not tested it on hardware.
Lcd is working. If logiccontention error is removed it might work. https://www.edaboard.com/threads/272323/
 
Last edited by a moderator:

pls check and tell this code will work..check my pointer declaration before main...my display function is working correctly.
sbit RS=P2^0;
sbit RW=P2^1;
sbit EN=P2^2;
unsigned char *disp ;
unsigned char c,i,b,a;
void lcd_string(unsigned char);
void display (unsigned char);

void main()
{
lcd_string("HELLO"); //FUNCTION CALL TO LCD STRING
command(0xc7); //display in 2nd row
lcd_string('k');
}
void lcd_string(unsigned char *disp)
{
int x;
for(x=0;disp[x]!=0;x++)
{
display(disp[x]);
}
void display(unsigned char b)
{
RS=1; //lcd pin to select in data mode
RW=0;
P0=b;
EN=1;
_nop_();
_nop_();
EN=0;
}
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top