Microcontroller › 8051 › 8051 PIR RFID BASED PROGRAM ERROR
- This topic has 1 reply, 2 voices, and was last updated 7 years, 12 months ago by GANEEV SINGH.
-
AuthorPosts
-
April 6, 2016 at 4:16 pm #4405Devjeet MandalParticipant
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]==||(id[10]=='D')||(id[ 11]=)) {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 #14139GANEEV SINGHParticipantHi 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 -
AuthorPosts
- You must be logged in to reply to this topic.