Date post: | 07-Aug-2018 |
Category: |
Documents |
Upload: | manoj-kavedia |
View: | 217 times |
Download: | 0 times |
of 15
8/20/2019 A Quick Introduction to RFID
1/36
A Quick Introduction to RFID
In its bare minimum, a RFID system consists of two main components:
• Reader/Writer
• Tags
An RFID reader/writer contains a scanning antenna and a transceiver It
uses t!e scanning antenna to send out radio fre"uency signa#s in a
re#ati$e s!ort range T!e radio fre"uency sent out is used to
communicate and power tags %a#so known as transponders& t!at are
wit!in range, w!ic! wi## t!en transmit t!e data on t!e tag back to t!e
reader T!e information sent out by t!e tag is t!en picked up by t!e
scanning antenna T!e data is t!en interpreted and decoded by t!etranscei$er
T!ere are two types of RFID tags'active and passive Acti$e RFID tags
!a$e t!eir own power source and !ence t!ey can transmit signa#s t!at
tra$e# fart!er In contrast, passi$e RFID tags !a$e no power source and
t!ey !a$e to re#y so#e#y on t!e signa# sent from t!e scanning antenna
to power t!em (ence t!e range supported by passi$e tags is #imited
Acti$e tags are bigger in si)e t!an passi$e tags and !a$e a #imited #ife
span %unti# t!e power source runs out& *assi$e tags, on t!e ot!er !and,
are muc! sma##er in si)e and !a$e $irtua##y un#imited #ife span
T!ere are two types of RFID tags: acti$e andpassi$e
RFID systems are categori)ed by t!eir transmitting fre"uencies and are
broad#y grouped into t!ree bands: +ow Fre"uency %+F&, (ig! Fre"uency
%(F&, and #tra (ig! Fre"uency %F(& Table 1 s!ows t!e di-erent
fre"uencies used by t!e t!ree bands and t!eir c!aracteristics.ac! RFID tag !as a uni"ue tag ID Tags carry no more t!an 01 of
data and can store information suc! as !istory, #ocation, etc
2ost common RFID app#ications use t!e tag ID transmitted by RFID
tags as a key to information stored in databases For e3amp#e, an RFID
tag attac!ed to an emp#oyee passcard on#y contains an RFID tag ID,
8/20/2019 A Quick Introduction to RFID
2/36
w!ic! an app#ication can use to retrie$e more detai#ed emp#oyee
information stored in t!e organi)ation databases W!i#e read-only RFID
app#ications are c!eaper, t!ere are occasions w!ere you mig!t need to
write data back to an RFID tag, in w!ic! case you4## use read'write
tags 5ou mig!t 6nd read'write RFID systems in a subway, for e3amp#e,
w!ere you may need to write back information to a tag in stored $a#ue
cards 7ote t!at some tags can on#y be written once
1ui#ding Attendance TrackingApp#ication
7ow t!at you !a$e a good understanding of !ow RFID works, I4## s!ow
you !ow to bui#d a simp#e attendance app#ication t!at registers an
emp#oyee w!en !e reports for workFigure 1 s!ows t!e user interface
of t!e app#ication
Figure 1: T!e
attendance system you wi## bui#d in t!is artic#e
W!en an emp#oyee scans !is emp#oyee passcard t!at !as an
embedded RFID tag, t!e app#ication t!at recei$es t!e ID from t!e RFID
tag wi## disp#ay t!e emp#oyee information T!e app#ication4s
administrator can assign an unused tag to an emp#oyee by using t!e
buttons on t!e rig!t of t!e app#ication For security reasons, t!e
app#ication wi## c#ear t!e emp#oyee information after t!ree seconds To
8/20/2019 A Quick Introduction to RFID
3/36
dep#oy t!is app#ication in a rea#'#ife setting, you wou#d !ide t!e
administrati$e functions so t!at t!e user on#y sees t!e necessary
information %see Figure 2&
Figure 2: (iding t!e administrati$e
functions in a dep#oyed en$ironment
RFID Reader 89: *ara##a34s RFID Reader 2odu#e
In t!is e3amp#e, I4## s!ow you !ow to use *ara##a34s RFID Reader 2odu#e
%!ttp://wwwpara##a3com/detai#aspproduct;id?& T!is #ow'cost
RFID reader %@B& reads passi$e RFID transponder tags and uses seria#
communication to transmit t!e tag IDs As you can see in Figure 3,
t!e reader !as four pins at t!e bottom %from #eft to rig!t&:
http://www.parallax.com/detail.asp?product_id=28140http://www.parallax.com/detail.asp?product_id=28140
8/20/2019 A Quick Introduction to RFID
4/36
Figure 3: T!e *ara##a34s RFID Reader
2odu#e
• C ' EC D power
• /.7A1+. ' .nab#e %Ground& or disab#e %EC D& pin
• HT ' Heria# output
• G7D ' Ground
T!e e-ecti$e read range of *ara##a34s RFID Reader modu#e is 9JK to K
inc!es %depending on t!e tag used& W!en t!e Reader 2odu#e ac"uires
a tag ID, data is sent t!roug! t!e seria# port using a 9'byte AHII
string T!e +F %+ine Feed& ser$es as t!e Htart byte and t!e R %arriageReturn& ser$es as t!e Htop byte T!e ten digits in between ser$e as t!e
uni"ue tag ID
RFID Tags
T!e *ara##a34s RFID Reader 2odu#e reads t!e fo##owing tags:
• > mm 3 = mm Rectang#e Tag
%!ttp://wwwpara##a3com/detai#aspproduct;id9L @ eac!&• ? mm Round Tag %!ttp://wwwpara##a3com/detai#asp
product;idL @ eac!&
Hetting p t!e Reader
http://www.parallax.com/detail.asp?product_id=28141http://www.parallax.com/detail.asp?product_id=28142http://www.parallax.com/detail.asp?product_id=28142http://www.parallax.com/detail.asp?product_id=28141http://www.parallax.com/detail.asp?product_id=28142http://www.parallax.com/detail.asp?product_id=28142
8/20/2019 A Quick Introduction to RFID
5/36
In order to connect t!e reader to your computer, you need to perform a
TT+'to'RH' #e$e# s!ifting so t!at t!e data can be read $ia a seria#
port ne way wou#d be to connect t!e reader to t!e RS-232 DCE
AppMod %!ttp://wwwpara##a3com/detai#aspproduct;id
8/20/2019 A Quick Introduction to RFID
6/36
Tip: 1e sure to use a Ostraig!tK seria# cab#e to connect t!e board to
your computer, or e#se you wi## not be ab#e to get any data from t!e
reader
If you do not !a$e a seria# port on your computer, you can use a H1'
to'seria# con$erter to con$ert a H1 connector into a seria# port 5ou
wi## a#so need a D1B straig!t seria# cab#e
Figure 5 s!ows t!e assemb#ed reader and board
8/20/2019 A Quick Introduction to RFID
7/36
Figure 5: T!e *ara##a3 RFID Reader and t!e Na$e#ine Demo 1oard
connected and ready to go
1ui#ding t!e App#ication ser Interface
8/20/2019 A Quick Introduction to RFID
8/36
sing Cisua# Htudio ??, create a new Windows app#ication and name
it :PAttendance 5ou wi## use t!e 7ort!wind samp#e database pro$ided
by HQ+ Her$er ??? wit! HQ+ .3press %Hee t!e sidebar, Installing the
Sample Database& To simp#ify data'binding, you wi## use t!e drag'and'
drop data'binding feature t!at is new in Cisua# Htudio ??
In addition, you wi## a#so add a new TagID 6e#d to t!e .mp#oyees tab#e
in t!e 7ort!wind database To do so:
• Go to Her$er .3p#orer %from t!e View menu c!oose Server
Eplorer&
• Rig!t'c#ick on Data onnections and se#ect Add onnection
• He#ect t!e 2icrosoft HQ+ Her$er %H"##ient& data source and in t!e
ser$er name 6e#d, enter OPHQ+.*R.HHK %assuming you !a$e HQ+.3press insta##ed on your #oca# computer& He#ect 7ort!wind as t!e
database name and c#ick 0
• In Her$er .3p#orer, e3pand t!e 7ort!wind database and t!en
t!e Table! item Doub#e'c#ick E"plo#ee! and add t!e TagID 6e#d
%Figure $&
8/20/2019 A Quick Introduction to RFID
9/36
Figure $: Adding a new TagID 6e#d to t!e .mp#oyees tab#e
%o&e: .nsure t!at t!e data source se#ected is O2icrosoft HQ+ Her$er
%H"##ient&K If it is not, c#ick !ange and se#ect 2icrosoft HQ+ Her$er
First, add a new data source to your proMect by se#ecting Add 7ew Data
Hource from t!e Data menu In t!e Data Hource on6guration Wi)ard
dia#og bo3, se#ect Database and c#ick 7e3t #ick t!e 7ew onnection
button to specify t!e database to use 5ou wi## see t!e Add onnection
dia#og bo3 %Figure '& As before, enter OPHQ+.*R.HHK as t!e ser$er
name and se#ect 7ort!wind as t!e database #ick 0
8/20/2019 A Quick Introduction to RFID
10/36
Figure ': Adding a new
connection to t!e 7ort!wind database
1ack in t!e Data Hource on6guration Wi)ard, c#ick 7e3t In t!e ne3t
screen, se#ect t!e tab#e and 6e#ds to use .3pand t!e Tab#es and
.mp#oyees item and t!en c!eck t!e fo##owing 6e#ds %Figure (&:
8/20/2019 A Quick Introduction to RFID
11/36
Figure (: !oosing t!e 6e#ds to use in t!e .mp#oyees tab#e
• .mp#oyeeID
• +ast7ame
• First7ame
• Tit#e
• *!oto
• TagID
From t!e Data menu, c!oose H!ow Data Hources to $iew t!e new#y
added data sourceFigure ) s!ows t!e .mp#oyees data source 1y
defau#t, t!e .mp#oyees tab#e is bound to a DataGridCiew contro# and a##
its 6e#ds %e3cept t!e *!oto 6e#d& are bound to Te3t1o3 contro#s 5ou
s!ou#d c!ange t!e bindings to t!ose as s!own in Table 2
8/20/2019 A Quick Introduction to RFID
12/36
Figure ): T!e
.mp#oyees data source
T!e .mp#oyees data source s!ou#d now #ook #ike t!e rig!t side
of Figure )
Drag t!e .mp#oyees data source onto t!e defau#t Form9 Figure1* s!ows t!e contro#s t!at automatica##y popu#ate t!e form For t!e
*icture1o3 contro#, set its Hi)e property to OB,99?K and Hi)e2ode to
OHtretc!ImageK
Figure 1*:
T!e data'bound contro#s
%o&e: 2o$e t!e TagID #abe# and its accompanying +abe# contro# %on t!e
rig!t& to t!e top
8/20/2019 A Quick Introduction to RFID
13/36
To test t!at t!e data'binding works, you can now press F to debug t!e
app#icationFigure 11 s!ows t!e app#ication disp#aying t!e records in
t!e .mp#oyees tab#e
Figure 11:
Testing to ensure t!at t!e data'binding works
7e3t you4## add contro#s to t!e form to a##ow an administrator to assign
a RFID tag to a user Figure 12 s!ows t!e contro#s to add
8/20/2019 A Quick Introduction to RFID
14/36
Figure 12: *opu#ating t!e form wit! t!e $arious contro#s
For t!e t3tTagID contro#, set bot! t!e Readn#y and t!e 2u#ti#ine
properties to True
In addition, drag a Timer contro# from t!e Too#bo3 onto t!e form T!is
contro# wi## ensure t!at t!e disp#ayed emp#oyee record wi## be c#eared
after t!ree seconds
oding t!e App#ication
Wit! t!e I of t!e app#ication out of t!e way, you can now focus on
writing t!e code to wire up a## t!e contro#s Hwitc! to t!e code'be!ind
of Form9 and import t!e fo##owing namespaces
Imports HystemData
8/20/2019 A Quick Introduction to RFID
15/36
Imports HystemDataH"##ient
Imports HystemI
Dec#are t!e member $ariab#es and constants seen in +i!&i,g 1
W!en t!e form #oads, you 6rst c#ear t!e disp#ayed emp#oyee by setting
its 6#ter to a non'e3istent tag ID T!e Timer contro# c#ears t!e disp#ayed
emp#oyee after a certain amount of time, and in t!is case you wi## set it
to t!ree seconds %as de6ned by t!e Inter$a# constant& T!at is to say,
w!en an emp#oyee is identi6ed using !is RFID tag, !is information wi##
be c#eared from t!e screen after t!ree seconds
As t!e *ara##a34s RFID Reader 2odu#e uses a seria# connection, you wi##
use t!e Heria#*ort c#ass to communicate wit! t!e reader
%o&e: For t!is e3amp#e, I !a$e assumed t!at you4## connect t!e 2
port to t!e RFID Reader 2odu#e 5ou need to c!ange it to t!e correct
port number for your own use
+i!&i,g 2 s!ows t!e code for t!e Form9;+oad e$ent
To recei$e incoming data from t!e Heria#*ort c#ass, you need to ser$ice
t!e DataRecei$ed e$ent In t!is case, w!en incoming data is recei$ed,
you wi## update t!e t3tTagID contro#+i!&i,g 3 s!ows t!e code for t!e
DataRecei$ed e$ent
5ou need to de6ne a de#egate to ca## a routine to update t!e t3tTagID
contro# (ere, de6ne t!e myDe#egate%& de#egate and t!e
updateTe3t1o3%& subroutine
S''' update t!e Tag ID te3tbo3
*ub#ic De#egate Hub myDe#egate%&
*ub#ic Hub updateTe3t1o3%&
S for recei$ing p#ain AHII te3t
Wit! t3tTagID
AppendTe3t% ;
seria#*ortRead.3isting&
Hcro##Toaret%&
.nd Wit!
.nd Hub
8/20/2019 A Quick Introduction to RFID
16/36
ne important point you need to understand about RFID readers %at
#east for t!e two RFID readers s!own in t!is artic#e& is t!at w!en a tag
is scanned, it wi## continuous#y send t!e tag ID to t!e seria# connection
For e3amp#e, suppose a tag wit! ID of ?F?BAF is p#aced near t!e
reader In t!is case, t!e reader wi## continuous#y send t!e $a#ue of
?F?BAF to t!e seria# connection For t!e *ara##a34s reader, eac!
$a#ue starts wit! t!e #ine feed c!aracter %c!aracter 9? ' U9?V& and
ends wit! a carriage return c!aracter %c!aracter 9 ' U9V& To make
matters comp#icated, using t!e Read.3isting%& met!od of t!e Heria#*ort
c#ass does not guarantee t!at you wi## read t!e comp#ete tag ID in its
entirety T!is is because a $a#ue may be sent in four b#ocks, #ike t!is:
U9?V?F?B
AF
U9V
5ou may be tempted to use t!e Read+ine%& met!od of t!e Heria#*ort
c#ass to read incoming data, but t!at wi## not work as t!e Read+ine%&
met!od wi## #ook for U9VU9?V at t!e end of t!e #ine 1ut since t!e
incoming data does not end wit! U9?V, t!is wi## cause t!e app#ication
to go into an in6nite #oop
In addition, if you don4t c#ear t!e incoming data bu-er fast enoug!, you
may get a series of data "ueued up #ike t!is:
U9?V
?F
?B
AF
U9VU9?V
?>
9=D
=1
U9V
8/20/2019 A Quick Introduction to RFID
17/36
Instead of writing e#aborate #ogic to process t!e incoming data, an easy
way is to append a## incoming data to a Te3t1o3 contro# %wit! t!e
2u#ti#ine property set to True& sing t!e data Must described, Figure
13 s!ows w!at t!e Te3t1o3 contro# wi## #ook #ike
Figure 13: Appending incoming
data to a Te3t1o3 contro#
T!e second to t!e #ast #ine wi## !ence a#ways contain t!e Tag ID t!at
you are interested in if t!e #ast #ine is an empty string In contrast, if
t!e tag ID is on#y partia##y recei$ed, t!e state of t!e Te3t1o3 contro#wou#d be as s!own in Figure 14
Figure 14: T!e state of t!e
Te3t1o3 contro# containing t!e #ast incomp#ete tag ID
As a## incoming data is updated in t!e Te3t1o3 contro#, you can c!eck if
t!e tag ID be#ongs to an emp#oyee w!ene$er t!ere are c!anges in t!e
content of t!e Te3t1o3 contro# 5ou4## use t!e Te3t!anged e$ent%+i!&i,g 4& to detect t!e c!ange
T!e Te3t!anged e$ent 6rst e3amines if t!e #ast #ine in t!e t3tTagID
contro# is an empty stringL if it is, t!en t!e scanned tag ID can be found
in t!e second to #ast #ine sing t!is tag ID, t!e code c!ecks t!e time
di-erence between t!e current time and t!e #ast time t!e tag ID was
read If it is #ess t!an t!ree seconds and t!e tag ID is t!e same as t!e
#ast read tag ID, it means t!at it is t!e same user and t!e current tag
ID s!ou#d be ignored sing t!is imp#ementation, t!e same user wou#d
be ignored for t!e ne3t t!ree seconds from t!e moment !e 6rst
scanned !is tag
Wit! t!e tag ID, you wi## app#y a 6#ter to t!e .mp#oyees1indingHource
contro# to #ook for an emp#oyee wit! a matc!ing tag ID If an emp#oyee
8/20/2019 A Quick Introduction to RFID
18/36
is found, an entry wi## be written to t!e #og 6#e using t!e WriteTo+og%&
subroutine
*ri$ate Hub WriteTo+og% ;
1yCa# emp#oyeeID As Htring, ;
1yCa# emp#oyee7ame As Htring&
S''' write to #og 6#e
Dim str As Htring < emp#oyeeID ;
X,X emp#oyee7ame X,X ;
7ow !r%9&
2yomputerFi#eHystem ;
WriteA##Te3t%FI+.;7A2., str, ;
True&
.nd Hub
Figure 15 s!ows t!e content of a typica# #og 6#e
Figure 15:
T!e content of a typica# #og 6#e
T!e Timer contro# wi## 6re t!e Tick e$ent e$ery t!ree seconds %as
determined by t!e $a#ue set in its Inter$a# property& (ence you need
to ser$ice t!e Tick e$ent so t!at e$ery time it 6res, you can c#ear t!e
current emp#oyee information t!at is disp#ayed (ere is t!eimp#ementation of t!e Tick e$ent
*ri$ate Hub Timer9;Tick% ;
1yCa# sender As HystembMect, ;
1yCa# e As Hystem.$entArgs& ;
8/20/2019 A Quick Introduction to RFID
19/36
(and#es Timer9 Tick
S''' c#ear t!e emp#oyee
.mp#oyees1indingHourceFi#ter < ;
XTAGID
8/20/2019 A Quick Introduction to RFID
20/36
5ou are now ready to test t!e app#ication *ress F to debug t!e
app#ication Take a tag and scan it using t!e RFID reader T!e
app#ication s!ou#d register your tag ID and s!ows t!at no emp#oyee is
found %Figure 1$&
Figure 1$:
Hcanning a tag t!at does not be#ong to any emp#oyee
5ou can associate t!e tag ID wit! an emp#oyee by searc!ing for an
emp#oyee %enter t!e emp#oyee ID in t!e Te3tbo3 and c#ick t!e Find
button or #ea$e it empty and it wi## return a## records& nce you !a$e#ocated t!e emp#oyee you want, c#ick t!e Assign Tag to .mp#oyee
button to assign t!e tag ID to t!e emp#oyee
T!e ne3t time you scan t!e same tag, t!e app#ication wi## s!ow t!e
emp#oyee
RFID Reader 8: *!idgetRFID
T!e second RFID reader I wi## s!ow you !ow to use is t!e *!idgetRFID
reader %!ttp://wwwp!idgetsusacom/cat/$iewproductasp
category
8/20/2019 A Quick Introduction to RFID
21/36
Figure 1': T!e *!idgetRFID
n#ike t!e *ara##a34s RFID Reader 2odu#e, t!e *!idgetRFID uses a H1
connection, w!ic! is actua##y easier for most peop#e since a#most a##
computers today support H1 de$ices And since it draws power from
t!e H1 connection, you don4t need to pro$ide an e3terna# power
source Himp#y connect t!e *!idgetRFID to your computer and start
scanning
RFID Tags
Instead of purc!asing t!e standa#one *!idgetRFID reader, I suggest
you purc!ase t!e *!idgetRFID kit%!ttp://wwwp!idgetsusacom/cat/$iewproductasp
category
8/20/2019 A Quick Introduction to RFID
22/36
1ui#ding t!e Hamp#e App#ication
Rat!er t!an modify t!e app#ication bui#t in t!e pre$ious section to work
wit! t!e *!idgetRFID reader %and !a$e a #ot of repeating code
snippets&, I !a$e opted to bui#d a simp#er app#ication so t!at you can
#earn t!e fundamenta#s wit!out being bogged down wit! t!e detai#s of
t!e app#ication
sing Cisua# Htudio ??, create a new Windows app#ication and
popu#ate t!e defau#t form wit! t!e contro#s as s!own in Figure 1(
Figure 1(: *opu#ating t!e
form wit! t!e contro#s
sing t!is app#ication, you can $iew t!e tag ID t!at is being scanned
and you can a#so programmatica##y turn on/o- t!e +.D on t!e reader
itse#f and enab#e/disab#e t!e reader
Running t!e *!idgetRFID Web Her$ice
*!idget !as made it easy for 7.T programmers to use t!e *!idgetRFID
reader De$e#opers can contro# t!e reader by t!e *!idgetWebHer$ice, a
component t!at interacts wit! your *!idgetRFID reader 5ou must
insta## and run t!e *!idgetWebHer$ice on t!e computer t!at !as t!e
8/20/2019 A Quick Introduction to RFID
23/36
*!idegetRFID connected nce t!e *!idgetWebHer$ice is up and
running, your program can t!en communicate wit! it in order to contro#
t!e *!idgetRFID reader 5ou can obtain t!e *!idget #ibrary %containing
t!e *!idgetWebHer$ice& from!ttp://wwwp!idgetsusacom %go to
Down#oads t!en c!oose Re#ease& and down#oad t!e *(IDG.Tmsi 6#e
%o&e: *!idget4s use of t!e term OWebHer$iceK is a #itt#e mis#eading
!ere *!idgetWebHer$ice is not an 2+ Web ser$ice t!at most
de$e#opers are fami#iar wit! Rat!er, it is a Windows Her$ice t!at runs
in t!e background
nce insta##ed, you can 6nd t!e *!idgetWebHer$ice in t!e :P*rogram
Fi#esP*!idgets directory 5ou can in$oke t!e *!idgetWebHer$ice
2anager %a GI $ersion of t!e WebHer$ice& by running t!e
*!idgetWebHer$ice2angere3e from t!is directory nce it is up andrunning, you4## 6nd it in t!e Hystem Tray %Figure 1)&
Figure 1): T!e *!idgetWebHer$ice 2anager in t!e
Hystem Tray
Doub#e'c#ick on t!e icon to #aunc! t!e *!idgetWebHer$ice 2anager
sing t!e manager, you can c!ange t!e settings of t!e WebHer$ice as
we## as manage your *!idget de$ices %not Must t!e *!idgetRFID reader&
As s!own in Figure 2*, t!e *!idgetWebHer$ice is #istening at port
??9 and re"uires a password OpassK %t!e defau#t& in order to access it
Wit! your *!idegetRFID reader attac!ed to your computer, c#ick Htart
In my case, my reader !as t!e seria# number of ?Y, w!ic! can be
used to uni"ue#y identify it
http://www.phidgetsusa.com/http://www.phidgetsusa.com/
8/20/2019 A Quick Introduction to RFID
24/36
Figure 2*:
T!e *!idgetWebHer$ice 2anager
ne uni"ue feature of t!e *!idgetWebHer$ice is t!at your c#ient
app#ication need not necessari#y be running on t!e same computer as
t!e one wit! t!e reader connected T!e c#ient app#ication uses sockets
communication to ta#k to t!e *!idgetWebHer$ice, so t!is means t!at
you can connect t!e *!idgetRFID reader to one computer and you can
run t!e c#ient app#ication on anot!er computer %as #ong as t!ey can see
eac! ot!er on t!e network& Figure 21 s!ows one possib#e scenario
T!e ad$antage of t!is approac! is t!at your c#ient can be running on
mobi#e p#atform de$ices %suc! as *ocket *& as #ong as it can
communicate wit! t!e !ost computer using sockets communications
8/20/2019 A Quick Introduction to RFID
25/36
Figure 21: T!e c#ient and
t!e reader need not be on t!e same computer
*!idgetRFID A*Is T!e *!idgetRFID reader, w!ic! is insta##ed w!en you insta## t!e
*!idgetWebHer$ice, e3poses its functiona#ity as A*Is #ocated in t!e
*!idget7.Td## #ibrary
To use t!e *!idgetRFID, 6rst import t!e *!idget7.Td## #ibrary into your
app#ication Rig!t'c#ick on t!e proMect name in Ho#ution .3p#orer and
t!en se#ect Add Reference In t!e 1rowse tab, na$igate to :P*rogramFi#esP*!idgetsP and se#ect *!idget7.Td##
oding t!e App#ication
8/20/2019 A Quick Introduction to RFID
26/36
Hwitc! to t!e code'be!ind of Form9 and 6rst dec#are a member
$ariab#e representing t!e *!idgetRFID reader:
*ub#ic #ass Form9
Dim Wit!.$ents RFIDReader As ;
*!idgets7.T*!idgetRFID
W!en t!e form is #oaded, instantiate t!e *!idgetReader $ariab#e and
open a connection to t!e computer running t!e *!idgetWebHer$ice
T!is is accomp#is!ed in t!e Form9;+oad e$ent:
*ri$ate Hub Form9;+oad% ;
1yCa# sender As HystembMect, ;
1yCa# e As Hystem.$entArgs& ;
(and#es 2y1ase+oad
RFIDReader
8/20/2019 A Quick Introduction to RFID
27/36
*ri$ate Hub RFIDReader;Attac!% ;
1yCa# sender As bMect, ;
1yCa# e As ;
*!idgets7.TAttac!.$entArgs& ;
(and#es RFIDReaderAttac!
S''' disp#ay t!e status
Too#HtripHtatus+abe#9Te3t < ;
X*!idget RFID Reader onnectedX
S''' .nab#e onboard +.D
c!kTurnn+.D!ecked
8/20/2019 A Quick Introduction to RFID
28/36
*ri$ate Hub RFIDReader;Tag% ;
1yCa# sender As bMect, ;
1yCa# e As ;
*!idgets7.T Tag.$entArgs& ;
(and#es RFIDReader Tag
S''' w!en incoming data is
S''' recei$ed, update t!e
S''' TagID te3tbo3
t3tTagID1eginIn$oke%7ew ;
myDe#egate% ;
Addressf updateTe3t1o3&, ;
7ew bMect%& ZegetTag[&
.nd Hub
T!e de#egate and t!e subroutine to update t!e te3tbo3 wit! t!e tag ID
is de6ned as fo##ows:
S''' update t!e Tag ID te3tbo3
*ub#ic De#egate Hub myDe#egate% ;
1yCa# str As Htring&
*ub#ic Hub updateTe3t1o3% ;
1yCa# str As Htring&
S''' update t!e te3tbo3 contro#
Wit! t3tTagID Te3t
8/20/2019 A Quick Introduction to RFID
29/36
Himi#ar#y, you can enab#e/disab#e t!e reader by ser$icing t!e
!eck!anged e$ent of t!e c!k.nab#eReader contro#
*ri$ate Hub ;
c!k.nab#eReader;!ecked!anged% ;
1yCa# sender As HystembMect, ;
1yCa# e As Hystem.$entArgs& ;
(and#es ;
c!k.nab#eReader!ecked!anged
S''' .nab#e RFID Reader
RFIDReaderHetutputHtate%, ;
c!k.nab#eReader!ecked&
.nd Hub
Testing t!e App#ication T!at4s it\ 5ou can now press F to test t!e app#ication .nsure you4$e
used *!idgetWebHer$ice 2anager to enab#e your *!idgetRFID
reader Figure 22 s!ows a tag scanned successfu##y
Figure 22: A tag scanned successfu##y
omparing t!e Two RFID Readers
5ou !a$e seen t!e two types of RFID readers and so w!ic! one s!ou#d
you go for (ere are some factors you can consider
ost
In terms of cost, t!e *ara##a3 RFID reader is $ery a-ordab#e at @B
(owe$er, you need to factor in t!e additiona# cost of wiring up t!e unit
5ou need to buy a power adapter %output C D&, a seria# cab#e, as we##
as t!e additiona# !ardware needed to con$ert t!e signa# to seria#
output In contrast, t!e *!idgetRFID kit costs about @= and inc#udes
e$eryt!ing you need
8/20/2019 A Quick Introduction to RFID
30/36
.ase of se
In terms of use, t!e *!idgetRFID is tru#y p#ug and p#ay Nust make sure
you down#oad t!e *!idgetWebHer$ice and you can start coding straig!t
away T!e *ara##a3 RFID Reader 2odu#e takes some e-ort to set up,especia##y if you are not fami#iar wit! e#ectronics and worry about
causing damage to t!e unit
F#e3ibi#ity
If you simp#y want to connect an RFID reader to your computer, t!en
t!e *!idgetRFID is c#ear#y an easy option (owe$er, t!e beauty of t!e
*ara##a3 RFID Reader 2odu#e is t!at it a##ows you to connect t!e unit to
de$ices ot!er t!an a *, suc! as an embedded contro##er sing t!e
*ara##a3 RFID Reader 2odu#e, you can embed it in a door and write
your own code to aut!enticate users
Tip: W!i#e at t!e moment, you can4t rea##y use t!e 7.T Framework %or
t!e 7.T ompact Framework& to write code for an embedded
contro##er, I am rea##y #ooking forward to t!e new 7.T 2icro Framework
%!ttp://wwwaboutnetmfcom/entryasp& to a##ow me to do t!e Mob in t!e
near future
Dimension
1ot! readers are simi#ar in si)e, and are ]at enoug! to be !idden from
$iew
Hummary
In t!is artic#e, you !a$e seen !ow RFID works and t!en #earned to bui#d
a Windows app#ication t!at uses two RFID readers'one from *ara##a3
and one from *!idget Depending on your needs, bot! #ow'cost readers
o-er a #ot of e3citing possibi#ities for integrating RFID capabi#ities into
your proMects If you !a$e not tried RFID yet, t!is is a good time to
begin\
http://www.aboutnetmf.com/entry.asphttp://www.aboutnetmf.com/entry.asp
8/20/2019 A Quick Introduction to RFID
31/36
^Hource: !ttp://wwwatme#com/dyn/resources/*rod;documents/secrerf;
RFID and 1arcodingHome critics critici)ed t!at RFID is simp#y a more e3pensi$e type of barcoding
tec!no#ogy, since t!e aim is to pick up a number stored on t!e tag %eit!er an
RFID tag or a barcode #abe#& (owe$er, RFID o-ers se$era# ad$antages o$er
barcode:
T!ere is no need for #ine of sig!t for RFID to work For barcoding, you need to
point t!e #aser at t!e #abe# before you can scan its ID
.ac! RFID tag ID is uni"ue A barcode #abe# does not uni"ue#y identify aproduct'it Must identi6es a particu#ar product type
ompanies can use RFID to track t!e w!ereabouts of goods In p#aces #ike
supermarkets, RFID readers can track e3pensi$e goods If an item is remo$ed
from t!e s!e#f, an RFID reader can detect its absence and take t!e
appropriate action
Insta##ing t!e Hamp#e DatabaseHince HQ+ Her$er ?? .3press does not come wit! any samp#e databases,
you need to insta## t!e samp#e databases yourse#f
5ou can insta## t!e pubs and 7ort!wind samp#e databases by down#oading
t!eir insta##ation scripts at!ttp://wwwmicrosoftcom/down#oads/detai#sasp3
fami#yid
8/20/2019 A Quick Introduction to RFID
32/36
:PHQ+ Her$er ??? Hamp#e DatabasesVs"#cmd 'H PHQ+.*R.HH 'i
instnwnds"#
+i!&i,g 1: Dec#aring member $ariab#es and constants*ub#ic #ass Form9
S'''seria# port to #isten toS incoming data''' *ri$ate Wit!.$ents seria#*ort As ; 7ew I*ortsHeria#*ort S'''tag ID read from t!e reader''' *ri$ate tagID As Htring < ; Htring.mpty S'''t!e time t!at t!e tag ID was
S recorded''' *ri$ate timeRecorded As ; DateTime < 7ow
S'''2 port to #isten to''' onst 2 As Htring
8/20/2019 A Quick Introduction to RFID
33/36
Wit! seria#*ort *ort7ame
8/20/2019 A Quick Introduction to RFID
34/36
If %temptagID < tagID& And ; timeInter$a# U I7T.RCA+ T!en S'''if it is t!e same tag and
S t!e time inter$a#S is #ess t!an seconds, t!eS tag wonSt be registered.3it Hub
.nd If
S'''t!e tag is sa$edtagID < temptagID
.mp#oyees1indingHource ; Remo$eFi#ter%&
S'''6nd t!e emp#oyee associatedS wit! t!e tag.mp#oyees1indingHource ;
Fi#ter < XTAGID
8/20/2019 A Quick Introduction to RFID
35/36
If t3tTagID Te3t UV Htring.mpty ; T!en S'''assign t!e Tag ID to t!e
S current emp#oyee TagID+abe#9 Te3t
8/20/2019 A Quick Introduction to RFID
36/36
+it%e +e,t-o,
hoto ictu!e-o,
+g/' +e,t-o,