150 likes | 300 Views
Getting Started with RFIDPhidgets. Human Computer Interaction. Equipment. Visit phidgets.com Look up specifications for each sensor Online documentation: http://www.phidgets.com/documentation/web/javadoc/index.html Order additional phidgets http://www.phidgets.com
E N D
Getting Started with RFIDPhidgets Human Computer Interaction
Equipment • Visit phidgets.com • Look up specifications for each sensor • Online documentation: http://www.phidgets.com/documentation/web/javadoc/index.html • Order additional phidgets • http://www.phidgets.com • http://www.trossenrobotics.com • Company ships from USA, competitive pricing
Installation Procedure (1 of 5) • Computer must have • Java Installed • JGrasp or TextPad
Installation Procedure (2 of 5) • Go to location for Phidget Windows Downloads • www.phidgets.com • Downloads • Windows
Installation Procedure (3 of 5) • Download Phidget Framework (Phidget 21.MSI) • Install Phidget Framework • Microsoft.NET should be installed on your computer, • After installing Microsoft .net., install Phidget 2.1 MSI. This will create the folder Program Files/Phidget on your computer. • You will see a PH icon on status bar to indicate success
Installation Procedure (4 of 5) • Create a Phidget Files Folder on your C Drive • Download “Java Files” and save in your Phidget Files Folder • Examples: Java (Zip file) • Additional Files: phidget21.jar • Java API Manual: javadoc.zip New RFID files posted in June
Installation Procedure (5 of 5) • Unzip Files • Use UnZip to extract files from .zip • The phiget21.jar is a compressed java file. You can use JGrasp to extract all files (Tools/Jar). Ultimate Zip is another program to extract the java files. • 2 folders will be created. (com and meta-inf) • All source files you create must be in the Phidget Files folder. They will import data from the com folder
RFID Phidget Product Features: • Cost: $65.00 (Canadian money) from www.phidget.com • Reads tags brought within 3 inches of the reader • Reads any tag with EM4102 protocol • Returns the unique number contained in the tag • Provides 2 Digital Outputs to drive LEDs, relays, etc. • RFID Tags Price : $3.00 each • Connects to USB port
Testing the RFIDPhidget • Double Click on the icon to activate the Phidget Control Panel and make sure that PhidgetRFID is properly attached to your PC. • If you do not see the device listed • Go to WebService Tab • Set [Start up Type] Automatic and Press [Start] • You may have to detach the RFID Phidgetfrom USB port and reattach after WebService status is Running General Tab WebService Tab
Testing the RFIDPhidget • When you double click on the device name, GUI appears that allows you to interact with the device • Remember to close this interface before executing your program. • The interface kit may be “connected” to one program at a time. Wave a tag in front of the reader to see the Tag Data
Using Phidget Classes • Source code must be saved in folder that contains the com folder. • Your program is looking for this structure. • Refer to Phidget Instructions on vista • Import required classes • import com.phidgets.*; • import com.phidgets.event.*;
Several RFIDPhidget Classes & Methods RFIDPhidget • void addTagGainListener (TagGainListenerlistener) Adds a tag gained listener. • void addTagLossListener (TagLossListenerlistener) Adds a tag lost listener. TagGainListener • void tagGained (TagGainEventae) This method is called with the event data when a new event arrives. TagLossListener • void tagLost (TagLossEventae) This method is called with the event data when a new event arrives. TagGainEvent • StringgetValue () Returns the gained tag. Similar to JTextField Similar to ActionListener Similar to ActionEvent
Open RFIDPhidget //Declare instance variable privateRFIDPhidgetrfid; //Code Segment that opens an RFIDPhidget try { rfid= new RFIDPhidget (); //Add a listener to fire when tag is read rfid.addTagGainListener (new MyTagGainListener()); //Open an interface kit without a serial number. If you had more than two // kit connected use open(intserialNumber) and pass the serial number rfid.openAny(); //Wait for the device to be attached System.out.println("waiting for InterfaceKit attachment..."); rfid.waitForAttachment(); System.out.println(ik.getDeviceName()); }//end try catch (PhidgetException e) { System.out.println("Phidget Exception Generated"); e.printStackTrace(); } Create your own Listener class An exception may be thrown. You must have code in try/catch block
Create a Listener Class for the Interface class MyTagGainListener implements TagGainListener { { public void tagGained(TagGainEventae) // Get value of the tag. String tagID= ae.getValue(); System.out.println("Tag id: " + tagID); } }
Protect your RFID reader and RFID tags • Do not attach the RFID tags directly to your objects • Insert each tag in an envelope or wrap it in plastic before taping to objects • Be careful when placing reader and tags in book back • Avoid long exposure to sun, water etc.