Home Automation Using Power Line Communication
Home Automation Using Power Line Communication
Home Automation Using Power Line Communication
CHAPTER 1
INTRODUCTION
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.
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.
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.
CHAPTER 3
WHY HOME AUTOMATION?
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.
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).
CHAPTER 5
GENERAL PACKET RADIO SERVICE
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.
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.
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.
CHAPTER 6
CONNECTING CIRCUITS
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
6.1.2 Interfaces
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.
DATA FORMAT:
Data : 5, 6, 7 or 8 bits
Parity : Odd, even, mark or space (not used with 8-bit data)
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 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
6.3 USART
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.
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
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.
CHAPTER 7
X-10 TRANSMITTER
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.
• All single cycle instructions except for program branches which are two cycle
• Watchdog Timer (WDT) with its own on-chip RC oscillator for reliable operation
• Programmable code-protection
• Low-power consumption:
• Timer2: 8-bit timer/counter with 8-bit period register, pre scaler and post scaler
• Synchronous Serial Port (SSP) with SPI (Master Mode) and I2C (Master/Slave)
• Parallel Slave Port (PSP) 8-bits wide, with external RD, WR and CS controls
• Zero-crossing detector
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:
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.
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.
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.
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.
CHAPTER 8
POWER LINE COMMUNICATION
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.
CHAPTER 9
X 10 RECIEVER
1. PIC 16F877A
2. Schmitt wave shape generator
3. Tuned amplifier
4. Band pass filter
5. Attenuator
6. Zero crossing detector
7. External interrupts
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.
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.
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.
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.
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.
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.
9.4 ATTENUATOR
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.
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.
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:
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.
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.
CHAPTER 10
X10 WAVES
CHAPTER 11
TCP/IP PROTOCOL
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.
Platform independence
CHAPTER 12
VISUAL BASIC
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.
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.
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.
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.
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.
CHAPTER 13
ALGORITHM
CHAPTER 14
FLOWCHART
Control signal
CHAPTER 15
ADVANTAGES & DISADVANTAGES
15.1 ADVANTAGES
15.2 DISADVANTAGES
CHAPTER 16
FUTURE SCOPE
FIG 16.1
CAHPTER 17
CONCLUSION
REFRENCES