problem to add third user in program PR8.

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

problem to add third user in program PR8.

Postby syukrikasim » Wed Nov 30, 2011 12:53 pm

Hi,i have bought DIY project PR8 for my final year project ,but when i want to add third user and BUILT,the output is error and show this message.i dont know how to solve this problem..for your information i want to make a 16 identification user in program PR8..please reply my message as soon as posible:tq
CODE: SELECT_ALL_CODE
HI-TECH C PRO for the PIC10/12/16 MCU family (Lite) V9.60PL5
Copyright (C) 1984-2009 HI-TECH SOFTWARE
(1273) Omniscient Code Generation not available in Lite mode (warning)
Error [1267] C:\Users\Syuk\Desktop\baru\cuba.c; 62. fixup overflow referencing symbol ??_main (0x13B) into 1 byte at 0xA (baru.obj 67/0x4)
Error [1267] C:\Users\Syuk\Desktop\baru\cuba.c; 63. fixup overflow referencing symbol ??_main (0xD2) into 1 byte at 0x2E (baru.obj 67/0x28)
Error [1267] C:\Users\Syuk\Desktop\baru\cuba.c; 64. fixup overflow referencing symbol ??_main (0x131) into 1 byte at 0x36 (baru.obj 67/0x30)
Error [1267] C:\Users\Syuk\Desktop\baru\cuba.c; 65. fixup overflow referencing symbol ??_main (0xD2) into 1 byte at 0x56 (baru.obj 67/0x50)
Error [1267] C:\Users\Syuk\Desktop\baru\cuba.c; 66. fixup overflow referencing symbol ??_main (0x113) into 1 byte at 0x5E (baru.obj 69/0x6)
Error [1267] C:\Users\Syuk\Desktop\baru\cuba.c; 78. fixup overflow referencing symbol ??_main (0xD2) into 1 byte at 0x7E (baru.obj 69/0x26)
Error [1267] C:\Users\Syuk\Desktop\baru\cuba.c; 84. fixup overflow referencing symbol ??_main (0x127) into 1 byte at 0x86 (baru.obj 69/0x2E)
Error [1267] C:\Users\Syuk\Desktop\baru\cuba.c; 94. fixup overflow referencing symbol ??_main (0xD2) into 1 byte at 0xA6 (baru.obj 71/0x0)
Error [1267] C:\Users\Syuk\Desktop\baru\cuba.c; 97. fixup overflow referencing symbol ??_main (0x11D) into 1 byte at 0xAE (baru.obj 71/0x8)
Error [1267] C:\Users\Syuk\Desktop\baru\cuba.c; 103. fixup overflow referencing symbol ??_main (0xD2) into 1 byte at 0xCE (baru.obj 71/0x28)
Error [1268] C:\Users\Syuk\Desktop\baru\cuba.c; 220. fixup overflow storing 0x13B in 1 byte at 0xE00 (baru.rlf 45/0x0)
Error [1268] C:\Users\Syuk\Desktop\baru\cuba.c; 220. fixup overflow storing 0x152 in 1 byte at 0xE00 (baru.rlf 101/0x0)
Error [1268] C:\Users\Syuk\Desktop\baru\cuba.c; 220. fixup overflow storing 0x131 in 1 byte at 0xE00 (baru.rlf 113/0x0)
Error [1268] C:\Users\Syuk\Desktop\baru\cuba.c; 220. fixup overflow storing 0x152 in 1 byte at 0xE00 (baru.rlf 165/0x0)
Error [1268] C:\Users\Syuk\Desktop\baru\cuba.c; 220. fixup overflow storing 0x113 in 1 byte at 0xE00 (baru.rlf 177/0x0)
Error [1268] C:\Users\Syuk\Desktop\baru\cuba.c; 220. fixup overflow storing 0x152 in 1 byte at 0xE00 (baru.rlf 229/0x0)
Error [1268] C:\Users\Syuk\Desktop\baru\cuba.c; 220. fixup overflow storing 0x127 in 1 byte at 0xE00 (baru.rlf 241/0x0)
Error [1268] C:\Users\Syuk\Desktop\baru\cuba.c; 220. fixup overflow storing 0x152 in 1 byte at 0xE00 (baru.rlf 293/0x0)
Error [1268] C:\Users\Syuk\Desktop\baru\cuba.c; 220. fixup overflow storing 0x11D in 1 byte at 0xE00 (baru.rlf 305/0x0)
Error [1268] C:\Users\Syuk\Desktop\baru\cuba.c; 220. fixup overflow storing 0x152 in 1 byte at 0xE00 (baru.rlf 357/0x0)

......................................................................................................................................................

yang nie program asal dalam PR8:

CODE: SELECT_ALL_CODE
void main(void)
{
//assign variable
unsigned char i,temp,database;   
unsigned char data[12];    //12 bytes of data received from RFID Reader.
//The data include start of heading, RFID ID,
//and start of text

unsigned char id_1[10]={"8012101210"};    //define the Tag ID here
unsigned char id_2[10]={"1125425145"};    //change this ID to the tag ID that user want to read

unsigned char user_1[10]={"Joseph"};   //define the Tag user here
unsigned char user_2[10]={"Mary"};   //change this user name to the tag ID owner name

bile saya tambah 3@ lebih user cam nie:

unsigned char id_1[]={"8012101210"};    //define the Tag ID here
unsigned char id_2[]={"1125425145"};    //change this ID to the tag ID that user want to read
unsigned char id_3[]={"3125456524"};

unsigned char user_1[]={"Joseph"};   //define the Tag user here
unsigned char user_2[]={"Mary"};   //change this user name to the tag ID owner name
unsigned char user_3[]={"Manir"};


terus error>..mintak pendapat camne nak selesaikan masalah nie
CODE: SELECT_ALL_CODE
program asa//========================================================================
//   Author            : Cytron Technologies      
//   Project            : DIY Project (PR8-RFID door security)
//   Project description   : Scan RFID tag and display the ID and user
//                    on lcd display
//   Version            : 1.1 Bug - Scanning Continuosly Hang Solve
//                    1.2 Upgrade Source code using new RFID Protocol
//========================================================================


//========================================================================
//   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)
#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[12];                  //12 bytes of data received from RFID Reader.
                                    //The data include start of heading, RFID ID,
                                    //and start of text
   
   unsigned char id_1[10]={"0002393929"};      //define the Tag ID here
   unsigned char id_2[10]={"0000797447"};      //change this ID to the tag ID that user want to read
   
   unsigned char user_1[10]={"Joseph    "};   //define the Tag user here
   unsigned char user_2[10]={"Mary      "};   //change this user name to the tag ID owner name

   //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 door");      //display welcome note
   lcd_goto(20);                  //set the lcd cursor to location 20
   send_string("   security");         //display welcome note
   
   beep();                        //initial beep
   delay(200000);                  //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<12;i+=1)data[i]=uart_rec();   //wait for 12 character data receive from RFID reader
                                    //The data receive are start of heading, RFID ID,
                                    //and start 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      
      
      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;
         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
}
syukrikasim
Freshie
 
Posts: 7
Joined: Tue Nov 29, 2011 6:16 pm

Re: problem to add third user in program PR8.

Postby ZaM » Thu Dec 01, 2011 12:14 am

okey jer..********** Build successful! ********** , tp yg ni xde tnda komen (program asa//============), yg ni jer error.
ZaM
Moderator
 
Posts: 78
Joined: Tue Nov 23, 2010 4:16 pm

Re: problem to add third user in program PR8.

Postby sich » Thu Dec 01, 2011 12:34 am

Can you successfully compile the original code without error message?
~> How to ask QUESTIONS the SMART way in FORUM? <~
User avatar
sich
Moderator
 
Posts: 603
Joined: Tue Apr 21, 2009 2:15 pm

Re: problem to add third user in program PR8.

Postby sich » Thu Dec 01, 2011 1:02 am

I can successfully build the original code on MPLAB 8.80 with Hi-Tech Universal Toolsuite 9.83.
I can add up to 8 IDs and 8 user names before the data memory full.
After I reduced the user name array to only 3 characters, 12 IDs and 12 user names can be added.
For higher data memory space, you may need to get other MCU model.
~> How to ask QUESTIONS the SMART way in FORUM? <~
User avatar
sich
Moderator
 
Posts: 603
Joined: Tue Apr 21, 2009 2:15 pm

Re: problem to add third user in program PR8.

Postby syukrikasim » Thu Dec 01, 2011 1:34 am

//this is original source code from cytron:

CODE: SELECT_ALL_CODE
//========================================================================
//   Author            : Cytron Technologies      
//   Project            : DIY Project (PR8-RFID door security)
//   Project description   : Scan RFID tag and display the ID and user
//                    on lcd display
//   Version            : 1.1 Bug - Scanning Continuosly Hang Solve
//                    1.2 Upgrade Source code using new RFID Protocol
//========================================================================


//========================================================================
//   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)
#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[12];                  //12 bytes of data received from RFID Reader.
                                    //The data include start of heading, RFID ID,
                                    //and start of text
   
   unsigned char id_1[10]={"0002393929"};      //define the Tag ID here
   unsigned char id_2[10]={"0000797447"};      //change this ID to the tag ID that user want to read
   
   unsigned char user_1[10]={"Joseph    "};   //define the Tag user here
   unsigned char user_2[10]={"Mary      "};   //change this user name to the tag ID owner name

   //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 door");      //display welcome note
   lcd_goto(20);                  //set the lcd cursor to location 20
   send_string("   security");         //display welcome note
   
   beep();                        //initial beep
   delay(200000);                  //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<12;i+=1)data[i]=uart_rec();   //wait for 12 character data receive from RFID reader
                                    //The data receive are start of heading, RFID ID,
                                    //and start 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      
      
      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;
         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
}

//==============================================================================================================



//if i change this program to three or more user like this its be error:

CODE: SELECT_ALL_CODE
//========================================================================
//   Author            : Cytron Technologies      
//   Project            : DIY Project (PR8-RFID door security)
//   Project description   : Scan RFID tag and display the ID and user
//                    on lcd display
//   Version            : 1.1 Bug - Scanning Continuosly Hang Solve
//                    1.2 Upgrade Source code using new RFID Protocol
//========================================================================


//========================================================================
//   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)
#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[12];                  //12 bytes of data received from RFID Reader.
                                    //The data include start of heading, RFID ID,
                                    //and start of text
   
   unsigned char id_1[10]={"0002393929"};      //define the Tag ID here
   unsigned char id_2[10]={"0000797447"};      //change this ID to the tag ID that user want to read
   unsigned char id_3[10]={"0000254354"};

   unsigned char user_1[10]={"Joseph    "};   //define the Tag user here
   unsigned char user_2[10]={"Mary      "};   //change this user name to the tag ID owner name
   unsigned char user_3[10]={"Mariam    "};

   //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 door");      //display welcome note
   lcd_goto(20);                  //set the lcd cursor to location 20
   send_string("   security");         //display welcome note
   
   beep();                        //initial beep
   delay(200000);                  //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<12;i+=1)data[i]=uart_rec();   //wait for 12 character data receive from RFID reader
                                    //The data receive are start of heading, RFID ID,
                                    //and start 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      
      
      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;
         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
}

//=================================================================================================


//[b]the output is error like this:[/b]

CODE: SELECT_ALL_CODE
Build C:\Users\Syuk\Desktop\PROGRAM\READ AND DISPLAY RFID asal\rfid  asal for device 16F876A
Using driver C:\Program Files\HI-TECH Software\PICC\PRO\9.60\bin\picc.exe

Make: The target "C:\Users\Syuk\Desktop\PROGRAM\READ AND DISPLAY RFID asal\PR8.p1" is up to date.
Executing: "C:\Program Files\HI-TECH Software\PICC\PRO\9.60\bin\picc.exe" "-orfid  asal.cof" "-mrfid  asal.map" --summary=default --output=default PR8.p1 --chip=16F876A -P --runtime=default --opt=default -D__DEBUG=1 -g --asmlist "--errformat=Error   [%n] %f; %l.%c %s" "--msgformat=Advisory[%n] %s" "--warnformat=Warning [%n] %f; %l.%c %s"
HI-TECH C PRO for the PIC10/12/16 MCU family (Lite)  V9.60PL5
Copyright (C) 1984-2009 HI-TECH SOFTWARE
(1273) Omniscient Code Generation not available in Lite mode (warning)
Error   [1267] C:\Users\Syuk\Desktop\PROGRAM\READ AND DISPLAY RFID asal\PR8.c; 62. fixup overflow referencing symbol ??_main (0x145) into 1 byte at 0xA (rfid  asal.obj 67/0x4)
Error   [1267] C:\Users\Syuk\Desktop\PROGRAM\READ AND DISPLAY RFID asal\PR8.c; 63. fixup overflow referencing symbol ??_main (0xDC) into 1 byte at 0x2E (rfid  asal.obj 67/0x28)
Error   [1267] C:\Users\Syuk\Desktop\PROGRAM\READ AND DISPLAY RFID asal\PR8.c; 64. fixup overflow referencing symbol ??_main (0x13B) into 1 byte at 0x36 (rfid  asal.obj 67/0x30)
Error   [1267] C:\Users\Syuk\Desktop\PROGRAM\READ AND DISPLAY RFID asal\PR8.c; 66. fixup overflow referencing symbol ??_main (0xDC) into 1 byte at 0x56 (rfid  asal.obj 67/0x50)
Error   [1267] C:\Users\Syuk\Desktop\PROGRAM\READ AND DISPLAY RFID asal\PR8.c; 67. fixup overflow referencing symbol ??_main (0x11D) into 1 byte at 0x5E (rfid  asal.obj 69/0x6)
Error   [1267] C:\Users\Syuk\Desktop\PROGRAM\READ AND DISPLAY RFID asal\PR8.c; 68. fixup overflow referencing symbol ??_main (0xDC) into 1 byte at 0x7E (rfid  asal.obj 69/0x26)
Error   [1267] C:\Users\Syuk\Desktop\PROGRAM\READ AND DISPLAY RFID asal\PR8.c; 71. fixup overflow referencing symbol ??_main (0x131) into 1 byte at 0x86 (rfid  asal.obj 69/0x2E)
Error   [1267] C:\Users\Syuk\Desktop\PROGRAM\READ AND DISPLAY RFID asal\PR8.c; 88. fixup overflow referencing symbol ??_main (0xDC) into 1 byte at 0xA6 (rfid  asal.obj 71/0x0)
Error   [1267] C:\Users\Syuk\Desktop\PROGRAM\READ AND DISPLAY RFID asal\PR8.c; 89. fixup overflow referencing symbol ??_main (0x127) into 1 byte at 0xAE (rfid  asal.obj 71/0x8)
Error   [1267] C:\Users\Syuk\Desktop\PROGRAM\READ AND DISPLAY RFID asal\PR8.c; 101. fixup overflow referencing symbol ??_main (0xDC) into 1 byte at 0xCE (rfid  asal.obj 71/0x28)
Error   [1267] C:\Users\Syuk\Desktop\PROGRAM\READ AND DISPLAY RFID asal\PR8.c; 102. fixup overflow referencing symbol ??_main (0x113) into 1 byte at 0xD6 (rfid  asal.obj 71/0x30)
Error   [1267] C:\Users\Syuk\Desktop\PROGRAM\READ AND DISPLAY RFID asal\PR8.c; 112. fixup overflow referencing symbol ??_main (0xDC) into 1 byte at 0xF6 (rfid  asal.obj 73/0x4)
Error   [1268] C:\Users\Syuk\Desktop\PROGRAM\READ AND DISPLAY RFID asal\PR8.c; 222. fixup overflow storing 0x145 in 1 byte at 0xE00 (rfid  asal.rlf 46/0x0)
Error   [1268] C:\Users\Syuk\Desktop\PROGRAM\READ AND DISPLAY RFID asal\PR8.c; 222. fixup overflow storing 0x15C in 1 byte at 0xE00 (rfid  asal.rlf 102/0x0)
Error   [1268] C:\Users\Syuk\Desktop\PROGRAM\READ AND DISPLAY RFID asal\PR8.c; 222. fixup overflow storing 0x13B in 1 byte at 0xE00 (rfid  asal.rlf 114/0x0)
Error   [1268] C:\Users\Syuk\Desktop\PROGRAM\READ AND DISPLAY RFID asal\PR8.c; 222. fixup overflow storing 0x15C in 1 byte at 0xE00 (rfid  asal.rlf 166/0x0)
Error   [1268] C:\Users\Syuk\Desktop\PROGRAM\READ AND DISPLAY RFID asal\PR8.c; 222. fixup overflow storing 0x11D in 1 byte at 0xE00 (rfid  asal.rlf 178/0x0)
Error   [1268] C:\Users\Syuk\Desktop\PROGRAM\READ AND DISPLAY RFID asal\PR8.c; 222. fixup overflow storing 0x15C in 1 byte at 0xE00 (rfid  asal.rlf 230/0x0)
Error   [1268] C:\Users\Syuk\Desktop\PROGRAM\READ AND DISPLAY RFID asal\PR8.c; 222. fixup overflow storing 0x131 in 1 byte at 0xE00 (rfid  asal.rlf 242/0x0)
Error   [1268] C:\Users\Syuk\Desktop\PROGRAM\READ AND DISPLAY RFID asal\PR8.c; 222. fixup overflow storing 0x15C in 1 byte at 0xE00 (rfid  asal.rlf 294/0x0)
Error   [1268] C:\Users\Syuk\Desktop\PROGRAM\READ AND DISPLAY RFID asal\PR8.c; 222. fixup overflow storing 0x127 in 1 byte at 0xE00 (rfid  asal.rlf 306/0x0)
Error   [1268] C:\Users\Syuk\Desktop\PROGRAM\READ AND DISPLAY RFID asal\PR8.c; 222. fixup overflow storing 0x15C in 1 byte at 0xE00 (rfid  asal.rlf 358/0x0)
Error   [1268] C:\Users\Syuk\Desktop\PROGRAM\READ AND DISPLAY RFID asal\PR8.c; 222. fixup overflow storing 0x113 in 1 byte at 0xE00 (rfid  asal.rlf 370/0x0)
Error   [1268] C:\Users\Syuk\Desktop\PROGRAM\READ AND DISPLAY RFID asal\PR8.c; 222. fixup overflow storing 0x15C in 1 byte at 0xE00 (rfid  asal.rlf 422/0x0)

********** Build failed! **********

//i dont know how to fix this problem..plese help me
syukrikasim
Freshie
 
Posts: 7
Joined: Tue Nov 29, 2011 6:16 pm

Re: problem to add third user in program PR8.

Postby syukrikasim » Thu Dec 01, 2011 1:41 am

how you make it source code..i dont know and my lecture in micro c also dont know and want me to ask u about the error.tq
syukrikasim
Freshie
 
Posts: 7
Joined: Tue Nov 29, 2011 6:16 pm

Re: problem to add third user in program PR8.

Postby sich » Thu Dec 01, 2011 9:50 am

Will you please list down what have you modified? I don't see why you cannot compile the code.
May be you can try reinstall your Hi-tech compiler to the latest version. Get the installer at hi-tech website.
~> How to ask QUESTIONS the SMART way in FORUM? <~
User avatar
sich
Moderator
 
Posts: 603
Joined: Tue Apr 21, 2009 2:15 pm

Re: problem to add third user in program PR8.

Postby A380 » Thu Dec 01, 2011 10:20 am

Here is the link to download the latest version of Hi-Tech Compiler for PIC16.
http://ww1.microchip.com/downloads/en/DeviceDoc/picc_9_.83_win.exe
User avatar
A380
Discoverer
 
Posts: 120
Joined: Tue May 19, 2009 2:44 pm
Location: Malaysia

Re: problem to add third user in program PR8.

Postby syukrikasim » Thu Dec 01, 2011 7:14 pm

for test program insert 3 user:soure code
//===========================================================================
// Main function (main fucntion of the program)
//===========================================================================
void main(void)
{
//assign variable
unsigned char i,temp,database;
unsigned char data[12]; //12 bytes of data received from RFID Reader.
//The data include start of heading, RFID ID,
//and start of text

unsigned char id_1[10]={"0002393929"}; //define the Tag ID here
unsigned char id_2[10]={"0000797447"}; //change this ID to the tag ID that user want to read

unsigned char user_1[10]={"Joseph "}; //define the Tag user here
unsigned char user_2[10]={"Mary "}; //change this user name to the tag

//==========================================================================
to modified: 3 user just add one more user

//===========================================================================
// Main function (main fucntion of the program)
//===========================================================================
void main(void)
{
//assign variable
unsigned char i,temp,database;
unsigned char data[12]; //12 bytes of data received from RFID Reader.
//The data include start of heading, RFID ID,
//and start of text

unsigned char id_1[10]={"0002393929"}; //define the Tag ID here
unsigned char id_2[10]={"0000797447"}; //change this ID to the tag ID that user want to read
unsigned char id_3[10]={"0000875634"};

unsigned char user_1[10]={"Joseph "}; //define the Tag user here
unsigned char user_2[10]={"Mary "}; //change this user name to the tag
unsigned char user_310]={"Azman "};
syukrikasim
Freshie
 
Posts: 7
Joined: Tue Nov 29, 2011 6:16 pm

Re: problem to add third user in program PR8.

Postby sich » Thu Dec 01, 2011 11:01 pm

Any update? What have you test and what's the result?
~> How to ask QUESTIONS the SMART way in FORUM? <~
User avatar
sich
Moderator
 
Posts: 603
Joined: Tue Apr 21, 2009 2:15 pm

Next

Return to DIY Project Set

Who is online

Users browsing this forum: No registered users and 16 guests