Page 1 of 1

interfacing RFID-IDR-RS232 with pic18

PostPosted: Sun Mar 03, 2013 12:11 pm
by rachel.tan
hi, i have a tag no of 0000523066, but when tag placed on the reader.

if is Write_decimal(data[i]), it gives value of 127230230230166102038230102102

if is number(data[i]), it gives value of 7000628022

why is it like that? It should've display 0000523066 right?

Im using PIC18F4520, MPlab C18.

this is my code:
#include <p18f4520.h>
#include <system4520.h>
#include <usart.h>
#include <stdio.h>
#include <delays.h>

unsigned char uart_rec(void);

unsigned char rfid_door[16]="   RFID Door    ";
unsigned char security_sys[16]=" Security System";
unsigned char place_tag[16]=" Place your tag ";
unsigned char reader[16]=" on the reader  ";
unsigned char id_no[16]={"ID:             "};
unsigned char identified[16]="User Identified ";
unsigned char unidentified[16]="User not found! ";
unsigned char access_denied[16]="Access DENIED!  ";
unsigned char opendoor[16]="  DOOR OPENED!  ";

void main(void)
   unsigned char i, database, cardid1, ID;
   unsigned char id1[10]={0,0,0,0,5,2,3,0,6,6};
   unsigned char ID1[16]={"0000523066"};
   unsigned char data[12];
   OpenUSART(USART_TX_INT_OFF &         //transmit interrupt off
   USART_RX_INT_ON &                  //receive interrupt on
   USART_ASYNCH_MODE &                  //asynchronous mode
   USART_EIGHT_BIT &                  //8-bit data
   USART_CONT_RX &                     //continuous reception
   USART_BRGH_HIGH,25);               //for baud rate 9600



      for(i=0; i<12; i+=1)

unsigned char uart_rec(void)         //receive uart value
   unsigned char rec_data;
   while(PIR1bits.RCIF==0);                  //wait for data
   rec_data = RCREG;            
   return rec_data;               //return the data received

Re: interfacing RFID-IDR-RS232 with pic18

PostPosted: Tue Mar 05, 2013 2:59 pm
by yonghui

what is the i in data[i]. did you properly initialize the i before pass the value?
and you didnt post the subrountine number() and Write_decimal(). i dont know whether the conversion is correct or not.