Tuesday, April 24, 2012

RFID based Attendance system using 8051- with easy AUTOMATIC FILE generation facility


watch the video for explanation of the project

#include
 #include<string.h>
 #include "lcd_display4bit.h"

 #define TOTAL 5

 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;
 
struct details
 {
   char *name;
   char id[4];
   int count;
 }emp[TOTAL]={{"phanindra", "437p", 0},
          {"nayak",     "455n", 0},
          {"anilKumar", "414a", 0},
          {"gowtham",   "456g", 0},
          {"chaitu",    "449c", 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[i]=SBUF;
        RI=0;
      }
      gotID=1;
   EA=1;
 }

//***********************************------
 void main()
  {
    ON=RESET=result=1;
    rs=en=0;
    P2=0x00;
    IR_Rx=1;
    IR_Tx=0;
    EA=1;
    ES=1;
    serial_init();
    lcd_init();

super:    
   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 super;
          
          checkID();    
         }
       }
      /////////////////////////
       while(!result)
        {
          for(i=0;i<=TOTAL;i++)
          {
            lcd_cmd(0x01);
            lcd_dataS(emp[i].name);
            lcd_cmd(0xc0);
            lcd_data_int(emp[i].count);
            delay_msec(500);
          }
        }
      ////////////////////////

       while(! Reset_Todays_Attendence)
        {
          for(i=0;i'\0';

          todays_count=0;
          lcd_cmd(0x01);
          lcd_dataS("todays attd rst");
          delay_msec(100);
        }
      ///////////////////////
      }    //end of super loop
 } //end of main

//*************************************

void checkID()
{
  access=0;               //like a flag
  lcd_dataS(recieved_id);
    for(i=0;iif(( strcmp(emp[i].id , recieved_id) )==0)
     { 
      if(checkTodaysAttd(i)) 
          {
              access=1;
              lcd_cmd(0x01);
              lcd_dataS("welcome");
              lcd_cmd(0xc0);
              lcd_dataS(emp[i].name);
              emp[i].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;
  for(d=0;dif(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[i].name);
  serial_tx(' ');
  serial_txS(emp[i].id);
  serial_tx(' ');
  serial_tx(emp[i].count+48);
  EA=1;
}  

void serial_init()
{
  TMOD=0x20;
  TH1=0xfd;
  SCON=0x50;
  TR1=1;
}

void serial_txS(char *p)
{
  while((*p)!='\0')
  {
    SBUF=*p;
    while(TI==0);
    TI=0;
    p++;
  }
}

void serial_tx(char x)
{
  SBUF=x;
  while(TI==0);
  TI=0;
} 

17 comments:

  1. can u give me lcd_display4bit.h file too

    ReplyDelete
  2. thank you for providing this much of information.
    really nice job..

    ReplyDelete
  3. can u give me all data and circuit diagram of this project

    ReplyDelete
  4. hi der..code is here...circuit diagram you can make it by looking the video..thanks

    ReplyDelete
  5. hi, when i compile this code iam getting 2 errors
    1.atend.c(3): warning C318: can't open file 'lcd_display4bit.h'
    2.atend.c(54): error C202: 'rs': undefined identifier.
    please send the correct code to my mail
    id:jontychandrasekhar2@gmail.com

    ReplyDelete
  6. bhai provide all the data plz....circuit as well as all the required files

    ReplyDelete
  7. how can i custumize ur code in pic 16f877

    ReplyDelete
  8. abe dif or iif kahan se uthaye hain

    ReplyDelete
  9. please mail me the full code iam not getting the output,is it lcd_dataS(recieved_id) is correct,please mail me the compiled code
    Gmail:kamranahmedb7@gmail.com

    ReplyDelete
  10. please can u give me lcd_display4bit.h
    my mail abdelhay.kannch@gmail.com

    ReplyDelete
  11. Hi folks,
    Regarding, LCD code you can get it from the LCD post in this same blog..
    Now a days I am not into embeddedsystems.So I dont have the environment to recompile and give the correct code for you. I am sure you guys can figure it out the changes required.
    Thanks for ur interest.

    ReplyDelete
    Replies
    1. your code gives no error(after correcting) ..just warnings but when i run in proteus it does not perform as shown in your video. the circuit is same, but Fails to take input in virtaul terminal.

      Delete
    2. I am having the same problem does anyone have a solution?

      Delete
  12. excuse me,i have some question to ask.
    The source code sir using what software to run it ?
    Can use MP LAB run or not?
    Thank you.

    ReplyDelete
  13. Can you please send the working code to sankalpgupta2@gmail.com?

    ReplyDelete
  14. its not working u just uploaded the wrong code, where is the lcd_display4bit.h even at the beginning #include what? u continued with second line i dont get it and i am sure that the code u used in the video is not here

    ReplyDelete