How to add more user id into programming RFID PR8B?

LED Blinking, Walking with Cytron Servo, Displaying RFID, Multi-function Mobile Robot......

How to add more user id into programming RFID PR8B?

Postby bahirah87 » Tue Jan 11, 2011 3:52 pm

im using MPLAB. i have tried several time to add more user id in my programming and add some more character to id name but the programming cannot been compile.. what should i do?
bahirah87
Newbie
 
Posts: 13
Joined: Sun Oct 24, 2010 11:28 pm

Re: How to add more user id into programming RFID PR8B?

Postby hyng » Tue Jan 11, 2011 5:46 pm

Maybe you should post your code up here. :mrgreen:
User avatar
hyng
Moderator
 
Posts: 292
Joined: Thu Apr 16, 2009 11:35 am

Re: How to add more user id into programming RFID PR8B?

Postby bahirah87 » Tue Jan 11, 2011 6:25 pm

there are not much different from original program... i only add few thing.
CODE: SELECT_ALL_CODE
//========================================================================
//   include
//========================================================================
#include <pic.h>


//========================================================================
//   Configuration
//========================================================================
__CONFIG ( 0x3F32 );            //configuration for the  microcontroller


//=========================================================================                           
//   Define
//=========================================================================
#define   rs         RC3            //RS pin of the LCD display
#define   rw         RC2            //R/W pin of the LCD display   
#define   e         RC4            //E pin of the LCD display
#define   b_light      RC1            //backlight of the LCD display (1 to on backlight)
#define   buzzer      RC0            //buzzer (1 to on buzzer)a
#define   button1      RA0            //button (active low)
#define   button2      RA1            //button (active low)
#define   lcd_data   PORTB         //LCD 8-bit data PORT
#define   led1      RA2            //led 1 (active high)
#define   led2      RA3            //led 2 (active high)


//===========================================================================
//   Function prototype            (every function must have a function prototype)
//===========================================================================
void delay(unsigned long data);         
void send_config(unsigned char data);
void send_char(unsigned char data);
void lcd_goto(unsigned char data);
void lcd_clr(void);
void send_string(const char *s);
unsigned char uart_rec(void);
void beep(void);


//===========================================================================
//   Main function               (main fucntion of the program)
//===========================================================================
void main(void)
{
   //assign variable
   unsigned char i,temp,database;            
   unsigned char data[15];                  //14 bytes of data received from RFID Reader.
                                    //The data include start of text, RFID ID,
                                    //carriage return, new line, and end of text
   
   unsigned char id_1[10]={"0010810115"};      //define the Tag ID here
   unsigned char id_2[10]={"0000797447"};      //change this ID to the tag ID that user want to read
   [color=#FF0000] unsigned char id_3[10]={"0000123456"};[/color]      //change this ID to the tag ID that user want to read   

   unsigned char user_1[10]={"Ikhwan"};   //define the Tag user here
   unsigned char user_2[10]={"Othman"};   //change this user name to the tag ID owner name
   [color=#FF0000]unsigned char user_3[10]={"Nurdiana"};[/color]

   //set I/O input output
   TRISB = 0b00000000;               //configure PORTB I/O direction
   TRISC = 0b10000000;               //configure PORTC I/O direction
   TRISA = 0b11110011;               //configure PORTA I/O direction
   
   //setup USART
   SPBRG = 0x81;                  //set baud rate to 9600 for 20Mhz
   BRGH = 1;                     //baud rate high speed option
   TXEN = 1;                     //enable transmission
   CREN = 1;                     //enable reception
   SPEN = 1;                     //enable serial port
   
   //setup ADC
   ADCON1 = 0b00000110;            //set ADx pin digital I/O
   
   //configure lcd
   send_config(0b00000001);         //clear display at lcd
   send_config(0b00000010);         //lcd return to home
   send_config(0b00000110);         //entry mode-cursor increase 1
   send_config(0b00001100);         //display on, cursor off and cursor blink off
   send_config(0b00111000);         //function set
         
   //set initial condition
   buzzer=0;                     //off buzzer
   b_light=1;                     //on backlight   
   led1=0;                        //off led 1
   led2=0;                        //off led 2
   
   lcd_clr();                     //clear lcd
   lcd_goto(0);                  //set the lcd cursor to location 0
   send_string("RFID Student");      //display welcome note
   lcd_goto(20);                  //set the lcd cursor to location 20
   send_string("Attendance");         //display welcome note
   
   beep();                        //initial beep
   delay(20000);                  //delay for display the welcome note

   //infinity loop
   while(1)   
   {
      CREN = 1;                        //enable reception from UART
      lcd_clr();                        //clear lcd
      lcd_goto(0);                     //set lcd cursor to location 0
      send_string("Place your ID");         //display note
      lcd_goto(20);                     //set lcd cursor to location 20
      send_string("on the reader.");         //display note
      
      for(i=0;i<14;i+=1)data[i]=uart_rec();   //wait for 14 character data receive from RFID reader
                                    //The data receive are start of text, RFID ID,
                                    //carriage return, new line, and end of text

      led1=1;                           //on led to indicate system is busy
            
      lcd_clr();                        //clear lcd
      lcd_goto(20);                     //set lcd cursor to location 20
      send_string("Processing......");      //display "Processing...."
      delay(40000);                     //delay
      
      database=0;                        //clear the value of database and start scanning         
      
      //comparing with the 1st id

      temp=0;                           //comparing the received data with the saved id.
                                    //only byte 2-11 which is RFID ID data, will be used to compare between
                                    //receive data and saved id.
      for(i=1;i<11;i+=1)                  //comparing digit by digit
      {   
         if((data[i])!=(id_1[i-1]))temp=1;   //if the id is different from the id define above,
      }                              //then set temp=1;
   
   if(temp==0) database=1;               //if temp=0, mean the id match, set the database=1
      
      //comparing with the 2nd id
      temp=0;                           //comparing the received data with the saved id
                                    //only byte 2-11 which is RFID ID data, will be used to compare between
                                    //receive data and saved id.
      for(i=1;i<11;i+=1)                  //comparing digit by digit
      {
         if((data[i])!=(id_2[i-1]))temp=1;   //if the id is different from the id define above,
      }                              //then set temp=1;
      if(temp==0) database=2;               //if temp=0, mean the id match, set the database=1   

   [color=#FF0000]//comparing with the 3rd id

      temp=0;                           //comparing the received data with the saved id.
                                    //only byte 2-11 which is RFID ID data, will be used to compare between
                                    //receive data and saved id.
      for(i=1;i<11;i+=1)                  //comparing digit by digit
      {   
         if((data[i])!=(id_3[i-1]))temp=1;   //if the id is different from the id define above,
      }                              //then set temp=1;
      if(temp==0) database=3;               //if temp=0, mean the id match, set the database=1      [/color]
      lcd_clr();                        //clear lcd   
      CREN = 0;                        //disable reception from UART


      switch(database)                  
      {
         case 1:                                 //id 1 match
            led2=1;                              //on led 2
            lcd_goto(0);                        //set lcd cursor to location 0
            send_string("ID:");                     //display "ID: "
            for(i=0;i<10;i+=1)send_char(id_1[i]);      //display tag ID
            lcd_goto(20);                        //set lcd cursor to location 20
            send_string("user:");                  //display "user: "
            for(i=0;i<10;i+=1)send_char(user_1[i]);      //display user name
            beep();                              //beep once
            break;
         case 2:                                 //id_2 match
            led2=1;                              //on led 2
            lcd_goto(0);                        //set lcd cursor to location 0
            send_string("ID: ");                  //display "ID: "
            for(i=0;i<10;i+=1)send_char(id_2[i]);      //display tag ID
            lcd_goto(20);                        //set lcd cursor to location 20
            send_string("user:");                  //display "user: "
            for(i=0;i<10;i+=1)send_char(user_2[i]);      //display user name   
            beep();                              //beep once
            break;
         [color=#FF0000]case 3:                                 //id_2 match
            led2=1;                              //on led 2
            lcd_goto(0);                        //set lcd cursor to location 0
            send_string("ID: ");                  //display "ID: "
            for(i=0;i<10;i+=1)send_char(id_3[i]);      //display tag ID
            lcd_goto(20);                        //set lcd cursor to location 20
            send_string("user:");                  //display "user: "
            for(i=0;i<10;i+=1)send_char(user_3[i]);      //display user name   
            beep();                              //beep once[/color]
            break;
         default:                              //id doesnt match
            lcd_goto(0);                        //set lcd cursor to location 0
            send_string("ID: ");                  //display "ID: "
            for(i=1;i<11;i+=1)send_char(data[i]);      //display tag ID
            lcd_goto(20);                        //set lcd cursor to location 20
            send_string("user not found");            //display "user not found"
            beep();                              //beep twice
            beep();
            break;
      }
      delay(300000);                              //delay
      led1=0;                                    //off led after the process complete
      led2=0;
   }
      
}

//===========================================================================
//   Functions
//===========================================================================

void delay(unsigned long data)         //delay function, the delay time
{                              //depend on the given value
   for( ;data>0;data-=1);
}

void send_config(unsigned char data)   //send lcd configuration
{
   rw=0;                        //set lcd to write mode
   rs=0;                        //set lcd to configuration mode
   lcd_data=data;                  //lcd data port = data
   e=1;                        //pulse e to confirm the data
   delay(50);
   e=0;
   delay(50);
}

void send_char(unsigned char data)      //send lcd character
{
    rw=0;                        //set lcd to write mode
   rs=1;                        //set lcd to display mode
   lcd_data=data;                  //lcd data port = data
   e=1;                        //pulse e to confirm the data
   delay(10);
   e=0;
   delay(10);
}

void lcd_goto(unsigned char data)      //set the location of the lcd cursor
{                              //if the given value is (0-15) the
    if(data<16)                     //cursor will be at the upper line
   {                           //if the given value is (20-35) the
       send_config(0x80+data);         //cursor will be at the lower line
   }                           //location of the lcd cursor(2X16):
   else                        // -----------------------------------------------------
   {                           // | |00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15| |
       data=data-20;               // | |20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35| |
      send_config(0xc0+data);         // -----------------------------------------------------   
   }
}

void lcd_clr(void)                  //clear the lcd
{
    send_config(0x01);
   delay(600);   
}

void send_string(const char *s)         //send a string to display in the lcd
{         
   unsigned char i=0;
     while (s && *s)send_char (*s++);

}

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

void beep(void)                     //short beep function
{
   buzzer=1;                     //on buzzer
   delay(10000);                  //short delay
   buzzer=0;                     //off buzzer
   delay(10000);                  //short delay
}
bahirah87
Newbie
 
Posts: 13
Joined: Sun Oct 24, 2010 11:28 pm

Re: How to add more user id into programming RFID PR8B?

Postby ober » Tue Jan 11, 2011 8:44 pm

bahirah87 WROTE:im using MPLAB. i have tried several time to add more user id in my programming and add some more character to id name but the programming cannot been compile.. what should i do?


Cannot compile with what error message? It will at least give you some message. And have you compiled the original file before?
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1486
Joined: Wed Apr 15, 2009 1:03 pm

Re: How to add more user id into programming RFID PR8B?

Postby bahirah87 » Tue Jan 11, 2011 8:58 pm

it can be compile but i have done the simulation using proteus 7.1 ... and with original program the LCD show the name.. after i add one more name and id the LCD show "user not found"
bahirah87
Newbie
 
Posts: 13
Joined: Sun Oct 24, 2010 11:28 pm

Re: How to add more user id into programming RFID PR8B?

Postby bahirah87 » Tue Jan 11, 2011 9:07 pm

the simulation that have been done
Attachments
mypojet.PNG
bahirah87
Newbie
 
Posts: 13
Joined: Sun Oct 24, 2010 11:28 pm

Re: How to add more user id into programming RFID PR8B?

Postby ober » Tue Jan 11, 2011 9:16 pm

bahirah87 WROTE:it can be compile but i have done the simulation using proteus 7.1 ... and with original program the LCD show the name.. after i add one more name and id the LCD show "user not found"


Woh, please ask your question properly, giving wrong direction to us will get wrong guidance from us too.

Cannot compile is different from what you have now, you are getting different result after compile and load into simulator.

OK, so you have done the simulation with original program and the simulation show the LCD did display the name, correctly, right?

Now can you point to us, where you add and modify the code? Frankly, is quite difficult for us to trace the code line by line to guess where is the error. Help us to help you.
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1486
Joined: Wed Apr 15, 2009 1:03 pm

Re: How to add more user id into programming RFID PR8B?

Postby bahirah87 » Tue Jan 11, 2011 9:44 pm

the program that i add
Attachments
1.PNG
2.PNG
3.PNG
bahirah87
Newbie
 
Posts: 13
Joined: Sun Oct 24, 2010 11:28 pm

Re: How to add more user id into programming RFID PR8B?

Postby bahirah87 » Tue Jan 11, 2011 9:45 pm

after i add the third id the simulation do not show the id name and on show user not found
bahirah87
Newbie
 
Posts: 13
Joined: Sun Oct 24, 2010 11:28 pm


Return to DIY Project Set

Who is online

Users browsing this forum: No registered users and 7 guests

cron