Easy RFID Education kit documentation 1
1. Kit Contents
1. i-Stamp2P module board x 1
2. JX-2P plus Project board x 1
3. UCON-4 USB download cable x 1
4. RFID reader serial board x 1
5. 400-point Breadboard x 1
6. DC adaptor +12Vdc 500mA x 1
7. #22 AWG hook up wire set x 1
8. IDC1MF wire set (5-wire mix color) x 1
9. IDC1FF wire set (5-wire mix color) x 1
10. LCD16x2 with cable x 1
11. Documentation x 1
12. CD-ROM x 1
13. Experiment component set
10.1 Resistor 1/4W 220 x 8
10.2 Resistor 1/4W 510 x 16
10.3 Resistor 1/4W 1k x 4
10.4 Resistor 1/4W 2.2k x 2
10.5 Resistor 1/4W 4.7k x 6
10.6 Resistor 1/4W 10k x 5
10.7 Capacitor 15pF 50V ceramic x 2
10.8 Capacitor 0.1F 50V ceramic x 2
10.9 Capacitor 10F 16V electrolytic x 1
10.10 Diode 1N4148 x 2
10.11 LED 3mm. Red x 16
10.12 Tact switch x 4
10.13 Piezo Speaker 32 x 1
10.14 RFID Rectangle Tag x 1
10.15 RFID 50mm Round Tag x 1
Easy RFID Education kit
2 Easy RFID Education kit documentation
2. Main hardware information summary
2.1 i-Stamp2P microcontroller board
Features are compatible with the BASIC Stamp 2P 40 module (BS2P40-IC)
20MHz clock frequency. Operate up to 12,000 P-BASIC command/second
16KByte memory, separate 8 sections, 2KByte/each, erasable 100,000+ times
32 byte RAM with 64 byte Scratchpad RAM
Consumption of 65mA in full operation and 200A in sleep mode
Connecting to PC’s serial port for programming and debuging
32 I/O, freedom separeted work or set in groups from 4, 8 and 16 pins
30mA/30mA source/sink current. Maximum 60mA/60mA source/sink current
per 8-pins groups (P0-P7/P8-P15/A0-A7/A8-A15)
LED power status
Board sizes 2.25" x 1.5"
Develop with BASIC Stamp Editor program
2.2 JX-2P plus Project board
Socket for i-Stamp2P (OEM BASIC Stamp2P40)
RJ-11 female connector for downloading and communication
+5V power supply on board
Free 24 of i-Stamp2P port (P0 to P15 and A0 to A7)
Provides in 3-pin JST connector for P0 to P7
3 of RC servo motor port (P13 to P15)
LCD module interfacing with brightness adjustment (LCD module 16x2 with
cable is optional) connected with A9 to A15 of i-Stamp2P port.
DS18B20 1-wire Temperature sensor IC on-board (A8 port)
Prototype area 8.5x5.5 cm. with 200 soldering pad both 100mil (2.54mm.) spacing
and 80mil (2.0mm.) spacing. Support the small beadboard (optional - sold sold separated)
Board size 9.5 x 13 cm.
2 of power supply terminals
- For i-Stamp2P and any interfacing circuit; use the external power suypply
such as DC adpator or battery 6 to12V 500mA (not include), on-board polarity protection
circuit. Include the power switch and LED indicator.
- For the servo motor; support 4.8 to 6Vdc. Use 2-pin terminal block and
have the power swith with LED indicator.
Use with DC adaptor +12V 500mA, on-board polarity protection circuit.
Easy RFID Education kit documentation 3
TX
RX
ATN
GND
P0
P1
P2
P3
P4
P5
P6
P7
1
2
3
4
5
6
7
8
9
10
11
12
40
39
38
37
36
35
34
33
32
31
30
29
GNDRES
+5V
A14
A13
A12A11
A10
A9
A8
P8
P9
P10
18
19
20
28
27
26
25
24
23
22
21
A7
A6
A5
A4
A3
A2
A1
A0
13
14
15
16
17
P11P12
P13P14
P15
A15
Figrure 1 : i-Stamp2P pin assignment
PIN NAME FUNCTION
Tx/SOUT1 Serial Out:connects to PC serial port RX pin(DB9 pin 2) for programming.
Rx/SIN2 Serial In:connects to PC serial port TX pin(DB9 pin 3) for programming.
ATN3 Attention:connects to PC serial port DTR pin(DB9 pin 4) for programming.
VSS/GND4 System ground: (same as pin 23)connects to PC serial port GNDpin (DB9 pin 5) for programming.
P0-P155-20 P0-P15 General-purpose I/O pins
+5V37 5-volt DC input
RES38 Reset input/output: goes low
Vss/GND39 System ground
N/A40 Not use
A0-A1521-36 A0-A15 General-purpose I/O pins
3. Introduction to i-Stamp2P microcontroller
i-Stamp2P is the emulator of BS2P40-IC module which is designed by Innovative
Experiment Co.,Ltd., Thailand under the co-operation with Parallax Inc., manufacturer BASIC
Stamp from USA.
The size is different from BS2P40-IC. i-Stamp2P requires 40-pin female header to fit on
the board. The i-Stamp2P use BASIC Stamp interpreter licenced by Parallax Inc.
Figure 1, shows i-Stamp2P pin assignment. It’s similar to BS2P40-IC. The only one
different is i-Stamp2P no Vin pin because inside i-Stamp2P has not +5V regulator circuit.
Figure 2 shows the schematic of i-Stamp2P.
The heart of circuit is IC1 SX-48AC microcontroller. Inside this microcontroller
contains PBASIC2P interpreter firmware. The users have already written PBASIC. The
program is downloaded into i-Stamp2P via serial port.
Opearing program is stored to IC2 which is 16KByte serial EEPROM 24LC128. It
means IC2 is the system memory program.
i-Stamp2P need +5V and at least 65mA supply from regulator. Users can just connect
+5V and ground to i-Stamp2P and start working on it.
4 Easy RFID Education kit documentation
9
10
1213
8
3
1
5
4
16 2
+5V
IC1MAX232 C3
C2
C1
SOUT7
SIN
ATN
GND
5
19
2
3
+5V
427
26
25
24
23
22
21
20
17
16
15
14
13
12
11
10
IC2SX48AC
BASIC Stamp 2PInterpreter
9
8
1RxD
TxD
MCLR
R24k7
R14k7
D11N4148
C1-C510/25V
CR1Ceramic
Resonator20MHz
615C4
6
76
5A2
1
2
38
4
SDA
SCL
SDA
SCLA1
A0
IC324LC128
R44k7
+5V
C60.1/63V
45
44
43
42
41
40
39
38
37
36
35
34
31
30
29
28
A15
A14
A13
A12
A11
A10
A9
A8
A7
A6
A5
A4
A3
A2
A1
A0
32
P15
P14
P13
P12
P11
P10
P9
P8
P7
P6
P5
P4
P3
P2
P1
P0
20
19
18
17
16
15
14
13
12
11
10
9
8
7
6
5
36
35
34
33
32
31
30
29
28
27
26
25
24
23
22
21
33
47
18
46
37+5V
RESET
1
2
3
4
38
39GND
R3150
Figrure 2 : i-Stamp2P schematic diagram
Easy RFID Education kit documentation 5
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
9 8 7 6 5 4 3 2 1
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10 9 8 7 6 5 4 3 2 1
ab
cd
ef
gh
ij
++
--
i-Stamp2PBASIC Stamp2P
LCD: A9-E,A10-RWA12-15 D4-D7A11-RS
Vin
POWER
ON
ON
OEM Board
C op yr i gh t 2002 by I nnov a t i v e E x pe r i m en t
0A0A1A2A3A4A5A6A7RESET +5V
-P0+
JX
-2P
plu
si-S
tam
p2
P P
roje
ct b
oa
rd
-P1+ -P2+ -P3+ -P4+ -P5+ -P6+ -P7+
1 2 3 4 5 6 7 8 9 101112131415 GND
A8:
DS
18B
20
+Vs
+V
s
Vs
P13 P12 P11
LCD moduleconnector
To PC serial port
DC jack
Battery terminal formain circuit
LCD brightness
RC servosupplyterminal
Power switchfor servomotor supply
Servo port
DS18B20
Prototypearea
P0 to P7 port with 3-pin of JST connector
RESETswitch
Powerswitch
Figrure 3 : JX-2P plus board layout; +5V is +5V regulated supply for main
circuit, GND is system ground and +Vs is RC servo motor supply voltage. The
i-Stamp2P is optional component (sold seprated)
6 Easy RFID Education kit documentation
Figure 2 : JX-2P plus i-Stamp2P Project board schematic
~~
+
-
IC12940-5.0
+5V
R1510
LED1POWER
K1RS-232
(RJ-11 female)+5V
+Vm
+Vin6-16V
+Vin7.5-16V
SW1POWER
C1220F25V
C20.1F63V
C30.1F63V
C447F16V
P13+VmGND
P14+VmGND
P15+VmGND
SERVO PORT
J2P1
J3P2
J4P3
J5P4
J6P5
J7P6
J8P7
J1P0
i-Stamp2PPORT
K4DC input
K3Batteryinput
BD11A50V
i-Stamp2PSocket
1
2
3
4
38
37
A15 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0A14 A13 A12 A11 A10S1
RESET
P15 P9 P8 P7 P6 P5 P4 P3 P2 P1 P0P14 P13 P12 P11 P10
39
C50.1/50V
36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5
P0P1P2P3P4P5P6P7P8P9P10P11P12P13P14P15A0A1A2A3A4A5A6A7
+5V
R22k2
IC2DS18B20
+5V
+5V
RW
RS
E
D5
D7
D4
D6
K2UIC-LCD
VR1BRIGHT.
+5V
+5V
GND
PORT
MCU port
C70.1/50V
C60.1/50V
1
2
3
GNDDQ +V
DS18B20
+Vm+Vm6-7.2V
C82200F
10V
K5SERVOsupply
SW2SERVO_POWER
R31k
LED1POWER
TxD
RxD
DTR
4. Inside JX-2P plus : i-Stamp2P Project board
JX-2P plus is the microcontroller project board that has become a standard for
students, hobbyists, and even professional engineers. The board includes everything
you need to get started with microcontroller applications at minimal expense . Just add
your external circuits, code, and imagination. You can interface all components very
easily. With the help of PBASIC programming you can understand about microcontroller
interfacing concepts.
Figure 3 shows the physical of JX-2P plus board and its schematic is shown in figure
4. SK1 is the 40-pin female header for support i-Stamp2P. +5V regulated voltage supply is
connected to pin 21 of i-Stamp2P. Pin 22 connects with RESET switch to reset the operation
of i-Stamp2P. For interfacing with serial port, use pin 1 to 4 connect with RJ-11 serial
Easy RFID Education kit documentation 7
connector. These interface are used for downloading and debugging via Debug
Terminal in BASIC Stamp editor software.
Some components are connected with i-Stamp2P auxiliary port. It includes LCD
module and DS18B20 1-wire Temperature sensor. LCD module are assigned to connect
with A9 to A15 port and A8 is connected with DS18B20.
The JX-2P plus board supoprts the optiional power supply for high power circuit
such as DC motor and Servo motor. +Vm is terminal for connecting with Motor supply
voltage. The 6 to 7.2Vdc voltage is suitable for RC servo motor. Addition, the JX-2P plus
board provides 3 servo ports. They are connected with P13, P14 and P15 of the main i-
Stamp2P port. User can connect the servo motors direct to these connectors. If would
not to use servo motor, +Vm terminal can support another DC power supply up to 9Vdc
for supporting 4.5 to 9Vdc DC motors and small relays.
5. UCON-4 USB download cable driver installation
Preparation of this kit requires the USB driver installation for UCON-4 download
cable. Double click at the USBDriverInstallerV2.x.x.exe (x.x is number of version) file
from the bundled CD-ROM to start the driver instalation. The installation dialogue-box will
appear below.
Next, check the USB serial port address
(1) Plug the UCON-4 cable to USB port. Wait a moment. Windows will be detect
and prepare the suitable driver for this cable.
(2) Check the Virtual COM port or USB Serial port address by clicking Start
Control Panel System Hardware Device Manager
8 Easy RFID Education kit documentation
(3) See the list of USB serial port and remember the COM port address to work
with UCON-4 cable. Normally it will create COM3 or higher. In this example is COM4
6. Software tools
i-Stamp2P can work on the JX-2P plus Project board with BASIC Stamp editor
software V2.39 or higher. This is free for download at www.parallax.com or see in the
CD-ROM which bundled in the Easy RFID education kit.
You can see after software installation, how to use and PBASIC command reference
from BASIC Stamp editor manual V2.0 or higher. This is free for download at
www.parallax.com.
Easy RFID Education kit documentation 9
7. Getting start, Step by step
(7.1) Put i-Stamp2P intothe 40-pin female header on the JX-2P plus board. You must
put it in the right direction as shown in figure below.
(7.2) Connect the UCON-4 cable between the PC’s USB port and the JX-2P plus
board.
(7.3) Plug in the DC adaptor or 4 of AA battery pack for supplying voltage to the
JX-2P plus Experiment board. Open the BASIC Stamp Editor software.
(7.4) Check the communication between i-Stamp2P and the BASIC Stamp Editor
software by pressing on the Ctrl I key or by clicking on the Identify button or by entering
the RUN menu and then selecting Identify
If all is done correctly,the Identification box will appear and show the version
of PBASIC2SP chip as shown in the figure below. Observe COM4 box, it will show BASIC
Stamp2P V1.x (x is any number). Now i-Stamp2P can connect with the BASIC Stamp Editor
software.
10 Easy RFID Education kit documentation
(7.5) Make a simple program for testing.
(7.5.1) Select the BASIC Stamp type by BASIC Stamp directive. Enter the
Directive menu and select Stamp BS2P. The message ‘{$STAMP BS2P} appears on first
line. Press the Enter key.
(7.5.2) At the Directive menu, select serial port by Port Com4 (or any
Com port that connect). Messge ‘{$PORT COM4} will appear at the second line. Pess
Enter.
(7.5.3) At Directive menu, select the version of PBASIC language by PBASIC
Version2.5. Message ‘{$PBASIC 2.5} will appear at the third line. Press Enter
(7.5.4) At programming area, type debug “welcome”. This short code i-
Stamp2P send massage welcome to display on Debug Terminal of BASIC Stamp Editor.
Press Enter.
(7.5.5) Click Run button. Debug Terminal will appears and show message
“welcome” on the screen.
(7.5.6) Press the RESET switch on the JX-2P plus board. The Debug Terminal
screen repeats to show the same message. Because the RESET switch pressing means
re-start the program running.
(7.5.7) If dialogue box below is appeared, it means The communication
between computer and i-Stamp is unsuccessful.
Easy RFID Education kit documentation 11
Check the UCON-4 cable and the status of USB serial port (created by
Virtual COM port driver). This cable is used to connect between the computer’s USB
port and the JX-2P plus board. The cable’s end uses a Modular plug RJ-11 6P4C (6-pins
form and 4-contacts) Its Length is 1.5 meters approximation. The cable assignment is shown
in the diagram below.
MCU_TxD
MCU_RxD
MCU_DTRGND
This cable requires +5V from USB port and support USB 1.0/2.0. User can set the
baudrate up to 115,200 bit per second. Requires the driver installation before using.
(7.5.8) All experiment PBASIC code of i-Stamp2P must be save in the
filename extension .bsp
12 Easy RFID Education kit documentation
8. BASIC Stamp2P with starter experiment
8.1 Running light
P15
P14
P13
P12
P11
P10
P9
P8
P7
P6
P5
P4
P3
P2
P1
P0
i-Stamp2P
R16
R15
R14
R13
R12
R11
R10
R9
R8
R7
R6
R5
R4
R3
R2
R1
R1-R16510
LED16
LED15
LED14
LED13
LED12
LED11
LED10
LED9
LED8
LED7
LED6
LED5
LED4
LED3
LED2
LED1
'******************************************
' Connect P0-P15 to LED monitor
'******************************************
' {$STAMP BS2p}
' {PBASIC 2.5}
X1 var NIB
DIRS = $FFFF
LOOP1 :
outs = $0001
for X1 = 0 to 15
pause 500
outs = OUTS << 1
next
goto LOOP1
Easy RFID Education kit documentation 13
FREQOUT generates one or two sine waves using a pulse-width modulation
algorithm. The circuits in the figure below work by filtering out the high-frequency
PWM used to generate the sine waves. FREQOUT works over a very wide range of
frequencies so at the upper end of its range.
'**********************************************************
' Program : note.bsp
' Make melody sounds on speaker
' Hardware : Connect Speaker to P0
'**********************************************************
'{$STAMP BS2p}
FREQ VAR WORD ' Define Byte variable to keep frequency
I VAR BYTE ' Define Byte variable to keep loop counter
C CON 278 ' Note C Frequency
D CON 312 ' Note D Frequency
E CON 350 ' Note E Frequency
F CON 370 ' Note F Frequency
G CON 416 ' Note G Frequency
A CON 467 ' Note A Frequency
B CON 524 ' Note B Frequency
C1 CON 555 ' Note C1 Frequency
OUTPUT 0
LOOP1:
FOR I=0 TO 7
LOOKUP I,[C,D,E,F,G,A,B,C1],FREQ ' Read table 8 notes
FREQOUT 0,1887,FREQ ' Make melody with duration 0.5 sec
PAUSE 100 ' Delay 100 ms.
NEXT
PAUSE 1000
GOTO LOOP1 ' Goto loop
8.2 Playing Note
P0
SP1PIEZO
i-Stamp2P+
-
C110F
14 Easy RFID Education kit documentation
8.3 LCD Experiment
16x2 LCD module with cable
4 of AA battery or DC adaptor
The three LCD commands (LCDCMD, LCDIN and LCDOUT) allow the BS2p, BS2pe, or
BS2px or i-Stamp2P to interface directly to standard LCD displays that feature a
Hitachi 44780 controller (part #HD44780A). This includes many 1 x 16, 2 x 16, and 4
x 20 character LCD displays.
The Hitachi 44780 LCD controller supports a number of special instructions for
initializing the display, moving the cursor, changing the default layout, etc. The
LCDCMD command is used to send one of these instructions to the LCD. It is most
commonly used to initialize the display upon a power-up or reset condition. Note
that LCDCMD, LCDIN and LCDOUT use a 4-bit interface to the LCD which requires a
specific initialization sequence before LCDIN and LCDOUT can be used. Specifics
on the initialization sequence will follow.
Easy RFID Education kit documentation 15
'****************************************************************************************
' Program: Show message ON LCD Module 16x2
' Filename : lcd16x2.bsp
' Using 4 Bit mode interface, Connect D4-D7 TO A12-A15, RS TO A11, R/W TO A10 AND'E TO A9
'****************************************************************************************
' {$STAMP BS2p}
' {$PBASIC 2.5}
' {$PORT COM1}
LCD_ PIN 9
CHAR VAR Byte(16)
Init_LCD:
AUXIO
PAUSE 1000 ' allow LCD to power-up
LCDCM LCD_, 48 ' Send wake-up sequence (3x)
PAUSE 5
LCDCMD LCD_, 48
PAUSE 1
LCDCMD LCD_, 48
PAUSE 1
LCDCMD LCD_, 32 ' Set data bus to 4-bit mode
LCDCMD LCD_, 40 ' Set 2-line mode with 5x8 font
LCDCMD LCD_, 8 ' Turn display off
LCDCMD LCD_, 12 ' Turn display on without cursor
LCDCMD LCD_, 6 ' Auto-increment cursor
LCDCMD LCD_, 1 ' Clear the display
Start:
LCDOUT LCD_,1,["Hello!"]
GOSUB ReadLCDScreen
PAUSE 3000
LCDOUT LCD_,1,["I'm a 2x16 LCD!"]
GOSUB ReadLCDScreen
PAUSE 3000
GOTO Start
ReadLcdScreen:
DEBUG "LCD NOW Says:"
LCDIN LCD_,128,[STR CHAR\16]
DEBUG STR char\16,CR,CR
RETURN
16 Easy RFID Education kit documentation
8.4 The 1-Wire Temperature sensor
DS18B20
Connect to thecomputer's serial port
4 of AA Battery orconnect to DC adaptor
The DS18B20 Digital Thermometer provides 9 to 12–bit centigrade temperature
measurements and has an alarm function with nonvolatile user-programmable
upper and lower trigger points. The DS18B20 communicates over a 1-Wire bus that
by definition requires only one data line (and ground) for communication with a
central microprocessor. It has an operating temperature range of –55°C to +125°C
and is accurate to ±0.5°C over the range of –10°C to +85°C.
The 1-Wire protocol is a form of asynchronous serial communication developed by
Maxim/Dallas Semiconductor. It only requires one I/O pin and that pin can be
shared between multiple 1-Wire devices. The OWIN, OWOUT command allows the i-
Stamp2P to receive data from a 1-Wire device.
Easy RFID Education kit documentation 17
' ***************************************************' Filename : ds18b20.bsp' Simple PC thermometer
' ***************************************************
'{$STAMP BS2p}
' {$PBASIC 2.5}
' {$PORT COM1}
Temp VAR Word 'Holds the temperature value
TH VAR Byte
TL VAR Byte
Config VAR Byte
Reserved1 VAR Byte
Reserved2 VAR Byte
Reserved3 VAR Byte
CRC VAR Byte
Point VAR Byte
x VAR Word
Start:
AUXIO
OWOUT 8, 1, [$CC, $44] 'Send Calculate Temperature command
CheckForDone: 'Wait until conversion is done
PAUSE 25
OWIN 8, 4, [Temp] 'Here we just keep reading low pulses until
IF Temp = 0 THEN CheckForDone 'the DS1820 is done, then it returns high.
OWOUT 8, 1, [$CC, $BE] 'Send Read ScratchPad command
OWIN 8, 2, [Temp.LOWBYTE,Temp.HIGHBYTE,TH,TL,Config]
' Format Data
' S S S S S B6 B5 B4 : B3 B2 B1 B0 B-1 B-2 B-3 B-4
' Convert LowByte To Point
Temp = Temp & $0FFF
DEBUG DEC temp/16,"."
x =(Temp << 4) & $00ff
x = 10000 */ x
DEBUG DEC4 x,CR
GOTO start
This PBASIC code demostrate the reading temperature from DS18B20 on the JX-2P
plus board to display on the Debug Terminal of BASIC Stamp editor.
18 Easy RFID Education kit documentation
9. RFID Technology Overview
Material in this section is based on information provided by the RFID Journal (www.rfidjournal.com).
Radio Frequency Identification (RFID) is a generic term for non-contacting
technologies that use radio waves to automatically identify people or objects. There
are several methods of identification, but the most common is to store a unique serial
number that identifies a person or object on a microchip that is attached to an antenna.
The combined antenna and microchip are called an "RFID transponder" or "RFID tag"
and work in combination with an "RFID reader" (sometimes called an "RFID interrogator").
An RFID system consists of a reader and one or more tags. The reader's antenna
is used to transmit radio frequency (RF) energy. Depending on the tag type, the energy
is "harvested" by the tag's antenna and used to power up the internal circuitry of the
tag. The tag will then modulate the electromagnetic waves generated by the reader in
order to transmit its data back to the reader. The reader receives the modulated waves
and converts them into digital data.
There are two major types of tag technologies. "Passive tags" are tags that do
not contain their own power source or transmitter. When radio waves from the reader
reach the chip’s antenna, the energy is converted by the antenna into electricity that
can power up the microchip in the tag (typically via inductive coupling). The tag is then
able to send back any information stored on the tag by modulating the reader’s
electromagnetic waves. "Active tags" have their own power source and transmitter.
The power source, usually a battery, is used to run the microchip's circuitry and to
broadcast a signal to a reader. Due to the fact that passive tags do not have their own
transmitter and must reflect their signal to the reader, the reading distance is much
shorter than with active tags. However, active tags are typically larger, more expensive,
and require occasional service.
Frequency refers to the size of the radio waves used to communicate between
the RFID system components. Just as you tune your radio to different frequencies in
order to hear different radio stations, RFID tags and readers must be tuned to the same
frequency in order to communicate effectively. RFID systems typically use one of the
following frequency ranges: low frequency (or LF, around 125 kHz), high frequency (or
HF, around 13.56 MHz), ultra-high frequency (or UHF, around 868 and 928 MHz), or
microwave (around 2.45 and 5.8 GHz).
The read range of a tag ultimately depends on many factors: the frequency of
RFID system operation, the power of the reader, and interference from other RF devices.
Balancing a number of engineering trade-offs (antenna size v. reading distance v. power
v. manufacturing cost), the Parallax RFID Card Reader's antenna was designed specifically
for use with low-frequency (125 kHz) passive tags with a read distance of around 4 inches.
Easy RFID Education kit documentation 19
10. About Parallax RFID reader - Serial
Designed in cooperation with Grand Idea Studio (www.grandideastudio.com),
the Parallax Radio Frequency Identification (RFID) Card Readers provide a low-cost
solution to read passive RFID transponder tags up to 4 inches away. The RFID Card
Readers can be used in a wide variety of hobbyist and commercial applications,
including access control, user identification, robotics navigation, inventory tracking,
payment systems, car immobilization, and manufacturing automation.VCC
/EN
ABLE
SO
UT
GN
D
GRAN
Did
ea
studio
10.1 Features
Low-cost method for reading passive, 125 kHz RFID transponder tags
Serial interface for microcontrollers
Bi-color LED for visual indication of status
20 Easy RFID Education kit documentation
10.2 RFID Compatibility
The Parallax RFID Card Reader works exclusively with the EM Microelectronics
EM4100-family of passive read-only transponder tags. Each transponder tag contains a
unique, read-only identifier (one of 240, or 1,099,511,627,776 possible combinations).
10.3 Connections (Serial)
The Parallax RFID Card Reader Serial version easily interfaces to any host
microcontroller using only four connections (VCC, /ENABLE, SOUT, GND).
Pin Pin Name Type Function
1 VCC powerSystem power.+5Vdc input.
2 /ENABLE inputModule enable pin. Active LOW digital input.Bring this pin LOW to enable the RFID reader andactivate the antenna.
3 SOUT outputSerial output to host.TTL-level interface, 2400 bps, 8 data bits, no parity,1 stop bit.
4 GND powerSystem ground.Connect to power supply’s ground (GND) terminal.
Use the following example circuit for connecting the Parallax RFID Card Reader:
+5V
OUT
OE VCC/ENABLESOUTGND
GRANDidea studio
Easy RFID Education kit documentation 21
10.4 Usage
A visual indication of the state of the RFID Card Reader is given with the on-
board LED. When the module is successfully powered-up and is in an idle state, the LED
will be GREEN. When the module is in an active state searching for or communicating
with a valid tag, the LED will be RED.
The RFID Card Reader Serial is activated via the /ENABLE pin on the module’s 4-
pin header. When the RFID Card Reader is powered and /ENABLE is pulled LOW, the
module will enter the active state. When /ENABLE is pulled HIGH or left unconnected,
the module will enter the idle state.
The face of the RFID tag should be held parallel to the front or back face of the
antenna (where the majority of RF energy is emitted). If the tag is held sideways (for
example, perpendicular to the antenna), you’ll either get no reading or a poor reading
distance. Only one transponder tag should be held up to the antenna at any time. The
use of multiple tags at one time will cause tag collisions and the reader may not detect
any of them. The tags available in the Parallax store have a read distance of
approximately 4 inches. Actual distance may vary slightly depending on the size of the
transponder tag and environmental conditions of the application.
10.5 Communication Protocol
All communication is 8 data bits, no parity, 1 stop bit, and least significant bit first
(8N1) at 2400 bps. The RFID Card Reader Serial version transmits data as 5V TTL-level, non-
inverted asynchronous serial.
When the RFID Card Reader is active and a valid RFID transponder tag is placed
within range of the activated reader, the tag’s unique ID will be transmitted as a 12-byte
printable ASCII string serially to the host in the following format:
Start Byte(0x0A)
Unique IDDigit 1
Unique IDDigit 2
Unique IDDigit 3
Stop Byte(0x0D)
Unique IDDigit 4
Unique IDDigit 5
Unique IDDigit 6
Unique IDDigit 7
Unique IDDigit 8
Unique IDDigit 9
Unique IDDigit 10
The start byte and stop byte are used to easily identify that a correct string has
been received from the reader (they correspond to line feed and carriage return
characters, respectively). The middle ten bytes are the actual tag's unique ID. For
example, for a tag with a valid ID of 0F0184F07A, the following bytes would be sent:
0x0A, 0x30, 0x46, 0x30, 0x31, 0x38, 0x34, 0x46, 0x30, 0x37, 0x41, 0x0D.
22 Easy RFID Education kit documentation
11. RFID basic experiment with i-Stam2P(BASIC Stamp2P40 OEM board)
11.1 Component list
1. RFID reader Serial version
2. RFID tag card
3. RFID tag circle
4. i-Stamp2P with JX-2P plus project board
5. UCON-4 download cable
6. IDC1MF 4 wires
7. 16x2 LCD module with cable
8. DC adaptor (+6 to +12Vdc 500mA)
11.2 Experiment 1 : Simple reading the RFID tag
(1.1) Connect RFID reader with the JX-2P plus board following figure 11-1
- Connect the /Enable pin of the RFID reader with P0 of i-Stamp2P
- Connect the SOUT pin of the RFID reader with P1 of i-Stamp2P
- Connect the VCC pin of the RFID reader with +5V on JX-2P plus board
- Connect the GND pin of the RFID reader with GND or Ground of the JX-2P
plus board
(1.2) Open the BASIC Stamp editor
Easy RFID Education kit documentation 23
VCC
/EN
ABLE
SO
UT
GN
D
GRAN
Did
ea s
tudio
+5V A7A6A5A4A3A2A1A0 0 1 2 3 4 5 6 7 8 9 1011 121314 15 GND
+Vs
DS18B20
Vs
ON
+Vs
P13 P12 P11
RESET
POWER
Vin+ON
6-12Vdc SERIA
L
LCD : A9-E, A10-RW,A12-A15 D4-D7A11-RS
Connect to thecomputer's USB portvia UCON-4 cable
+12Vdcadaptor
P1P0
Figure 11-1 : RFID reader experiment 1 connection diagram
24 Easy RFID Education kit documentation
(1.3) Type the code following List 11-1
(1.4) Download the code to i-Stamp2P by clicking the RUN button or press the key
CTRL+R.
The Debug Terminal is opened. Choose the interfaced COM port.
(1.5) Place the RFID tag card over the RFID reader at antenna side. See the results
on the Debug Terminal window
The Debug Terminal displays the ID of RFID tag below :
VCC
/EN
ABLE
SO
UT
GN
D
GRA
ND
idea s
tudio
RFID tagFront side
' {$STAMP BS2p}
' {$PBASIC 2.5}
char_rfid VAR Byte (10) ' Declare the ID variable 10 bytes
Main:
LOW 0 ' Force Enable pin as low
SERIN 1, 1021, [WAIT($0A),STR char_rfid\10]
' Read data from RFID reader from P1
' and store 10-byte of ID to the char_rfid array variable.
' The first byte must be 0A
Show_Tag:
DEBUG "Tag ID: ", STR char_rfid ' Show ID on the Debug Terminal
DEBUG CR ' Next line
PAUSE 1000
GOTO Main ' Do again
END
Listing 11-1 : RFID_ReadTerminal.bsp; Read the RFID tag card to show on
the Debug terminal
Easy RFID Education kit documentation 25
(1.6) Change the RFID tag card to RFID tag circle and try again following the step
(1.5)
VCC
/EN
ABLE
SO
UT
GN
D
GRAN
Did
ea s
tudio
VCC
/EN
ABLE
SO
UT
GN
D
GRAN
Did
ea s
tudio
26 Easy RFID Education kit documentation
11.3 Experiment 2 : Simple reading the RFID tag to show on LCD
(2.1) Connect RFID reader with the JX-2P plus board following figure 11-2
- Connect the /Enable PIN of the RFID reader with P0 of i-Stamp2P
- Connect the SOUT PIN of the RFID reader with P1 of i-Stamp2P
- Connect the VCC of the RFID reader with +5V on JX-2P plus board
- Connect the GND of the RFID reader with GND or Ground of the JX-2P plus
board
(2.2) Plug the LCD module with cable to LCD connector on the JX-2P plus board
(2.3) Open the BASIC Stamp editor
VCC
/EN
ABLE
SO
UT
GN
D
GRA
ND
idea
studio
+5V A7A6A5A4A3A2A1A0 0 1 2 3 4 5 6 7 8 9 1011 12131415 GND
+Vs
DS18B20
Vs
ON
+Vs
P13 P12 P11
RESET
POWER
Vin+ON
6-12Vdc SER
IAL
LCD : A9-E, A10-RW,A12-A15 D4-D7A11-RS
+12Vdcadaptor
P1
Connect toLCD16x2
P0
Figure 11-2 : RFID reader experiment 2 connection diagram
Easy RFID Education kit documentation 27
(2.4) Type the code following Listing 11-2
(2.5) Download the code to i-Stamp2P by clicking the RUN button or press the key
CTRL+R.
(2.6) Place the RFID tag card over the RFID reader at antenna side. See the results
on the LCD module screen.
The LCD module will show the ID below on the line 1 :
0414E50079
(2.7) Change the RFID tag card to RFID tag circle and try again following the step
(2.6)
' {$STAMP BS2p}
' {$PBASIC 2.5}
char_rfid VAR Byte (10)
LOW 0 ' Send “0” to Enable pin of RFID reader
AUXIO ' Change to AUX port
Init_LCD:
PAUSE 1000
LCDCMD 9, %00110000 ' Initial LCD
PAUSE 5
LCDCMD 9, %00110000
PAUSE 0
LCDCMD 9, %00110000
PAUSE 0
LCDCMD 9, %00100000 ' Set data bus to 4-bit mode
LCDCMD 9, %00101000 ' Set to 2-line mode with 5x8 font
LCDCMD 9, %00001100 ' Display on without cursor
LCDCMD 9, %00000110 ' Auto-increment cursor
LCDCMD 9, %00000001 ' Clear the display
Main:
MAINIO ' Switch to Main port
SERIN 1, 1021, [WAIT($0A),STR char_rfid\10]
' Read data from RFID reader from P1
' and store 10-byte of ID to the char_rfid array variable.
' The first Byte must be 0A
AUXIO ' Switch to AUX port
LCDOUT 9, 1, [STR char_rfid] ' Show ID on LCD screen
GOTO MAIN
END
Listing 11-2 : RFID_ReadLCD.bsp; Read the RFID tag card and display on the
16x2 LCD module
28 Easy RFID Education kit documentation
11.4 Experiment 3 : Test range reading of the RFID reader withany direction
(3.1) Still use the connection diagram of figure 11-3 and using the code from Listing
11-3
(3.2) Open the BASIC Stamp editor
(3.3) Type the code following Lisiting 11-3
(3.4) Download the code to i-Stamp2P by clicking the RUN button or press the key
CTRL+R.
12345678910
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
fg
hi
je
dc
ba
12345678910
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
++
fg
hi
je
dc
ba
VCC
/EN
ABLE
SO
UT
GN
D
GRAN
Did
ea s
tudio
+5V A7A6A5A4A3A2A1A0 0 1 2 3 4 5 6 7 8 9 1011 121314 15 GND
+Vs
DS18B20
Vs
ON
+Vs
P13 P12 P11
RESET
POWER
Vin+ON
6-12Vdc SERIA
L
LCD : A9-E, A10-RW,A12-A15 D4-D7A11-RS
+12Vdcadaptor
P1
Connect toLCD16x2
P0
10F
piezo speaker
Figure 11-3 : RFID reader experiment 3 connection diagram
Easy RFID Education kit documentation 29
GND
P0
P1
A9
A10
A11
A12
A13
A14
A15
D0 D1 D2 D3 D4 D5 D6 D7
7 8 9 10 11 12 13 14
E
RW
RS
+V
Vo
G
+5V
VR110k
P4
C110F
SP1PIEZO
SPEAKER
i-Stamp2P
+5V
VCC
EN
ABLE
SO
UT
RFID reader6
5
4 1
3
2
'*************************************************************' RFID_ReadTest.bsp' Detect and read RFID tag and drive sound with piezo speaker'*************************************************************' {$STAMP BS2p}' {$PBASIC 2.5}char_rfid VAR Byte (10)LOW 0 ' Send "0" to Enable pin of RFID readerAUXIO ' Change to AUX portInit_LCD: PAUSE 1000 LCDCMD 9, %00110000 ' Initial LCD PAUSE 5 LCDCMD 9, %00110000 PAUSE 0 LCDCMD 9, %00110000 PAUSE 0 LCDCMD 9, %00100000 ' Set data bus to 4-bit mode LCDCMD 9, %00101000 ' Set to 2-line mode with 5x8 font LCDCMD 9, %00001100 ' Display on without cursor LCDCMD 9, %00000110 ' Auto-increment cursor LCDCMD 9, %00000001 ' Clear the displayMain:MAINIOSERIN 1, 1021, [WAIT($0A),STR char_rfid\10]FREQOUT 4,1000,1000 ' Output sound on port 4AUXIO ' Switch to AUX portLCDOUT 9, 1, [STR char_rfid] ' Show ID on LCD screenPAUSE 2000GOTO Main
END
Listing 11-3 : RFID_ReadTest.bsp; Read the RFID tag card to show on the
16x2 LCD module and drive a beep signal.
Figure 11-4 : RFID reader experiment 3 schematic diagram
30 Easy RFID Education kit documentation
(3.5) Place the RFID tag card over the RFID reader at antenna side. See the results
on the LCD module screen.
VCC
/EN
ABLE
SO
UT
GN
D
GRAN
Did
ea s
tudio
RFID tagFront side
The LCD module will show the ID below on the line 1 :
0414E50079
and the piezo speaker drives a beep signal on every reading.
(3.6) Place the RFID tag circler over the RFID reader at antenna side. See the
results on the LCD module screen.
VCC
/EN
ABLE
SO
UT
GN
D
GRAN
Did
ea s
tudio
The LCD module will show the ID of RFID tag circle (must different the
RFID tag card) below on the line 1 :
0F02A68691
and the piezo speaker drives a beep signal on every reading.
Easy RFID Education kit documentation 31
(3.7) Back to use the RFID tag card. Move the card far from RFID reader until
does not detect the RFID tag. Record the distance.
VCC
/EN
ABLE
SO
UT
GN
D
GRAN
Did
ea s
tudio
RFID tagFront side
Antenna side
RFID reader
Front side
Back sideadjust distance
RFID tag
Maximum operation distance is during 5 to 6cm.
(3.8) Flip the RFID tag . The back side is over the RFID reader. See the ID on the
LCD module annd move the RFID tag far from RFID reader until does not detect the
RFID tag. Record the distance.
VCC
/EN
ABLE
SO
UT
GN
D
GRAN
Did
ea s
tudio
RFID tagBack side
Antenna side
RFID reader
adjust distance
RFID tag
Front side
Back side
Maximum operation distance is during 5 to 6cm. Summary is that the RFID
reader can detect and read any side of the RFID tag card.
32 Easy RFID Education kit documentation
(3.9) Turn the RFID tag long edge over the RFID reader 3 positions following the
figure below. Moving the tag is required to the RFID reader detects the tag.
VCC
/EN
ABLE
SO
UT
GN
D
GRAN
Did
ea s
tudio
RFID tag
VCC
/EN
ABLE
SO
UT
GN
D
GRAN
Did
ea s
tudio
RFID tag
VCC
/EN
ABLE
SO
UT
GN
D
GRAN
Did
ea s
tudio
RFID tag
Antenna side
RFID reader
RFID tagFront side
adjust distance
Antenna side
RFID reader
adjust distance
RFID tagBack side
The RFID reader cannot detect the tag in this direction.
Easy RFID Education kit documentation 33
(3.10) Turn the RFID tag short edge over the RFID reader 3 positions following the
figure below. Moving the tag is also required to the RFID reader detects the tag.
VCC
/EN
ABLE
SO
UT
GN
D
GRAN
Did
ea s
tudio
RFID tag
VCC
/EN
ABLE
SO
UT
GN
D
GRAN
Did
ea s
tudio
RFID tag
VCC
/EN
ABLE
SO
UT
GN
D
GRAN
Did
ea s
tudio
RFID tag
Antenna side
RFID reader
adjust distance
RFID
ta
gFro
nt
side
Antenna side
RFID reader
adjust distance
RFID
ta
gBack
sid
e
The RFID reader also cannot detect the tag in this direction.
Summary, RFID reader cannot detect and read the edge of the card. The best
result reading are front and back sides orientation of RFID tag card.
34 Easy RFID Education kit documentation
(3.11) Change to the RFID tag circle. Move the tag far from RFID reader until
does not detect the RFID tag. Record the distance. Try with both side of tag.
VCC
/EN
ABLE
SO
UT
GN
D
GRAN
Did
ea s
tudio
VCC
/EN
ABLE
SO
UT
GN
D
GRAN
Did
ea s
tudio
Antenna side
RFID reader
Front side
Back sideadjust distance
RFID circle tag
Antenna side
RFID reader
Back side
Front sideadjust distance
RFID circle tag
Maximum operation distance is during 6 to 7cm.
Summary :
1. The RFID reader can detect and read the RFID tag circle with any flat side.
2. The operation range of RFID reader is same with any flat side of RFID tag card.
Easy RFID Education kit documentation 35
(3.12) Place the RFID tag over the RFID reader by edge side 3 positions following
the figure below. Moving the tag is required to the RFID reader detects the tag.
VCC
/EN
ABLE
SO
UT
GN
D
GRAN
Did
ea s
tudio
RFID tag circle
VCC
/EN
ABLE
SO
UT
GN
D
GRAN
Did
ea s
tudio
RFID tag circle
VCC
/EN
ABLE
SO
UT
GN
D
GRAN
Did
ea s
tudio
RFID
tag c
ircl
e
A CB
Antenna side
RFID reader
adjust distance
The RFID reader detects and reads RFID tag circle only position A and C. Range
is similar at 2 to 2.5cm. RFID reader does not detect the RFID tag circle in postion B.
36 Easy RFID Education kit documentation
(3.13) Change the direction of the RFID tag from step (3.12) following the figure
below. Try to detect 3 positions. Moving the tag is required till the RFID reader detects
the tag.
VCC
/EN
ABLE
SO
UT
GN
D
GRAN
Did
ea s
tudio
VCC
/EN
ABLE
SO
UT
GN
D
GRAN
Did
ea s
tudio
VCC
/EN
ABLE
SO
UT
GN
D
GRAN
Did
ea s
tudio
RFID tag circle
RFID tag circle
RFID tag circle
A
B C
Antenna side
RFID reader
adjust distance
RFID tag circle
The RFID reader detects and reads RFID tag circle only position A and C. Range
is similar at 2 to 2.5cm. The RFID reader does not detect the RFID tag circle in postion B.
The position B is out of antenna area.
Summary :
1. The RFID reader cannot detect and read the ID from RFID tag circle when the
tag located out of antenna area.
2. The operation range of RFID reader is decreased with edge side of the RFID
tag circle.
Easy RFID Education kit documentation 37
(3.14) Place the RFID tag card over the RFID reader at antenna side and insert
some medium between the tag and RFID reader. Test the operation. The medium includes
a piece of papaer, wood with 3mm. thickness and plastic sheet with 3mm. thickness.VCC
/EN
ABLE
SO
UT
GN
D
GR
AN
Did
ea s
tudio
RFID tagFront side
Antenna side
RFID reader
2 to 3cm.
a piece of paper
RFID tagFront side
A piece of paper
VCC
/EN
ABLE
SO
UT
GN
D
GR
AN
Did
ea s
tudio
RFID tagFront side
RFID tagFront side
A piece of wood (3mm. thick)
VCC
/EN
ABLE
SO
UT
GN
D
GR
AN
Did
ea s
tudio
RFID tagFront side
RFID tagFront side
A piece of plastic (3mm. thick)
RFID tag
Antenna side
RFID reader
2 to 3cm.
wood (3mm.)
RFID tag
Antenna side
RFID reader
2 to 3cm.
plastic (3mm.)
RFID tag
The operation of RFID reader is same. The medium paper, wood and plastic
also are not effect the detection if the thickness are not more than the operation
range.
38 Easy RFID Education kit documentation
12. RFID logger
This example project is about how to use RFID reader and i-Stamp2P to build a
simple ID logger system. This project required the database software for collecting the
ID data from any RFID tag. We choose AppServ 2.5.10; the free software of Web server
to create the data server in the computer and create the control software from Visual
BASIC 2010 express to manage the system.
12.1 AppServ software installation
AppServ 2.5.10 is free software. Download from http://prdownloads.sourceforge.
net/appserv/appserv-win32-2.6.0.exe?download.
Install the software following these step :
(12.1.1) Double click the setup file; appserv-win32-2.5.10.exe to start the installation.
Click on the Next button.
(12.1.2) Choose components and click on the Next button.
Easy RFID Education kit documentation 39
(12.1.3) Put name localhost into the Server Name box and fill the email address
into the Administrator Email box. Click on the Next button.
(12.1.4) Set password for ID root. It is ID for server and database administrator.
Click on the Install button.
(12.1.5) After installation is completed, select Start Apache and Start MySQL for
starting the operation of Web Server and database management software.
40 Easy RFID Education kit documentation
12.2 Database preparation
Purpose is making the database table of check-in time and check-out time of
employee.
(12.2.1) O p e n the In te rne t Exp lo re r. Bro w se to a d d re ss http://localhost/
phpMyAdmin/ . The authentication window is appeared. Fill the ID or User name with
root and fill password such as 1234 or another setting from installation steps.
(12.2.2) The new database is created. Put the name db_employee into Create
new database box following click on the Create button.
Easy RFID Education kit documentation 41
(12.2.3) Make the database table following these procedures :
(12.2.3.1) Set the nam e as tb_in for storing the ID data, date and check-in
time of employee
(12.2.3.2) Set the Number of Fields as 3
(12.2.3.3) Click on the Go button
(12.2.4) Set name and parameter of data filed as follows :
- id_in field, type is VARCHAR and length is 10 ; choose as Primary
- time_in field, type is TIME choose as Primary
- date_in field, type is DATE and choose as Primary.
Click on the Save button.
42 Easy RFID Education kit documentation
(12.2.5) After the tb_in table is created, the message “Table 'db_employee'.'tb_in'
has been created” is appeared in the yellow box. In the SQL quiery box shows all
instructions for creating the table of database and structure. At the left menu; it shows
the database name and number of data table.
(12.2.6) Click on the db_employee(1). The browser will display the new page for
creating the new table. Create the table for storing the ID data, date and check-out
time of employee similar the step 12.2.3. Set the name and parameter as follows :
(12.2.6.1) Set the name as tb_out
(12.2.6.2) Set the Number of Fields as 3 and click on the Go button.
Easy RFID Education kit documentation 43
(12.2.7) Set name and parameter of data filed as follows :
- id_out field, type is VARCHAR and length is 10. Choose as Primary.
- time_out field, type is TIME and choose as Primary.
- date_out field, type is DATE and choose as Primary.
Click on the Save button.
(12.2.8) After the tb_out table is created, the message "Table 'db_employee'.'tb_out'
has been created" is appeared in the yellow box. In the SQL quiery box shows all instructions
for creating the table of database and structure. At the left menu; it shows the database
name and number of data table. Now there are 2 tables.
44 Easy RFID Education kit documentation
12.3 MySQL driver installation
Before accessing the database with MySQL, you will need to install MySQL ODBC
3.51 Driver. Download at http://dev.mysql.com/downloads/connector/odbc/3.51.html
(12.3.1) Double click on the installation file; mysql-connector-odbc-3.51.30-winx64.msi.
Welcome window is appeared.
(12.3.2) Click on the Next button of each step until the installation is started. After
the installation is completed, the database system is prepared already.
Easy RFID Education kit documentation 45
12.4 Database programming with Visual BASIC Express 2010
Next step is creating the software for connecting with database by Visual BASIC
Express 2010.
(12.4.1) Open the VB Express 2010. Create the New project.
(12.4.2) Set the project name as RFIDLogger. Click on the OK button.
46 Easy RFID Education kit documentation
(12.4.3) Drag and drop all controls and buttons and set the name of any element
following the picture below.
Label1 : Label for displaying the message “Available Com Ports”
cbbCOMPorts : Combobox for choosing the COM port that connect
with RFID reader system.
btnConnect : Button for displaying the message “Connect” after open
the COM port.
btnDisConnect : Button for displaying the message “Disconnect” after
close the COM port..
btnSearch : Button for displaying the message “Search”. It is button for
searching the employee code
txtSearch : TextBox for filling the employee ID to searching
btnPrint : Button for displaying the message “Print” after print text in
rtxtDataReceived
txtDataReceived : RichTextBox for showing ID data and working time of
employee
lblMessage : Label of RFID reader system interfacing status.
txtRFIDData : TextBox for showing the employee data of RFID tag reading.
Printdialog : Printdialog for opening the Printing dialog box.
PrintDocument1 : PrintDocument control for printing out the data to printer.
Easy RFID Education kit documentation 47
(12.4.4) Enter to Form1.vb to write the code by clicking on the View Code button
(12.4.5) Type the code for Class Form1 and subprogram Form1_Load as followings :
Imports System.Data.Odbc
Imports System.Drawing.Printing
Public Class Form1
Dim WithEvents serialPort As New IO.Ports.SerialPort
Dim x As String = "" 'save value form serial port
Dim command As New OdbcCommand
'command for insertSQL string contains a SQL statement that
Dim reader As OdbcDataReader 'for execute command sql
Dim MyConString As String 'string value for connect mysql
Dim num As Integer 'save row sql execute
Dim MyConnection As New OdbcConnection
'MyConnection value connect mysql
Dim strsql As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles MyBase.Load
'connect mysql
MyConString = "DRIVER={MySQL ODBC 3.51 Driver};" + "SERVER=localhost;" +"DATABASE=db_employee;" + "UID=root;" + "PASSWORD=1234;" + "OPTION=3;"
MyConnection.ConnectionString = MyConString
MyConnection.Open() 'check port connect and add value on cbbCOMPorts
For i As Integer = 0 To _
My.Computer.Ports.SerialPortNames.Count - 1
cbbCOMPorts.Items.Add(_My.Computer.Ports.SerialPortNames(i))
Next
btnDisconnect.Enabled = False
End Sub
End Class
48 Easy RFID Education kit documentation
The Database connection code below are setting the default database
authentification.
MyConString = "DRIVER={MySQL ODBC 3.51 Driver};" + "SERVER=localhost;" +"DATABASE=db_employee;" + "UID=root;" + "PASSWORD=1234;" + "OPTION=3;"
MyConnection.ConnectionString = MyConString
MyConnection.Open()
Data in the MyConString is default data from installation. It includes :
“SERVER=localhost;” : Assign the server name
“DATABASE=db_employee;” : Assign the database name
“UID=root;” : Assign the database ID
“PASSWORD=1234;” : Assign the password
(12.4.7) Double click on the btnConnect button to make the code in subprogram
btnConnect_Click as follows:
Private Sub btnConnect_Click(ByVal sender As System.Object, ByVale As System.EventArgs) Handles btnConnect.Click
If serialPort.IsOpen ThenserialPort.Close()
End IfTry 'set serial port number
With serialPort.PortName = cbbCOMPorts.Text.BaudRate = 9600.Parity = IO.Ports.Parity.None.DataBits = 8.StopBits = IO.Ports.StopBits.One
End WithserialPort.Open() ' open serialportlblMessage.Text = cbbCOMPorts.Text & " connected."
'change text of labelbtnConnect.Enabled = False 'btnConnect disable clickbtnDisconnect.Enabled = True 'btnDisconnect enable clickCatch ex As ExceptionMsgBox(ex.ToString)
End TryEnd Sub
(12.4.8) Double click on the btnDisconnect button to add the code in subprogram
btnDisconnect_Click as follows :
Private Sub btnDisconnect_Click(ByVal sender As System.Object, ByVale As System.EventArgs) Handles btnDisconnect.Click
Try ' close serailportserialPort.Close()lblMessage.Text = serialPort.PortName & " disconnected."
' change text of labelbtnConnect.Enabled = True ' btnConnect enable clickbtnDisconnect.Enabled = False ' btnDisconnect disable clickCatch ex As ExceptionMsgBox(ex.ToString)
End TryEnd Sub
Easy RFID Education kit documentation 49
(12.4.9) Add subprogram for receiving the serial data from COM port and show
data at TextBox1 :
Private Sub DataReceived(ByVal sender As Object, ByVal e AsSystem.IO.Ports.SerialDataReceivedEventArgs) Handles serialPort.DataReceived
' update data go to updateTextBoxrtxtDataReceived.Invoke(New myDelegate(AddressOf updateTextBox), New
Object() {})End Sub
(12.4.10) After getting the ID from COM port, transfers data to the updateTextBox
to compare the ID database in the tb_in table. The data is current date. If found the
data, system will find more in the tb_out table. If found; it means this data is completed.
No add the data. In the other hand, if there is not data in each table data; system will
add the current data in the table. Store in the database and show the reading ID on the
TextBox1. The code is as follows :
Public Delegate Sub myDelegate()
Public Sub updateTextBox()Dim currentSystemTime As DateTime = DateTime.Now 'date and time nowx = x + serialPort.ReadExisting 'save data form serialport in xIf x.Length >= 10 Then 'check length data >=10 ok
x.Substring(0, 10) 'substring 0-10
'select input with database for check in or outstrsql = "select * from tb_in where id_in='" + x + "' and date_in='" +
currentSystemTime.Year.ToString + "-" + currentSystemTime.Month.ToString + "-"+ currentSystemTime.Day.ToString + "'"
'execute sql commandcommand = New OdbcCommand(strsql, MyConnection)reader = command.ExecuteReader()num = reader.RecordsAffected
If num <= 0 Then ' if no check in insert data in tb_instrsql = "INSERT INTO tb_in VALUES (‘" + x + "‘, ‘" +
currentSystemTime.TimeOfDay.ToString.Substring(0, 8) + "‘, ‘" +currentSystemTime.Year.ToString + "-" + currentSystemTime.Month.ToString + "-"+ currentSystemTime.Day.ToString + "')"
Tex tBox 1.Te xt = "In " + x + " " +currentSystemTime.TimeOfDay.ToString.Substring(0, 8) + " " +currentSystemTime.Date
Else ' if check out select check outstrsql = "select * from tb_out where id_out='" + x + "' and
date_out='" + currentSystem Time .Yea r.To Stri ng + "-" +currentSystemTime.Month.ToString + "-" + currentSystemTime.Day.ToString + "‘"
command = New OdbcCommand(strsql, MyConnection)reader = command.ExecuteReader()num = reader.RecordsAffected
If num <= 0 Then' insert data in tb_outstrsql = “INSERT INTO tb_out VALUES ('" + x + "', ‘" +
currentSystemTime.TimeOfDay.ToString.Substring(0, 8) + "', ‘" +currentSystemTime.Year.ToString + "-" + currentSystemTime.Month.ToString +"-" +currentSystemTime.Day.ToString + "')"
50 Easy RFID Education kit documentation
TextBox1.Text = "Out " + x + " " + currentSystemTime.TimeOfDay.ToString.Substring(0, 8) + " " + currentSystemTime.Date
ElseTextBox1.Text = x & " Cannot add more data"
End IfEnd If
'execute sql commandcommand = New OdbcCommand(strsql, MyConnection)command.ExecuteReader()x = "" 'clear value x
End IfEnd Sub
(12.4.11) Double click on the btnSearch button. Add the following code into
subprogram btnSearch_Click.
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles btnSearch.Click
'execute sql select value input in db_employeestrsql = "SELECT tb_in.id_in as Id ,tb_in.date_in as date ,tb_in.time_in
as In_time ,tb_out.time_out as Out_time FROM tb_in,tb_out WHERE tb_in.id_in=’"+ txtS earc h.Te xt + "‘ and tb_ in.i d_in =tb_ out. id_o ut a ndtb_in.date_in=tb_out.date_out ORDER BY date DESC "
command = New OdbcCommand(strsql, MyConnection)reader = command.ExecuteReader()num = reader.RecordsAffected
' no value in databaseIf num <= 0 Then
rtxtDataReceived.Text = "Can not Search Value Input"
' have value in databaseElse
rtxtDataReceived.Clear() 'clear rich textrtxtDataReceived.AppendText(" ID Date Time_In
Time_out" + Environment.NewLine) ‘print value on richtext
While (reader.Read()) 'next rowrtxtDataReceived.AppendText(reader.GetValue(0).ToString + " " +
reader.GetValue(1).ToString.Substring(0, 9) + " " + reader.GetValue(2).ToString+ " " + reader.GetValue(3).ToString + Environment.NewLine)
End WhileEnd If
End Sub
To searching data from the txtSearch; use select instruction and select only id,
date, time_in and time_out. Search in both table ; tb_in and tb_out by using the
same date and same ID. After that, display the searching ID with reader.Read()
instruction in row and reader.GetValue(0).ToString to select the message in each
column. Includes : id, date, time_in and time_out. (column 0, 1, 2 and 3 respectively)
Easy RFID Education kit documentation 51
(12.4.12) Double click on the btnPrint button to make the addition code in
subprogram ; btnPrint_Click as follows :
Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles btnPrint.Click ' Allow the user to choose the page range he or she would like to print.
PrintDialog1.AllowSomePages = True 'Show the help button.PrintDialog1.ShowHelp = True
' Set the Document property to the PrintDocument for ' which the PrintPage Event has been handled. To display the ' dialog, either this property or the PrinterSettings property ' must be set
PrintDialog1.Document = PrintDocument1Dim result As DialogResult = PrintDialog1.ShowDialog() 'show dialog print
If result = DialogResult.OK Then ‘ If the result is OK then print the document.PrintDocument1.Print()
End IfEnd Sub
' The PrintDialog will print the document' by handling the document’s PrintPage event.Private Sub document_PrintPage(ByVal sender As Object, ByVal e As
System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
' Insert code to render the page here. ' This code will be called when the control is drawn.
' The following code will render a simple message on the printed document. ' Dim text As String = "In document_PrintPage method."
Dim printFont As New System.Drawing.Font(“Arial”, 22, System.Drawing.FontStyle.Regular)' Draw the content.e.Graphics.DrawString(rtxtDataReceived.Text, printFont, System.Drawing.Brushes.Black,
10, 10)End Sub
(12.4.13) The complete code is shown in the Listing 12-1. Run the code. The main
window of this code is shown in the figure 12-1
Figrue 12-1 RFID logger program
52 Easy RFID Education kit documentation
Imports System.Data.OdbcImports System.Drawing.Printing
Public Class Form1Dim WithEvents serialPort As New IO.Ports.SerialPortDim x As String = "" ' save value form serial portDim command As New OdbcCommand' command for insertSQL string contains a SQL statement that
Dim reader As OdbcDataReader ' for execute command sqlDim MyConString As String ' string value for connect mysqlDim num As Integer ' save row sql executeDim MyConnection As New OdbcConnection' MyConnection value connect mysql
Dim strsql As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles MyBase.Load
' connect mysqlMyConString = "DRIVER={MySQL ODBC 3.51 Driver};" + "SERVER=localhost;" +
"DATABASE=db_employee;" + "UID=root;" + "PASSWORD=1234;" + "OPTION=3;"
MyConnection.ConnectionString = MyConStringMyConnection.Open() 'check port connect and add value on cbbCOMPortsFor i As Integer = 0 To _
My.Computer.Ports.SerialPortNames.Count - 1cbbCOMPorts.Items.Add(_My.Computer.Ports.SerialPortNames(i))
NextbtnDisconnect.Enabled = False
End Sub
Private Sub btnConnect_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles btnConnect.Click
If serialPort.IsOpen ThenserialPort.Close()
End IfTry 'set value serialport for connect
With serialPort.PortName = cbbCOMPorts.Text
.BaudRate = 9600.Parity = IO.Ports.Parity.None.DataBits = 8.StopBits = IO.Ports.StopBits.One
End WithserialPort.Open() ' open serialportlblMessage.Text = cbbCOMPorts.Text & " connected." 'change text of labelbtnConnect.Enabled = False 'btnConnect disable clickbtnDisconnect.Enabled = True 'btnDisconnect enable click
Catch ex As ExceptionMsgBox(ex.ToString)
End TryEnd Sub
Listing 12-1 : Source code of the RFID Logger program. This code is written
by Visual BASIC Express 2010 (continue)
Easy RFID Education kit documentation 53
Listing 12-1 : Source code of the RFID Logger program. This code is written
by Visual BASIC Express 2010 (continue)
Private Sub btnDisconnect_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles btnDisconnect.Click
Try ' close serailportserialPort.Close()lblMessage.Text = serialPort.PortName & " disconnected."
' change text of labelbtnConnect.Enabled = True ' btnConnect enable clickbtnDisconnect.Enabled = False ' btnDisconnect disable click
Catch ex As ExceptionMsgBox(ex.ToString)
End TryEnd Sub
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles btnSearch.Click
'execute sql select value input in db_employeestrsql = "SELECT tb_in.id_in as Id ,tb_in.date_in as date ,tb_in.time_in
as In_time ,tb_out.time_out as Out_time FROM tb_in,tb_out WHERE tb_in.id_in=’"+ txtS earc h.Te xt + "‘ and tb_ in.i d_in =tb_ out. id_o ut a ndtb_in.date_in=tb_out.date_out ORDER BY date DESC "
command = New OdbcCommand(strsql, MyConnection)reader = command.ExecuteReader()num = reader.RecordsAffected
' no value in databaseIf num <= 0 Then
rtxtDataReceived.Text = "Can not Search Value Input"
' have value in databaseElse
rtxtDataReceived.Clear() 'clear rich textrtxtDataReceived.AppendText(" ID Date Time_In
Time_out" + Environment.NewLine) ‘print value on richtext
While (reader.Read()) 'next rowrtxtDataReceived.AppendText(reader.GetValue(0).ToString + " " +
reader.GetValue(1).ToString.Substring(0, 9) + " " + reader.GetValue(2).ToString+ " " + reader.GetValue(3).ToString + Environment.NewLine)
End WhileEnd If
End Sub
Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles btnPrint.Click ' Allow the user to choose the page range he or she would like to print.
PrintDialog1.AllowSomePages = True 'Show the help button.PrintDialog1.ShowHelp = True
' Set the Document property to the PrintDocument for ' which the PrintPage Event has been handled. To display the ' dialog, either this property or the PrinterSettings property ' must be set
PrintDialog1.Document = PrintDocument1Dim result As DialogResult = PrintDialog1.ShowDialog() 'show dialog print
If result = DialogResult.OK Then ‘ If the result is OK then print the document.PrintDocument1.Print()
End IfEnd Sub
54 Easy RFID Education kit documentation
Listing 12-1 : Source code of the RFID Logger program. This code is written
by Visual BASIC Express 2010 (continue)
' The PrintDialog will print the document' by handling the document’s PrintPage event.Private Sub document_PrintPage(ByVal sender As Object, ByVal e As
System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
' Insert code to render the page here. ' This code will be called when the control is drawn.
' The following code will render a simple message on the printed document. ' Dim text As String = "In document_PrintPage method."
Dim printFont As New System.Drawing.Font(“Arial”, 22, System.Drawing.FontStyle.Regular)' Draw the content.e.Graphics.DrawString(rtxtDataReceived.Text, printFont, System.Drawing.Brushes.Black,
10, 10)End Sub
' data received go to DataReceivedPri vate Sub DataReceived(ByVal sender As Object, ByVal e As
System.IO.Ports.SerialDataReceivedEventArgs) Handles serialPort.DataReceived
' update data go to updateTextBoxrtxtDataReceived.Invoke(New myDelegate(AddressOf updateTextBox), New Object() {})
End Sub
Public Delegate Sub myDelegate()
Public Sub updateTextBox()Dim currentSystemTime As DateTime = DateTime.Now ' date and time nowx = x + serialPort.ReadExisting ' save data form serialport in xIf x.Length >= 10 Then ' check length data >=10 ok
x.Substring(0, 10) ' substring 0-10
' select input with database for check in or outstrsql = “select * from tb_in where id_in='" + x + "' and date_in='" +
currentSystemTime.Year.ToString + "-" + currentSystemTime.Month.ToString + "-"+ currentSystemTime.Day.ToString + "'"
' execute sql commandcommand = New OdbcCommand(strsql, MyConnection)reader = command.ExecuteReader()num = reader.RecordsAffected
If num <= 0 Then ' if no check in insert data in tb_instrsql = "INSERT INTO tb_in VALUES (‘" + x + "‘, ‘" +
currentSystemTime.TimeOfDay.ToString.Substring(0, 8) + "‘, ‘" +currentSystemTime.Year.ToString + "-" + currentSystemTime.Month.ToString + "-"+ currentSystemTime.Day.ToString + "')"
Tex tBox 1.Te xt = "In " + x + " " +currentSystemTime.TimeOfDay.ToString.Substring(0, 8) + " " +currentSystemTime.Date
Else ' if check out select check outstrsql = "select * from tb_out where id_out='" + x + "' and
date_out='" + currentSystem Time .Yea r.To Stri ng + "-" +currentSystemTime.Month.ToString + "-" + currentSystemTime.Day.ToString + "‘"
command = New OdbcCommand(strsql, MyConnection)reader = command.ExecuteReader()num = reader.RecordsAffected
Easy RFID Education kit documentation 55
Listing 12-1 : Source code of the RFID Logger program. This code is written
by Visual BASIC Express 2010 (final)
If num <= 0 Then' insert data in tb_outstrsql = “INSERT INTO tb_out VALUES ('" + x + "', ‘" +
currentSystemTime.TimeOfDay.ToString.Substring(0, 8) + "', ‘" +currentSystemTime.Year.ToString + "-" + currentSystemTime.Month.ToString +"-" +currentSystemTime.Day.ToString + "')"
Te xtBo x1.T ext = "O ut " + x + " " +currentSystemTime.TimeOfDay.ToString.Substring(0, 8) + " " +currentSystemTime.Date
ElseTextBox1.Text = x & " Cannot add more data"
End IfEnd If
' execute sql commandcommand = New OdbcCommand(strsql, MyConnection)command.ExecuteReader()x = "" ' clear value x
End IfEnd Sub
End Class
12.5 Microcontroller code
Open the BASIC Stamp editor to create the code following the Listing 12-2.
Download this to i-Stamp2P microcontroller. Use the circuit and connection diagram
same the experiment 3.
' {$STAMP BS2p}
' {$PBASIC 2.5}
m VAR Byte (10)
LOW 2
main :
SERIN 3, 1021, [WAIT($0A),STR m\10]
FREQOUT 4,1000,1000 'output sound on port 4
SEROUT 16, 240, [STR m\10]
PAUSE 2000
GOTO Main
Listing 12-2 : RFIDreader.bsp; Read the RFID tag to show on the RFID logger
software that created by Visual BASIC express 2010
56 Easy RFID Education kit documentation
12.6 Testing
(12.6.1) Run the VB express 2010 code and microcontroller code. The RFID logger
software window will appear. Select the connected COM port.
(12.6.2) Place the RFID tag over the RFID reader. See the operation at the RFID
program window.
ID of RFID tag is read and show in the program following the figure 12-2.
The first reading is Check-in time of the current date.
(12.6.3) Read the same RFID tag again.
ID of RFID tag is read and show in the program following the figure 12-3.
The second reading is Check-out time of the current date.
Figrue 12-2 RFID logger software with
check-in RFID tagFigrue 12-3 RFID logger software with
check-out RFID tag
Easy RFID Education kit documentation 57
(12.6.4) Next,try to serach the RFID tag record. Type the ID of the register tag in
Search box. Click on the Search button. The database of this tag is shown in the figure
12-4.
Figrue 12-4 RFID logger software with the
registered RFID tag data
(12.6.5) User can print this data. Click on the Print button to print to the target
printer following the figure 12-5.
You can add more RFID tags data that you want. The maximum record are
depended on the computer memory storage.
Figrue 12-5 RFID logger software with the
print window for printing the registered
RFID tag data
That is the simple application of RFID system. It includes the RFID
reader hardware, microcontroller to control the operation and interface
with computer. At the computer side, requires the suitable software that
includes database management and microcontroller interfacing.
58 Easy RFID Education kit documentation