Faculty of Electrical Engineering
PSZ 19:16 (Pind. 1/07)
UNIVERSITI TEKNOLOGI MALAYSIA
DECLARATION OF THESIS / UNDERGRADUATE PROJECT PAPER AND
COPYRIGHT
Author’s full name :
Date of birth
:
W.M.FAHMI FATHUDDIN B. WAN MOKHTAR
21 NOVEMBER 1985
Title
SMART OFFICE USING RFID VIA PIC AND PLC
:
Academic Session :
2008/2009
I declare that this thesis is classified as :
CONFIDENTIAL
(Contains confidential information under the
Official Secret Act 1972)*
RESTRICTED
(Contains restricted information as specified by
the organisation where research was done)*
OPEN ACCESS
I agree that my thesis to be published as online
open access (full text)
I acknowledged that Universiti Teknologi Malaysia reserves the right as follows :
1. The thesis is the property of Universiti Teknologi Malaysia.
2. The Library of Universiti Teknologi Malaysia has the right to make copies
for the purpose of research only.
3. The Library has the right to make copies of the thesis for academic
exchange.
Certified by :
SIGNATURE
851121-13-5901
(NEW IC NO. /PASSPORT NO.)
Date : 11 MAY 2009
NOTES :
*
SIGNATURE OF SUPERVISOR
EN.MOHD SHUKRI B ABD MANAF
NAME OF SUPERVISOR
Date : 11 MAY 2009
If the thesis is CONFIDENTIAL or RESTRICTED, please attach with the
letter from the organisation with period and reasons for
“I hereby declare that I have read this thesis and in my
opinion this thesis is sufficient in terms of scope and quality for the
award of the degree of Bachelor of Electrical Engineering
(Control and Instrumentation)”
Signature
:
....................................................
Name of Supervisor :
En Mohd Shukri B Abd Manaf
Date
15 May 2009
:
SMART OFFICE USING RFID VIA PIC AND PLC
W.M.FAHMI FATHUDDIN B. WAN MOKHTAR
A report is submitted in partial fulfilment of the requirement for the award of
the degree of Bachelor in Electrical Engineering (Control and Instrumentation)
Faculty of Electrical Engineering
Universiti Teknologi Malaysia
MAY 2009
ii
I declare that this is thesis entitled ‘smart office using RFID via PIC and PLC’
is the result of my on resource expect as cited in the references. The thesis is has
not been accepted for any degree and is not concurrently submitted in
candidature of any other degree.
Signature
:
................... ........................................
Name
:
W.M.FAHMI FATHUDDIN B. WAN MOKHTAR
......................................................................
Date
:
15 MAY 2009
............................................................
iii
Dedicated, in thankful appreciation for support, encouragement, and understandings
to:
My supervisor En Mohd Shukri B. Abd Manaf
My beloved mother, Hasinah Bt Ratman and father, Wan Mokhtar b Wan Saad
My Brothers;
Also all my beloved friend SEI student batch 2006-2009,
And all person contribute to this project
iv
ACKNOWLEDGEMENT
First and foremost, I would like to express my heartily gratitude to my
supervisor, Tuan Hj Mohd Shukri B. Abd Manaf for the guidance and enthusiasm
given throughout the progress of this project.
My appreciation also goes to my family who has been so tolerant and supports
me all these years. Thanks for their encouragement, love and emotional supports that
they had given to me.
Not forget to thank to Mohd Alif Amir, student of Faculty of Electrical
Engineering major in Telecommunication for his valuable guidance during the
troubleshooting process of the controller circuit.
Nevertheless, my great appreciation dedicated to all my friends from Faculty
of Electrical Engineering batch 2008 and those that involve directly or indirectly
with this project.
Finally, the most important, my project would not be carried out smoothly
without the continuing support and encouragement given by my parent, lecturers,
tutors, SEI and SEM students, and Diploma-Degree student intake 2006. I would like
to express my sincere gratitude to them especially for their helping during the time in
need.
v
ABSTRACT
Since the crime cases in Malaysia increase, the security system also expands.
Today Radio Frequency Identification (RFID) is the answer for all problem
approach. It is an automatic identification (Auto-ID) technology which allows remote
interrogation of ID data on RFID tags using radio frequency (RF) as a means of
wireless communication between tagged objects and RFID readers. It is really useful
in tracing and identification. This system is suitable to be used in secure buildings
such as colleagues, army headquarters, condominium, universities, and so on. This
project was conducted to improve the security system as well as to reduce the crime
in office building. This project used 125 kHz RFID system including RFID tag,
RFID reader, PIC microcontroller 16f788A and also PLC OMRON CPM 2a. By
using only one RFID reader, the main entrance door and other doors can be opened
by employee that on default. It also was used for the staff attendance system. PLC
system was used as the surveillance system for the office during the night. In This
project, programming language of visual basic 6 was developed to design the system
interface. The system interface was connected by Microsoft Access database to store
the registration information. Then, the RFID system was linked to the computer
processing database and output application hardware via serial communication.
vi
ABSTRAK
Memandangkan kes jenayah di Malaysia semakin meningkat, kawalan
keselamatan juga semakin diperketatkan terutamanya di bangunan-bangunan yang
memerlukan kawalan keselamatan yang tinggi seperti ibu pejabat tentera, universiti,
kondominium, kolej dan sebagainya. Pengesan Radio Frekuensi (RFID) merupakan
teknologi alat pengesan automatik yang membenarkan pemindahan data pada RFID
tag melalui sistem perhubungan tanpa wayar antara tag dan reader. RFID sangat
berguna dalam sistem pengesan. Projek ini telah dibangunkan untuk meningkatkan
sistem keselamatan disamping mengurangkan kes jenayah dan kecurian kenderaan.
Projek ini menggunakan sistem RFID 125 kHz termasuk tag dan reader. Perisian
visual basic 6 telah dibangunkan untuk mereka sistem antaramuka. Microsoft Access
database telah disambungkan ke sistem antaramuka untuk menyimpan maklumat
yang telah didaftarkan. Akhirnya, sistem RFID ini dihubungkan ke system
pemprosesan data komputer dan aplikasi keluaran melalui antaramuka perhubungan
sesiri.
vii
TABLE OF CONTENTS
CHAPTER
TITLE PAGE
DECLARATION
ii
DEDICATION
iii
ACKNOWLEDGEMENT
iv
ABSTRACT
1
2
PAGE
v
ABSTRAK
vii
TABLE OF CONTENTS
ix
LIST OF FIGURES
xii
LIST OF TABLES
xiii
CHAPTER 1
1.1
Background
1
1.2
Objectives
2
1.3
Scope of Work
2
1.4
Outline Thesis
3
LITERATURE REVIEW
2.1
Introduction
4
viii
2.2
Programmable Logic Controller 1
4
2.3
RFID Technology
5
2.4
RFID Tags
6
2.4.1 Passive Tag
7
2.4.2 Active Tag
7
2.5
Reader
8
2.6
Microcontroller
9
2.7
3
2.6.1 PIC16F877A
11
2.6.2
12
USART
Serial Communication Interfaces
13
2.7.1 RS 232 Serial Port
14
2.7.2 Speed
15
2.8
Liquid Cristal Display (LCD)
16
2.9
Programming Tools
16
2.9.1 Microsoft Visual Basic 6.0
17
2.92
18
Microsoft Access
METHODOLOGY
3.1
Introduction
19
3.2
Database Interface
20
3.2.1 ActiveX Data Object (ADO)
20
3.2.2 Microsoft Access
21
3.2.2.1 Microsoft Access Table
3.3
3.4
3.5
22
RFID Door Security System
22
3.3.1 Staff Identification
25
Connection VB6 to RFID READER
25
3.4.1 Microsoft Comm. Control 6.0
26
Connection to PIC16F877A
27
3.5.1
Connection from PIC to MAX232 to PC
29
ix
3.6
USART Connection
30
3.7
Interface LCD (2 x 16 characters)
31
3.8
Programming PIC 16F877A
32
3.8.1 MP LAB IDE
32
3.8.2 ICPROG
33
4
RESULTS AND DISCUSSION
4.1
Introduction
34
4.2
Project Result
34
4.3
Database System
35
4.3.1 Login Menu
35
4.3.2 Main Menu
36
4.3.3 Data Base
37
4.3.4 News Registration
38
4.3.5 Interfacing
39
4.3.6 Record
40
4.4
Hardware
41
4.5
Discussion
43
4.6
Suggestion and Recommendation
44
REFERENCES
45
APPENDICES
46
x
LIST OF TABLE
TABLE NO.
TITLE
PAGE
2.1
Frequency band and Aplication
5
2.4
LCD Function Pins
16
xi
LIST OF FIGURE
FIGURE
TITLE
PAGE
2.0
Variety tag in Market
8
2.1
Reader
9
2.2
Pin Diagram PIC 16f877A
12
2.3
Pin Connection DB9 female
14
2.4
2 x 16 character LCD
16
3.1
Adodc1 interface
20
3.2
Example of data source and data field
21
3.3
Block Diagram RFID Security Door
23
3.4
How Security RFID Door works
23
3.5
Pin Diagram MAX 232
24
3.6
Pin Diagram MAX 232
27
3.7
RS 232 Receiver TTL input
28
3.8
RS 232 Transmitter and TTL outpu
28
3.9
Connection from PIC to MAX232 to PC
29
4.1
Staff name and password for security system
35
4.2
Main Menu
36
4.3
Data Base Form
37
4.4
Registration Form
38
4.5
Staff Information Interface
39
4.6
Record Form
40
xii
LIST OF ABBREVIATION
RFID
-
Radio Frequency Identification
PIC
-
Peripheral Interface Controller
USART
-
Universal Synchronous Asynchronous Receiver Transmitter
ASCII
-
American Standard Code for Information Interchange
IC
-
Integrated Circuit
PC
-
Personal Computer
I/O
-
Input/Output
GUI
-
Graphical User Interface
LCD
-
Liquid Crystal Display
LED
-
Light Emitting Diode
CPU
-
Central Processing Unit
MCU
-
Microcontroller Unit
RAM
-
Random Access Memory
ROM
-
Read Only Memory
EEPROM
-
Electrically Erasable Programming ROM
CMOS
-
Complementary Metal Oxide Semiconductor
LF
-
Low Frequency
HF
-
High Frequency
UHF
-
Ultra High Frequency
DBMS
-
Database Management System
DAO
-
Data Access Object
MS
-
Microsoff
LIST OF APPENDICES
APPENDIX
TITLE
PAGE
A
VB6 Source Code
46
B
MP LAB Source Code
62
C
PLC Mnemonic Code
71
2
CHAPTER 1
INTRODUCTION
1.1
Background
Most of the entry door system of a highly secured building today requires
user to use tradition technique that need a key to performing and efficient access
control system in order to improve the security system of the area. Under the old
system, user need a key to open and close the door and only the person who have the
key can get enter into the building. However, this is a risk technique because the
building still can be access by unauthorized person if has the duplicate the key.
Hence, this project will develop to move from a manual door entrance system to an
automatically door access control system.
Besides that, this RFID system in this project also act as the user attendance
and it’s also used to record down the time for all granted user who are entering and
out the office building. This project explains the background of RFID or Radio
Frequency Identification system specifically on 125 kHz RFID system,
Microcontroller PIC18F877A, database system and the relationship of each part with
the security system. RFID and microcontroller PIC16F877A are two essentials parts
of the security system development in this project.
1.2
Objective of Project
The main objective of this project is to enhance the level of office building
security system by using RFID (Radio Frequency Identification) Technology and
PLC. Following are the specific objectives that are needed to achieve the main goal
sequentially.
i.
To use the application of 125 kHz RFID system as the door access and also as a
user attendance system.
ii.
To interface PIC microcontroller with visual basic6 and LCD 16x2
iii.
To prove that PLC also can be used in security system not just as in industrial.
1.3
Scope Of Project
There are several scope had been outlined in order to accomplished the
objectives of this project. The scopes of this project are as follows:
i.
Writing the data code for the reader by using visual basic
ii.
Design and program the controller circuit to Microcontroller PIC 16F877A
by using MPLAB IDE V8.1
iii.
Microsoft Visual basic 6.0 and Microsoft Access 2003 software are used for
implementing the graphical user interface and the database system
iv.
The hardware part of this project is the controller circuit which is used to
display the status of the user on the LCD. This project used MPLAB software
to program microcontroller PIC16F877A.
2
1.4
Outline of Thesis
This thesis consists of four chapters. In first chapter, it discussed the overall
idea of this project including objectives of project, problem statement, and scope of
work and summary of work.
Chapter 2 discussed more on theory and literature reviews that have been
done. It well discuss about the basic concept of RFID system, PIC16F877A
microcontroller, the serial communication interface, Microsoft Visual Basic 6 and
MPLAB software.
Chapter 3 described the methodology of hardware and software
implementation of this project. The tools, component and software used to
accomplish the project also discussed in this chapter.
Chapter 4 presents a discussion of the implementation, result and analysis of
the whole security door system.Lastly this chapter provides the conclusion of the
project. There are also several suggestions that can be used for future implementation
of RFID Door Security System.
CHAPTER 2
LITERATURE REVIEW
2.1 Introduction
This chapter gives the study of RFID technology and the basic concept of
RFID system which are tag, reader and antenna. It also briefly discuss
microcontroller, Programmable Logic Controller, Ladder Diagram, serial
communication interface, Microsoft Access, Microsoft Visual Basic 6.0, MPLAB
and Proteus ISIS 7 Professional.
2.2
Programmable Logic Controller
A programmable logic controller (PLC) is an industrial computer used to
control and automate complex systems. Programmable logic controllers are a
relatively recent development in process control technology. It is designed for use in
an industrial environment, which uses a programmable memory for the integral
storage of user-oriented instructions for implementing specific functions such as
logic, sequencing, timing, counting, and arithmetic to control through digital or
analog inputs and outputs, various types of machines or processes.
Programmable logic controllers are widely used in industry and process
control. Programmable logic controllers are used in a wide spectrum of applications
from factory automation to waste water treatment plant controls and from chemical
process plant control to engine management systems. Each application has a unique
program, written to the user's specifications, to control the sequence of events for that
particular system.
Programmable logic controllers are used throughout industry to control and
monitor a wide range of machines and other movable components and systems. As a
part of process control, a PLC is used to monitor input signals from a variety of input
points (input sensors) which report events and conditions occurring in a controlled
process. For example, a PLC can monitor such input conditions as motor speed,
temperature, pressure, volumetric flow and the like.
2.3
RFID Technology
RFID is an abbreviation of Radio Frequency Identification, which is a recent
technology that automatically tracks object remotely via radio frequency. Originally,
this technology was implemented during World War II to identify and authenticate
allied planes; this was known as Friend or FOE.1 This type of identification is still
being used today for the same purpose. The beneficial features provided by RFID
system is the capability of real-time object visibility with high accuracy enabling
continuous identification and location of all items and thereby providing accurate
real-time data management instead of simple snapshots.
Radio frequency identification (RFID) technology is attracting considerable
attention as a complement or even replacement for bar code because of the
significant range, speed and unattended reading advantages it provides. However,
users should expect more than improved reading before investing in an RFID system.
RFID has read/write ability, and users can unlock the full value and benefits of the
1
http://www.whitepapersource.com/forum/viewtopic.php
2
technology by taking advantage of the ability to add and change data on the tag in
real time. Read/write RFID creates many new applications in the supply chain and
helps accommodate changes in business processes, customer requirements or
standards.
RFID uses radio waves that are generally between the frequencies of 30 kHz
and 5.8 GHz. Different frequencies have different characteristics that make them
more useful for different applications. For the time being, four frequency ranges are
generally distinguished for RFID system. Table 2.1 summarizes these four
frequency ranges, along with the typical system characteristics and examples of
major areas of application.
Table 2.1: Frequency bands and applications
Frequency Band
Characteristics
Low Frequency (LF)
Short read range less than
Range : 30 kHz – 300 kHz 1m
Inexpensive
Commonly use 125 kHz
Low reading speed
Low power labels
Noise sensitive
High Frequency (HF)
Range : 3 MHz – 30
MHz
Commonly use
Read range about 1m
Medium reading speed
Less noise sensitive
Potentially inexpensive
Typical Applications
Animal identification
Beer keg tracking
Car key immobilizer
Building access control
Smart cards
Bookstore tracking
13.56MHz
Ultra High Frequency
(UHF)
Range : 300 MHz – 1
GHz
433MHz (active tag)
860 MHz – 960 MHz
Long read range
High reading speed
Expensive
Container tracking
Smart shipping
Microwave Frequency
Upward from 1 GHz
2.45 GHz
Longest read range
Highest reading speed
Most expensive
Toll collection system
containers
3
2.4
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), where as 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.4.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
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.
4
2.4.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.
Figure 2.0 Variety of tag in the market
2.5
Reader
An RFID reader, also called an interrogator, is a device that can read from
and write data to compatible RFID tags. An RFID reader typically contains a module
(transmitter and receiver), a control unit and a coupling element (antenna). The
reader has three main functions which are energizing, demodulating and decoding. In
addition, readers can be fitted with an additional interface that converts the radio
waves returned from the RFID tag into a form that can then be passed on to another
5
system, like a computer or any programmable logic controller. Anti-Collision
algorithms permit the simultaneous reading of large numbers of tagged objects, while
ensuring that each tag is read only once. Figure 2 shows some RFID readers.
Figure 2.1 Reader
2.6
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). Have 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
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
6
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.
To summarize, a microcontroller contains (in one chip) two or more of the
following elements in order of importance:
i. Instruction set
ii. RAM
iii. ROM, PROM or EPROM
iv. I/O ports
v. Clock generator
vi. Reset function
vii. Watchdog timer
viii. Serial port
ix. Interrupts
x. Timers
xi. Analog-to-digital converters
xii. Digital-to-analog converters
7
2.6.1 PIC 16F877A
PIC stands for ‘Peripheral Interface Controller’, general instrument as small,
fast, inexpensive embedded microcontroller with strong input/output capabilities.
The PIC18F877A is CMOS Flash-based 8 bit microcontroller. It packs into 40-pin
package with 3 ports for input/output which are Port A, Port B, Port C and Port D.
In this project, PIC16F877A will be use. PIC16F877A is in either baseline
core or mid-range core devices in the PIC’s family core architecture. PIC16F877A
also have enhanced core features, eight-level deep stack, and multiple internal and
external interrupt sources.
PIC18F877A has been chosen because of its USART (Universal Serial
Asynchronous Receiver Transmitter) function. In this project, USART is used to
communicate between hardware and PC serial port. The details explanation of
USART function will be discussed in the next sub-chapter. Besides, this
microcontroller also has input/output port just enough for the project application.
Figure 2.2 shows Pin Diagram for PIC18F877A.
Figure 2.2: Pin Diagram PIC 16f877A
8
2.6.2 USART
USART (Universal Synchronous Asynchronous Transmitter) USART stands
for Universal Synchronous Asynchronous Receiver Transmitter. It is sometimes
called the Serial Communications Interface or SCI. Synchronous operation uses a
clock and data line while there is no separate clock accompanying the data for
Asynchronous transmission. Since there is no clock signal in asynchronous
operation, one pin can be used for transmission and another pin can be used for
reception. Both transmission and reception can occur at the same time, this is known
as full duplex operation. Transmission and reception can be independently enabled.
However, when the serial port is enabled, the USART will control both pins and one
cannot be used for general purpose I/O when the other is being used for transmission
or reception. The USART is most commonly used in the asynchronous mode. The
most common use of the USART in asynchronous mode is to communicate to a PC
serial port using the RS-232 protocol.
2.7
Serial Communication Interface
Serial communication is a very common protocol for device communication
that is standard on almost every PC. Most computers include two serial ports. Serial
communication is also a common communication protocol that is used by many
devices for instrumentation, numerous GPIB-compatible devices also come with a
serial communication port. Furthermore, serial communication can be used for data
acquisition in conjunction with a remote sampling device. Serial communication only
sends or receives a single bit at a time. Although this is slower than parallel
communication, which allows the transmission of an entire byte at once, it is simpler
and can be used over longer distances.
9
Serial communication has two types which are asynchronous and
synchronous communications. Synchronous communication requires more complex
interface and clock is sent along with data with higher rate than asynchronous
communication. Synchronous communication requires that each end of an exchange
of communication respond in turn without initiating a new communication. A typical
activity that might use a synchronous protocol would be a transmission of files from
one point to another. As each transmission is received, a response is returned
indicating success or the need to resend.
On the other hand, asynchronous communication is usually for a situation
where data can be transmitted intermittently rather than in a steady stream. For
example, a telephone conversation is asynchronous because both parties can talk
whenever they like. If the communication were synchronous, each party would be
required to wait a specified interval before speaking. The difficulty with
asynchronous communications is that the receiver must have a way to find the end of
talks of the other side so that one starts to speak. In computer communications, this is
usually accomplished through special bits to indicate the beginning and the end of
each piece of data. Asynchronous communication, therefore, has simpler interface
and does not send clock, but requires start and stop bits.
2.7.1
RS-232 Serial Port
RS-232 is a long-established standard that describes the physical interface
and protocol for relatively low-speed serial data communication between computers
and related devices. RS-232 is a popular communications protocol for connecting
modems and data acquisition devices to computers. It is used for many purposes,
such as connecting a mouse, printer, or modem, as well as industrial instrumentation.
10
Because of improvements in line drivers and cables, applications often
increase the performance of RS-232 beyond the distance and speed listed in the
standard. RS-232 is limited to point-to-point connections between PC serial ports and
devices. RS-232 devices can be plugged straight into the computer's serial port. RS232 hardware can be used for serial communication up to distances of 50 feet.
A nine pin D plug has become the standard fitting for the serial ports of PCs.
The pin connections used are as shown in figure 2.3. The connector on the PC has
male pins; therefore the mating cable needs to terminate in a DB9/F (Female pin)
connector.
Figure 2.3: Pin Connection DB9 female
2.7.2
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 teleprompters.
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
11
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.8
Liquid Crystal Display (LCD)
There are a wide variety of shapes and sizes of LCD. Line lengths of 8, 16,
20,24, 32 and 40 characters are all standard in one, two, and four-line versions. Each
character is displayed using 5x7 pixel font matrix. The module has a character
generator ROM capable of displaying ASCII characters. Most LCD modules
conform to a standard interface specification. A 14-pin access is provided having
eight data lines, three control lines and three power lines.
Figure 2.4 shows the front view of LCD. The function of each pin of the
connections is shown in Table 2.4.
Figure 2.4: 2 x 16 character LCD
12
Table 2.4 : LCD’s function pin
Pin
1
2
3
4
5
6
7-14
15
16
2.9
Name
Vss
Vcc
Vee
RS
R/W
E
DB0 – DB7
LED+
LED-
Pin Function
Ground
Positive Supply for LCD
Brightness adjust
Select Register
Select read or write
Start data read or write
Data Bus Pin
Backlight Positive Input
Backlight Negative Input
Programming Tools
The programming tools used in the project are Microsoft Visual Basic6,
Microsoft Access, MP LAB and CX programmer.
2.9.1 Microsoft Visual Basic 6.0
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.
13
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++, JavaScript, C# and Java 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.
2.9.2
Microsoft Access
Microsoft Access is a relational database management system from Microsoft
which combines the relational Microsoft Jet 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/Jet, 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 nonprogrammer "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.
14
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.9.3 CX Programmer
CX-Programmer is a support tool for the programming of OMRON PLCs and
for maintenance of their device settings. It supersedes the OMRON applications
SYSWIN and SYSMAC-CPT.
The following list describes important features that were present in CX-Programmer
2.0.
i.
Improved search / replace - including wildcards and memory range
movement.
ii.
Improved ladder and mnemonic editors, with much greater clarity, and
improved zooming.
iii.
It is possible to choose the format and amount of symbol information to show
on
iv.
The ladder editor automatically justifies a ladder rung when the cursor is
moved
v.
Errors in ladder elements are shown a definable 'Error' color.
vi.
The shortcut keys and toolbars can be customized.
CHAPTER 3
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 for
certain door that on default.
Each phase has different methodology in order to complete this project. In
this chapter, all the used methodology will be shown and explain
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 User database. In order to make
the link work, firstly the database in Microsoft Access must be established. The User
database is the main and only database for this project. Figure 3.1 shows the Adodc1
interface.
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
‘user_name’ column in the User 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
‘user_name’.
2
Figure 3.2: Example of Data Source and Data Field
3.2.2
Microsoft Access
Microsoft Access is a relational DBMS (Database Management System) with
all the features necessary to develop and use a database application. Access can
usedata stored in Access or Jet, Microsoft SQL Server, Oracle, or any ODBCcompliantdata container (including MySQL and PostgreSQL). Access allows
relatively quick development because all database tables, queries, forms, and reports
are stored in the database.
Microsoft Access combines the relational Microsoft Jet Database Engine with
a graphical user interface and software development tools. In this project, Jet
database is link to the Visual Basic program using ADO data control
3.2.2.1
Microsoft Access Table – User
The User table is the main source in this project. It holds all the information
that is required for each registered user.
3
To link Microsoft Access table with VB6, we must first save the table as User
under the “rfid” database. In “rfid” database as only one table and it is ‘user” table.
The user table has ten sub divisions. Every each division holds information about the
user such as ‘user_name’, ‘user_id’ and ‘user_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.
3.3
RFID Door Security System
This RFID Door Security System designed to increase the high secured
building security such as army headquarters, colleagues and so on. The security
system used 125 kHz RFID system as the vehicle identification. The 125 kHz RFID
is including RFID tag on user matrix card and RFID reader placed above at the door.
The tag consists of staff unique identification codes which are alphanumeric form
and differ for each staff. The door will only be unlocked for the granted staff.
4
Figure 3.3 Block Diagram RFID Security Door System
Figure 3.4 How Security RFID Door works
Figure 3.5: Office’s Model
5
When the staff arrives to the door early morning, he/she will touch the tag at
the reader. Then reader will read the staff identification code or tag ID from the tag.
If the staff identification code from the RFID 125 kHz tag matched with one of the
identification code list on the database system, the information of the relevant staff
will appear on the computer screen at the security desk and time of the relevant staff
using the door will be recorded to the database system. Then, computer will send an
appropriate signal to the controller circuit via serial communication port. For the
granted staff, Green LED will turn ON which indicates that the door’s lock is
unlocked to allow the staff to enter the office and buzzer sound beep once. At the
same time, tag ID and Staff Name will display on the LCD.
There are 5 green LED in this project to indicates 5 doors that should be
controlled. Every single door can be opened only by those who have the permission
from employer. As example if the employee is a woman who comes in early morning
she just can access the main door and female toilet .If he/she is a cleaner that’s mean
he/she just can access the main door and all toilet in the office.
Since the controller circuit is controlled by Microcontroller PIC18F877A, the
correct and completed codes for the controller loaded and programmed into the
Microcontroller PIC18F877A chip. The source code for designing the controller
circuit was written in C programming language and compiled using MP Lab
software. The model of the controller circuit was designed on the strip board.
3.3.1 Staff Identification
The database has only one data system that is Staff Identification. In Staff
Identification it has ten information of a staff. This information is inserting only by
the assigned administrator. The information is confidential and only the administrator
knows about it.
6
In Microsoft Access database, information must have it own name. The name cannot
be duplicated or doubled in the table. Below is the staff information with the field
name in the bracket.
The staff 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 Martial Status (Staff _marriage)
• Staff Registration Date (Staff _regdate)
3.4
Connection VB6 to RFID READER
To match the ID-TAG number with the staff, connection from RFID
READER to VB6 must be establish. With this connection, we can see what is the IDTAG number in the ID-TAG itself.
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
discuss how VB6 to receive data from RFID READER and that is the ID-TAG
number.
7
3.4.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 we’re 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.
3.5
Connection to PIC16F877A
Connection to PIC16F84A was the trickiest phase in this project. To establish
a connection to PIC16F877A 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
8
1.3V and a typicall hysteresis of 0.5V, and can accept + 30V inputs. Each driver
converts TTL/CMOS input levels into EIA
EIA-232 levels. MAX232 pinn diagram is
shown in Figure 3.7.
Figure 3.6 Pin Diagram MAX 232
Transmitter’s and receiver’s signal have low level and high level. In
transmitter’s logic levels the low level for RS232 output is between +5V to +15V
and for Transistor-transistor
transistor Logic (TTL) output is from 0V to +0.4V while in the
high level for RS232 output
tput is between -5V to -15V
15V and for TTL output is from
+2.4V to +5V.
In receiver’s logic levels the RS232 transmitter must have highest voltage
than the input threshold of the RS232 receiver (+3V).
( 3V). The receiver logic level for the
RS232 input is from +3V
V to +15V and for TTL input is from 0V to +0.8V. In the
high level for the RS232 is from -3V to -15V
15V and for TTL input is between +2V to
+5V.
In both figures below shows the RS232 receiver and transmitter vvoltage level
diagram. Figure 3.7 is the
he RS232 receiver and Figure 3.8 is the RS232 transmitter.
9
Figure 3.7 RS232 receiver and TTL input.
Figure 3.8 RS232 transmitter and TTL output
10
3.5.1 Connection from PIC to MAX232 to PC
Figure 3.9: Connection from PIC to MAX232 to PC
Figure 3.9 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.
11
3.6
USART Connection
In order to connect a microcontroller to a computer, MAX 232 is used to
convert the voltage level from 10 Volt to 5 Volt TTL/CMOS level. This is because
the voltage level on a PC is -10V for logic zero, and +10V for logic one while the
voltage level on the microcontroller is +5V for logic one and 0V for logic zero. The
connection between PIC16F877A, MAX232 and DB9 is referred from USART
Library that provided in MPLAB Libraries. Figure 3.10 shows the connection
between PIC18F877A, MAX232 and DB9 Female.
Figure 3.10 : Connection between PIC18F877A, MAX232 and DB9 Female
12
3.7
Interface LCD (2 x 16 character)
LCD is used in this project to provide staff with the output result, which is the
status of the staff. For this project, port B of microcontroller are use to connect the
microcontroller to the LCD data pin. The LCD is connected to the microcontroller
using 8 bit mode. For the granted staff, the LCD will display tag ID number and
staff’s name while for non-granted staff, the LCD will display ‘Staff Not Found’.
Figure 3.12 shows the connection between PIC18F877A and LCD.
Figure 3.12: Hardware Connection for LCD
13
3.8
Programming PIC 16F877A
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 staff) or RED LED (invalid staff) after the staff scan their ID-TAG to the
RFID READER. This simple program must include transmit and receive instruction
to MAX232.
In PIC16F877A it has 24 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.
3.8.1 MP LAB 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 there’s a functional error. In MPLAB IDE library
has the PIC16F877A, so it supported the simulation of the program that includes
PIC16F877A.
14
3.8.2 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.13 shows the ICPROG
programmer window.
Figure 3.13: ICPROG programmer
CHAPTER 4
RESULTS AND DISCUSSION
4.1
Introduction
After the system fully integrates, the system went through an extensive
testing.From the test conducted, every output and result of the system were verified.
The results were directly corresponding to the objectives of the system, which were
defined earlier in the introduction.
4.2
Project Result
The database system interacts with 125 kHz RFID system successfully and
able to detect the vehicle with RFID tag ID whenever the staff scans the tag at the
reader. The database system also capable to search for the matched RFID tag ID
stored in the current database. Then, the Visual Basic program will sends an
appropriate signal to the controller circuit via serial communication interface port
and there is output display on the LCD. Green LED or red LED will turn on to
indicate the rotation of the arm-barrier. Buzzer also will sound beep when the LCD
displays the output. At the same time, the staff’s details will display on the monitor
screen as well as recording the time to the database system.
4.3
Database System
The database system store all the staff’s information and time record. There
are two tables built in Microsoft Access to store the staff’s details. The database
designed interacted successfully with the main system which is VB program. The VB
program will look up and retrieve the required staff information stored in the
database system. Once the VB program add, delete or edit the staff information, the
database system will update the database automatically.There are eight frames
designed in VB which are frame Introduction, Login, Menu, Database, Registration,
Edit, Record and Interface. The coding for each frames are shown in Appendix A.
4.3.1 Login Menu
Figure 4.1 : Staff Name and Password for Security
2
4.3.2 Main Menu
Figure 4.2: Main Menu for RFID Door Security Database System
There are two modules in Main Menu which are View as the staff interface
and database to store all the staff information. Exit button used to exit from this
system.
3
4.3.3 Database
Figure 4.3: Database Form
Database form is connected to the Microsoft Access using Microsoft ADO
Data Control. Microsoft Data Grid used to display all the data from Microsoft Access
in VB interface. From database form, staff admin also can add new record, edit or
delete the staff information. All the time record can be shown by clicking button
Record. To go to main menu, admin can click button Main Menu.
4
4.3.4 New Registration
Figure 4.4: Registration Form
To add information for new staff, admin have to fill up the registration form.
When clicking the Add New button, a message box ‘Please Wave Your Tag at the
Reader’ will display. Once the reader detects the tag ID, VB will display the tag ID
in the tag ID text box. Then, admin can type the staff information and then Click
Save button to store data in the database system.
5
4.3.5 Interfacing
Figure 4.5: Staff Information Interface
Interface is the main frame for this system. When the staff touches the tag on
the reader, the VB program finds the match tag ID from the database. If the tag ID is
in the current database, all the staff information will display automatically on the
frame interface and Time In will be recorded and stored in the database. Time Out
will record when the staff want to leave the door.
6
4.3.6
Record
Figure 4.6: Record form
Admin can check the staff that enter and out from the area from Record
frame. The database records the unique staff ID, time and date.
7
4.3
Hardware
The controller circuit displays the welcome note and it only will display the
status of staff on the LCD when it receives the signal from serial communication
port.
After designed schematic of the circuit, the coding for the controller circuit is
written in C language using MP LAB software. Appendix B shows the source code
to program
PIC18F877A. After the compilation success, the controller circuit is tested
virtually using Proteus software. The schematic circuit is designed and draws in
Proteus. In Proteus, the 5V power supply and crystal oscillator are automatically
connected to the microcontroller. Then *.hex file is downloaded into the PIC in the
schematic circuit.
The correct output of the circuit will be shown by the software virtually.
Figure 4.7 shows the result when the controller circuit is tested using Proteus
software. After get the correct output from Proteus, the circuit is first tested by using
protoboard and then built the circuit using strip board.
8
Figure 4.7 Connection all circuitry
When give the power to the controller circuit, it will beep once and green
LED at the power supply will turn on to show the power status. At the same time,
welcome note ‘RFID Door Security’ and ‘Place Your ID on the Reader’ will display
on the LCD screen. This circuit can be reset by clicking the push button. Figure 4.8
shows the Welcome Note after give the power to the circuit.
Figure 4.8: Welcome note displayed on the LCD screen
9
When the staff places their tag on the reader, VB program will check the tag
ID and then give instruction to open the serial communication port to the controller
circuit. In this project, the serial communication for the reader used comm. 6 while
serial communication for the controller circuit used comm. 8. VB will write data
which is the tag ID from comm. 6 to comm. 8 and then comm. 8 will send the data to
MAX232 at the controller circuit using RS232 serial port. Then, MAX232 send the
data to PIC16F877A. PIC will compare the tag ID sent by comm. 8 with the tag ID
stored in PIC memory.
If it found the match tag ID, the Staff Name and Tag ID will displayed on the
LCD screen and the buzzer sound beep once and green LED turn on.
If PIC did not found the match tag ID, the LED displayed ‘Staff Not Found’
on the LCD screen and the buzzer sound beep twice and red LED on. After a few
second, the LCD will display the welcome note ‘Place Your ID on the Reader’ again.
It will repeat continuously.
4.3
Discussion
After testing the system, it is clear that this project achieve most of the
objectives. It has been proved that the reader can communicate to the controller
circuit successfully via the serial communication port. The system is able to display
the output on the LCD screen, switch on the entire led base on admin requirement
and sound the buzzer whenever the controller circuit gets the signal from serial
communication port.
The related features that can be seen in this system are:
i. The multicolor of LEDs are use to indicate different situation.
ii. The LCD displays the welcome note and the status of the staff.
iii. The buzzer sound beep twice when the microcontroller didn’t found the match tag
10
iv. The operation of RFID Door Security System goes in continuously
There also some constraint faced during the process of developing the
database system of this project were that the tag ID did not appear on the VB
interface whenever the tag touched on the reader. The problem found after trouble
shooting process. Actually, data from the reader is sent character by character to the
HyperTerminal of the computer via RS232 serial communication port. The problem
was solved successfully after change the right coding to read data from
HyperTerminal to VB program.
Another problem was in USART programming for microcontroller. The
circuit did not interact with the computer whenever the user touched the tag on the
reader. For this problem; it was found that there was a problem with USART
initialization coding. After that, all the source code was recompile and reload to the
microcontroller.
4.4
Suggestion and Recommendation
This system also can be expanding by installing readers at the entrance of
facilities places such library, pool, washing machine, tennis court and so on. The
users only use one tag for many applications. Besides that, RFID system also can be
applied for the new student registration at school when the new semester begins.
Beside that we also can use the manual key system as the supplement for the
security system. That’s mean, in order the failure of power supply (electrical system)
the RFID security system will be shut off then we still have the manual system.
11
Lastly, this project can be combined with GSM application where the AT
command can be used to construct the GSM modem using VB program. So, the
admin can send SMS from computer to the user’s mobile to remind them to renew ID
or password and so on.
12
REFERENCES
1.
Alka R. Harringer, Susan K. Lisack, John 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 O’Cull. (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.
Sandip Lahiri. RFID Source Book. 1stedition. Upper Saddle River, New
Jersey: Pearson. 2006
5.
Julia Case Bradley, Anita C. Millspaugh. Programming in Visual Basic 6.0
Version 6. New York: McGraw-Hill. 2002.
6.
PIC16F87X Datasheet, Microchip Technology Inc
7.
Visual Basic: www.planetsourcecode.com
8.
http://en.wikipedia.org/wiki/Radio-frequency_identification
Aplikasi PLC sebagai sistem kawalan keselamatan berkonsepkan pintu pintar
9.
/ Mohammad Effero Echek
13
APPENDIX A
Source Code of Visual Basic 6.0 for Frame Login
Option Explicit
Public LoginSucceeded As Boolean
Private Sub cmdCancel_Click()
'set the global var to false
'to denote a failed login
LoginSucceeded = False
Me.Hide
End
End Sub
Private Sub cmdOK_Click()
'check for correct password
If txtStaffName = "fahmi" And txtPassword = "1234" Then
'place code to here to pass the
'success to the calling sub
'setting a global var is the easiest
LoginSucceeded = True
frmLogin.Hide
Main_Frame.Show
Else
MsgBox "Invalid Password, try again!", , "Login"
frmLogin.Show
End If
End Sub
14
Source Code of Visual Basic 6.0 for Frame Main Menu
Option Explicit
Private Sub Click_System_Click()
Unload Me
REFID_Interface.Show
End Sub
Private Sub Command_record_Click()
Unload Me
Record_Form.Show
End Sub
Private Sub Command_Register_Click()
Unload Me
Register_Form.Show
End Sub
Private Sub Database_Click_Click()
Unload Me
DatabaseManagment.Show
End Sub
Private Sub Exit_Click()
Unload Me
Exit_dialog.Show
End Sub
Private Sub Timer1_Timer()
End Sub
Private Sub Image2_Click()
End Sub
15
Source Code of Visual Basic 6.0 for Frame Database
Option Explicit
Private Sub Back_Menu_Click()
Unload Me
Main_Frame.Show
End Sub
Private Sub Command_Delete_Click()
If (Adodc1_Staff.Recordset.BOF And Adodc1_Staff.Recordset.EOF) Then
MsgBox "No Record in the database", , "Can't delete"
Else
Adodc1_Staff.Recordset.Delete
Adodc1_Staff.Recordset.MoveNext
If Adodc1_Staff.Recordset.EOF Then
Adodc1_Staff.Recordset.MovePrevious
End If
End If
End Sub
Private Sub Command_Newdata_Click()
Unload Me
Register_Form.Show
End Sub
Private Sub Exit_Click()
Unload Me
Exit_dialog.Show
End Sub
Private Sub Command_record_Click()
Unload Me
Record_Form.Show
End Sub
Private Sub ICNumber_Click()
Unload Me
Show
Private Sub Command_Search_Click()
16
Unload Me
Search_Data.Show
End Sub
Source Code of Visual Basic 6.0 for Frame New Registration
Const portnum As Integer = 3
Public Aline As String
Public flagIn As Boolean
Private Sub Command_add_Click()
Aline = ""
Data_register.Recordset.AddNew
Text_TagID.Refresh
flagIn = False
With MSComm1
If .PortOpen = False Then
.CommPort = 1
.Settings = "9600,n,8,1"
.RThreshold = 1
.RTSEnable = True
.InputLen = 1
.PortOpen = True
End If
MsgBox "Please Wave Your Tag at the Reader", vbInformation, "Read RFID"
End With
Form_load_exit:
Exit Sub
err_exit:
MsgBox "Unable to Open Comm Port", vbCritical, "CommPort Error"
End Sub
Private Sub Command_Cancel_Click()
Text_TagID.Text = ""
17
Text_No.Text = ""
Text_Name.Text = ""
Text_IC.Text = ""
Text_Sex.Text = ""
Text_phonenumber.Text = ""
Text_emel.Text = ""
Text_position.Text = ""
Text_address.Text = ""
MSComm1.PortOpen = False
Text_TagID.Text = ""
End Sub
Private Sub Command_Delete_Click()
confirm = MsgBox("Are you sure you want to delete this record?", vbYesNo,
"Deletion Confirmation")
If confirm = vbYes Then
Data_register.Recordset.Delete
MsgBox "Record Deleted!", , "Message"
Else
MsgBox "Record Not Deleted!", , "Message"
End If
End Sub
Private Sub Command_EXIT_Click()
Unload Me
Exit_dialog.Show
End Sub
Private Sub Command_Menu_Click()
Unload Me
Main_Frame.Show
End Sub
Private Sub Command_Next_Click()
If Not Data_register.Recordset.EOF Then
Data_register.Recordset.MoveNext
If Data_register.Recordset.EOF Then
Data_register.Recordset.MovePrevious
18
End If
End If
End Sub
Private Sub Command_Previous_Click()
If Not Data_register.Recordset.BOF Then
Data_register.Recordset.MovePrevious
If Data_register.Recordset.BOF Then
Data_register.Recordset.MoveNext
End If
End If
End Sub
Private Sub Command_Refresh_Click()
Text_TagID.Text = ""
Text_No.Text = ""
Text_Name.Text = ""
Text_phonenumber.Text = ""
Text_emel.Text = ""
Text_IC.Text = ""
Text_Sex.Text = ""
Text_adress.Text = ""
Text_position.Text = ""
End Sub
Private Sub Command_Save_Click()
Data_register.Recordset.Fields("No") = Text_No.Text
Data_register.Recordset.Fields("Tag") = Text_TagID.Text
Data_register.Recordset.Fields("Name") = Text_Name.Text
Data_register.Recordset.Fields("IC Number") = Text_IC.Text
Data_register.Recordset.Fields("Sex") = Text_Sex.Text
Data_register.Recordset.Fields("phone number") = Text_phonenumber.Text
Data_register.Recordset.Fields("E-mail") = Text_emel.Text
Data_register.Recordset.Fields("Position") = Text_position.Text
Data_register.Recordset.Fields("Address") = Text_address.Text
Data_register.Recordset.Update
MsgBox "Record Save!", , "Message"
19
End Sub
Private Sub MSComm1_OnComm()
Dim Achar As String
Achar = MSComm1.Input
Aline = Aline & Achar
Text_TagID = Aline
Source Code of Visual Basic 6.0 for Frame Staff Interface
Const portnum As Integer = 1
Public Aline As String
Public flagIn As Boolean
Private Sub Command_Menu_Click()
Unload Me
Main_Frame.Show
End Sub
Private Sub Command_EXIT_Click()
Unload Me
Exit_dialog.Show
End Sub
Private Sub Command_record_Click()
Unload Me
Record_Form.Show
End Sub
Private Sub Form_Load()
Dim vntBookmark As Variant
flagIn = False
On Error GoTo err_exit
With MSComm1
If .PortOpen = False Then
.CommPort = 1
.Settings = "9600,n,8,1"
.RThreshold = 1
.RTSEnable = True
20
.InputLen = 1
.PortOpen = True
End If
End With
timeLable.Caption = Format(Now, "hh:mm:ss AM/PM")
dateLable.Caption = Format(Now, "Long Date") & ""
Form_load_exit:
Exit Sub
err_exit:
MsgBox "Unable to Open Comm Port", vbCritical, "CommPort Error"
End Sub
Private Sub MSComm1_OnComm()
Dim Data As String
Dim Achar As String
flagIn = False
Achar = MSComm1.Input
Aline = Aline & Achar
Text_TagID.Text = Aline
If Len(Aline) = 10 The
With Staff_Database.Recordset
vntBookmark = .Bookmark
.MoveFirst
.Find "Tag Like " & Aline & ""
If Staff_Database.Recordset.EOF Then
With MSComm2
If .PortOpen = False Then
.CommPort = 3
.Settings = "9600,n,8,1"
.RThreshold = 1
.RTSEnable = True
.InputLen = 1
.PortOpen = True
End If
21
End With
DoEvents
If (Len(Achar) > 0) Then
For I = 1 To 10
Data = Mid(Aline, I, 1)
MSComm2.Output = Data
Next
End If
Text_TagID.Text = ""
lblTimeIn.Caption = ""
lblTimeOut.Caption = ""
MsgBox "Tag Not found", vbCritical, "RFID Tag"
.Bookmark = vntBookmark
MsgBox_Click_OK:
Aline = ""
Exit Sub
End If
End With
If lblTimeIn.Caption = "" Then
LogBook.Recordset.AddNew
LogBook.Recordset.Fields("Tag ID") = Text_TagID.Text
LogBook.Recordset.Fields("Name") = Text_Name.Text
LogBook.Recordset.Fields("IC Number") = Text_IC.Text
LogBook.Recordset.Fields("Sex") = Text_Sex.Text
lblTimeIn.Caption = Format(Now, "hh:mm:ss AM/PM")
LogBook.Recordset.Fields("Time in") = lblTimeIn.Caption
LogBook.Recordset.Fields("Time out") = lblTimeOut.Caption
LogBook.Recordset.Fields("Date") = dateLable.Caption
LogBook.Recordset.Update
Aline = ""
With MSComm2
If .PortOpen = False Then
22
.CommPort = 3
.Settings = "9600,n,8,1"
.RThreshold = 1
.RTSEnable = True
.InputLen = 1
.PortOpen = True
End If
End With
DoEvents
If (Len(Achar) > 0) Then
If Text_Sex.Text = "male" And Text_TagID.Text = "0010828700" Then
For I = 1 To 10
Data = Mid(Aline, I, 1)
MSComm2.Output = "k"
Next
Else
If Text_Sex.Text = "male" And Text_TagID.Text <> "0010828700" Then
For I = 1 To 10
Data = Mid(Aline, I, 1)
MSComm2.Output = "o"
Next
Else
If Text_Sex.Text = "female" And position.Text <> "engineer" Then
For I = 1 To 10
Data = Mid(Aline, I, 1)
MSComm2.Output = "s"
Next
Else
If position.Text = "engineer" And Text_Sex.Text = "male" Then
For I = 1 To 10
Data = Mid(Aline, I, 1)
MSComm2.Output = "t"
Next
Else
23
If position.Text = "engineer" And Text_Sex.Text = "female" Then
For I = 1 To 10
Data = Mid(Aline, I, 1)
MSComm2.Output = "i"
Next
'Label1.Caption = Data
End If
End If
End If
End If
End If
End If
Else
If Len(Aline) = 10 Then
If lblTimeOut.Caption = "" And LogBook.Recordset.Fields("Tag ID") =
Text_TagID.Text Then
lblTimeOut.Caption = Format(Now, "hh:mm:ss AM/PM")
LogBook.Recordset.Fields("Tag ID") = Text_TagID.Text
LogBook.Recordset.Fields("Name") = Text_Name.Text
LogBook.Recordset.Fields("IC Number") = Text_IC.Text
LogBook.Recordset.Fields("Sex") = Text_Sex.Text
LogBook.Recordset.Fields("Time in") = lblTimeIn.Caption
LogBook.Recordset.Fields("Time out") = lblTimeOut.Caption
LogBook.Recordset.Fields("Date") = dateLable.Caption
LogBook.Recordset.Update
With MSComm2
If .PortOpen = False Then
.CommPort = 3
.Settings = "9600,n,8,1"
.RThreshold = 1
.RTSEnable = True
.InputLen = 1
24
.PortOpen = True
End If
End With
DoEvents
If (Len(Achar) > 0) Then
For I = 1 To 10
Data = Mid(Aline, I, 1)
MSComm2.Output = Data
Next
'Label1.Caption = Data
End If
Else
If Len(Aline) = 10 Then
With Staff_Database.Recordset
vntBookmark = .Bookmark
.MoveFirst
.Find "Tag Like " & Aline & ""
End With
LogBook.Recordset.AddNew
LogBook.Recordset.Fields("Tag ID") = Text_TagID.Text
LogBook.Recordset.Fields("Name") = Text_Name.Text
LogBook.Recordset.Fields("IC Number") = Text_IC.Text
LogBook.Recordset.Fields("Sex") = Text_Sex.Text
LogBook.Recordset.Fields("Time in") = lblTimeIn.Caption
LogBook.Recordset.Fields("Time out") = lblTimeOut.Caption
LogBook.Recordset.Fields("Date") = dateLable.Captio
lblTimeIn.Caption = Format(Now, "hh:mm:ss AM/PM")
LogBook.Recordset.Fields("Tag ID") = Text_TagID.Text
LogBook.Recordset.Fields("Name") = Text_Name.Text
LogBook.Recordset.Fields("IC Number") = Text_IC.Text
LogBook.Recordset.Fields("Sex") = Text_Sex.Text
LogBook.Recordset.Fields("Time in") = lblTimeIn.Caption
LogBook.Recordset.Fields("Time out") = lblTimeOut.Caption
LogBook.Recordset.Fields("Date") = dateLable.Caption
25
With MSComm2
If .PortOpen = False Then
.CommPort = 3
.Settings = "9600,n,8,1"
.RThreshold = 1
.RTSEnable = True
.InputLen = 1
.PortOpen = True
End If
End With
DoEvents
If (Len(Achar) > 0) Then
If Text_Sex.Text = "male" And Text_TagID.Text = "0010828700" Then
For I = 1 To 10
Data = Mid(Aline, I, 1)
MSComm2.Output = "k"
Next
Else
If Text_Sex.Text = "male" And Text_TagID.Text <> "0010828700" Then
For I = 1 To 10
Data = Mid(Aline, I, 1)
MSComm2.Output = "o"
Next
Else
If Text_Sex.Text = "female" And position.Text <> "engineer" Then
For I = 1 To 10
Data = Mid(Aline, I, 1)
MSComm2.Output = "s"
Next
Else
If position.Text = "engineer" And Text_Sex.Text = "male" Then
For I = 1 To 10
Data = Mid(Aline, I, 1)
MSComm2.Output = "t"
26
Next
Else
If position.Text = "engineer" And Text_Sex.Text = "female" Then
For I = 1 To 10
Data = Mid(Aline, I, 1)
MSComm2.Output = "i"
Next
'Label1.Caption = Data
End If
End If
End If
End If
End If
End If
Else
lblTimeOut.Caption = Format(Now, "hh:mm:ss AM/PM")
LogBook.Recordset.Fields("Tag ID") = Text_TagID.Text
LogBook.Recordset.Fields("Name") = Text_Name.Text
LogBook.Recordset.Fields("IC Number") = Text_IC.Text
LogBook.Recordset.Fields("Sex") = Text_Sex.Text
LogBook.Recordset.Fields("Time in") = lblTimeIn.Caption
LogBook.Recordset.Fields("Time out") = lblTimeOut.Caption
LogBook.Recordset.Fields("Date") = dateLable.Caption
LogBook.Recordset.Update
With MSComm2
If .PortOpen = False Then
.CommPort = 3
.Settings = "9600,n,8,1"
.RThreshold = 1
.RTSEnable = True
.InputLen = 1
.PortOpen = True
End If
End With
27
DoEvents
If (Len(Achar) > 0) Then
For I = 1 To 10
Data = Mid(Aline, I, 1)
MSComm2.Output = Data
Next
'Label1.Caption = Data
End If
If Staff_Database.Recordset.EOF Then
With MSComm2
If .PortOpen = False Then
.CommPort = 3
.Settings = "9600,n,8,1"
.RThreshold = 1
.RTSEnable = True
.InputLen = 1
.PortOpen = True
End If
End With
MSComm2.Output = "f"
End If
End If
End If
End If
End I
Aline = ""
End If
End Sub
Private Sub Timer1_Timer()
timeLable.Caption = "" & Format(Now, "hh:mm:ss AM/PM")
End Sub
28
Source Code of Visual Basic 6.0 for Frame Record
Option Explicit
Private Sub Click_System_Click()
Unload Me
REFID_Interface.Show
End Sub
Private Sub Command_record_Click()
Unload Me
Record_Form.Show
End Sub
Private Sub Command_Register_Click()
Unload Me
Register_Form.Show
End Sub
Private Sub Database_Click_Click()
Unload Me
DatabaseManagment.Show
End Sub
Private Sub Exit_Click()
Unload Me
Exit_dialog.Show
End Sub
Private Sub Timer1_Timer()
End Sub
Private Sub Image2_Click()
End Sub
29
APPENDIX B
//========================================================
//
Author
: FAHMI FATHUDDIN
//
Project
: PSM
//
Project description
: SECURITY DOOR SYSTEM
//=========================================================
//
include
//========================================================
#include <pic.h>
//
//include pic librarY
configuration
//========================================================
__CONFIG ( 0x3F32 );
//
//microcontroller configuration
define
#define RS
RB4 //define port RS for 1=display mode 0=config mod
#define RW
RB5
//RW 1=write mode 0=read mode
#define E
RB6
//
#define BL
RB7
#define Data_LCD
PORTD
#define Led1
RA0
#define Led6
RA1
#define Led3
RA2
#define Led4
RA3
#define Led5
RA5
#defineMHZ *1000L
/* number of kHz in a MHz *
#defineKHZ *1
/* number of kHz in a kHz */
// Value x must not more that 255
#defineDelayUs(x)
{ unsigned char _dcnt; \
_dcnt = (((x)*(20MHZ))/(24MHZ))|1; \
while(--_dcnt != 0) \
continue; \
_dcnt = (((x)*
(20MHZ))/(24MHZ))|1; \
30
while(--_dcnt != 0) \
continue; }
//
Function Prototype
//========================================================
void init(void);
void send_string(const char *s);
void LCD_config(unsigned char data);
void send_char(unsigned char data);
unsigned char ReceiveChar;
void lcd_clr(void);
void delay(unsigned long data);
void lcd_goto(unsigned char data);
void DelayMs(unsigned char y);
// Value y must not more that 255
// delay ms void DelayMs(unsigned char y)
{
unsigned char i;
do {
i = 4;
do {
DelayUs(250);
}
while(--i);
}
while(--y);
}
void init(void)
// subroutine to initialize
{
SPBRG=0x81;
BRGH=1;
// set baud rate as 9600 baud
31
TXEN=1;
CREN=1;
SPEN=1;
}
unsigned char receive(void)
// subrountine to receive text from PC
{
while (RCIF == 0);
ReceiveChar = RCREG;
return ReceiveChar;
}
void delay(unsigned long data)
//delay function, the delay time
{
//depend
on the given value
for( ;data>0;data-=1);
}
void LCD_config(unsigned char data)
//config LCD
{
RS=0;
RW=0;
Data_LCD=data;
E=1;
delay(50);
E=0;
delay(50);
}
void send_string(const char *s)
//Send string to LCD display
{
unsigned char i=0;
while (s && *s)send_char (*s++);
}
void send_char(unsigned char data)
//send lcd character
{
RW=0;
//set lcd to write mode
32
RS=1;
//set lcd to display mode
Data_LCD=data;
//lcd data port = data
E=1;
//pulse e to confirm the data
delay(10);
E=0;
delay(10);
}
void lcd_clr(void)
//clear the lcd
{
LCD_config(0x01);
delay(600);
}
void lcd_goto(unsigned char data)
//set the location of the lcd cursor
{
//if the given value is (0-15) the
if(data<16)
//cursor will be at the upper line
{
//if the given value is (20-35) the
LCD_config(0x80+data);
//cursor will be at the lower line
}
//location
of the lcd cursor(2X16):
else
// -----------------------------------------------------
main function
(main function of the program)
}
//
//========================================================
void main(void)
{
//configure PORTA I/O direction
TRISD = 0b00000000;
TRISB = 0B00000000;
TRISA = 0B00000000;
ADCON1 = 0b00000110;
init();
//LCD config
33
LCD_config(0b00000001);
//clear display at lcd
LCD_config(0b00000010);
//lcd return to home
LCD_config(0b00000110);
//entry mode-cursor increase1
LCD_config(0b00001100);
//display
on, cursor off and cursor blink off
LCD_config(0b00111000);
set
//set intial value or reset circuit
BL=1;
Led1=0;
//RA0 green led
Led3=0;
//RA2 male toilet
Led4=0;
//RA3 female toilet
Led5=0;
Led6=0;
//RA5 ceo room
//set LCD intial condition
lcd_clr();
lcd_goto(0);
send_string(" WELCOME TO ");
lcd_goto(20);
send_string("
ARASH
");
delay(200000);
lcd_clr();
lcd_goto(0);
send_string(" RFID DOOR");
lcd_goto(20);
send_string("SECURITY SYSTEM");
//function
34
while(1)
//infinity
loop
{
ReceiveChar = receive();
if (ReceiveChar == 'o')
{
lcd_clr();
lcd_goto(0);
send_string(" READING TAG ");
lcd_goto(20);
send_string(" PLEASE WAIT.... ");
delay(500000);
lcd_clr();
lcd_goto(0);
send_string(" ACSESS GRANTED ");
lcd_goto(20);
send_string(" WELCOME TO ARASH ");
delay(200000);
Led1=1;
Led3=1;
Led4=0;
Led5=0;
Led6=0
;
}
if (ReceiveChar == 'f')
{
lcd_clr();
lcd_goto(0);
send_string(" READING TAG ");
lcd_goto(20);
send_string(" PLEASE WAIT.... ");
35
delay(500000);
lcd_clr();
lcd_goto(0);
send_string("ACSESS DENIED");
lcd_goto(20);
send_string("TAG NOT FOUND");
delay(300000);
Led1=0;
lcd_clr();
lcd_goto(0);
send_string("PLEASE SCAN ");
lcd_goto(20);
send_string(" AGAIN");
}
if (ReceiveChar == 's')
//for female toilet
{
lcd_clr();
lcd_goto(0);
send_string(" READING TAG ");
lcd_goto(20);
send_string(" PLEASE WAIT.... ");
delay(500000);
lcd_clr();
lcd_goto(0);
send_string(" ACCESS GRANTED ");
lcd_goto(20);
send_string(" WELCOME TO ARASH ");
delay(200000)
Led1=1;
Led3=0;
Led4=1;
Led5=0;
Led6=0;
}
36
if (ReceiveChar == 'k')
//for CEO room
{
lcd_clr();
lcd_goto(0);
send_string(" READING TAG ");
lcd_goto(20);
send_string(" PLEASE WAIT.... ");
delay(500000);
lcd_clr();
lcd_goto(0);
send_string(" ACCESS GRANTED ");
lcd_goto(20);
send_string(" WELCOME BOSS ");
delay(200000);
Led1=1;
Led3=1;
Led4=0;
Led5=1;
Led6=1;
}
if (ReceiveChar == 't')
//for engineer male
{
lcd_clr();
lcd_goto(0);
send_string(" READING TAG ");
lcd_goto(20);
send_string(" PLEASE WAIT.... ");
delay(500000);
lcd_clr();
lcd_goto(0);
send_string(" ACCESS GRANTED ");
lcd_goto(20);
37
send_string(" WELCOME TO ARASH ");
delay(200000);
Led1=1;
Led3=1;
Led4=0;
Led5=0;
Led6=1;
}
if (ReceiveChar == 'i')
//for engineer female
{
lcd_clr();
lcd_goto(0);
send_string(" READING TAG ");
lcd_goto(20);
send_string(" PLEASE WAIT.... ");
delay(500000);
lcd_clr();
lcd_goto(0);
send_string(" ACCESS GRANTED ");
lcd_goto(20);
send_string(" WELCOME TO ARASH ");
delay(200000);
Led1=1;
Led3=0;
Led4=1;
Led5=0;
Led6=1;
}
}
}
38
APPENDIX C
MNEMONIC CODE FOR PLC PROGRAM
LD X0
OR Y0
TIM 005 #7200
LD X0
OR Y0
OR Y8
ANDNOT X1
ANDNOT TIM005
ANDNOT X2
OUT Y0
TIM 001 #600
LD TIM001
TIM 002 #600
LD TIM001
OR Y1
ANDNOT TIM002
ANDNOT X1
ANDNOT X2
OUT Y1
LD TIM002
TIM 003 #150
LD TIM001
OR Y2
ANDNOT TIM003
ANDNOT X1
ANDNOT X2
OUT Y2
LD TIM003
39
TIM 004 #750
LD TIM003
OR Y3
ANDNOT TIM004
ANDNOT X1
ANDNOT X2
OUT Y3
LD TIM004
OR Y4
ANDNOT TIM006
ANDNOT X1
ANDNOT X2
OUT Y4
LD TIM004
TIM 006 #600
LD Y4
OR Y9
ANDNOT Y0
ANDNOT X1
ANDNOT X2
OUT Y9
LD Y9
TIM 008 #1200
LD TIM008
OR Y8
ANDNOT Y0
ANDNOT X1
ANDNOT X2
OUT Y8
LD X2
ANDNOT X1
OUT alarm
END(01)
Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF

advertising