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 Tag ID Recognition

Status
Not open for further replies.

imranahmed

Advanced Member level 3
Advanced Member level 3
Joined
Dec 4, 2011
Messages
822
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,298
Location
Karachi,Pakistan
Visit site
Activity points
6,533
Please let me know that I build a circuit for displaying RFID tag ID.

The ID is written on card is 0001712436 026,08500.

The circuit is 89c52 uC based,
The card ID is received on LCD(20x2) like, |||0001712436||
The 3 lines on start of code and 2 lines on end of code is displaying.
How to fix this problem?

Please find the attachment, How Hyper terminal display the code please see.
 

Attachments

  • HypTer.PNG
    HypTer.PNG
    36.6 KB · Views: 90

Maybe some additional ascii data is appended while transmitting the tag. Just use something like this


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
char buff1[20], buff2[20];
 
//buff1[] is used in ISR where RFID data is dumped to it.
 
while(1) {
 
      while(buff1[i]) {
 
              if((buff1[i] >= '0') && (buff1[i] <= '9'))buff2[j++] = buff1[i++];
 
      }
 
      buff2[j] = '\0';
 
      lcdPrint(buff2);
 
 
}

 
Zip and post your complete project files. I will see if there is any better way to modify the code. Does any of the RFID tag contains characters A to Z or a to z ?
 
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]);
          }
      }
}

Please see the code.
The ID on card is only 0001712436 026,08500
 

Is it Keil uVision Code ? If yes, Zip and post the complete Keil project.

- - - Updated - - -

Try attached project. RFID baudrate is 9600 bps.

112201d1418189537-rfid-20x2.png
 

Attachments

  • RFID Reader.rar
    135.1 KB · Views: 76
  • rfid 20x2.png
    rfid 20x2.png
    50.8 KB · Views: 122
Last edited:

Thank you for given project.

I need not only display Tag ID but I am comparing tag ID with tag ID is saved in code.
If ID match the door should be open.
But I am build code for checking that it can receive proper ID or not and not for opening door.

Code is below,
Code:
// Atmel AT89C52 @ 11.0592MHz
#include<reg52.h>
#include<string.h>
#include<stdio.h> 

sfr lcd_data_pin=0xA0; //P2 port
sbit rs=P3^1;          //Register select 
sbit en=P3^3;          //Enable pin	

unsigned char card_id[12];
unsigned char current_byte=0,flag=0;
unsigned char val1=1;
code const char Student1[]="200017124353";

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;    
     delay(1);
     en=0;
}

void lcd_data(unsigned char disp)  //Lcd data function
{
     lcd_data_pin=disp;
     en=1;
     rs=1;    
     delay(1);
     en=0;
}

void lcd_string(unsigned char *disp)     //Function to send string 
{
     int x;
     for(x=0;disp[x]!='\0';x++)
    {
         lcd_data(disp[x]);
    }
}
void lcd_init()                       //Function to initialize the LCD
{
    lcd_command(0x38);          
    delay(5);
    lcd_command(0x0F);        
    delay(5);
    lcd_command(0x80);
    delay(5);
} 

/*
void display()                     // Function to display the unique id
{
    unsigned char count;
    lcd_command(0xC1);               //Place cursor to second position of second line
    for(count=0;count<15;count++)
     { 
          lcd_data(card_id[count]);
     }
		 
    current_byte=0;
		 
}
*/


void recieve() interrupt 4           //  Function to recieve data serialy from RS232 
    {
     card_id[current_byte]=SBUF;
     RI=0;                            // Reset the serial interrupt after recieving the byte
     current_byte++;  
     card_id[current_byte]='\0';		
		}


void RFID_routine()
{	
	          
	   
      while(current_byte!=13);
	   
	    val1=strcmp(Student1,card_id);		
			if(val1 == 0)
			{	
      current_byte=0;				
      lcd_command(0x01);        //Clear LCD 
	    lcd_command(0x81);        //Place cursor to second position of first line 
      lcd_string("Condition true");				  
			}
			
			else
			{
			current_byte=0;		
			lcd_command(0x01);        //Clear LCD 
	    lcd_command(0xC1);        //Place cursor to second position of first line 
      lcd_string("Condition false");	 
			}	 
			
}

void main()
{
    
    TMOD=0x20;            //Enable Timer 1
    TH1 =0xFD;
    SCON=0x50;
    TR1 =1;                // Triggering Timer 1
	  EA  =1;
    ES  =1;  
    lcd_init();
    lcd_command(0x01);        //Clear LCD 
	  lcd_command(0x81);        //Place cursor to second position of first line 
    lcd_string("UNIQUE~CARD~ID:");	    
	  delay(10);
    while(1)
    {		
			RFID_routine();                      
	         
	   
		}
}
 

Did you see my code ? In that you only have to add

I have attached my project which is working.


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
const char tag[] = "200017124353";
 
while(1) {
 
         if(index >= 20) {
                 parseRFID(card_id, text);
                 if(strcmp(tag, text) == 0) {
                         LCD_Out(2,1,"Access Granted...");
                 }
                 else {
                      LCD_Out(2,1,"Access Denied...");
                 }
                 
                 index = 0;
                 memset(card_id, '0', 30);
                 memset(text, '0', 25);
           }
}

 

Attachments

  • RFID Reader rev1.rar
    33.3 KB · Views: 72
Last edited:

Dear milan,

Thank you for your co-operation.

I am working on your given project and I will reply you as soon as possible.

Regards,
Imran
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top