SECURITY SYSTEM INTEGRATED WITH RF MUHAMMAD ... - RPS Home - UniKL BMI

Document Sample
SECURITY SYSTEM INTEGRATED WITH RF MUHAMMAD ... - RPS Home - UniKL BMI Powered By Docstoc
					SECURITY SYSTEM INTEGRATED WITH RF




    MUHAMMAD NAZRI BIN AHMAD




     UNIVERSITI KUALA LUMPUR

            APRIL 2011
MUHAMMAD NAZRI BIN AHMAD   BACHELOR OF ENGINEERING TECHNOLOGY (HONS) IN ELECTRICAL APRIL/2011
 SECURITY SYSTEM INTEGRATED WITH RF




       MUHAMMAD NAZRI BIN AHMAD
                   51210109355




Report Submitted to Fulfill the Partial Requirements
           for the Bachelor of Electrical
             Universiti Kuala Lumpur


                 APRIL and 2011


                         i
                               DECLARATION PAGE


I declare that this report is my original work and all references have been cited
adequately as required by the University.




Date: 29/April/2011                  Signature:   ……………………………


                                     Full Name:   MUHAMMAD        NAZRI      BIN
                                     AHMAD
                                     ID No:       51210109355


                                            ii
                                 APPROVAL PAGE


We have examined this report and verify that it meets the program and University’
requirements for the Bachelor of ……………………….




Date: 29/April/2011       Signature             :…………………………..
                                                Supervisor’s Name:
                         Official Stamp




                                          iii
                               ACKNOWLEDGEMENT




        Firstly, I’m very grateful to Allah s.w.t for their blessing in my project until it
was finished.
        I was a great satisfaction to work on this project. This task would not have been
possible without the patience and support of my supervisor, Mr Alias bin Md Noor.
With his enthusiasm, his inspiration and his great effort to explain things clearly and
simply, he helped to make the task fun for me. Throughout my thesis- writing period, he
provided encouragement, sound advice, good teaching, good accompany, and lots of
good ideas. I would have been without him.
        I would like to thank to Mr Alias for his help while I was in process of
completing this project. Your supports in making this project reality, will be used as
guidance for us to do better work next time, especially when we enroll into job position
in the future.
        Also not forgotten to the other UniKL BMI’s lecturer who is direct and indirect
support throughout the entire process. I wish to thank all my friend for helping me get
throughout the difficult times and for all the emotional support, comradeship,
entertainment and caring they provided.
        Lastly and mostly importantly, I wish to thank to my parent. They bore me,
raised me, support me, taught me, and loved me.




                                            iv
                                        ABSTRACT




     The purpose of this project is to construct a Security System, which consist of the
Security Unit at the security post and the Home Unit located at each individual home.
The Security Unit and the Home Unit is each controlled by an individual
Microcontroller. This Microcontroller is programmed using C language, which is then
complied using its C complier. The device used to communicate between the Security
and Home Unit will be the Radio Frequency (RF) Transmitter and Receiver and will
operate at a frequency of 300 MHz. The Home Unit will also consist of a Siren, which
will sound upon activation from any of a sensor. The respective Bulb at the Security
Unit will also light up to indicate which Home had been intruded into or any other
emergency problem. This system is capable of allowing the home users to alert the
security post instantaneously in an emergency through it wireless link rather than relying
on the telephone network or routine security patrols. The aim of this project is to allow
the Security Unit to receive signals from the Home Unit through its RF transmitter and
receiver. Each Unit consists of 3 main components, which are the Microcontroller,
Transmitter and Receiver.
     The system use RFID passive card reader as a tool to activate and deactivate the
system. When any of the sensors triggered, the right card can deactivate the alarm and
reset the system.




                                            v
                                     TABLE OF CONTENT


CONTENTS                                          PAGE


Title Page                                               i
Declaration                                              ii
Approval                                                 iii
Acknowledgement                                          iv
Abstract                                                 v
Table of Content                                         vi
List of Tables                                           ix
List of Figures                                          x




CHAPTER1: INTRODUCTION
       1.1        Introduction of chapter                    1
       1.2        Project Background                         2
       1.3        Project Statement                          3
       1.4        Objective                                  3
       1.5        Scope of Project                           4
       1.6        Summary of Chapter                         4




                                            vi
CHAPTER2: LITERATUREREVIEW
     2.1   History                              5
     2.2   Overview of Micro-controllers        6
           2.2.1   Zilog(Z80) Microcontroller   8
           2.2.2   PIC16F877A Microcontroller   9
           2.2.3   Rabbit Microcontroller       11
     2.3   Microcontroller Selection            12
     2.4   RFID Reader                          14


CHAPTER 3: METHODOLOGY
     3.1   Design Method                        16
     3.2   Project Operation                    17
     3.3   Budget and Costing                   18
     3.4   Component and Material               22
     3.5   Block Diagram                        38
     3.6   Block Diagram Description            39
     3.7   Schematic Diagram                    40
     3.8   PCB layout                           41
     3.9   Project Wiring                       49


CHAPTER 4: RESULT AND DISCUSSION
     4.1   Result and Analysis                  52
     4.2   Home unit                            53
     4.3   PIC16F877A Microprocessor Testing    54
     4.4   Power Supply Testing                 54
     4.5   Problem and Solution                 55




                                       vii
CHAPTER 5: CONCLUSION AND RECOMMENDATION
    5.1   Summary                          57
    5.2   Future Recommendation            58
    5.3   Review and Reflection            60
    5.4   Skill review                     61




REFERENCES                                 xi
APPENDIXES                                 xii




                                  viii
                                   LIST OF FIGURE


                                                                      PAGE
Figure 2.1b    : A wireless security system                            6
Figure 2.2b    : Basic architecture of a microcontroller               7
Figure 2.2.1   : A CMOS Z80                                            8
Figure 2.2.2   : PIC 16F877A Microcontroller                           10
Figure 2.2.3   : RCM3000                                               11
Figure 2.4a    : RFID tag and reader                                   14
Figure 3.4.1a : LM7805 voltage regulator                               24
Figure 3.4.1b : Power supply schematic diagram                         24
Figure 3.4.2a : PIC16F877A Microcontroller                             25
Figure 3.4.3a : PIC16F877A Interfacing Diagram                         26
Figure 3.4.4a : PIC Programmer and Cable                               28
Figure 3.4.5a : Interconnection between the FOX Board and
                a LCD with Hitachi HD44780 interface                   33
Figure 3.4.5b : LCD Display                                            33
Figure 3.4.6a : LM35 pin configuration                                 34
Figure 3.4.7a : Relay from the inside view                             36
Figure 3.4.7b : Circuit for controlling an AC or other high-current
                device from a microcontroller by using a relay         37
Figure 3.4.7c : Relay                                                  37
Figure 3.4.9a : PCB wiring                                             50
Figure 3.4.9b : Relay on the PCB                                       50
Figure 3.4.9c : Model House                                            51
Figure 3.4.9d : Model House wiring                                     51
Figure 4.1a    : Microcontroller unit block diagram                    53
Figure 4.2a    : Microcontroller testing                               54
Figure 4.2b    : Output from the LM 7805                               54

                                              ix
                             LIST OF TABLE


                                                         PAGE
Table 1   : Comparison between active and passive RFID    15
Table 2   : Component Price List                          18
Table 3   : Key Features of PIC16F Family                 26
Table 4   : Wiring on Microcontroller                     48




                                        x
                                     CHAPTER 1




                                    INTRODUCTION




1.1      Introduction of Chapter


         As a final semester student, a task had been given to student for a final year
project and to accomplish the subject course. The scope of this project to make
student get a lot of knowledge and can learn from the theoretical and practically
principle for apply into the project. In addition, student also can get some experience
by developing and solving the problem.


      Security has to be compared to related concepts: safety, continuity, reliability.
The key difference between security and reliability is that security must take into
account the actions of people attempting to cause destruction. Perception of security
is sometimes poorly mapped to measureable objective security. The perceived
effectiveness of security measures is sometimes different from the actually security
provided by those measures. The presence of security protections may even be taken
for security itself. For example, two computer security programs could be interfering
with each other and even cancelling each other's effect, while the owner believes s/he
is getting double the protection.


         Since some intruders will decide not to attempt to break into such areas or
vehicles, there can actually be less damage to windows in addition to protection of
valuable objects inside. Without such advertisement, a car-thief might, for example,

                                            1
approach a car, break the window, and then flee in response to an alarm being
triggered. Either way, perhaps the car itself or the objects inside aren't stolen, but
with perceived security even the windows of the car have a lower chance of being
damaged, increasing the financial security of its owner.




1.2    Project Background


       In a populated area, the houses in the area are spread out over a large distance.
This will result in many houses being isolated in a particular area, thus the houses
will not be able to form any neighborhood watch group and is not possible to have
security personnel constantly patrolling the vast area. Therefore there is a need for a
security system in each and every house to keep them and their belongings safe.


       The use of the telephone or the mobile network to communicate with the
Security Post is unreliable as the telephone is a landline and could easily be cut by
any intruder. The mobile network is slightly more reliable as it uses the wireless
network, but a mobile phone could also experience situations when the battery runs
flat or when there is no network coverage. Using of the mobile phone will also give
rise to prank calls as anyone can alert the security post even if their home is safe.
Another drawback of these two communication tools is that it will require the caller
to identify the location of the break-in to the guard on the receiving end; this will
result in unnecessary time wasted by the caller and the security personnel. The
Security System Integrated with RF will cover all the limitations of the two
communication tools as described above. The proposed system will enable the
security to identify which house is in need of immediate attention and to be able to
proceed to the scene in the least possible time required. With a wireless transmitter
and receiver system, there are no cable lines for the intruder to cut. It has also a
dedicated frequency network for the security system to transmit and receive data
from one another.



                                          2
1.3    Project Statement


       A man's home is his castle, as the saying goes. But homes today don't
normally feature ramparts, drawbridges, moats and six-foot thick stone walls to keep
out unwanted visitors. Today, a house alarm, and preferably a managed home
security system, is needed to ensure your home's security. Not only does installing a
home security system improve the safety of your family and possessions, but it can
also decrease your home insurance costs.


       This project describes an effort to produce better home security not only for
burglar alarm, but also for flood and fire alarm. The critical investigation is on the
software part where program must be reliable with the hardware.




1.4    Objective


       The aim of the work is to investigate and to design security system for house
  complete with flood alarm and fire alarm. In doing so, the bulk of the work can be
  summarized as follows; To develop a prototype program capable of dealing with
  Malaysian needs to have security system that cover flood and fire detector
  including burglar alarm; To investigate the capability of engineering methods in
  obtaining the optimized solution in improving existing methods; To overcome
  new solution for new problem regarding the area and landscape; To produce better
  program and better hardware that can comply with end user; To produce a much
  cheaper product from the existing home security in the market.




                                           3
1.5     Scope of Project


        Protecting our loved ones and our hard earned valuables has always been one
of the more important considerations in life since the early days. There are many
ways to protect our valuables and one of the most feasible and practical solutions are
to use security system.


        There are many types of Neighborhood Security Systems available in the
market today. These Security Systems play a vital role in keeping the neighborhood
safe. These system works by linking a network of homes around in the neighborhood
to a central Security Post. A security officer who monitors the status of the homes
could then dispatch security officers to an affected home when required.




1.6     Summary of Chapter


        Home security in the market had various type and function, but it is still not
perfect. By having the process assisted by machine, it is a great hope that the
existing process can be improved in many ways, such as improved speed, memory
reliability and flexibility.


        The investigations are of experimental type, where most of the activities are
developing computer programs on the subject matter and tested. The programs
developed using microcontroller based, aim at demonstrating the utilisation of a
stand-alone computerised system.




                                          4
                                   CHAPTER 2




                             LITERATURE REVIEW




2.1    History




RESEARCH ON SECURITY SYSTEMS
       Protecting our loved ones and our hard earned valuables has always been one
of the more important considerations in life since the early days. There are many
ways to protect our valuables and one of the most feasible and a practical solution is
to use a Security System. There are many types of Security Systems available in the
market today. These Security Systems play a vital role in keeping the neighborhood
safe. These system works by linking a network of homes around in the neighborhood
to a central Security Post. A security officer who monitors the status of the homes
could then dispatch security officers to an affected home when required.


       With the advancement of technology, the wireless security system can not
only inform the Security Centre in case of an emergency, but the security system can
also be integrated into our wireless telecommunications network to send an Short-
Message Service (SMS) text to the home owner to inform of any intrusion into their
property.

                                          5
Stand-alone Security Panel
Some of its main features consist of Supervises up to 20 field devices; Reports any
alarm or fault automatically using Voice Reporting; Built in emergency buttons;
Voice Reporting: Up to 20 seconds, a common address message.




2.2 – OVERVIEW OF MICRO-CONTROLLERS


       The Microcontroller (MCU) is also known to be a computer-on-a-chip. It is
an integrated chip that is often part of a bigger embedded system. It is optimized to
interact with the outside world through its on-board interfaces. It consists of 3 main
components, a Central Processing Unit (CPU), Random- Access Memory (RAM),
Read-Only Memory (ROM) and Input/Output ports, which are all fabricated into a
single chip.
       The Microcontroller is a low powered integrated circuit that is able to
perform digital arithmetic, logic and Input/Output operations. The microcontrollers
are usually embedded inside another device so that it is able to control the actions
and features of the device. It is controlled by software program and it is dedicated to
one task and to run one specific program only. The program is stored in its ROM. A

                                           6
microcontroller will also combine with other components like the Timer/Counter
module, Serial Input/Output port and the Analog to Digital Converter.


       A basic Microcontroller will usually consists of the following
           1. Central Processing Unit (CPU)
           2. Memory Unit (RAM and ROM)
           3. Bus (Address Bus and Data Bus)
           4. Input and Output Unit (I/O ports)
           5. Serial Communication
           6. Timer Unit
           7. Watchdog
           8. Analog to Digital Converter (ADC)
           9. Program




       The microcontroller is often popular among developers and hobbyists alike as
it emphasizes on high integration, low power consumption, self-sufficiency and cost-
effectiveness. It integrates with a number of components of the microprocessor
system onto a single microchip and optimized to interact with the outside world
through its on-board interfaces. We shall now look into the 3 more popular
Microcontrollers, which is easily available in the market today. They are the Zilog
Microcontroller, the PIC Microcontroller and the Rabbit Microcontroller.
                                         7
2.2.1 – ZILOG (Z80) Microcontroller




       The Z80 is an 8-bit microprocessor with a 16-bit address bus that is capable
of direct access of 64k of memory space. It has a language of 252 root instructions
with the reserved 4 bytes as prefixes. The Z80 was modeled after the 8080
microcontroller and it contains the 78 - 8080 opcodes as a subset to its language[4].
Figure 2.1.1a below shows a Zilog Z80 Microchip.




       The Zilog Z-80 family of microcontrollers is a significant advancement in the
technology advancement of microcomputers. These microcontrollers can be
configured with any types of standard semiconductor memory to generate computer
systems with a wide range of capabilities. The Zilog Z80 Microcontroller is also one
of the more popular 8-bit microprocessors that are being used in many applications.
Microcomputers, like the popular Nintendo Game boy and Sega Mega Drive game
consoles all runs on the Z80 disk operating system.
       The Z80 is very popular among engineers worldwide even many years after
its production. It is ideal for embedded control applications and it incorporates dual
register banks that can enable fast context switching and interrupt handling. It has a
built-in DRAM refresh, which allowed systems to be built with fewer support chips.
It is also extremely useful for low cost control applications.


                                            8
2.2.2 - PIC16F877A Microcontroller




Microcontroller Specification




RAM                                   368
EEPROM                              256 bytes
Flash Program Memory                8k words
Operating Frequency               DC to 20MHz
I/O port                        Port A,B,C,D,E




This is the specification for PIC16F877A from Microchip. A single microcontroller
which is very brilliant and useful. Also this microcontroller is very easy to be
assembled, program and also the price is very cheap. The good thing is that single
unit can be purchased at that 30 ringgit price. Unlike some other Integrated Circuit
that must be bought at a minimum order quantity such as 1000 units or 2000 units or
else you won‟t be able to purchase it.


One unit of PIC16F877A microcontroller can be programmed and erased so many
times. Some said about 10 000 times. If you are doing programming and
downloading your code into the PIC 20 times a day, that means you can do that for
500 days which is more than a year!


The erasing time is almost unnoticeable because once new program are loaded into
the PIC, the old program will automatically be erased immediately. During my time
of Diploma study, I did not use PIC but I use other type of microcontroller. I have to
wait for about 15 to 30 minutes to erase the EEPROM before I can load a new

                                            9
program and test the micrcontroller. One day I can only modify my code and test it
for less than 10 times. 10x15 minutes = 150 minutes.


PIC16F877A already made with 368 bytes of Random Access Memory (RAM)
inside it. Any temporary variable storage that we wrote in our program will be stored
inside the RAM. Using this microcontroller you don‟t need to buy any external RAM.
256 bytes of EEPROM are available also inside this microcontroller. This is very
useful to store information such as PIN Number, Serial Number and so on. Using
EEPROM is very important because data stored inside EEPROM will be retained
when power supply is turn off. RAM did not store data permanently. Data inside
RAM is not retained when power supply is turn off.


The size of program code that can be stored is about 8k words inside PIC16F877A
ROM. 1 word size is 14 bits. By using the free version of the CCS C compiler only
2k words of program can be written and compiled. To write 8k words of C program
you have to purchase the original CCS C compiler and it cost less than 700 dollar.


The crystal oscillator speed that can be connected to the PIC microcontroller range
from DC to 20Mhz. Using the CCS C compiler normally 20Mhz oscillator will be
used and the price is very cheap. The 20Mhz crystal oscillator should be connected
with about 22pF capacitor. Please refer to my circuit schematic. There are 5
input/output port on PIC microcontroller namely port A, port B, port C, port D and
port E. Each port have diffent function. Most of them can be used as I/O port.




                    Figure 2.2.2 : PIC 16F877A Microcontroller




                                         10
2.2.3 - Rabbit Microcontroller




The Rabbit is a microcontroller created by Rabbit Semiconductors. Rabbit
Semiconductor provides low-cost, quick-to-market solutions for a variety of
networked embedded systems. It offers fast and powerful development solutions with
a variety of different form factors, Input/Output configuration and memory.These
solutions are usually used in parking systems, telecommunications, building security
and many more other applications. The board is relatively cheap and has up to 52 I/O
ports to control external devices; it also has up to 512K of program space and up to
256K of data memory. The Rabbit is also a very fast running microcontroller that
runs up 44.2 MHz[8]. The Rabbit development board though small in size, but is
packed with many powerful features, it bundles hardware and software together,
creating a user- friendly development environment for the developer than a typical
embedded 8-bit controller.




                                        11
2.3    MICRO-CONTROLLER SELECTION




The selection of the Microcontroller was not an easy process. Based on the 3
different kinds of Microcontrollers that was reviewed, each of them has many
advantages.


ZILOG (Z80) MICROCONTROLLER
 The advantages is; it is a low cost microcontroller and the disadvantages is I have
never use this chip before.


PIC16 F877A MICROCONTROLLER
 The advantages are it use low power but produce high performances and also
commonly used by students. The disadvantage is high cost for Debugger Unit.


RABBIT MICROCONTROLLER
   Advantages are; no requirement for Debugger Unit (Save money); “Ready-to-
run/ready-to-program” Microprocessor; Software obtainable free and similar choice
with Course Mates. The disadvantages are inexperienced in programming and higher
cost than others.


Based on the above comparison, the PIC16F877A Microcontroller is my ideal choice
for the Security System Integrated With RF. The advantages that it is easily available,
with its free Programming Software, and it being the similar choice of
Microcontroller with my Course Mates are the few main reason of it being my
Microcontroller of choice.




                                          12
2.4    RFID Reader




       RFID is often compared to UPC code technology. When a UPC code is
scanned, information is displayed on a computer or cash register screen. RFID is a
wireless technology that uses radio waves to scan. RFID technology is normally
comprised of three parts: an antenna, a tag and a reader. A tag, also called a
transponder, contains a printed circuit board and semiconductors. A reader, also
called a transceiver, decodes information sent by the transponder. An antenna,
generally found on the tag itself, obtains or gives out energy, in this, case radio
waves. The data from the tag is sent out through the antenna and read by the reader.


       To continue the UPC comparison, an RFID reader reads a tag like a scanner
reads a UPC code. Unlike UPC code scanning, RFID tags do not require direct-line-
of-sight. They also may contain more product information than a UPC, although this
is not always the case. Multiple products, like items on a pallet in a warehouse, can
be read simultaneously, whereas UPC is restricted to one coded item at a time. RFID
tags can be scanned if the item is dirty, wet or otherwise obstructed since they are
read via radio waves and not optical means. The reading speed is less than 100
milliseconds even in obstructed conditions or extreme temperatures.


       While UPC codes are fairly standard, RFID technology comes in many
different shapes, sizes, and capabilities. Subcutaneous implants, like those used to
identify missing pets, can be as small as a grain of rice or pencil lead (~10 mm long).
Other RFID tags are small enough to be built into casino chips, or as big as credit
cards. The plastics tags found on clothing in stores are a familiar example of RFID
tags. For especially large applications, such as scanning the contents of railroad cars,
an RFID tag may be as large as 120 by 100 by 50 mm.



                                          13
                         Figure 2.4a : RFID tag and reader


       There are two types of RFID tags that are passive and active. Passive RFID
tags do not use batteries and must be used at a close range of 3m or less. The antenna,
tuned to a particular radio frequency, sends out radio waves. The reader then sends
out a radio signal to the antenna, which is activated to transmit the pertinent
information. The radio signal contains enough energy to power the tag long enough
to send out its information. Most passive RFID tags use Electrically Erasable
Programmable Read Only Memory (EEPROM) for small amounts of data.

       The more sophisticated active tags use batteries, which make them more
expensive. However, the reader can read tags that are ~100m (300 feet) away. Many
use Static Random Access Memory (SRAM), which means the information in the tag
is available as long as it is being powered, for instance with a battery. In summary,
an active tag uses an internal power source (battery) while a passive tag uses an
external power source (radio waves from the reader).




                                          14
              Table 1 : Comparison between active and passive RFID


As for our design, we decided to use passive RFID because of the price is way
cheaper than the active RFID. Although active RFID have many advantage, for our
project demo we will use the passive.




                                        15
                                      CHAPTER 3




                                  METHODOLOGY




3.1      Design Method




         The Security System Integrated with RF will be split into 3 different modules
for easy management.


      1. Microcontroller Module
      2. RFID Modules
      3. Software Module


      In the initial stage, we had begun on the hardware portion, namely the voltage
regulation and the RFID testing. Upon completing most of the hardware units, we
had then proceeded to develop the software portion for the RFID, and for the
microcontroller programming. After these components can work individually,
I tried to implement them together as a whole.




                                           16
Hardware
         Power Supply
         Testing of the Transmitter and Receiver
         Interfacing Transmitter and Receiver with the Microcontroller
         Integrating the system


Software
         Microcontroller programming
         Transmitter and Receiver Programming




3.2       Project Operation




Push button: The push buttons are connected to 5V when no pressed. Thus PIC gets
1 when button no pressed. Whenever button is pressed the PIC pin is shorted to
ground and thus PIC get 0.


Output LED indicator: A normal LED use 5V and 5mA to operate. And through
LED the current status of the system can be known. A 1KR resistor is connected
series with the LED to limit the current pass through LED is 5mA. This is calculated
using V=IR. Where V=5VDC, R=1KR.


Magnetic switch: The magnetic switch for the system is pulled to high. So when
magnetic is close to the magnetic switch, the switch is closed and PIC will get 0 (0V).
Else PIC will get 1 (+5V).




                                           17
PIR sensor: The PIR sensor power is 12V. Normally the PIR switch is closed. So
when no motion detected the output switch of the PIR is close and PIC get 0 (0V).
Else PIC gets 1 (+5V).


Vibrate switch: The vibrate switches for the system is pulled to high. So when no
vibration detected the sensor gives signal 0 (0V). Else it gives signal 1 (+5V).


RFID Reader: The RFID reader is a passive RFID reader it operates using 12VDC.
It can read RFID card within 3mm distance. The operating frequency of the RFID
reader is 125 KHz. It communicates with PIC using Wiegand26 communication.
Minus the start and stop bit, the ID content is in 3 bytes form (24 bit). There are 3
wires used to control the RFID reader. Orange color wire used to enable/disable the
RFID reader. Green and white color wires are signal line.




3.3 Budget and Costing




3.3.1 Project Component list


       The entire project was a self-funded project. Most of all the equipments are
new and had to be purchased from outside vendors or thru online shops. The main
components, the Microcontroller was researched and was purchased from Bizit
Systems Pte. Ltd1. located at Bukit Batok Crescent. The RF transmitter and receiver
are purchased thru the Farnell online store2. The other components and tools
required for the project can mostly be found and purchased at SIM LIM Tower3.
The whole system consists of the following parts and components:



                                          18
Description          Value                    Quantity   Unit Price
                                                           (RM)
Microcontroller      PIC16F877A                  1         27.00
IC Socket            40 pin                      2         1.00
Crystal              20MHz                       1         1.20
Capacitor            18pF                        2         0.30
Voltage Regulator    LM7805                      1         1.20
Capacitor            0.1uF, 50V                  1         0.30
Capacitor            1000uF, 16V                 1         1.00
LED                  5mm                         1         0.20
Resistor             1KR                         1         0.05
Diode                1N4007                      4         0.20
Switch               On/Off                      1         2.00
Photo PCB            300mm*150mm                 1         28.00
Etching Powder       1Kg                         1         20.00
PCB Developer        50g                         1         8.00
Battery              12VDC, 7.0AH                1         50.00
LCD                  2x16, Green                 1         30.00
Resistor             1KR                         8         0.05
LED                  5mm                         5         0.20
Solenoid             Push pull                   1         60.00
Relay                SPDT                        3         2.50
Transistor           NPN, C9013                  3         0.50
Temperature Sensor   LM35, range: 0C – 150C      1         6.00
Resistor             100KR, 1/4W, 5%             1         0.05
Resistor             10KR, 1/4W, 5%              1         0.05
Resistor array       10K, 6 pin                  1         0.60


                                   19
Switch              Push button, big                 1    5.00
PIR Motion Sensor   12VDC, switch output             1   70.00
Switch              Magnetic switch                  1    6.00
Switch              Vibrate switch                   1   12.00
Switch              Float switch                     1   90.00
RFID reader         12VDC                            1   150.00


                    Table 2 : Component Price List




                                   20
3.3.2 Project Development Flow Chart

                                        Start



           Learn                 Planning and     Identify
          Software                  Design       Hardware



            Write                                 Assemble
           Program                               Breadboard
                                       Testing




                                 Fine tune and
                                 troubleshoot



                                    Printed
                                 Circuit Board


                                  Install in a
                                    casing


                                 Development
                                  Complete




                                         21
3.4    Component and Material




3.4.1 Voltage regulator module


       The voltage regulator module is used to protect PIC and other connected
sensors from over voltage. This is because PIC and all other connected sensors are all
support 5V DC only. Over voltage will cause any of the module burn.
       LM7805 is used to regulate voltage in the system and output 5V DC (max
output current: 1000mA). It supports input voltage from 7V DC to 18V DC. If the
input voltage is over, the LM7805 will burn or auto shutdown due to overheat.
       The generated 5V from LM7805 will be noise filtered by 0.1uF ceramic
capacitor and a 1000uF electrolytic capacitor. This is to avoid high frequency
oscillation on the outputs which may cause system hang or unstable.
       A diode is connected at the input of the LM7805. This is to avoid voltage
connected reversely. An on/off switch is used to turn on/off the system and a LED
(5V, 5mA) is used to indicate the system is power on/off. The LED is connected
through 1KR resistor to limit current pass through LED is 5mA.




                                         22
Advantages
The 7805 series has several key advantages over many other voltage regulator
circuits which have resulted in its popularity:
      7805 series ICs do not require any additional components to provide a
       constant, regulated source of power, making them easy to use, as well as
       economical, and also efficient uses of circuit board real estate. By contrast,
       most other voltage regulators require several additional components to set the
       output voltage level, or to assist in the regulation process. Some other designs
       (such as a switching power supply) can require not only a large number of
       components but also substantial engineering expertise to implement correctly
       as well.
      78xx series ICs have built-in protection against a circuit drawing too much
       power. They also have protection against overheating and short-circuits,
       making them quite robust in most applications. In some cases, the current-
       limiting features of the 78xx devices can provide protection not only for the
       78xx itself, but also for other parts of the circuit it is used in, preventing other
       components from being damaged as well.


Disadvantages
      The input voltage must always be higher than the output voltage by some
       minimum amount (typically 2 volts). This can make these devices unsuitable
       for powering some devices from certain types of power sources (for example,
       powering a circuit which requires 5 volts using 6-volt batteries will not work
       using a 7805).
      As they are based on a linear regulator design, the input current required is
       always the same as the output current. As the input voltage must always be
       higher than the output voltage, this means that the total power (voltage
       multiplied by current) going into the 78xx will be more than the output power
       provided. The extra input power is dissipated as heat. This means both that
       for some applications an adequate heat sink must be provided, and also that a

                                           23
    (often substantial) portion of the input power is wasted during the process,
    rendering them less efficient than some other types of power supplies. When
    the input voltage is significantly higher than the regulated output voltage (for
    example, powering a 7805 using a 24 volt power source), this inefficiency
    can be a significant issue.
   Even in larger packages, 78xx integrated circuits cannot supply as much
    power as many designs which use discrete components, and therefore are
    generally not appropriate for applications which require more than a few
    amps of current.




                  Figure 3.4.1a : LM7805 voltage regulator




               Figure 3.4.1b : Power supply schematic diagram




                                      24
3.4.2 PIC 16F877A microcontroller


       PIC16F877A-I/P microcontroller is used to control the whole system. It is
designed using flash technology. So the PIC can read/write program for more than
100,000 times. The PIC 16F877A has 8 K words or program memory. Since each
word in the midrange family is 14 bits long the program memory can also be
expressed as 14 Kbytes. The unit has 368 bytes of data ram and 256 bytes of
EEPROM. It has 8 channels of A/D with 10 bit resolution. The unit has 2 8 bit
Timer/Counters and a single 16 bit Timer/Counter. In addition to this it has several
different types of serial communication functions such as SPI, I2C, and normal pc
type serial communications functions.




                   Figure 3.4.2a: PIC16F877A Microcontroller




                                        25
3.4.3 PIC Microcontroller Interface




                  Figure 3.4.3a : PIC16F877A Interfacing Diagram
       OSC1 and OSC2 pins are connected to 20MHz crystal to execute every single
program line in the system. 20MHz crystal is used because this is the maximum
frequency that the PIC can support. If over frequency the PIC will burn. Else if
crystal speed less than 20MHz then PIC response speed will slower. The MCLR pin
of the PIC is pull up to 5V through a 10KR resistor.
       The PIC can operate using 4.5V to 6.0V DC voltage. In the project is
operating at 5.0V (by using 7805). It is DIP layout (dual in line package) and suitable
for student project. It has 40 pins but only 33 I/O pins can be set as digital input or
digital output. The digital output of the PIC is 5V (for signal 1) and 0V (for signal 0)
                                          26
these signals will be directly connected to actuators for control purpose. When the
PIC pin is set as digital input. It will detect input voltage 5V as signal 1 and 0V as
signal 0. Any voltage less than 0V or more than 5V will damage PIC.




                     Table 3 : Key Features of PIC16F Family
3.4.4 Multi PIC Programmer
Features
      ZIF Sockets for Easy IC Programming and Removal
      No External Power Supply Required
      Easy to Use Windows Software Included
      Connects to a standard Computer USB Port
      Supports a wide range of PIC Microcontrollers from 8 pin to 40 pin
      In-Circuit Programming Connection and Adapters
      Power and Programming LED's




                                         27
Steps to download PIC program into PIC Microcontroller
1. Connect PIC programmer to computer via serial port / USB port.
2. Insert PIC into the programmer socket.




                    Figure 3.4.4a : PIC Programmer and Cable
3. Copy „Winpic800‟ folder to Desktop.
4. Look for Winpic800.exe in the folder.




                                         28
5. Double click Winpic800.exe to start the program.




6. Select proper PIC name in the top right combo box.




7. Open the .hex file which you want to download into PIC e.g. if your .c filename
   is „abc.c‟, suppose you need to download „abc.hex‟ into PIC.




                                        29
8. Go to „Device‟ -> „Program All‟ to start download program into your PIC.




Steps to use PCWH C-Compiler
1. Open PCW C-Compiler Start->All Programs->PIC-C->PIC C Compiler.
2. „File‟ -> „New‟ to start a new file.
3. Save the file as .c file, it is advisable to put the main file name within 8 chars
   length, extended file name must be .c, e.g. myprog1.c.
4. Type / Edit your program.
5. Save program before compile.
6. Compile your program using F9.
7. If any error occurs, please check your program and compile again. Otherwise you
   won‟t get your .hex file.




                                          30
3.4.5 HD44780 Character LCD
An HD44780 Character LCD is a de facto industry standard liquid crystal display
(LCD) display device designed for interfacing with embedded systems. These
screens come in a variety of configurations including 8x1, which is one row of eight
characters, 16x2, and 20x4. The most commonly manufactured configuration is 40x4
characters, which requires two individually addressable HD44780 controllers with
expansion chips.


These LCD screens are limited to text only and are often used in copiers, fax
machines, laser printers, industrial test equipment, networking equipment such as
routers and storage devices.
Character LCDs can come with or without backlights, which may be LED,
fluorescent, or electroluminescent.
Character LCDs use a standard 14-pin interface and those with backlights have 16
pins. The pin outs are as follows:
   1. Ground
   2. VCC (+5V)
   3. Contrast adjustment
   4. Register Select (R/S)
   5. Read/Write (R/W)
   6. Clock (Enable)
   7. Bit 0
   8. Bit 1
   9. Bit 2
   10. Bit 3
   11. Bit 4
   12. Bit 5
   13. Bit 6

                                        31
   14. Bit 7
   15. Optional backlight power rail
   16. Optional backlight power rail
The backlight power rail differs often, the polarity can be different and some screens
need an external resistor. Usually the supply voltage is 5V DC.
Character LCDs can operate in 4-bit or 8-bit mode. In 4 bit mode, pins 7 through 10
are unused and the entire byte is sent to the screen using pins 11 through 14 by
sending 4-bits (nibble) at a time.


Font
The character generator ROM contains 208 characters in a 5x8 dot matrix, and 32
characters in a 5x10 dot matrix.
There is a Japanese version of the ROM which includes kana characters, and a
European version which includes Cyrillic and Western European characters.
The 7-bit ASCII subset for the Japanese version is non-standard: it supplies a Yen
symbol where the backslash character is normally found, and left and right arrow
symbols in place of tilde and the rub-out character.




                                          32
Figure 3.4.5a : Interconnection between the FOX Board and a LCD with Hitachi
                             HD44780 interface




                        Figure 3.4.5b : LCD Display




                                    33
3.4.6 Temperature Sensor - The LM35


      By interfacing different types of sensors with our MCU we can sense the
       environment and take decisions, in this way we can create "smart"
       applications. There are wide variety of sensors available. In this tutorial we
       will learn about a popular sensor LM35 which is precision centigrade
       temperature sensor. It can be used to measure temperature with accuracy of
       0.5 degree centigrade. We can interface it easily with AVR MCUs and can
       create thermometers, temperature controller, fire alarms etc.
      LM35 by National Semiconductor is a popular and low cost temperature
       sensor. It is also easily available.
      It has three pins as follows.




                   Figure3.4.6a: LM35 pin configuration




                                              34
   The Vcc can be from 4V to 20V as specified by the datasheet. To use the
    sensor simply connect the Vcc to 5V ,GND to Gnd and the Out to one of the
    ADC (analog to digital converter channel). The output linearly varies with
    temperature. The output is 10MilliVolts per degree centigrade.
   The resolution of AVRs ADC is 10bit and for reference voltage we are using
    5V so the resolution in terms of voltage is 5/1024 = 5mV approx .So if ADCs
    result corresponds to 5mV i.e. if ADC reading is 10 it means 10 x 5mV =
    50mV.
   You can get read the value of any ADC channel using the function
    ReadADC(ch); Where ch is channel number (0-5) in case of ATmega8. If you
    have connected the LM35's out put to ADC channel 0 then call adc_value =
    ReadADC(0).
   this will store the current ADC reading in variable adc_value. The data type
    of adc_value should be int as ADC value can range from 0-1023.
   As we saw ADC results are in factor of 5mV and for 1 degree C the output of
    LM35 is 10mV, So 2 units of ADC = 1 degree.
   So to get the temperature we divide the adc_value by to temperature =
    adc_value/2;




                                     35
3.4.7 Relay
A relay is an electrically operated switch. Many relays use an electromagnet to
operate a switching mechanism, but other operating principles are also used. Relays
find applications where it is necessary to control a circuit by a low-power signal, or
where several circuits must be controlled by one signal. Figure 1 shows the basic
design of relay.




                       Figure 3.4.7a: Relay from the inside view
    The output of each PIC pin is 5V with max output current of 20mA or 0V with
0mA output. The voltage is not enough to run high power device e.g. motor, solenoid.
Thus we need a relay to control these high power items. A simple switching circuit
(using NPN transistor, C9013) will be used to energize / de-energize the input coil of
the relay.
    The relay output is single pole double throw (SPDT). And its coil can be
energized using 5V and de-energized using 0V. Normally the relay output NC and
COM will be connected. When the input coil of relay is energized, output NO and
COM will connect. The switching can be used to control item which is less than
250Vac and 10A.
    A reverse diode (1N4007 is connected with input of relay to avoid reverse spike
or over current flow back from the load. And a LED indicator is used to show relay
is now on/off. When relay is on, LED is on. When relay is off, LED is off.




                                         36
Figure 3.4.7b : Circuit for controlling an AC or other high-current device from a
                        microcontroller by using a relay




                             Figure 3.4.7c : Relay




                                       37
3.5   Block Diagram




                      38
3.6    Block Diagram Description




       Push to on button will operate the system. The system powered by 12vdc
rechargeable battery. The PIC16f877A is a main controller for the system. The RFID
will arm and disarm the whole system. When the system is in arm condition, the
main entrance will lock. We use solenoid as the locking mechanism meaning that
you can only enter the main entrance using the right card as recorded by the RFID.
The solenoid will open and closed in around 7 second counting.
       We put LCD for system display. It will display five sensors that were used for
the system. Flood sensor, fire sensor, motion sensor, vibration sensor and door sensor.
It also displays whether the system is arm or disarms. When we swap the card, the
system arms meaning that if any of the sensors trigger, the alarm will activate.




                                          39
3.7   Schematic Diagram




                          40
3.8      PCB Layout




Project Development Tools Required
1. Computer:
      The computer is used to draw schematic and PCB for the system. Computer can
      be used to compile and download program into PIC through C-compiler and
      downloader software.
2. Laser printer:
      The laser printer is used to print the PCB drawing for PCB fabrication.




                                            41
3. PCB development tools:
   a. Blade: to cut suitable size for PCB.
   b. Fluorescence light: to do photo etching for PCB.
   c. PCB developer, etching powder and thinner: to develop track from PCB.
4. PCB assembly tools:
   a. Cutter: used to cut wire and components legs.
   b. Pliers: used to bend component legs and place components on PCB.
   c. Soldering iron: used to solder components on PCB.
   d. Mini drill: used to drill holes on PCB to place components.




                                             42
PCB Fabrication
1. PCB Drawing: PCB drawing is designed using Protel DXP 2004, this software
   can automatically convert schematic file to PCB automatically.




                                        43
2. Film Printing: After PCB file is generated, use laser printer to print it on
   transparency.




3. PCB Cutting: Cut photo PCB size according to the film size.




                                        44
4. PCB Photo Etching: Expose the photo PCB in photo etching kit for 8-10minutes.




                                       45
5. PCB Developing: Wash the PCB using PCB developer (white powder) for 2 min.




6. Acid Etching: After PCB is developed, put it in Ferric Chloride liquid. Add in hot
   water (80C) and shake the water until you see unused part is „washed‟ and left
   only the tracks. The etching process takes around 30 min.




                                         46
7. Alcohol Washing: Wash the PCB with alcohol to get rid off the green coating.




                                        47
8. Drilling: Drill PCB after alcohol washing, use drill bit 0.8mm, 1.0mm and 1.2mm.




                  \




9. Soldering: Place all components on the PCB, use tape to stick all components
   tightly on the PCB and then solder the components using soldering iron and lead.




                                        48
3.9   Project Wiring


PIC   I/O Connected To
Pin        Sensor / Actuator                     Function
RA0        Temperature sensor                    To detect temperature
RB0        Pin E LCD                             Display message on LCD
RB1        Pin RS LCD                            Display message on LCD
RB2        Pin R/W LCD                           Display message on LCD
RB4        Pin DB4 LCD                           Display message on LCD
RB5        Pin DB5 LCD                           Display message on LCD
RB6        Pin DB6 LCD                           Display message on LCD
RB7        Pin DB7 LCD                           Display message on LCD
RC1        Push button                           To detect button pressed
RC2        Magnetic switch                       To detect door open
RC3        Vibrate switch                        To detect vibration
RC4        Relay                                 On/off siren
RC7        Green LED                             On/off LED
RD0        PIR sensor                            To detect motion
RD1        Float switch                          To detect float
RD2        Relay                                 On/off solenoid
RD3        Relay                                 On/off pilot light
RD6        Red LED                               On/off LED
RE0        RFID                                  To detect RFID card
RE1        RFID                                  To detect RFID card
RE2        RFID                                  To detect RFID card


                       Table 4 : Wiring on Microcontroller




                                       49
  Figure 3.9a : PCB wiring




Figure 3.9b : Relay on the PCB




             50
   Figure 3.9c : Model House




Figure 3.9 d : Model House wiring

               51
                                   CHAPTER 4




                          RESULT AND DISCUSSION




      Upon completion of all the individual system design and testing, we then
proceed to integrate the different parts together to work as a complete Security and
Home System. The PIC16F877A Microcontroller was used as the heart of the system
and all the rest of the components were connected to its Serial ports or I/O ports
directly. The green and red LEDs at each system are used to indicate the connection
status and the alarm status respectively. The RFID is used as the input from the users
to the Microcontroller; it allows the user to activate the alarm at the Home system or
for the guard to activate the acknowledgement and reset button. The Security and
Home system are somehow similar as it contains similar separate units except the
Security consists of a buzzer and more LEDs for indication of the different houses
that it is linked to.
       A multi-meter was used to check the voltage at the Transmitter at the Home
Module and voltage pulses could be seen. The PG6 of the PIC Microcontroller at the
Home Module was also tapped to an oscilloscope and some waveforms could be seen
transmitting from the Home Microcontroller. The problem was initially identified at
the communicating link of the RF transmitter and receiver. The Modules were put
closer to one another and modifications to the antenna length were done but the
Security Module was still not able to receive the signal. The Transmitter input pin
was then changed to be connected to PF6, an output port of the Microcontroller. A
simple LED program was then downloaded to the PIC Microcontroller. Using the

                                         52
same method of testing in the Hardware Design Chapter 4.3.3, the LEDs at the
Receiver side was able to blink. Further understanding of the PIC Microcontroller
was carried out and the problem was identified at the Serial Port to the RF
Transmitter. Detailed understanding of the PIC Microcontroller Serial Port is then
needed to be carried out.


4.2 Home Unit
The Home System consists of the PIC16F877A Microcontroller, the Transmitter and
Receiver and green and red LEDs. These LEDs are used to indicate the connection
and alarm respectively. The green is to indicate the connection and red to indicate
alarm




                  Figure 4.1a : Microcontroller unit block diagram




                                          53
4.3 PIC16F877A Microprocessor Testing
For the PIC16F877A Microcontroller simulation, a simple LED-blinking program is
downloaded to the PIC16F877A Microcontroller to check the functionality for the
Microcontroller. This program uses the PIC16F877A Microcontroller to control 2
LEDs to blink at different intervals. These 2 LEDs are connected to RB6 and RB7 of
the PIC16F877A Microcontroller.




                       Figure 4.2a : Microcontroller testing
4.4 Power Supply Testing
The LM7805 is chosen as the 5V voltage regulator as it is a simple and high-
efficiency step down regulator with a guaranteed 1A output current. Shown below in
Figure 4.2b, the 5V supply is achieved from the output of the LM7805 regulator.




                     Figure 4.2b : Output from the LM 7805




                                        54
4.5 Problems and Solutions


Power Supply
Problem:
A 9V battery was each used to power up the whole of Security and Home system,
this result in the battery being drained quickly during the testing stage of the system.
Solution:
A 12V adapter was used in place of the 9V battery. This 12V adapter is able to
output a stable supply with a 1A of current. The downside of this solution is that the
adapter cost up to 10 times of the 9V battery.


Transmitter and Receiver
Problem:
In the initial stage, a single core wire was used as the antenna for the Transmitter and
Receiver. These results in the LED at the Receiver end to light up intermittently upon
activation. It also has a very limited range.


Solution:
A longer single core wire was coil up and used. This will allow the Transmitter and
the Receiver to have a stronger reception and the LED at the receiver side will have a
more constant output and can last a longer distance.




                                            55
Transmitter and Receiver
Problem:
During the testing of the Microcontroller, there was no response received at the
Microcontroller side from the RF Receiver. In this situation, we do not know if the
RF Transmitter receiver any signal or was it due to the Microcontroller unable to
receive the signal from the RF Receiver.
Solution:
A LED was connected to the output pin of the RF Receiver in parallel with the PG7
of the Microcontroller. In this way, upon receiving data from the RF Transmitter, the
LED will light up to inform us that it is receiving some signal.


Integration
Problem:
During the final testing of the Security System, the Receiver Module could not
receive the data, which was sent from the Active Unit to the Passive Unit.
Attempted Solution:
Decrease the distance between the Active and Passive unit and increase the Antenna
length and tested with other Output ports. Able to Link successfully.




                                           56
                                   CHAPTER 5




                  CONCLUSION AND RECOMMENDATION




5.1 – Summary


        In the beginning of the year, when I started to select my project title and
proceed to write the project proposal for the Final Year Report, I had started on the
research of the project. The literature review was immediately carried out to learn
more about the project that I was tasked with. To date, I am almost successful with
the design and the development of the Security System Integrated with RF. I had
successfully tested all the individual units, drawn out the flow chart and written the
program using C. I was able to use to sample programs to test out the PIC16F877A
Microcontroller using the sample programs provided and to edit the program to my
preferences. The RF Transmitter and Receiver was also successfully tested and
implemented as a separate unit. During the development of the software for the
Security Modules, I had faced many problems writing the software from its flow
chart. This was overcome with a friend who had a great deal of experience with
programming Microcontroller. Through his advice, I was able to understand and
develop the software required for the Security Modules. Finally, throughout this one
year of project, I believed that the project was a success as its main objectives were
met. Throughout the duration of the project, I had picked up many valuable skills and
knowledge. My years of study in UniKL BMI had been tested and I had learnt to
source of solutions when problem arise and improved on my project management



                                         57
skills. Lastly, my report writing skills and oral presentation skills, which I pick up in
this module, will greatly aid me in my future and my career.




5.2 – Future Recommendation


For future recommendations for the Security System Integrated with RF, many new
improvements could be done to further improve on its hardware and software.
Project management skills could be further improved to allocate more time for the
research on the hardware and software of the Microcontroller. This will allow me to
have a more in-depth understanding of the PIC16F877A Microcontroller, as it is
quite a new Microcontroller to me. Below are some of the areas, which could be
better improved.


Power Supply
By adding a 12V rechargeable battery to the power supply, we could have the
Security System Integrated with RF running for 24hours even during power trips.
The battery will act as a backup power supply in the absence of power.


Voice and Data Transfer
A camera could be added to the Home system and speakers added to allow the Home
and Security to communicate over real-time. Cameras added to the Home system
could also allow the Security to have a live feed of each individual house.




                                           58
Short Messaging Services (SMS)
Incorporate the Microcontroller to a modem. This will enable the Microcontroller to
send an SMS to the other home users who are not at Home or even to the Security
guard.




Intruder Alert
Incorporate sensors or motion detectors to the Home system to monitor the Home
when the Home users arm the house. This will enable the home to be automatically
protected and secured without relying on the Home user to activate the distress
button.




                                        59
5.3    Review and Reflections




There were several problems, which was encountered throughout the course of the
project. Upon completion of the project, I was able to better understand my strengths
and weakness on the technical skills and knowledge related to this project.


My Strengths
My strengths developed throughout my course in UniKL BMI had taught me the
basics of developing the hardware and software. Besides these, my ability to source
for solutions when I encounter a problem was also greatly put to use.


My Weakness
The weakness I had was with the understanding of the Microcontroller, as I had
never worked with a Microcontroller or done any programming of the
Microcontroller. The PIC16F877A was also relatively new to me and I did not know
how to commencement for this project. The main weakness was probably the
integration of the hardware, which I had encountered problems with. In all, I felt that
more time should been allocated to the understanding of the PIC16F877A
Microcontroller as it is quite a complex chip.




                                          60
5.4   Skills Review




         This project requires a lot of knowledge on both hardware and software
engineering. Skills like information research, time management and project
management were very important throughout this project and the skill was greatly
enhanced. Time and Project management skills were two of the more important skills
required in this project. This is because of the tight schedule of juggling a full time
job and the part time studies, which consists of juggling another 20 credit units
beside this Final Year Project. A lot of time was also spent on doing research on the
information needed, especially in the initial stage of the Project Overview to get a
better understanding on how the neighborhood security system works. In the latter
stage, information research is also needed to complete the Literature Review portion.
In my three years of study in UniKL BMI, I had gained invaluable knowledge of
logic design, analogue electronics and digital electronics, which I believe was put to
used for this project. Skills on basic troubleshooting techniques and Programming
skills on C+ language were also learned, put to use and improved. For this project,
the biggest problem I had faced was the hardware and software portion of the Rabbit
Microcontroller, as I have limited knowledge on the chip. Therefore, a lot of time
was spent on gaining more knowledge on the PIC16F877A Microcontroller.
Although I have had some knowledge on C programming during my polytechnic
days and during my course of work, I had never done any Dynamic C programming,
as this is required to program the PIC16F877A Microcontroller. Therefore, I will
need to greatly strengthen my skills on programming for this project otherwise many
problems might occur, even during the compiling of the software program.




                                          61
                                  REFERENCES


1. www.hsas.com.sg
2. http://o.mneina.googlepages.com/what_is_microcontroller.htm
3. http://en.wikipedia.org/wiki/Microcontroller
4. http://en.wikipedia.org/wiki/Zilog_Z80
5. http://www.zilog.com/products/
6. www.semiconductorstore.com/pdf/newsite/microchip/SW300040-EVAL_PB2.pdf
7. http://www.microcontroller.com/Embedded.asp?did=33
8. http://www.rabbit.com/products/rcm3700/
9. www.alge-timing.com/alge/rls1n-e.htm
10. http://dailydiy.com/2007/05/05/diy-wireless-link-for-microcontroller/
11. http://www.sparkfun.com/commerce/product_info.php?products_id=7813
12. http://www.freepatentsonline.com/6681101.html
13. http://en.wikipedia.org/wiki/ZigBee
14. http://www.zigbee.org/
15. www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=75
16. http://www.national.com/mpf/LM/LM2575.html
17. http://www.national.com/mpf/LM/LM3940.html
18. http://www.national.com/mpf/LM/LM386.html
19. http://www.rabbit.com/products/rcm3700/rcm3700.pdf
20. http://www.rfsolutions.co.uk/acatalog/DS069-8.pdf


Books/Journals
1. K. Hyder, Embedded systems design using the 16F877A Microprocessor:
interfacing, networking, and application development. Burlington, Mass.: Newnes,
2005.
2. M. James, Microcontroller cookbook. Oxford: Newnes, 2001.

                                            xi
             APPENDIX


Appendix A




                xii
xiii
Appendix B




             xiv
xv
xvi
xvii
Appendix C




             xviii
xix
Appendix D




             xx
xxi
xxii
xxiii
xxiv
xxv
xxvi
xxvii
Appendix E


Security System Integrated With RF Source Code


#include <16f877a.h> //use pic16f877a
#device adc=10     //set 10-bit adc
#use delay(clock=20000000) //operating speed 20mhz
#fuses hs,nowdt,noprotect,nolvp //default fuse setting
#define use_portb_lcd TRUE //use portb for lcd
#include <lcd.c> //call lcd.c library


//initialize port A,B,C,D,E
#byte PORTA=5
#byte PORTB=6
#byte PORTC=7
#byte PORTD=8
#byte PORTE=9


//program parameter
int arm_sta=0;
int card_detected=0;
int buffer[3];
int mycard[3];
int i;
int win=0;
int motion=0;
int door=0;
int wfloat=0;
int alarm_en=0;
int lcd_en=0;
long int mysuhu;

                                        xxviii
long int mytimer;


void record_card(); //record card module
void detect_card(); //detect card module


//timer module for servo module
#int_rtcc
clock_isr()
{
    detect_card();//detect card


    if(mytimer<9765) //if timer not yet reach 1sec
    {
        mytimer=mytimer+1; //upcount
    }
    else //if reached 1sec
    {
        mytimer=0; //reset timer
        lcd_en=1;
    }


}


void main()
{
    set_tris_a(0b00001111);
    set_tris_b(0b00000000);
    set_tris_c(0b00001110);
    set_tris_d(0b00000011);
    set_tris_e(0b00000011);
    setup_port_a(RA0_ANALOG);
    setup_adc(ADC_CLOCK_INTERNAL);

                                           xxix
set_adc_channel(0);


//initialize rfid reader
set_rtcc(0);
setup_counters(RTCC_INTERNAL, RTCC_DIV_2);
enable_interrupts(int_rtcc);
enable_interrupts(GLOBAL);


//test i/o port
output_high(pin_d6); //on red led
output_high(pin_c7); //on green led
output_low(pin_c4); //off siren
output_low(pin_d3); //off pilot light
output_low(pin_d2); //off solenoid
delay_ms(1000);
output_low(pin_d6); //off red led
output_low(pin_c7); //off green led
delay_ms(1000);


lcd_init(); //initialize lcd
printf(lcd_putc,"\fTouch Card");
printf(lcd_putc,"\nTo Record");
record_card(); //record card
printf(lcd_putc,"\fCard ID:%x%x%x",buffer[2],buffer[1],buffer[0]);
printf(lcd_putc,"\nRecorded");
mycard[2]=buffer[2];
mycard[1]=buffer[1];
mycard[0]=buffer[0];
delay_ms(3000);
card_detected=0;
output_low(pin_d6); //off red led
output_high(pin_c7); //on green led

                                        xxx
  do
  {
      mysuhu=read_adc()/2; //read temperature


      if(card_detected==1) //if card detected
      {
          lcd_gotoxy(1,2);
          printf(lcd_putc,"Card ID:%x%x%x ",buffer[2],buffer[1],buffer[0]);
          if(buffer[2]==mycard[2] && buffer[1]==mycard[1] && buffer[0]==mycard[0])
//if valid card
          {


              output_low(pin_d6); //off red led
              output_low(pin_c7); //off green led
              output_low(pin_c4); //off siren
              output_low(pin_d3); //off pilot light
              output_high(pin_d2); //unlock door
              delay_ms(2000);


              //toggle arm mode
              if(arm_sta==1)
              {
                  arm_sta=0;
                  output_low(pin_d6); //off red led
                  output_high(pin_c7); //on green led
              }
              else
              {
                  arm_sta=1;
                  output_high(pin_d6); //on red led
                  output_low(pin_c7); //off green led

                                                 xxxi
        }
        delay_ms(1000);
    }


    card_detected=0;
    buffer[2]=0;
    buffer[1]=0;
    buffer[0]=0;
    delay_ms(2000);
    output_low(pin_d2); //lock door
    delay_ms(2000);
}


if(input(pin_c1)==0) //open door manually
{
    output_high(pin_d2); //unlock door
    delay_ms(5000);
    output_low(pin_d2); //lock door
    delay_ms(2000);
}


if(input(pin_c2)==0) //if door closed
{
    door=0;
}
else
{
    door=1;
}


if(input(pin_c3)==0) //if window closed
{

                                        xxxii
    win=0;
}
else
{
    win=1;
}


if(input(pin_d0)==0) //if motion not detected
{
    motion=0;
}
else
{
    motion=1;
}


if(input(pin_d1)==0) //if float not detected
{
    wfloat=0;
}
else
{
    wfloat=1;
}


alarm_en=door+win+motion+wfloat;


if(arm_sta==1) //under arm mode
{
    //if any sensor triggered
    if(alarm_en>0 || mysuhu>50)
    {

                                      xxxiii
                output_high(pin_c4); //on siren
                output_high(pin_d3); //on pilot light
            }
        }
        else
        {
            output_low(pin_c4); //off siren
            output_low(pin_d3); //off pilot light
        }


        if(lcd_en==1)
        {
            //display output
            lcd_gotoxy(1,1);
            printf(lcd_putc,"Arm:%u T:%03luC D:%u",arm_sta,mysuhu,door);
            lcd_gotoxy(1,2);
            printf(lcd_putc,"Mot:%u Win:%u FS:%u",motion,win,wfloat);
            lcd_en=0;
        }


    }while(1);


}


void record_card() //record card module
{
    output_high(pin_e2); //enable reader


    for(i=0; i<26;i++)
    {
        while(input(PIN_e0)==1 && input(PIN_e1)==1);



                                                  xxxiv
        if(input(PIN_e1)==0 )
        {        if(i!=0 && i != 25)
                {      shift_left(buffer,3,0); }
        }
        if(input(PIN_e0)==0)
        {           if(i!=0 && i != 25)
                    {shift_left(buffer,3,1); }
        }
        delay_us(500);
    }
}


void detect_card() //detect card module
{
    output_high(pin_e2); //enable reader


    //rfid read
    if(input(pin_e0)==0 || input(pin_e1)==0)
    {
        buffer[0]=0;
        buffer[1]=0;
        buffer[2]=0;


        //read Wiegand Format (26bit binary) card data
        for(i=0; i<26;i++)
        {
            while(input(PIN_e0)==1 && input(PIN_e1)==1);
            if(input(PIN_e1)==0 )
            {
                if(i!=0 && i != 25)
                {
                    shift_left(buffer,3,0);

                                                   xxxv
                }
            }
            if(input(PIN_e0)==0)
            {
                if(i!=0 && i != 25)
                {
                    shift_left(buffer,3,1);
                }
            }
            delay_us(500);
        }
        card_detected=1;
    }
}




                                              xxxvi
Week7
Week 8
Week9




Week10




Week 11
Week12
Week13
Week 14
           SECURITY SYSTEM INTEGRATED
                     WITH RF
               Muhammad Nazri bin Ahmad1 & Shaiful Azlizan bin Khairuddin2
                                         1
                                          Section of Electrical Technology
                                         2
                                          Section of Electrical Technology
                                Universiti Kuala Lumpur British Malaysian Institute

      Abstract: In a populated area, the houses are spread out over a large distance. This will result in many
      houses being isolated in a particular area. The purpose of this project is to construct a Security System,
      which consist of the Security Unit at the security post and the Home Unit located at each individual
      home. The Security Unit is controlled by a Microcontroller. This Microcontroller is programmed using
      C language, which is then complied using its C complier. The device used to communicate between the
      Security and Home Unit will be the Radio Frequency (RF) Transmitter and Receiver. This system is
      capable of allowing the home users to alert the security post instantaneously in an emergency through
      wireless link rather than relying on the telephone network or routine security patrols. The aim of this
      project is to allow the Security Unit to receive signals from the Home Unit through its RF transmitter
      and receiver. Each Unit consists of 3 main components, which are the Microcontroller, Transmitter and
      Receiver. Instead of burglars alarms, it also has flood sensor and heat sensor to detect fire.


      Keywords: Security System Integrated With RF (SSIRF)


1.0 INTRODUCTION                                               sensor and door sensor. It also displays whether the
                                                               system is arm or disarms. When we swap the card,
Security has to be compared to related                         the system arms meaning that if any of the sensors
concepts: safety, continuity, reliability. The    key          trigger, the alarm will activate.
difference between security and reliability is that                 .
security must take into account the actions of people
attempting to cause destruction. Perception of                 3.0 RESULTS
security is sometimes poorly mapped to measureable
objective security. The perceived effectiveness of             The PIC16F877A Microcontroller was used as the
security measures is sometimes different from the              heart of the system and all the rest of the components
actually security provided by those measures. The              were connected to its Serial ports or I/O ports
presence of security protections may even be taken             directly. The green and red LEDs at each system are
for security itself.                                           used to indicate the connection status and the alarm
2.0 MATERIALS AND METHODS                                                                  status respectively. The
                                                                                           RFID is used as the input
     The system powered by 12vdc rechargeable                                              from the users to the
battery. The PIC16f877A is a main controller for the                                       Microcontroller; it allows
system. The RFID will arm and disarm the whole                                             the user to activate the
system. When the system is in arm condition, the                                           alarm at the Home system
main entrance will lock. We use solenoid as the                                            or for the guard to activate
locking mechanism meaning that you can only enter                                          the acknowledgement and
the main entrance using the right card as recorded by                                      reset button. The Security
the RFID. The solenoid will open and closed in                 and Home system are somehow similar as it contains
around 7 second counting.                                      similar separate units except the Security consists of
         We put LCD for system display. It will                a buzzer and more LEDs for indication of the
display five sensors that were used for the system.            different houses that it is linked to.
Flood sensor, fire sensor, motion sensor, vibration
The Home System consists of the PIC16F877A                 This will allow me to have a more in-depth
Microcontroller, the Transmitter and Receiver and          understanding of the PIC16F877A Microcontroller,
green and red LEDs. These LEDs are used to indicate        as it is quite a new Microcontroller to me.
the connection and alarm respectively. Each green is
to indicate the connection and red to indicate alarm


4.0 DISCUSSION
Power Supply                                               REFERENCES
Problem:
A 9V battery was each used to power up the whole of        website
Security and Home system, this result in the battery       1. www.hsas.com.sg
being drained quickly during the testing stage of the      2. http://en.wikipedia.org/wiki/Microcontroller
system.                                                    3. http://en.wikipedia.org/wiki/Zilog_Z80
Solution:                                                  4. http://www.zilog.com/products/
A 12V adapter was used in place of the 9V battery.         5. http://www.rabbit.com/products/rcm3700/
This 12V adapter is able to output a stable supply         6. www.alge-timing.com/alge/rls1n-e.htm
with a 1A of current. The downside of this solution is     7. http://www.freepatentsonline.com/6681101.html
that the adapter cost up to 10 times of the 9V battery.    8. http://en.wikipedia.org/wiki/ZigBee
                                                           9. http://www.zigbee.org/
Transmitter and Receiver
Problem:                                                   Books/Journals
In the initial stage, a single core wire was used as the   1. K. Hyder, Embedded systems design using the
antenna for the Transmitter and Receiver. These            16F877A Microprocessor: interfacing, networking,
results in the LED at the Receiver end to light up         and application development. Burlington, Mass.:
intermittently upon activation. It also has a very         Newnes, 2005.
limited range.                                             2. M. James, Microcontroller cookbook. Oxford:
Solution:                                                  Newnes, 2001.
A longer single core wire was coil up and used. This
will allow the Transmitter and the Receiver to have a
stronger reception and the LED at the receiver side
will have a more constant output and can last a longer
distance.

Integration
Problem:
During the final testing of the Security System, the
Receiver Module could not receive the data, which
was sent from the Active Unit to the Passive Unit.
Attempted Solution:
Decrease the distance between the Active and Passive
unit and increase the Antenna length and tested with
other Output ports.



5.0 CONCLUSION
    For future recommendations for the Security
System Integrated with RF, many new improvements
could be done to further improve on its hardware and
software. Project management skills could be further
improved to allocate more time for the research on
the hardware and software of the Microcontroller.

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:78
posted:11/11/2011
language:Malay
pages:108