EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / RFID Attendance System

RFID Attendance System

|

Microcontroller › 8051 › RFID Attendance System

  • This topic has 6 replies, 3 voices, and was last updated 11 years, 4 months ago by Ashutosh Bhatt.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • August 23, 2014 at 3:51 am #3170
    SUnny
    Participant
    RFID Attendance System

    Hi i m trying to build a Rfid attendance system using 8051(AT89C52). Could someone please tell me what is wrong with code as it compiles without error but woudnt simulate on proteus and also how accurate is proteus compared to real life testing. I am also trying to interface a RTC(DS1307) if someone could help that it would be great aswell.

     

    #include <reg51.h>
    #include <string.h>
     
     
     
    #define TOTAL 5
    void delay_msec(int);
    void lcd_init();
    void lcd_data(char);
    void send(char);
    void lcd_cmd(char);
    void lcd_dataS(char *p);
    void lcd_data_int(int);
     
    sbit rs=P2^0;
    sbit en=P2^1;
     
     
     void serial_init();
     void serial_txS(char *);
     void serial_tx(char);
     void checkID();
     void printOnTerminal();
     short int checkTodaysAttd(int);
     
     sbit ON=P1^0;
     sbit RESET=P1^1;
     sbit result=P1^2;
     sbit IR_Tx=P1^3;
     sbit IR_Rx=P1^4;
     sbit Reset_Todays_Attendence=P1^5;
     
     
    void lcd_init()
    {    
     delay_msec(20);
     send(0x30);   
     delay_msec(10);  
     send(0x30);
     delay_msec(1);
     send(0x30);
     delay_msec(1); 
     send(0x20);
     delay_msec(1); // upto here we call it as RESETting of LCD, 
                    // and telling the LCD that we are using 4bit mode
     
     lcd_cmd(0x06);
     lcd_cmd(0x01);
     lcd_cmd(0x28);
     lcd_cmd(0x0e);
    }
     
    void send(char value)
    {
    char temp;
     temp= P2 & 0x0f; //store the higher nibble of P2 in temp
     P2= temp | value;  //now bitwise OR the value with temp,
                //which successfully sends data(higher nibble) to P2 without 
                //effecting its prevoius data in the lower nibble
     en=1;
     delay_msec(1);
     en=0;
    }
     
     
    void lcd_cmd(char cmd)
    {
     char temp;
     temp=cmd &0xf0; //masks (makes zero) the lower nibble
     rs=0;
     send(temp);  //now send the higher nibble
     temp=cmd<<4;    //now left shift 4 times which shifts lower
              //nibble to higher nibble
     temp=temp&0xf0;  //now mask lower nibble again
     send(temp);   //and send to the LCD
    }
     
    /*
    void lcd_data(char d)
    {
     char temp;
     temp=d &0xf0;
     rs=1;
     send(temp);
     temp=d<<4;
     temp=temp&0xf0;
     send(temp);
    } */
     
     
    void lcd_dataS(char *p)
    {
      char temp;
      while(*p!=’’)
      { 
      rs=1;
     temp=(*p) & 0xf0;
     send(temp);
     temp=(*p) << 4;
     temp=temp & 0xf0;
     send(temp);
     p=p+1;
      }
    }
     
    void lcd_data_int(int value)
    {
      int a[3]={0,0,0},i=0,temp;
      while((value/10)!=0)
      {
       a=48+value%10;
       i++;
       value=value/10;
      }
      a=48+value;
     
      for(i=2;i>=0;i–)
      {
        rs=1;
     temp= a & 0xf0;
     send(temp);
     temp=(a << 4) & 0xf0;
     send(temp);
      }
    }
     
    void delay_msec(int n)
    {
     int i,j;
     for(j=0;j<n;j++)
     for(i=0;i<921;i++);
    }
    struct details
     {
       char *name;
       char id[4];
       int count;
     }emp[TOTAL]={{“Sunny”, “431a”, 0},
              {“Sunny1”,     “456p”, 0},
              {“Sunny2”, “111”, 0},
              {“Sunny3”,   “123”, 0},
              {“Sunny4”,    “145”, 0}};
     
     char recieved_id[4]={0};
     int i, no_of_stu=0, todays_count=0;
     int todays_ids[4]={0};
     short int access=0, gotID=0;
     
     void serial() interrupt 4
     {
       EA=0;
         for(i=0;i<4;i++)
          {
            while(RI==0);
            recieved_id=SBUF;
            RI=0;
          }
          gotID=1;
       EA=1;
     }
    void checkID()
    {
      access=0;               //like a flag
      lcd_dataS(recieved_id);
      i=0;
    if(( strcmp(emp.id , recieved_id) )==0)
         { 
          if(checkTodaysAttd(i)) 
              {
                  access=1;
                  lcd_cmd(0x01);
                  lcd_dataS(“welcome”);
                  lcd_cmd(0xc0);
                  lcd_dataS(emp.name);
                  emp.count++;
     
                todays_ids[todays_count]=i+1;
                     todays_count++;
     
                delay_msec(400);
                printOnTerminal();
                gotID=0;
                  //break;
              }
           else
             {
               lcd_cmd(0x01);
               lcd_dataS(“your turns over”);
               gotID=0;
               delay_msec(400);
             }
         }
        
     
     
       if(access==0)
        {
            lcd_cmd(0x01);
            lcd_dataS(“access denied”);
            delay_msec(100);
            gotID=0;
        }    
    }
     
    short int checkTodaysAttd(int id)
    {
      short int d;
      d=0;
      if(id==(todays_ids[d]-1))
       {
        return 0;    //return 0 if specific ID has already been
       }            //counted for today.
      return 1;
    }
     
    void printOnTerminal()
    { EA=0;
      serial_tx(‘r’);
      serial_tx(‘n’);
      serial_txS(emp.name);
      serial_tx(‘ ‘);
      serial_txS(emp.id);
      serial_tx(‘ ‘);
      serial_tx(emp.count+48);
      EA=1;
    }  
     
    void serial_init()
    {
      TMOD=0x20;
      TH1=0xfd;
      SCON=0x50;
      TR1=1;
    }
     
    void serial_txS(char *p)
    {
      while((*p)!=’’)
      {
        SBUF=*p;
        while(TI==0);
        TI=0;
        p++;
      }
    }
     
    void serial_tx(char x)
    {
      SBUF=x;
      while(TI==0);
      TI=0;
    } 
    //***********************************


    void main()
      {
        ON = 1;
    RESET = 1;
    result = 1;
        rs= 0; 
    en=0;
        P2=0x00;
        IR_Rx=1;
        IR_Tx=0;
        EA=1;
        ES=1;
        serial_init();
        lcd_init();
     
    start:    
       while(1)
         {
         IR_Tx=0;
         lcd_cmd(0x01);
     
           while(!ON)
           { 
            lcd_cmd(0x01);
            IR_Tx=1;
             while(!(IR_Rx==1))
             {
              lcd_cmd(0x01);
              lcd_dataS(“ID please”);
              
              while(gotID==0)   //wait until any card is shown
                if(ON==1)
    {
    goto start;
              }
              checkID();    
             }
           }
          /////////////////////////
           while(!result)
            {
              for(i=0;i<=TOTAL;i++)
              {
                lcd_cmd(0x01);
                lcd_dataS(emp.name);
                lcd_cmd(0xc0);
                lcd_data_int(emp.count);
                delay_msec(500);
              }
            }
          ////////////////////////
     
           while(! Reset_Todays_Attendence)
            {
              i=0;
     
              todays_count=0;
              lcd_cmd(0x01);
              lcd_dataS(“todays attd rst”);
              delay_msec(100);
            }
          ///////////////////////
          }    //end of  loop
     } //end of main
    Please note: This not my code but i rectfied it to my needs.

     

    August 23, 2014 at 6:14 am #12061
    AJISH ALFRED
    Participant

    Hi,

    I would suggest not to waste your time on simulation software if you are planning to try it out in real hardware

    August 25, 2014 at 8:13 am #12073
    SUnny
    Participant

    Thanks, but would the code be alright for real life testing?

    August 31, 2014 at 6:22 am #12099
    Ashutosh Bhatt
    Participant

    i wonder how you simulate RFID reader in proteus?

    there is no way.

    you can check only LDC or hardware push buttons in proteus

    September 1, 2014 at 8:35 pm #12113
    SUnny
    Participant

    You can, by putting a virtual terminal onto RX/TX pins of the micro. Have managed to get the code working with RTC aswell now. 

     

    Thanks

    September 2, 2014 at 11:42 am #12119
    AJISH ALFRED
    Participant

    Thats great!

    September 11, 2014 at 2:00 am #12149
    Ashutosh Bhatt
    Participant

    i know virtual terminal available in proteus

    but you can not use it to work as RFID reader. its simple serial terminal

    it is provided for simulation of serial communication with PC or other micro controllers/processors

    if you are using it in place of RFID reader then its based on simple assumption

  • Author
    Posts
Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • factory device from 2017'ish with web ui - too old to function with Microsoft Edge ? January 14, 2026
  • flexible copper cable January 14, 2026
  • renewed interest in old project I call it WICKED 8 January 14, 2026
  • updating circuit with power on off switching January 14, 2026
  • Steering angle sensor question January 13, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise