Professional Documents
Culture Documents
A SPECIAL PROJECT
Presented to
The Electrical, Electronics and Computer Engineering Department
College of Engineering
MSU Iligan Institute of Technology
Iligan City
MELVIN P. LACIA
PRESCILA S. PALACIO
JAPHET R. REPOLLEDO
March 2013
ii
ABSTRACT
This special project entitled Mobile Web Application for Appliance and Lighting
System Control is designed to control the appliance and lighting system switches in such
a way that a client or user can remotely turn ON or turn OFF them with the access of a
mobile web.
The significance of such project points to two important things, convenience and
safety. With a smartphone or a tablet, one can control their appliances and lighting
switches with just the use of the mobile web. Thus, offering convenience to man. On the
other hand, it is undeniable that people forget to switch off their appliances and lights
when they leave home. This negligence may result to worst cases such as overheating and
then results to house fires. Once a person has an access of the mobile web and has an
application such as this project, one would be able to avoid such incident and safety is
redeemed.
This project offers a mobile web application which has a user-friendly interface.
The ON/OFF controls are arranged on a floor plan which could give the client idea on the
status of his whole electrical system so that he could give the actions with ease. On the
other hand, with the integration of the mobile web application and the prototype of the
control system the projects set-up is completed. The researchers conducted simulations
and system evaluations using different methods of turning ON/OFF the system. Result of
the tests verified its functionality. Thus, this mobile web application makes as an ideal
method of controlling the appliance and lighting system of a typical home which ensures
safety and convenience to the one who uses this project.
APPROVAL SHEET
This thesis attached hereto, entitled "MOBILE WEB APPLICATION FOR
APPLIANCE AND LIGHTING SYSTEM CONTROL", prepared and submitted by
MELVIN P. LACIA, PRESCILA S. PALACIO, and JAPHET R. REPOLLEDO in
partial fulfilment of the requirements for the degree of BACHELOR OF SCIENCE IN
ELECTRICAL ENGINEERING, is hereby recommended for approval,
ACKNOWLEDGEMENT
The researchers would like to thank first and foremost the most precious and
powerful, our God Almighty for His never ending love and presence in our daily lives.
We thank Him for always being there for us especially during the time when our special
project was still under development. We would never make it this far without Him.
We would also like to thank the following people responsible for the success of
this project:
To Engr. Marven E. Jabian, our thesis adviser, for his undying support and
never ending help that enlightened us during the course of this project.
To Ms. Gisela P. Po for letting us use her Samsung Galaxy that helped us
perform the tests of our project.
To Ms. Leah S. Paladen for lending us her camera which helped us demonstrate
the video documentation.
To e-Gizmo Mechatronix Central for their high-quality service in providing us
the electronic components we needed in developing our prototype.
To Google for giving us knowledge that allow us to search anything that could
help us in making our project.
To Youtube for giving us a demonstration using video tutorials that allowed us to
learn the things we didnt know.
To our friends and colleagues who helped in the success of this project.
To our family for the unending financial and moral support which did a great
deal on us.
The researchers,
TABLE OF CONTENTS
TITLE PAGE
ABSTRACT
ii
APPROVAL SHEET
iii
DEDICATION
iv
ACKNOWLEDGMENT
TABLE OF CONTENTS
vi
CHAPTER 1: INTRODUCTION
1.1
1.2
1.3
1.4
1.5
1.6
Definition of Terms
1.7
Theoretical Framework
1.7.1
General
1.7.2
Web Design
1.7.3
Firmware
12
1.7.4
Software
14
1.7.5
Hardware
14
19
2.1
19
2.2
19
2.3
20
on Embedded Server
2.4
21
21
Carrier
23
3.1
System Overview
23
3.2
Circuit Design
24
3.2.1 PIC16f877A
24
3.2.2 Relay
25
3.2.3 ULN2003A
25
26
26
27
Firmware Design
28
28
3.3
3.4
3.5
3.6
30
31
Web Design
32
33
34
35
35
36
37
Hardware Design
38
38
3.5.1.1 PIC16f877A
38
3.5.1.2 ULN2003A
38
3.5.1.3 Relay
39
39
40
40
41
41
41
42
42
43
43
44
46
4.1
Web Design
46
4.2
Prototype
47
4.3
System Evaluation
50
4.4
Electrical Plan
55
58
5.1 Conclusion
58
5.2 Recommendation
59
BIBLIOGRAPHY
60
APPENDICES
62
CURRICULUM VITAE
78
1
CHAPTER I
Introduction
2
a lot of people unintentionally left their homes with their appliances plugged in and lights
switched on.
3
appliances in our homes. Some people leave certain appliances plugged in at all times,
such as toaster ovens or refrigerators. Others include computers, monitors, gaming
consoles, TVs, VCR and DVD players. These appliances can overheat and cause fires
even when not in use. Unplugging appliances when not in use helps reduce the risk of
fire. But the common situation here is unintentionally leaving these appliances plugged in
and no one is left in their homes. One forgets that the appliances are left plugged in but
he/she, under some circumstances has no chance of going home right away to prevent a
possible cause of fire. As a solution to this problem, a remote method of controlling the
power supply of the outlets and lighting is needed. The design of a control system
controlled via mobile web can be made to answer to the existing problem. The
convenience of World Wide Web using smartphones or tablets will help to easily turn off
supply to the outlets and lighting system when not in use to avoid the risks of fire.
Moreover, this solution can be helpful in cutting down costs in electric bills.
4
4. This study is limited only to the ON/OFF action of the switches of the outlets and
lighting of a typical house.
5. The PC host must be on at all times where in case of a power interruption, the PC
host must be restarted to resume web control of the electrical system.
6. The study includes design implementation of control system to a real electrical
system of the prototype based on an electrical plan.
Mobile Web - refers to the use of Internet-connected applications, or browserbased access to the Internet from a mobile device - such as a smartphone or tablet
PC - connected to a wireless network.
World Wide Web (www) - a widely used information system on the Internet that
provides facilities for documents to be connected to other documents by hypertext
links, enabling the user to search for information by moving from one document
to another.
1.7.1 General
This portion explains the general theories used for this project namely mobile
web, PIC microcontroller, and serial communication.
6
1.7.1.1 Mobile Web
The Mobile Web refers to access to the world wide web, i.e. the use of browserbased Internet services, from a handheld mobile device, such as a smartphone, a feature
phone or a tablet computer, connected to a mobile network or other wireless network.
The shift to mobile Web access has been accelerating with the rise since 2007 of
larger multitouch smartphones, and of multitouch tablet computers since 2010. Both
platforms provide better Internet access, screens, and browser- or application-based user
Web experiences than previous generations of mobile devices have done.
Most instructions are single cycle execution (2 clock cycles, or 4 clock cycles in
8-bit models), with one delay cycle on branches and skips
One accumulator (W0), the use of which (as source operand) is implied (i.e. is not
encoded in the opcode)
All RAM locations function as registers as both source and/or destination of math
and other functions.
A small amount of addressable data space (32, 128, or 256 bytes, depending on
the family), extended through banking
The program counter is also mapped into the data space and writable (this is used
to implement indirect jumps).
There is no distinction between memory space and register space because the
RAM serves the job of both memory and registers, and the RAM is usually just referred
to as the register file or simply as the registers.
8
1.7.2 Web Design
This portion discusses the applications and software used in building the web
design of the project.
1.7.2.1 WAMP
WAMPs are packages of independently created programs installed on computers
that use a Microsoft Windows operating system.
WAMP is an acronym formed from the initials of the operating system Microsoft
Windows and the principal components of the package: Apache, MySQL and one of
PHP, Perl or Python. Apache is a web server. MySQL is an open-source database. PHP,
Perl and Python are scripting languages that can manipulate information held in a
database and generate web pages dynamically each time content is requested by a
browser. Other programs may also be included in a package, such as phpMyAdmin
which provides a graphical user interface for the MySQL database manager.
1.7.2.2 MySQL
MySQL is the world's most used open source relational database management
system (RDBMS) as of 2008 that runs as a server providing multi-user access to a
number of databases. The SQL phrase stands for Structured Query Language.
MySQL is a popular choice of database for use in web applications, and is a
central component of the widely used LAMP open source web application software stack
(and other 'AMP' stacks). LAMP is an acronym for "Linux, Apache, MySQL,
9
Perl/PHP/Python." Free-software-open source projects that require a full-featured
database management system often use MySQL.
10
1.7.2.4 PHP
PHP is an open source server-side scripting language designed for Web
development to produce dynamic Web pages. It is one of the first developed server-side
scripting languages to be embedded into an HTML source document rather than calling
an external file to process data. The code is interpreted by a Web server with a PHP
processor module which generates the resulting Web page.
Any PHP code in a requested file is executed by the PHP runtime, usually to
create dynamic web page content or dynamic images used on Web sites or elsewhere. It
can also be used for command-line scripting and client-side graphical user interface
(GUI) applications. PHP can be deployed on most Web servers, many operating systems
and platforms, and can be used with many relational database management systems
(RDBMS). Most web hosting providers support PHP for use by their clients. It is
available free of charge, and the PHP Group provides the complete source code for users
to build, customize and extend for their own use.
PHP acts primarily as a filter, taking input from a file or stream containing text
and/or PHP instructions and outputting another stream of data; most commonly the
output will be HTML. Since PHP 4, the PHP parser compiles input to produce bytecode
for processing by the Zend Engine, giving improved performance over its interpreter
predecessor.
Originally designed to create dynamic Web pages, PHP now focuses mainly on
server-side scripting, and it is similar to other server-side scripting languages that provide
dynamic content from a Web server to a client, such as Microsoft's ASP.NET, Sun
Microsystems' JavaServer Pages, and mod_perl.
11
The LAMP architecture has become popular in the Web industry as a way of
deploying Web applications. PHP is commonly used as the P in this bundle alongside
Linux, Apache and MySQL, although the P may also refer to Python, Perl, or some mix
of the three. Similar packages are also available for Windows and OS X, then called
WAMP and MAMP, with the first letter standing for the respective operating system.
Although both PHP and Apache are provided as part of the Mac OS X base install, users
of these packages seek a simpler installation mechanism that can be more easily kept up
to date.
1.7.2.5 JavaScript
JavaScript (JS) is an interpreted computer programming language. It was
originally implemented as part of web browsers so that client-side scripts may interact
with the user, control the browser, communicate asynchronously and alter the document
content that is displayed. It uses syntax influenced by the language C. The key design
principles within JavaScript are taken from the Self and Scheme programming languages.
It is a multi-paradigm language, supporting object-oriented, imperative, and functional
programming styles.
12
XHTML, but the language can also be applied to any kind of XML document, including
plain XML, SVG and XUL.
CSS is designed primarily to enable the separation of document content (written
in HTML or a similar markup language) from document presentation, including elements
such as the layout, colors, and fonts. This separation can improve content accessibility,
provide more flexibility and control in the specification of presentation characteristics,
enable multiple pages to share formatting, and reduce complexity and repetition in the
structural content (such as by allowing for tableless web design). CSS can also allow the
same markup page to be presented in different styles for different rendering methods,
such as on-screen, in print, by voice (when read out by a speech-based browser or screen
reader) and on Braille-based, tactile devices. It can also be used to allow the web page to
display differently depending on the screen size or device on which it is being viewed.
While the author of a document typically links that document to a CSS style sheet,
readers can use a different style sheet, perhaps one on their own computer, to override the
one the author has specified.
CSS specifies a priority scheme to determine which style rules apply if more than
one rule matches against a particular element. In this so-called cascade, priorities or
weights are calculated and assigned to rules, so that the results are predictable.
1.7.3 Firmware
This portion discusses the applications and software used for the design of the
firmware of the prototype.
13
1.7.3.1 mikroC PRO for PIC
The mikroC PRO for PIC is a powerful, feature-rich development tool for PIC
microcontrollers. It is designed to provide the programmer with the easiest possible
solution to developing applications for embedded systems, without compromising
performance or control.
PIC and C fit together well: PIC is the most popular 8-bit chip in the world, used in a
wide variety of applications, and C, prized for its efficiency, is the natural choice for
developing embedded systems. mikroC PRO for PIC provides a successful match
featuring highly advanced IDE, ANSI compliant compiler, broad set of hardware
libraries, comprehensive documentation, and plenty of ready-to-run examples.
14
micro-controller systems and thus to develop the software for them without access to a
physical prototype.
1.7.4 Software
This portion discusses the application used for the design of the software of the
system control.
1.7.4.1 MATLAB
MATLAB (matrix laboratory) is a numerical computing environment and fourthgeneration programming language. Developed by MathWorks, MATLAB allows matrix
manipulations, plotting of functions and data, implementation of algorithms, creation of
user interfaces, and interfacing with programs written in other languages, including C,
C++, Java, and Fortran.
Although MATLAB is intended primarily for numerical computing, an optional
toolbox uses the MuPAD symbolic engine, allowing access to symbolic computing
capabilities. An additional package, Simulink, adds graphical multi-domain simulation
and Model-Based Design for dynamic and embedded systems.
1.7.5 Hardware
This part discusses the components used in the design of the hardware of this
project.
15
1.7.5.1 PIC16f877A
PIC16f877A microcontroller is a powerful (200 nanosecond instruction
execution) yet easy-to-program (only 35 single word instructions) CMOS FLASH-based
8-bit microcontroller PIC16F877A. It packs Microchip's powerful PIC architecture into
an 40- or 44-pin package and is upwards compatible with the PIC16C5X, PIC12CXXX
and PIC16C7X devices. The PIC16F877A features 256 bytes of EEPROM data memory,
self programming, an ICD, 2 Comparators, 8 channels of 10-bit Analog-to-Digital (A/D)
converter, 2 capture/compare/PWM functions, the synchronous serial port can be
configured as either 3-wire Serial Peripheral Interface (SPI) or the 2-wire InterIntegrated Circuit (IC) bus and a Universal Asynchronous Receiver Transmitter
(USART). All of these features make the PIC16F877A ideal for more advanced level
A/D applications in automotive, industrial, appliances and consumer applications.
1.7.5.2 ULN2003A
The ULN2003A is a seven-channel NPN Darlington array used to interface logic
circuits (i.e., microcontroller) to high-voltage, high-current devices like lamps, relays,
and solenoids. It is capable of driving 500 mA into a single channel, up to 250 mA per
channel with four channels active, and up to 150 mA per channel with all seven channels
active. ULN2003A outputs use clamp diodes for transient suppression to protect lowpower microcontroller circuitry.
This versatile device is useful for driving a wide range of loads including
solenoids, relays, DC motors, LED displays filament lamps, thermal print-heads and high
16
power buffers. The ULN2003A is supplied in 16 pin plastic DIP packages with a copper
lead frame to reduce thermal resistance.
1.7.5.3 Relay
A relay is an electrically operated switch. Relays are used where it is necessary to
control a circuit by a low-power signal (with complete electrical isolation between
control and controlled circuits), or where several circuits must be controlled by one
signal.
A simple electromagnetic relay consists of a coil of wire wrapped around a soft
iron core, an iron yoke which provides a low reluctance path for magnetic flux, a
movable iron armature, and one or more sets of contacts. The armature is hinged to the
yoke and mechanically linked to one or more sets of moving contacts. It is held in place
by a spring so that when the relay is de-energized there is an air gap in the magnetic
circuit. In this condition, one of the two sets of contacts in the relay pictured is closed,
and the other set is open. Other relays may have more or fewer sets of contacts depending
on their function. The relay in the picture also has a wire connecting the armature to the
yoke. This ensures continuity of the circuit between the moving contacts on the armature,
and the circuit track on the printed circuit board (PCB) via the yoke, which is soldered to
the PCB.
When an electric current is passed through the coil it generates a magnetic field
that activates the armature and the consequent movement of the movable contact either
makes or breaks (depending upon construction) a connection with a fixed contact. If the
set of contacts was closed when the relay was de-energized, then the movement opens the
17
contacts and breaks the connection, and vice versa if the contacts were open. When the
current to the coil is switched off, the armature is returned by a force, approximately half
as strong as the magnetic force, to its relaxed position. Usually this force is provided by a
spring, but gravity is also used commonly in industrial motor starters. Most relays are
manufactured to operate quickly. In a low-voltage application this reduces noise; in a
high voltage or current application it reduces arcing.
When the coil is energized with direct current, a diode is often placed across the coil to
dissipate the energy from the collapsing magnetic field at deactivation, which would
otherwise generate a voltage spike dangerous to semiconductor circuit components. Some
automotive relays include a diode inside the relay case. Alternatively, a contact protection
network consisting of a capacitor and resistor in series (snubber circuit) may absorb the
surge. If the coil is designed to be energized with alternating current (AC), a small copper
"shading ring" can be crimped to the end of the solenoid, creating a small out-of-phase
current which increases the minimum pull on the armature during the AC cycle.
18
RS-232 standard, intended to interface with a modem or with a similar communication
device.
1.7.5.5 MAX232
MAX232 is a single supply voltage, RS-232 transceiver. MAX232 is compatible
with RS-232 standard, and consists of dual transceiver. Each receiver converts TIA/EIA232-E levels into 5V TTL/CMOS levels. Each driver converts TTL/COMS levels into
TIA/EIA-232-E levels. The MAX232 is characterized for operation from -40C to +85C
for all packages. MAX232 is purposed for application in high-performance information
processing systems and control devices of wide application.
CHAPTER II
2.2 Home Appliances Control Using GSM (Global System for Mobile)
The title of the project is Home appliances control using Global System for
Mobile communications (GSM). The main purpose of the project is to create a system
which uses GSM to control the home appliances such as lamp, fan, air condition and
many more. These devices are able to be controlled by a single cell phone that acts as the
transceiver module. This project can be operated by user while they are not at home by
using the mobile phone remotely. The device is able to control the ON/OFF switch of any
device, appliances status review of overall system and perform a safety and security
system. This system is reliable and highly accurate. GSM modem is the medium by
20
which the user can interact with the module. It is used to send and receive SMS based on
which appropriate actions taken by the user. PIC microcontroller performs as heart of
whole controlling system. Main function of PIC microcontroller is to initiate the attached
GSM module and make it ready to communicate with the home appliances by using
mobile phone. The software was written using MikroC Compilers. [2]
21
The system provides an ideal solution to the remote and busy home owners whose
presence is not necessary in order to control/monitor their household appliances. It also
demonstrates the reliable data transfer capability of the internet by providing such
practical application to simplify our lifestyle. [3]
2.4 Control Home Appliances via Internet (CoHAVI) Home Appliances Using
Microcontroller
Control Home Appliances Via Internet (CoHAVI) is one of a system that can
control home appliance such as air conditioner, rice cooker, heater and etc. using internet.
It is another method that is used in this project to create a smart home. User can activate
the home appliance whenever and wherever they are by using Internet on PCs or PDAs.
There are three stages to build this system that are Client Server, Radio Frequency and
Microcontroller. This project focuses on Microcontroller where its divided into two parts
with embedded for software Peripheral Interface Controller (PIC) and hardware (control
circuit). The programmed is developed by C++ programming language. C++ has a
moderate speed of performance and easy to debug. This embedded software will control
all the input and output data such as home appliances integrated with Radio Frequency
(RF) section. The achievement of this project will create a new way to implement smart
home. [4]
22
microcontroller. The computer acquires and transmits the data while the microcontroller
interprets the signal and executes whatever instruction imbedded in the signal. A set of
rules will be established for data transfer between the computer and microcontroller
(Z86). The systems capability is limited only in turning the appliances into it are on or
off state.
The system as centralized switch used to control home appliances. With this
system, one does not have to go to every corner of the house to check whether an
appliance is on or off. All he has to do is to go to his computer, check the status of any
appliance, and then send the appropriate instruction. [5]
CHAPTER III
Methodology
The general setup of the project shown above is composed of the client, local host
or web server, a PC host, the MCU-Relay System and the Electrical System. The
Electrical System is controlled by accessing Mobile Web. The end user sends a request to
the web-server either to turn ON or OFF a certain sub-breaker or an appliance. As the
web-server receives the request, it generates the specific action which is carried out by
24
the MCU-Relay System to the Electrical System. The web-server sends back the status to
the end-user by changing the corresponding effects to the appearance of the lighting or
outlets on the mobile phone. Internet provides the connectivity between the end-user
client and the Electrical System.
This project is a prototype of an actual electrical system design. In this paper, an
Electrical plan was designed to show how this project could be integrated into a real-life
set-up in an electrical system.
3.2.1 PIC16f877A
The microcontroller used in the project is PIC16f877A. It has 33 I/O pins and 5
I/O ports. This available number of pins made the project feasible because the circuit has
17 pins set as output. These pins belong to PORTB, PORTC and PORTD.
For this microcontroller to operate, some basic components were used to support
it. A 5V dc source is in series with a 10k ohm resistor which is connected to PIN 1 of the
microcontroller to pull up the Reset pin 16f877A to avoid sinking the reset pin with a
large amount of current. The oscillator used is 4MHz Crystal Oscillator clock input
source which connected across PIN 13 and PIN 14. The two 22pF capacitors used serve
25
as loading capacitor which stabilizes oscillation for a clearer clock signal with one
connected across PIN 13 and the ground and the other across PIN 14 and the ground. PIN
11 and PIN 32 are supplied with 5V and PIN 12 and PIN 31 are both connected to
ground.
3.2.2 Relay
In the circuit design, there were a total of 17 relays that were included. These
relays would operate a main switch; five sub-switches operating the 5 circuits of the
prototypes electrical system; and the rest are for each load of the five circuits.
One contact of the coil is connected to the ULN2003A and the other contact is
supplied by a DC power with a rating the same with the relays DC rating. This
connection allows a path for current to flow the moment when the port where the relay is
connected is set to a value of 1. When an electric current is passed through the coil it
generates a magnetic field that activates the armature and the consequent movement of
the movable contact either makes or breaks (depending upon construction) a connection
with a fixed contact. The COM, normally-open, and normally-close pins, on the other
hand are associated to the AC system.
3.2.3 ULN2003A
The relay driver is a ULN2003A which is a seven-channel NPN Darlington array
used to interface logic circuits (i.e., microcontroller) to high-voltage, high-current devices
like lamps, relays, and solenoids. The ULN2003A is capable of driving 500 mA into a
single channel, up to 250 mA per channel with four channels active, and up to 150 mA
26
per channel with all seven channels active. ULN2003A outputs use clamp diodes for
transient suppression to protect low-power microcontroller circuitry and the inputs are
pinned opposite the outputs to simplify board layout. The input pins of ULN2003A are
connected to the output ports of the PIC microcontroller and the output pins are
connected to the relays.
27
wire is connected to the normally-open contact of the relay. The continuity of these two
cut ends of the wire is determined by the switching mechanism of the relay.
28
3.3 Firmware Design
The firmware part of the study focuses mainly on the programming of the
microcontroller. The microcontroller of choice was the PIC16f877A. It was programmed
in mikroC PRO and coded using C programming language.
29
In the beginning of the program, the arithmetic type specifier was declared using
char with variable called uart_rd. Thus, the data being passed to the PIC are characters
such as the alphabet and other symbols (e.g. #, @, $). The main function is called void
main(). Under this function, three ports of the PIC were assigned as output namely
PORTB, PORTC and PORTD. In the next line, the code UART1_Init(9600) initializes
the hardware UART1 module and establishes the communication at 9600 bps. After that
is the code Delay_ms(100) which creates a software delay in duration of time_in_ms
milliseconds (a constant). The next line is a while loop for which the if statements are
under it and for which the switching values of the port are set to 1 or 0. The while loop is
while(1) which means that it has the condition to always evaluate to true, creating an
infinite loop. The first code under the while loop is an if statement with the expression
UART1_Data_Ready() to test if data in receive buffer is ready for reading. Under this if
statement, the variable uart_rd was assigned with UART1_Read(). The function
UART1_Read() receives a byte via UART. This is followed by a series of if statements
each having expression such as uart_rd == 'm' for example, that if it be true, the
corresponding ports will be turned on or off using values 1 or 0 respectively. This m is
the byte being received by the function UART1_Read(). The same went for the other if
statements with distinct values assigned for uart_rd using the alphabet and other symbols.
When the coding is finished, it is built and a HEX file is generated.
30
3.3.2 Virtual Terminal Simulation
With the circuit already established in Proteus and the HEX file loaded into the
PIC in Proteus, a simulation is carried out in Proteus to test and debug the firmware as
well as the circuit itself using a virtual terminal.
Virtual Terminal instrument is a virtual instrument in Proteus which simulates the
programmed PIC Microcontroller. It is in substitute with COM Port Physical interference
Model or COMPIM when no other software is run for the simulation except Proteus. Like
the COMPIM, the virtual terminal is wired to the PIC microcontroller through the TX
and RX terminals.
When the play button is clicked, the simulation starts and the virtual terminal
pops-up like a command window. By right-clicking on it, the Echo Typed Characters
must then be chosen so that input of characters (i.e. alphabet and symbols) can be
permitted. Each of the ports was assigned with one character distinct from the other.
When a certain character is inputted, the programmed PIC comes into action where the
statements of setting ports to 1 or 0 inside the if statement associated with that character,
is executed. When the port is turned on, the connected load turns on while it turns off
when the same port is turned off.
The significance of this step is to test the circuit design and to test the firmware
made in mikroC which is loaded into the PIC microcontroller. After this stage is
completed, the use of the COMPIM and the MATLAB controls can then be applied.
31
3.3.3 Loading the Program
The HEX file generated from building the program was used for the simulation of
the firmware design and for the actual loading into the microcontroller.
The application PICkit 2 v2.60.00 was used to load the HEX file into the
microcontroller. Upon completion of the loading, the PIC microcontroller carried its
firmware and was ready to be integrated into the MCU-Relay System.
32
3.4 Web Design
The initial step in the web design is the installation of the WAMP server and other
applications such as Notepad++ and Dreamweaver. The rest is the coding of the design as
discussed in the following sections.
33
3.4.1 Building the Web Design
The first step is to set up a new project in WAMP by opening the www directory
and creating a new folder which becomes the name of the project. The project is named
lapconsys. The main file of the web design is then created and was named index.php
In index.php, two pages were designed namely the log in page and the sign up
page. There were three categories in creating the page: header, content and footer. The
content in the log in page includes the input text of username and password, and the two
buttons for logging in and signing up. In the sign up page, its content includes the input
text of first name, last name, username, password, and re-type password. Two buttons
were put in the footer in this page, the create button and cancel button. The cancel button
leads the user to the previous page, and the create page leads the user to the CAPTCHA
page (human verification).
In captcha.php, the content has six numbers that will be sorted by the user. Two
buttons were put in the footer, the register button and the cancel button. The cancel
button leads the user to the previous page, and the register leads the user to the home
page if the numbers are arranged in increasing order. While if the numbers are not sorted
and the user clicks the register button, this prompts the user is not a human.
On the other hand, in home.php, its content includes three buttons, the system
profile, control system, and the contact us. When the user clicks the system profile, this
displays the brief summary of the system. In the contact us page, its content consist of
three image button of the three legendary ninja. Clicking the image of a ninja displays
the contact information such as the address, Facebook, email, and contact number. In the
control system page, its content includes the toggle switches and the zoom in buttons.
34
The toggle switches include the main breaker and the sub-breakers such as light breaker
1, light breaker 2, the outlet breaker 1, outlet breaker 2, and outlet breaker 3. The zoom
buttons include the bedroom 1 light, bedroom 2 light, living room light, toilet light,
kitchen light, dining light, bedroom 1 outlet, bedroom 2 outlet, living room outlet, toilet
outlet, kitchen outlet, and dining outlet. When turning on the main breaker, this enables
the five sub-breakers. When turned off, this becomes disabled. When the light breaker 1
is on, this enables the zoom in buttons of bedroom 1 light, bedroom 2 light, and the living
room light. Turning it off disables those zoom in buttons. When the light breaker 2 is on,
this enables the toilet light, kitchen light, and dining light and this will be disabled when
turned off. When the outlet breaker 1 is on, this enables the bedroom 1 and bedroom 2
outlets. Turning this off disables them. The living room outlet is under the control of
outlet breaker 2, and in the outlet breaker 3 has the control of kitchen and dining outlet.
Clicking the zoom in buttons leads the user to the page which correspond the button.
Each page has two toggle switches (this becomes the internal controls of the system), one
for light and one for outlet. Turning on the light switch changes the background of the
page which indicates that the light is turned on. Turning on the outlet changes the outlet
image that has a led indicator turn on.
35
toggleswitch table, this includes the six breakers (one main breaker and five subbreakers); eleven internal controls (six for lights and five for outlets). This table has the
name of the toggle switch and its value (on/off).
36
interface during offline usage. But the program that was created is the basis for the
controls in the Web since this MATLAB program was also connected to the Web design.
In the design of the GUI or the Graphical User Interface, the main components
used were buttons. These buttons serve as switch for turning on or turning off of the
loads switches. Each of these buttons generates a function in the source code with a
name according to the tag assigned to them. Under each button function, the codes were
comprised of three parts. First, the codes set the handles of some specific buttons or
objects to visible on or visible off. The purpose of this is to organize the appearance of
the design in coordination with the buttons function. Second, the codes set the handles of
some specific buttons or objects to enable on or enable off. The purpose of this is to
organize the controls where the relationship of buttons to other buttons can be defined
such that there is a main switch and some of the buttons belong to this main switch. For
example, the buttons of sub-switches belonging to the main switch are always disabled
unless the main switch is switched on. Lastly, the codes function is for the serial
communication which consists basically of the serial COM number, Baud rate, and the
specific byte or symbol assigned to the button to control the relay that is paired to this
button. This byte is the one being passed then received by the function UART1_Read() as
programmed in mikroC.
37
To enable connection of Proteus with MATLAB, the application Virtual Serial
Port Driver or VSPD is used. VSPD is an advanced utility which emulates unlimited
number of RS232 serial ports connected via virtual null-modem cable using special
driver. With VSPD, one can create any number of pure virtual serial ports in his system
connected into pairs via virtual null-modem cable without having real serial ports
occupied.
In the case of this simulation, two virtual serial ports were created, COM1 and
COM2 in a virtual pair so that they could be opened by MATLAB and Proteus. In
Proteus, the physical port of the COMPIM was set to COM2 with physical and virtual
baud rate both set to 9600. Meanwhile in the MATLAB code, all serial port objects
created were associated with the serial port specified by port COM1. Everything that the
MATLAB sends to COM1 will be received by Proteus at COM2.
38
3.5 Hardware Design
The hardware design is the physical implementation of the circuit design. This
hardware served as a prototype of the actual electrical system design.
3.5.1.1 PIC16f877A
Only one PIC16f877A was used in the hardware design. Its basic circuit includes
a 10k ohm resistor, two 22pF ceramic capacitors, and a 4MHz Crystal Oscillator. The
microcontroller is supplied by 5V DC source.
3.5.1.2 ULN2003A
Three ULN2003A were used in the hardware. One of the ICs is connected to
PORTB. This ULN2003A drives 6 relays switching the main relay and the other five
relay switches of the five circuits of the electrical system. This IC is supplied by 12V DC
source since the relays have coil side rating of 12V DC. The other two ICs were used for
the other relays wherein all the loads are connected. These two ICs are both supplied by
6V DC source since the relays connected have coil side rating of 6V DC.
39
3.5.1.3 Relay
There were a total of 17 relays used in the hardware design. These relays are all
SPDT relays or Single-Pole Double Throw relays each having 5 pins or contacts. For the
main relay, a 12V dc relay was used. Five 12V dc relays were also used each for the five
circuits of the system. For all the loads, they are operated by 6V dc relays.
The 12V dc relay used has an ampacity of 10A when connected to 240V AC
system. On the other hand, the 6V dc relay used has an ampacity of 5A when connected
to a 240V AC system. Relays with larger ratings were used for the main relay and the
sub-relays to observe safety in the electrical system.
40
41
42
circuits of the electrical system three of which are circuits for outlet and the remaining
two are circuits for lighting load.
Beside the house miniature, is where the MCU-Relay System is installed.
Moreover, a 15A two-pole circuit breaker at the terminals of the AC source to ensure
safety of the electrical system in cases of short circuits.
43
3.6.2 Deployment Diagram
44
To evaluate the system, different manners of switching the relays were used.
All methods start with turning on the main relay. One of these methods next
steps is to turn on one by one the branch circuit relays. Once all the five relays are turned
on, the relays of the loads at each branch circuit are turned on and the response of the
loads are to be observed whether they correspond to the action of the relay.
Another manner of turning on all the relays starts after turning the main relay step
is to turn on one main relay of a branch circuit and then all relays of the loads under that
branch circuit are to be switched on before proceeding to the next branch circuit and so
on.
Various methods of switching off all relays were also done. One test is to turn off
the relays of each load, and then the main relay of the branch circuit. Same method goes
with the other branch circuits before turning off the systems main relay. Another method
is to turn off all the relays at the same time by directly turning off the main relay of the
system.
The results were listed on a table for each method by putting remarks whether
action is OK or NOT OK.
45
system layout, power receptacle system layout, single-line diagram and panel load
schedule. The bases for the design of this electrical plan were the 2008 National
Electrical Code (NEC) and 2008 Philippine National Electrical Code (PEC). The
software AutoCAD by Autodesk, Inc. was used to draw the layout of the electrical
system. Please see Appendix A for the layouts.
There were lots of things that were considered in the integration of this projects
design into the electrical plan. In determining the rating of the relay to be chosen for the
main breaker, the rating of the breaker was used. Also, for the branch circuits of the
electrical system, their ratings were the basis of the relays ratings.
The number and ratings of the relays to be designed to the electrical plan were
also determined for the loads of each branch circuit. The number of light switches
controlling groups of lighting fixtures was used to determine the number of relays needed
for that circuit. The relays ampere rating was determined as per NEC 2008 210.20 or as
per PEC 2008 2.10.2.2. For the general receptacle branch circuit, the number relays was
determined with the number of rooms in the dwelling unit. Their ratings were determined
with the same sections in NEC or PEC used for the loads of lighting branch circuit. For
branch circuits carrying single loads such as in circuit 3 with a cooking range and circuits
4 and 5 each with an air-conditioning unit, no additional relays were chosen.
The new electrical system was then drawn in Proteus to establish the whole
system including the MCU-Relay system. Also, the single-line diagram was modified
into one with the integration of the relays to it.
CHAPTER IV
This chapter discusses the output of the project, the performance of the system
and the resulting design on the implementation of the project to an electrical plan.
47
Please see the appendix B for screenshots of the mobile web design.
4.2 Prototype
On the other hand, the prototype is established in a miniature of a 12.5 m by 9.5 m
dwelling unit. The major parts of this prototype are the microcontroller unit with the relay
system, power supplies, small lighting loads, electrical outlets and the AC supply with
one main circuit breaker.
On the other hand, the MCU-Relay System and the electrical outlets were
integrated in a box casing as shown below.
48
49
Lastly, the photo below shows the power supply of the project.
50
4.3 System Evaluation
The evaluation of the system was based on the results of testing the system. Six
methods were completed in testing the system. The tables below show the evaluation of
the system.
.
Table 4.1 Method 1 Turning ON the System
CIRCUIT 1
Light Breaker 1
ON
OK
CIRCUIT 2
Light Breaker 2
ON
OK
MAIN ON
OK
CIRCUIT 3
Outlet Breaker
1 ON
OK
Bedroom 1 ON
Toilet ON
Bedroom 1 ON
OK
OK
OK
CIRCUIT 4
Outlet Breaker
2 ON
OK
Living Room
ON
OK
Bedroom 2 ON
Kitchen ON
Bedroom 2 ON
OK
Living Room
ON
OK
OK
Dining Room
ON
OK
OK
OK
Dining Room
ON
OK
CIRCUIT 5
Outlet Breaker
3 ON
OK
Kitchen ON
The first method of turning ON the system starts with the Main Relay of the
system. This is followed by turning ON all the main relays of the five branch circuits one
by one. The last step is turning ON all the loads by turning all loads under each branch
circuits starting with Circuit 1 then proceeding to the next branch circuit and so on.
Remarks are indicated with OK as working while Not OK as not working.
51
Table 4.2 Method 2 Turning ON the System
MAIN ON
OK
CIRCUIT 1 Light
Breaker 1 ON
OK
CIRCUIT 2 Light
Breaker 2 ON
OK
CIRCUIT 3 Outlet
Breaker 1 ON
OK
CIRCUIT 4 Outlet
Breaker 2 ON
OK
CIRCUIT 5 Outlet
Breaker 3 ON
OK
Bedroom 1 ON
Bedroom 2 ON
Living Room ON
OK
OK
OK
Toilet ON
Kitchen ON
Dining Room ON
OK
OK
OK
Bedroom 1 ON
Bedroom 2 ON
OK
OK
Living Room ON
OK
Kitchen ON
Dining Room ON
OK
OK
The second method of turning ON the system starts with the Main Relay of the
system. This is followed by turning ON the main relay of a branch circuit (starting with
Circuit 1). The next step is to turn ON all the loads under that branch circuit one by one.
The following steps are for the other branch circuits (2nd to the 5th Circuit) with the same
order in Circuit 1. Remarks are indicated with OK as working while Not OK as
not working.
52
Table 4.3 Method 1 Turning OFF the System
Living Room
OFF
OK
Bedroom 2
OFF
OK
Bedroom 1
OFF
OK
CIRCUIT 1
Light Breaker 1
OFF
OK
Dining Room
OFF
OK
Living Room
OFF
OK
Dining Room
OFF
OK
Kitchen OFF
OK
Bedroom 2
OFF
OK
Bedroom 1
OFF
OK
OK
Toilet OFF
OK
CIRCUIT 2
Light Breaker 2
OFF
OK
CIRCUIT 3
Outlet Breaker
1 OFF
OK
MAIN OFF
OK
CIRCUIT 4
Outlet Breaker
2 OFF
OK
CIRCUIT 5
Outlet Breaker
3 OFF
OK
Kitchen OFF
The first method of turning off the system when the system is ON initially starts
with turning off all the loads of a circuit (starting with Circuit 1). The next step is to turn
OFF the main relay of that branch circuit. The same procedure follows for other circuits
(2nd to 5th). When all relays of the five branch circuits are already OFF, the Main Relay is
then turned OFF. Remarks are indicated with OK as working while Not OK as
not working.
53
Table 4.4 Method 2 Turning OFF the System
Living Room OFF
Bedroom 2 OFF
Bedroom 1 OFF
OK
OK
OK
Kitchen OFF
Toilet OFF
OK
OK
OK
Bedroom 2 OFF
Bedroom 1 OFF
OK
OK
OK
Kitchen OFF
OK
OK
CIRCUIT 1 Light
Breaker 1 OFF
OK
CIRCUIT 2 Light
Breaker 2 OFF
OK
CIRCUIT 3 Outlet
Breaker 1 OFF
OK
CIRCUIT 4 Outlet
Breaker 2 OFF
OK
CIRCUIT 5 Outlet
Breaker 3 OFF
OK
MAIN OFF
OK
The second method of turning OFF the system when the system is ON initially,
starts with turning off all the loads of a branch circuit (starting with loads under Circuit
1). The next steps are the same with the steps for Circuit 1 for the other circuits (2nd to 5th
Circuit). When all the loads are already turned off, the next step is to turn off the main
relays of all branch circuits. The last step is to turn off the Main Relay of the System.
Remarks are indicated with OK as working while Not OK as not working.
54
Table 4.5 Method 3 Turning OFF the System
CIRCUIT 1
Light
Breaker 1
OFF
OK
CIRCUIT 2
Light
Breaker 2
OFF
OK
CIRCUIT 3
Outlet
Breaker 1
OFF
OK
CIRCUIT 4
Outlet
Breaker 2
OFF
OK
CIRCUIT 5
Outlet
Breaker 3
OFF
OK
MAIN OFF
OK
The third method in turning OFF the system when the system is initially ON,
starts with turning off the main relay of a branch circuit (starting with Circuit 1). Then the
same procedure follows for the other branch circuits (2nd to 5th Circuit). The last step is to
turn off the Main Relay. Remarks are indicated with OK as working while Not OK
as not working.
The fourth method in turning OFF the system when the system is initially ON, has
only one step. It is to turn off the Main Relay of the system. Remarks are indicated with
OK as working while Not OK as not working.
55
4.4 Electrical Plan
The main concern of the design of the electrical system from an electrical plan is
the design of the relay ratings. The electrical systems single-line diagram plays a great
role in choosing what kind of relay is applicable to the system. The following lists the
relays that could be used for the system with specifications.
Table 4.7 Relay Specifications
COIL DATA
Circuit
MAIN
CIRCUIT 1
CIRCUIT 2
CIRCUIT 3
CIRCUIT 4
CIRCUIT 5
Rated
Voltage
12VDC
12VDC
12VDC
12VDC
12VDC
12VDC
Rated
Coil
Current Power
167mA 2000mW
75mA
900mW
75mA
900mW
75mA
900mW
75mA
900mW
75mA
900mW
CONTACT
DATA
Switch-Type
Rated Load
100A at 250VAC
15A at 240VAC
20A at 240VAC
30A at 240VAC
15A at 240VAC
15A at 240VAC
SPST/SPDT
SPST/SPDT
SPST/SPDT
SPST/SPDT
SPST/SPDT
SPST/SPDT
56
On the other hand, the relays designed for the loads of the branch circuits are
summarized in the table below.
Table 4.7 Relay Specifications
CONTACT
DATA
COIL DATA
Circuit
Load A
Downlights &
Ceiling Fan Living
Room (CIRCUIT 1)
Load B
Downlights
Bedroom 1,
Bedroom 2 &
Hallway (CIRCUIT
1)
Load C
Downlights Dining
Room, Kitchen &
Toilet (CIRCUIT 1)
Load D General
Purpose Receptacle
Outlets Living
Room (CIRCUIT 1)
Load E General
Purpose Receptacle
Outlets Bedroom 1
& 2 (CIRCUIT 2)
Load F General
Purpose Receptacle
Outlets Dining
Room & Kitchen
(CIRCUIT 2)
SwitchType
Rated
Voltage
Rated
Current
Coil
Power
Rated Load
12VDC
75mA
900mW
10A at 240VAC
SPST/SPDT
12VDC
75mA
900mW
10A at 240VAC
SPST/SPDT
12VDC
75mA
900mW
10A at 240VAC
SPST/SPDT
12VDC
75mA
900mW
10A at 240VAC
SPST/SPDT
12VDC
75mA
900mW
10A at 240VAC
SPST/SPDT
12VDC
75mA
900mW
10A at 240VAC
SPST/SPDT
No relays were designed for cooking range and air conditioning units because
each of these loads are connected to branch circuits which have relays designed already
57
to each of them. The supposedly additional relays were not made to consider economic
aspects.
The circuit design of the new system was drawn in Proteus. The design consists of
the microcontroller unit, the relay system and the virtual loads.
Figure 4.5 Schematic Diagram of the System from the Electrical Plan
Having completed the circuit design analysis, a modification on the single-line
diagram was made. The new single-line diagram shows the relays for the main breaker
and the other relays for each branch circuits.
CHAPTER V
5.1 Conclusion
This special project was completed basically through the integration of various
designs which is composed of circuit design, firmware design, web design, and hardware
design.
The whole system was verified through testing and debugging. Also with system
evaluation, the researchers were able to verify the functionality of the project.
On the other hand, the projects mobile web design shows a user-friendly
interface. The ON/OFF controls are arranged on a floor plan which could give the client
idea on the status of his whole electrical system so that he could give the actions with no
hassle. The client could even zoom to whatever room he/she likes and then be able
control the ON/OFF state of appliance and lighting in that particular room.
In addition, to study its feasibility in actual applications such as in a typical
dwelling unit, an electrical plan was made and the researchers were able to implement the
control system design into the electrical system of the said dwelling unit.
With its feasibility being verified, the researchers were able to conclude that the
special project is a helpful tool to provide convenience and to ensure safety of the
consumers from a home-related electricity problem they might experience.
59
5.2 Recommendation
The researchers suggest the following improvements:
1. Compress the mobile web design into a mobile application;
2. To include loads such as a dimmer that can also be controlled by the mobile web
design;
3. To put up the mobile web design to the internet;
4. To modify system having an embedded web server instead of a laptop/PC server;
and
5. To include a feedback mechanism in the control system for the user to verify the
current status of the system.
BIBLIOGRAPHY
Special Projects
[1] Abhishek Vichare, Shilpa Verma. Embedded Web Server for Home Appliances.
Thadomal Shahani Engineering, College, Mumbai, Mahrashtra, India, March
2012
[2] Liew Jia Qi. Home Appliances Control Using GSM (Global System for Mobile).
Universiti Teknikal Malaysia Melaka, April 2010
[3] Jouperse Cabaluna, Gerald Ermac, Nel John Gerodias III . Internet-based Home
Power Switch Controlling/Monitoring System on Embedded Server. College of
Engineering, Mindanao State University Iligan Institute of Technology, March
2010
[4] Nurul Husna Binti Ismail. Control Home Appliances via Internet (CoHAVI) Home
Appliances Using Microcontroller. Universiti Teknikal Malaysia Melaka, May
2007
61
Internet
APPENDICES
63
APPENDIX A
Electrical Plan:
(1) Legend
(2) Specifications
(3) Lighting System Layout
(4) Power Receptacle Layout
(5) Panel Load Schedule
(6) Single Line Diagram
(7) Modified Single Line Diagram
Ckt no.
1
2
3
4
5
6
Voltage:
Phase:
Load Description
3015W Recessed Downlight + 160W Fan with light
19180VA Duplex Convenience Outlet
18 kW Cooking Range
16A, 230V Room Air Conditioning Unit (BED 1)
16A, 230V Room Air Conditioning Unit (BED 2)
Spare
Wire:
VA
510
3420
6400
1380
1380
3000
Rating
V
I
230 1 2.22
230 1 14.87
230 1 27.83
230 1 6.00
230 1 6.00
230 1 13.04
Circuit Breaker
Type Pole AT
2
MCCB
15
2
MCCB
20
2
MCCB
30
MCCB
2
15
MCCB
2
15
MCCB
2
20
AF
100
100
100
100
100
100
Set
1
1
1
1
1
Service Wire
Cond/Set Size(mm2)
3.5
2
3.5
2
3.5
2
3.5
2
3.5
2
230V
1
2W + E
Enclosure: NEMA 1
Ground Wire
2
Type
Type
Size(mm )
THHN
3.5
THHN
THHN
THHN
3.5
THHN
THHN
5.5
THHN
THHN
3.5
THHN
THHN
3.5
Conduit
mm Type
PVC
20
PVC
20
PVC
20
PVC
20
20
PVC
71
APPENDIX B
MOBILE WEB DESIGN SCREENSHOTS
72
73
74
APPENDIX C
PROTOTYPE SCREENSHOTS
75
76
77
CURRICULUM VITAE
79
CURRICULUM VITAE
Name:
Melvin P. Lacia
Address:
Date of Birth:
Place of Birth:
Gender:
Male
Citizenship:
Filipino
Religion:
Roman Catholic
Civil Status:
Single
Contact Number:
(+63) 909-350-7936
Email Address:
melvin_lacia@yahoo.com
EMPLOYMENT HISTORY:
On-the-job Training:
EDUCATIONAL ATTAINMENT:
Elementary:
Secondary:
Jacinto P. Elpa National High School SSC Tandag, Surigao del Sur
March 2008
4th Honors
Tertiary:
ORGANIZATIONS:
2011 Present
(IIEE CSC)
80
CURRICULUM VITAE
Name:
Prescila S. Palacio
Address:
Date of Birth:
Place of Birth:
Gender:
Female
Citizenship:
Filipino
Religion:
Protestant
Civil Status:
Single
Contact Number:
(+63) 926-457-0029
Email Address:
palacioprescila@yahoo.com
EMPLOYMENT HISTORY:
On-the-job Training:
EDUCATIONAL ATTAINMENT:
Elementary:
Secondary:
Iligan City East High School Kiwalan Annex, Kiwalan, Iligan City
March 2006
1st Honors
Tertiary:
ORGANIZATIONS:
2011 Present
(IIEE CSC)
81
CURRICULUM VITAE
Name:
Japhet R. Repolledo
Address:
Date of Birth:
Place of Birth:
Gender:
Male
Citizenship:
Filipino
Religion:
Roman Catholic
Civil Status:
Single
Contact Number:
(+63) 906-657-8879
Email Address:
japhet.repolledo@gmail.com
EMPLOYMENT HISTORY:
On-the-job Training:
EDUCATIONAL ATTAINMENT:
Elementary:
Secondary:
Tertiary:
ORGANIZATIONS:
2011 Present
(IIEE CSC)