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.

program off rfid tags

Status
Not open for further replies.

sireesha7

Newbie level 3
Joined
Feb 8, 2014
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
57
i am doing a project on "rfid based shopping trolley".
please help me for programming the rfid tags... i read the tag id serially and i should display the details of that particular i.d on the lcd..
here is my program
but i need to modify this program as
all the card no's(tag i.d's) are to placed in an array...when a card is read ... i to have compare received card i.d with all the card no's in the array and i have to display the details of that card i.d on lcd
NOTE: use a loop for comparing received card i.d and card i.ds in array


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#include<reg52.h>
#include<string.h>
unsigned int data_out;
sfr lcd_data_pin=0x90; //P1 port 
sbit rs=P2^0;      //Register select sbit
sbit rw=P2^1;      //Read/Write sbit 
sbit en=P2^2;       //Enable pin
unsigned char card_id[12]; 
void delay(unsigned int count)    //Function to provide delay 
{   
int i,j; 
for(i=0;i<count;i++)
for(j=0;j<1275;j++); 
}
void lcd_cmd(unsigned char comm)   //Lcd command funtion
{     
lcd_data_pin=comm;  
en=1;  
rs=0;   
rw=0;   
delay(1);  
en=0;
}
void lcd_data(unsigned char disp)  //Lcd data function
{     
lcd_data_pin=disp; 
en=1;     
rs=1;   
rw=0;   
delay(1); 
en=0;
}
lcd_string(unsigned char *disp)     //Function to send string
{  
int x; 
for(x=0;disp[x]!=0;x++) 
{        
lcd_data(disp[x]); 
}
}
void lcd_init()   //Function to initialize the LCD 
{  
lcd_cmd(0x38); 
delay(5);  
lcd_cmd(0x0F);      
delay(5);  
lcd_cmd(0x80);    
delay(5);
}
void recieve()     //Function to recieve data serialy from RS232 
{   
unsigned char k; 
for(k=0;k<12;k++)  
{        
while(RI==0);
card_id[k]=SBUF;   
RI=0;  
} 
}
void main()
{  
int l;
TMOD=0x20;            //Enable Timer 1   
TH1=0XFD;  
SCON=0x50;  
TR1=1;                // Triggering Timer 1  
lcd_init();  
lcd_cmd(0x81);      //Place cursor to second position of first line 
lcd_string("RFID BASED");
delay(100);
lcd_cmd(0xc0);
lcd_string("SHOPPING TROLLEY");
delay(100);
lcd_cmd(0x01);
lcd_string("UNIQUE ID:");  
delay(200);  
while(1)
{
        recieve(); 
     lcd_cmd(0xC1);        //Place cursor to second position of second line  
     for(l=0;l<12;l++) 
     {
          lcd_data(card_id[l]);
         }
         if(strcmp(card_id,"42006B613E76"))
         {
                 lcd_cmd(0x01);
             lcd_cmd(0x80);
             lcd_string("Product cost=100");
             lcd_cmd(0xC0);
             delay(20);
                lcd_string("exp date=mar2016");
         }
         else if(strcmp(card_id,"42006B613E77"))
         {
            lcd_cmd(0x01);
             lcd_cmd(0x80);
             lcd_string("Product cost=150");
             lcd_cmd(0xC0);
             delay(20);
                lcd_string("exp date=mar2015");
         }
         else
         {
                lcd_cmd(0x01);
             lcd_cmd(0x80);
             lcd_string("Product cost=200");
             lcd_cmd(0xC0);
             delay(20);
                lcd_string("exp date=mar2017");
         }
}
}

 
Last edited by a moderator:

Have you successfully read the ID Card data and printed it on LCD , First ,

If that thing is ok ,

Then Make a condition for getting the Card Data as

you have written "receive" function in while loop
make it like
Code:
if(SRXD_PIN == 0)  //Whenever A Card Is received the Rx Pin should become LOW//
{

/*all Your Logic here*/ 

}
then First check with this Logic to print the ID Card ON LCD
then Move on the Comparison and all Further algos,
 

what happens if i write receive function in whie loop?????????
 

I meant to say the receive function will only work when there is some start bit detected at Rx pin of MCU then it will be redundant ,
 
thanks for ur help.... i am getting an error while doing my program help me out of this
my program:
#include<reg52.h>
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
unsigned char card_id[12];
unsigned char p[3];
char fun(char p[]);
char fun1(char pc);
sbit switch_pin1=P2^5;
sbit switch_pin2=P2^6;
sfr lcd_data_pin=0x90; //P1 port
sbit rs=P2^0; //Register select sbit
sbit rw=P2^1; //Read/Write sbit
sbit en=P2^2; //Enable pin
void delay(unsigned int count) //Function to provide delay
{
int i,j;
for(i=0;i<count;i++)
for(j=0;j<1275;j++);
}
void lcd_cmd(unsigned char comm) //Lcd command funtion
{
lcd_data_pin=comm;
en=1;
rs=0;
rw=0;
delay(1);
en=0;
}
void lcd_data(unsigned char disp) //Lcd data function
{
lcd_data_pin=disp;
en=1;
rs=1;
rw=0;
delay(1);
en=0;
}
lcd_string(unsigned char *disp) //Function to send string
{
int x;
for(x=0;disp[x]!=0;x++)
{
lcd_data(disp[x]);
}
}
void lcd_init() //Function to initialize the LCD
{
lcd_cmd(0x38);
delay(5);
lcd_cmd(0x0F);
delay(5);
lcd_cmd(0x80);
delay(5);
}
void main()
{
int l,pc,tc,d;
char k;
tc=0;
d=0;
TMOD=0x20; //Enable Timer 1
TH1=0XFD;
SCON=0x50;
TR1=1; // Triggering Timer 1
lcd_init();
lcd_cmd(0x81); //Place cursor to second position of first line
lcd_string("RFID BASED");
delay(100);
lcd_cmd(0xc0);
lcd_string("SHOPPING TROLLEY");
delay(200);
lcd_cmd(0x01);
lcd_cmd(0x80);
lcd_string("unique id:");
delay(200);
lcd_string(0xc0);
while(1)
{
if(RI==0);
{
for(k=0;k<12;k++)
card_id[k]=SBUF;
RI=0;
}
for(k=0;k<12;k++)
{
lcd_string(card_id[k]);
}

}
}
i got an error as illegal pointer conversion where indicate the letters as bold and underlined
can u tell me why i am getting this error i am not able to understant plss??????????/
 

You got the error because of the following:-


1. You want to Print ID_Card Data , but that thing has to be printed as BYTE by BYTE according to your logic of printing
Code:
for(k=0;k<12;k++)// that will print first 
0th Element of ID_card received , then 1st element , then 2nd element and further on !!

2. You have to print that thing using a function whose argument is a char (a byte) and you have used "lcd_string()" whose argument is a string or an array complete that's why you got the error

Correct one !!-:

Code:
for(k=0;k<12;k++)
{
lcd_data(card_id[k]);   // Prints Data Byte by Byte
}
 

hai ... thanku for your suggestion ...i had dumped the code on the microcontroller but i am not getting the data serially (receive part) help me pls ...and i have one question to ask you.
for max232 i used capacitors of 1uf will it be able to drive ic(max232)???? if not what value of capacitors i have to use
 

Hi,
The Capacitor values are fine as per my Knowledge,
In addition to the Capacitor's Value is also listed in THE DATASHEET,

and check for any BASIC Serial Communication with PC first if there is any problem in transceiving of DATA Serialy,

Like write a basic program having one character transmitting to PC and Receiving also ,
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top