[go: up one dir, main page]

0% found this document useful (0 votes)
98 views52 pages

Home Automation Using Power Line Communication

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 52

Home Automation Using Power Line Communication

CHAPTER 1
INTRODUCTION

Home automation is the residential extension of building automation. It


is automation of the home, housework or household activity. Home automation may
include centralized control of lighting, HVAC (heating, ventilation and air
conditioning), appliances, security locks of gates and doors and other systems, to
provide improved convenience, comfort, energy efficiency and security. Home
automation for the elderly and disabled can provide increased quality of life for persons
who might otherwise require caregivers or institutional care. Home Automation allows
the user to control his home from his or her computer. In the computer program the user
can create what should happen with electrical devices in the network depending on the
happenings in the surrounding environment. In the proposed system we are using Power
Line Communication so that no extra cables are required.

The project is implemented using the TCP/IP protocol, X10 protocol and
microcontroller based embedded system. The embedded device consists of a micro
controller, which monitors the parameters and updates its data to the internet using
TCP/IP protocol. This data can be accessed using any PC connected to the Internet.
The embedded device monitors and stores the status of different devices in a
home/building in its memory. The system can also control devices (On/Off) based on
user data. A communication network in the house will provide the infrastructure for
linking appliances, sensors, controllers, and control panels inside the house. This has
become feasible by tailoring the communications technologies developed for office
automation to the home environment.

The system has two main modules – embedded side and the
computerside. The computer side application software can be developed using HTML
and any scripting language. The webpage developed with this software helps the user to
monitor and control the parameters in real time in the PC.

Department of Electrical and Electronics, ICET 1


Home Automation Using Power Line Communication

CHAPTER 2
HISTORY

Home automation has been a feature of science fiction writing for many
years, but has only become practical since the early 20th Century following the
widespread introduction of electricity into the home, and the rapid advancement of
information technology. Early remote control devices began to emerge in the late 1800s.
For example, Nikola Tesla patented an idea for the remote control of vessels and
vehicles in 1898.

The emergence of electrical home appliances began between 1915 and


1920; the decline in domestic servants meant that households needed cheap, mechanical
replacements. Domestic electricity supply, however, was still in its infancy - meaning
this luxury was afforded only the more affluent households. Ideas similar to modern
home automation systems originated during the World's Fairs of the 1930s. Fairs
in Chicago (1934), New York (1939) and (1964–65), depicted electrified and automated
homes. In 1966 Jim Sutherland, an engineer working for Westinghouse Electric,
developed a home automation system called "ECHO IV"; this was a private project and
never commercialized. The first "wired homes" were built by American hobbyists
during the 1960s, but were limited by the technology of the times. The term "smart
house" was first coined by the American Association of House builders in 1984.

With the invention of the microcontroller, the cost of electronic control


fell rapidly. Remote and intelligent control technologies were adopted by the building
services industry and appliance manufacturers worldwide, as they offer the end user
easily accessible and/or greater control of their products.

Despite interest in home automation, by the end of the 1990s there was
not a widespread uptake - with such systems still considered the domain of hobbyists or
the rich. The lack of a single, simplified, protocol and high cost of entry has put off
consumers.

Department of Electrical and Electronics, ICET 2


Home Automation Using Power Line Communication

CHAPTER 3
WHY HOME AUTOMATION?

PC based home automation is one of the easiest ways to operate and


control electrical appliances. Many of the software applications out there offer a range
of features, but can be started with devices as simple as a couple of lights. Home
appliances like light, fan, television, refrigerator etc. can be controlled using electrically
operated switch capable of controlling 230V compatible electrical devices with Power
Line Communication (PLC).
The proposed system is more advantageous to the disabled ones.
Because switches are normally located at high location and it is difficult for them to
operate it without any help. Furthermore, closing gates might be a problem for the
disable people. A home automation system using power line communication is
proposed to solve this problem. The system is user friendly and requires only to drive
the system. It is often a problem for technicians required to design and installs such
plants, especially when the plant has to be installed in a pre-existing building whose
electrical cabling has not been prearranged to support that level of automation. In this
case the solution proposed by the application of power line communication links could
be very helpful. These methods exploit standard electric lines (e.g. 220V AC, 50Hz) to
transmit data, with specific techniques, among the different modules (sensors, actuators,
controllers) which are installed in the house. In this project a practical implementation
of a power line communication protocol, realized by means of embedded processor is
presented.

Home appliances were fully controlled by the computer through the


communication line and command from computer was done by the control circuit with
the help of the relays. Power line communication is a system for transmitting data on a
conductor also used for electric power transmission.

Department of Electrical and Electronics, ICET 3


Home Automation Using Power Line Communication

CHAPTER 4
THE PROPOSED SYSTEM

The proposed Home Automation System is using one of the latest technologies,
Power line communication. Power line offers the opportunity for the PC to be integrated into
the household as never before. As part of the household power grid, PCs could easily be
programmed to turn off lights and control security devices. So our system doesn‟t require any
extra cables and thereby the cost can be considerably reduced. Apart from the obvious saving in
installation cost, this virtual network also makes modification and enhancement very simple
since new devices just have a wall socket to be instantly connected to the network. The project
is implemented using the TCP/IP protocol, X10 protocol and microcontroller based embedded
system. As controlling is done through GPRS system, it can be done from any part of the world.
By this system all the devices of our home can be controlled. A communication network in the
house will provide the infrastructure for linking appliances, sensors, controllers, and control
panels inside the house. This has become feasible by tailoring the communications technologies
developed for office automation to the home environment.
Every Home Automation box is a stand-alone device. It is connected to
the mains and controls the power outlet of the electrical device that is plugged into it.
There will be a receiver and transmitter in each of the box, so they can exchange
information with the master (a computer). People can control power supply of electrical
devices in order to create an interactive home environment to facilitate the control
without changing any home appliance. People can enjoy the high technology and
simplicity modern life style. Each device will be with standard setup and while adding it
into network; it can be given an address and tasks to do. All the setting will be easily
resettable to default value, so people can move the devices between different electrical
devices and networks. Home Automation boxes will be put into different rooms at
home, depending on the needed functionality. Various different sensors could be
attached to the boxes. The sensors are used as triggers for actions, that user can set up in
the computer program.

Department of Electrical and Electronics, ICET 4


Home Automation Using Power Line Communication

Our system is covering two areas, one is the location from which the user
is operating and the other is his/her home. The user is having an application which is
installed in his system. This application will access the data through a GPRS modem. In
the Home there is a GPRS modem, X-10 Transmitter which includes a microcontroller,
and various devices to generate 120 kHz and for the safe coupling with power line. Also
there is a X-10 Receiver which again includes a microcontroller and various devices to
connect with the devices. From X-10 receiver control is given to a relay through a relay
driver which will operates the devices (switch on/off/dim).

FIG 4.1 BLOCK DIAGRAM SHOWING THE SYSTEM INSTALLED IN A HOME

Department of Electrical and Electronics, ICET 5


Home Automation Using Power Line Communication

CHAPTER 5
GENERAL PACKET RADIO SERVICE

General Packet Radio Service(GPRS) is expected to profoundly change


the mobile data services that GSM, CDMA and TDMA (ANSI-I36) network operators
can offer. GPRS will increase opportunities for higher revenues and enable new,
differentiated services and tariff dimensions to be offered (such as a charge for the
number of kilobytes of data transferred). GPRS combines mobile access with Internet
protocol (IP)-based services, using packet data transmission that makes highly efficient
use of radio spectrum and enables high data speeds. It gives users increased bandwidth,
making it possible and cost-effective to remain constantly connected, as well as to send
and receive data as text, graphics and video.

5.1 What is GPRS?

GPRS (general packet radio service) is a packet-based data bearer service for
wireless communication services that is delivered as a network overlay for GSM,
CDMA and TDMA (ANSII36) networks. GPRS applies a packet radio principle to
transfer user data packets in an efficient way between GSM mobile stations and external
packet data networks. Packet switching is where data is split into packets that are
transmitted separately and then reassembled at the receiving end. GPRS supports the
world's leading packet-based Internet communication protocols, Internet protocol (IP)
and X.25, a protocol that is used mainly in Europe. GPRS enables any existing IP or
X.25 application to operate over a GSM cellular connection. Cellular networks with
GPRS capabilities are wireless extensions of the Internet and X.25 networks. GPRS
gives almost instantaneous connection set-up and continuous connection to the Internet.
GPRS users will be able to log on to an APN (Access Point Name) and have access to
many services or an office network (without the need to dial-up) and remain
continuously connected until they log off, only paying when data is actually transmitted.

Department of Electrical and Electronics, ICET 6


Home Automation Using Power Line Communication

A physical end-to-end connection is not required because network resources and


bandwidth are only used when data is actually transferred. This makes extremely
efficient use of available radio bandwidth. Therefore, GPRS packet-based services
should cost users less than circuit-switched services since communication channels are
being shared and are on a „as-packets-are-needed‟ basis rather than dedicated to only
one user at a time. It should also be easier to make applications available to mobile
users because the faster data rate means that middleware currently needed to adapt
applications from fixed line rates to the slower speed of wireless systems will no longer
be needed.

GPRS data speeds will range from 14.4 Kbit/s (using one radio timeslot) to
115kbit/s (by amalgamating timeslots) and offer continuous connection to the Internet
for mobile phone and computer users. GPRS data speeds are likely to average at about
56 Kbit/s, with between 28 and 40 Kbit/s initially. The higher data rates will allow users
to take part in video conferences and interact with multimedia web sites and similar
applications using mobile handheld devices as well as notebook computers.

The key drivers for operators to evolve to GPRS networks are to:

 Increase revenues by moving into the mobile data market, especially since the
voice market has had profit margins squeezed with the commoditization of voice
services
 Gain new subscribers who require mobile data services or do not want to invest
in a PC to gain Internet access
 Retain current subscribers by offering new services
 Reduce costs due to the efficient use of network resources
 Ease of adapting applications for mobile users because high data speeds mean
that middleware is no longer required to convert fixed applications for mobile
use.

Department of Electrical and Electronics, ICET 7


Home Automation Using Power Line Communication

Fig 5.1 GPRS CONNECTIVITY

GPRS is based on GSM communication and will complement existing services such as
circuit switched cellular phone connections and the Short Message Service (SMS). It
will also complement Bluetooth, a standard for replacing wired connections between
devices with wireless radio connections.

5.2 How is GPRS different to GSM?

GPRS is different to GSM because it offers the following key features:

 Higher bandwidth and, therefore, data speeds


 Seamless, immediate and continuous connection to the Internet – „always
on-line‟
 New text and visual data and content services (due to data speeds and the
Internet), such as email, chat, still and moving images, information services
(stock prices, weather reports, train times), video conferencing, e-commerce
transactions (buying flight and cinema tickets) and Internet-based remote
access to corporate intranets and public networks (rather than dial-up remote
access which incurs long distance phone calls).

Department of Electrical and Electronics, ICET 8


Home Automation Using Power Line Communication

 Packet-switching rather than circuit-switching, which means that there is


higher radio spectrum efficiency because network resources and bandwidth
are only used when data is actually transmitted even though it is always
connected.
 Different mediation, rating and billing requirements such as collecting
records from GPRS and IP networks, charging for volumes of data
transferred rather than connection time and new and multiple members of
the billing value chain
 Support for leading Internet communications protocols - Internet protocol
(IP) and X. 25
 Additional components and protocols to the GSM network – the key
elements are SGSN (serving GPRS support node), GGSN (gateway GPRS
support node) and a charging gateway
 Different devices (not GSM phones) - GPRS will be available from laptops
or handheld computers that are either connected to GPRS-capable cellular
phones, external modems or that have PC card modems, smart phones that
have full screen capability and cellular phones that have WAP micro
browsers. All of these devices have user interfaces that will allow users to
utilise GPRS services
 The first important step on the path to 3G.

GSM (Global System for Mobile) – is known as a 2G (second generation) digital.


GSM has maximum data speeds of 9.6 kbit/s and is based on circuit switching
technology.

Department of Electrical and Electronics, ICET 9


Home Automation Using Power Line Communication

CHAPTER 6
CONNECTING CIRCUITS

6.1 THE RS-232 STANDARD

Information being transferred between data processing equipment and peripherals is in


the form of digital data which is transmitted in either a serial or parallel mode. Parallel
communications are used mainly for connections between test instruments or computers
and printers, while serial is often used between computers and other peripherals.

Serial transmission involves the sending of data one bit at a time, over a single
communications line. In contrast, parallel communications require at least as many lines
as there are bits in a word being transmitted (for an 8-bit word, a minimum of 8 lines
are needed). Serial transmission is beneficial for long distance communications,
whereas parallel is designed for short distances or when very high transmission rates are
required.

6.1.1 Standards

One of the advantages of a serial system is that it lends itself to transmission


over telephone lines. The serial digital data can be converted by modem, placed onto a
standard voice-grade telephone line, and converted back to serial digital data at the
receiving end of the line by another modem.

Officially, RS-232 is defined as the “Interface between data terminal equipment


and data communications equipment using serial binary data exchange.” This definition
defines data terminal equipment (DTE) as the computer, while data communications
equipment (DCE) is the modem. A modem cable has pin-to-pin connections, and is
designed to connect a DTE device to a DCE device.

Department of Electrical and Electronics, ICET 10


Home Automation Using Power Line Communication

6.1.2 Interfaces

In addition to communications between computer equipment over telephone


lines, RS-232 is now widely used for direct connections between data acquisition
devices and computer systems. As in the definition of RS-232, the computer is data
transmission equipment (DTE). However, many interface products are not data
communications equipment (DCE). Null modem cables are designed for this situation;
rather than having the pin- to-pin connections of modem cables, null modem cables
have different internal wiring to allow DTE devices to communicate with one another.

6.1.3 Cabling Options

RS-232 cables are commonly available with 4, 9 or 25-pin wiring. The 25-pin
cable connects every pin; the 9-pin cables do not include many of the uncommonly used
connections; 4-pin cables provide the bare minimum connections, and have jumpers to
provide “handshaking” for those devices that require it. These jumpers connect pins 4, 5
and 8, and also pins 6 and 20.

The advent of the IBM PC AT has created a new wrinkle in RS-232


communications. Rather than having the standard 25-pin connector, this computer and
many new expansion boards for PC‟s feature a 9-pin serial port. To connect this port to
a standard 25- pin port, a 9-to-25-pin adaptor cable can be utilized, or the user can
create his own cable specifically for that purpose.

6.1.3 Selecting a Cable

The major consideration in choosingan RS-232 cable is, what devicesare to be


connected? First, are youconnecting two DTE devices (nullmodem cable) or a DTE
device toa DCE device (modem cable)?Second, what connectors arerequired on each
end, male orfemale, 25-pin or 9-pin (AT style)?Usually, it is recommended that theuser
obtain the two devices to beconnected, and then determinewhich cable is required.

Department of Electrical and Electronics, ICET 11


Home Automation Using Power Line Communication

6.1.4 Rs-232 Specifications

Transmitted signal voltage levels:

Binary 0: +5 to +15 Vdc (called a “space” or “on”)

Binary 1: - 5 to -15 Vdc (called a “mark” or “off”)

Received signal voltage levels:

Binary 0: +3 to +13 Vdc

Binary 1: -3 to -13 Vdc

DATA FORMAT:

Start bit : Binary 0

Data : 5, 6, 7 or 8 bits

Parity : Odd, even, mark or space (not used with 8-bit data)

Stop bit : Binary 1, one or two bits

FIG 6.1 PIN DIAGRAM

Department of Electrical and Electronics, ICET 12


Home Automation Using Power Line Communication

6.2 MAX 232 STANDARD

The MAX232 is an integrated circuit, first created by Maxim Integrated


Products, that converts signals from an RS-232 serial port to signals suitable for use in
TTL compatible digital logic circuits. The MAX232 is a dual driver/receiver and
typically converts the RX, TX, CTS and RTS signals.

The drivers provide RS-232 voltage level outputs (approx. ± 7.5 V) from
a single + 5 V supply via on-chip charge pumps and external capacitors. This makes it
useful for implementing RS-232 in devices that otherwise do not need any voltages
outside the 0 V to + 5 V range, as power supply design does not need to be made more
complicated just for driving the RS-232 in this case.

The receivers reduce RS-232 inputs (which may be as high as ± 25 V), to


standard 5 V TTL levels. These receivers have a typical threshold of 1.3 V, and a
typical hysteresis of 0.5 V.

The later MAX232A is backwards compatible with the original


MAX232 but may operate at higher baud rates and can use smaller external capacitors –
0.1 μF in place of the 1.0 μF capacitors used with the original device. The newer
MAX3232 is also backwards compatible, but operates at a broader voltage range, from
3 to 5.5 V.Pin to pin compatible: ICL232, ST232, ADM232, HIN232 (much cheaper
alternatives).

FIG 6.2 MAX 232

Department of Electrical and Electronics, ICET 13


Home Automation Using Power Line Communication

6.2.1 Voltage Levels

It is helpful to understand what occurs to the voltage levels. When a


MAX232 IC receives a TTL level to convert, it changes a TTL Logic 0 to between +3
and +15 V, and changes TTL Logic 1 to between -3 to -15 V, and vice versa for
converting from RS232 to TTL. This can be confusing when you realize that the RS232
Data Transmission voltages at a certain logic state are opposite from the RS232 Control
Line voltages at the same logic state. To clarify the matter, see the table below.

Table 6.1: Voltage Levels of RS232

6.2.2 Sim 900 Rs 232 Gsm Modem

GSM/GPRS RS232 Modem is built with SIMCOM Make SIM900 Quad-band


GSM/GPRS engine, works on frequencies 850 MHz, 900 MHz, 1800 MHz and 1900
MHz It is very compact in size and easy to use as plug in GSM Modem. The Modem is
designed with RS232 Level converter circuitry, which allows you to directly interface
PC Serial port .The baud rate can be configurable from 9600-115200 through AT
command. Initially Modem is in Auto baud mode. This GSM/GPRS RS232 Modem is
having internal TCP/IP stack to enable you to connect with internet via GPRS. It is
suitable for SMS as well as DATA transfer application in M2M interface.

Department of Electrical and Electronics, ICET 14


Home Automation Using Power Line Communication

The modem needed only 3 wires (Tx, Rx, GND) except Power supply to
interface with microcontroller/Host PC. The built in Low Dropout Linear voltage
regulator allows you to connect wide range of unregulated power supply (4.2V -13V).
Yes, 5 V is in between!! .Using this modem, you will be able to send & Read SMS,
connect to internet via GPRS through simple AT commands.

6.2.3 Features

 High Quality Product (Not hobby grade)


 Quad-Band GSM/GPRS 850/ 900/ 1800/ 1900 MHz
 Built in RS232 Level Converter (MAX3232)
 Configurable baud rate
 SMA connector with GSM L Type Antenna.
 Built in SIM Card holder.
 Built in Network Status LED
 Inbuilt Powerful TCP/IP protocol stack for internet data transfer over GPRS.
 Audio interface Connector
 Most Status & Controlling Pins are available at Connector
 Normal operation temperature: -20 °C to +55 °C
 Input Voltage: 5V-12V DC

6.3 USART

USART is Universal Synchronous and Asynchronous Receiver and


transmitter. USART module is one of the two serial I/O modules in
PIC16F877A.USART can be configured as asynchronous system that communicate
with personal computers. The most common use of the USART in asynchronous mode
is to communicate to a PC serial port using the RS-232 protocol. Please note that a
driver is required to interface to RS-232 voltage levels and the PIC should not be
directly connected to RS-232 signals. The USART outputs and inputs logic level signals
on the TX and RX pins of the PIC. The signal is high when no transmission or reception
is in progress and goes low when the transmission starts.

Department of Electrical and Electronics, ICET 15


Home Automation Using Power Line Communication

This low going transition is used by the receiver to synchronize to the incoming data.
The signal stays low for the duration of the start bit and is followed by the data bits,
least significant bit first. In the case of an eight-bit transfer, there are eight data bits and
the last data bit is followed by the stop bit which is high. The transmission therefore
ends with the pin high. After the stop bit has completed, the start bit of the next
transmission can occur as shown by the dotted lines. There are several things to note
about this waveform, which represents the signal on the TX or RX pins of the
microcontroller. The start bit is a zero and the stop bit is a one. The data is sent least
significant bit first so the bit pattern looks backwards in comparison to the way it
appears when written as a binary number. The data is not inverted even though RS-232
uses negative voltages to represent a logic one. Generally, when using the USART for
RS-232 communications, the signals must be inverted and level shifted through a
transceiver chip of some sort.
There are several registers used to control the USART and these will be discussed in
more detail later in the presentation. The SPBRG register allows the baud rate to be set.
The TXSTA and RCSTA registers are used to control transmission and reception but
there are some overlapping functions and both registers are always used. The TXREG
and RCREG registers are used write data to be transmitted and to read the received data.
The PIR1 and PIE1 registers contain the interrupt flag bits and enable bits to allow the
USART to generate interrupts. Interrupts are often used when the PIC is busy executing
code and data needs to be transmitted or received in the background. The interrupt flags
are not only used for interrupts but can also be read during normal operation to
determine whether data has been received or can be transmitted.

We will now look at some code examples for transmitting data with the USART. Before
a byte can be transmitted, a check should be made to ensure that the previous byte
written to the TXREG register does not get overwritten. Data is only moved from the
TXREG when the transmit shift register is empty so if a transmission is in progress,
data will stay in the TXREG until the previous data has been transmitted. The TXIF flag
gets set when the data in the TXREG gets moved into the transmit shift register so this
bit must be tested before new data is written to TXREG. The code tests the TXIF bit in
the PIR1 register and keeps looping back until the bit is detected high.

Department of Electrical and Electronics, ICET 16


Home Automation Using Power Line Communication

In some situations, the processor cannot spare the time to wait for the current
transmission to end and in this case the code might return to a main program instead of
waiting in a loop. After the TXIF bit has been tested to check that new data can be
transmitted, the data can be written. If a nine bit transmission is required, the ninth bit
must be written before the other eight bits are written to TXREG since writing to
TXREG will immediately initiate a transmission if the transmit shift register is empty.
In this example the ninth data bit is assumed to be in the least significant bit of a general
purpose register labeled Data Bits. A rotate instruction is used to get this bit into the
carry flag in the STATUS register which is then tested to set or clear the TX9D bit
which holds the ninth data bit.
This code can be simplified if the Data Bits register is in the same bank as the
TXSTA register. In this example they are assumed to be in different banks and the
STATUS register is used for intermediate storage of the bit since it can be accessed in
all banks. To initiate the transmission, data must be written to the TXREG. In this
example, the data to be transmitted is assumed to be in a general purpose register
labeled Data Byte. The code moves the data from Data Byte into the working register
and then into the TXREG register. This initiates the transmission.

We will now look at some code examples for receiving data with the USART.
Before reading the RCREG, a check should be made to determine whether new data has
been received. When there is new data in the RCREG register, the RCIF bit in the PIR1
register will be set. The code tests the RCIF bit in the PIR1 register and keeps looping
back until the bit is detected high. In many situations, the processor cannot spare the
time to wait for the next data to be received and there is also the danger of being stuck
in an endless loop if data cannot be received for some reason. It is usually better to
return to the main program instead of waiting in a loop. An alternative is to use
interrupts to detect when data has been received. After the RCIF bit has been tested to
check that new data has been received, the data can be read. If a nine bit reception is
being performed, the ninth bit in RX9D must be read before the other eight bits are read

Department of Electrical and Electronics, ICET 17


Home Automation Using Power Line Communication

from RCREG since reading from RCREG will immediately allow the next data in the
FIFO to be loaded into RCREG and the RX9D bit.
In this example it is assumed that the ninth data bit should be loaded into the
least significant bit of a general purpose register labeled Data Bits. Since the ninth data
bit, RX9D, is the least significant bit of RCSTA, a rotate instruction is be used to place
this bit into the carry flag of the STATUS register. The least significant bit of the Data
Bits register is then set or cleared depending on the carry flag. This code can be
simplified if the Data Bits register is in the same bank as the RCSTA register. The
STATUS register is used for intermediate storage since it can be accessed in all banks.
The method used to read the ninth data bit also depends on the particular application.
For example if this bit is to be used as another stop bit, it can tested directly and cause a
branch to an error handling routine if it is zero. After detecting that new data has been
received and reading the ninth data bit if required, the eight bits of data can be read
from the RCREG register.
In this example, it is assumed that the data received should be put into a general purpose
register labeled Data Byte. The code moves the data from the RCREG register into the
working register and then into the Data Byte register.

FIG 6.3 CONNECTION BETWEEN UART AND PIC

Department of Electrical and Electronics, ICET 18


Home Automation Using Power Line Communication

CHAPTER 7
X-10 TRANSMITTER

X-10 is a communication protocol that allows compatible products to


talk to each other using the existing electrical wiring in the home. Most X10 compatible
products are very affordable and the fact that they talk over existing wires in your home
means that no costly rewiring is necessary. Installation is simple, a transmitter plugs (or
wires) in at one location in the home and sends its control signal (on, off, dim, bright,
etc.) to a receiver which plugs (or wires) into another location in the home. X-10
protocol designed for sending signals over 120 VAC wiring. X-10 uses 120 kHz bursts
timed with the power line zero-crossings to represent digital information.

PIC microcontrollers can easily be used in conjunction with X-10 technology to create
home automation applications. The specific PIC microcontroller (MCU) used should be
selected based on RAM, ROM, operating frequency, peripheral, and cost requirements
of the particular application. The PIC16F877A was selected for this application because
of its versatility as a general purpose microcontroller, its FLASH program memory (for
ease of development), data EEPROM, and ample I/O.

The home controller application described in this application note allows


the user to program on and off times for up to sixteen devices, using a 2 x 16 liquid
crystal display and five push buttons. A built-in light sensor can be used to turn on
lights at dusk, and turn them off at dawn.

The home controller is designed to facilitate experimentation with home automation


using the PIC16F877A.

Department of Electrical and Electronics, ICET 19


Home Automation Using Power Line Communication

7.1 PIC 16F877A

The main part of the X-10 Transmitter is a microcontroller. The proposed


system uses the Microcontroller PIC 16F877A. It is a 40 pin 16 bit device.

7.1.1 Microcontroller Core Features:

• High-performance RISC CPU

• Only 35 single word instructions to learn

• All single cycle instructions except for program branches which are two cycle

• Operating speed: DC - 20 MHz clock input DC - 200 ns instruction cycle

• Up to 8K x 14 words of Flash Program Memory,

• Up to 368 x 8 bytes of Data Memory (RAM)

• Up to 256 x 8 bytes of EEPROM data memory

• Pinout compatible to the PIC16C73/74/76/77

• Interrupt capability (up to 14 internal/external interrupt sources)

• Eight level deep hardware stack

• Direct, indirect, and relative addressing modes

• Power-on Reset (POR)

• Power-up Timer (PWRT) and Oscillator Start-up Timer (OST)

• Watchdog Timer (WDT) with its own on-chip RC oscillator for reliable operation

• Programmable code-protection

• Power saving SLEEP mode

• Selectable oscillator options

Department of Electrical and Electronics, ICET 20


Home Automation Using Power Line Communication

• Low-power, high-speed CMOS EPROM/EEPROM technology

• Fully static design

• In-Circuit Serial Programming via two pins

• Only single 5V source needed for programming

• In-Circuit Debugging via two pins

• Processor read/write access to program memory

• Wide operating voltage range: 2.5V to 5.5V

• High Sink/Source Current: 25 mA

• Commercial and Industrial temperature ranges

• Low-power consumption:

- < 2 mA typical @ 5V, 4 MHz

- 20 A typical @ 3V, 32 kHz

- < 1 A typical standby current

7.1.2 Peripheral Features:

• Timer0: 8-bit timer/counter with 8-bit prescaler

• Timer1: 16-bit timer/counter with prescaler, can be incremented during sleep

via external crystal/clock

• Timer2: 8-bit timer/counter with 8-bit period register, pre scaler and post scaler

• Two Capture, Compare, PWM modules

• Capture is 16-bit, max. resolution is 12.5 ns, Compare is 16-bit, max.

resolution is 200ns, PWM max. resolution is 10-bit

Department of Electrical and Electronics, ICET 21


Home Automation Using Power Line Communication

• 10-bit multi-channel Analog-to-Digital converter

• Synchronous Serial Port (SSP) with SPI (Master Mode) and I2C (Master/Slave)

• Universal Synchronous Asynchronous Receiver Transmitter (USART/SCI)

with 9-bit address detection

• Parallel Slave Port (PSP) 8-bits wide, with external RD, WR and CS controls

• Brown-out detection circuitry for Brown-out Reset (BOR)

FIG 7.1: PIC 16F877A

Department of Electrical and Electronics, ICET 22


Home Automation Using Power Line Communication

7.2 HARDWARE DESCRIPTION

An overview of the home controller application hardware is shown in Figure.


The hardware functionality of X-10 circuitry can be divided into four functional blocks:

• Zero-crossing detector

• 120 kHz carrier detector

• 120 kHz signal generator

• Transformer less power supply

7.2.1 Zero-Crossing Detector

In X-10, information is timed with the zero-crossings of the AC power. A zero-


crossing detector is easily created by using the external interrupt on the RB0 pin and
just one external component, a resistor, to limit the current into the PIC MCU.

Input protection diodes clamp any voltage higher than VDD or lower than VSS.
Therefore, when the AC voltage is in the negative half of its cycle, the RB0 pin will be
clamped to VSS - 0.6V. This will be interpreted as a logic zero. When the AC voltage
rises above the input threshold, the logical value will become a „1‟.

In this application, RB0 is configured for external interrupts, and the input
buffer is a Schmitt trigger. This makes the input threshold 0.8 VDD = 4V on a rising
edge and 0.2 VDD = 1V on a falling edge.

Upon each interrupt, the Interrupt Edge Select bit within the OPTION_REG
register is toggled, so that an interrupt occurs on every zero-crossing. Using the
following equation, it is possible to calculate when the pin state will change relative to
the zero-crossing:

V = Vpk*sin(2*π*f*t), where Vpk = 165Vand f = 60 Hz

Department of Electrical and Electronics, ICET 23


Home Automation Using Power Line Communication

On a rising edge, RB0 will go high about 64 μs after the zero-crossing, and on a falling
edge, it will go low about 16 μs before the zero-crossing.

FIG 7.2 ZERO CROSSING DETECTOR

FIG 7.3 X-10 TRANSMISSION TIMING

Department of Electrical and Electronics, ICET 24


Home Automation Using Power Line Communication

7.2.2 120 KHz Carrier Detector

To receive X-10 signals, it is necessary to detect the presence of the 120 kHz
signal on the AC power line. This is accomplished with a decoupling capacitor, a high-
pass filter, a tuned amplifier, and an envelope detector. The components of the carrier
detector.

Because the impedance of a capacitor is: Zc = 1/(2*π*f*C), a 0.1 μF capacitor


presents a low impedance (13Ω) to the 120 kHz carrier frequency, but a high impedance
(26.5 KΩ) to the 60 Hz power line frequency. This high-pass filter allows the 120 kHz
signal to be safely coupled to the 60 Hz power line, and it doubles as the coupling stage
of the 120 kHz carrier generator described in the next section. Since the 120 kHz carrier
frequency is much higher than the 60 Hz power line frequency, it is straight forward to
design an RC filter that will pass the 120 kHz signal and completely attenuate the 60
Hz. A high-pass filter forms the first stage of the High-Pass Filter and Tuned Amplifier
Block.

For a simple high-pass filter, the -3 db breakpoint is:

ƒ3db = 1/(2*π*R*C). For C = 150 pF and R = 33 kΩ,

ƒ3db = 1/(2*π*150 pF *33 kΩ) = 32 kHz.

This ƒ3 db point assures that the 60 Hz signal is completely attenuated, while


the 120 kHz signal is passed through to the amplifier stages. Next, the 120 kHz signal is
amplified using a series of inverters configured as high gain amplifiers. The first two
stages are tuned amplifiers with peak response at 120 kHz. The next two stages provide
additional amplification. The amplified 120 kHz signal is passed through an envelope
detector, formed with a diode, capacitor, and resistor. The envelope detector output is
buffered through an inverter and presented to an input pin of the PIC.

Department of Electrical and Electronics, ICET 25


Home Automation Using Power Line Communication

Upon each zero-crossing interrupt, RC3 is simply checked within the 1 ms


transmission envelope to see whether or not the carrier is present. The presence or
absence of the carrier represents the stream of „1‟s and „0‟s that form the X-10
messages.

FIG 7.4 120 KHz CARRIER DETECTOR

7.2.3 120 KHz Carrier Generator

X-10 uses 120 kHz modulation to transmit information over 60 Hz power lines.
It is possible to generate the 120 kHz carrier with an external oscillator circuit. A single
I/O pin would be used to enable or disable the oscillator circuit output. However, an
external oscillator circuit can be avoided by using one of the PIC MCU‟s CCP modules.

The CCP1 module is used in PWM mode to produce a 120 kHz square-wave
with a duty cycle of 50%. Because X-10 specifies the carrier frequency at 120 kHz (+/-
2 kHz), the system oscillator is chosen to be 7.680 MHz, in order for the CCP to
generate precisely 120 kHz. After initialization, CCP1 is continuously enabled, and
the TRISC bit for the pin is used to gate the PWM output. When the TRISC bit is set,
the pin is an input and the 120 kHz signal is not presented to the pin. When the TRISC
bit is clear, the pin becomes an output and the 120 kHz signal is coupled to the AC
power line through a transistor amplifier and capacitor. Since the impedance of a
capacitor is Zc = 1/(2*π*f*C), a 0.1 μF capacitor presents a low impedance to the 120
kHz carrier frequency, but a high impedance to the 60 Hz power line frequency. This
high-pass filter allows the 120 kHz signal to be safely coupled to the 60 Hz power line,
and it doubles as the first stage of the 120 kHz carrier detector, described in the
previous section.

Department of Electrical and Electronics, ICET 26


Home Automation Using Power Line Communication

To be compatible with other X-10 receivers, the maximum delay from the zero-
crossing to the beginning of the X-10 envelope should be about 300 μs. Since the zero-
crossing detector has a maximum delay of approximately 64 μs, the firmware must take
less than 236 μs after detection of the zero-crossing to begin transmission of the 120
kHz envelope.

FIG 7.5 120 kHz CARRIER GENERATOR

Department of Electrical and Electronics, ICET 27


Home Automation Using Power Line Communication

CHAPTER 8
POWER LINE COMMUNICATION

Power line communication (PLC) carries data on a conductor that is also


used simultaneously for AC electric power transmission or electric power distribution to
consumers. It is also known as power line carrier, power line digital subscriber
line (PDSL), mains communication, power line telecom (PLT), power line
networking (PLN), and broadband over power lines (BPL).

A wide range of power line communication technologies are needed for different
applications, ranging from home automation to Internet access. Most PLC technologies
limit themselves to one type of wires (such as premises wiring within a single building),
but some can cross between two levels (for example, both the distribution network and
premises wiring). Typically transformers prevent propagating the signal, which requires
multiple technologies to form very large networks. Various data rates and frequencies
are used in different situations. A number of difficult technical problems are common
between wireless and power line communication, notably those of spread
spectrum radio signals operating in a crowded environment. Radio interference, for
example, has long been a concern of amateur radio groups.

Typically home-control power line communication devices operate by


modulating in a carrier wave of between 20 and 200 KHz into the household wiring at
the transmitter. The carrier is modulated by digital signals. Each receiver in the system
has an address and can be individually commanded by the signals transmitted over the
household wiring and decoded at the receiver. These devices may be either plugged into
regular power outlets, or permanently wired in place. Since the carrier signal may
propagate to nearby homes (or apartments) on the same distribution system, these
control schemes have a "house address" that designates the owner. A popular
technology known as X10 has been used since the 1970s.

Department of Electrical and Electronics, ICET 28


Home Automation Using Power Line Communication

CHAPTER 9
X 10 RECIEVER

X 10 receiver receives signals which is transmitted by the X 10


transmitter. X 10 receiver is connected to any of the plug sockets in the home. The
devices which are needed to be controlled is connected to the X 10 receiver through
relays. Relays are used to ON or OFF the devices. The transmitted signals from X 10
transmitter are provided to the power line in the home, then this signals are identified by
the receiver and processed according to the program written in the PIC present in the
receiver. All the data send by the transmitter is framed with start bit and stop bit. The
receiver first check the zero crossing because the transmitter sends the data in zero
crossing of 50 Hz power line. Then compare the received bits initially with start code. If
start code received is correct, store the remaining bits received after start code. Then
check whether the stored bit sequence match with the house code. If house code is also
correct compare the device code to select the device. Now compare the function code to
select the function. Then the devices will work according to the function. The receiver
also given the status of various devices connected to it to the transmitter section through
power line.

The X 10 receiver consist of various components

1. PIC 16F877A
2. Schmitt wave shape generator
3. Tuned amplifier
4. Band pass filter
5. Attenuator
6. Zero crossing detector
7. External interrupts

Department of Electrical and Electronics, ICET 29


Home Automation Using Power Line Communication

9.1 SCHMITT WAVEFORM GENERATORS

Simple Waveform Generators can be constructed using basic Schmitt


trigger action inverters such as the TTL 74LS14. This method is by far the easiest way
to make a basic astable waveform generator. When used to produce clock or timing
signals, the astable multivibrator must produce a stable waveform that switches quickly
between its "HIGH" and "LOW" states without any distortion or noise, and Schmitt
inverters do just that.

We know that the output state of a Schmitt inverter is the opposite or inverse to
that of its input state, (NOT gate principles) and that it can change state at different
voltage levels giving it "hysteresis". Schmitt inverters use a Schmitt trigger action that
changes state between an upper and a lower threshold level as the input voltage signal
increases and decreases about the input terminal. This upper threshold level "sets" the
output and the lower threshold level "resets" the output which equates to a logic "0" and
a logic "1" respectively for an inverter. Consider the circuit below.

9.1.1 Schmitt Inverter Waveform Generator

This simple waveform generator circuit consists of a single TTL 74LS14


Schmitt inverter logic gate with a capacitor, C connected between its input terminal and
ground, ( 0v ) and the positive feedback required for the circuit to oscillate being
provided by the feedback resistor, R.

So how does it work?. Assume that the charge across the capacitors plates is
below the Schmitt's lower threshold level of 0.8 volt (Datasheet value). This therefore
makes the input to the inverter at a logic "0" level resulting in a logic "1" output level
(inverter principals). One side of the resistor R is now connected to the logic "1" level (
+5V ) output while the other side of the resistor is connected to the capacitor, C which
is at a logic "0" level (0.8v or below). The capacitor now starts to charge up in a
positive direction through the resistor at a rate determined by the RC time constant of
the combination.

Department of Electrical and Electronics, ICET 30


Home Automation Using Power Line Communication

When the charge across the capacitor reaches the 1.6 volt upper threshold level
of the Schmitt trigger (datasheet value) the output from the Schmitt inverter rapidly
changes from a logic level "1" to a logic level "0" state and the current flowing through
the resistor changes direction. This change now causes the capacitor that was originally
charging up through the resistor, R to begin to discharge itself back through the same
resistor until the charge across the capacitors plates reaches the lower threshold level of
0.8 volts and the inverters output switches state again with the cycle repeating itself
over and over again as long as the supply voltage is present.

So the capacitor, C is constantly charging and discharging itself during each


cycle between the inputs upper and lower threshold levels of the Schmitt inverter
producing a logic level "1" or a logic level "0" at the inverters output. However, the
output waveform is not symmetrical producing a duty cycle of about 33% or 1/3 as the
mark-to-space ratio between "HIGH" and "LOW" is 1:2 respectively due to the input
gate characteristics of the TTL inverter.

The value of the feedback resistor, ( R ) MUST also be kept low to below 1kΩ
for the circuit to oscillate correctly, 220R to 470R is good, and by varying the value of
the capacitor, C to vary the frequency. Also at high frequency levels the output
waveform changes shape from a square shaped waveform to a trapezoidal shaped
waveform as the input characteristics of the TTL gate are affected by the rapid charging
and discharging of the capacitor.

9.2 TUNED AMPLIFIER

A tuned amplifier is a type of electronic device designed to amplify


specific ranges of electrical signals while ignoring or blocking others. It finds common
use in devices that work with radio frequency signals such as radios, televisions, and
other types of communication equipment; however, it also can be useful in many other
applications. Tuned amplifiers can be found in aircraft autopilot systems, audio systems,
scientific instruments, spacecraft, or anywhere else when there is a need to select and
amplify specific electronic signals while ignoring others.

Department of Electrical and Electronics, ICET 31


Home Automation Using Power Line Communication

The most common tuned amplifiers an average person interacts with can be
found in home or portable entertainment equipment, such as FM stereo receivers. An
FM radio has a tuned amplifier that allows listening to only one radio station at a time.
When the knob is turned to change the station, it adjusts a variable capacitor, inductor,
or similar device inside the radio, which alters the inductive load of the tuned amplifier
circuit. This retunes the amplifier to allow a different specific radio frequency to be
amplified so a different radio station can be heard.

All radio-based communication devices, including stereos, televisions, and cell


phones, simultaneously receive all signals present in a given area. The tuned amplifier
within the device is what allows only one specific frequency to be amplified, through a
process called bandpass filtering. In bandpass filtering, the electronics are configured in
such a way that they only allow a specific band of frequencies to pass through the filter.
In some devices, such as FM radios, the filter is adjustable. In others, such as cell
phones or computer WiFi networks, the filter is fixed to a single specific frequency
range.

Fixed frequency tuned amplifiers can also be found in audio processing


equipment such as graphic equalizers. For example, in a five-band graphic equalizer,
there are five separate controls. Each of these controls manipulates an individual tuned
amplifier. In this case, each of the bandpass filters in the tuned amplifiers is fixed,
allowing a distinct range of sound frequencies to pass through each of the controls.
Adjusting the control for one of these bands of sound frequency adjusts the amount of
amplification for the band, not the actual frequency range of the band itself.

Tuned amplifiers can have adjustable bandpass filters, adjustable amplifiers,


both, or neither. The function that identifies a tuned amplifier is that the signals
amplified are limited, or tuned, to a specific range or band of frequencies. The ability to
be configured in so many variations for so many different purposes has made the tuned
amplifier a mainstay in almost all sophisticated electronic devices that exist.

Department of Electrical and Electronics, ICET 32


Home Automation Using Power Line Communication

9.3 BAND PASS FILTER

A band pass filter is an electronic device or circuit that allows signals between
two specific frequencies to pass, but that discriminates against signals at other
frequencies. Some band pass filters require an external source of power and employ
active components such as transistors and integrated circuits; these are known as active
band pass filters. Other band pass filters use no external source of power and consist
only of passive components such as capacitors and inductors; these are called passive
band pass filters.

Band pass filters are used primarily in wireless transmitters and receivers. The
main function of such a filter in a transmitter is to limit the bandwidth of the output
signal to the minimum necessary to convey data at the desired speed and in the desired
form. In a receiver, a band pass filter allows signals within a selected range of
frequencies to be heard or decoded, while preventing signals at unwanted frequencies
from getting through. A band pass filter also optimizes the signal-to-noise
ratio (sensitivity) of a receiver.

In both transmitting and receiving applications, well-designed band pass filters,


having the optimum bandwidth for the mode and speed of communication being used,
maximize the number of signals that can be transferred in a system, while minimizing
the interference or competition among signals.

9.4 ATTENUATOR

An attenuator is an electronic device that reduces the power of


a signal without appreciably distorting its waveform. it is effectively the opposite of
an amplifier, though the two work by different methods. While an amplifier
provides gain, an attenuator provides loss, or gain less than 1.

Attenuators are usually passive devices made from simple voltage divider
networks. Switching between different resistances forms adjustable stepped attenuators
and continuously adjustable ones using potentiometers. For higher frequencies precisely
matched low VSWR resistance networks are used.

Department of Electrical and Electronics, ICET 33


Home Automation Using Power Line Communication

Fixed attenuators in circuits are used to lower voltage, dissipate power, and to
improve impedance matching. In measuring signals, attenuator pads or adaptors are
used to lower the amplitude of the signal a known amount to enable measurements, or
to protect the measuring device from signal levels that might damage it. Attenuators are
also used to 'match' impedances by lowering apparent SWR.

9.5 ZERO CROSSING DETECTOR

In X-10, information is timed with the zero-crossings of the AC power.


A zero-crossing detector is easily created by using the external interrupt on the RB0 pin
and just one external component, a resistor, to limit the current into the PIC MCU.

Input protection diodes clamp any voltage higher than VDD or lower than VSS.
Therefore, when the AC voltage is in the negative half of its cycle, the RB0 pin will be
clamped to VSS - 0.6V. This will be interpreted as a logic zero. When the AC voltage
rises above the input threshold, the logical value will become a „1‟.

In this application, RB0 is configured for external interrupts, and the input
buffer is a Schmitt trigger. This makes the input threshold 0.8 VDD = 4V on a rising
edge and 0.2 VDD = 1V on a falling edge.

Upon each interrupt, the Interrupt Edge Select bit within the OPTION_REG
register is toggled, so that an interrupt occurs on every zero-crossing. Using the
following equation, it is possible to calculate when the pin state will change relative to
the zero-crossing:

V = Vpk*sin(2*π*f*t), where Vpk = 165Vand f = 60 Hz

On a rising edge, RB0 will go high about 64 μs after the zero-crossing, and on a
falling edge, it will go low about 16 μs before the zero-crossing.

Department of Electrical and Electronics, ICET 34


Home Automation Using Power Line Communication

To receive X-10 signals, it is necessary to detect the presence of the 120 kHz signal on
the AC power line. This is accomplished with a decoupling capacitor, a high-pass filter,
a tuned amplifier, and an envelope detector. The components of the carrier detector.

Because the impedance of a capacitor is: Zc = 1/(2*π*f*C), a 0.1 μF


capacitor presents a low impedance (13Ω) to the 120 kHz carrier frequency, but a high
impedance (26.5 kΩ) to the 60 Hz power line frequency. This high-pass filter allows the
120 kHz signal to be safely coupled to the 60 Hz power line, and it doubles as the
coupling stage of the 120 kHz carrier generator described in the next section. Since the
120 kHz carrier frequency is much higher than the 60 Hz power line frequency, it is
straight forward to design an RC filter that will pass the 120 kHz signal and completely
attenuate the 60 Hz. A high-pass filter forms the first stage of the High-Pass Filter and
Tuned Amplifier Block.

For a simple high-pass filter, the -3 db breakpoint is:

ƒ3 db = 1/(2*π*R*C). For C = 150 pF and R = 33 kΩ,

ƒ3 db = 1/(2*π*150 pF *33 kΩ) = 32 kHz.

This ƒ3 db point assures that the 60 Hz signal is completely attenuated,


while the 120 kHz signal is passed through to the amplifier stages. Next, the 120 kHz
signal is amplified using a series of inverters configured as high gain amplifiers. The
first two stages are tuned amplifiers with peak response at 120 kHz. The next two stages
provide additional amplification. The amplified 120 kHz signal is passed through an
envelope detector, formed with a diode, capacitor, and resistor. The envelope detector
output is buffered through an inverter and presented to an input pin of the PIC.

Upon each zero-crossing interrupt, RC3 is simply checked within the 1


ms transmission envelope to see whether or not the carrier is present. The presence or
absence of the carrier represents the stream of „1‟s and „0‟s that form the X-10
messages.

Department of Electrical and Electronics, ICET 35


Home Automation Using Power Line Communication

CHAPTER 10
X10 WAVES

FIG 10.1 TRANSMISSION

FIG 10.2 120 KHz SIGNAL

FIG 10.3 TRANSISTOR OUTPUT WITH NO DATA

Department of Electrical and Electronics, ICET 36


Home Automation Using Power Line Communication

FIG 10.4 TRANSISTOR O/P WITH DATA

FIG 10.5 RECIEVER UNED AMPLIFIER O/P

FIG 10.6 RECIEVER AMPLIFIER O/P

Department of Electrical and Electronics, ICET 37


Home Automation Using Power Line Communication

FIG 10.7 ENVELOP DETECTOT O/P

FIG 10.8 RECEIVED SIGNAL AFTER PROCESSING

FIG 10 9 RECIEVER HIGH-PASS FILTER O/P

Department of Electrical and Electronics, ICET 38


Home Automation Using Power Line Communication

CHAPTER 11
TCP/IP PROTOCOL

TCP/IP is everywhere. It‟s not something physical that can only be in


one place at a time. It's a set of protocols that allows anyone with a computer, modem,
and an Internet service provider to access and share information over the Internet. In
fact, users of AOL's Instant Messenger service and ICQ (also owned by AOL) account
for over 750 million messages per day. This is an incredible amount of traffic, and most
of it is transmitted over the Internet.

It is TCP/IP that allows these millions of transactions per day to occur (it's actually well
into the billions because many more things are going on than email and instant
messaging), mostly without a hitch. And it shows no signs of letting up anytime soon.
TCP/IP is a stable, well-established, complete set of protocols, and this chapter takes a
close look at exactly what makes it tick.

Both TCP and IP, two separate protocols that work hand-in-hand, perform chores that
manage and guide the general mobility of data packets over the Internet. They both use
special headers that define each packet's contents and, if there is more than one, how
many others should be expected. TCP concerns itself with making the connections to
remote hosts. IP, on the other hand, deals with addressing so that messages are directed
to where they are intended. The following section takes a look at the benefits of TCP/IP.

11.1 THE BENEFITS OF USING TCP/IP

TCP/IP enables cross-platform, or heterogeneous, networking. For example, a


Windows NT/2000 network could contain Unix and Macintosh workstations or even
networks mixed in it. TCP/IP also has the following characteristics:

 Good failure recovery

 The ability to add networks without interrupting existing services

Department of Electrical and Electronics, ICET 39


Home Automation Using Power Line Communication

 High error-rate handling

 Platform independence

 Low data overhead

Because TCP/IP was originally designed for Department of Defense–related purposes,


what we now call features or characteristics were actually design requirements. The
idea behind "Good Failure Recovery" was that if a portion of the network were disabled
during an incursion or attack, its remaining pieces would still be able to function fully.
Likewise is the capability of adding entire networks without any disruption to the
services already in place. The ability to handle high error rates was built in so that if a
packet of information got lost using one route, there would be a mechanism in place to
ensure that it would reach its destination using another route. Platform independence
means that the networks and clients can be Windows, Unix, Macintosh, or any other
platform or combination thereof. The reason TCP/IP is so efficient lies in its low
overhead. Performance is key for any network. TCP/IP is unmatched in its speed and
simplicity.

Department of Electrical and Electronics, ICET 40


Home Automation Using Power Line Communication

CHAPTER 12
VISUAL BASIC

It is a high level programming language which evolved from the earlier


DOS version called BASIC.BASIC means Beginners' All-purpose Symbolic Instruction
Code. It is a very easy programming language to learn. The code looks a lot like
English Language. Different software companies produced different versions of
BASIC, such as Microsoft QBASIC, QUICKBASIC, GWBASIC, and IBM BASICA
and so on. However, people prefer to use Microsoft Visual Basic today, as it is a well-
developed programming language and supporting resources are available everywhere.
Visual basic is a visual and events driven Programming Language. In VB, you just need
to drag and drop any graphical object anywhere on the form, and we can change its
color any time using the properties windows. On the other hand, because the user may
click on a certain object randomly, so each object has to be programmed independently
to be able to response to those actions (events). Therefore, a VB Program is made up of
many subprograms, each has its own program code, and each can be executed
independently and at the same time each can be linked together in one way or another.

12.1 FEATURES OF VISUAL BASIC

The language not only allows programmers to create simple GUI


applications, but can also develop complex applications. Programming in VB is a
combination of visually arranging components or controls on a form, specifying
attributes and actions of those components, and writing additional lines of code for
more functionality. Since default attributes and actions are defined for the components,
a simple program can be created without the programmer having to write many lines of
code. Performance problems were experienced by earlier versions, but with faster
computers and native code compilation this has become less of an issue. Forms are
created using drag-and-drop techniques. A tool is used to place controls (e.g., text
boxes, buttons, etc.) on the form (window).

Department of Electrical and Electronics, ICET 41


Home Automation Using Power Line Communication

Controls have attributes and event handlers associated with them.


Default values are provided when the control is created, but may be changed by the
programmer. Many attribute values can be modified during run time based on user
actions or changes in the environment, providing a dynamic application.

FIG 12.1 VISUAL BASIC NEW PROJECT WINDOW

You can choose to start a new project, open an existing project or select a list of
recently opened programs. A project is a collection of files that make up your
application. There are various types of applications that we could create; however, we
shall concentrate on creating Standard EXE programs (EXE means executable
program). Now, click on the Standard EXE icon to go into the actual Visual Basic 6
programming environment.

Department of Electrical and Electronics, ICET 42


Home Automation Using Power Line Communication

12.2 THE DEVELOPMENT ENVIRONMENT OR FORM WINDOW

Learning the ins and outs of the Development Environment before you learn visual
basic is somewhat like learning for a test you must know where all the functions belong
and what their purpose is. First we will start with labeling the development
environment.

FIG 12.2 DESIGN FORM

The above diagram shows the development environment with all the important points
labeled. Many of Visual basic functions work similar to Microsoft word e.g. the Tool
Bar and the tool box is similar to other products on the market which work off a single
click then drag the width of the object required. The Tool Box contains the control you
placed on the form window. All of the controls that appear on the Tool Box controls on
the above picture never runs out of controls as soon as you place one on the form
another awaits you on the Tool Box ready to be placed as needed.

Department of Electrical and Electronics, ICET 43


Home Automation Using Power Line Communication

12.3 PROPERTIES WINDOW

The Properties Window is docked under the Project Explorer window. The Properties
Window exposes the various characteristics of selected objects. Each and every form in
an application is considered an object. Now, each object in Visual Basic has
characteristics such as color and size. Other characteristics affect not just the
appearance of the object but the way it behaves too. All these characteristics of an
object are called its properties. Thus, a form has properties and any controls placed on it
will have properties too. All of these properties are displayed in the Properties Window.

FIG 12.3 PROPERTIES OF FORM

12.4 THE DEFAULT LAYOUT OR FORM LAYOUT WINDOW

When we start Visual Basic, we are provided with a VB project. A VB project is a


collection of the modules and files like Global module (that contains declaration and
procedures), Form module (that contains the graphic elements of the VB application
along with the instruction), General module (that generally contains general-purpose
instructions not pertaining to anything graphic on-screen), Class module (that contains
the defining characteristics of a class, including its properties and methods), Resource
files (that allows you to collect all of the texts and bitmaps for an application in one
place)

Department of Electrical and Electronics, ICET 44


Home Automation Using Power Line Communication

12.5 TOOL BOX

You may have noticed that when you click on different controls the Properties Window
changes slightly this is due to different controls having different functions. Therefore
more options are needed for example if you had a picture then you want to show an
image. But if you wanted to open a internet connection you would have to fill in the
remote host and other such settings. When you use the command ( ) you will find that a
new set of properties come up the following will provide a description and a property.

FIG 12.4 TOOL BOX

Department of Electrical and Electronics, ICET 45


Home Automation Using Power Line Communication

CHAPTER 13
ALGORITHM

13.1 MAIN NODE

1. Initialize the ports of PIC.


2. Initialize USART with 9600 baud rate.
3. Initialize GPRS modem.
4. Read data from Internet using SIM900 Module.
5. Data is captured using UART.
6. Data is sent to PIC at 9600 Baud rate.
7. Continuously checks the pins.
8. Set another pin according to the logic.
9. The data is sent and received from Power line from the respective X10 Receiver
from the respective X10 Receivers.

13.2 SUB NODE

13.2.1 Program Flow for Transmitter

1. Do the basic initializations- PWM, External Interrupt and Basic Variables.


2. Configure RB7, RB6, RB5 and RB4 as house select, device select, status and
send keys.
3. House and Device number given is incremented after the selection of desired
house & device number.
4. Display the functions ON, OFF, ON ALL, OFF ALL when status key RB5 is
toggled and output the corresponding PWM when send key RB4 is pressed.

Department of Electrical and Electronics, ICET 46


Home Automation Using Power Line Communication

13.2.2 Program Flow for Receiver

1. Do the basic initializations – Configure RE2 as I/P, RB0-RB4 as o/p.


2. Check RE2 at each zero crossing for 1millisec.
3. Compare the received bits initially with start code.
4. If start code received is correct, store the remaining bits received after start
code.
5. Check whether the stored bit sequence match with the house-address code.
6. If house code is correct compare the device code to select the device.
7. Then compare the function code to select the function.
If function is ON output high to corresponding RB pin.
If function is OFF output low to corresponding RB pin.

Department of Electrical and Electronics, ICET 47


Home Automation Using Power Line Communication

CHAPTER 14
FLOWCHART

Control signal

Department of Electrical and Electronics, ICET 48


Home Automation Using Power Line Communication

CHAPTER 15
ADVANTAGES & DISADVANTAGES

15.1 ADVANTAGES

1. Can be accessed from any PC having Internet connection.


2. No need to install extra control cables.
3. Appliances can be connected to network simply by plugging them in to the
nearest wall socket
4. Easy to modify.
5. Low installation cost.
6. It is highly efficient. It is becoming easier to reduce the bills of electricity by
using the pro-active based home-automated appliances.
7. It is less time consuming.
8. Safe and comfortable.

15.2 DISADVANTAGES

1. High power consumption in the homes.


2. Crippled people and sick patients cannot operate some of the home electrical
appliances.
3. High cost of design.
4. It uses timers, and cannot be controlled as one wish.
5. It is limited to the type of appliances being used.
6. If a fault occurs in a substantial part of the system will block the entire network
and all functions would be canceled.
7. Depending on the number of systems that have connected may slow down
much, since the transmission speed is affected if large amounts of data occur.

Department of Electrical and Electronics, ICET 49


Home Automation Using Power Line Communication

CHAPTER 16
FUTURE SCOPE

FIG 16.1

Department of Electrical and Electronics, ICET 50


Home Automation Using Power Line Communication

CAHPTER 17
CONCLUSION

Department of Electrical and Electronics, ICET 51


Home Automation Using Power Line Communication

REFRENCES

Department of Electrical and Electronics, ICET 52

You might also like