You are on page 1of 90

MOBILE WEB APPLICATION FOR APPLIANCE AND

LIGHTING SYSTEM CONTROL

A SPECIAL PROJECT

Presented to
The Electrical, Electronics and Computer Engineering Department
College of Engineering
MSU Iligan Institute of Technology
Iligan City

In Partial Fulfillment of the Requirements for the Degree of


BACHELOR OF SCIENCE IN ELECTRICAL ENGINEERING

MELVIN P. LACIA
PRESCILA S. PALACIO
JAPHET R. REPOLLEDO

ENGR. MARVEN E. JABIAN


Adviser

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,

ENGR. CARL JOHN O. SALAAN


Member
___________________
Date

ENGR. ARTURO D. BALLESTA


Member
___________________
Date

DR. NOEL R. ESTOPEREZ


Member
___________________
Date

ENGR. MARVEN E. JABIAN


Adviser
___________________
Date
This thesis is accepted and approved in partial fulfillment of the requirements for
the degree of Bachelor of Science in Electrical Engineering.

ENGR. OLGA JOY L. GERASTA


Chairman, EECE Department
___________________
Date

FELICIANO B. ALAGAO, Ph.D.


Dean, College of Engineering
___________________
Date

Dedicated to Densetsu no Sannin

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,

Melvin P. Lacia Melvs


Prescila S. Palacio Rak2x
Japhet R. Repolledo Jep2x

TABLE OF CONTENTS

TITLE PAGE

ABSTRACT

ii

APPROVAL SHEET

iii

DEDICATION

iv

ACKNOWLEDGMENT

TABLE OF CONTENTS

vi

CHAPTER 1: INTRODUCTION

1.1

Background of the Study

1.2

Statement of the Problem

1.3

Objectives of the Study

1.4

Significance of the Study

1.5

Scope and Limitations

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

CHAPTER 2: REVIEW OF RELATED LITERATURE

19

2.1

Embedded Web Server for Home Appliances

19

2.2

Home Appliances Control Using GSM (Global System for Mobile)

19

2.3

Internet-based Home Power Switch Controlling/Monitoring System

20

on Embedded Server
2.4

Control Home Appliances via Internet (CoHAVI) Home

21

Appliances Using Microcontroller


2.5

Home Appliance Networking Protocol Implemented On Power Line

21

Carrier

CHAPTER 3: RESEARCH DESIGN AND METHODOLOGY

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

3.2.4 Serial Communication

26

3.2.5 Electrical System

26

3.2.6 Proteus Virtual System Modeling

27

Firmware Design

28

3.3.1 mikroC Programming

28

3.3

3.4

3.5

3.6

3.3.2 Virtual Terminal Simulation

30

3.3.3 Loading the Program

31

Web Design

32

3.4.1 Building the Web Design

33

3.4.2 Setting up the Database

34

3.4.3 Communication of Web Design to MySQL

35

3.4.4 MATLAB GUIDE

35

3.4.4.1 MATLAB Simulation

36

3.4.5 Connection of MySQL Database to MATLAB

37

Hardware Design

38

3.5.1 Hardware Components

38

3.5.1.1 PIC16f877A

38

3.5.1.2 ULN2003A

38

3.5.1.3 Relay

39

3.5.1.4 RS232-Serial TTL Converter

39

3.5.1.5 Power Supplies

40

3.5.1.6 Electrical Loads

40

3.5.2 Breadboard Simulation

41

3.5.3 PCB Integration

41

3.5.4 Prototype Integration

41

Testing the System

42

3.6.1 Testing and Debugging of the System

42

3.6.2 Deployment Diagram

43

3.6.3 Test for Simulation and System Evaluation

43

3.7 Electrical Plan

CHAPTER 4: RESULTS AND DISCUSSION

44

46

4.1

Web Design

46

4.2

Prototype

47

4.3

System Evaluation

50

4.4

Electrical Plan

55

CHAPTER 5: CONCLUSION AND RECOMMENDATION

58

5.1 Conclusion

58

5.2 Recommendation

59

BIBLIOGRAPHY

60

APPENDICES

62

CURRICULUM VITAE

78

1
CHAPTER I

Introduction

1.1 Background of the Study


Since 2007, people have shifted to the access of mobile webs from conventional
web usage in our laptops and desktop computers. One main reason for this is a lot of
people nowadays value more on their convenience in accessing the web especially when
they are out from their homes most of the time to go to work, meetings and other related
activities. This convenience is made possible by multi-touch smartphones and since 2010,
by multi-touch tablet computers which laptops and desktop computers cannot offer.
Though quite expensive, this has not stopped people from purchasing these gadgets.
Furthermore, the production of these gadgets has significantly risen since then.
With this significant technological advancement, the researchers have come to
thinking on how they can use smartphones or tablets to improve household electrical
systems. This special project entitled Mobile Web Application for Appliance and
Lighting System Control intends to design a mobile web-based control system which
can control the on and off switching of appliances and lighting systems through the
access of the World Wide Web or WWW using smartphones or tablets. With this kind of
project, we can give additional advantage on the use of smartphones or tablets aside from
the convenience it can give to us in accessing the web. This is to cut down electrical
charges and even to prevent electrical accidents from happening due to overheating since

2
a lot of people unintentionally left their homes with their appliances plugged in and lights
switched on.

1.2 Statement of the Problem


In this study, the researchers aimed to develop a mobile web-based control system
which can turn ON/OFF the appliance and lighting system.

1.3 Objective of the Study


The researcher aimed to achieve the following objectives:
1. To develop a prototype for the control system of appliance and lighting of a
typical home;
2. To develop a mobile web design that can control the appliance and lighting
system;
3. To implement the mobile web design for the control of the appliance and lighting
system prototype;
4. To perform a system evaluation and a simulation of the mobile-web design and
the appliance and lighting system by using different turning ON/OFF methods;
and
5. To implement the projects design in an actual electrical plan.

1.4 Significance of the Study


Many of the fires that are happening in our country are caused by faulty electrical
wiring. But one fact that we usually neglect to give attention is the irresponsible usage of

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.

1.5 Scopes and Limitations


This special project is bounded with the following statements:
1. The client must have a smartphone or tablet that is connected to the same network
of the PC host.
2. The user must input the IP address of the network and the project name of the
mobile web design in order for the user to remotely control the power switches.
3. The appliance and lighting control system is installed on a residential house
miniature where the outlets and small lighting fixtures are installed.

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.

1.6 Definition of Terms

Appliance - is usually defined as a large machine which accomplishes some


routine housekeeping task, which includes purposes such as cooking, or food
preservation, whether in a household, institutional, commercial or industrial
setting.

Control System - is a device, or set of devices to manage, command, direct or


regulate the behavior of other device(s) or system(s).

Electrical Outlet - an opening or series of openings connected to a wired power


source meant to power electrical equipment and components.

Low-Voltage Control refers to the control system (included by microcontroller


unit) wherein the system is operated at 5V power supply.

Microcontroller - is a small computer on a single integrated circuit containing a


processor core, memory, and programmable input/output peripherals.

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.

Smartphone - a mobile phone built on a mobile operating system, with more


advanced computing capability and connectivity than a feature phone.

Tablet Computer or simple tablet, is a one-piece, mobile version of a personal


computer, primarily operated by touchscreen (the user's finger essentially
functions as the mouse and cursor, removing the need for the physical [i.e., mouse
& keyboard] hardware components necessary for a desktop or laptop computer;
and, an onscreen, hideable virtual keyboard is integrated into the display).

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 Theoretical Framework


The following sections explain the theories behind the operations and procedures
used entirely in the project.

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.

1.7.1.2 PIC Microcontroller


PIC is a family of modified Harvard architecture microcontrollers made by
Microchip Technology, derived from the PIC1650 originally developed by General
Instrument's Microelectronics Division. The name PIC initially referred to "Peripheral
Interface Controller".
The PIC architecture is characterized by its multiple attributes:

Separate code and data spaces (Harvard architecture).

A small number of fixed length instructions

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 hardware stack for storing return addresses

A small amount of addressable data space (32, 128, or 256 bytes, depending on
the family), extended through banking

Data space mapped CPU, port, and peripheral registers

ALU status flags are mapped into the data space

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.

1.7.1.3 Serial Communication


In telecommunication and computer science, serial communication is the process
of sending data one bit at a time, sequentially, over a communication channel or
computer bus. This is in contrast to parallel communication, where several bits are sent as
a whole, on a link with several parallel channels. Serial communication is used for all
long-haul communication and most computer networks, where the cost of cable and the
synchronization difficulties make parallel communication impractical. Serial computer
buses are becoming more common even at shorter distances, as improved signal integrity
and transmission speeds in newer serial technologies have begun to outweigh the parallel
bus's advantage of simplicity (no need for serializer and deserializer, or SerDes) and to
outstrip its disadvantages (clock skew, interconnect density). The migration from PCI to
PCI Express is an example.

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.

1.7.2.3 Adobe Dreamweaver


Adobe Dreamweaver is a web design and development application that provides a
visual WYSIWYG editor (colloquially referred to as the Design view) and a code editor
with standard features such as syntax highlighting, code completion, and code collapsing
as well as more sophisticated features such as real-time syntax checking and code
introspection for generating code hints to assist the user in writing code. The Design view
facilitates rapid layout design and code generation as it allows users to quickly create and
manipulate the layout of HTML elements. Dreamweaver features an integrated browser
for previewing developed webpages in the program's own preview pane in addition to
allowing content to be open in locally installed web browsers. It provides transfer and
synchronization features, the ability to find and replace lines of text or code by search
terms or regular expressions across the entire site, and a templating feature that allows
single-source update of shared code and layout across entire sites without server-side
includes or scripting. The behaviors panel also enables use of basic JavaScript without
any coding knowledge, and integration with Adobe's Spry Ajax framework offers easy
access to dynamically-generated content and interfaces.
Dreamweaver, like other HTML editors, edits files locally then uploads them to
the remote web server using FTP, SFTP, or WebDAV. Dreamweaver CS4 now supports
the Subversion (SVN) version control system.

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.

1.7.2.6 Cascading Style Sheets (CSS)


Cascading Style Sheets (CSS) is a style sheet language used for describing the
presentation semantics (the look and formatting) of a document written in a markup
language. Its most common application is to style web pages written in HTML and

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.

1.7.3.2 Proteus VSM (Virtual System Modeling)


Virtual System Modeling lets cosimulate embedded software for popular microcontrollers alongside hardware design.
Proteus VSM combines a superb mixed mode circuit simulator based on the
industry standard SPICE3F5 with animated component models. It provides an
architecture in which additional animated models may be created by anyone, including
end users. Indeed, many types of animated model can be produced without resort to
coding. Consequently PROTEUS VSM allows professional engineers to run interactive
simulations of real designs, and to reap the rewards of this approach to circuit simulation.
Proteus VSM has a range of simulator models for popular micro-controllers and a
set of animated models for related peripheral devices such as LED and LCD displays,
keypads, and RS232 terminal and more. Suddenly it is possible to simulate complete

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.

1.7.5.4 Serial Port


In computing, a serial port is a serial communication physical interface through
which information transfers in or out one bit at a time (in contrast to a parallel port).
Throughout most of the history of personal computers, data transfer through serial ports
connected the computer to devices such as terminals and various peripherals.
While such interfaces as Ethernet, FireWire, and USB all send data as a serial
stream, the term "serial port" usually identifies hardware more or less compliant to the

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

Review of Related Literature

2.1 Embedded Web Server for Home Appliances


Main aim of this paper is to describe how to connect a micro- controller to LAN
or Internet and use it as a web server. This paper offers a new approach to control home
appliances from a remote terminal, with an option from a local server, using the Internet.
This system is accomplished by personal computers, interface cards, microcontroller,
along with window-type software and microcontroller control software. The system is
designed to control home appliances' on/off, to regulate their output power, and to set
their usage timing. The microcontroller which is used in this project is the Philips
P89C51RD2BN microcontroller. [1]

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]

2.3 Internet-based Home Power Switch Controlling/Monitoring System on


Embedded Server
The special project is designed purposely to control and monitor home power
switches in such a way that a user can remotely turn them ON/OFF as well as monitor
their current status (ON/OFF) in real-time. The users location is arbitrary which enables
him to control/monitor his home power switches from his workplace or wherever he may
be as long as he is connected to the internet and has a PC installed with the
supplementary software that provides an interactive application interface. The power
switches can be used to provide power connection to the appliances or any electricallydriven devices.
In contrast to the previous project, entitled WEB-BASED HOME APPLIANCES
MONITORING AND CONTROL, this system no longer uses desktop PC as a server but
utilizes an embedded server on robust microcontroller hardware. In this manner, cost
reduction has been possible since power-hungry PC has been replaced by a less power
consuming embedded server board that contains low cost components. Moreover, this
special project has been designed to handle eight power switches that can be turned on all
together, a feature that has not been carried out by the previous project.

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]

2.5 Home Appliance Networking Protocol Implemented On Power Line Carrier


This project aims to develop/make software, firmware and hardware for
networking home appliances. The system is composed of a computer and a

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

3.1 System Overview

Figure 3.1 Project General Setup

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 Circuit Design


The circuit refers to the design and analysis of the MCU-Relay System and the
AC Electrical System. With the main objective of an ON/OFF switching of the system,
the main electrical devices or components used were the microcontroller PIC16f877A
and relays. Other important components include ULN2003A, MAX232 and Serial Port.

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.

3.2.4 Serial Communication


In order to control the switching of relays, serial communication between the PC
host and the prototype is used. In serial communication, MAX232 is used. MAX232 is a
single supply voltage, RS-232 transceiver. MAX232 is compatible with RS-232 standard,
and consists of dual transceiver. It is purposed for application in high-performance
information processing systems and control devices of wide application.
The TX and RX pins of the PIC microcontroller are connected to this component.
Then, this transceiver is connected to the serial port to carry out serial communication
between the server and the MCU-Relay System.

3.2.5 Electrical System


The electrical system refers to the AC side of the whole system. It is supplied by a
single phase AC source. This single phase source supplies loads that were sorted into five
circuits. These circuits are connected to the source parallel to each other. The relays are
connected to either of the two wires/conductors connected from the AC source. The
connection can be illustrated as a continuous wire in a standard AC system cut into two
and one cut side is connected to the COM pin of the relay and the other side of the cut

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.

3.2.6 Proteus Virtual System Modeling


The main purpose for using the Proteus was to simulate the established circuit.
The main components that were drawn in Proteus are the following: PIC16F877A;
ULN2003A; Relays; COM Port Physical interference Model or COMPIM; an AC source;
and Electrical Loads. MAX232 was intentionally not included in the simulation but the
serial communication was still carried out without it.

Figure 3.2 Schematic Diagram in Proteus

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.

3.3.1 mikroC Programming

Figure 3.3 Firmware Process Flow

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.

Figure 3.4 Web Design Flow

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.

3.4.2 Setting up the Database


The database is created in the WAMP Server and is named phplogin. The tables
that were created under the phplogin were the toggleswitch and signup. The signup table
includes the ID, firstname, lastname, username, and password information. This is where
the data is stored that the user inputs in the sign up page of the web design. In the

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).

3.4.3 Communication of Web Design to MySQL


Four files were created to communicate with the phplogin database. The three
files connect to the signup table, the login.php, adduser.php, ifexist.php, and one file
which is the updateswitch.php that connects to the toggleswitch table. The login.php
works with the log in page in which the two inputted data of web design which are the
username and password is compared to the database table sign up. If the inputted data
match with the data stored in the table, this allows the user to log in, but if it doesnt, it
prompts the user as invalid username and/or password. The ifexist.php works with the
sign up page which prompts the user if the inputted data of the username is not the same
with the data stored in the signup table, it says, username already exist. The adduser.php
works with the CAPTCHA page which transfers all the inputted data from sign up page
to the sign up table of the database. The updateswitch.php works with the control system
page and other pages under the control system. This updates the value of the toggleswitch
table when the switch is on/off.

3.4.4 MATLAB GUIDE (Graphical User Interface Development Environment)


The system design can be controlled by MATLAB. The MATLAB GUIDE
(Graphical User Interface Development Environment) was used to design the control

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.

3.4.4.1 MATLAB Simulation


In Proteus, the Virtual Terminal is replaced with the COMPIM or the COM Port
Physical interference Model and the control of the ports is executed in MATLAB to test
both the firmware and the GUI.

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.

3.4.5 Connection of MySQL Database to MATLAB


An additional MATLAB code were included that allows the GUI to communicate
with the localhost, and then execute the connection by selecting the toggleswitch table.
This allows fetching the data from the signup table. The data are being transferred from
database to MATLAB. The data are the corresponding value of the outer and internal
control switches. The outer are the breakers (one main breaker and five sub-breakers) and
the internal are the light and outlet switches of bedroom1, bedroom2, living room, toilet,
kitchen, and dining room.

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 Hardware Components


The main hardware components are PIC16f877A, ULN2003A, Relays, MAX232,
DB9 Angle Type Female and RS232 to USB converter, DC power supplies and the loads.

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.

3.5.1.4 RS232-Serial TTL Converter


E-Gizmo RS-232C to Serial TTL converter is a interface board that provides level
translation between your RS-232C level communication channel to your TTL UART
circuit. This kit uses a chip MAX3245 that will work with supply voltages of 3.3V to 5V,
making it correspondingly compatible with both logic. Mustering all of MAX3245s
I/Os, full implementation of RS-232C hardware handshake is realized, making the kit
truly compatible with all possible RS-232C wiring schemes.

40

Figure 3.5 RS232-Serial TTL Converter

3.5.1.5 Power Supplies


Three power supplies are needed for the project. From a single ac/dc 24V 6A
power supply, three voltage regulators are used to have 5V, 6V, and 12V outputs. One
12V dc output was used to supply one ULN2003A and to the six 12V relay connected to
that IC. One 6V dc output was used for the two remaining ULN2003A ICs, one supply
for one IC. It also supplies five 6V relay for outlet loads and the other 6V dc supplies six
relays for the lighting loads. Lastly, a 5V dc output was used to power the PIC16f877A
microcontroller and the MAX232 IC.

3.5.1.6 Electrical Loads


In the house miniature is where the lighting loads are installed. Six 5W AC bulbs
are installed one for each room. On the other hand, the five outlets are provided by
installing one duplex convenience outlet and one triplex convenience outlet. It is mounted
at the side of the box where the MCU is installed.

41

3.5.2 Breadboard Simulation


All of the hardware components were set-up on a breadboard to test the hardware
design except for the relays and loads which do not directly fit on the board. Electrical
wires were used to connect the relays and loads to the circuit on the breadboard.
To enable the simulation, the GUI created in MATLAB was used to control the
switching mechanism of the relays. This stage of hardware design is crucial to ensure a
working hardware design before it is integrated on a Printed Circuit Board or PCB. This
procedure saves time and money in the process of completing the project.

3.5.3 PCB Integration


A presensitized Printed Circuit Board (PCB) was used for the integration of the
hardware components of the electrical system. A presensitized PCB is a factory prepared
PCB surface coated with a photo sensitive emulsion. All components, except the loads,
were soldered on the printed circuit board.

3.5.4 Prototype Integration


The prototype of the system is mainly composed of the residential house
miniature, the loads, and the MCU-Relay System. It has 6 rooms namely the living room,
bedroom 1, bedroom 2, dining room, kitchen, and toilet and bath. All of the rooms,
except for the toilet and bath, each have one lighting load and one electrical outlet
installed. The toilet and bath has only one lighting load. These loads belong to the five

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.

3.6 Testing the System


Testing of the system is one important stage because it determines if the project is
working or not. From here, results are obtained. Moreover, this discusses the deployment
diagram, the method in testing the system and the method for system evaluation.

3.6.1 Testing and Debugging of the System


To test the system if it is working, the hardware must be set-up initially. The main
components of the hardware are the box, the power supplies, and the miniature. The box
houses the microcontroller unit, the relays, and the convenience outlets. Four power
supplies were connected to the box supplying the microcontroller unit and the relays. The
miniature comprises of the loads and the main circuit breaker.
Other things needed to be set-up are the connection of the MCU to the PC server
made possible by RS232 to USB converter.
The GUI file must be executed and the WAMP must be launched where the local
host can be started. When these applications are already good to go, then the power
supplies and the ac source must be turned ON already. After all this, then it is ready to
control the home appliances and the lighting system.

43
3.6.2 Deployment Diagram

Figure 3.6 Systems Unified Modeling Language for Deployment Diagram

3.6.3 Test for Simulation and System Evaluation


A simulation was conducted using Proteus Virtual System Modeling with
different methods of turning ON/OFF the power switches. The different methods are the
same with the methods conducted in system evaluation.

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.

3.7 Electrical Plan


This projects hardware presents only a prototype of the electrical system design.
An actual electrical plan was designed and the project was implemented into the
electrical plan in order to study the feasibility of the project in large-scale applications.
A typical electrical plan comprises of various layouts and calculations. But in this
project, not all of them were designed. The following layouts included were lighting

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

Results and Discussion

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.

4.1 Web Design


One of the outputs of this project is the mobile web design.
The output of the mobile web design mainly comprises of the home page, log-in
page, sign-up page, CAPTCHA page, and the Control System. The design also includes
system profile and the contact us page. Here is a screenshot of the home page of the
web design.

Figure 4.1 Home Page of the Mobile Web Design

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.

Figure 4.2 Miniature of the whole system

On the other hand, the MCU-Relay System and the electrical outlets were
integrated in a box casing as shown below.

48

Figure 4.3 Controller


In addition, the lighting loads were installed inside the miniature with one load for
each room. These loads are wired leading to the box casing where the control system is.
The figure below shows the installation of the lighting loads.

Figure 4.4 Lighting Load Installation

49

Lastly, the photo below shows the power supply of the project.

Figure 4.5 Power Supply

Please see the appendix C for photos of the prototype.

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

Dining Room OFF

Kitchen OFF

Toilet OFF

OK

OK

OK

Bedroom 2 OFF

Bedroom 1 OFF

OK

OK

Living Room OFF

OK

Dining Room OFF

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.

Table 4.6 Method 4 Turning OFF the System


MAIN OFF
OK

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

Conclusion and Recommendation

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

[5] Isaac Paul N. Dandasan. Home Appliance Networking Protocol Implemented On


Power Line Carrier. College of Engineering, Mindanao State University Iligan
Institute of Technology, March 2010

61

Internet

(____).Mobile Web. [Online]. Available:


http://en.wikipedia.org/wiki/Mobile_Web
(____).PIC Microcontroller. [Online]. Available:
http://en.wikipedia.org/wiki/Pic_microcontroller
(____).Serial Communication. [Online]. Available:
http://en.wikipedia.org/wiki/Serial_communication
(____).Relay. [Online]. Available:
http://en.wikipedia.org/wiki/Relay

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

Panel Load Schedule


Panel Designation:

Ckt no.
1
2
3
4
5
6

Voltage:

Phase:

Lighting and Power Panel 1

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

Main Protection 100AT/100AF, 2 Pole, 230V, 1


Main Feeder Size 2 x 30mm2 THHN + 1 x 8mm2 THHN(E) in 40mm PVC

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

Figure B.1 Log-in

Figure B.3 CAPTCHA

Figure B.2 Sign-up

Figure B.4 System Profile

72

Figure B.5 Contact Us

Figure B.6 Main Breaker OFF

Figure B.7 Main Breaker ON

73

Figure B.8 Bedroom 1 Off

Figure B.9 Bedroom 2 On

74
APPENDIX C
PROTOTYPE SCREENSHOTS

Figure C.1 House Miniature

Figure C.2 House Miniatures Inside View

Figure C.3 Circuit Breaker

75

Figure C.4 Lighting Installation

Figure C.5 MCU and RS232 TTL Converter

Figure C.6 Relays

76

Figure C.7 Controller

Figure C.8 Terminals for AC System

Figure C.9 Terminals for Power Supply

77

Figure C.10 Electrical Outlets

Figure C.11 Integrated Power Supply

CURRICULUM VITAE

79
CURRICULUM VITAE
Name:

Melvin P. Lacia

Address:

Tago, Surigao del Sur

Date of Birth:

October 20, 1991

Place of Birth:

Tago, Surigao del Sur

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:

JGC PHILIPPINES, INC.


Building Section
Madrigal Business Park
Ayala Alabang, Muntinlupa City, Philippines
April June 2012

EDUCATIONAL ATTAINMENT:
Elementary:

Falcon Memorial Elementary School Tago, Surigao del Sur


March 2004
4th Honors

Secondary:

Jacinto P. Elpa National High School SSC Tandag, Surigao del Sur
March 2008
4th Honors

Tertiary:

Bachelor of Science in Electrical Engineering


Mindanao State University Iligan Institute of Technology
Tibanga, Iligan City
April 2013

ORGANIZATIONS:
2011 Present

Institute of Integrated Electrical Engineers of the Philippines, Inc.


Council of Student Chapters, Northern Mindanao Sector
Regular Member

(IIEE CSC)

80
CURRICULUM VITAE
Name:

Prescila S. Palacio

Address:

Dalipuga, Iligan City

Date of Birth:

July 12, 1989

Place of Birth:

Kiwalan, Iligan City

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:

Celestica Philippines, Inc.


Mactan Economic Zone 1 (MEZ 1), Lapu-lapu City, Cebu Philippines
November 2008 May 2009
Signal Marine Shipyard Corp.
Cabu Tambler, General Santos City, Philippines
April June 2012

EDUCATIONAL ATTAINMENT:
Elementary:

Kiwalan Elementary School, Kiwalan, Iligan City


March 2002
5th Honors

Secondary:

Iligan City East High School Kiwalan Annex, Kiwalan, Iligan City
March 2006
1st Honors

Tertiary:

Electronics Engineering Technology (Major in Computer)


Mindanao State University Iligan Institute of Technology
Tibanga, Iligan City
March 2009
With Honors
Bachelor of Science in Electrical Engineering
Mindanao State University Iligan Institute of Technology
Tibanga, Iligan City
April 2013
Cum Laude

ORGANIZATIONS:
2011 Present

Institute of Integrated Electrical Engineers of the Philippines, Inc.


Council of Student Chapters, Northern Mindanao Sector
Regular Member

(IIEE CSC)

81
CURRICULUM VITAE
Name:

Japhet R. Repolledo

Address:

Margosatubig, Zamboanga del Sur

Date of Birth:

October 29, 1989

Place of Birth:

Margosatubig, Zamboanga del Sur

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:

Monde Nissin Corporation


Mandaue City, Cebu, Philippines
November 2008 May 2009
JGC PHILIPPINES, INC.
Madrigal Business Park
Ayala Alabang, Muntinlupa City, Philippines
April June 2012

EDUCATIONAL ATTAINMENT:
Elementary:

Margosatubig Regional School - Margosatubig, Zamboanga del Sur


March 2002
6th Honors

Secondary:

Toribio Minor National High School- Margosatubig, Zamboanga del Sur


March 2006
Salutatorian

Tertiary:

Electronics Engineering Technology (Major in Communication)


Mindanao State University Iligan Institute of Technology
Tibanga, Iligan City
March 2009
With Honors
Bachelor of Science in Electrical Engineering
Mindanao State University Iligan Institute of Technology
Tibanga, Iligan City
April 2013

ORGANIZATIONS:
2011 Present

Institute of Integrated Electrical Engineers of the Philippines, Inc.


Council of Student Chapters, Northern Mindanao Sector
Regular Member

(IIEE CSC)

You might also like