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.
thank u so much for your suggestion...finally i got the output...
 

sir...how to display in LCD and in hyper terminal simultaneously....i don't know how to collect the data and send to SBUF..
IN LCD i am displaying time, name and authroized
 

To display in hyperterminal you have to send data from PIC to PC using uart like UART_Write() function, if you have it in your compiler.

http://www.8052.com/tutser.phtml

It says you only have to place the byte in SBUF register.
Code:
 SBUF = 'X'

Try this. It might work

Code:
void send_uart(void);
void send_string_uart(unsigned char string[])


unsigned char mystring[] = "AT89C51";

void send_uart(void) {

	TI = 0;
	SBUF = 'A';
	while(TI == 0);

}

void send_string_uart(unsigned char string[]) {

	unsigned int count;

	for(count = 0; count < strlen(string); count++) {
		TI = 0;
		SBUF = string[count];
		while(TI == 0);
	}

}

void main() {


	while(1) {


		send_uart();
		send_string_uart(mystring);


	}

}
 
Last edited:

sir,while display my RFID tag it display 8 numbers and 2chunk value...if i display using hyper terminal it showing 8 numbers only...how to find that..iam using the 4th product which shown in below link
**broken link removed**
 

what is chunk value? Is data displayed on lcd ok and data displayed on hyperterminal is missing 2 chunks?

Can you post your code please? There is no datasheet or documentation for you product. If you got any document on CD/DVD when purchased post it.
 
Last edited:

sir,in my program every time i want to press reset button in order to place the next RFID tag and to display the data...how to display it without pressing reset.

Code:
#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,l,byte=0;      
unsigned char card_id[8];
void command(unsigned char);
void recieve();
void lcd_string(unsigned char);
void ready();
void get();
unsigned char *disp[]	 ;
unsigned char tag[8]={'1','5','4','2','7','4','1','2'}; //for comparing the tag id which i receive from SBUF
unsigned char tag1[8]={'1','5','4','2','8','7','5','2'};  //for comparing the tag id which i receive from SBUF
void main()
{
	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) // checking i'am getting 8 char from SBUF
{
get();
}
} 
}	
void lcd_string(unsigned char *disp)	 
{
 	int x;
 	for(x=0;disp[x]!=0;x++)
	{
 		display(disp[x]);
	}
}  
void receive(void) interrupt 4  //SERIAL INTERRUPT
{
unsigned char k=0;

    if(RI==1)
{
card_id[byte]=SBUF;
RI=0;
byte++; 
}
}
void get()   //FUNCTION TO COMPARE THE TAG ID AND DISPLAY IN LCD
{
unsigned char j,k,count=0,count1=0;
for(j=0;j<8;j++)
	{
	 if(card_id[j]==tag[j])
	 {
	 count++;
	 }
	 }
for(k=0;k<8;k++)
	{
	 if(card_id[k]==tag1[k])
	 {
	 count1++;
	 }
	 } 
if(count==8)
	 {
	lcd_string("BAGYA");
	command(0xc7);
	lcd_string("GRANTED");
	}
	else if(count1==8)
	{	
	lcd_string("GOPI");
	command(0xc7);
	lcd_string("GRANTED");
	 } 
	 else
	 {
	 command(0xc3);
	 lcd_string("WRONG ID");
	 }
	 }
void command (unsigned char a) //LCD COMMAND FUNCTION
{
	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;
}
 
Last edited:

Is your tag 8 * 8 bytes? Edit you last post and wrap your code in code tags. use the # button. The cod eyou posted is not full. Where is the UART send code?
 
Last edited:

Sorry, I mean to say 8 * 8 bits. each char is 1 byte = 8 bits and you have 8 bytes, so 8 bits into 8 bits = 64 bits.

My last post is updated. Please check it any reply.

Try this code
Code:
#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;

void command(unsigned char);
void recieve();
void lcd_string(unsigned char);
void ready();
void get();

unsigned char c,i,b,a,l,byte=0; 
unsigned char card_id[8];
unsigned char *disp[];
unsigned char tag[8]={'1','5','4','2','7','4','1','2'}; //for comparing the tag id which i 

//receive from SBUF
unsigned char tag1[8]={'1','5','4','2','8','7','5','2'}; //for comparing the tag id which i 

//receive from SBUF

void main()
{
	P0=0x00;
	P3=0x03;
	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) // checking i'am getting 8 char from SBUF
		{
			get();
			break;
		}
	} 
}
	
void lcd_string(unsigned char *disp)	
{
	int x;
	for(x=0;disp[x]!=0;x++)
	{
		display(disp[x]);
	}
} 

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

	if(RI==1)
	{
		card_id[byte]=SBUF;
		RI=0;
		byte++; 
	}
}

void get() //FUNCTION TO COMPARE THE TAG ID AND DISPLAY IN LCD
{
	unsigned char j,k,count=0,count1=0;
	
	for(j=0;j<8;j++)
	{
		if(card_id[j]==tag[j])
		{
			count++;
		}
	}
	
	for(k=0;k<8;k++)
	{
		if(card_id[k]==tag1[k])
		{
			count1++;
		}
	} 
	
	if(count==8)
	{
		lcd_string("BAGYA");
		command(0xc7);
		lcd_string("GRANTED");
	}
	else if(count1==8)
	{	
		lcd_string("GOPI");
		command(0xc7);
		lcd_string("GRANTED");
	} 
	else
	{
		command(0xc3);
		lcd_string("WRONG ID");
	}
}

void command (unsigned char a) //LCD COMMAND FUNCTION
{
	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;
}

Try to put a message like "Swipe RFID Card" in the beginning i.e, in the main function before while(1) loop.
 
Last edited:

in UART iam getting the data from RFID reader. which iam doing in serial interrupt function
 

That is UART reading. You said that it is not printing properly on hyperterminal. So you are sending data to hyperterminal. Where is that UART write code?

This was your message regardint uart write sir,while display my RFID tag it display 8 numbers and 2chunk value...if i display using hyper terminal it showing 8 numbers only...how to find that..iam using the 4th product which shown in below link

See this link https://www.edaboard.com/threads/272426/ There is a .c file in the .rar file. Open it in notepad and see the code.
 
Last edited:

i'm not not done with hyper terminal coding yet..first i want to display the char continuously without pressing reset. i tried with putting break command inside while(1) loop..then also it's not working
 

first i want to display the char continuously without pressing reset Tell me how it is displaying? explain.

Do you want to display decoded RFID tag like 12345678 on lcd?
 
Last edited:

once i scan the ID it will display the name of the person belonging to that ID and when i want to scan the next ID i must press reset to display the next person name...but that should not be the case...it should display the names continuously without pressing reset
 
Last edited:

Once you scan the card it will display the name of the person belonging to that id if id matched. Then do ask something like "Swipe RFID Card"? before another person swipes the card?

try this code
Code:
#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;

void command(unsigned char);
void recieve();
void lcd_string(unsigned char);
void lcd_array(unsigned char data[]);
void ready();
void get();

unsigned char c,i,b,a,l,byte=0; 
unsigned char card_id[8];
unsigned char *disp[];
unsigned char tag[8]={'1','5','4','2','7','4','1','2'}; //for comparing the tag id which i 

//receive from SBUF
unsigned char tag1[8]={'1','5','4','2','8','7','5','2'}; //for comparing the tag id which i 

//receive from SBUF

void main()
{
	P0=0x00;
	P3=0x03;
	TMOD=0x20; 
	TH1=0XFD;
	SCON=0x50;
	TR1=1; 
	command(0x38);
	command(0x01);
	command(0x0e);
	command(0x06); 
	command(0x80);
	command(0xc0);
	IE=0X90;
	
	command(0x80);
	lcd_string("Swipe RFID Card");

	while(1)
	{
		if(byte!=8)
		{	
			command(0x80);
			lcd_string("Swipe your Card");

		}
		if(byte==8) // checking i'am getting 8 char from SBUF
		{
			get();
			
		}
	} 
}

void lcd_array(unsigned char data[])	
{
	int x;
	for(x=0;x<8;x++)
	{
		display(data[x]);
	}
}
	
void lcd_string(unsigned char *disp)	
{
	int x;
	for(x=0;disp[x]!=0;x++)
	{
		display(disp[x]);
	}
} 

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

	if(RI==1)
	{
		card_id[byte]=SBUF;
		RI=0;
		byte++; 
	}
}

void get() //FUNCTION TO COMPARE THE TAG ID AND DISPLAY IN LCD
{
	unsigned char j,k,count=0,count1=0;
	
	
	
	for(j=0;j<8;j++)
	{
		if(card_id[j]==tag[j])
		{
			count++;
		}
	}
	
	for(k=0;k<8;k++)
	{
		if(card_id[k]==tag1[k])
		{
			count1++;
		}
	}


	//lcd_array(card_id);
 	//delay(500);
	
	if(count==8)
	{
		lcd_string("BAGYA");
		command(0xc7);
		lcd_string("GRANTED");
	}
	else if(count1==8)
	{	
		lcd_string("GOPI");
		command(0xc7);
		lcd_string("GRANTED");
	} 
	else
	{
		command(0xc3);
		lcd_string("WRONG ID");
	}
	
	byte = 0;
}

void command (unsigned char a) //LCD COMMAND FUNCTION
{
	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;
}
 

no i'am not display that...if i do like that means it will work without pressing reset?
 

That doesn't mean it will work without pressing reset, but I asked do you want to prompt user to swipe another card or do you just want to display the old message like "BAGYA" "GRANTED", like that. try the code I have posted in my last post.

also change this
Code:
if(byte==8) // checking i'am getting 8 char from SBUF
		{
			get();
			
		}

to this code
Code:
if(byte==8) // checking i'am getting 8 char from SBUF
		{
			get();
                        // add a 2 sec delay here
			
		}
 

though if i add 2 sec delay...i think i should press reset..because once i scan next ID means the program should start from first then only it can show next name..i'm i correct?
 

You can add whatever delay you want. First it will display "Swipe your Card" then if card is swiped and id matched for "BAGYA" then it displays "BAGYA" "GRANTED" for 2sec or 10 sec if you want then byte is set to 0. so, when it again loops it checks if byte not equal to 8, which is true, so it displays "Swipe your card", and again you swipe another card then byte become 8, if matched it displays "GOPI" "GRANTED" for 10 sec depending upon the delay. then again byte is set to 0 and it repeats.
 
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top