Final Book Erick
-
Upload
erick-mataba -
Category
Documents
-
view
32 -
download
1
Transcript of Final Book Erick
DECLARATION
I hereby, declare that i carried out the work reported in this report in the department of
Electronics and Telecommunication Engineering, at Dar-es-Salaam Institute of
Technology, under the supervision of Dr .KENNEDY A.GREYSON I , also solemnly
declare that to the best of my knowledge, no part of this report has been submitted here
or elsewhere in a previous application for award of a degree. All sources of knowledge
have been duly acknowledged.
Student name: Erick Mataba
Admission number:1006028228
Signature:...................................
i
CERTIFICATION
This is to satisfy that this thesis titled “Design and Implementation of an Interactive sms-
based Controlled Home Automation and Security system” by Erick Mataba, meet the
requirement and regulation governing the award for the bachelor of engineering degree at
Dar-es-Salaam Institute of Technology (D.I.T) and is approved for its contribution to
knowledge and literary presentation.
Supervisor: Name: Dr. KENEDY A. GREYSON
Signature:……………………………
Date:…………………………………
ii
DEDICATION
I dedicate this project to the Prince of Peace my Lord Jesus Christ for giving me the grace
and enablement to carry out this project. Also to my dear parent and siblings for their
continual support, this project wouldn’t have been possible without their loving presence in
my life.
iii
ACKNOWLEDGEMENT
First of all, I would like to express my gratitude and thanks to my supervisor,
Dr.Kennedy.A.Greyson for his invaluable advice and guidance throughout the period
of this semester. His guidance in this project will remain forever.
My appreciation also to my parents, Deusdedith Mataba and Florence Kyambile ,
who have been so tolerant and supports me all these academic years. Thanks for their
encouragement, love, emotional and financial supports to me.
iv
ABSTRACT
This project comprises of two sections (Home Automation and Security System). The
home automation was designed to function using short message service (SMS)
application offered by telecommunication networks to control different home appliances
including a security system. The system proposes a network which comprises of a GSM
module, a microcontroller connected to different home appliances, an alarm circuit and
an infrared detector circuit.
The project has been implemented; it successfully controlled four different light bulbs
and fans, it also activated and deactivated the security system.
The microcontroller in the system circuit takes instructions via SMS received by the
GSM module to control the appliances and activate or deactivate the security system.
The microcontroller scans the GSM module for message received, when it sees any
message it decodes the message, performs the instruction the message gives then deletes
the message to wait for another one. When it does this it sends a confirmatory message
to programmed phone numbers via the GSM module.
The security system is functions with an infrared motion detector such that when the
security is bridged it sends a signal to the microcontroller, then the microcontroller sends
signals to the alarm circuit which blows an alarm and also to the GMS module to alert
the owner of the house via SMS that there was an intrusion.
v
Table of Contents
DECLARATION................................................................................................................i
CERTIFICATION..............................................................................................................ii
DEDICATION..................................................................................................................iii
ACKNOWLEDGEMENT................................................................................................iv
ABSTRACT…...................................................................................................................v
LIST OF SYMBOLS.........................................................................................................xi
LIST OF ABBREVIATIONS...........................................................................................xii
CHAPTER ONE.................................................................................................................1
1.0INTRODUCTION.........................................................................................................1
1.1 Background Information..............................................................................................2
1.2 Problem Statement.......................................................................................................3
1.3.0Main Objective of the Project....................................................................................3
1.3.1General Objective.......................................................................................................3
1.3.2Specific Objectives.....................................................................................................3
1.4Significance of the Project............................................................................................4
1.5Scope and Limitation of the Project..............................................................................4
CHAPTER TWO................................................................................................................5
METHODOLOGY.............................................................................................................5
2.0Introduction...................................................................................................................5
2.1Methodology Steps:.......................................................................................................5
LITERATURE REVIEW...................................................................................................7
3.0Introduction...................................................................................................................7
3.1 The Existing System.....................................................................................................7
3.1.1User’s Mobile Phone..................................................................................................8
3.1.2Server……..................................................................................................................8
3.1.3Devices…...................................................................................................................8
3.2 Limitation of the Existing System................................................................................8
3.3The Proposed System....................................................................................................9
vi
3.4.0HOME AUTOMATION SECTION........................................................................10
3.4.1User GSM Phone Handset........................................................................................10
3.4.2Global System for Mobile Communication (GSM) Network..................................10
3.4.3GSM Modem............................................................................................................11
3.4.4The Microcontroller.................................................................................................12
3.4.5Switching Module....................................................................................................12
3.4.6Interfacing Microcontroller and GSM Modem........................................................13
3.4.7Power supply............................................................................................................15
3.4.8MAX 232..................................................................................................................16
3.5The Advantages of Proposed System..........................................................................17
3.6The Disadvantages of Proposed System.....................................................................17
3.7SECURITY SYSTEM.................................................................................................17
3.7.1BURGLAR ALARM...............................................................................................18
3.7.2 Passive infrared detectors.......................................................................................19
3.7.3 Ultrasonic detectors.................................................................................................19
3.7.4 Photo-electric beam.................................................................................................20
3.7.5 Outdoor…................................................................................................................21
3.7.6Taut wire fence systems...........................................................................................21
3.7.7Microwave barriers...................................................................................................21
3.7.8Passive magnetic field detection:.............................................................................22
3.7.INFRARED DETECTOR..........................................................................................22
3.8.0INFRARED SENSOR DESIGN..............................................................................23
3.9.0 GSM INTRUDER ALERT USING SHORT MESSAGE SERVICES...........24
3.9.1HOW SMS WORKS................................................................................................26
3.9.2APPLICATIONS......................................................................................................27
3.9.3BENEFITS OF USING GSM INTRUDER ALERT...............................................27
CHAPTER FOUR............................................................................................................28
DATA COLLECTION.....................................................................................................28
4 Introduction…...............................................................................................................28
4.2Switching Relay..........................................................................................................29
4.3GSM Modem...............................................................................................................30
CHAPTER FIVE..............................................................................................................34
vii
DATA ANALYSIS AND DESIGNING..........................................................................34
2 Data Analysis................................................................................................................34
5.1Power Supply..............................................................................................................34
5.1.1Transformer..............................................................................................................34
5.1.2Bridge Rectifier........................................................................................................35
5.1.3Filter…….................................................................................................................35
Figure 5-1 Power supply..................................................................................................36
5.2Programmable Interface Controller (P.I.C).................................................................36
5.3Relay Switching Circuit Analysis...............................................................................38
5.4The complete circuit diagram......................................................................................43
5.5Software designing......................................................................................................44
5.6Coding…….................................................................................................................44
CHAPTER SIX................................................................................................................46
RESULTS AND DISCUSSION......................................................................................46
3 Introduction…...............................................................................................................46
6.1 Regulated Power supply.............................................................................................46
6.2 Relay Circuit Simulation:..........................................................................................47
6.3.0 Complete Circuit Diagram Simulation....................................................................48
6.3.1Simulation of the Complete Circuit Diagram when Security System is ON...........49
6.3.2 Simulation of the Complete Circuit when Home Appliences is ON.......................49
CHAPTER SEVEN..........................................................................................................50
CONCLUSION AND RECOMMENDATIONS.............................................................50
7.0 SUMMARY:..............................................................................................................50
7.2 CHALLENGES..........................................................................................................51
7.3 RECOMMENDATIONS...........................................................................................51
APPENDIX…..................................................................................................................54
APPENDIX A: Cost Estimation.......................................................................................54
Appendix B Gantt chart for project schedule...................................................................55
APPENDIX C…...............................................................................................................57
APPENDIX: D.................................................................................................................58
APPENDIX :D.................................................................................................................59
viii
LIST OF FIGURES
Figure 3-1: Existing System……………………………………….………….5
Figure 3-2: Proposed System Block Diagram………………………………..7
Figure 3-3: GSM Network Architecture …………………………………......8
Fig 3-4;Gsm Modem………………………………….……………….…...….9
Figure 3.4.6:interfacing microcontroller and gsm………………………....…12
Figure2.4.7: Regulated power supply system…………………………….…..13
Figure 4.3.1: GSM Modem (Top view)……………………..…………..........31
Figure 4.3.1: GSM Modem (bottom view)….…………………………......…32
Figure 5-1 Power supply……………………………………………….…......36
Figure5-2: Pin arrangement of PIC16F877A…………………………...….....37
Figure5-3: Side view of PIC 16F877A…………………..…………….…......38
Figure 5-4: Schematic Diagram of the Relay Switching Circuit……………...39
Figure 5-2: A Schematic Diagram of Relay Circuit…………………...……...40
Figure 5-4: A Schematic Diagram of Relay Circuit…………………………..42
Figure5-4: Complete Circuit diagram for Home automation and Security…...43
Figure5-5: The Flowchart of the System……………………………….…......45
Figure 6-5:The AC output wave at the secondary terminal of transformer…..45
Figure6-2: Simulation results of Power supply…………………..…………..46
Figure6-3: Relay Circuit Simulation……………………………….…………47
Figure6-4: Complete Circuit Diagram Simulation when the system is ON….48
Figure6-5:Simulation when Security System is ON…..……………………..49
ix
Figure6-5:Simulation when all appliances is ON…………………………...50
LIST OF TABLES
Table 4.1.1: PIC data sheet
Table 4.2.1 : Parameter of Relay
Table 4.2.2: Voltage Requirements For PIC and Switching Circuit
Table4.4: Technical Specification of GSM MODEM
Table 4.4: The Daily Use of Home Appliances
Table 5-1: Specification of BC 140 NPN
x
LIST OF SYMBOLS
……………………………………….….. Ammeter
…………………………………………….Antenna
…………………………………………….Diode, General
…………………………………………….Ground, Earth
……………………………………………..Integrated Circuit
………………………………………….….Lamp, Neon
……………………………………………..Battery
……………………………………………..Relay, SPDT
……………………………………………. Resistor
………………………………………….....Signal Generator
………………………………………….....Switch, Momentary-Contact
xi
……………………………………….…….Transformer, Iron-Core
……………………………………………..Transistor, Bipolar, npn
…………………………………………….Voltmeter
.
LIST OF ABBREVIATIONS
AC… … .…………………………...Alternating Current
A/D……………………………….…Analog to digital
BTS……………………………….…Base transceiver station
CDMA……………………………....Code Division Multiple Access
CPU…………………………………Central processing unit
D/A …………………………..….… Digital to analog
DC……………………………...…...Direct Current
GSM………………………….…..…Global System for Mobile communication
I/O………………………….……..…Input/output lines
MCU…………………………….…. Microcontroller unit
PIC ……………………………….....Programmable interface controller
RAM………………………...………Random-access memory
ROM…………………………….......Read-only memory
SIM ………………………………....Subscriber Identity Module
SMS…………………………………Short Message Text
xii
xiii
CHAPTER ONE
1.0 INTRODUCTION
The concept of “automation” has existed for years. It began with a student connecting
two electric wires to an alarm clock in order to close a circuit of a battery and light
bulb. Later, companies developed automated systems of their own to control alarms,
sensors, actuators and video cameras and, in so doing, created the first automated
buildings
The term “intelligent home” followed. Due to the obvious advantages of these
systems, their influence on the conventional home was predictable and finally, in
1988, the term domotics was coined. “Domotics is the application of computer and
robot technologies to domestic appliances. It is a portmanteau word formed from
domus (Latin, meaning house) and robotics.
A modern definition of Domotics could be the interaction of technologies and services
applied to different buildings with the purpose of increasing security, comfort,
communications and energy savings in homes. Home Automation has been in
existence for quite a long time. Today Home Automation has grown widely and has
become a standard in most home because it reduces stress and makes life lot easier.
The increasing universality of heterogeneous computing devices such as laptop
computers, palms, mobiles etc. shows that users prefer an omnipresent access of a
system rather than to be uncomfortably forced to go physically to the nearest control
point. Remote control saves time and everybody is aware of this, it also provides
increased security and flexibility. Home automation takes care of a lot of different
activities in the house. Some of these things are as simple as switching domestic
appliances such as lights, fans, microwave ovens, air-conditioner, water heater, and
personal computer on or off.
An example could be the possibility to turn on an air conditioner from a remote station
using a mobile phone, laptop or PDA so that the home can be cold before one gets
home. This could be really useful and lifesaving.
1
In the area of security which is a major concern to sectors and homes having theft and
burglar cases, technology has also made life easier. The trend of using security
personnel seems to be a basic first level security measure, but as new trends in the
information technology gave birth to new technique in security system such as remote
sensing/alerting systems, which aid in informing the necessary authorities about theft
cases, the worries of people are being reduced. [Source:lamson-home.com,2012]
For instance, if a house resident receives an SMS alerting him/her of an intrusion in
his house when not at home, he/she could connect to the internet (in cases where there
are cameras in the house connected to a wireless network) to view what is happening,
then probably inform security agencies to take action.
As a matter of fact, security will always be a main priority in all families, and
prevention is better than cure. By receiving alerts in a portable device, like instant
messaging (since many users are already familiar with the concepts and user interfaces
of instant messaging) user is informed of all possible issues occurring in the house and
it gives the possibility to deal with it using different ways of control.
Good scalability or expandability properties, independence of location or geographical
distance, and high flexibility due to the different existing protocols make remote-
controlling home automation systems suitable for most user needs.
With the help of intelligent home technologies comfort has increased, safety and
security of life was improved.
Home automation is not a new invention. It has been in existence. but this project is
aimed at further improving on what is already in existence by introducing flexibility to
the chain of commands for control actions, a security system with an alarm included
for confirmatory message to residents’.
1.1 Background Information
The rapid growth of wireless communication motivated us to use mobile phones to
remotely control a home appliance. In this project we describe a remote appliance
control system which can control different household appliances by sending an SMS
message from a mobile phone. This controller is extremely handy at places where we
2
have to control the ON and OFF switching of the devices but no wired connection to
that place is available. The microcontroller would then control and device based on the
information given to it. The proposed solution will need to be easy to use, simple,
secure, and robust and be useful on most mobile phones.
1.2 Problem Statement
i) Need of people to control and monitor their home appliances remotely.
ii) Lack of convenient and reliable means of controlling home appliances remotely.
iii) Absence of means of knowing the status of the home appliance remotely.
1.3.0 Main Objective of the Project.
The objective of this project is divided into general and specific objectives.
1.3.1 General ObjectiveThe general objective of this project is divided into two categories:
i) To design and implement a system that will turn ON or OFF multiple home appliances through text message.
ii) And to provide a security system for the house for safety and convenience.
1.3.2 Specific Objectives.
The specific objectives of the project are as follows:
i) Review literature related to GSM home automation and sensor triggering systems.
ii) Build a model of a house with controllable appliances.
iii) Design and construct an infrared security system with alarm.
iv) Interface the security system with a microcontroller circuit.
3
v)Interface the appliances with the microcontroller circuit.
vi)Create an independent power supply for the system.
vii)Program the microcontroller to carry out any instruction sent to the GSM module
from the GSM phone and sends feedback message to the GSM phone.
1.4 Significance of the Project.
i) Cost reduction. Once the system already installed the energy will be saved.
ii) Save Time. It may happen that someone is far away so from home and forgets to
switch of the power it can be easily for him/her to switch of the power wherever he/she
is needed.
iii) For security purpose; Since the system turn on the power when the person is away
from home no need for a security to go inside to turn on the power because it avoids
lost of home worth or equipments.
1.5 Scope and Limitation of the Project.
i) To design and testing the prototype.
ii)Where GSM network is covered.
4
CHAPTER TWO
METHODOLOGY
2.0 Introduction
This chapter explain different steps that taken in order to accomplish the objectives of
the project. So, in order to achieve the objectives of this project, the following
methodology were undertaken:
2.1 Methodology Steps:
i) Reading different literatures relevant to this project
This is an on-going process from the very start of my project up to its end. Apart from
electronic books, I will also read computer materials.
ii) Data CollectionsOn way towards accomplishment of this project important data about the proposed
system will be gathered as collected from different relevant sources.
iii) Circuit Design
The circuit design will base on information collected in order to meet the objective of
the project.
iv) Programming of Programmable Devices.
The programming of PIC will be done at the end of the project so as to enable the
system automatically save power.
v) Interfacing of System.
5
This will involve interfacing of PIC to the control circuit via GSM network which
provides the interconnection between the peripherals.
vi) Simulation
Different parts of this system after design will be simulated in order to observe results of
each part before implementing the complete circuit.
vii) Circuit Implementation and Testing
Circuit will be implemented in the board to see whether the output is as that one
obtained in the simulation before install it into the Vero board or printed circuit board.
6
CHAPTER THREE
LITERATURE REVIEW
3.0 Introduction This chapter describes the features, operation and limitation of the existing system. Also
explains about the proposed system.
3.1 The Existing System.
The existing system is designed and implemented to monitor home appliances by using
Internet automation. The system consists of three units: a Control unit, an interface unit
and a remote unit. The control unit is the standard server computer with a web based
user interface software and a device driver which is required to control the high power
home devices. The Interface unit is for interfacing the high power loads with the
control unit. The remote unit may be a desktop PC, laptop computer with a web
browser. The home appliances can be controlled over the internet by the remote unit.
The home appliances can be monitored and controlled locally or remotely through a
web browser from anywhere in the world provided that an Internet access is available.
Figure 3-6: Existing System
7
3.1.0 The main components of the system are described below:
3.1.1 User’s Mobile Phone
Mobile phone is a hand held mobile radio telephone for use in an area divided into
small section each with its own short-range transmitter. Also this can be defined as
electronic telecommunication device often referred to as cellular phone or cell phone.
The wave is connected from one phone to another by means of radio waves or satellite
transmission.
3.1.2 Server
The server in this system is a computer connected with a mobile phone for receiving
the message from the user. The connection is done via RS232, when a message is
received it will first enter the mobile phone then immediately an SMS Gateway
Application download the message into the computer and store it in a database. The
decisions include, the appliance to act on, the operation to perform on that appliance
(ON, OFF, or ON for some times). When the decision is taken, the server will then
sends data to one of the cables connected to the microcontroller that will either switch
ON or OFF the appliance.
3.1.3 DevicesThe devices are the appliances that the user wants to control. The appliance can be a
washing machine, cooler, boiler, and cooker. Any of these devices can be started while
the user is away and stopped as desired.
3.2 Limitation of the Existing System.
There are limitations for this system which brings about the need for further improvement, some of which include:
i) Unable to control multiple appliances concurrently.
ii) Unable to know the status of the appliances.
8
3.3 The Proposed System
The system has two parts namely; hardware and software. The hardware architecture
consists of GSM phone, GSM Modem, PIC Microcontroller and a driver circuit. The
GSM modem provides the communication media between the owner phones by
means of SMS messages. The SMS message consists of commands to be executed.
The SMS message is sent to the GSM modem via the GSM public networks as a text
message with a definite predefined format.
Once the GSM modem receives the message, the commands sent will be extracted
and executed by the microcontroller. The system will interpret the commands and
turn the appliances ON/OFF accordingly via the switching module.
Figure 3-7: Proposed System Block Diagram
9
POWER SUPPLY
SWITCHING MODE
GSM MODULE
POWER SUPPLY SECURITY MODE
MIC
RO
CO
NT
RO
LL
ER
tiGO
MO
BIL
E
PH
ON
E DEVICE 1
DEVICE 2
3.4.0 HOME AUTOMATION SECTION
3.4.1 User GSM Phone Handset.
GSM Phone Handset is a type of mobile phone that uses the Global System for Mobile
(GSM) communication to send and receive phone calls and data.GSM uses TDMA
technology that assign a specific frequency to each user.
3.4.2 Global System for Mobile Communication (GSM) Network.
Cellular phone will use GSM Network (global service for mobile commission) which
is digital wireless network provides a common set of compatible service and
capabilities to all mobile users. Base station system (BSS) is connected to the network
and switching subsystem (NSS) by communicating with a mobile switching centre
(MSC). This GSM Network acts as switch, which make call connection through the
base station system. The connecting is depending on the operating frequency, which is
on the range of 900MHz and 1800MHz.
Figure 3-8: GSM Network Architecture [ 5 ].
10
3.4.3 GSM Modem.
A GSM modem is a device, which modulates an analog carrier signal to encode digital
information, and demodulates that carrier to decode the transmitted information
signals in a GSM system. GSM modem modulates data from microcontroller so that
they will suit the GSM network in this project the modem will only process data from
microcontroller so as to send it as the SMS to a GSM network. This modem will
operate at either the 900MHz or 1800MHz frequency band depends on available GSM
network at applied area .Modem consists of two parts, which are mobile telephone
radio and Subscriber Identity Module
Fig 3-4;Gsm Modem [ 6 ]
This enables a communication to be made in the GSM network between user and
mobile terminal. The GSM modem that is going to be interfaced with the
microcontroller operates in the GSM Network. When the GSM modem is activated
through AT command by sending Synchronous Signal (UART) from microcontroller
and route the message.
11
3.4.4 The Microcontroller
A microcontroller is a single chip, self-contained computer which incorporates all the
basic components of a personal computer on a much smaller scale. Microcontrollers
are typically used as embedded controllers where they control part of a larger system
such as appliance, automobile, scientific instrument or computer peripheral
The microcontroller contains the same basic elements as in a computer system. These
are;
i) Central Processing Unit
ii) Memory
iii) I/O
3.4.5 Switching Module.
This module drives (switches ON/OFF) the appliance according to the command sent
in the SMS. The switching module is controlled by the microcontroller. The switching
module may be in the form of a relay which allows a low-power circuit to switch a
relatively high current on or off for example a bulb connected to the 220V mains
supply.
Relay is an electromechanical device that permits the opening and closing of electrical
contacts by means of an electromagnetic structure similar to a moving iron transducer.
That is, when current flows through the coil, it generates a field in magnetic structure
(Energize relay windings), and by doing so the resulting force draws the movable part
towards the fixed part (i.e. It attracts the soft iron armature) and hence causing an
electric contact to be made. The device operates in switching high voltage loads,
whereby its output is connected to the power supply.
12
3.4.6 Interfacing Microcontroller and GSM Modem
AT commands are instructions used to control a modem. AT is the abbreviation of
Attention. Every command line starts with "AT" or "at". That's why modem
commands are called AT commands. There are two types of AT commands.
Basic commands are AT commands that do not start with a "+". For example, D
(Dial), A (Answer), H (Hook control), and O (Return to online data state) are the basic
commands.
Extended commands are AT commands that start with a "+". All GSM AT commands
are extended commands. For example, +CMGS (Send SMS message), +CMGL (List
SMS messages), and +CMGR (Read SMS messages) are extended commands.
The AT command +CPMS (command name in text: Preferred Message Storage)
serves several purposes. It can be used to:
Select the message storage area that will be used when sending, receiving, reading,
writing or deleting SMS messages.
Find the number of messages that are currently stored in the message storage area.
Find the maximum number of messages that can be stored in the message storage area.
Selecting the Message Storage Areas to be Used for SMS Reading, Writing, Deleting,
Sending or Receiving.
To select the message storage areas to be used for SMS reading, writing, deleting,
sending or receiving, the +CPMS AT command should be performed.
The message storage Parameter
The first parameter of the +CPMS AT command, message_storage1, specifies the
message storage area that will be used when reading or deleting SMS messages.
13
The message_storage2 Parameter
The second parameter of the +CPMS AT command, message_storage3, specifies the
preferred message storage area for storing newly received SMS messages.
Values that May be Assigned to the Parameters of the +CPMS AT Command
Here are the values defined in the SMS specification that may be assigned to the
parameters
message_storage1, message_storage2 and message_storage3:
SM. It refers to the message storage area on the SIM card.
ME. It refers to the message storage area on the GSM modem or mobile phone.
Usually its storage space is larger than that of the message storage area on the SIM
card.
MT. It refers to all message storage areas associated with the GSM/GPRS modem or
mobile phone. For example, suppose a mobile phone can access two message storage
areas: "SM" and "ME". The "MT" message storage area refers to the "SM" message
storage area and the "ME" message storage area combined together.
BM. It refers to the broadcast message storage area. It is used to store cell broadcast
messages.
SR. It refers to the status report message storage area. It is used to store status reports.
TA. It refers to the terminal adaptor message storage area
Sending SMS Messages AT Commands (AT+CMGS, AT+CMSS)
Either of the AT commands +CMGS (command name in text: Send Message) and
+CMSS (command name in text: Send Message from Storage) can be used to send
SMS messages from a computer (microcontroller). The key difference between them
is that the +CMGS AT command.
14
:
Figure 3.4.6:interfacing microcontroller and gsm[6]
3.4.7 Power supply
The power supplies are designed to convert high voltage AC mains electricity to a
suitable low voltage supply for electronic circuits and other devices. A power supply
can by broken down into a series of blocks, each of which performs a particular
function. A d.c power supply which maintains the output voltage constant irrespective
of a.c mains fluctuations or load variations is known as “Regulated D.C Power
Supply”. For example a 5V regulated power supply system.
15
Figure2.4.7: Regulated power supply system
3.4.8 MAX 232
The MAX232 from Maxim was the first IC which in one package contains the
necessary drivers (two) and receivers (also two), to adapt the RS-232 signal voltage
levels to TTL logic. It does is to convert signal voltage levels”. The MAX 232 has two
receivers (converts from RS-232 to TTL voltage levels) and two drivers (converts
from TTL logic to RS-232 voltage levels). This means only two of the RS-232 signals
can be converted in each direction. The MAX232 is a dual driver/receiver that includes
a capacitive voltage generator to supply EIA-232 voltage levels from a single 5-V
supply.
16
3.5 The Advantages of Proposed System.
The advantage of the system is, it can be economically operated because it enables the
user to select the economical time to switch ON/OFF the home appliances.
3.6 The Disadvantages of Proposed System.
i) it operate depends on network parameters.
ii) High starting cost.
3.7 SECURITY SYSTEM
The Institute for Security and Open Methodologies (ISECOM) defines security as "a
form of protection where a separation is created between the assets and threat. This
includes but is not limited to the elimination of either the asset or the threat. In order to
be secured, either the asset is physically removed from the threat or the threat is
physically removed from the asset. Security is the degree of protection against danger,
loss, and criminals.
Security has to be compared and contrasted with other 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.
With Home Automation, the consumer can select and watch cameras live from an
Internet source to their home or business. Security cameras can be controlled, allowing
the user to observe activity around a house or business right from a Monitor or touch
panel. Security systems can include motion sensors that will detect any kind of
unauthorized movement and notify the user through the security system, alarms can
also be used or via cell phone.
17
3.7.1 BURGLAR ALARM
Burglar alarms have become standard equipment in stores and other businesses, and
they're becoming increasingly common in private homes as well, most alarm systems
are actually built around the same basic design concepts.
The concept of burglar alarms was introduced to the world by Edwin Holmes. Holmes
made these alarms an important component of business and residential security. In
1905, after enjoying several years of successful business, Holmes sold the concept of
burglar alarms and his company to American Telephone and Telegraph Company
(AT&T). Since then, a lot of people sleep easy as they know that if someone breaks
into their homes and offices, the alarm will ring and alert the police. A burglar alarm
can be classified into two categories depending on the type of electric circuit system
used: closed-circuit alarm or open-circuit alarm. In a closed-circuit alarm, the circuit is
completed only when the door is closed. That is, when the door is closed, electricity
can pass through the circuit. However, when the door is opened, the flow of electricity
in the circuit is interrupted and the circuit becomes open. This triggers the alarm to
start ringing. In an open-circuit alarm, the opposite is true. That is, the alarm is
triggered when the circuit is closed.
Also, the ringing of the alarm can depend on the movement of the intruder. So, how
would a burglar alarm detect movement? The alarm system has a set of magnetic
sensors that sense movement. A magnetic sensor is composed of a battery that
functions as the power source, a magnet that is embedded in the door, a spring switch,
and a buzzer. As soon as some motion is detected, a magnetic sensor transmits signals
to the alarm device through the control box. Upon receiving these signals, the alarm
starts ringing. The shrill sound of the alarm is supposed to scare the intruder away.
The most common security sensors are used to indicate the opening of a door or
window or detect motion via passive infrared (PIR). New construction systems are
predominately hardwired for economy. Retrofit installations often use wireless
systems for a faster, more economical installation. Some systems serve a single
purpose of burglar or fire protection. Combination systems provide both fire and
18
intrusion protection. Systems range from small, self-contained noisemakers, to
complicated, multi-zoned systems with colours-coded computer monitor outputs.
Many of these concepts also apply to portable alarms for protecting cars, trucks or
other vehicles and their contents. There are different types of alarms; the outdoor and
the indoor alarms.
Indoor alarms: These types of sensors are designed for indoor use. Outdoor use would
not be advised due to false alarm vulnerability and weather durability. The different
types include; the passive infrared detector, the ultrasonic and photoelectric beam.
3.7.2 Passive infrared detectors
The passive infrared detector (PIR) is one of the most common detectors found in
household and small business environments because it offers affordable and reliable
functionality. The term passive means the detector is able to function without the need
to generate and radiate its own energy (unlike ultrasonic and microwave volumetric
intrusion detectors that are “active” in operation) .PIRs are able to distinguish if an
infrared emitting object is present by first learning the ambient temperature of the
monitored space and then detecting a change in the temperature caused by the
presence of an object.
3.7.3 Ultrasonic detectors
Using frequencies between 25 kHz and 75 kHz, these active detectors transmit
ultrasonic sound waves that are inaudible to humans. The Doppler shift principle is the
underlying method of operation, in which a change in frequency is detected due to
object motion. This is caused when a moving object changes the frequency of sound
waves around it.
19
Two conditions must occur to successfully detect a Doppler shift event:
i) There must be motion of an object either towards or away from the receiver.
ii) The motion of the object must cause a change in the ultrasonic frequency to the
receiver relative to the transmitting frequency.
iii) The ultrasonic detector operates by the transmitter emitting an ultrasonic signal into
the area to be protected. The sound waves are reflected by solid objects (such as the
surrounding floor, walls and ceiling) and then detected by the receiver. Because
ultrasonic waves are transmitted through air, then hard-surfaced objects tend to reflect
most of the ultrasonic energy, while soft surfaces tend to absorb most energy.
iv) When the surfaces are stationary, the frequency of the waves detected by the receiver
will be equal to the transmitted frequency. However, a change in frequency will occur
as a result of the Doppler principle, when a person or object is moving towards or
away from the detector. Such an event initiates an alarm signal. This technology is
considered obsolete by many alarm professionals, and is not actively installed.
3.7.4 Photo-electric beam
Photoelectric beam systems detect the presence of an intruder by transmitting visible
or infrared light beams across an area, where these beams maybe obstructed. To
improve the detection surface area, the beams are often employed in stacks of two or
more. However, if an intruder is aware of the technology’s presence, it can be avoided.
The technology can be an effective long-range detection system, if installed in stacks
of three or more where the transmitters and receivers are staggered to create a fence-
like barrier. Systems are available for both internal and external applications. To
prevent a clandestine attack using a secondary light source being used to hold the
20
detector in a ‘sealed’ condition whilst an intruder passes through, most systems use
and detect a modulated light source.
3.7.5 OutdoorThis includes taut wire fence, passive magnetic field detection, microwave barrier.
3.7.6 Taut wire fence systems
A taut wire perimeter security system is basically an independent screen of tensioned
tripwires usually mounted on a fence or wall. Alternatively, the screen can be made so
thick that there is no need for a supporting chain wire fence. These systems are
designed to detect any physical attempt to penetrate the barrier. Taut wire systems can
operate with a variety of switches or detectors that sense movement at each end of the
tensioned wires. These switches or detectors can be a simple mechanical contact, static
force transducer etc. Unwanted alarms caused by animals and birds can be avoided by
adjusting the sensors to ignore objects that exert small amounts of pressure on the
wires. It should be noted that this type of system is vulnerable to intruders digging
under the fence. A concrete footing directly below the fence is installed to prevent this
type of attack.
i) pros: low rate of false alarms, very reliable sensors and high rate of detection.
ii) cons: Very expensive, complicated to install and old technology.
3.7.7 Microwave barriers
The operation of a microwave barrier is very simple. This type of device produces an
electromagnetic beam using high frequency waves that pass from the transmitter to the
21
receiver, creating an invisible but sensitive wall of protection. When the receiver
detects a difference of condition within the beam (and hence a possible intrusion), the
system begins a detailed analysis of the situation. If the system considers a real
intrusion, it provides an alarm signal that can be treated in analog or digital form.
3.7.8 Passive magnetic field detection:
This buried security system is based on the Magnetic Anomaly Detection principle of
operation. The system uses an electromagnetic field generator powering two wires
running in parallel. Both wires run along the perimeter and are usually installed about
5 inches apart on top of a wall of about one foot buried in the ground. The wires are
connected to a signal processor which analyses any change in the magnetic field. This
kind of buried security system sensor cable could be buried on the top of almost any
kind of wall to provide regular wall detection ability.
pros: Very low false alarm rate, can be put on top of any wall, very high chance of
detecting real burglars.
cons: Cannot be installed near high voltage lines, radars, or airports.
3.7.9 INFRARED DETECTOR
An infrared security beam can be used to set-up an invisible security system using
infrared beams. When the beam is broken (or the power supply cut) the relay is
tripped. This can be used to sound a bell, alarm or other devices. It can be used for
detecting customers entering a shop or vehicles coming up a driveway.
There are different types of infrared sensors, this can be normal motion detectors that
trigger an alarm or it can be connected wirelessly to your telephone. When the alarm is
triggered, then it causes the system to call the phone number(s) or send sms to the
telephone number that is programmed in the security system. More elaborate systems
can have:
i) Wireless security cameras.
22
ii) Glass breaking sensors.
iii) Outdoor decals to alert burglars that there is an intruder.
iv) Shrill or silent alarms.
This project is a combination of both alarming system and SMS. When the alarm is
triggered, an sms will be sent to the telephone number of an SMS module used to
program the system.
Infrared sensors are among the most common devices used for detecting motion.
Passive-infrared sensors detect the heat emitted by animate forms. Because all living
things emit heat, a system of recording measurable changes in a specific area provides
a means of detecting unauthorized intrusions.
When the unit registers changes in temperature in its area of detection, it relays the
information to a processor which measures the change according to detection
parameters. If the change falls outside the parameters, the processor sends a signal to
an alarm unit[4].
3.8.0 INFRARED SENSOR DESIGN
These systems' design detects infrared heat emitted by living objects. They do not emit
any signal or energy wave like ultrasonic sensors. The design includes a mirror or lens
that captures the heat emission and transfers the emission to a solid-state chip on a
circuit board which records the changes. Only a part of the chip is affected and as the
object moves, so does the "hot spot" on the chip.
The processor then records this movement and triggers the alarm. Many companies
offer a range of lenses to address different situations. For example, homeowners may
not want their alarms to sound when it registers a pet moving across the detection area
during the middle of the night. A special lens that does not detect floor-level
movement addresses this specific scenario.
One must ensure that the pet will not climb into the detection zone. However, because
of the regularity of body heat and its propensity to influence measurable temperatures
23
in the surrounding environment, these types of sensors are regarded as among the most
reliable of motion detectors. As also smaller and cheaper than most other types of
sensors, many people find them to be a attractive choice for their home security.
Units consist of two (dual) or four (quad) sensor units. The dual-sensor model projects
two contiguous detection zones. This projection allows the sensor to track movement
as changes occur in both detection zones. The quad-sensor model also includes a
vertical element registering changes in upper and lower sections.
Different sensors may cover different zones to reduce false alarms. The detection
range for these sensors is not as complete as it is for active-type sensors. Detection
areas radiate out from the central point where the unit is located, thus, gaps appear
between the detection areas. For this reason, many people decide to use these sensors
in conjunction with other types of detectors such as microwave sensors.
The different sensors record data at different times. Usually a combined system such
as these requires all systems to register abnormalities within their detection
parameters. Typically, the range for models suitable for home security extends for
about thirty feet from the lens. Ideally, this type of sensor should be attached to
ceilings where, in theory, it provides a 360-degree coverage area. Nevertheless,
sensors placed on walls may operate effectively.
In addition, some lenses allow reversible angles of 110 degrees and narrow curtain
coverage.
3.9.0 GSM INTRUDER ALERT USING SHORT MESSAGE SERVICES
(Global System for Mobile communications: originally from Group Special Mobile) is
the most popular standard for mobile phones in the world. Its promoter, the GSM
Association, estimates that 80% of the global mobile market uses the standard.] GSM
is used by over 3 billion people across more than 212 countries and territories. Its
ubiquity makes international roaming very common between mobile phone operators,
24
enabling subscribers to use their phones in many parts of the world. GSM differs from
its predecessors in that both signaling and speech channels are digital, and thus is
considered a second generation (2G) mobile phone system. This has also meant that
data communication is easier to build into the system.
The ubiquity of the GSM standard has been an advantage to both consumers (who
benefit from the ability to roam and switch carriers without switching phones) and also
to network operators (who can choose equipment from any of the many vendors
implementing GSM). GSM also pioneered a low-cost (to the network carrier)
alternative to voice calls, the short message service (SMS, also called "text
messaging"), which is now supported on other mobile standards as well. Another
advantage is that the standard includes one worldwide emergency telephone number,
112. This makes it easier for international travellers to connect to emergency services
without knowing the local emergency number.
GSM networks operate in a number of different frequency ranges (separated into
GSM frequency ranges for 2G and UMTS frequency bands for 3G). Most 2G GSM
networks operate in the 900 MHz or 1800 MHz bands. Some countries in the
Americas (including Canada and the United States) use the 850 MHz and 1900 MHz
bands because the 900 and 1800 MHz frequency bands were already allocated. Most
3G GSM networks in Europe operate in the 2100 MHz frequency band. Similarly,
instead of using a dedicated phone, a GSM module can be integrated to make the
project more dynamic. This is because a GSM module can be controlled using AT
commands. The GSM module can also be interfaced with a microcontroller for
automation and control. This project would incorporate a GSM module to send SMS
alert messages to the user when an intruder is detected in the system.
One of the features of GSM which is to be used in this project is its short message
services which informs an individual of an intruder through sms. Short message
service is a mechanism of delivery of short messages over the mobile networks. It is a
store and forward way of transmitting messages to and from mobiles. The message
(text only) from the sending mobile is stored in a central short message center (SMC)
which then forwards it to the destination mobile.
25
This means that in the case that the recipient is not available; the short message is
stored and can be sent later. Each short message cannot be longer than 160 characters.
These characters can be text (alphanumeric) or binary Non-Text Short messages. An
interesting feature of SMS is return receipts. This means that the sender, if wishes, can
get a small message notifying if the short message was delivered to the intended
recipient. Since SMS used signaling channel as opposed to dedicated channels, these
messages can be sent/received simultaneously with the voice/data/fax service over a
GSM network. SMS supports roaming. This means that you can send short messages
to any other GSM mobile user around the world. With the PCS networks based on all
the three technologies, GSM, CDMA and TDMA supporting SMS, SMS is more or
less a universal mobile data service.
3.9.1 HOW SMS WORKS
The SMC (Short Message Centre) is the entity which does the job of store and forward
of messages to and from mobile stations. The SME (Short Message Entity) which can
be located in the fixed network or a mobile station receives and sends short messages.
The SMS GWMSC (SMS gateway MSC) is a gateway MSC that can also receive
short messages. The gateway MSC is a mobile network’s point of contact with other
networks. On receiving the short message from the short message center, GMSC uses
the SS7 network to interrogate the current position of the mobile station from the HLR
( the home location register) subsystem.
HLR is the main database in users’ mobile network. It holds information of the
subscription profile of the mobile and also about the routing information for the
subscriber, i.e. the area (covered by MSC) where the mobile is currently situated. The
GMSC is thus able to pass on the message to the MSC.
MSC (Mobile Switching Center) is the entity in a GSM network which does the job of
switching connections between mobile stations or between mobile stations and the
fixed network.
26
A VLR (Visitor Location Register) corresponds to each MSC and contains temporary
information about the mobile, information like mobile identification and the cell (or a
group of cells) where the mobile is currently situated. Using information from the
VLR the MSC is able to switch the information (short message) to the corresponding
BSS (Base Station Subsystem, BSC + BTSs), which transmits the short message to the
mobile. The BSS consists of transceivers, which send and receive information over the
air interface, to and from the mobile station. This information is passed over the
signalling channels so the mobile can receive messages even if a voice or data call is
going on.
3.9.2 APPLICATIONS
i) SMS can be used by the network operators to provide services like balance enquiry
in case of prepaid cards using SMS.
ii) Mobile chatting is one more hot application of SMS
iii) SMS can be used to notify users that they have received new voice-mail or fax
messages.
iv) It provides an alternative to alphanumeric paging services
v) It can be used as an intruder alert system for security purpose.
3.9.3 BENEFITS OF USING GSM INTRUDER ALERT
i) It is faster when compared to wired systems and internet connection.
ii) It is cost-effective and cheap to install.
27
CHAPTER FOUR
DATA COLLECTION
Introduction
This chapter describes the data collected from various places and data collected
specifically for the blocks that make up the proposed system. The data have been
collected by considering their advantages, characteristics, performances, cost related
and also the availability of the particular devices.
4.1 Programmable Interface Controller (PIC)
There are several factors to consider in the choice of an appropriate PIC to use for a
certain operation. The following are some few important factors that will considered
when choosing the PIC for this project.
The most common consideration is how many digital inputs, analogue inputs and
outputs does the system require. This specifies the minimum number of I/O the
microcontroller must have.
The next consideration is the size of the program memory we need. This is very
important feature as one would find discarding a microcontroller for the reason that it
does not suite the capacity required. Clock frequency, this determines the speed at
which the instructions are executed
Table 4.1.1: PIC data sheet [7]
28
4.2 Switching Relay
Relay is an electromechanical device that permits the opening and closing of electrical
contacts by mean of an electromagnetic structure similar to a moving iron transducer.
29
Product Program memory EEPROM
data memory
RAM
( bytes)
I/O Ports Max speed
(MHz /Sec)Bytes Words
PIC16F83 896 512 64 36 13 10
PIC16F84 1792 1024 64 68 13 10
PIC16F872 3584 2048 64 128 22 20
PIC16F873 7168 4096 128 192 22 20
PIC16F874 7168 4096 128 192 33 20
PIC16F876 14336 8192 256 368 22 20
PIC16F877 14336 496 256 368 33 20
That is, when current flows through the coil, it generates a field in magnetic structure
(energize relay windings), and by doing so the resulting force draws the movable part
towards the fixed part. It attracts the soft iron armature and hence causing an electric
contact to be made. The device operates in switching high voltage loads, whereby its
output is connected to the power supply.
Table 4.2.1 : Parameter of Relay
Parameter Value
Coil Energizing Voltage 6V or 12V
No. of Poles Dipole
Voltage controlled 220V
Max Load Current 15A
3.9.4 Table 4.2.2: Voltage Requirements For PIC and Switching Cir-
cuit
Component Voltage Requirement
PIC16F877A +5V
Switching Circuit +12
30
4.3 GSM Modem
A GSM Modem (modulator-demodulator) is a device that modulates an analog
carrier signal to encode digital information, and also demodulates such a carrier
signal to decode the transmitted information. The goal is to produce a signal that can
be transmitted easily and decoded to reproduce the original digital data .The
Specifications of GSM Modem includes;
i) HSPA/UMTS 900/2100
ii) GSM/GPRS/EDGE 850/900/1800/1900MHz
iii) Support 2Mbps (5.76Mbps ready) HSUPA and 7.2Mbps HSDPA services
iv) Receive diversity (UMTS 2100/1900/850MHz)
v) Support SMS Service
vi) Plug and play
31
Figure 4.3.1: GSM Modem (Top view)[6]
Figure 4.3.1: GSM Modem (bottom view)[6]
Table4.4: Technical Specification of GSM MODEM.
32
Table 4.4: The Daily Use of Home Appliances
Equipments Qty Watts
Security lights(Energy Saver) 3 120W
Toilets lights(2ft) 4 18W
Bedroom light(4ft) 8 40W
Kitchen lights(4ft) 2 40W
Garage lights(Energy Saver) 1 120W
Air conditioner (Samsung) 4 0.5Horse Power
33
Parameter E 1762 Features
Network 2G Network GSM 900, GSM 1800,
GSM 1900
2G Network GSM
900/1800
Serial Interface Serial UART, USB Serial UART
Phone book records 50 by 14 records 99
SMS Support Yes Yes
CHAPTER FIVE
DATA ANALYSIS AND DESIGNING
2 Data Analysis. Regarding to the data that was collected and presented in chapter four , chapter five
will now provide the analysis of the collected data and further used in the design to
come up with the suitable values of components, integrated circuits, together with
power supplies for the proposed system. Also this chapter is going to talk about major
components selection, data analysis and design.
34
5.1 Power SupplyThe supply is 240Vac that is transformed into the 12Vac before it is rectified through
Diode Bridge to get a full-wave rectified of 12Vdc. The power supply is intended to
supply 5Vdc for Vcc supply to a PIC, LCD and MAX232 and 12V for GSM Modem.
Design of the input C1 that plays a big role in filtering is selected to provide a very
low resistance to the ripple frequency. The remaining ripples are filtered by
combination of voltage regulator.
5.1.1 TransformerTransformer steps down Ac voltage to Dc voltage from 220 -240VAC to 12VAC.
Turns ratio (n) is given by:
I1N1 = I2N2…………………………………………………………………………………………..……….(1)
I1/I2 = V2/V1= N2/ N1…………………………………………………..……………………………. (2)
Thus, V2/V1 = 12/240 = 0.05 ….................................................................................. (3)
5.1.2 Bridge Rectifier
Let Vp (out) be Rectifier output, Vp (sec) be Transformer secondary voltage
VP (sec) = 1.414Vrms *12 ~16.96Vac ……………………………………………………………………….. (5)
Vp (out) = Vp (sec) – 1.4V = 16.96 – 1.4 = 15.55Vp………………………………………………...... (6)
PIV for each diode = Vp (out) + 0.7V = 16.25V…………………………………… (7)
5.1.3 Filter
Unfiltered dc (Vp rect),
Vp(rect) = Vp (sec) – 1.4V = 15.55 – 1.4V = 14.15V………………………………….
(8)
Taking ripple factor of 3.97%, then capacitor will be
C = 1/(4fyR * √3) = 20uF, where y= 0.0397, f = 50Hz and R = 3.6K.
35
Pure dc (filtered dc) can be calculated using the formula,
Vdc = (1- (1/2fRC)) * Vp (rect)
Frequency for full wave rectified is 100Hz, let capacitor be 20μF, Rl be 3.6kΩ
Vdc = (1-(1/100Hz * 3.6K * 20uF)) * 14.15V = 12.18V
With this voltage, regulator LM7805 will be used whereby output of LM7805 will be
used to power the micro controller, LCD as well as MAX 232. Here under is the
connection of the power supply.[3]
TR1
230/12V
C120uF
VI1
VO3
GND
2
U17805
VI3
VO1
GND
2
U278L12
V1230VA=230FREQ=50
+88.8
Volts
+88.8
Volts
D11N4007
D21N4007
D31N4007
D41N4007
Figure 5-1 Power supply
5.2 Programmable Interface Controller (P.I.C)
P.I.C used in this project is PIC16F877A, this is an 8-bit processors that runs up to
20MHz with external crystal
This powerful (200 nanosecond instruction execution) yet easy-to-program (only 35
single word instructions) CMOS FLASH-based 8-bit microcontroller packs
Microchip's powerful PIC® architecture into an 40- or 44-pin package and is upwards
compatible with the PIC16C5X, PIC12CXXX and PIC16C7X devices.
5.2.1 The PIC16F877A has the following features
i) capture/compare/PWM functions,
36
ii) 256 bytes of EEPROM data memory, 8 channels of 10-bit Analog-to-Digital (A/D)
converter, 0 An ICD, 2 Comparators,
iv) Self-programming,
v) The synchronous serial port can be configured as either 3-wire Serial Peripheral
Interface (SPI™) or the 2-wire Inter-Integrated Circuit (I²C™) bus and a Universal
Asynchronous Receiver Transmitter (USART).
All of these features make it ideal for more advanced level A/D applications in
automotive, industrial, appliances and consumer applications.
5.2.2 Advantages of PIC16F877A
It has more I/O, program memory, data memory, and EEPROM data memory than the other PIC16F8XX family.
It has large number of pins availability, also with an internal module supporting UART interfaces for interfacing with peripherals.
The maximum supply voltage is +5V, and minimum is +2V.
37
RA0/AN02
RA1/AN13
RA2/AN2/VREF-/CVREF4
RA4/T0CKI/C1OUT6
RA5/AN4/SS/C2OUT7
RE0/AN5/RD8
RE1/AN6/WR9
RE2/AN7/CS10
OSC1/CLKIN13
OSC2/CLKOUT14
RC1/T1OSI/CCP2 16
RC2/CCP1 17
RC3/SCK/SCL 18
RD0/PSP0 19
RD1/PSP1 20
RB7/PGD 40RB6/PGC 39
RB5 38RB4 37
RB3/PGM 36RB2 35RB1 34
RB0/INT 33
RD7/PSP7 30RD6/PSP6 29RD5/PSP5 28RD4/PSP4 27RD3/PSP3 22RD2/PSP2 21
RC7/RX/DT 26RC6/TX/CK 25RC5/SDO 24
RC4/SDI/SDA 23
RA3/AN3/VREF+5
RC0/T1OSO/T1CKI 15
MCLR/Vpp/THV1
U1
PIC16F877A
Figure5-2: Pin arrangement of PIC16F877A
Figure5-3: Side View of PIC 16F877A
38
5.3 Relay Switching Circuit Analysis.
The relay switch selected according to the data collected is the normally open switch. This means that it will be open all the time but will close when the PIC commands it to do so.
Its features
i) Is suitable for the ac and dc
ii) Provide real separation when the contact is open
iii) Can withstand large currents and serve voltage transients.
iv) It is subjected to mechanical failure and contact erosion.
The circuit consists of the relay switch, the diode, the transistor and the bias resistor
(Rb).
The circuit is connected in such a way that the output of the circuit will trigger the
load to the condition when required.
D1DIODE
NPNBC140
RL1PCJ-105D3MH
RB
12v
(COM)
39
Figure 5-4: Schematic Diagram of the Relay Switching Circuit
Table 5-2: Specification of BC 140 NPN
TYPE Vmax Imax Pmax Hfe(β)Si NPN 12V 1Ǻ 3.7W 100-160
The dc resistance of the relay is 200 ohms and its related voltage is 12V.
Then from the above equation (Ia),
Using NPN transistor BC140, from the data sheet as shown in appendix 1, Gain
.
Then taking collector transistor current,
Then;
The
40
Then from the above equation (Ib),
The base resistor
Then the standard value of will be 4.7k Ω
D1DIODE
NPNBC140
RL1PCJ-105D3MH
4.7K
12v
(COM)
Figure 5-2: A Schematic Diagram of Relay Circuit
Table 5-3: Specification of BC 140 NPN
TYPE Vmax Imax Pmax Hfe(β)Si NPN
12V 1Ǻ 3.7W 100-160
41
The dc resistance of the relay is 200 ohms and its related voltage is 12V.
Then from the above equation (Ia),
Using NPN transistor BC140, from the data sheet as shown in appendix 2, Gain
.
Then taking collector transistor current,
Then;
The
Then from the above equation (Ib),
The base resistor
42
Then the standard value of will be 4.7k Ω
D1DIODE
NPNBC140
RL1PCJ-105D3MH
4.7K
12v
(COM)
Figure 5-9: A Schematic Diagram of Relay Circuit
43
5.4 The complete circuit diagram
The system was designed and tested using Proteus 7.8 professional circuit design and
simulation package and the PIC16F8772A microcontroller was programmed in
assembly language using the MikroC Pro for PIC multilanguage Compiler as
showed in the circuit below:
RA0/AN02
RA1/AN13
RA2/AN2/VREF-/CVREF4
RA4/T0CKI/C1OUT6
RA5/AN4/SS/C2OUT7
RE0/AN5/RD8
RE1/AN6/WR9
RE2/AN7/CS10
OSC1/CLKIN13
OSC2/CLKOUT14
RC1/T1OSI/CCP2 16
RC2/CCP1 17
RC3/SCK/SCL 18
RD0/PSP0 19
RD1/PSP1 20
RB7/PGD 40RB6/PGC 39
RB5 38RB4 37
RB3/PGM 36RB2 35RB1 34
RB0/INT 33
RD7/PSP7 30RD6/PSP6 29RD5/PSP5 28RD4/PSP4 27RD3/PSP3 22RD2/PSP2 21
RC7/RX/DT 26RC6/TX/CK 25RC5/SDO 24
RC4/SDI/SDA 23
RA3/AN3/VREF+5
RC0/T1OSO/T1CKI 15
MCLR/Vpp/THV1
U1
PIC16F877A
X1CRYSTAL
C1
22pF
C2
22pF
R1(1)
D7
14D6
13D5
12D4
11D3
10D2
9D1
8D0
7
E6
RW
5RS
4
VSS
1
VDD
2
VEE
3
LCD1LM044L
LCD1(VDD)
1B1 1C 16
2B2 2C 15
3B3 3C 14
4B4 4C 13
5B5 5C 12
6B6 6C 11
7B7 7C 10
COM 9
U2
ULN2003A
RL112V
RL212V
RL312V
RL412V
RL512V
RL5(C2)
RL5(NO)
L2
12V
L3
12V
L4
12V
BUZ1BUZZER
R110k
ERROR
TXD
3
RXD
2
CTS
8
RTS
7
DSR
6
DTR
4
DCD
1
RI
9
P1COMPIM
RXD
RTS
TXD
CTS
R310k
(1)
L1
12V
I1INFRED
I2INFRED
I3INFRED
I4INFRED
security system
Home Automation
RESET
GSM MODEM
. Figure5-4: Complete Circuit diagram for Home automation and Security system.
44
5.5 Software designing
Before designing the software, the designing environments were considered such as
making a flow chart for the program development and writing codes for program-
ming the microcontroller. The system operates as per the algorithm shown in figure
5-7. The microcontroller is powered to initializes the AT Modem it continuously
checks the Modem for any new message. Upon receipt of a message the microcon-
troller reads the message and extracts the command and authentication information.
After the initialization is complete the microcontroller a message for AT modem
stating the Status of the appliance. The system software is developed using C pro-
gramming language in the compiler mikro c for PIC Microcontrollers.
The software is an essential part for the functionality of the designed circuit as far as
this project is concerned. It has the following main tasks:
1) To control the input signal from the GSM modem.
2) To allow user to input data (commands for SMS) through the inputs of the mi-
crocontroller.
3) To enable user to check their status of the home appliances.
5.6 Coding
During the coding process, the program is divided into function (subroutine) accord-
ing to the task which was to be accomplished. This could make the code reuse and
hence make the program so robust and executes very fast. On the other hand during
coding, the source code is documented for further/future revision and updates. After
writing the source codes, it will be compiled and debugged to remove errors which
may occur.
45
46
Figure5-5: The Flowchart of the System.
CHAPTER SIX
RESULTS AND DISCUSSION
3 Introduction This chapter explains on how the simulation has been done, simulation results are also attached, and implementation of the prototype. The circuit simulations for this project were carried in Proteus 7.8Version.
6.1 Regulated Power supply The simulation of the power supply to the PIC 16F877A showing 5V output required by the microcontroller and display.
Figure 6-10: The AC output waveforms at the secondary terminal of transformer.
47
TR1
230/12V
C120uF
VI1 VO 3
GND
2
U17805
VI3 VO 1
GND
2
U278L12
V1230VA=230FREQ=50
Volts
+5.02
Volts
+12.0D11N4007
D21N4007
D31N4007
D41N4007
Figure6-2: Simulation results of Power supply
6.2 Relay Circuit Simulation:
Figure6-3: Relay Circuit Simulation
48
Q1BC140
RL1G2R-14-AC120
B112V
R1
4.7k
B212V
B312V
Volts
+12.0
6.3.0 Complete Circuit Diagram Simulation
Figure6-4: Complete Circuit Diagram Simulation when the system is ON
49
6.3.1 Simulation of the Complete Circuit Diagram when Security System is ON
Figure6-5:Simulation when Security System is ON
6.3.2 Simulation of the Complete Circuit when Home Appliences is ON
Figure6-5:Simulation when all appliances is ON
50
CHAPTER SEVEN
CONCLUSION AND RECOMMENDATIONS
7.0 SUMMARY:
The aim of this project is to develop a Home Automation and Security System for
home and office security. The project has been designed to function using GSM
technology to remotely switch any home appliance on or off and to alert the legal
owner of the house of any security intrusion while sounding an alarm locally to alert
people around and to also scare the intruder away.
The title "Interactive SMS-based remote controlled Home Automation and Security
System” has been chosen to describe the features of the system.
All the components required to implement the designed system were sourced for and
successfully put together to produce a working system that corresponds to the laid
out design.
7.1 ACHIEVEMENT
While the technologies involved in designing and implementing this project are not
new inventions, the innovation in this project is unique. It combines the already
existing GSM technologies and the alarm systems and produces home automation
and security alert system that performs its intended functions. It also allows
flexibility in the strings of commands used to control the system. The following
achievements were recorded in the course of the project:
i ) I have been able to build easy remote access to basic home/office appliances.
ii) I have been able to provide a process of real-time device/appliance control.
iii) I have been able to provide a real-time alert system making legal owners of
properties the increasingly aware of the security of his property.
iv) I have been able to provide a system that increases the rate of response to crime.
51
7.2 CHALLENGES
In the design and implementation of the system, there were several challenges faced.
The basic of which are listed below:
i) Challenges in corning up with a logical structure for the system that could be
easily implemented.
ii) Challenges in designing a system that meets the requirements using already
existing technologies that are cost effective.
iii) Challenges i was faced in balancing cost and functionality.
iv) Another challenge was that some of the components like GSM modem was not
found in my country so i exported from China.
v) Challenges on how to interfacing GSM modem and PIC
7.3 RECOMMENDATIONS
This project is very practicable and can be marketed for home usage, office usage,
and so on, to provide a means of saving cost of energy consumption and also to
make life easy.
This project can be further modified by any student from any department. The
Security section of the system focused on sending SMS to the legal owner when an
intruder is detected. In the future, more features can be activated using MMS
(Multimedia Message Service) where the picture of the intruder is sent immediately
to the owner for faster investigation.
This project can also be marketed to telecommunication device manufacturers.
Finishing this project tested my skills as engineering student and increased my
knowledge and experience in my chosen fields.
52
7. CONCLUSION
The project is relevant to homes and offices especially with the ease of control of
appliances and security. Also it is an inexpensive solution that can be easily
implemented.
53
References
BOOKS:
[1] Amos S W & James MR (1999). Principles of Transistor Circuits. Butterworth- Heinemann,page (23-35).
[2] A. C. Nunes and J. C. M. Delgado, “An Internet application for home automation,” Electrotechnical Conference, 2000. MELECON 10th Mediterranean, Vol. 1, pp. 298 -301, 2000. [3] Theraja B.L and Theraja AK, Electrical technology, 2002 S.Chad & Company Ltd India,page (430-490).
[4] Thomas W, Electronic Communication Systems, Fundamental through Advance,Fifth Edition, Pearson Education Inc,page (50-55)
WEBSITE: [5] www.ss7-training.net/ gsm network Architecture 5/7/2013
[6] www.sunron.com/gsm modem ,30/4/2013
[7] www.freedatasheets.com/datasheet-search/pic,13/03/2013
54
APPENDIX
APPENDIX A: Cost Estimation
No. Items Qty Price(Tsh) per each
Total Cost(Tsh)
1 Resistor 8 400/= 3,200/=
2 Capacitor 2 400/= 800/=
3 Regulator 2 2,500/= 5,000/=
4 Transformer 1 8,000/= 8,000/=
5 Bridge Rectifier 1 2,500/= 2,500/=
7 Printed circuit board 1 10,000/= 10,000/=
8 Relay 4 2,500/= 10,000/=
9 PIC 1 30,000/= 30,000/=
10 MODEM 1 150,000/= 150,000/=
11 Diode 2 200/= 400/=
12 Crystal Oscillator 1 5000/= 4500/=
13 Display(2by16) 1 30,000/= 30,000/=
14 Transistor 4 2500/= 10,000/=
15 Stationary 5 8,000/= 40,000/=
Total Cost
225,000/=
55
Appendix B Gantt chart for project scheduleTable B1 Senior Project I
ACTIVITIES DURATION OF PROJECT IN WEEKS
1 2 3 4 5 6 7 8 9 10 11 12 13 14 16
A
B
C
D
E
KEY:
A. Selection of project title
B. Title defending
C. Problem statement, methodology and literature review
D. Data collection
E. Proof reading and submission of project proposal for marking.
56
Table B2 Senior project II
ACTIVITIES DURATION OF PROJECT IN WEEKS
1 2 3 4 5 6 7 8 9 10 11 12 13 14 16
A
B
C
D
E
KEY:
A. Data analysisB. Design the circuit and simulation of the design circuitC. Building of circuit and testing of prototypeD. Project report writing
57
APPENDIX C
58
APPENDIX: D
APPENDIX :D
* Project name: Home Appliances and security System Using Mobile Phone. * PIC: PIC16F877A
59
* Developed By:Erick Mataba sbit device0 at RD0_bit;
sbit device1 at RD1_bit;
sbit device2 at RD2_bit;
sbit device3 at RD3_bit;
sbit buzzer at RD4_bit;
sbit sensor at RC0_bit;
// LCD module connections
sbit LCD_RS at RB2_bit;
sbit LCD_EN at RB3_bit;
sbit LCD_D4 at RB4_bit;
sbit LCD_D5 at RB5_bit;
sbit LCD_D6 at RB6_bit;
sbit LCD_D7 at RB7_bit;
sbit LCD_RS_Direction at TRISB2_bit;
sbit LCD_EN_Direction at TRISB3_bit;
sbit LCD_D4_Direction at TRISB4_bit;
sbit LCD_D5_Direction at TRISB5_bit;
sbit LCD_D6_Direction at TRISB6_bit;
sbit LCD_D7_Direction at TRISB7_bit;
// End LCD module connections
unsigned char beeps = 0;
char txt[20];
//*****
//multitasking system – handle multiple tasks with one microprocessor
60
//task counters used to tell when a task is ready to be executed
//all these counters are incremented every time a 500us interrupt happens
//every task has its own counter that is updated every time a 500us interrupt happens
unsigned int task0_counter=0;
unsigned int task1_counter=0;
unsigned int task2_counter=0;
//this tells when a task is going to happen again
//for example, when task0_counter==TASK0_COUNTER_MAX, set
task0_counter=0 and do task
#define TASK0_COUNTER_MAX 1 //high frequency task – every 500us, maybe PWM#define TASK1_COUNTER_MAX 1000 //low frequency task – every 500ms#define TASK2_COUNTER_MAX 5000 //low frequency and low priority task, every 2500ms
//Note: every variable referenced in both interrupt and main() must be declared volatile. You have been warned!//this enables/disables a taskvolatile unsigned char task0_enable=1;volatile unsigned char task1_enable=1;volatile unsigned char task2_enable=1;
//this allows tasks triggered by interrupt to run in the background in main()volatile unsigned char task2_go=0;
void beepBuzzer();
void checkText (unsigned char * txt) if(strncmp("1 on",txt, 4)== 0) device0 = 1; else if(strcmp("2 ON",txt)== 0) device1 = 1; else if(strcmp("3 ON",txt)== 0) device2 = 1; else if(strcmp("4 ON",txt)== 0) device3 = 1; else if(strcmp("1 OFF",txt)== 0) device0 = 0; else if(strcmp("2 OFF",txt)== 0) device1 = 0;
61
else if(strcmp("3 OFF",txt)== 0) device2 = 0; else if(strcmp("4 OFF",txt)== 0) device3 = 0;
void setup_multitasking(void) //set up tmr1 to interrupt every 500us TMR1CS_bit=0; T1CKPS0_bit=0; T1CKPS1_bit=0;
/*We want to wait 2000 clock cycles, or 500us @ 8MHz (instructions are 1/4 speed of clock). Timer 1 interrupts when it gets to 0xFFFF or 65535. Therefore, we set timer 1 to 65535 minus 2000 = 63535, then wait 1000 ticks until rollover at 65535. To test, use simulator to find that its exactly correct*/
#define TICKS_BETWEEN_INTERRUPTS 1000 #define INTERRUPT_OVERHEAD 19 #define TMR1RESET (0xFFFF-(TICKS_BETWEEN_INTERRUPTS-INTERRUPT_OVERHEAD)) #define TMR1RESET_HIGH TMR1RESET >> 8 #define TMR1RESET_LOW TMR1RESET & 0xFF TMR1ON_bit=0; TMR1H=TMR1RESET_HIGH; TMR1L=TMR1RESET_LOW; TMR1ON_bit=1; TMR1IF_bit=0; TMR1IE_bit=1; PEIE_bit=1; GIE_bit=1;
void interrupt (void) //one tick every 500us at 16Mhz if (TMR1IF_bit) //set up timer 1 again to interrupt 500us in future TMR1IF_bit=0; TMR1ON_bit=0; TMR1H=TMR1RESET_HIGH; TMR1L=TMR1RESET_LOW; TMR1ON_bit=1;
62
task0_counter++; if (task0_counter>=TASK0_COUNTER_MAX) //high frequency task – every 1 tick task0_counter=0; if (task0_enable==1) //do high frequency important task 0, for example PWM task1_counter++; if (task1_counter>=TASK1_COUNTER_MAX) //low priority task - every 1000 ticks task1_counter=0; if (task1_enable==1) //do low frequency yet important task 1 beepBuzzer();
/*this task takes a long time, 100ms for example, lots of maths. Is extremely low priority, but has to be done at regular intervals, so all this does is trigger it. In main(), it will, at leisure, poll ‘task2_go’ and then execute it in the background.*/
task2_counter++; if (task2_counter>=TASK2_COUNTER_MAX) //every 250ms task2_counter=0; if (task2_enable==1) //every 250ms take 100ms to do maths, do this in main() so the we can get back to doing the high frequency tasks. task2_go=1; //if (TMR1IF) //interrupt routine
void beepBuzzer() if(beeps > 0) buzzer = ~buzzer; beeps--;
63
/*if(beeps == 0) Lcd_Cmd(_LCD_CLEAR); LCD_OUT(1,1,"HOME AUTOMATION") ; */
void sendTxt(char * message) UART1_Write_Text("AT+CMGF=1"); //select text mode for sms UART1_Write(0x0D); //<CR> mean Enter UART1_Write_Text("AT+CMGS="); Delay_ms(100); UART1_Write(0x22); //" double qoute Delay_ms(200); UART1_Write_Text("0714672893"); // Your Telephone Number Delay_ms(200); UART1_Write(0x22); //" double qoute UART1_Write(0x0D); //<CR> mean Enter Delay_ms(200); UART1_Write_Text(message); //Message sent to the user UART1_Write(0x0D); //<CR> mean Enter Delay_ms(200); UART1_Write(26); //Ctr +Z Delay_ms(200); UART1_Write(0x0D); Delay_ms(100);
void main() TrisD = 0x00; //Set PortD as output PortD = 0x00; //Initialize PortD to 0 TRISC.B0=1; //Set bit 0 of portC as input PORTC.B0=0; //Initialize bit 0 of portC to 0
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off LCD_OUT(1,1,"HOME AUTOMATION") ;
uart1_init(9600); // Initialize serial port delay_ms(100);
setup_multitasking();
while(1)
64
if(sensor = 1) while(sensor = 1) delay_ms(100); LCD_OUT(2,1,"INTRUDER ALERT!!") ; sendTxt("There is an intruder at home!!"); beeps = 20; //Edit to alter length of buzzer beeps
// If data is ready, read it: if(UART1_Data_Ready() == 1)
UART1_Read_Text(txt, ".", 10); /*Lcd_Cmd(_LCD_CLEAR); LCD_OUT(2,1,txt) ;*/ checkText(txt); txt[0] = 0;
65