rfid problem

General discussion on mikroC.
Post Reply
Author
Message
HoorAlein
Posts: 2
Joined: 30 Jan 2012 20:07

rfid problem

#1 Post by HoorAlein » 31 Jan 2012 20:58

Hello guys ,,
I have a problem with my project, its a rfid reader (125 KHz) connected to pic16f877a with a LCD (works fine without rfid )..

after I connect them ,, I only see the cursor down , but nothing happens when I try to make it read the tags!


my code (micro c):

Code: Select all

unsigned char uart_rd;
unsigned char data;
unsigned char temp[13];
unsigned char N = 0;

void main() {
   TRISD = 0x80;

   TRISB = 0;
   PORTB = 0xFF;
   USART_Init(9600);
   Delay_ms(100);

   Lcd_Init(&PORTB);
   Lcd_Cmd(LCD_BLINK_CURSOR_ON);
   Delay_ms(1000);

   do {
   if (USART_Data_Ready()){              //<------ Check if a character has been received before reading
       uart_rd = USART_Read();     // read the received data,
       USART_Write(uart_rd);

       temp[N] = uart_rd;

       N = N +1;

       if (N == 12) // temp storing  string
       {
          temp[12] = 0;
          Lcd_Cmd(LCD_CLEAR);
          Lcd_out(1,1,temp);
          N=0;
        }

       }
    } while(1);
}

the datasheets for the rfid and LCD:

http://www.4shared.com/office/EGiVzy51/ ... _uart.html

http://www.4shared.com/office/UtNizZ_L/datasheet.html

the circuit of my project is in the attachment

can anyone help me plz??
Attachments
circuit2.jpg
circuit2.jpg (48.2 KiB) Viewed 2234 times

HoorAlein
Posts: 2
Joined: 30 Jan 2012 20:07

Re: rfid problem

#2 Post by HoorAlein » 26 Feb 2012 14:50

hi guys

I've did some changes in my code and I will reach to this result in the following pictures

http://www11.0zz0.com/2012/02/26/09/280708830.jpg

http://www11.0zz0.com/2012/02/26/09/464098718.jpg

http://www11.0zz0.com/2012/02/26/09/682491035.jpg

and the code as following:

Code: Select all


unsigned *text1 = "RFID Test #1";
unsigned *text2 = "Show Your Card";
unsigned *text3 = "Waiting";
unsigned *text4 = "Card Data >>";
unsigned short i;
char temp[15];
void main(){

delay_ms(50);

Lcd_Init(&PORTB);

USART_Init(9600);

Lcd_Cmd(LCD_CLEAR);
Lcd_Cmd(LCD_CURSOR_OFF);
LCD_Out(1,1,text1);
delay_ms(50);

while(1)
{

LCD_Out(1,1,text2);
LCD_Out(2,1,text3);


if (UsART_Data_Ready()){
if (usart_read()== 2)
{
Lcd_Cmd(LCD_CLEAR);
LCD_Out(1,1,text4);


//Dump Remaining 11 bytes

for(i=0;i<11;i++)
{
temp[i] = usart_read();
LCD_Out(2,1,temp);
}
usart_read();

delay_ms(2000);
//Now Clear it
Lcd_Cmd(LCD_CLEAR);
}
}
}
}


I think the problem is in the code !!
Can u help me with it?

User avatar
janko.kaljevic
Posts: 3565
Joined: 16 Jun 2011 13:48

Re: rfid problem

#3 Post by janko.kaljevic » 27 Feb 2012 15:56

Hello,

Have you checked our example for RFID reader?
RFID board that we provide should be connected to two external interrupt pins.

Best regards.

Post Reply

Return to “mikroC General”