RFID Application Guide

From Flowcode Help
Revision as of 14:32, 29 August 2014 by LeighM (talk | contribs)
Jump to navigationJump to search

Introduction

These examples demonstrate the use of the Flowcode RFID component.

In particular they make use of the EB052 E-blocks RFID board, connected to an EB006 E-blocks PICmicro multiprogrammer fitted with a 16F1937 microprocessor.

However, the examples are easily changed in Flowcode to support other microprocessors and platforms.

The standard RFID E-Block comes with support for the 13.56MHz Mifare and I-Code devices.

The Matrix TSL EB539SI6 Easy RFID bundle has all the items required for these sample applications and is an ideal introduction to RFID.


Setting up the project hardware

Connect the E-Blocks as indicated in the table below.

The RFID, LCD and Switch E-Blocks all need to be powered via wire connections to the +V on the EB006.

Hardware Setup
EB006 PICmicro multiprogrammer
EB005 E-blocks LCD board Port A
EB004 E-blocks LED board Port B
EB052 E-blocks RFID board Port C
EB007 E-blocks push-to-make switch board Port D


Example 1: Reading the status of the RFID Card

FC6 Icon.png RFID Card Status Example

This example simply initialises the RFID module and then reads the status of the card when placed in the detection area of the RFID board.

This Flowcode example also uses the LCD display to inform the user of progress.

The card status is displayed on the LED board, described in the following tables:


Mifare RFID Device Status Flags
LED
0 EEPROM error (Internal EEPROM write error)
1 Card OK (Card serial number matched to identity code list)
2 Rx OK (Card communication and acknowledgement OK)
3 RS232 error (Host serial communication error)
4 MF type (0 = MF 1k card, 1 = MF 4k card)
5 UL type (0 = MF standard 1k/4k card SINGLE UID, 1 = MF Ultralight card DOUBLE UID)
6 MFRC error (Internal or antenna fault)
7 1


ICODE RFID Device Status Flags
LED
0 EEPROM error (Internal EEPROM write error)
1 Card OK (Card serial number matched to identity code list)
2 Rx OK (Card communication and acknowledgement OK)
3 RS232 error (Host serial communication error)
4 0
5 0
6 MFRC error (Internal or antenna fault)
7 1


To switch between the Mifare and ICODE types of RFID card you can simply change the Card Type property in the RFID component properties window and then recompile to the device.


Example 2: Reading and writing data on the RFID Card

FC6 Icon.png RFID Card Data Transfer Example

Example 2 is more advanced and demonstrates reading and writing data from the internal memory of an ICODE type card.

The program scans for a ICODE RFID device and if such a device is detected then the LCD will print out the contents of 5 of the internal memory bytes.

The switches are then read and if any of the switches are pressed then the binary value from the switch port is copied into memory byte 0 of the card.


Example 3: Auto increment or decrement of data on the RFID Card

FC6 Icon.png RFID Card Data Auto Update Example

Example 3 repeats the functionality demonstrated in example 2 but this time using a Mifare type of RFID device.

The Mifare devices feature an auto increment or auto decrement value which means it is possible to use these types of cards to obtain a fixed number of services. E.g. 5 trips on the bus before you have to buy a new ticket.

We first read back the status of the user identifier data using the GetRFIDUID component macro.

Once we have the status we send the value out to the LEDs. If the status value is 134 then this indicates that an Mifare device is present in range of the RFID reader.

We then read the memory contained in block 5 on the RFID Mifare device by calling the ReadRFIDBlock function. If the device is still present and we successfully read the memory then the returned status byte will still be equal to 134.

Once we have read one of the memory blocks we can use the ReadRFIDBuffer command to read back data. This time each memory block has 8 bytes and so can be used to store eight 8-bit values, four 16-bit values, two 32-bit values or a single 64-bit value. The while loop simply allows the index memory pointer to be incremented from 0 through to 7 so as to collect all eight bytes from the memory and output the values to the LCD.

As with Example 2, if a switch is pressed then we will store the binary value of the switch press into the first byte of the buffer.

The FormatRFIDValue macro is used to configure a memory byte for use with the increment, decrement or transfer commands.

The data manipulation is performed by simply calling the IncementRFIDValue or the DecrementRFIDValue macros.