You are on page 1of 69

PROJECT REPORT ON

AUTOMATION USING POWER LINE


COMMUNICATION
SUBMITTED BY:

Prabhakaran Ashwin V
Sadhnani Tarun I
Shah Aesha A
Thakrani Manish G

UNDER GUIDANCE OF

PROF. T.R PAUL

DEPARTMENT OF ELECTRONICS AND


TELECOMMUNICATION
WATUMULL INSTITUTE OF ELECTRONICS
ENGINEERING AND COMPUTER
TECHNOLOGY
UNIVERSITY OF MUMBAI
2009-2010

PROJECT REPORT ON
AUTOMATION USING POWER LINE
COMMUNICATION
Submitted in partial fulfilment of requirements for the degree course of
BACHELOR OF ENGINEERING IN ELECTRONICS AND
TELECOMMUNICATION [EXTC]
By
Prabhakaran Ashwin V
Sadhnani Tarun I
Shah Aesha A
Thakrani Manish G

Under the noted guidance of

Prof. (Mr.) T R Paul


University Of Mumbai
2009-2010
DEPARTMENT OF EXTC ENGG.
Watumull Institute Of Electronics Engineering
And Computer Technology,
2

Worli.

ACKNOWLEDGEMENT
We acknowledge with sincere gratitude, the whole hearted support
both technically and morally that we have received from our HOD,
PROF. (MRS.) SUNITA SHARMA.
We would like to thank for the sincere appreciation and
encouragement that we have received during the launching of this
project from our GUIDE, Mr. T.R PAUL. We also thank the lab
technician MISHRA SIR and other non teaching staff of our
EXTC department for their help during the development of this
project.
We are thankful to our colleagues and all those who helped us
knowingly or unknowingly to make our project a success.
We have realized that the efficiency of team work is indeed more
than an individual effort. The guidance of our guide motivated us to
work harder under all circumstances.
SUBMITTED BY:

Prabhakaran Ashwin V
Sadhnani Tarun I
Shah Aesha A
Thakrani Manish G

TABLE OF CONTENS
1.

2.

3.

4.
5.
6.
7.
8.
9.

Introduction.
1.1 Power Line Communication.
1.2 Modern Applications and Prospects.
1.3 Project Aim.
Protocols.
2.1 Existing Industry Protocols used in PLC
2.2 X10
2.2.1 Overview.
2.2.2 Protocol.
2.2.3 Sequence of Signals.
2.2.4 Disadvantages.
2.3 MODBUS
2.3.1 Overview.
2.3.2 MODBUS Message Structure.
2.3.3 MODBUS Serial Transmission Modes.
2.3.4 MODBUS Addressing.
2.3.5 MODBUS Function Codes.
2.3.6 Disadvantages.
Circuit Design
3.1 Power line as Communication Channel.
3.2 Digital Modulation.
3.3 Transmitter Structure.
3.4 Power Line Interface (Isolation Circuit):
3.5 Receiver Structure.
System Implementation - The Transmitter.
4.1 Hardware.
4.2 Software.
System Implementation - The Receiver.
5.1 Hardware
5.2 Software
Cost of Project.
Conclusion.
Bibliography
Appendix.

11

22

26
34
42
43
44
45

List of Figures
Figure 1: Electric power transmission scheme
Figure 2: Power Line Waveform with Zero Crossing for trans-receiving X10 data
Figure 3: Receiver Sensing Zero Crossing Figure 5: Start Code.
Figure 4: Zero crossing
Figure 5: Start Code.
Figure 6: Letter Code.
Figure 7: Number Code.
Figure 8: Transmission of Address Data.
Figure 9: Address Code and Command Code separation.
Figure 10: Power Line Phases and X-10 pulse.
Figure 11: MODBUS message structure.
Figure 13: Device and MODBUS address ranges
Figure 14: MODBUS Function Codes
Figure 15: Power Line Communication Channel
Figure 16: Binary Amplitude Shift Keying Waveform
Figure 17: A BFSK waveform derived from a Binary message.
Figure 18: The Transmitter Circuit diagram
Figure 19: The Receiver Circuit Diagram
Figure 20: The Power Line Communication System

Abstract
In this project tilted power line communication we discuss how the existing power line
network operating at 230V (50 Hz) can be used for digital data transfer. The transmitter
microcontroller is used to generate the digital carrier and the binary codes which control
which devices are actuated at the receiving end. The receiver microcontroller receives the
binary codes and controls the appropriate devices. The coupling circuitry and the
isolation mechanism used at high voltages are also specified. Finally the applications of
the project and the future scope of the technology are specified.

1. INTRODUCTION

1. INTRODUCTION
Establishing an efficient and rapid means of communication between devices constituting
a network has remained the main research initiative of communication engineers for a
long time now. The concept initially started with an aim of establishing a communication
link between two devices .Slowly the devices constituting the network multiplied until we
faced the task of interfacing thousands of devices together to a common communication
channel. As the frequencies to be used changed and the cost of establishing network links
increased, researchers began the work of finding new media and new technologies which
could enable communication in a network at high speeds and low cost.
Initially when devices were connected dedicated communication lines were laid down for
communication. Miles and miles of wire were laid to enable communication over longer
distances. Hence the cost continued to remain a concern. Hence scientists came up with
the idea of using already established networks, such as the one carrying AC power to our
household, as a communication pathway. This eliminated the need to establish separate
dedicated networks and hence resulted in reduced costs.
1.1 Power Line Communication : Power Line Communications (PLC) is the use of
existing electrical cables to transport data. It is a scheme in which data is transmitted over
a conductor used for electric power transmission. Here a modulated carrier signal is
superimposed on the wiring system. Electrical power is transmitted over high voltage
transmission lines, distributed over medium voltage, and used inside buildings at lower
voltages. Power line communications can be applied at each stage.

Figure 1: Electric power transmission scheme


8

Different types of power line communications use different frequency bands, depending
on the signal transmission characteristics of the power wiring used. Since the power
wiring system was originally intended for transmission of AC power, in conventional use,
the power wire circuits have only a limited ability to carry higher frequencies. The
propagation problem is a limiting factor for each type of power line communications.
1.2 Modern Applications & Prospects
Power Line Communications (PLC) has been around for a very long time. In this section
we would also like to discuss some major applications driving the Power Line
Communication (PLC) technology. They are:
Automatic Meter Reading (AMR) For the readings of Electricity, Water, Gas
or any other meters in the customer premises to be transmitted to a central base station for
further processing, billing etc. With tens of millions of meters to be read periodically and
regularly, this alone represents an enormous market.

Home automation - Power line communications technology can use the


household electrical power wiring as a transmission medium. INSTEON, X10 and
MODBUS are the two most popular de facto standards using power line communications
for home control. This is a technique used in home automation for remote control of
lighting and appliances without installation of additional control wiring.

Distribution Automation, and Supervisory Control and Distribution


Automation (DA and SCADA) This is for the utility companies themselves to monitor
and control the Power Distribution Process.

1.3 Project Aim


The project aims to thoroughly explore the theoretical and practical aspects of power line
communications (PLC) techniques. To this end a number of specific goals were proposed
at the start of the project.
To gain a detailed knowledge of the challenges faced by PLC techniques-why
they are not a widespread communications method.

To research and design a working PLC system.

To use the design and implement a power line carrier communications system that
connects two microprocessor/micro-controller kits as also two personal computers. The
devices should be able to transfer data using the power lines as their only link of
communication.

2. PROTOCOLS

2. PROTOCOLS
10

When establishing a communication network we first decide what transmission medium is


to be used and then we decide the communication protocol to be used. A communications
protocol is the set of standard rules for data
representation, signaling, authentication and error detection required to send information
over a channel. The following are the pre-requisites of a communications protocol:
Transmission data rate and reception data rate should be same

Format of the data packet as sent by the transmitter should be understood by the
receiver
Transmitters and receivers should use compatible coding and decoding schemes

respectively
Both the transmitter and receiver should use the same error detection algorithm

2.1 Existing Industry Standards in PLC

Some of the most commonly used automation protocols used in the industry today for
wired communication are given below:

X 10
MODBUS
C-Bus
KNX
INSTEON
We give a detailed description of the X10 and MODBUS protocols along with a
comparison of their features in the following section.
2.2 X10
2.2.1 Overview: X10 is an international and open industry standard
for communication among electronic devices used for home automation, also known
as domotics. It primarily uses power line wiring for signaling and control, where the
signals involve brief radio frequency bursts representing digital information.
11

Household electrical wiring the same which powers lights and appliances is used to
send digital data between X10 devices.
2.2.2 Protocol: This digital data is encoded onto a power line carrier which is transmitted
as bursts during the relatively quiet zero crossings of the AC alternating
current waveform. One bit is transmitted at each zero crossing.

Figure 2: Power Line Waveform with Zero Crossing for trans-receving X10 data

A receiver opens its receive "window" twice each sine wave i.e. 120 times each
second.

12

Figure 3: Receiver Sensing Zero Crossing.

Figure 4: Zero crossing


Whether using power line or radio communications, packets transmitted using the X10
control protocol consist of a four bit house code followed by one or more four bit unit
code, finally followed by a four bit command. For the convenience of users configuring a
system, the four bit house code is selected as a letter from A through P while the four bit
unit code is a number 1 through 16.
When the system is installed, each controlled device is configured to respond to one of the
256 possible addresses (16 house codes 16 unit codes); each device reacts to commands
specifically addressed to it, or possibly to several broadcast commands.
2.2.3 Sequence of Signals:
1. In order to provide a predictable start point, every data frame would always
begin with at least 6 leading clear zero crossings, then a start code of 1110.

13

Figure 5: Start Code.


2. Once the start code is sent, a 4 digit letter code is sent(house code).

Figure 6: Letter Code.


3.

Then a 4 digit function code is sent(1-16)

14

Figure 7: Number Code.


Function codes may specify a unit number code (116) or a command code, the selection
between the two modes being determined by the last bit where 0=unit number and
1=command. One start code, one letter code, and one function code is known as an
X10 frame and represent the minimum components of a valid X10 data packet.
4. Each frame is sent twice in succession to make sure the receivers understand it
over any power line noise for purposes of redundancy, reliability, and to accommodate
line repeaters.

Figure 8: Transmission of Address Data.

15

5. Whenever the data changes from one address to another address, from an

address to a command, or from one command to another command, the data frames must
be separated by at least 6 clear zero crossings (or "000000"). The sequence of six zeros
resets the device decoder hardware.

Figure 9: Address Code and Command Code separation.


Till now all the diagrams have shown signals on a single sinusoidal line. But our mains
power supply generates electric power in 3 phases. Hence instead of sending just one
pulse each transmitter should send three pulses every half sine wave.

Figure 10: Power Line Phases and X-10 pulse.


2.2.4 Disadvantages:
TVs or wireless devices may cause spurious off or on signals. Noise filtering

(as installed on computers as well as many modern appliances) may help keep
external noise out of X10 signals, but noise filters not designed for X10 may
16

also filter out X10 signals traveling on the branch circuit to which the
appliance is connected.
X10 signals can only be transmitted one command at a time, first by

addressing the device to control, and then sending an operation for that device
to perform. If two X10 signals are transmitted at the same time they
may collide or interleave, leading to commands that either cannot be decoded
or that trigger incorrect operations.

The X10 protocol is also slow.

2.3 MODBUS
2.3.1 Overview: The MODBUS communication interface is built around messages. The
format of these MODBUS messages is independent of the type of physical interface used.
This gives the MODBUS interface definition a very long lifetime. The same protocol can
be used regardless of the connection type. Because of this, MODBUS gives the possibility
to easily upgrade the hardware structure of an industrial network, without the need for
large changes in the software. A device can also communicate with several MODBUS
nodes at once, even if they are connected with different interface types, without the need
to use a different protocol for every connection.
2.3.2 MODBUS Message Structure: Each MODBUS message has the same structure.
Four basic elements are present in each message. The sequence of these elements is the
same for all messages, to make it easy to parse the content of the MODBUS message. A
conversation is always started by a master in the MODBUS network. A MODBUS master
sends a message anddepending of the contents of the messagea slave takes action and
responds to it. There can be more masters in a MODBUS network. Addressing in the
message header is used to define which device should respond to a message. All other
nodes on the MODBUS network ignore the message if the address field doesn't match
their own address.

MODBUS message structure


Field

Description

Device address Address of the receiver


17

Function code Code defining message type


Data

Data block with additional information

Error check

Numeric check value to test for communication errors


Figure 11: MODBUS message structure.

2.3.3 MODBUS serial transmission modes: MODBUS/ASCII and MODBUS/RTU


Serial MODBUS connections can use two basic transmission modes, ASCII or Remote
Terminal Unit (RTU). The transmission mode in serial communications defines the way
the MODBUS messages are coded. With MODBUS/ASCII, the messages are in a
readable ASCII format. The MODBUS/RTU format uses binary coding which makes the
message unreadable when monitoring, but reduces the size of each message which allows
for more data exchange in the same time span. All nodes on one MODBUS network
segment must use the same serial transmission mode. A device configured to
use MODBUS/ASCII cannot understand messages in MODBUS/RTU and vice versa.
When using MODBUS/ASCII, all messages are coded in hexadecimal values, represented
with readable ASCII characters. Only the characters0...9 and A...F are used for coding.
For every byte of information, two communication-bytes are needed, because every
communication-byte can only define 4 bits in the hexadecimal system.
With MODBUS/RTU the data is exchanged in a binary format, where each byte of
information is coded in one communication-byte.
MODBUS messages on serial connections are not sent in a plain format. They are framed
to give receivers an easy way to detect the beginning and end of a message. When
using MODBUS/ASCII, characters are used to start and end a frame. The colon ':' is used
to flag the start of a message and each message is ended with
a CR/LF combination. MODBUS/RTU on the other hand uses time gaps of silence on the
communication line for the framing. Each message must be preceded by a time gap with a
minimum length of 3.5 characters. If a receiver detects a gap of at least 1.5 characters, it
assumes that a new message is coming and the receive buffer is cleared. The main
advantage of MODBUS/ASCII is, that it allows gaps between the bytes of a message with
a maximum length of 1 second. With MODBUS/RTU it is necessary to send each message
as a continuous stream.

Properties of MODBUS/ASCII and MODBUS/RTU


MODBUS/ASCII
18

MODBUS/RTU

Characters

ASCII 0...9 and A..F

Binary 0...255

Error check

LRC Longitudinal Redundancy Check CRC Cyclic Redundancy Check

Frame start

character ':'

3.5 chars silence

Frame end

characters CR/LF

3.5 chars silence

Gaps in
message

1 sec

1.5 times char length

Start bit

Data bits

Parity

even/odd

none

even/odd

none

Stop bits

Figure 12: Properties of MODBUS/ASCII and MODBUS/RTU


2.3.4 MODBUS Addressing
The first information in each MODBUS message is the address of the receiver. This
parameter contains one byte of information. In MODBUS/ASCII it is coded with two
hexadecimal characters, in MODBUS/RTU one byte is used. Valid addresses are in the
range 0-247. The values 1-247 are assigned to individual MODBUS devices and 0 is used
as a broadcast address. Messages sent to the latter address will be accepted by all slaves. A
slave always responds to a MODBUS message. When responding it uses the same address
as the master in the request. In this way the master can see that the device is actually
responding to the request.
Within a MODBUS device, the holding registers, inputs and outputs are assigned a
number between 1 and 10000. One would expect that the same addresses are used in the
MODBUS messages to read or set values. Unfortunately this is not the case. In the
MODBUS messages addresses are used with a value between 0 and 9999. If you want to
read the value of output (coil) 18 for example, you have to specify the value 17 in the
MODBUS query message. More confusing is even, that for input and holding registers an
offset must be subtracted from the device address to get the proper address to put in the
MODBUS message structure. This leads to common mistakes and should be taken care of
when designing applications with MODBUS. The following table shows the address
ranges for coils, inputs and holding registers and the way the address in the MODBUS
message is calculated given the actual address of the item in the slave device.
19

Device and MODBUS address ranges


Device address

MODBUS address

1...10000* address 1

Description
Coils (outputs)

10001...20000* address - 10001

Inputs

40001...50000* address - 40001

Holding registers

Maximum value is device dependent

Figure 13: Device and MODBUS address ranges


2.3.5 MODBUS Function Codes
The second parameter in each MODBUS message is the function code. This defines the
message type and the type of action required by the slave. The parameter contains one
byte of information. In MODBUS/ASCII this is coded with two hexadecimal characters,
in MODBUS/RTU one byte is used. Valid function codes are in the range 1..255. Not all
MODBUS devices recognize the same set of function codes. The most common codes are
discussed here.
Normally, when a MODBUS slave answers a response, it uses the same function code as
in the request. However, when an error is detected, the highest bit of the function code is
turned on. In that way the master can see the difference between success and failure
responses.

Common MODBUS function codes


Code

Description

01

Read coil status

02

Read input status

03

Read holding registers


20

04

Read input registers

05

Force single coil

06

Preset single register

07

Read exception status

15

Force multiple coils

16

Preset multiple registers

17

Report slave ID

Figure 14: MODBUS Function Codes

2.3.6 Disadvantages:

MODBUS was designed in the late 1970s to communicate to programmable


logic controllers the number of data types is limited to those understood by
PLCs at the time. Large binary objects are not supported.

Since MODBUS is a master/slave protocol, there is no way for a field device to


"report by exception"-the master node must routinely poll each field device,
and look for changes in the data. This consumes bandwidth and network time
in applications where bandwidth may be expensive, such as over a low-bit-rate
radio link.

MODBUS is restricted to addressing 247 devices on one data link, which limits
the number of field devices that may be connected to a master station.

21

3. CIRCUIT DESIGN

22

3. CIRCUIT DESIGN
As stated earlier, the project aims at developing a system that uses the AC power lines as
the communication channel/medium to transmit and receive information. In this chapter
we shall study the various circuits that form the basis of the power line communication
system. We would come across the actual system implementation in the next chapter. Let
us first start with describing the power line as a communication channel

3.1 The Communication Channel: The low-voltage power grid that is used to supply
electric power to houses consists of many channels each with its own characteristics and
quality. Figure below shows a communication system using the power-line as a
communication channel. The transmitter is shown to the left and the receiver to the right.
Important parameters of the communication system are the output impedance, Zt, of the
transmitter and the input impedance, Zi, of the receiver.

23

Figure 15: Power Line Communication Channel

3.2 Transmitter: The transmitter in the PLC system provides the necessary signal which
is to be transmitted through the channel. The signal generated is digital in nature (Binary
0s & 1s or a sequence of 0s n 1s). A microcontroller is programmed by software to
generate the necessary digital signal.

The transmitter needs to make sure it provides the necessary signal without being affected
by external parameters. The digital signal is modulated in proper form to make the signal
more noise free, efficient, and immune to stray signals. Let us now study the various
digital modulation schemes.

3.3 Modulation Schemes: The transmitter (a Microcontroller in our case) is the source of
digital signal for communication purpose. The source signals are generally referred to as
Base-band signals. The low-frequency signal is often frequency-translated to a higher
frequency range for efficient transmission. The process is called modulation. In the
modulation process, the base-band signals constitute the modulating signal and the highfrequency carrier signal is a sinusoidal waveform.
There are three basic ways of modulating a sine wave carrier. They are
Binary Amplitude-Shift keying (BASK).
Binary Frequency-Shift keying (BFSK).
Binary Phase-Shift Keying (BPSK).

3.2.1 Binary Amplitude shift keying (BASK) - In the context of digital communications,
BASK is a modulation process, which imparts to a sinusoid two or more discrete
amplitude levels. These are related to the number of levels adopted by the digital message.
Mathematically it can be expressed as
v(t) = A* b(t) * cos(wo t)
Where, A = amplitude
wo = carrier frequency
b(t ) = Uni-polar digital data
24

When b(t ) = 1
When b(t ) = 0

v(t) = A* cos (wo t)


v(t) = 0

This implies that the carrier frequency is present when data is at high logic level and there
is no
carrier at all when the data is at logic low level.
For a binary message sequence there are two levels, one of which is typically zero. Thus
the modulated waveform consists of bursts of a sinusoid. Figure illustrates a binary ASK
signal, together with the binary sequence which initiated it

Figure 16: Binary Amplitude Shift Keying Waveform

3.2.2 Binary Frequency Shift Keying (BFSK): Its the most common form of digital
modulation in the high-frequency radio spectrum. Binary FSK (usually referred to simply
as FSK) is a modulation scheme typically used to send digital information between digital
equipment such as tele-printers and computers. Data is transmitted by shifting the
frequency of a continuous carrier in a binary manner to one or the other of two discrete
frequencies. Mathematically it can be expressed as
v(t) = A* cos[wot + d (t ) *W* t]
Where A = amplitude
wo = center frequency

W = frequency deviation

d (t) = +1 for logic level 1

d (t) = -1 for logic level 0

Thus the transmitted signal is either


v(t) = A* cos[wo + W] * t or
v(t) = A* cos[wo - W]* t
25

And hence two analog waves of different frequencies are obtained. The waveforms for
BFSK are shown below.

Figure 17: A BFSK waveform derived from a Binary message.

3.3. Power Line Interface (Isolation Circuit): One of the most important parts of our
power line transmitter and receiver is the Power Line Interface. Because our circuit has to
connect to the 230V, 50 Hz power line, without careful isolation, the rest of the circuit will
be easily damaged. The idea is to superimpose the data signal onto the 230V, 50 Hz power
waveform, and extract it afterwards at the receiving end. The ideal isolation circuit should
completely block the 50Hz signal, and pass the information signal. The information signal
in our case is the frequency modulated signal.

3.4. Receiver: The signal generated by the transmitted is sufficiently amplified and passed
through the isolation and coupling circuitry onto the A.C power lines. The high frequency
digital signal gets superimposed over the low (50Hz) power lines. The signal thus passes
over the power lines. This superimposed signal reaches the receiver. The receiver is
designed to perform the following actions.
Filtering and Isolation: The received signal is passed through a high pass (RC) filter
which is designed specifically to filter out the 50 Hz power line signal. The powerful A.C
signal should be prevented from entering the receiver peripherals as it can cause damage
to the components. Thus the foremost function of the receiver must be to filter out this
signal. Thereafter careful isolation from the 230V must be provided to the receiver
components as it can also cause sufficient damage. At the output of this portion of the
receiver circuit we get the transmitted high frequency digital signal.

Wave Shaping: The digital signal recovered from the transmitted signal can be affected
by noise introduced during its travel through the power lines. Any stray noise pulses can
cause unwanted action at the receiver. Therefore the receiver should wave shape the
recovered digital signal to take care of the unwanted stray pulses.
26

Control Action: The recovered digital signal is then used by the microcontroller in the
receiver to perform the necessary control action on the devices connected to the receiver.
The receiver should thus differentiate between the different signals for the respective
devices and the take the necessary controlling action.

27

4. System Implementation: The


Transmitter

28

4. System Implementation: The Transmitter

The chapters discussed earlier described the various design methodologies used in
building a power line communication system. We now study the actual circuit of the
transmitter and the receiver of the Power Line Communication system in chapter 4 & 5.

Let us start with the transmitter.

The basic layout of the transmitter circuit diagram is shown below.

29

Figure 18: The Transmitter Circuit diagram

4.1 Hardware:

The heart of the transmitter is the microcontroller. The system deploys the 8052
microcontroller because the timer2 in the 8052 can be programmed to generate a
fixed frequency digital pulse train which can be used as a carrier in the amplitude
shift keying modulation process.

The microcontroller is programmed to output a frequency of 100 KHz at pin P1.0.


The output from this pin is ANDed with the signal from the transmit pin (TX) of
the microcontroller. The output of the AND gate gives the amplitude modulated
waveform.

This waveform is subsequently fed to a transistor amplifier which amplifies the


resultant waveform and also couples it to the input side of the opto-coupler
circuitry.

30

The opto-coupler is used for the isolation of the microcontroller and other allied
low voltage circuitry from the high voltage power line. The output of the optocoupler is capacitor coupled to the high voltage power line as shown in the figure.

31

32

33

4.2 Software

The transmitter microcontroller performs two main functions


1. Generating the carrier digital pulse train
2. Transmitting data bytes to control appliance at the receiver end.

The carrier frequency of 100 KHz is generated using the Timer2 of the 8052
microcontroller in the Programmable Clock Out mode. Here the timer2 is used
to generate a continuous pulse train of 50% duty cycle having frequency of 100
KHz on pin P1.0.

We have programmed the microcontroller on the transmitter side to send four


different bytes depending on the action to be performed.

Byte 1: Turns led 1 on


Byte 2: Turns led 1 off
34

Byte 3: Turns led 2 on


Byte 4: Turns led 2 off

These bytes are sent depending on the status of the pins 2.0, 2.1, 2.2, 2.3. The
status of these pins is manipulated using four switches connected to these pins.

35

89C52 Programming for the Transmitter Circuit

include reg_52.pdf

cseg

at

00h
SJMP

CSEG

AT

MAIN
03H

AJMP
cseg

at

ZCD_INT
23h

AJMP

UART_INT

BSEG

AT

SEND_DATA_NOW:

DBIT

01

KEY_DTCT_1:

DBIT

01

KEY_DTCT_2:

DBIT

01

KEY_DTCT_3:

DBIT

01

KEY_DTCT_4:

DBIT

01

DSEG

AT

25H

DST_REP_COUNT:

DS

01

KEY1

EQU

P2.0 ; Clock pin assignment for I2C

KEY2

EQU

P2.1 ; Clock pin assignment for I2C

KEY3

EQU

P2.2 ; Clock pin assignment for I2C

KEY4

EQU

P2.3 ; Clock pin assignment for I2C


36

CSEG

AT

30H

MAIN:
MOV

T2CON,#04H

MOV

T2MOD,#02H

MOV

SCON,#50h

MOV

TMOD,#20h

MOV

TH1,#0f4h

MOV

TL1,#0f4h

SETB

TR1

SETB

ES

SETB

EX0

SETB

;2400 Baud-rate

IT0
SETB

EA

MOV

RCAP2H,#0FFH

MOV

RCAP2L,#0E2

JBC

SEND_DATA_NOW,SEND_DATA

JB

KEY_DTCT_1,CHK_KEY2

JB

KEY1,CHK_KEY2

SETB

KEY_DTCT_1

MOV

DST_REP_COUNT,#2

HERE:

CHK_KEY2:
JB

KEY_DTCT_2,CHK_KEY3
37

JB

KEY2,CHK_KEY3

SETB

KEY_DTCT_2

MOV

DST_REP_COUNT,#2

CHK_KEY3:
JB

KEY_DTCT_3,CHK_KEY4

JB

KEY3,CHK_KEY4

SETB

KEY_DTCT_3

MOV

DST_REP_COUNT,#2

CHK_KEY4:
JB

KEY_DTCT_4,HERE

JB

KEY4,HERE

SETB

KEY_DTCT_4

MOV

DST_REP_COUNT,#2

SJMP

HERE

SEND_DATA:
JB

KEY_DTCT_1,SEND_55

JB

KEY_DTCT_2,SEND_AA

JB

KEY_DTCT_3,SEND_5A

JB

KEY_DTCT_4,SEND_A5

SJMP

HERE

SEND_55:
MOV

SBUF,#55H
38

DJNZ

DST_REP_COUNT,HERE

CLR

KEY_DTCT_1

SJMP

HERE

MOV

SBUF,#0AAH

DJNZ

DST_REP_COUNT,HERE

CLR

KEY_DTCT_2

SJMP

HERE

MOV

SBUF,#5AH

DJNZ

DST_REP_COUNT,HERE

CLR

KEY_DTCT_3

SJMP

HERE

MOV

SBUF,#0A5H

DJNZ

DST_REP_COUNT,HERE

CLR

KEY_DTCT_4

SJMP

HERE

SEND_AA:

SEND_5A:

SEND_A5:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
UART_INT:

39

JBC

TI,EXIT_UART

JBC

RI,EXIT_UART

EXIT_UART:
RETI

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ZCD_INT:

SETB SEND_DATA_NOW
RETI
END

40

5. System Implementation: The


Receiver

41

5. System Implementation: The Receiver


We studied the transmitter in detail in the previous chapter. Now we shall look closer into
the receiver of the power line communication system in this chapter. The signal received
from the transmitter needs to be recovered and the necessary action is to be taken on the
devices connected to the receiver.

The circuit layout of the receiver is given below.

42

Figure 19: The Receiver circuit Diagram


5.1 Hardware:

The input at the receiving end is a 50 Hz power line signal superimposed with the
100 hz signal frequency. This composite signal is passed through a high pass RC
filter to remove the 50 Hz component and pass the 100 KHz component(data
signal).

The signal is then amplified and fed to the input of the opto-coupler. The optocoupler isolates the low voltage microcontroller section from the high voltage
section consisting of the power line.

The output of the opto-coupler is again amplified and fed to the microcontroller
where necessary processing takes place.

43

44

5.2 Software

The receiver microcontroller performs two main functions


1. Wave shaping of the received signal to eliminate the effect of noise
transients and for signal smoothening
2. Switching the devices connected to the pins based on the code
received.

The received signal as a result is fed at the external interrupt 1. The


interrupt subroutine performs the necessary wave shaping and gives the
wave shaped output on pin P1.3. Pin P1.3 is then connected to the receive
(RX) pin of the microcontroller.

Depending on the byte received the microcontroller switched the LEDs


connected to the pin P2.0 and pin P2.1.

45

46

89C52 Programming for the Receiver Circuit

include reg_52.pdf

cseg

at

00h
SJMP

CSEG

AT

MAIN
13H

SJMP
CSEG

AT

EXT_1
0BH

SJMP
cseg

at

TMR_0
23h

SJMP

UART_INT

DSEG

AT

25H

SR_DATA:

DS

01

BSEG

AT

00

F_T_FLAG:

DBIT

01

VALID_DATA:

DBIT

01

OP1

EQU

P2.0

; Clock pin assignment for I2C

OP2

EQU

P2.1

; Clock pin assignment for I2C

47

CSEG

AT

30H

MAIN:
CLR

OP1

CLR

OP2

CLR

P1.3

MOV

SCON,#50h

MOV

TMOD,#22h

MOV

TH1,#0f4h

MOV

TL1,#0f4h

SETB

TR1

SETB

ES

SETB

ET0

SETB

EX1

SETB

TR0

SETB

IT1

MOV

IP,#04H

SETB

EA

JBC

VALID_DATA,PROC_SR_DATA

SJMP

HERE

;2400 Baud-rate

HERE:

PROC_SR_DATA:
MOV

A,SR_DATA

CJNE

A,#55H,CHK_4_AA
48

SETB

OP1

SJMP

HERE

CJNE

A,#0AAH,CHK_4_5A

CLR

OP1

SJMP

HERE

CJNE

A,#5AH,CHK_4_A5

SETB

OP2

SJMP

HERE

CJNE

A,#0A5H,HERE

CLR

OP2

SJMP

HERE

CHK_4_AA:

CHK_4_5A:

CHK_4_A5:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
EXT_1:
JB

F_T_FLAG,CONT_EXT_1

SETB

F_T_FLAG

SJMP

CONT_EXT_2

CONT_EXT_1:
SETB

P1.3
49

CONT_EXT_2:
MOV

TL0,#220

SETB

TR0

RETI

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
TMR_0:
CLR

P1.3
CLR

F_T_FLAG

CLR

TR0

RETI

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
UART_INT:
JBC

TI,EXIT_UART

JBC

RI,CHK_RCV_DATA

EXIT_UART:
RETI

CHK_RCV_DATA:
50

MOV

A,SBUF

CJNE

A,#0,CHK_4_FF

RETI

CHK_4_FF:
CJNE

A,#0FFH,GO_VALID_DATA

RETI

GO_VALID_DATA:
MOV

SR_DATA,A

SETB

VALID_DATA

RETI
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

51

5.3 THE POWER LINE COMMUNICATION SYSTEM

52

6.

Cost of Project
53

Sr no:

Components

Price(Rs)

Quantity

Total

1
2

PCB
Microcontrollers 89C52

50
40

2
2

100
80

3
4

MCT2E
PC817

7.5
3

2
3

15
9

5
6

Box caps
BC548

7
6

3
1

21
6

7
8

LED
LM2940

1
35

2
2

2
70

Capacitor 1000uF

10

10
11

Capacitor 220uF
Capacitor 0.1uF

3
.25

2
3

6
.75

12
13

Capacitor 0.33pF
Crystal

.25
3

4
2

1
6

14

Resistor Network

15

Bridge rectifier

10

16

Capacitor 10uF

17

Bus ship

18

Slide Switch

19

Sockets

18

20

AND gate

21

Adapter

100

300

22
23

Resistors
Switches

1
4

10
4

10
16

24

Transformers

200

200

25

Diode

.25

.25

26

Wires

20

20

Grand Total

7. Conclusion
54

Rs.918

The devices connected to the designed power line communication system can be
increased by making minute changes in the underlying hardware and software. The
system can be used for a number of applications such as home automation, automatic
meter reading etc.
The implications of power line communication are farfetched and varied. The
technology can be used for controlling appliances in a household as well as for
remotely controlling vast industrial establishments. The technology is highly cost
effective since it uses the already established power line network for data
communications.
In spite of its numerous advantages, the communication is limited to low data rates
and hampered by high power line noise. Research advances in these areas will further
lead to improvements in the technology.

55

8. Bibliography
www.hometoys.com
www.lammertbies.nl.
Design of Power-Line Communication System (PLC) Using a PIC Microcontroller, Q.
Al-Zobi, I. Al-Tawil, K. Gharaibeh and I. S. Al-Kofahi.
ITU Press Release: New global standard for fully networked home.
IEEE P1901 Press Release.
Modicon MODBUS Protocol Reference Guide.
Tech note-X-10 Communications Protocol and Power Line Interface.

56

57

9. APPENDIX

58

59

60

61

62

63

64

65

66

67

68

69

You might also like