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.

RFID Card identification

Status
Not open for further replies.

burcum_sky

Newbie level 1
Joined
Jul 10, 2015
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
71
Hello Everyone;

I am new this job.
I can t find it what I want to do

I have four Rfid Cards ant i want to identificate them with Rfid Reader.

When Rfid card is read, the terminal writes ASCII Code like this;
11111111101001110110000000000010100110001100011111111010100111001
How can i identicate this code for anyone.

i want to that;
when RFid reader read this code, it detect this code and uart write someone's name.

i did seperate cards with 60. bit but not enough.

can you help me this topic?

----------------------------------------------------------------------------------------------------------------
i wrote this part;


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
if(data_valid[60]==0)
              {
              UART1_Write(10);
              UART1_Write_Text("MİSAFİR");
              UART1_Write(10);
              TRISD=0x00;
              LATD=0x0F;
              delay_ms(2000);
              LATD=0x00;
              
 
 
              
              }
            else
              {
              UART1_Write(10);
              UART1_Write_Text("PERSONEL");
              UART1_Write(10);
              TRISA=0x00;
              LATA=0x0F;
              delay_ms(2000);
              LATA=0x00;


----------------------------------------------------------------------------------------------------------------
I working this code;

/*
* Project name
RFiD (Displaying CRC check of RFid card via Usart)
* Copyright
(c) mikroElektronika, 2010.
* Revision History
20091220:
- initial release;
20101021:
- added active comments, sbit approach, code reorganized...
* Description
The code demonstrates using two external interrupts to read data sent
by EM4095 chip (clock - RDY/CLK; data - OUT).
Upon correct identification of the card, results are displayed via USART
along with the card specific number.
* Test configuration:
MCU: PIC18F4520
https://ww1.microchip.com/downloads/en/DeviceDoc/39631E.pdf
Dev.Board: EasyPIC6
https://www.mikroe.com/eng/products/view/297/easypic6-development-system/
Oscillator: HS-PLL, 32.0000 MHz
Ext. Modules: mE RFid Reader Board
ac:RFid_reader
https://www.mikroe.com/eng/products/view/185/rfid-reader-board/
SW: mikroC PRO for PIC
https://www.mikroe.com/eng/products/view/7/mikroc-pro-for-pic/
* NOTES:
- mE RFid Reader Board should be connected to PORTB
- Make sure you turn on the apropriate switches to enable USART communication (board specific)
- Upon correct CRC check program will send "CRC CHECK OK!" via USART
- Usage of P18 family of MCUs and clock setting >= 32 MHz is recommended when working with RFid Reader Board
*/


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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
sbit OUT at RB0_bit;
sbit RDY_CLK at RB1_bit;
sbit SHD at RB2_bit;
sbit MOD at RB3_bit;
 
sbit OUT_Direction at TRISB0_bit;
sbit RDY_CLK_Direction at TRISB1_bit;
sbit SHD_Direction at TRISB2_bit;
sbit MOD_Direction at TRISB3_bit;
 
unsigned short sync_flag,     // in the sync routine if this flag is set
               one_seq,       // counts the number of 'logic one' in series
               data_in,       // gets data bit depending on data_in_1st and data_in_2nd
               cnt,           // interrupt counter
               cnt1, cnt2;    // auxiliary counters
unsigned short data_index;    // marks position in data arrey
char i;
char _data[256];
char data_valid[64];
char bad_synch;               // variable for detecting bad synchronization
 
void Interrupt() {
 
  // This is external INT1 interrupt (for sync and sample)
  //     it is enabled until we get 128 data bits
  if (INT1IF_bit && INT1IE_bit) {
      cnt++;                  // count interrupts on INT1 pin (RB1)
      INT1IF_bit = 0;
     }
 
  // This is external INT0 interrupt (for sync start)
  //   - once we get falling edge on RB0 we are disabling INT0 interrupt
  else if (INT0IF_bit && INT0IE_bit) {
     cnt = 0;
     sync_flag = 1;
     INT0IF_bit = 0;
     INT0IE_bit = 0;
     INT1IF_bit = 0;
     INT1IE_bit = 1;
   }
}
 
 
char CRC_Check(char *bit_array) {
 
char row_count, row_bit, column_count;
char row_sum, column_sum;
char row_check[5];
char column_check[11];
 
   // row parity check:
   row_count = 9;                      // count rows
   while (row_count < 59) {
     column_count = 0;                 // count columns
     while (column_count < 5) {
       row_check[column_count] = bit_array[row_count+column_count];
       column_count++;
     }
     row_bit = 0;                      // count row bits
     row_sum = 0;
     while (row_bit < 4) {
       row_sum = row_sum + row_check[row_bit];
       row_bit++;
     }
 
     if (row_sum.B0 != row_check[4].B0) {
       return 0;
     }
     row_count = row_count + 5;
   }
   // end row parity check
 
   // column parity check
   column_count = 9;            // count columns
   while (column_count < 13) {
     row_bit = 0;               // count column bits
     row_count = 0;             // count rows
     while (row_bit < 11) {
       column_check[row_bit] = bit_array[column_count+row_count];
       row_bit++;
       row_count = row_count + 5;
     }
 
     row_bit = 0;               // count column bits
     column_sum = 0;
     while (row_bit < 10) {
       column_sum = column_sum + column_check[row_bit];
       row_bit++;
     }
 
     if (column_sum.B0 != column_check[10].B0) {
       return 0;
     }
     column_count++;
   }
   // end column parity check
   if (bit_array[63] == 1) {
     return 0;
   }
   return  1;
}
 
// main program
void main() {
  ADCON1 = 0x0F;                // AD converter off
  CMCON = 7;
 
  OUT_Direction = 1;
  RDY_CLK_Direction = 1;
  SHD_Direction = 0;
  MOD_Direction = 0;
 
  SHD = 0;
  MOD = 0;
 
  UART1_Init(19200);            // Initialise USART communication
  Delay_ms(100);
 
  sync_flag = 0;                // sync_flag is set when falling edge on RB0 is detected
  one_seq = 0;                  // counts the number of 'logic one' in series
  data_in = 0;                  // gets data bit
  data_index = 0;               // marks position in data arrey
  cnt = 0;                      // interrupt counter
  cnt1 = 0;                     // auxiliary counter
  cnt2 = 0;                     // auxiliary counter
 
  // setup interrupts
  INTEDG0_bit = 0;              // Interrupt on falling edge on RB0
  INTEDG1_bit = 1;              // Interrupt on rising edge on RB1
  INT0IF_bit = 0;               // Clear INT0IF
  INT1IF_bit = 0;               // Clear INT1IF
 
  INT0IE_bit = 0;               // turn OFF interrupt on INT0
  INT1IE_bit = 0;               // turn OFF interrupt on INT1
  GIE_bit = 1;                  // enable GIE
 
 
  while (1) {
    bad_synch = 0;              // set bad synchronization variable to zero
    cnt = 0;                    // reseting interrupt counter
    sync_flag = 0;              // reseting sync flag
    INT1IF_bit = 0;
    INT1IE_bit = 0;             // disable external interrupt on RB1 (for sync and sample)
    INT0IF_bit = 0;
    INT0IE_bit = 1;             // enable external interrupt on RB0 (start sync procedure)
 
    while (sync_flag == 0) {    // waiting for falling edge on RB0
     asm nop
    }
 
    while (cnt != 16) {         // waiting 16 clocks on RB1 (positioning for sampling)
     asm nop
    }
 
    cnt = 0;
    _data[0] = OUT & 1;
 
    for (data_index = 1; data_index != 0; data_index++) {   // getting 128 bits of data from RB0
      while (cnt != 32) {                                   // getting bit from RB0 every 32 clocks on RB1
        asm nop
      }
      cnt = 0;                                              // reseting interrupt counter
      _data[data_index] = OUT & 1;                          // geting bit
      if(data_index & 1)
      if (!(_data[data_index] ^ _data[data_index-1]))
         {
            bad_synch = 1;
            break;                                          //bad synchronisation
         }
    }
 
    INT1IE_bit = 0;                         // disable external interrupt on RB1 (for sync and sample)
    if (bad_synch)
     continue;                              // try again
    cnt1 = 0;
    one_seq = 0;
    for(cnt1 = 0; cnt1 <= 127; cnt1++) {    // we are counting 'logic one' in the data array
      if (_data[cnt1 << 1] == 1) {
        one_seq++;
        }
      else {
        one_seq = 0;
        }
 
      if (one_seq == 9) {                  // if we get 9 'logic one' we break from the loop
          break;
    }
    }                                      //   (the position of the last  'logic one' is in the cnt1)
    if ((one_seq == 9) && (cnt1 < 73)) {   // if we got 9 'logic one' before cnt1 position 73
                                           //   we write that data into data_valid array
       data_valid[0] = 1;                  //   (it has to be before cnt1 position 73 in order
       data_valid[1] = 1;                  //    to have all 64 bits available in data array)
       data_valid[2] = 1;
       data_valid[3] = 1;
       data_valid[4] = 1;
       data_valid[5] = 1;
       data_valid[6] = 1;
       data_valid[7] = 1;
       data_valid[8] = 1;
       for(cnt2 = 9; cnt2 <= 63; cnt2++) {      // copying the rest of data from the data array into data_valid array
          cnt1++;
          data_valid[cnt2] = _data[cnt1 << 1];
        }
       if (CRC_Check(data_valid) == 1) {        // if data in data_valid array pass the CRC check
 
            UART1_Write_Text("CRC CHECK OK!");         // Writing of the CRC Check confirmation through USART communication
            UART1_Write(13);                           // Cariage return (view ASCII chart)
            UART1_Write(10);                           // Line Feed (view ASCII chart)
 
 
 
            for (i = 0; i <= 64; i++){                 // This part of the code
                                                       //  dislays the number of the specific RfID CARD
                if (data_valid[i] == 0) {
                  Uart1_Write('0');
                  }
                else {
                  Uart1_Write('1');                    // at the end of this for loop you will get a string of "0" and "1"
                  }
            }                                          // specific to a single RfID CARD
            UART1_Write(13);                           // Cariage return (view ASCII chart)
            UART1_Write(10);                           // Line Feed (view ASCII chart)
            Delay_ms(500);
            
            
            if(data_valid[60]==0)
              {
              UART1_Write(10);
              UART1_Write_Text("MİSAFİR");
              UART1_Write(10);
              TRISD=0x00;
              LATD=0x0F;
              delay_ms(2000);
              LATD=0x00;
              
 
 
              
              }
            else
              {
              UART1_Write(10);
              UART1_Write_Text("PERSONEL");
              UART1_Write(10);
              TRISA=0x00;
              LATA=0x0F;
              delay_ms(2000);
              LATA=0x00;
 
              }
 
 
 
 
 
        }
     }
     
 
 
   }
}


-----------------------------------------------------------------------------------------------------------------
 
Last edited by a moderator:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top