From iLab Cookbook

Toolkits: SimpleExampleUsingTheRFIDReader

<< Back to the SharedPhidgets page


What you will learn in this tutorial:


Download source: SharedPhidgetsExample_RFID.zip
The zip file contains the program code of this example.

Overview

The Phidget RFID Reader
The Phidget RFID Reader
  1. Create a new Windows C# application in VisualStudio.NET
  2. Use the ConnectionManager for connecting to the server
  3. Create a RFID object
  4. Create a RFID skin and connect it to the RFID reader object
  5. Create a textbox on your form and display retrieved RFID tags
  6. Finished! Compile the application and enjoy to work with RFID tags!
  7. Some features of the RFID reader skin


Step-by-step in detail

1) Open VisualStudio.NET, click New Project, select a new C# Windows application, enter the name of the project (SharedPhidgetsExample_RFID) and confirm the dialog.

2) Now we click on the SharedPhidgets toolbox on the left side of the VisualStudio window, select the ConnectionManager object and click on your Windows form.

Then change the SharedDictionaryURL property of the Connection Manager to the address of the server:

3) Drag a SharedPhidget RFID component on your form

...and click on the FilterSerialNumber property in the Properties explorer of Visual Studio...

...and specify the serial number of the RFID reader. If you have only one RFID reader at your infrastructure (means: only one RFID reader connected to one of the SharedPhidgets Connectors that are connected with the server), you don't need to add the serial number because the component will then connect to the only component of its type it founds.

4) Create a skin object for the RFID reader (RFIDSkin object): Just click on the entry in the toolbox and click-and-hold to create the control on your Windows form.

Change the RFID property of the RFIDSkin to the object of the created RFID reader, here this is rfid1:

5) Create a new TextBox object on your form, and select the Multiline property to true and the ScrollBars property to Vertical. Furthermore, set the value of the Text property to an empty string.

Create a new eventhandler for the Tag event of the RFID object (rfid1):
just select the event in the list of events and press Enter (or Doubleclick there), and a new callback method will be created:

Just insert the following code line in this callback method: it will add the received Tag (e.Tag) to the textbox and adds a new line.

private void rfid1_Tag(object sender, GroupLab.SharedPhidgets.RFIDTagEventArgs e)
{
  this.textBox1.Text = e.Tag + System.Environment.NewLine + this.textBox1.Text;
}

6) Compile your application:

The following window will appear, where you can see the Skin for the RFID reader and the textbox with the received tags. Just place different tags near the reader, and you will see the ID of the tag in the RFID Reader skin and the textbox:

7) The RFID skin has three additional sections than the RFID skin of the Phidgets.NET toolkit:

a) You can see a history of received tags and also clear this history.
b) You can control the four binary outputs of the RFID reader: the 5V output, an internal LED on the RFID reader itself, an external LED, and finally the active state of the RFID itself (You ALWAYS have to activate this flag to use the RFID reader to detect tags).
c) Delay: you can specify a time interval in that similar tags will not be fired as a new event by the RFID component. This means, that when you hold an RFID tag near the reader, it will not fire 20-30 events per second, but only one (if you have set the delay to 1 second).


That's it,

you can now modify this application and enhance the functionality. You can simply use RFID tags to identify objects, and create software that can react dynamically to these detected objects/tags.


Retrieved from http://grouplab.cpsc.ucalgary.ca/cookbook/index.php/Toolkits/SimpleExampleUsingTheRFIDReader
Page last modified on January 28, 2006, at 05:09 PM