Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Help with programming rfid with LCD usnig pic16f877A

Status
Not open for further replies.

abdo.medo1000

Member level 1
Member level 1
Joined
Apr 27, 2021
Messages
33
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Activity points
324
Dear all,
I'm trying to make an Door Security System Using RFID with LCD using pic16f877A. I was trying to defined my ID tag number on the code in MicroC program but it is not working on my simulation , I want to save some ID tags number like ( x=12345// john's card , y=54321// Sara's card) as a variable and when RFID reader read them it should show tag and the cards number which meaning the the entering is approved and if else it will say "it not correct" . Now i rote the code to do that but im not taking what i want im lookng forward of your helping

Here is my code

Code:
//Title :CD interfacing with pic16f877a

//LCD module connections





sbit LCD_RS at RC0_bit; //LCD reset

sbit LCD_EN at RC1_bit; //LCD enable



sbit LCD_D4 at RC2_bit; //Data

sbit LCD_D5 at RC3_bit; //Data

sbit LCD_D6 at RC4_bit; //Data

sbit LCD_D7 at RC5_bit; //Data



//LCD Pin Direction



sbit LCD_RS_direction at TRISC0_bit;

sbit LCD_EN_direction at TRISC1_bit;

sbit LCD_D4_direction at TRISC2_bit;

sbit LCD_D5_direction at TRISC3_bit;

sbit LCD_D6_direction at TRISC4_bit;

sbit LCD_D7_direction at TRISC5_bit;



void main() {



char j,i,rfid[13];



int sara=54321;



Lcd_Init();

Lcd_cmd(_LCD_CLEAR);

LCD_Cmd(_LCD_CURSOR_OFF);



Lcd_out(1,1,"Press your card :)");



UART1_Init(9600);

rfid[13]= '\0' ;

while(1)

{

      if (UART1_Data_Ready())

      {

      for(i=0;i<6;)

      {

      if(UART1_Data_Ready())

      {

      rfid[i]=UART1_Read();   // read the received data,

      i++;

      }

      }

      if(sara == rfid[i])

      {

      Lcd_Cmd(_LCD_SECOND_ROW);

      Lcd_Out_cp("Tag:");

      for(i=0;i<6;){

      Lcd_Chr_Cp(rfid[i]);

      UART1_Write(rfid[i]);

      i++;

      delay_ms(1);

      }}

      else {

      Lcd_Cmd(_LCD_SECOND_ROW);

      Lcd_Out_cp("not correct");

      delay_ms(1);

      }

[ATTACH type="full"]169103[/ATTACH]



       }

      }

}
 

Attachments

  • Screenshot 2021-04-28 010037.jpg
    Screenshot 2021-04-28 010037.jpg
    383.1 KB · Views: 187
Last edited:

You haven't made it clear which RFID data format you expect but my suspicion is you are not framing it correctly.

It looks like MikroC code which I'm not familiar with, it has some non-standard features but I guess "if (UART1_Data_Ready())" is telling you a character has been received in the RXD register. You don't know which character it is though, you need something unique (or an electrical signal if the RFID receiver produces one) to tell it which is the first byte in the RFID sequence. From there you can count the required number of bytes in the ID number then reset 'i' in readiness for the next ID sequence. You probably also want to 'push' a \0 string terminator ahead of the received data as you store it or you will still have any previous data in your rfid[] array.

The RFID units I use (https://www.rfsolutions.co.uk/radio-modules-c10/rfid-modules-c333/micro-rwd-quad-tag-reader-p926) have an LED output to signal a tag is in reader range, I use it to prepare the receive buffer to accept a new ID code.
 
hello,

your RFID card must allready have a serial number on 10 digits, 5 bytes
ex: TAG type 0400
Serial number 44B7E1E9FB
so first step is to recognize this TAG and serial number,
then you can write or read your own data into blocs

i did sucessfully tests with RFID interface board with SPI link...
using **broken link removed**

maybe could help you ...
 

Code:
char j,i,rfid[13];
int sara=54321;
//
if(sara == rfid[i])

You can't compare a character with an integer number. Also 54321 is outside int data type number range of -32768 .. 32767.

You probably want to convert the ASCII coded tag ID to a number by using atoi() or atol() function. Or compare with a string representation of the expected tag number.
 

Code:
char j,i,rfid[13];
int sara=54321;
//
if(sara == rfid[i])

You can't compare a character with an integer number. Also 54321 is outside int data type number range of -32768 .. 32767.

You probably want to convert the ASCII coded tag ID to a number by using atoi() or atol() function. Or compare with a string representation of the expected tag number.
Yeah you are correct
Code:
char j,i,rfid[13];
int sara=54321;
//
if(sara == rfid[i])

You can't compare a character with an integer number. Also 54321 is outside int data type number range of -32768 .. 32767.

You probably want to convert the ASCII coded tag ID to a number by using atoi() or atol() function. Or compare with a string representation of the expected tag number.
Thank you sir for replying,
Yesh you are correct i convert the ASCUI using atoi function and it's working very well
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top