You are on page 1of 101

PSZ 19:16 (Pind.

1/97)
UNIVERSITI TEKNOLOGI MALAYSIA

BORANG PENGESAHAN STATUS TESIS


J UDUL: CAR PARK CONTROL SYSTEM:
INTERFACE RFID TO PIC USING SERIAL PORT

SESI PENGAJIAN: 2006/2007

Saya AHMAD DZAFIR BIN JOHARI

(HURUF BESAR)

mengaku membenarkan tesis (PSM/Sarjana/Doktor Falsafah)* ini disimpan di Perpustakaan
Universiti Teknologi Malaysia dengan syarat-syarat kegunaan seperti berikut:


1. Tesis adalah hakmilik Universiti Teknologi Malaysia.
2. Perpustakaan Universiti Teknologi Malaysia dibenarkan membuat salinan untuk tujuan
pengajian sahaja.
3. Perpustakaan dibenarkan membuat salinan tesis ini sebagai bahan pertukaran antara
institusi pengajian tinggi.
4. **Sila tandakan ( )


(Mengandungi maklumat yang berdarjah keselamatan atau

kepentingan Malaysia seperti yang termaktub di dalam









Disahkan oleh



(TANDATANGAN PENULIS) (TANDATANGAN PENYELIA)

Alamat Tetap:
255, JLN. DAMAI 1,
TMN. DAMAI, EN. MOHD. AFZAN OTHMAN
81400, SENAI, JOHOR. Nama Penyelia

Tarikh: 23 NOVEMBER 2007 Tarikh: 23 NOVEMBER 2007


SULIT
AKTA RAHSIA RASMI 1972)
TERHAD
(Mengandungi maklumat TERHAD yang telah ditentukan
oleh organisasi/badan di mana penyelidikan dijalankan)
TIDAK TERHAD



CATATAN: * Potong yang tidak berkenaan.


** J ika tesis ini SULIT atau TERHAD, sila lampirkan surat daripada pihak
berkuasa/organisasi berkenaan dengan menyatakan sekali sebab dan
tempoh tesis ini perlu dikelaskan sebagai SULIT atau TERHAD.
Tesis dimaksudkan sebagai tesis bagi Ijazah Doktor Falsafah dan Sarjana secara
penyelidikan, atau disertasi bagi pengajian secara kerja kursus dan penyelidikan,
atau Laporan Projek Sarjana Muda (PSM).











I certify that I have read this project, and in my opinion, it is fully adequate, in scope
and quality, as dissertation for the Degree in Bachelor of Electrical Engineering
(Electronics).







Signature : ....................................................




Supervisor : MOHD. AFZAN BIN OTHMAN
Date : 23 NOVEMBER 2007














CAR PARK CONTROL SYSTEM:
INTERFACE RFID TO PIC USING SERIAL PORT




AHMAD DZAFIR BIN JOHARI




This thesis is submitted in compliance with
the requirements for the award of the
Degree in Bachelor of Electrical Engineering (Electronics)




FACULTY OF ELECTRICAL ENGINEERING
UNIVERSITY OF TECHNOLOGY MALAYSIA




NOVEMBER, 2007






ii




DECLARATION




I declared that this thesis entitled CAR PARK CONTROL SYSTEM:
INTERFACE RFID TO PIC USING SERIAL PORT is the result of my own
efforts. Any materials that are not the effort of mine have been stated clearly.






Signature :
Author : AHMAD DZAFIR BIN J OHARI
Date : 23 NOVEMBER 2007
















iii




DEDICATION











To my beloved mother and father
















iv




ACKNOWLEDGEMENT




First of all, thanks to the Mighty God for giving me the strength to finish this
final project (PSM).


During this project, I receive contribution and support from many people. In
particular, I would like to express my thanks to my supervisor, Mr. Mohd. Afzan bin
Othman for his ideas, encouragement and guidance.


Besides, I would like take this opportunity to thank all my friends, in
particular Mr. J epri bin Mustafa, Sahasuhana binti Shahadan and Ab. Al-Hakam bin
Abd. Aziz for their technical support and moral guidance.


Last but not least, I would like to thank my family members and my love for
their support and blessings.
v




ABSTRACT




With the high number of student register each year and it increasing yearly,
the number of parking space in Faculty of Electrical Engineering (FKE) is becoming
more crowded. The construction of the parking spaces cannot be done only in one
year. It takes proper planning because the faculty location is at the hillside. Although
the staff has their own parking space and it marks by a yellow line, students often use
the parking space because it is near to the classroom buildings. So this project was
built to make the staff parking spaces cannot be invade by others. This project is
consisting of two main parts, hardware and software. As for the software, it has two
separate parts; a database system and the identifying system. The database is handled
only by the assigned administrator (e.g. clerk) with a fix login password. This is for
the security measure for safety of the data from being hacked. The database system
holds the staff (user) information such as Staff No. and Staff Name. It also
includes the ID-TAG number that will be matched after the user database is
complete. The second part of the software is to identify either a valid or invalid user
was tagged at the RFID READER. The identification is done by comparing the
tagged ID-TAG number to the database. In the hardware part, this project is using the
Programmable Intelligent Computer (PIC) microcontroller for the user to know either
they can enter the parking space. If a valid user tagged, the PIC will on the GREEN
LED, but if an invalid user tagged, the PIC will on the RED LED.
vi




ABSTRAK




Dengan kemasukan pelajar yang tinggi pada setipa tahun dan bilangannya
meningkat, bilangan tempat letak kereta di Fakulti Kejuruteraan Elektrik (FKE) akan
menjadi semakin sesak. Untuk membuat tempat letak kereta akan memakan masa
lebih dari setahun kerana ia memerlukan perangcangan yang teliti kerana FKE
terletak di lereng bukit. Walaupun staf FKE mempunyai tempat letak kereta yang
ditanda dengan garisan kuning, tetapi boleh juga digunakan oleh para pelajar. Maka
projek ini dibina supaya para pelajar tidak dapat menggunakan tempat letak kereta
yang telah dikhaskan untuk staf. Projek ini terbahagi kepada dua bahagian utama,
perkakasan dan perisian. Bagi perisian, terdapat dua bahagian; pengkalan data dan
pengesahan data. Pengkalan data akan diselenggara hanya oleh pegawai yang telah
dilantik (contoh: kerani) dimana ia mempunyai kata laluan yang tetap. Ini adalah atas
sebab-sebab keselamatan daripada pengkalan data diceroboh. Pada pengkalan data
terdapat maklumat berkenaan staf (pengguna) seperti Staff No. dan Staff Name. Ia
juga mempunyai maklumat berkenaan nombor ID-TAG yang akan diselarikan
apabila maklumat pengguna lengkap diisi. Bahagian pengesahan data adalah untuk
mengesahkn samada pengguna yang melekapkan TAG ID itu sah ataupn tidak sah.
Proses pengesahan ini dilakukan dengan membandingkan nombor ID-TAG yang
dilekapkan dengan pengkalan data. Projek ini menggunakan perkakasan utama iaitu
mikropengawal Programmable Intelligent Computer (PIC). PIC digunakan untuk
menyalakan GREEN LED untuk pengguna yang sah dan menyalakan RED LED
untuk pengguna yang tidak sah.

vii




TABLE OF CONTENTS




CHAPTER TITLE PAGE

PROJECT TITLE i
DECLARATION ii
DEDICATION iii
ACKNOWLEDGEMENT iv
ABSTRACT v
ABSTRAK vi
TABLE OF CONTENTS vii
LIST OF FIGURES xi
LIST OF TABLE xiv
LIST OF APPENDIXES xv


I INTRODUCTION 1
1.1 Problem Statement 1
1.2 Solution 2
1.3 Objectives 3
1.4 Scope of Work 3





viii
II LITERATURE REVIEW 5
2.1 RFID 5
2.1.1 RFID Tags 6
2.1.1.1 Passive Tags 6
2.1.1.2 Active Tags 7
2.1.2 RFID Frequency 8
2.1.3 Current use Passport 9
2.1.4 RFID Beginners Kit 9
2.2 PIC Microcontroller 11
2.2.1 PIC Family Core Architectural 12
2.2.2 PIC 16F84A 13
2.3 Serial Port 16
2.3.1 Speed 18
2.3.2 Data Bits 18
2.4 Visual Basic 6 19
2.5 Microsoft Access 20
2.5.1 Uses 20


III METHODOLOGY 22
3.1 Introduction 22
3.2 Database Interface 23
3.2.1 ActiveX Data Object (ADO) 23
3.2.2 Microsoft Access Table Staff 25
3.2.2.1 Step to convert Microsoft 26
Access Application file
3.2.3 Link ADO with rfid.mdb 28
3.2.4 Staff Identification 30
3.3 Connection VB6 to RFID READER 31
3.3.1 Microsoft Comm. Control 6.0 31
3.3.2 InRFID 125Ctrl ActiveX Control 32
module


ix
3.4 Connection to PIC16F84A 33
3.4.1 Connection from PIC to MAX232 36
to PC
3.5 Programming PIC16F84A 37
3.5.1 The PIC16F84A program 38
3.5.2 MPLAB IDE 39
3.5.3 ICPROG 40


IV APPLICATION 41
4.1 Introduction 41
4.2 Database 42
4.2.1 Admin 42
4.2.2 Staff Registration 45
4.2.3 Staff Identification 47
4.2.4 User Guide 50
4.2.5 RFID ID-Tag 51
4.2.6 Example 53
4.3 Identify 55
4.4 PIC Circuit 58


V RESULT AND DISCUSSION 61
5.1 Results 61
5.1.1 Interface VB6 to RFID READER 62
5.1.2 Identify User 63
5.1.3 Connecting PIC16F84A to PC 65
5.2 Discussion 65






x
VI CONCLUSION 67
6.1 Conclusion 67


REFERENCES 68


APPENDIX 69


xi




LIST OF FIGURES




FIGURE NO. TITLE PAGE


1.1 System Flow Diagram 4

2.1 InRFID Beginners Kit System Diagram 10

2.2 InRFID Beginners Kit complete set 11

2.3 The PIC16F84A block diagram 15

2.4 PIC16F84A Pin Diagram 15

2.5 Pinout Description 16

2.6 Pin designations on RS232 connector 17

3.1 Adodc1 interface 24

3.2 Example of Data Source and Data Field 24


3.3 Flow diagram of steps to convert Microsoft Access 27
Application file to an .mdb format

xii
3.4 ADO Component 28

3.5 Property Pages 29

3.6 MSComm interface 32

3.7 InRFIDCtrl interface 33

3.8 MAX232 pin diagram 34

3.9 RS232 receiver and TTL input 35

3.10 RS232 transmitter and TTL output 35

3.11 Connection from PIC to MAX232 to PC 36

3.12 Circuit diagram for I/O pins used 38

3.13 The main program in an .asm code 39

3.14 ICPROG programmer 40

4.1 The password is correct 42

4.2 Wrong password entered 43

4.3 Times up 44

4.4 Clock coding times up 44

4.5 Staff Registration form 45

4.6 Secure measure if exit 46

xiii
4.7 The Staff Registration form 48

4.8 Clock coding present time 49

4.9 User Guide form 50

4.10 User without an ID-TAG number 51

4.11 User has been match with an ID-TAG number 52

4.12 Sample coding for RFID READER 53
connection to VB6

4.13 The Example form 54

4.14 Valid ID-TAG tagged 56

4.15 Invalid ID-TAG tagged 56

4.16 Sample coding for identifying 57

4.17 User Confirmation flow 58

4.18 PIC Circuit diagram 60

5.1 Result of the ID-TAG shown in the 62
TAG ID text column

5.2 Result of the confirmation as a VALID user 63

5.3 Result of the confirmation as a INVALID user 64
xiv




LIST OF TABLES




TABLE NO. TITLE PAGE


2.1 The features list of PIC16F84A 14

4.1 PIC Circuit component 59

xv




LIST OF APPENDIXES




APPENDIX TITLE PAGE


A VISUAL BASIC 6 SOURCE CODE 69

B PIC16F84A SOURCE CODE 79

C DATA SHEET AND MANUAL 84






CHAPTER I




INTRODUCTION




1.1 Problem Statement


In this new millennium most students have a vehicle of their own, mostly with
motorcycle and car. So few uses the transport that the university has provided, which
is buses transportation. Thats what happens in our university, University
Technology of Malaysia (UTM). UTM Skudai has an average number of students,
not include at UTM CITY CAMPUS which in Kuala Lumpur (KL), estimate around
30 000 students. In this situation, the vehicle that was uses by students is being
separated with the staff vehicle for parking spaces. The staff will be given specific
parking spaces that cannot be used by the student.


The students also need parking spaces, but in UTM the parking spaces that
available for the students is very limited. In that case, few of them were using the
staff parking spaces. This is because the staff parking spaces were not fully protected.
It just has blue signboard says Parking For Staff Only.


2
In Faculty of Electrical Engineering (FKE) have at least 160 of academic and
90 non-academic staff. Thats a total of 250 staff member in FKE. Most of the staff
has more than 1 vehicle and each day it rotates. FKE also has a big number of
students, which is more than 3000 students including studying bachelor and master.


The problems occur when 3000 student and 250 staff want to park in a limited
parking space available. In FKE there were less than 300 parking spaces available.
Most of the parking spaces were for cars.




1.2 Solution


A system was built to solve this problem. Using Radio Frequency
Identification (RFID) as the key to enter the parking spaces it will allow only a
registered or valid user can enter the parking spaces. This system will facilitate the
staff so that their parking spaces will not be intruded.


This system has the staff identification database that is control by assigned
administrator. Only this administrator can insert or edit the database. This means that
the system will secure all staff identification registered and only registered staff will
be given the RFID TAG as a key to enter the parking spaces.


The databases were built using Visual Basic 6 (VB6) and link with Microsoft
Access as the database source. It can be use only to assigned administrator because it
has a fix password to login. This system called Car Park Control System : Interface
RFID to PIC via Serial Port.


3
1.3 Objective


The main objective for this project is to build a system that can save and load a
data of users and match it with the RFID TAG so that only a valid user can enter the
parking spaces. The RFID READER were connected to VB6 via serial connection
were built to match the Staff No. and the RFID TAG. The RFID READER also being
connected to VB6 to identify either valid or invalid user. Then to send signal from
VB6 to the Programmable Interrupt Controller (PIC) to on either GREEN LED
(valid) or RED LED (invalid).




1.4 Scope of work


This project is divided into four phases. First phase is built database interface
with VB6. The second phase is establishing connection from RFID READER to
VB6. The third phase is establishing connection from VB6 to PIC. The last phase is
program the PIC to on either GREEN LED or RED LED.


VB6 is use as a Graphical User Interface (GUI) for this system. In this system,
VB6 is the main host to save the user data and to verify the correct or incorrect user.
It also used as the interface for serial connection for both RFID READER and to the
PIC circuit. From VB6, the RFID TAG number will appear and it can be match to the
valid user. VB6 also will show the user identification that was already registered.


The second phase is establishing connection from RFID READER to VB6. It
is for matching the user identification (USER ID) with the RFID TAG number. Each
user will be given a different ID TAG with different RFID TAG number in it. The
connection is established via serial port, either COM1 or COM2.
4
The third phase is establishing connection from VB6 to PIC. The connection
is via serial port. VB6 will receive the RFID TAG number from the RFID READER
and compare it to the database in Microsoft Access and determined either the user is
valid or invalid. Only valid (registered) user can enter the parking spaces.


The fourth or last phase is program the PIC to on either GREEN LED or RED
LED. This system will use PIC16F84A. This PICs is widely use because it is simple
(has only 18 pin) and suitable for a short program. PIC16F84A is connecting to serial
port through MAX232. The system flow is shown in the Figure 1.1.




RFI D READER
PI C16F84
GREEN LED
& RED LED
VI SUAL BASI C 6
( COMPUTER)
Figure 1.1 : System Flow Diagram




CHAPTER II




LITERATURE REVIEW




2.1 RFID


Radio-frequency identification (RFID) is an automatic identification method,
relying on storing and remotely retrieving data using devices called RFID tags or
transponders. An RFID tag is an object that can be applied to or incorporated into a
product, animal, or person for the purpose of identification using radio waves. Some
tags can be read from several meters away and beyond the line of sight of the reader.


Most RFID tags contain at least two parts. One is an integrated circuit for
storing and processing information, modulating and demodulating a (RF) signal and
can also be used for other specialized functions. The second is an antenna for
receiving and transmitting the signal. A technology called chip less RFID allows for
discrete identification of tags without an integrated circuit, thereby allowing tags to
be printed directly onto assets at lower cost than traditional tags.

Today, a significant thrust in RFID use is in enterprise supply chain
management, improving the efficiency of inventory tracking and management.
However, a threat is looming that the current growth and adoption in enterprise
6
supply chain market will not be sustainable. A fair cost-sharing mechanism, rational
motives and justified returns from RFID technology investments are the key
ingredients to achieve long-term and sustainable RFID technology adoption.




2.1.1 RFID Tags


RFID tags come in three general varieties: passive, active, or semi-passive
(also known as battery-assisted). Passive tags require no internal power source, thus
being pure passive devices (they are only active when a reader is nearby to power
them), whereas semi-passive and active tags require a power source, usually a small
battery.


To communicate, tags respond to queries generating signals that must not
create interference with the readers, as arriving signals can be very weak and must be
told apart. Besides backscattering, load modulation techniques can be used to
manipulate the reader's field. Typically, backscatter is used in the far field, whereas
load modulation applies in the near field, within a few wavelengths from the reader.




2.1.1.1 Passive Tags


Passive RFID tags have no internal power supply. The minute electrical
current induced in the antenna by the incoming radio frequency signal provides just
enough power for the CMOS integrated circuit in the tag to power up and transmit a
response. Most passive tags signal by backscattering the carrier wave from the
reader. This means that the antenna has to be designed to both collect power from the
7
incoming signal and also to transmit the outbound backscatter signal. The response of
a passive RFID tag is not necessarily just an ID number; the tag chip can contain
non-volatile, possibly writable EEPROM for storing data.




2.1.1.2 Active Tags


Unlike passive RFID tags, active RFID tags have their own internal power
source, which is used to power the integrated circuits and broadcast the signal to the
reader. Active tags are typically much more reliable (i.e. fewer errors) than passive
tags due to the ability for active tags to conduct a "session" with a reader. Active
tags, due to their onboard power supply, also transmit at higher power levels than
passive tags, allowing them to be more effective in "RF challenged" environments
like water (including humans/cattle, which are mostly water), metal (shipping
containers, vehicles), or at longer distances, generating strong responses from weak
requests (as opposed to passive tags, which work the other way around). In turn, they
are generally bigger and more expensive to manufacture, and their potential shelf life
is much shorter.


Many active tags today have practical ranges of hundreds of meters, and a
battery life of up to 10 years. Some active RFID tags include sensors such as
temperature logging which have been used to monitor the temperature of perishable
goods like fresh produce or certain pharmaceutical products. Other sensors that have
been married with active RFID include humidity, shock/vibration, light, radiation,
temperature, and atmospherics like ethylene. Active tags typically have much longer
range (approximately 500 m/1500 feet) and larger memories than passive tags, as
well as the ability to store additional information sent by the transceiver. The United
States Department of Defense has successfully used active tags to reduce logistics
costs and improve supply chain visibility for more than 15 years.

8
2.1.2 RFID Frequency


Low-frequency (LF: 125 134.2 kHz and 140 148.5 kHz) and high-
frequency (HF: 13.56 MHz) RFID tags can be used globally without a license. Ultra-
high-frequency (UHF: 868 MHz-928 MHz) cannot be used globally as there is no
single global standard. In North America, UHF can be used unlicensed for 902 928
MHz (13 MHz from the 915 MHz center frequency), but restrictions exist for
transmission power. In Europe, RFID and other low-power radio applications are
regulated by ETSI recommendations EN 300 220 and EN 302 208, and ERO
recommendation 70 03, allowing RFID operation with somewhat complex band
restrictions from 865868 MHz.


Readers are required to monitor a channel before transmitting ("Listen Before
Talk"); this requirement has led to some restrictions on performance, the resolution
of which is a subject of current research. The North American UHF standard is not
accepted in France as it interferes with its military bands. For China and J apan, there
is no regulation for the use of UHF. Each application for UHF in these countries
needs a site license, which needs to be applied for at the local authorities, and can be
revoked. For Australia and New Zealand, 918 926 MHz is unlicensed, but
restrictions exist for transmission power.


These frequencies are known as the ISM bands (Industrial Scientific and
Medical bands). The return signal of the tag may still cause interference for other
radio users.







9
2.1.3 Current use - Passport


RFID tags are being used in passports issued by many countries. The first
RFID passports ("E-passport") were issued by Malaysia in 1998. In addition to
information also contained on the visual data page of the passport, Malaysian e-
passports record the travel history (time, date, and place) of entries and exits from the
country.


Standards for RFID passports are determined by the International Civil
Aviation Organization (ICAO), and are contained in ICAO Document 9303, Part 1,
Volumes 1 and 2 (6th edition, 2006). ICAO refers to the ISO 14443 RFID chips in e-
passports as "contact less integrated circuits". ICAO standards provide for e-
passports to be identifiable by a standard e-passport logo on the front cover.


In 2006, RFID tags were included in new US passports. The US produced 10
million passports in 2005, and it has been estimated that 13 million will be produced
in 2006. The chips will store the same information that is printed within the passport
and will also include a digital picture of the owner. The passports will incorporate a
thin metal lining to make it more difficult for unauthorized readers to "skim"
information when the passport is closed.




2.1.4 RFID Beginners Kit


In this project, InRFID Beginners Kit is use. This kits has InRFIDCtrl
Control software. InRFIDCtrl Control is a software development kit to aid
development of RFID based application. Application written in MS-Visual Basic and
10
MS-Visual C++can make use to this control to extend its functionality by
implementing RFID based features.


The InRFID Beginners Kit system diagram is shown in Figure 2.1 and the
InRFID Beginners Kit complete set shown in Figure 2.2.



Figure 2.1 : InRFID Beginners Kit System Diagram













From the system diagram, the application of InRFID Beginners Kit starts
with the RFID TAGS tag to the RFID READER and scans it. The RFID READER
can read different type of tags such as ISO 15693, ICODE1, TagIt and etc. Then after
InRFIDCtrl identify the tags, it can be use in many application using MS-Visual
Basic or MS-Visual C++.







11


Figure 2.2 : InRFID Beginners Kit complete set











2.2 PIC Microcontroller


PIC is a family of Harvard architecture microcontrollers made by Microchip
Technology, derived from the PIC1650 originally developed by General Instrument's
Microelectronics Division. The name PIC was originally an acronym for
"Programmable Intelligent Computer".


PICs are popular with developers and hobbyists alike due to their low cost,
wide availability, large user base, extensive collection of application notes,
availability of low cost or free development tools, and serial programming (and re-
programming with flash memory) capability.


The PIC architecture is distinctively minimalist. It is characterized by the
following features with separate code and data spaces (Harvard architecture). Has a
small number of fixed length instructions. Most instructions are single cycle
execution (4 clock cycles), with single delay cycles upon branches and skips. Has a
single accumulator (W), the use of which (as source operand) is implied (i.e. is not
encoded in the opcode). All RAM locations function as registers as both source
12
and/or destination of math and other functions. Has a hardware stack for storing
return addresses also has a fairly small amount of addressable data space (typically
256 bytes), extended through banking. Data space mapped CPU, port, and peripheral
registers. The program counter is also mapped into the data space and writable (this
is used to synthesize indirect jumps).


Unlike most other CPUs, there is no distinction between "memory" and
"register" space because the RAM serves the job of both memory and registers, and
the RAM is usually just referred to as the register file or simply as the registers.




2.2.1 PIC Family Core Architectural


PIC can be divided into several family core architectural. There are three
main family core. That is baseline core, mid-range core and high end core.


Baseline core devices is feature a 12-bit wide code memory, and a tiny two
level deep call stack. They are represented by PIC10 series, as well as some PIC12
and PIC16 devices. Baseline devices are available in 6-pin to 40-pin packages.


Mid-Range core devices is feature a 14-bit wide code memory, and an
improved 8 level deep call stack. The instruction set differs very little from the
baseline devices, but the increased opcode width allows more memory to be directly
addressed. The mid-range core is available in the majority of devices labeled PIC12
and PIC16.


13
High end core devices are 17 series never became popular and has been
superseded by the PIC18 architecture. It is not recommended for new designs, and
may be in limited availability.


Improvements over earlier cores are 16-bit wide opcodes (allowing many new
instructions), and a 16 level deep call stack. PIC17 devices were produced in
packages from 40 to 68 pins.




2.2.2 PIC 16F84A


In this project, PIC16F84A will be use. PIC16F84A is in either baseline core
or mid-range core devices in the PICs family core architecture. PIC16F84A also
have enhanced core features, eight-level deep stack, and multiple internal and
external interrupt sources. The separate instruction and data buses of Harvard
architecture allow a 14-bit wide instruction word with a separate 8-bit wide data bus.
The two stage instruction pipeline allows all instructions to execute in a single cycle,
except for program branches which require two cycles. A total of 35 instructions are
available.


PIC16F84A also has up to 68 bytes of RAM, 64 bytes of Data EEPROM
memory and 13 I/O pins. A timer/counter is also available. The features of
PIC16F84A are list in Table 2.1. The PIC16F84A block diagram is shown in Figure
2.3. The PIC16F84A pin diagram is shown in Figure 2.4.


PIC16F84A contain an 8-bit ALU and working register. The ALU is general
purpose arithmetic unit. It performs arithmetic and Boolean functions between data
in the working register and any register file.
14
The ALU is 8-bit wide and capable of addition, subtraction, shift and logical
operations. Unless otherwise mentioned, arithmetic operations are twos complement
in nature. In two-operand instructions, typically one operand is the working register
(W register) and the other operand is a file register or an immediate constant. In
single operand instructions, the operand is either the W register or a file register.


The W register is an 8-bit working register used for ALU operations. It is not
an addressable register. In Figure 2.5 shows the PICs pin out description.



Table 2.1 : The features list of PIC16F84A






















15


Figure 2.3 : The PIC16F84A block diagram.


















Figure 2.4 : PIC16F84A Pin Diagram














16

Figure 2.5 : Pinout Description






















2.3 Serial Port


In computing, a serial port is a serial communication physical interface
through which information transfers in or out one bit at a time (contrast parallel port).
Throughout most of the history of personal computers, data transfer through serial
ports connected the computer to devices such as terminals or modems. Mice,
keyboards, and other peripheral devices also connected in this way.


17
While such interfaces as Ethernet, FireWire, and USB all send data as a serial
stream, the term "serial port" usually identifies hardware more or less compliant to
the RS-232 standard, intended to interface with a modem or with a similar
communication device. Pin designations on RS232 connector is shown in Figure 2.6.

Figure 2.6 : Pin designations on RS232 connector

Pin designations on RS232 connector

1. CD (Carrier Detect)
2. RXD (Receive Data)
3. TXD (Transmit Data)
4. DTR (Data terminal Ready)
5. GND (Ground)
6. DSR (Data Set Ready)
7. RTS (Request To Send)
8. CTS (Clear To Send)
9. RI (Ring Indicator)







For many computer peripheral devices the USB interface has replaced the
serial port as of 2007, most modern computers are connected to devices through a
USB connection. While nearly every server has a serial port, modern workstations
and laptops often don't have one. The serial port is omitted for cost savings, and is
considered to be a legacy port. Serial ports can also be found in industrial automation
systems, scientific analysis, and some industrial and consumer products. Network
equipment (such as routers and switches) often has serial ports for configuration.
Serial ports are still used in these areas as they are simple, cheap and allow
interoperability between devices. The disadvantage is that setting up serial
connections may require expert knowledge and complex commands if poorly
implemented.




18
2.3.1 Speed


Serial ports use two-level (binary) signaling, so the data rate in bits per
second is equal to the symbol rate in baud. Common bit rates per second for
asynchronous start/stop communication are 300, 1200, 2400, 9600, 19200 baud, etc.
These rates are based on multiples of the rates for electromechanical teleprinters. The
port speed and device speed must match, though some devices may automatically
detect the speed of the serial port. Though the RS-232 standard is formally limited to
20,000 bits per second, serial ports on popular personal computers allow settings up
to 115,200 bits per second; the capability to set a bit rate does not imply that a
working connection will result. Not all bit rates are possible with all serial ports.
Some special-purpose protocols such as MIDI for musical instrument control, or
OBD diagnostics for automobiles, use serial data rates other than the above series.




2.3.2 Data Bits


The number of data bits in each character can be 5 (for Baudot Code), 6
(rarely used), 7 (for true ASCII), 8 (for any kind of data, as this matches the size of a
byte), or 9 (rarely used). 8 data bits are almost universally used in newer applications.
5 or 7 bits generally only make sense with older equipment such as teleprinters.









19
2.4 Visual Basic 6


Visual Basic is an event driven programming language and associated
development environment from Microsoft for its COM programming model. Visual
Basic was derived from BASIC and enables the rapid application development
(RAD) of graphical user interface (GUI) applications, access to databases using
DAO, RDO, or ADO, and creation of ActiveX controls and objects. Scripting
languages such as VBA and VBScript are syntactically similar to Visual Basic, but
perform differently.


A programmer can put together an application using the components provided
with Visual Basic itself. Programs written in Visual Basic can also use the Windows
API, but doing so requires external function declarations.


In business programming, Visual Basic has one of the largest user bases. In a
survey conducted in 2005, 62 percent of developers reported using some form of
Visual Basic. It currently competes with C++, J avaScript, C#and J ava for dominance
in the business world.


Visual Basic was designed to be easy to learn and use. The language not only
allows programmers to create simple GUI applications, but can also develop fairly
complex applications as well. Programming in VB is a combination of visually
arranging components or controls on a form, specifying attributes and actions of
those components, and writing additional lines of code for more functionality. Since
default attributes and actions are defined for the components, a simple program can
be created without the programmer having to write many lines of code. Performance
problems were experienced by earlier versions, but with faster computers and native
code compilation this has become less of an issue.


20
2.5 Microsoft Access


Microsoft Access is a relational database management system from Microsoft
which combines the relational Microsoft J et Database Engine with a graphical user
interface and software development tools. It is a member of the 2007 Microsoft
Office system.


Access can use data stored in Access/J et, Microsoft SQL Server, Oracle, or
any ODBC-compliant data container. Skilled software developers and data architects
use it to develop application software. Relatively unskilled programmers and non-
programmer "power users" can use it to build simple applications. It supports some
object-oriented techniques but falls short of being a fully object-oriented
development tool.


Access was also the name of a communications program from Microsoft,
meant to compete with ProComm and other programs. This Access proved a failure
and was dropped.

Years later Microsoft reused the name for its database software.




2.5.1 Uses


Access is used by small businesses, within departments of large corporations,
and hobby programmers to create ad hoc customized desktop systems for handling
the creation and manipulation of data. Access can be used as a database for basic web
based applications hosted on Microsoft's Internet Information Services and utilizing
Microsoft Active Server Pages ASP. Most typical web applications should use tools
like ASP/Microsoft SQL Server or the LAMP stack.

21

Some professional application developers use Access for rapid application
development, especially for the creation of prototypes and standalone applications
that serve as tools for on-the-road salesmen. Access does not scale well if data access
is via a network, so applications that are used by more than a handful of people tend
to rely on Client-Server based solutions. However, an Access "front end" (the forms,
reports, queries and VB code) can be used against a host of database backend,
including J ET (file-based database engine, used in Access by default), Microsoft
SQL Server, Oracle, and any other ODBC-compliant product.








CHAPTER III




METHODOLOGY




3.1 Introduction


As mention earlier, this project is divided to four phases. Which is the first
phase is built database interface with VB6. The second phase is establishing
connection from RFID READER to VB6. The third phase is establishing connection
from VB6 to PIC. The last phase is program the PIC to on either GREEN LED or
RED LED.


Each phase has different methodology in order to complete this project. In
this chapter, all the used methodology will be shown and explain.








23
3.2 Database Interface


In this project, database interface is the main criteria that make this project
function as it is. The database interface is using VB6 as the GUI and Microsoft
Access as the source of the database.




3.2.1 ActiveX Data Objects (ADO)


Microsoft ActiveX Data Objects (ADO) is a set of Component Object Model
objects for accessing data sources. It provides a layer between programming
languages and OLE DB (a means of accessing data stores, whether they be databases
or otherwise, in a uniform manner), which allows a developer to write programs
which access data, without knowing how the database is implemented. You must be
aware of your database for connection only. No knowledge of SQL is required to
access a database when using ADO, although one can use ADO to execute arbitrary
SQL commands. The disadvantage of this (i.e. using SQL directly) is that it
introduces a dependency upon the type of database used.


In this project, ADO is connected to Microsoft Access and known as Adodc1.
It use as link to Microsoft Access table and named as Staff database. In order to make
the link work, firstly the database in Microsoft Access must be established. The Staff
database is the main and only database for this project. Figure 3.1 shows the Adodc1
interface.





24


Figure 3.1 : Adodc1 interface.






With Adodc1 we can go to the next data, previous data, last data and first data
in the database. It must link with the text form in the interface. This is to enable the
database to show in the interfaces.


The text must be formatted to a Data Source of Adodc1 and the Data Field as
the text field show. For example to show the user name, the Data Field is assigned as
staff_name column in the Staff database. The name that shown is same as at the
database. Figure 3.2 shows an example of Data Source and Data Field related to
staff_name.



Figure 3.2 : Example of Data Source and Data Field.













25
3.2.2 Microsoft Access Table Staff


The Staff table is the main source in this project. It holds all the information
that is required for each registered user.


To link Microsoft Access table with VB6, we must first save the table as Staff
under the rfid database. In rfid database as only one table and it is staff table.
The staff table has ten sub divisions. Every each division holds information about the
user such as staff_name, staff_id and staff_email. The Microsoft Access file
then saved as rfid Microsoft Access Application file.


Then the Microsoft Access file must be change into an .mdb file. This
change is to allow Adodc1 to able to read the database format. The file must be
changed because Adodc1 cannot read the Microsoft Access Application file. It only
read an .mdb file.
















26
3.2.2.1 Steps to convert Microsoft Access Application file.


In order for Adodc1 to read the Microsoft Access database, it has to convert
the Microsoft Access Application file to an .mdb file. The step is first go to
Start/Control panel/Administrative Tools.


Then in the Administrative Tools, there is seven shortcuts. That is to the
Component Services, Computer Management, Data Source (ODBC), Event Viewer,
Local Security Policy, Performance and Services.


Select the Data Source (ODBC). Then go to User DSN and click the Add
button. Then select the Driver do Microsoft Access (*.mdb) and click the Finish
button. Then the ODBC Microsoft Access Setup window will appear.


Click the Select button and the Select Database window will appear.
Search for the rfid file, double click it and click button Ok. It will back to the
ODBC Microsoft Access Setup window. Insert the same name file (rfid) in the Data
Source Name text and click button Ok. Back to the ODBC Microsoft Access Setup
window will appear. Then the rfid name will appear in the User Data Sources with
other existing file. Then click Ok.










27

Figure 3.3 : Flow diagram of steps to convert Microsoft Access
Application file to an .mdb format.
Start/Control
panel/Administrative
Tools
Data Source (ODBC)
Click Add
Select Driver do Microsoft
Access (*.mdb) and click
Finish button.
ODBC Microsoft Access Setup
Click Select and search
the file from folder and
click Ok.
Type the file name (same
as selected file) at Data
Source Name text and Ok

































28
3.2.3 Link ADO with rfid.mdb


After finishing converting the Microsoft Access Application file to an .mdb
file, then we must link the rfid.mdb file to Adodc1 to show the database. The
database is from Microsoft Access file that is staff table.


With this link, we can do editing, adding, searching and deleting the data in
VB6 with VB6 interfaces. This link is very important because administer who handle
the database system can see the user identification throughout the VB6 interfaces.
Administer also can match the RFID TAG number with the user and save it into the
database with this link.


Heres steps how to link the database with VB6 interfaces. Note that each
VB6 Form must have Adodc1 interfaces (Figure 3.1) so that the link will be
connected. The first step is drag the mouse courser to the general column and right
click in it.


Then an option window will appear and click Component. Then
Component windows appear and select the Microsoft ADO Data Control 6.0
(OLEDB). Then clink Apply button and OK. The ADO component then appears in
the general column like shows in Figure 3.4.



Figure 3.4 : ADO Component





29
After that right click to Adodc1 interface and select the ADODC Properties,
the Property Pages will appear. Select General and click at the Use ODBC Data
Source Name and select rfid. Then go to the Record Source and select
Command Type as 2-adCmdTable and select staff at Table or Stored Procedure
Name. Figure 3.5 show the Property Pages with rfid selected in it.















Figure 3.5 : Property Pages



With this steps completed, and then the link from Microsoft Access to VB6 is
now established.









30
3.2.4 Staff Identification


The database has only one data system that is Staff Identification. In Staff
Identification it has ten information of a user. This information is inserting only by
the assigned administrator. The information is confidential and only the administrator
knows about it.


In Microsoft Access database, information must have it own name. The name
cannot be duplicated or doubled in the table. Below is the user information with the
field name in the bracket.


The user information is:
Staff No. (staff_id)
Staff full name (staff_name)
Staff IC no. (staff_ic)
Staff Phone No. (staff_phone)
Staff E-Mail (staff_email)
Staff Department (staff_dept)
Staff Room No. (staff_room)
Staff Martial Status (staff_marriage)
Staff Registration Date (staff_regdate)
Staff ID-TAG (id_tag)








31
3.3 Connection VB6 to RFID READER


To match the ID-TAG number with the user, connection from RFID
READER to VB6 must be establish. With this connection, we can see what is the ID-
TAG number in the ID-TAG it self.


The connection from RFID READER to VB6 is via serial port. The serial
port connection to computer has been discus in Chapter 2. In this chapter we will
discus how VB6 to receive data from RFID READER and that is the ID-TAG
number.




3.3.1 Microsoft Comm. Control 6.0


The connection between VB6 and serial port can be established only by
activating the Microsoft Comm. Control 6.0 in the VB6. Microsoft Comm. Control
6.0 will allow VB6 to communicate with external hardware via serial port.


To active it only need a simple step because it almost similar to activating the
Microsoft ActiveX Data Objects. The different is only this time were activating
Microsoft Comm. Control 6.0 in the Components window box and then click
Apply button.


After applying Microsoft Comm. Control 6.0, in the General column will
appear the MSComm component. For the communication to communicate, each form
that needs to transmit or receive signal or data must have the MSComm interface.
Figure 3.6 shows the MSComm interface.
32






Figure 3.6 : MSComm interface.




3.3.2 InRFID 125Ctrl ActiveX Control module


To connect the RFID READER with VB6, the InRFID 125Ctrl ActiveX
Control module needs to be activated. InRFID 125Ctrl ActiveX Control module is
the component that only after the RFID BEGINNER KITS has been installed. The
InRFID 125Ctrl ActiveX Control module is similar with the Microsoft Comm.
Control 6.0 but it purpose use is only for connection with the RFID READER
BBEGINNERS KIT.


To active it only need a simple step because it almost similar to activating the
Microsoft ActiveX Data Objects. The different is only this time were activating
InRFID 125Ctrl ActiveX Control module in the Components window box and then
click Apply button.


After applying InRFID 125Ctrl ActiveX Control module, in the General
column will appear the InRFIDCtrl component. For the communication to
communicate, each form that needs to transmit or receive signal or data must have
the InRFIDCtrl interface. Figure 3.7 shows the InRFIDCtrl interface.



33

Figure 3.7 : InRFIDCtrl interface.







3.4 Connection to PIC16F84A


Connection to PIC16F84A was the trickiest phase in this project. To establish
a connection to PIC16F84A from the computer (PC) must include a component call
MAX232. This is because the logic levels between PIC and PC are different. So, it
must we need a level converter to leveled it.


Either to transmit or receive signals from PIC-to-PC or PC-to-PIC the logic
level must be synchronous. To level the logic level between PIC and PC we need
MAX232.


MAX232 is a dual driver/receiver that includes a capacitive voltage generator
to supply EIA-232 voltage levels from signal 5V supply. Each receiver converts EIA-
232 inputs to 5V TTL/CMOS levels. These receivers have a typical threshold of 1.3V
and a typical hysteresis of 0.5V, and can accept +30V inputs. Each driver converts
TTL/CMOS input levels into EIA-232 levels. MAX232 pin diagram is shown in
Figure 3.8.






34


Figure 3.8 : MAX232 pin diagram.












Transmitters and receivers signal have low level and high level. In
transmitters logic levels the low level for RS232 output is between +5V to +15V and
for Transistor-transistor Logic (TTL) output is from 0V to +0.4V while in the high
level for RS232 output is between -5V to -15V and for TTL output is from +2.4V to
+5V.


In receivers logic levels the RS232 transmitter must have highest voltage
than the input threshold of the RS232 receiver (+3V). The receiver logic level for the
RS232 input is from +3V to +15V and for TTL input is from 0V to +0.8V. In the
high level for the RS232 is from -3V to -15V and for TTL input is between +2V to
+5V.


In both figures below shows the RS232 receiver and transmitter voltage level
diagram. Figure 3.9 is the RS232 receiver and Figure 3.10 is the RS232 transmitter.




35














Figure 3.9 : RS232 receiver and TTL input.
















Figure 3.10 : RS232 transmitter and TTL output.




36
3.4.1 Connection from PIC to MAX232 to PC




















Figure 3.11 : Connection from PIC to MAX232 to PC


Figure 3.11 shows the detail connection from PIC to MAX232 to PC via
RS232. As shown in the figure above, there is some pin that has been shorted. Pin 1,
pin 4 and pin 6 were shorted together while pin 7 and pin 8 were shorted together.
Pin 5 is connected to ground. Pin 9 has no connection. Pin 3 is for MAX232 receive
from PC and pin 2 is for MAX232 transmit to PC.






37
3.5 Programming PIC16F84A


In order to program the PIC16F84A, there were several things that needed do
done first. The program must be running without an error, the PIC burner must be
functional and the circuit for the PIC must be well developed.


In this project, the Cytron PIC burner model L4128D is used. The burner only
suits for PIC 40 pins, 28 pins and 18 pins. It has a green led that will on while
burning process.


The program is built as an .asm file. The program is to on either GREEN
LED (valid user) or RED LED (invalid user) after the user scan their ID-TAG to the
RFID READER. This simple program must include transmit and receive instruction
to MAX232.


In PIC16F84A it has 13 I/O pins. Pin RA3 as output to the MAX232, RB1 as
output to GREEN LED and pin RB2 as output to RED LED. Only pin RB0 as an
input from MAX232. Figure 3.12 shows the circuit diagram for I/O pins that were
use in this project.











38


Figure 3.12 : Circuit diagram for I/O pins used.





















3.5.1 The PIC16F84A program

This project is using a very simple instruction. This because the PIC16F84A
function is the receive signal (high or low) from the PC and then on either GREEN
LED or RED LED. The input and output of the PIC16F84A has been discus in the
previous sub-chapter, so in this sub-chapter will shows the main program for this
project. Figure 3.13 shows the main program in an .asm code.




39


Figure 3.13 : The main program in an .asm code.













3.5.2 MPLAB IDE


In this project, MPLAB IDE is use form converting the .asm file to the
.HEX file. After converting the converted program, the simulation is done using
MPLAB IDE. The simulation is just to make sure that the program has no numerical
error, but cannot simulate to see if theres a functional error. In MPLAB IDE library
has the PIC16F84A, so it supported the simulation of the program that includes
PIC16F84A.










40
3.5.3 ICPROG


In this project, ICPROG is used to program the PIC16F84A. The
programming process is by open the .HEX files that has been converted from
MPLAB IDE and then establish the connection via serial port to the Cytron PIC
Burner. Before burn the PIC, the PIC must be erase first either it has a previous
program or a new one, this is for the safety of the PIC. Then select the Program All
option to program the PIC. Wait until the GREEN LED at the Cytron PIC Burner to
off, and then the PIC16F84A is programmed. Figure 3.14 shows the ICPROG
programmer window.



Figure 3.14 : ICPROG programmer.






















CHAPTER IV




APPLICATION




4.1 Introduction


In this chapter will discus about the system applications. This system is quite
simple an easy to understand. It also made especially for the administrator facilitate
to handle the database system.


As discussed in previous chapter, this system has two main VB6 applications,
that is the database and the confirmation forms. The database has total of six forms
which include Admin, Staff Registration, Staff Identification, User Guide, RFID ID-
TAG and Example. The confirmations only have one form which is ID Confirmation.


Also in this chapter, the PIC circuit will be discus including the power supply
for the PIC from 9V to 5V using voltage divider. This is because PIC has the input
(operational) voltage up to +5V.



42
4.2 Database


The database interfaces is made only for the administrator usage. Then it built
with a secure pattern so that the data is saved and the user is registered. It has a fix
login password and some features that needs to make the database not so easy to edit
if hacked.




4.2.1 Admin


Form Admin act as the login form. Its need for the administrator to key in
the fix password to enter the database system. In this form has three part of
application. First is the correct password, second is the wrong password and third are
times up.



Figure 4.1 : The password is correct.













43
This form has a fix password that only the assigned administrator who knows
it. So only the assigned administrator can enter the correct password. Figure 4.1
shows the Admin form in the correct password with a message box note as
Welcome to FKE CER PARK SYSTEM DATABASE.


If the wrong password were enter, a message box note as SORRY, YOUR
PASSWORD IS NOT VALID will appear. The password can be entering again if
its still incorrect, but in only 20 second of time. After 20 second, the system will
automatically exit.




Figure 4.2 : Wrong password entered.

























Figure 4.2 shows if a wrong password were entered and Figure 4.3 shows
when the time is up to entering the correct password. Figure 4.4 shows the clock
coding used in this form.

44



Figure 4.3 : Times up.



























Figure 4.4 : Clock coding times up.




















45
4.2.2 Staff Registration


This form is the main form in this database section. It has three main path
with one exit button that. From this form, it cannot go back to the Admin form. This
procedure is for security measure.


As mention earlier, this form has three paths to enter. First is the STAFF
PROFILE, second is the USER GUIDE, and last is the EXAMPLE.



Figure 4.5 : Staff Registration form.





















46


Figure 4.6 : Secure measure if exit.
















The EXIT button is for permanently stop the database system run. It will
appear a confirmation message box note as Are you sure to exit? with button Yes
and No in it. Again, this is for a secure measure in this system. Most of the button
has the same measure so that the administrator can redo editing if he accidental
clicking the EXIT button. Figure 4.5 shows the Staff Registration form and Figure
4.6 show the secure measure if exit.










47
4.2.3 Staff Identification


From the Staff Identification form, by clicking at the STAFF PROFILE
button, the Staff Identification form will appear. This form is the core part in the
database section. It shows the user information. There are ten user information needs
in this project. Thats Staff No., Staff full name, Staff IC no., Staff Phone No., Staff
E-Mail, Staff Department, Staff Room No., Staff Martial Status, Staff Registration
Date, and Staff ID-TAG number. All this information is save in the data source in
Microsoft Access staff table file.


As shown in Figure 4.7, the Staff identification form has sixs push button.
Each button has different application. For the SEARCH button, it is use to search
the existing staff or to make sure that theres no users duplication. The key for
search is using the Staff No. because each staff has different staff number.


The ADD button is for adding a new staff user. By clicking the button, a
message box note as New User ID? will appear. After adding the new user data,
click the SAVE button to save the user data. DELETE button is for deleting the
user data. By clicking the DELETE button, the entire user information will be
deleted.


The SCAN ID-TAG button is for matching the user ID with the ID-TAG
number. By clicking it the next form, RFID ID-TAG will appear. The BACK
button is to go back to the previous form which is Staff Registration form. Figure 4.7
shows the Staff Identification form complete with the Staff ID.





48


Figure 4.7 : The Staff Registration form.
































49
In this form also shows the present date and time. This will facilitate the
administrator while using the database system either to add or edit the user database.
Figure 4.8 shows the coding for showing present date and time. This method also use
in the Admin form.



Figure 4.8 : Clock coding present time.



























50
4.2.4 User Guide


In this form is shows the step by step user guide for the administrator to use
the database system. Its include application for adding, saving and matching the user
ID with the ID-TAG number. Figure 4.9 shows the USER GUIDE form.



Figure 4.9 : User Guide form.

























51
4.2.5 RFID ID-Tag


This form is for the administrator to matching the user ID with the ID-TAG
number. The STAFF NO. and TAG ID text column cannot be entering because it
was disabling. This is for the security measure so that the ID-TAG number cannot be
insert manually, it must receive from the RFID READER.


First the administrator will search the STAFF NO. by clicking the
SEARCH button. Then the STAFF NO. appears. If the staff has already register
and the TAG ID number will also appear. This means is the user has been match with
an ID-TAG number. Figure 4.10 shows the user without an ID-TAG number and
Figure 4.11 shows the same user has been match with an ID-TAG number.




Figure 4.10 : User without an ID-TAG number.
















52



Figure 4.11 : User has been match with an ID-TAG number.

















Figure 4.12 shows the sample code used in this project to establish connection
between RFID READER with VB6 in this form. The connection must be connected
first before searching for the staff number. This is because there are two serial ports
available, so the administrator must determined which port is used and connected
with the RFID READER. Its include with the baud rate setting of 9600, n, 8, 1.









53

Figure 4.12 : Sample coding for RFID READER connection to VB6.




















4.2.6 Example


The Example form is for the administrator to see how the data format is will
be insert. Although there were not program if any mistake while inserting the data,
but the format is for the official document is insert. The format is to apply the ISO
standard for documentations. Figure 4.13 shows the Example form.






54


















Figure 4.13 : The Example form.
















55
4.3 Identify

The Identify form is separate from the database form because this form is
always running. This is for the user to enter the parking spaces at any time while the
database form is only use if the administrator wants to add or edit the user database.


In this form, it has three function which is establish connection from RFID
READER to this form, identify ID-TAG that receive from the RFID READER and
then transmit signal to the next port to the PIC16F84A.


First the connection to both port (e.g. port COM1 to RFID READER and
port COM2 to the PIC Circuit) must be established by clicking the CONNECT
PORT button for both port. Then the user can tag their ID-TAG and this form will
determine either the ID-TAG number valid or in valid. Figure 4.14 shows the valid
user output and Figure 4.15 shows the invalid user output.


When a user tag his ID-TAG to the RFID READER, if the ID-TAG that has
been scan has the number that match the ID-TAG number in the database, then
message box note as Valid User. Please Proceed will appear. But if the ID-TAG
that has been scan has the number that does not match the ID-TAG number in the
database, then message box note as Invalid User. Cannot Enter!!! will appear.










56


Figure 4.14 : Valid ID-TAG tagged.
















Figure 4.15 : Invalid ID-TAG tagged.
















57
The identifying process is determining the tagged ID-TAG number either
valid or invalid by comparing it to the database. The process is looping for the next
tagged ID-TAG number can be compared to the same database. This coding is shown
in Figure 4.16. Figure 4.17 shows the User Confirmation flow.



Figure 4.16 : Sample coding for identifying.



























58






















Theuser
scanshisID
Tagtothe
RFID
Reader.
*REDLED
alwayson.
Computer
receivetheID
Tagnumberand
compareittothe
database.
IftheIDTag
numberissame
asinthe
database,User
IDisvalid.
Then
Computer
transmitting
signal1tothe
PIC.
PICthensend
signaltomotor
torunand
GREENLEDon.
REDLEDoff.
IftheIDTag
numberisnot
sameasinthe
database,User
IDisinvalid.
Then
Computer
transmitting
signal0tothe
PIC
Noaction
willbetaken.
VALI
D
I NVAL
I D
Figure 4.17 : User Confirmation flow



4.4 PIC Circuit

The PIC Circuit is design to connect to the PC serial port via RS232. The
connection from PIC16F84A to PC serial port is through MAX232. The PIC Circuit
has 14 components. Table 4.1 shows the components and the numbers of the item
used to build the PIC Circuit. Figure 4.18 shows the PIC Circuit diagram complete
with the power supply circuit.

59

Table 4.1 : PIC Circuit component.

No. Component Numbers of item
1 PIC16F84A 1
2 MAX232 1
3 Voltage Regulator 7805 1
4 Resistor 10k 1
5 Resistor 100 1
6 Resistor 220 2
7 Capacitor 0.1u 3
8 Capacitor 10u 3
9 Capacitor 22u 2
10 Capacitor 22p 2
11 Crystal 40MHz 1
12 Green LED 1
13 Red LED 1
14 Push Button 1



















This PIC Circuit has been tested with several simples program. The testing
process is to see the functionality of the circuit before installing the program for this
project. The simple program is Blink-blink, Running Light and Switch LED.
The entire program runs smoothly. So with that, this PIC Circuit is well function.









60


Figure 4.18 : PIC Circuit diagram.



.




CHAPTER V




RESULTS AND DISCUSSION




5.1 Results


This project called Car Park Control System : Interface RFID to PIC via
Serial Port has three main objective. There are designing the interface using VB6
between the computers to the RFID READER via serial connection, to identify the
correct user ID that had been permited to use the parking space and to attach the
PIC16F84A to the PC using serial connection for sending signal to on either GREEN
LED or RED LED.


In this chapter, all the result will be discus. Wheres the outcome of this
project is compared to the main three objective.







62
5.1.1 Interface VB6 to RFID READER






















As shown in Figure 5.1 the ID-TAG number has appeared in the TAG ID
text column wheres match the STAFF NO. text column. The tags that is used in
this project in ISO 15693 that has ten digit format ID-TAG, which it will change only
the last two digit for around 100 user.


That means the connection between VB6 interface and the RFID READER
were establish.



Figure 5.1 : Result of the ID-TAG shown in the TAG ID text column.
63
5.1.2 Identify User






















As shown in Figure 5.2, the message box note as Valid User. Please
Proceed. This will appear after the user has tag his ID-TAG to the RFID READER.
The RFID READER will send the ID-TAG number to PC. From the database, it will
compare either the ID-TAG number is match with in the database or not. In this case,
it matches.





Figure 5.2 : Result of the confirmation as a VALID user.
64
Figure 5.3 shown that the unregistered user that tags to the RFID READER
and cannot enter the parking space. The message box noted as Invalid User. Cannot
Enter !!!. This is because the ID-TAG number does not matches with the data in
database.


As result the second objective, to identify the correct user ID that had been
permited to use the parking space is a success.



















Figure 5.3 : Result of the confirmation as a INVALID user.







65
5.1.3 Connecting PIC16F84A to PC


PIC16F84A has successfully program. The program runs smoothly by
sending a positive voltage to the input port which is RB0. By sending low input
voltage the GREEN LED will on and by sending high input voltage the RED LED
will on. Normally well the high logic to on the GREEN LED, but in this project we
use low input because the signal the PIC receive from the computer is normal high.


But, unfortunately transmitting signal from PC serial port to the PIC was
failed. This is because the PC serial port is sending an always high input while PIC
read 8-bits inputs. In order to change the first bit, the high voltage must be change
into a low voltage with the same amount (e.g. -11V change to +11V). Using VB6,
after trying with sending an ASCII character from 0-255, the biggest change is
0.16V, so its not enough to change the first bit in order to send signal to the
PIC16F84A.




5.2 Discussions


This system is well built with the database and the identifying run smoothly.
But the database has one insufficient thats make it look undesirable or unofficial.
That is formatting. The database does not have a solid format for the administrator to
insert the user data, it can insert anything. For example in the STAFF IC NO. text
column it suppose can only enter numbers but it also can enter alphabets.





66
So in order to solve this problem, more research need to be done and
comparing to others database system using VB6, most of it using SQL as a link
database source. Furthermore SQL is more advance compared to using Microsoft
Access.


Another insufficient in this project is the failing to make an establish
connection between VB6 and PIC16F84A. Its not the program in the PIC thats
incorrect, it just the serial port has always send a high logic and with VB6, it has
some others coding in order to successfully change the -11V to +11V. Then the PIC
first bit input can change and the LEDs will on and off like it program.




CHAPTER VI




CONCLUSION




6.1 Conclusion


RFID is now becoming the most use identification system in world wide. It is
increasingly used by big companies because of it data structure and reliability to
identify and detected. Although the price is a bit higher compare to the barcode
system, the secure system it has makes it more reliable to use. PICs are popular with
developers due to their low cost, wide availability and large user base. This are the
two main product used in this project.


Overall of this project is a success. The database functioning very well, the
connection from the RFID READER to VB6 also functioning so that the each
different ID-TAG number can be matches with each different user. Lastly the
program in the PIC16F84A is also functioning well, with GREEN LED and RED
LED on after a signal sent to the input pin.

68




REFERENCES




1. Alka R. Harringer, Susan K. Lisack, J ohn K. Gotwals, and Kyle D. Lutes
(2001). Introduction to Computer Programming with Visual Basic 6 : A
Problem Solving Approach. United Kingdom. Que E&T.

2. Barnett, Cox, and OCull. (2002). Embedded C Programming and The
Microchip PIC. United Kingdom. Thomson Delmar.

3. Chan Kok Keong (2006). RFID Convocation Graduates Name Call.
University Technology of Malaysia: Degree Thesis.

4. Bong Khong Lee (2006). RFID Car Security System. University
Technology of Malaysia: Degree Thesis.

5. Chong Shih J un (2005). To Develop RFID System. University Technology
of Malaysia: Degree Thesis.

6. PIC Manual: www.microchip.com

7. Information: en.wikipedia.org

8. PIC Programming: www.electronic-engineering.ch

9. Visual Basic: www.planetsourcecode.com





















APPENDIX A



VISUAL BASIC 6 SOURCE CODE

























APPENDIX A 70
DATABASE

FORM 1: ADMIN

Private Sub Command1_Click()
If Text1.Text ="123" Then
Timer1.Enabled =False
MsgBox ("Welcome to the FKE CARPARK SYSTEM DATABASE")
Form2.Show
Me.Hide
Else
MsgBox ("SORRY, YOUR PASSWORD IS NOT VALID !")
End If
End Sub

Private Sub exitbtn_Click()
Dim Form1 As New Form1
t =MsgBox("Are you sure to exit?", vbQuestion +vbYesNo)
Me.Hide
If t =vbYes Then
End
Else
Form1.Show
End If
End Sub

Private Sub Timer1_Timer()
MsgBox ("Sorry, your time is up!!!")
End
End Sub

Private Sub Timer2_Timer()
Label1.Caption =Now
End Sub


FORM 2: STAFF REGISTRATION


Private Sub cthbtn_Click()
Form6.Show
Me.Hide
End Sub

Private Sub scanbtn_Click()
Form4.Show
Unload Me
End Sub

Private Sub exitbtn_Click()
APPENDIX A 71
Dim Form2 As New Form2
t =MsgBox("Are you sure to exit?", vbQuestion +vbYesNo)
Me.Hide
If t =vbYes Then
End
Else
Form2.Show
End If
End Sub

Private Sub newbtn_Click()
Form3.Show
Unload Me
End Sub



FORM 3: STAFF IDENTIFICATION

Private Sub backbtn_Click()
Form2.Show
Unload Me
End Sub

Private Sub addbtn_Click()
Text1.SetFocus
t =MsgBox(" New User ID?", vbQuestion +vbYesNo)
Me.Show
If t =vbYes Then
MsgBox (" Please Insert Data ")
Adodc1.Recordset.AddNew
Else
Me.Show
Adodc1.Recordset.Cancel
End If
End Sub


Private Sub searchbtn_Click()
Dim a As String
Dim b As Integer
a =Text1.Text
Let a =UCase(InputBox("Insert Staff No", "INPUT"))
If Len(a) >0 Then
Adodc1.Recordset.MoveFirst
Let b =0
Do While b =0 And Not Adodc1.Recordset.EOF
If UCase(Adodc1.Recordset.Fields("staff_id").Value) =a Then
Let b =1
MsgBox "Record Found !", vbOKOnly +vbQuestion, "No Record"
APPENDIX A 72
Else
Adodc1.Recordset.MoveNext
End If
Loop
If b =0 Then
MsgBox "Record Not Found !", vbOKOnly +vbQuestion, "No Record"
Me.Show
End If
Else
MsgBox "Insert Staff No"
End If
End Sub

Private Sub deletebtn_Click()
t =MsgBox(" Delete User ID? ", vbQuestion +vbYesNo)
Me.Show
If t =vbYes Then
Adodc1.Recordset.Delete
Adodc1.Recordset.MoveFirst
MsgBox (" User ID Deleted ")
Else
Me.Show
Adodc1.Recordset.Cancel
End If
End Sub

Private Sub id_tagbtn_Click()
Form5.Show
Unload Me
End Sub

Private Sub savebtn_Click()
t =MsgBox(" Save User ID?", vbQuestion +vbYesNo)
Me.Show
If t =vbYes Then
Adodc1.Recordset.Save
MsgBox (" User ID Saved ")
Else
Me.Show
Adodc1.Recordset.Cancel
Adodc1.Recordset.MoveFirst
End If
End Sub

Private Sub Timer1_Timer()
Label1.Caption =Now
End Sub



APPENDIX A 73
FORM 4: USER GUIDE

Private Sub backbtn_Click()
Form2.Show
Unload Me
End Sub



FORM 5: RFID ID-TAG

Private Sub backbtn_Click()
Form3.Show
Unload Me
End Sub

Private Sub searchbtn_Click()
Dim a As String
Dim b As Integer
a =Text2.Text
Let a =UCase(InputBox("Insert Staff No", "INPUT"))
If Len(a) >0 Then
Adodc1.Recordset.MoveFirst
Let b =0
Do While b =0 And Not Adodc1.Recordset.EOF
If UCase(Adodc1.Recordset.Fields("staff_id").Value) =a Then
Let b =1
MsgBox "Record Found !", vbOKOnly +vbQuestion, "No Record"
Else
Adodc1.Recordset.MoveNext
End If
Loop
If b =0 Then
MsgBox "Record Not Found !", vbOKOnly +vbQuestion, "No Record"
Form2.Show
Unload Me
End If
Else
MsgBox "Insert Staff No"
End If
End Sub

Private Sub savebtn_Click()
Adodc1.Recordset.Save
Adodc1.Refresh
End Sub

Private Sub CommCtrl_OnComm()
On Error Resume Next
Dim tmpStr As String
APPENDIX A 74
Dim chrRet As String
Dim TagId As String
chrRet =Chr(13)
tmpStr =txtReply
If CommCtrl.CommEvent =comEvReceive Then
While CommCtrl.InBufferCount >0
tmpStr =tmpStr & CommCtrl.Input
If InStr(tmpStr, chrRet) >0 Then
TagId =InRFID125Ctrl1.GetId(tmpStr)
If Len(TagId) >0 Then
txtTagId.Text =TagId
txtReply.Text =""
tmpStr =""
End If
End If
Wend
txtReply.Text =tmpStr
End If
End Sub

Private Sub btnOpen_Click()
If CommCtrl.PortOpen =True Then
CommCtrl.PortOpen =False
End If
If Len(cmbPort) <=0 Then
Exit Sub
End If
Dim strComm As String
strComm ="9600,N,8,1"
Dim Port As Integer
Dim strPort As String
strPort =cmbPort.Text
strPort =Replace(strPort, "COM", "")
Port =CInt(strPort)
CommCtrl.Settings =strComm
CommCtrl.CommPort =Port
CommCtrl.RThreshold =1
CommCtrl.SThreshold =255
CommCtrl.InputLen =0
CommCtrl.OutBufferCount =0
CommCtrl.PortOpen =True
End Sub

Private Sub LoadPort()
cmbPort.Clear
cmbPort.AddItem "COM1"
cmbPort.AddItem "COM2"
End Sub


APPENDIX A 75

Private Sub Form_Load()
txtReply =""
txtCommand =""
LoadPort
End Sub


FORM 6: EXAMPLE

Private Sub backbtn_Click()
Form2.Show
Unload Me
End Sub




































APPENDIX A 76
IDENTIFY

FORM 1: ID CONFIRMATION

Private Sub LoadPort()
cmbPort1.Clear
cmbPort2.Clear
cmbPort1.AddItem "COM1"
cmbPort1.AddItem "COM2"
cmbPort2.AddItem "COM1"
cmbPort2.AddItem "COM2"
End Sub

Private Sub btnConnect2_Click()
If CommCtrl.PortOpen =True Then
CommCtrl.PortOpen =False
End If
If Len(cmbPort2) <=0 Then
Exit Sub
End If
Dim strComm As String
strComm ="9600,N,8,1"
Dim Port As Integer
Dim strPort As String
strPort =cmbPort2.Text
strPort =Replace(strPort, "COM", "")
Port =CInt(strPort)
CommCtrl.Settings =strComm
CommCtrl.CommPort =Port
CommCtrl.RThreshold =1
CommCtrl.SThreshold =255
CommCtrl.InputLen =0
CommCtrl.OutBufferCount =0
CommCtrl.PortOpen =True
End Sub

Private Sub btnConnect1_Click()
If CommCtrl.PortOpen =True Then
CommCtrl.PortOpen =False
End If
If Len(cmbPort1) <=0 Then
Exit Sub
End If
Dim strComm As String
strComm ="9600,N,8,1"
Dim Port As Integer
Dim strPort As String
strPort =cmbPort1.Text
strPort =Replace(strPort, "COM", "")
Port =CInt(strPort)
APPENDIX A 77
CommCtrl.Settings =strComm
CommCtrl.CommPort =Port
CommCtrl.RThreshold =1
CommCtrl.SThreshold =255
CommCtrl.InputLen =0
CommCtrl.OutBufferCount =0
CommCtrl.PortOpen =True
End Sub

Private Sub exitbtn_Click()
Dim Form1 As New Form1
t =MsgBox("Are you sure to exit?", vbQuestion +vbYesNo)
Me.Hide
If t =vbYes Then
End
Else
Me.Show
End If
End Sub

Private Sub Form_Load()
txtReply =""
txtCommand =""
LoadPort
End Sub

Private Sub CommCtrl_OnComm()
On Error Resume Next
Dim tmpStr As String
Dim chrRet As String
Dim TagId As String
chrRet =Chr(13)
tmpStr =txtReply
If CommCtrl.CommEvent =comEvReceive Then
While CommCtrl.InBufferCount >0
tmpStr =tmpStr & CommCtrl.Input
If InStr(tmpStr, chrRet) >0 Then
TagId =InRFID125Ctrl1.GetId(tmpStr)
If Len(TagId) >0 Then
masuk.Text =TagId
txtReply.Text =""
tmpStr =""
scanbtn_Click
End If
End If
Wend
txtReply.Text =tmpStr
End If
End Sub

APPENDIX A 78
Private Sub scanbtn_Click()
Dim a As String
Dim ada As Boolean:
a =masuk.Text
ada =False
Adodc1.Recordset.MoveFirst
Do While Not Adodc1.Recordset.EOF
Debug.Print Adodc1.Recordset("id_tag") & "=" & a
If a =Adodc1.Recordset("id_tag") Then
ada =True
Exit Do
Else
ada =False
End If
Adodc1.Recordset.MoveNext
Loop
If ada Then
MsgBox "Valid User. Please Proceed"
Call onled(1)
Else
MsgBox "Invalid User. Cannot Enter !!!"
Call onled(0)
End If
End Sub

Public Function onled(led As Long)
'led
'----------
'1 : green
'0 : red
'----------
If CommCtrl.PortOpen =True Then CommCtrl.PortOpen =False
CommCtrl.CommPort =2
CommCtrl.PortOpen =True
'selecting led
Dim temp As Long
Select Case led
Case 0
temp =4 '0000 0100 : bit2 is on
Case 1
temp =2 '0000 0010 : bit1 is on
End Select
'sending
Dim i As Long
For i =1 To 2000
DoEvents
CommCtrl.Output =Chr(temp)
Next
End Select
End Function




















APPENDIX B


PIC16F84A SOURCE CODE
























APPENDIX B 80
; FILE: rcv1_1.asm

; AUTH: P.Oh

; DATE: 04/27/02 18:00 1.0 - WORKS

; 04/27/02 18:35 1.1

; DESC: 1.0: PC-to-PIC serial communications.

; REFS: rcv4800.asm

;--------------------------------------------------------------------------

list p=16f84

radix hex

;--------------------------------------------------------------------------

; CPU EQUATES



tmr0 equ 0x01 ; Timer/counter register

status equ 0x03 ; Status word register. See Easy PIC'n p. 145

portA equ 0x05 ; Port A register

portB equ 0x06 ; Port B register

intCon equ 0x0b ; Interrupt control register

rcvReg equ 0x0c ; General purpose register

count equ 0x0d ; General purpose register

temp equ 0x0e ; General purpose register

optReg equ 0x81 ; File register in Bank 1

trisA equ 0x85 ; File register in Bank 1. See Easy PIC'n p. 145

trisB equ 0x86 ; File register in Bank 1. See Easy PIC'n p. 145

;--------------------------------------------------------------------------

; BIT EQUATES

APPENDIX B 81
rp0 equ 5

;--------------------------------------------------------------------------

org 0x000

start bsf status, rp0 ; Switch to Bank 1

movlw b'00001000' ; A3 are input and the rest is output

movwf trisA

movlw b'00000000' ; All port B are output

movwf trisB

bcf status, rp0 ; Switch back to Bank 0

clrf portB

clrf rcvReg


doThis call rcv4800 ; Yes, to serial in subroutine

movf rcvReg, w ; Get byte received

movwf portB ; Display byte on the 8 LEDs

circle goto doThis ; Done

;--------------------------------------------------------------------------

rcv4800 bcf intCon, 5 ; Disable tmr0 interrupts

bcf intCon, 7 ; Disable global interrupts

clrf tmr0 ; Clear timer/counter

clrwdt ; Clear wdt prep prescaler assign

bsf status, rp0 ; to page 1

movlw b'11011000' ; set up timer/counter

movwf optReg

bcf status, rp0 ; Back to page 1

movlw 0x08 ; Init shift counter
APPENDIX B 82

movwf count

sbit btfsc portA, 0 ; Look for start bit

goto sbit ; For Mark

movlw 0x98 ;

movwf tmr0 ; Load and start timer/counter

bcf intCon, 2 ; Clear tmr0 overflow flag

time1 btfss intCon, 2 ; Has the timer (bit 2) overflowed? Skip next line if 1

goto time1 ; No

btfsc portA, 0 ; Start bit still low?

goto sbit ; False start, go back

movlw 0x30 ; real, define N for timer

movwf tmr0 ; start timer/counter - bit time

bcf intCon, 2 ; Clear tmr0 overflow flag

time2 btfss intCon, 2 ; Timer overflow?

goto time2 ; No

movlw 0x30 ; Yes, define N for timer

movwf tmr0 ; Start timer/counter

bcf intCon, 2; ; Clear tmr0 overflow flah

movf portA, w ; Read port A

movwf temp ; Store

rrf temp, f ; Rotate bit 0 into carry flag

rrf rcvReg, f ; Rotate carry into rcvReg bit 7

decfsz count, f ; Shifted 8?

goto time2 ; No

time3 btfss intCon, 2 ; Timer overflow?
APPENDIX B 83

goto time3 ; No

return ; Yes, byte received

;-----------------------------------------------------------------------

end

;-----------------------------------------------------------------------














APPENDIX C


DATA SHEET AND MANUAL

You might also like