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 / 8051 PIR RFID BASED PROGRAM ERROR

8051 PIR RFID BASED PROGRAM ERROR

|

Microcontroller › 8051 › 8051 PIR RFID BASED PROGRAM ERROR

  • This topic has 1 reply, 2 voices, and was last updated 8 years, 8 months ago by GANEEV SINGH.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • April 6, 2016 at 4:16 pm #4405
    Devjeet Mandal
    Participant

    Here is my program about a motion security system.This system got one pir sensor,rfid module rdm6300 and a lcd.The problem is 

    1;>RFID DATA READING ERROR.The AT89S52 read the data with start bit and stop bit,While i<12……But give correct data when i<14.But compare failed.Means i cant compare the rfid data properly.

    2;>LCD giving garbage after running more than 12 hours.What should i do ????

     

    #include<reg52.h>
    #include<lcd.h>
    #include<string.h>
    sbit RELAY = P2^5;
    sbit RS = P0^7;
    sbit EN = P0^6;
    sbit D4 = P0^5;
    sbit D5 = P0^4;
    sbit D6 = P0^3;
    sbit D7 = P0^2;
    sbit PIR = P0^0;
    sbit SRED = P2^4;
    sbit SGREEN = P2^3;
    sbit RGREEN = P2^0;
    sbit RRED = P2^2;
    sbit RBLUE = P2^1;
    sbit ALARM=P2^7;
    sbit CARD = P3^0;
    unsigned char card_id[12] = {"F0200CE7E8D3"} ;
    char Data,k;
    char j=0,i=0,flag=0;
     
    volatile char id[12];                                       
    void Delay(int a)
     {
       int j;
       int i;
       for(i=0;i<a;i++)
        {
          for(j=0;j<100;j++)
             {
             }
        }
    }
     
     char rcv(void)
      {
     TR1 = 1;
         while(!RI);
     RI = 0;
     TR1 = 0;
        return SBUF;
      }
     
    void main()
     {
        P0 = 0;
        P1 = 0;
        P2 = 0;
        P3 = 0;
        RELAY = 0;
        Delay(1000);
        RELAY = 1;
        Delay(500);
        card_id[12]=0;
        id[12]=0;
        Delay(100);
        TMOD = 0x20;
    TH1 = 0xFD;
    SCON = 0x50;
    TR1 =0;
    Lcd4_Init();
    SBUF = 0;
    while(1)
      {
             Lcd4_Clear();
         Lcd4_Set_Cursor(1,0);
         Lcd4_Write_String("Unique ID:");
         id[12]=0;
     Lcd4_Set_Cursor(2,0);
     for(i=0;i<12;i++)
       id = rcv();
     i=0;
     Delay(100);
     Lcd4_Write_String(id);
         Delay(1000);
     if((id[0]=='F')||(id[1]==0)||(id[2]==2)||(id[3]==0)||(id[4]==0)||(id[5]=='C')||(id[6]=='E')||(id[7]==7)||(id[8]=='E')||(id[9]==8)||(id[10]=='D')||(id[11]==3))
     {
       Lcd4_Set_Cursor(1,0);
       Lcd4_Write_String("Access Granted");
       RGREEN = 1;
       SRED = 0;
       Delay(1000);
       Lcd4_Clear();
       RGREEN = 0;
     }
    else
     {
       Lcd4_Set_Cursor(1,0);
       Lcd4_Write_String("Acces Denied");
       SRED = 1;
       RGREEN = 0;
       Delay(1000);
       Lcd4_Clear();
       SRED = 0;
    }
      }
     }

     

    September 17, 2016 at 6:08 am #14139
    GANEEV SINGH
    Participant

    Hi Devjeet

    I dont know if this happens only wiht 8051s but yeah the number that is written on the RFID card is not what you'll see on LCD after processing.First try out reading the card value using the code written below, also its better to read 14 bytes from RFID module becuase these 14 byes include start byte, stop byte and 12 data bytes. here's the code:

    for(i=0;i<15;i++)   // 15 works fine here
    {
    j=0;
    while(RI==0)
    {
    if(j>=1000)
    goto timeout;
    j++;
    }
    c=SBUF;
    RI=0;
    }
    timeout:
    c[12]='';   //this ensures that only 12 byte data is stored in c[]
     
    also after this you can print this c[] over the LCD to get RFID card's comparable value. Here you go:
     
    i=0;
    while(c!='')
    {
    lcdData(c);
    i++;
    }
     
    Now note down this value somewhere, this will help in recognizing the card in future while working out through your code.
    Replace "F0200CE7E8D3" value that you have written in your code with the new one.
     
    Hope this helps. 
     
    Good luck
  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • Capacitive Touch On The Profile May 24, 2025
  • going out on a limb and praying the schematic is correct May 24, 2025
  • Easy PC Demo version Schem and Layout program questions May 24, 2025
  • nicd charger for li-ion May 24, 2025
  • Can't get a small CRT display to focus May 24, 2025

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2025 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