[SOLVED] RFID using ARM7 LPC2148

Status
Not open for further replies.

djc

Advanced Member level 1
Joined
Jan 27, 2013
Messages
402
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,298
Location
India
Visit site
Activity points
4,554
Hi all,

I am trying to read the RFID tag value using ARM7 LPC2148. It's simple 12 digit hex code"04003C317871". It is showing perfect when i connect thr RFID reader directly to computer on hyperterminal. However when i read it using said controller it is showing some garbage value. I tested the UART port by sending and receiving the charecters using controller, it's working fine. I tried to display tag no. on LCD also, but not working. Do i nedd to add some code to TAG no. while reading by controller or anything else. Please guide.

Thanx in advance
 

Hi,
what type/model of RFID you are using? Couple of question come to the mind. Are you reading the "ID" using its generic software supplied with RFID? If "yes" then it will be definitely using a protocol/encryption technique. Also check about parity bits and the baud rate?
 

The Reader is EM-18. I havent been given any software with RFID reader. I have simple assive tag whose ID is mentioned above. I just configured the UART registers for UART1 and 0 for ARM7 LPC2148. Receiving RFID input on UART1. I am using 9600 baud rate to send and receive characters on UART0 which is working fine. I havent been given any generic software with RFID. I dont know where I am goin wrong.
Thank you
 

Hi,

I have never used such module but after googling i found a helpful link "http://www.engineersgarage.com/embedded/pic-microcontroller-projects/rfid-interfacing-circuit-code".
It uses a pic microcontroller. If this does not solve your problem paste your code here and let the members here see where you are going wrong?
 

Hi,
Here is the code
Code:
#include <LPC21xx.H>  
 unsigned char card_id[12];

 void delay(unsigned long b){ 
  while (--b!=0);	 
  }

void init_serial(void)
  {
  PINSEL0       = 0x00050005;   	/* Enabling RxD0 and TxD0, RxD1 and TxD1 */
  U0LCR         = 0x00000083;    	/* 8 bits, no Parity, 1 Stop bit * for UART0*/
  U0DLL         = 0XC3;
  U0FCR			= 0x81;             /*Enable the FIFO registers*/
  U0DLM 		= 0X00;
  U0LCR         = 0x00000003;       /* DLAB = 0  for UART0*/
  U1LCR         = 0x00000083;       /* 8 bits, no Parity, 1 Stop bit for UART1*/
  U1DLL         = 0XC3;
  U1LCR         = 0x00000003;       /* DLAB = 0 * for UART1*/
  U1FCR			= 0x81;          	/*Enable the FIFO registers*/

 }
int receive(void)						/*function for receiving data from sensor (reads byte by byte & returns value if exist)       */
{
 	unsigned char k;
	//while (!(U1LSR & 0x01))
	//if(U1RBR==0x0a)
	
	for(k=0;k<=11;k++)
	{
	
		while (!(U1LSR & 0x01));   /* If U0LSR 1st bit contains valid data, then return value of U1RBR*/
     	card_id[k] =U1RBR;
     	U1LSR = U1LSR & 0x00;
		
   	}
	  return (0); 	                      
}



 void write_command(int cmd) {
  IO1CLR  |= 0x00f00000;                 	/* Clear D4-D7  */
  IO1CLR  |= 0x00040000;	                /* Read/Write = 0 				*/
  IO1CLR  |= 0X00020000;                    /* Register Select = 0,Command */
  IO1SET  |= 0x00f00000 & cmd;  		    /* Set D4-D7    */
  IO1SET  |= 0X00080000;	                /* Enable = 1 					*/  
  delay(30000);
  IO1CLR  |= 0x00080000;                	 /* set E to low 	  			*/
  }
 
void write_data(int dat) {
  IO1CLR  |= 0x00f00000;                 	/* Clear D4-D7  */
  IO1CLR  |= 0x00040000;		 			/* Read/Write = 0 			*/
  IO1SET  |= 0X00020000;    				/* Register Select = 1,Data */
  IO1SET  |= 0x00f00000 & dat;  			/* Set D4-D7    */
  IO1SET  |= 0X00080000;					/* Enable = 1 				*/
  delay(30000);          					//delay ~2ms
  IO1CLR  |= 0x00080000; 					/* Set E to low 		  	*/
  }

void lcd_data(char dat){
  write_data(dat << 16);
  write_data(dat << 20);
  }

void lcd_command(char cmd){
  write_command(cmd << 16);
  write_command(cmd << 20);
  }
  
void printlcd(unsigned char *CPtr){
  while(*CPtr != '\0') {
	lcd_data(*CPtr);
    CPtr++;
	delay(20000);
	}
  }



void init_lcd(void) {										  
  IO1DIR 	|= 0x00FE0000;    
  delay(200000) ;
  write_command(0x30 << 16); 
  delay(100000);
  write_command(0x30 << 16);
  delay(100000);
  write_command(0x30 << 16);
  delay(100000);
  write_command(0x20 << 16);

  lcd_command(0x01);	                         /* clear display */
  lcd_command(0x06);	                         /* auto address inc */
  lcd_command(0x0c);	                         /* cursor off */
  lcd_command(0x80);	                         /* first location */
  }


 main(void)
{
	unsigned int i;
	init_lcd();
	init_serial();
	
	
	while(1)
	  {
		receive();
		for(i=0;i<=11;i++)
	 	{
			printlcd(card_id); 
			delay(20);
	  	}
	  }
}

- - - Updated - - -

HI,
As suggested by you, i checked out the PIC n RFID interfacing post. The same logic is applied there. I tried to connect pin 7 of RFID to pin 3 of max of controller but not working I think problem is max232 is there too on the RFID reader module. When i tried to connect pin 2 of max232 from RFID reader to Pin 2 of max of controller it shows no output. However when I connected pin 2 of max232 from RFID reader to PIN3 of max of controller I am getting atleast some garbae value. Where is the catch? what i am missin? Please guide.

Thanking you.
 

Hi,

Plz see this link
HTML:
http://www.pantechsolutions.net/microcontroller-boards/uart-interfacing-with-lpc2148-arm7-primer
to find some help I am not LPC2148 user so i cannot guide more; but in this link you can check your circuit.
you can try this one.
Code:
unsigned char k;     // declared as global
int receive(void)						/*function for receiving data from sensor (reads byte by byte & returns value if exist)       */
{

if(!(U1LSR & 0x01))     // valid data indication
{
     	card_id[k++] =U1RBR;
     	U1LSR = U1LSR & 0x00;
}
 return (0); 
}
}
 
Last edited:

Hi,
I have tried both of these, but none is working. Any other solution?
Thank you
 

Hi babar,
Thanx for your valuable time and suggestions. The problem is solved now.

Thanking you
 

Code:
#include <LPC21xx.H>  
 unsigned char card_id[11];
 unsigned char card_id2[11];//= {'1','2','3','4','5','6','7','8','9','0','1'};
 

 void delay(unsigned long b){ 
  while (--b!=0);	 
  }

void init_serial(void)
  {
  PINSEL0       = 0x00050005;   	/* Enabling RxD0 and TxD0, RxD1 and TxD1 */
  U0LCR         = 0x00000083;    	/* 8 bits, no Parity, 1 Stop bit * for UART0*/
  VPBDIV		= 0x2;
  U0DLL         = 0Xc3;				//Baud rate 9600
  U0FCR			= 0x81;             /*Enable the FIFO registers*/
  U0DLM 		= 0X00;
  U0LCR         = 0x00000003;       /* DLAB = 0  for UART0*/
  U1LCR         = 0x00000083;       /* 8 bits, no Parity, 1 Stop bit for UART1*/
  U1DLL         = 0Xc3;
  U1LCR         = 0x00000003;       /* DLAB = 0 * for UART1*/
  U1FCR			= 0x81;          	/*Enable the FIFO registers*/

 }
int receive(void)						/*function for receiving data from sensor (reads byte by byte & returns value if exist)       */
{
 	unsigned char k,j;
	while (!(U1LSR & 0x01) && (U1RBR != 0x81));
	
	
	for(k=0;k<=11;k++)
	{
		while (!(U1LSR & 0x01));   /* If U0LSR 1st bit contains valid data, then return value of U1RBR*/
     	card_id[k] =U1RBR;
		//U1LSR = U1LSR & 0x00;		
   	}
	for(j=0;j<=11;j++);
	{
		card_id2[k] = card_id [k+ 0x48];
	} 
	return (0);                      
}



 void write_command(int cmd) {
  IO1CLR  |= 0x00f00000;                 	/* Clear D4-D7  */
  IO1CLR  |= 0x00040000;	                /* Read/Write = 0 				*/
  IO1CLR  |= 0X00020000;                    /* Register Select = 0,Command */
  IO1SET  |= 0x00f00000 & cmd;  		    /* Set D4-D7    */
  IO1SET  |= 0X00080000;	                /* Enable = 1 					*/  
  delay(30000);
  IO1CLR  |= 0x00080000;                	 /* set E to low 	  			*/
  }
 
void write_data(int dat) {
  IO1CLR  |= 0x00f00000;                 	/* Clear D4-D7  */
  IO1CLR  |= 0x00040000;		 			/* Read/Write = 0 			*/
  IO1SET  |= 0X00020000;    				/* Register Select = 1,Data */
  IO1SET  |= 0x00f00000 & dat;  			/* Set D4-D7    */
  IO1SET  |= 0X00080000;					/* Enable = 1 				*/
  delay(30000);          					//delay ~2ms
  IO1CLR  |= 0x00080000; 					/* Set E to low 		  	*/
  }

void lcd_data(char dat){
  write_data(dat << 16);
  write_data(dat << 20);
  }

void lcd_command(char cmd){
  write_command(cmd << 16);
  write_command(cmd << 20);
  }
  
void printlcd(unsigned char *CPtr){
  while(*CPtr != '\0') {
	lcd_data(*CPtr);
    CPtr++;
	delay(20000);
	}
  }



void init_lcd(void) 
{										  
  IO1DIR 	|= 0x00FE0000;    
  delay(200000) ;
  write_command(0x30 << 16); 
  delay(100000);
  write_command(0x30 << 16);
  delay(100000);
  write_command(0x30 << 16);
  delay(100000);
  write_command(0x20 << 16);

  lcd_command(0x01);	                         /* clear display */
  lcd_command(0x06);	                         /* auto address inc */
  lcd_command(0x0c);	                         /* cursor off */
  lcd_command(0x80);	                         /* first location */
}



int main(void)
{
	unsigned int i,k=0;
	init_lcd();
	init_serial();
	printlcd("A");
	while(1)
	{
	receive();
		for(i=0;i<=11;i++)
	 	{
			lcd_command(0x80);	
			printlcd(card_id); 			
	  	}
	 	 
		for(k=0;k<11;k++)
		{
			card_id[k]= '\0';
		} 
         /*for(k=0;k<11;k++)
		{
			card_id[k]= card_id2[k];
		}*/  
		/*for(k=0;k<11;k++)
		{
			lcd_command(0x80);
			printlcd(card_id2);
		}*/	

	 }
	

}
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…