You are on page 1of 49

Table of Contents

Table of Figures

Chapter 1
Introduction
Domotics ,smart homes ,home automation system are terms used to describe the

cooperation of several In home devices to handle home environment in comfortable ,intelligent and electrically energy efficient way. It is a field that touches electronics, communication, automation and building architecture. Home automation includes a centralized control of lighting, HVA !heating, ventilation air conditioning" and other appliances in order to give improved convenience and energy saving. onsiderable improvements can be made in #uality of life of elderly, and paralyzed persons who might otherwise re#uire a care ta$er. Home automation systems by different companies differ in communication protocol ,communication medium ,topology of networ$ and power consumption .%esides now with current data rate of &' (bps!mega bit per second" )*+,power line carrier communication system are good choice over wireless and other home networ$ing technologies ,due to ease of installation ,availability of A ,reliability ,greater through put and security.),+ plug outlets, low cost

Our project
-ower line communication would appear to be economical and user friendly method for home automation .our pro.ect e/plores such claims and to investigate the challenges we could face. It is about using ,,0v Ac power lines as a ommunication (edium to automate and

control single -hase A devices. 1ser !domestic or industrial" is able to monitor sensors data and control electrical devices using touch screen color display provided by H(I !human machine interference" .H(I is commonly used with -2 s !programmable logic controller" instead of microcontrollers. 3ow here is a uni#ue thing that we have interfaced -I *&45', microcontroller with H(I. 6he scope of this pro.ect is very huge but we have successfully implemented a system that integrates and controls four electric appliances, temperature sensor, door sensor and light sensor.

1.1 Objectives
6o design a 6ransceiver for power line communication.

-ower line modem oupling circuitry

6o interface H(I with -I *&45', using (odbus -rotocol. 6o design 7raphical user interface !71I" for H(I using 8asy builder&000.

1.2 Problem statement


9ur building management system helps to monitor and control electricity appliances .2ets say we have a building which is larger than ,'0 s#uare meters than how we will be able to control electrical devices everywhere in multi or single story building. As we $now, current electricity prices have raised and it is a must do thing to safe energy .as a matter of fact a communication medium which is usually not ta$en in account, power line can be used .:;*0 uses power line communication system and it can help us a lot to solve this problem otherwise we may have face following problems. 6o install a dedicated bus cable for data e/change between appliances. <pend money on buying remote sensors and inter face with each device. =aste our time and electricity if forgot to switch off any 8lectric device which may be dangerous.

1.3 Motivation for our project


It is ideal for applications in e/isting houses. 3o e/tra wiring is necessary low;cost solutions. 3o interference with other devices in contrast to radio communications. -ossibility to put modules in every place !nearest soc$et"

8nergy efficient homes are hot topic these days. 2ot of research has been carried out in power line communication in 1<A ,8urope and (alaysia

1.4 Thesis overvie


9ur thesis on smart building management system using -2 > (odbus is combination of five chapters that elaborates , introduction ,literature review , -ro.ect design (ethodology ,?esults and discussion , conclusion and future wor$. In chapter * we have discussed introduction of power line, ob.ective of pro.ect .In chapter , we discussed noise factors for power line and (odbus protocol. In chapter @ re#uirement specification is given .Architecture and components are given in chapter 5.In chapter ' implementation procedure is discussed about H(I configuration and master unit and slave unit construction .power line transceiver is also discussed in detail. onclusion and discussion is given in chapter A.

Chapter 2
!iterature "evie
2.1 Po er line communication
-ower ;line communication is based on electrical signals, carrying information, propagating 9ver the power;line.)@+ -ower ;line carrier communication refers to a method in which information is transfer through networ$ of electrical power lines as communication channel .and a communication channel is defined as physical path between two nodes on which signal is propagated 6his topic has been in spot light of researchers across the world from #uite couple of years bac$ still there is not any universal standard for -2 ,nor there is any globally accepted worldwide regulatory authority, but some standards are developed from time to time by

different research groups with improvement each time .standards can be classified in two classes depending on data rates for high ,;,0mhz and for low data rate @ ;*5& $Hz.)5+

2.2 #tandardi$ation of Po er !ine net or%in&


6he most important factor in delay of power line installations is developments of standards acceptable to all .-rinciples for communications are developed all over the world but some standard are best suited according to regional conditions of particular country or continent.

2.2.1 !o data rate standards


6hese standards were developed for command and control applications and other telemetry operations :;*0 2on wor$s 8;bus

2.2.2 'i&h speed P!C standards


Home -lug -ower line Alliance 1niversal -ower line Association I888 -*B0* I61;6 home grid forum. 9-8?A !9pen -2 8uropean ?esearch Alliance" -9=8?386 -anasonic

2.2.3

"e&ulator( )uthorities
83828 !8uropean committee for electro technical standardization" 4ederal ommunication ommission !4 Capan (-6 ",

:;*0 and I3<6893 are two industrial standards most commonly used .in our pro.ect we used

2.3 *+1,

It is an international and open industry standard using power line communication for home automation widely spread in 1<A and 8urope. It primarily uses power line wiring for signaling and control applications. It does not use any forward error correction !48 " or cyclic redundancy chec$sum ! ? " techni#ue. 6his protocols uses a form A<D !amplitude shift $eying" and was initially designed for simple/ communication .it uses *,0$hz amplitude modulated carrier signal .to represent digital information .6o minimize interference this signal is superimposed on power line at zero crossings of '0Hz ,,0v ac signal. 6he presence or absence of this burst is used to decode the transmission of E*Fs Eor G0FsH bits respectfully. Addresses are assigned to each node while transmission signal contain room address device address, and function code, but speed limitations !I0 bps"are there and multiple device transmitting at same time can cause collisions .)'+

2.4

Po er line carrier communication challen&es-

-ower line networ$ was not designed for communication purpose .they offer a hostile environment for the propagation of communication signal accurately .two of the biggest impairments of residential power line as communication channel are noise and attenuation )I+. Here we will discuss some types of noise mainly present in power line channel.

.i&ure 2+1. /oise contribution over Po er line /et or% 012

2.4.1

3ac% &round colored noise-

6his noise has low power spectral density at fre#uencies ranging ,0;@0 (Hz, but high at low fre#uencies. 6his noise varies with time and caused by devices li$e dimmers, hair dryers and computer

2.4.2

/arro band noise-

1p to *'0 $Hz range of fre#uencies this type of noise is generated by switching power supplies, fre#uency converters, tube lights, and 6V. Its level varies across the day.

.i&ure 2+2 #pectral densit( Model for bac%&round noise .042

2.4.3

#(nchronous Impulsive /oise-

6his type of noise rises due to short voltage pea$s caused mainly by on ;off switching of home appliances. (ostly appear at multiples of '0 Hz fre#uency. 6hese pulses are for very short duration and vanish in micro seconds. Another reason of this type noise is rectifiers in D appliances.

2.4.4 )s(nchronous Impulsive /oiseJ


6he worst of all that affects power line communication .Its duration ranges from few micro to milliseconds .impulse of this type of noise are due to switching transients in the networ$ due to power supplies .spectral density of this noise can be greater than '0d% and it affects the fre#uency up to ,0(hz. it can corrupt large data bloc$s transmitted power line.)A+)&+

2.4.5

.re6uenc( dependence-

-revious studies show that noise level in residential conditions fluctuate greatly .noise level have tendency towards decreasing as fre#uency increases. In other words communication carrier fre#uency will face less noise if fre#uency is higher .it was also found that fre#uencies above 500$hz are affected more by noise ,as this band is closer to radio band. so power line acts as radio antenna, creating noise. 9n the contrary fre#uencies less than *00 $Hz are more affected by noise as fre#uencies above *00 $Hz.)I+ 9n the other hand, fre#uencies lower than *00 $Hz tend to contain noise inversely proportional to fre#uency.

.i&ure 2+3 Measurements of noise spectrum on a residential po er line 072

2.4.7

#i&nal attenuation.

2oss of signal strength as signal travels over some distance is called attenuation. Attenuation remains appro/imately flat if distance is within *0 meters but attenuation increased as distance increase. And it also depends on carrier fre#uency selection

.i&ure 2+ 4 #i&nal attenuation on a po er line across the ,+3,, %'$ 3and. 072 Hence seeing above results it is clear that trade off e/ist fre#uency with attenuation and noise .either low noise and high attenuation with high fre#uency selection .or to use low fre#uency with high noise and low attenuation. <tudies show us that desirable band lies between*00$hz;,00$hz.as we are using *,' $Hz carrier fre#uency so this study provide us solid ground on choosing this fre#uency.

2.5 )mplitude #hift 8e(in& 9)#8:


In our pro.ect we used A<D amplitude shift $eying in order to send data in selected fre#uency band. In Amplitude <hift $eying logic level G*F is transmitted by carrier of particular fre#uency while logicF0F is transmitted by changing the amplitude of that particular carrier fre#uency signal used to represent logicF*F.to be more precisely amplitude of the carrier is changed in response to digital bit stream $eeping fre#uency And phase are $ept constant. 9n;944 $eying is special form of Amplitude shift $eying !99D;A<D".In this scheme one of the amplitude is zero. A binary Amplitude shift $eying !%A<D" can be defined as that the carrier signal is present when digital signal is at logic high and absent at logic low. X ( t )= Acos ( ,Kft ) for binary * X ( t )=0 for binary 0 6his modulation scheme is nose resistant as all information is sent at one particular carrier fre#uency, saving bandwidth and narrow band filters can be designed to reduce noise effect . In our pro.ect as 6DA'0'* is operated at active logic low !DA6ALI3 and DA6AL916" so here logic one will be represented by absence of A<D carrier signal and vice versa.

2.7 Modbus Protocol


(odbus is application layer level messaging protocol published by (odicon in *BAB for use with its programmable logic controllers.!-2 s".3ow it is de facto standard in automation industry for communication and most common mean of connecting industrial electronic devices. (odbus allows communication with all type of networ$s architecture.

2.7.1 Main reasons for the e;tensive of Modbus are

9penly published 8asy networ$ to deploy 3ot vendor specific

(odbus is usually used to connect a supervisory computer with remote terminal unit !?61" in < ADA systems.

2.7.2 <ersions

(odbus ?61 (odbus A< II (odbus 6 -MI(odbus over !6 (odbus -lus !(%N")B+

=e are using (odbus ?61 we will discuss this protocol.

2.1

Modbus "T= .rame.

6he (odbus protocol defines a protocol data unit !-D1", introducing additional fields of Application Data 1nit !AD1" .(odbus follows client server communication. In our case -I *&45', is server and H(I is client. lient initiates communication and built AD1.=e will discuss each field of AD1 pac$et below.

.i&ure 2+ 5 Modbus frame 01,+.

2.1.1 .unction code=hen a message is sent from client to server 4unction codeJ tells server which action to perform .valid codes range are *;,'' decimal.*,&;,'' are reserved .o is not a valid function code.

2.1.2 >ata fieldData field contains information .re#uired by server to ta$e action against function code sent by client .it may of zero length in certain cases.i.e. In re#uest frame in which client want information from server data field is zero.

2.1.3 ?rror fieldJ


It contains ? !cyclic redundancy chec$sum" for error detection. 2ength is , bytes.

2.1.4 )ddress fieldIt contains address of server and of length * byte. AD1 !Application Data 1nit" O ,'@ bytes N * byte !<erver Address" N, bytes ! ? "O,'Ibytes <o -D1!-rotocol Data 1nit" O4unction code!* byte"NData AD1O-D1NAddressN8rror.

2.4 Modbus Transaction<erver uses function code in response frame to tell client either error has occurred or not .if some error occur then server does not send re#uested data it sends e/ception response 8/ception response consist of e/ception function code and 8/ception code. 8/ception code tells server what action to ta$e in case of error. In case of no error (odbus simply echoes the same function code with data re#uested.

.i&ure 2+ 7 Modbus ?rror free "esponse.

.i&ure 2+1- Modbus ?;ception response.

2.4.1 3it )ccessin (odbus discrete output, either 0M* is treated as output" use ,;,5. oils and function code to read coil is ,;,1and to read discrete inputs function code is ,;,2.to write single coil! single bit at

2.4.2 17 bit )ccessIt uses byte operation for analog continuous data li$e ,temperature .(odbus uses holding ?egisters to store data in bye form .and function code to read input register is ,;,4 .)*0+

Chapter 3
"e6uirement #pecification
3.1 Or&ani$ational re6uirements
ID 3?;0,;00* -riority * Details DeliveryJ 6he system development process and deliverable documents shall conform to the process and deliverables defined in the document G II6; 8;0,H Degree -ro.ect <tudentFs 3?;0,;00, * Handboo$F. <tandardJ 6he standard of final product shall be of undergraduate level or above.

3.2

?;ternal re6uirements
-riority @ Details <ecurityJ 6his is a degree pro.ect having no strict security re#uirements.

ID 3?;0@;00*

3?;0@;00,

* 8thicalJ 6he application will not use any type of unethical electronic material while pro.ect development and e/ecution.

3?;0@;00@

* 2egislativeJ 6he application shall not use any private or confidential data, or networ$ information that may infringe copyrights andMor confidentiality of any personnel not directly involved in this product.

3?;0@;005

@ <afetyJ 6his application has 8lectric shoc$ hazard. Avoid touching on board components under operation. ,,0vA

3.3 .unctional "e6uirements 3.3.1 Cate&or( 1


4ollowing re#uirements should be met under given prioritiesJ ID 4?;0*;00* 4?;0*;00, 4?;0*;00@ 4?;0*;005 4?;0*;00' -riority * * * , * Details 6DA '0'* -9=8? 2I38 A<D (9D8( -I *&45', =8I368D (6I0'II H(I (A:,@, A&,'0( HI7H 4?8P13 Q 6?A3<49?(8?

3.3.2 Cate&or( 2
ID 4?;0,;00* 4?;0,;00, 4?;0,;00@ 4?;0,;005 -riority * * * , Details < 9(-I28? 49? -I 8A<Q%1I2D8?&000 49? H(I -?9681< A.I (-2A% ID8

3.3.3 Cate&or( 3
ID 4?;0@;00* 4?;0@;00, 4?;0@;00@ -riority , * * Details 2(A&0' ?8712A69? I A&,'0( HI7H 4?8P13 Q 6?A3<49?(8? *, V926< -9=8? <1--2Q

4?;0@;005 4?;0@;00'

, *

-c&*A 9-69 91-28? 2(@' 68(-8?A61?8 <83<9?.

Chapter 4
)rchitecture and Components

6he design of the intended product is e/plained graphically with the help of a bloc$ diagram

4.2

"e6uired Components
=einte$ '.Ainch Interface !H(I"

Human (achine .i&ure 4+1 3loc%

(icrocontroller -I *&45', 6DA '0'* -ower line A<D (odem I

A&,'0( High 4re#uency -ulse 6ransformer (A: ,@, ?<,@, Driver I 2(@' 6emperature sensor.

4.2.1 PIC14.452 Microcontroller


>escription -I *&45', belongs to *&4 family of (icrochip controllers. It is Industrial (icrocontroller widely used because of its low power, high performance flash, &;bit microcontroller with @, Dbytes of 4lash programmable and erasable read only memory !88-?9(". -I *&45', is compatible with the industry standard -I *&4//, instruction set and pin outs. %ecause of its on chip 4lash memory it can be #uic$ly re programmed using a nonvolatile memory programmer. It is powerful microcomputer which gives a highly fle/ible and cost effective solution to many control applications. )**+.

4.2.2 Pin Confi&uration

.i&ure 4+2 pin out of PIC14.452

4.2.3 #pecifications

-rogram (emory type is 4lash (emory for programming @,Db -1 speed *0 (I-<!mega instruction per second" 88-?9( ,'I bytes ?A( *'@I bytes ommunication peripherals AM8M1<A?6, (<<-!<-IMI, " 4our -orts A,%, , D and 8 6otal IM9 pins @,

4.2.4 @h( PIC 14.A


It is more suitable for our pro.ect due to more memory and instruction speed, as re#uired by our system, than -I *I4/// family or A6(82. It is also compatible with (odbus ?61 protocol (oreover it is more reliable and efficient than others.

4.3

T>) 5,51 po er line modem

6he -hilips 6DA '0'* A is *Ipin Amplitude shift $eying !A<D" modem, used in power line communications !two wire A " for reception Mtransmission of digital signals .this modem is specially designed for in home applications and operate at low baud rate of I00bps to *,00 bps !ma/imum".its full digital circuitry provides efficient bi directional communication between a control unit and lighting setup and one or more in;home appliances connected to power mains ,,0v A . It operates from single 'V supply.

.i&ure 4+3 pin out confi&uration of modem .i&ure 4+4 T>) 5,51 modem

4.3.1

.eatures
4ull digital modulation.

Automatic 7ain conditions.

ontrol !A7 " for detection of small signals in power line

I00 baud rate, *,00 baud ma/imum Digital demodulator 2ow cost coupling networ$ by using 2 filter without any tunable omponents. I;bit DMA !Digital to Analog" &;bit AMD !Analog to Digital" 4re#uency range B' $Hz to *5&.' $Hz band in compliance with 83'00I' standard.)*,+

4.4 MT7,57i 'MI 9'uman Machine Interface:


In our pro.ect we are using =einte$ '.I inch high brightness 646 2 D display with #uic$ response touch screen as interface of central control unit .It can be programmed using 8asy builder &000 software .=einte$ H(I is used field of industrial control and machinery automation in < ADA, and is even suitable for the modern Intelligent %uilding Automation. 9perates on ,5V D .It is compatible with ?<;,@, ?<;5&' and usb,.0.

4.4.1 #pecifications
Display @,0R,50 pi/els. -1J@,%it ?I< 500(Hz processor D?A(J %uilt in I5 (b DD?, ?am. <torageJ *,& (% flash memory. IM9J serial ports ?<;,@,M?<;5&' and 1<% ,.0. <oftwareJ 8asy builder&000 . ompatible with (odbus protocol.)*@+

4.5 "#232 driver IC M)*232


<ince we are using ?<,@, port of (6I0'I H(I to implement (odbus ?61 serial communication with our microcontroller and (odbus ?61 uses ?<,@, voltage levels .so a line driver !voltage converter is needed" to ma$e this communication possible.. Hence ,(A:,@, is used which converts ?<;,@, !N@v to N,'V for logic G0F, ;@V to ;,' V for logic G*F" signal to 662 voltage levels ! 0Vto 0.&V for logic G0F, N,.,V to N' V for logic G*F ", and vice versa .(A:,@, provides an output S A.'V from a 'V dc supply and 0.* uf charge pump capacitors.

.i&ure 4+5 .unctional dia&ram of M)*232

Figure 4-6 Pin out

of Max232

4.7 1425, MC 'i&h Transformer-

.re6uenc(

It is isolation transformer which is used at time when carrier signal is in.ected in to power lines through live and neutral wire. onnection between power line modem and ,,0 Ac must be isolated with*J* isolation transformer for safety purposes It is in <(D pac$age and allows high fre#uency signals to pass through with it. (a/imum isolation voltage up to *.' $V.)*5+

.i&ure4+7 1425, .re6uenc(

MC 'i&h transformer

Chapter 5

>esi&n and implementation


Development of our pro.ect can be divided in two parts.

'ard are development 5.1 Po er line transceiver


=e started our pro.ect with designing of power line transceiver .which in general consist of modulator M demodulator .coupling circuitry ,and filtration for channel noise removal. In start we use 4<D fre#uency shift $eying and successfully designed a 4<D modem using -hilips 38'I5 V 9 !voltage controlled oscillator" details of which u can find in results but we left this approach because some reasons discussed later. =e shifted to 6DA'0'* A<D modem..It comes in <9*I !<(D" pac$age.

5.1.1 Transmission Mode.


-2 transceiver consist of A<D (odem, coupler, line filter .In transmission mode baseband digital signal from microcontroller at baud rate of I00 bps is fed to pin *!DA6A;I3"of modem which then converts this bit stream of 0Fs and *Fs in sine wave curve of *,' DHz. %inary * is represented by absence of *,' DHz burst and binary 0 is represented by presence of *,' $Hz burst. arrier fre#uency is generated by e/ternal oscillator which in our case is & (Hz 9utputA<D modulated signal is at pin*0 !6: out" it is connected to D protect against over voltage . de coupling capacitor *0 uf .6: out pin is also connected to negative transient voltage suppressor to

5.1.2 "eception mode.


(odulated analog signal is fed to pin *5 !?: I3" and this modulated signal is amplified by A7 !automatic gain controller".<ignal then passes through &;bit analog to digital convertor and digital demodulator ,giving baseband signal and noise removal at pin , !Data out".?:;I3 pin is also connected 0.*uf capacitor for additional '0 HT noise removal.

.i&ure of T>)5,51 0122 .i&ure 5+2 #chematic dia&ram of Po er line modem 0122

5+1 3loc% dia&ram

5.2 !ine filter and couplin&J

-ower systems operate at low fre#uency and high power where as communication systems operate at high fre#uency low power. <ince we need to have couple our low power, *,' $Hz communication signal on ,,0v mains, there must be some circuitry to couple high fre#uency signal and to prevent our (odem and rest of electronics from ,,0v A . 6his coupling circuitry would be a filter which will allow specific band of fre#uencies to pass and stop low fre#uencies and provide isolation. =e followed design of passive 2 filter suggested by -hilips )tda sheet+ the topology of filter is shown below. 6wo fre#uencies considered here are *,'$hz and '0Hz.this filter completely filtered out power signal '0Hz ,,0V by offering high impedance to it .series of 5Auh high voltage coupling capacitor and 5AuH power inductor with transformer inductance act as a high pass filter..?:M6: -ins are connected to filter with *uf dc bloc$ing capacitor. -reventing from D load of transformer. )*,+)@+

.i&ure 14 !ine filter as adapted from T>)5,51 data sheet.

5+3

5.2.1 Transformer selection.


hoosing transformer was not easy tas$ as transformer available in local mar$et failed to serve the purpose. <o ferrite core transformer was tested available in mar$et as D chopper or audio transformer, they also not wor$ed .so we used ( A&,'0 recommended by -hilips.

5.2.2 Issues ith transceiver6his I was not available in -a$istan so we imported from hina. It came in <(D pac$age and we face problem in designing - % of <(D pac$ages, - % ma$ing company made a mirror - % but we managed after some hard wor$. Another issue was of #uartz crystal. local &(Hz crystal available in mar$et was not efficient and it was disturbed circuitry due to electrostatic charge .so we used A3 oscillator but , it was available with ,0 and 5& (Hz oscillator fre#uency. %ut this oscillator did not wor$ for Ac power line although it was

wor$ing for dc power line then we ma$e a new oscillator circuitry using 5& (Hz can oscillator and Cohnson counter 50*A to produce & (Hz oscillator fre#uency out put

.i&ure 5+4 BohnsonCs counter circuit.

5.3 Master unit


(aster unit provides control on all A devices we have attached to our slave board. 6he hardware part of master unit consists of power line transceiver, H(I connected with microcontroller. And in software part consist of 71I developed in 8asy builder&000, software programmed in pic*&45', to sendMreceive data toMfrom slave unit.H(I communicates with controller of master unit through (odbus ?61 protocol. 3etwor$ code of master microcontroller is attached at appendi/. H(I is connected to -I through (A:,@, with -in ,I,pin ,' i.e. ? A and ? I for serial communication provide by Hardware 1A?6 port of pic*&45',.crystal oscillator ,0(hz is connected to pin *@,*5 of microcontroller. It generates cloc$ pulses for e/ecution of instruction of microcontroller .'(hz is the operating fre#uency of controller .-in number @B !bI" is 6: pin and connected to ?: pin of modem pin *5 %A in ?: pin of microcontroller connected to 6: pin of modem .

5.3.1 #(nta; for serial portUuse rs,@,!baudOBI00, /mitO-I3L I, rcvO-I3L A, parityO3, bitsO&, stopO*" Uuse rs,@,!baudOBI00, /mitO-I3L%I, rcvO-I3L%A, parityO3, bitsO&,streamOmodem"

.i&ure 5+5 - Master board circuit dia&ram.

5.3. 2 Modbus protocol implementation in CC# C compiler


=e are using < compiler in which (odbus stac$ is available .Data on (odbus goes to ready data first .In our software -I has a ready data !?DQ DA6A" and in ram there is buffer of coils ,i.e input buffer, and main application use these buffers to put data at output or input ports ,-ort A or -ort %. In this test we have onMoff switches on -ort % .and on -ort A we have 5 leds., (odbus uses *I bit holding registers to store data in ram . HereH inputs ) + Eand Ecoils ) +H are holding registersMbuffers.

#(nta;
EHwhile !6?18" V if! modbusL$bhit!""V processLmodbus!"W X inputs)0+ O inputLb!"W outputLa!coils)0+

.i&ure 5+7 .unctional bloc% dia&ram of Modbus and main process. =e are using < compiler in which modbus stac$ is available .Data on (odbus goes to ready

data first .In our software pic has ready data ,in ram there is buffer of coils ,input buffer, and main application use these buffers to put data at out or input ports . -orta or port b.in this test we have onMoff switches on port b .on port a we have 5 leds.port a is of si/ bits ,(odbus uses *I bit holding registers to store data in ram . HereH inputs) + E and Ecoils) +H are holding registersMbuffers .

#(nta;
EHwhile!6?18"V if!modbusL$bhit!""V processLmodbus!"W Xinputs)0+ O inputLb!"W outputLa!coils)0+"

(odbusL$bhit!" chec$s whether any pac$et has come from client !H(I".if yes then it will go to process (odbus .now in process (odbus function ,it chec$s if client has demanded some input or client has some data to show on out put of microcontroller then process (odbus will put that info in ready data. 3ow in our H(I configuration we have assigned 0/5 ,0/*,0/,,0/@ to discrete outputs for coils !switching on Moff" . 3ow to read status of input switches at port % we use this line. It will get input from port % and store at holding register !input ) +" E inputs)0+ O inputLb!" E from there process (odbus will send this data on (odbus through ready data .?8ADQ DA6A aligns the bytes. If H(I sends some output it will go to Ecoils buffer ) +H from there our main application will get output data and map bits on port A. 6here are two layers in processor .foreground main application and in bac$ ground process (odbus is wor$ing .which is in (odbus.h file.

5.4 'MI Confi&uration4or 71I we used 8%&000 software of =einte$ (6I000M&000 series. it is interesting to use. 4irst install this software. go to file menu and select new pro.ect. After selecting H(I name -2 as MO>3=# "T= chose P!C then select local in location menu. In P!C t(pe select (9D%1< ?61.adn chose ?<,@, in -2 IM4. 4or com port settings .and we have faced lot of difficulties in setting this. As our -ower line (odem 6DA'0'* has low baud rate of I00bps.so time out option in set to * sec. All other options are found after many trials. 4or H(I configuration in detail see Appendi/ .

5.4.1 P!C no response errorJ


6his error occur when there is problem in connectivity .6his also shows that microcontroller is treated by H(I as -2 . 6his trend is rising in our local industry to use cheap microcontrollers instead of costly -2 Fs.

.i&ure 5+1 P!C /o response error

5.4.2 Draphical =ser interface D=I development4inal screen for user will be of following form we will discuss some steps to ma$e this screen.

1 2 3

.i&ure 5+4 'MI indo

control

5.4.3 #teps for screen developmentJ


%asic component of H(I screen is window. All $inds of information li$e ob.ects ,word and pictures can be placed on screen. 8ach window has its own address.

E*

E6o

show

input or status of

door or discrete input either on Moff we used %it lamp shown as press bulb button following window open.

in toolbar. =hen you

.i&25 Input bit object address settin&s.

.i&ure 5+E Input bit object address settin&s 1nderstanding of (odbus protocol is re#uired for proper functioning. E,Hto turn devices on Moff we use <et bit buttons. %y pressing re#uired action, either by setting style set on Moff. a new window will pop up.

As in modbus protocol 0: is used for discrete output so configure each push button for

.i&ure Output settin& ?34,,, F3 Fto get temperature (odbus use *I bit registers .use numeric display new window will popup as shown in below figure.

5+1, coils

option .and

As (odbus uses 5/ register address for storing analog data input. so we assign starting address 5/ and inde/ is *.this finishes placing buttons for switches and temperature display. )fter this compile the pro&ram usin& reboot. and do nload to 'MI. It ill

5.5

#lave unit-

9n our slave side .slave unit consist of 5 relays a connected to -I *& 45', with relay driver I 123 ,00@. A temperature sensor and ?eed sensor are connected to slave controller. ?eed sensor is used for door opening and sensing .reed sensor is connected to ?A*!pin @" through opt coupler -c&*A.realys are connected on port % of -I *&45',through *$ resistance that are %0,%*,%,,%@ .these pins are to 3-3 transistor array .temperature sensor 2(@' is connected to pin ,!A0". 6DA'0'* (odem ?: pin is connected to pin,' ? I 6: of pic*&f5', and ?: pin of (odem is connected to -in ,I !6: of controller" for serial communication .In slave only one hardware 1A?6 of controller was used.

5.5.1 @or%in& of "ela( driver3-3 transistors are use as relay drivers. In 3-3 when base gets voltage it then at output !collector " 0 volt from 8mitter is transferred. %ase is input. 8mitter is connected to ground. 3ow when there is no voltage at base we get some negative voltage at collector. 6his in result did not allow relay *,v to complete its circuit and energize the coil. <o when input is given !'v" to relay is energized

.i&ure 5+11 slave circuit dia&ram .

.i&ure 5+12 circuit Diode D* connected to relay is used here to avoid bac$ 8(4 of relay.

"ela( driver

5.5.2 @or%in& =!/ 2,,3 rela( driver ICJ


4or the ease of circuit and instead of using ,* components we can use one single *I pin I . In our slave boar we have used array of A 3-3 transistors !123,00@ I " with common emitter connection bMw relays and uln,00@ are shown in above slave circuit diagram.

5.5.3 @or%in& of Temperature sensorJ


2(@' is precise temperature sensor I temperature in elsius. .Its output voltage is linearly proportional to

5.5.4 #(nta; for temperature sensor on port )


Etemperature*IO!int*I"!!readLadc!";,"M,H

.i&ure 5+13 Temperature circuit sensor

5.5.5 @or%in& of reed sensorJ


9n our slave board we have used reed sensor as door sensor used industrially. It is a magnetic switch .when magnet comes close to this switch it gives *, volts .to avoid connecting *,v at input we used opt couplers - &*A .that will give 'V when door is closed and 0V when door is open.

5.5.7

PC411 Photo coupler-

6o electrically insulate we use photo couplers .when any voltage upto ,0V is applied at input led will glow which switch -3- transistor on we will get 'V at collector .instead of applied ,0 volts.

.i&ure 5+14 or%in& principle of Photo coupler

Chapter 7
?valuation G "esults
=e have focused on through testing and evaluation in design and implementation phase .starting from theoretical design to hardware implementation we have faced lot of hurdles especially the power line (odem and filter design .=e first used 4<D modulation as I Fs were locally available. And we successfully were able to design 4<D modulator and demodulator using -hilips 38'I5.althoughr resulting wave form was very good enough but it was very much component dependent i.e. tuning issue. And these I Fs are not designed for power line communication .I which use 4<D for power line communication li$e stA'@& were very costly so we switched to 6DA'0'* as it was more suitable to our design for low data rate home control.6DA'0'* I , A&,'0( transformer, were imported from china and it too$ long time. rystal oscillator was another big issue. As we first use & (Hz local crystal :6A2 but our modem ic, it didnFt wor$ so we then tried ,0(hz #uartz oscillator which gave results at @*@ DHz fre#uency. but still we were not able to run power line. &(Hz crystal for *,' DHz modulation fre#uency was needed. 6his was not available in mar$et .we somehow managed to get 6: oscillator 5& (HT which was used with Cohnson counter to get & (Hz cloc$.

2ocal components li$e in filter we used 5Anf ,'0V A #uality.

capacitor. =hich fail to wor$ on

power line for accurate filtration. 6his problem was solved by using :, type imported high

.i&ure 7+1 *2 t(pe 25, 41 nf capacitor

.i&ure 7+2 T*C 4 pin 44 M'$ C)/ oscillator

7.1 .unction testin&

?e#uirement 6ested 4?;0*;00* 4?;0*;00@ 4?;0*;005 4?;0*;00' 4?;0*;00, 4?;0*;00* 4?;0@;00* 4?;0@;005 4?;0@;00'

Q 28 * 4ailed 4ailed

Q 28 , 4ailed 9$

4I3A2 <6A61< 9$ 9$

D86AI2< -ower line (odem H(I (A:,@, 6ransformer <erial communication (odem I A&0' I -hoto coupler 2(@' 6emp.sensor

4ailed 9$ 9$ 4ailed!dead" 4ailed!dead" 9$ 4ailed 4ailed 9$ 4ailed!dead" 9$ 4ailed 9$ 4ailed!dead" 9$ 9$ 9D 9$ 9$ 9$ 9$

4?;0@;00I

4ailed

4ailed

9$

9scillator

Chapter 1
Conclusion and .uture or%

1.1 Conclusion
6he ob.ective of our -ro.ect E<mart %uilding (anagement <ystem using -ower line carrier communication !-2 " > (9D%1<H was to design and implement the concept of centralized control unit for a building along with using already installed ,,0v single phase house wiring as communication medium .Important part was to interface H(I with microcontroller using (odbus protocol and to realize the concept of power lines as communication medium. 9ur pro.ect can improve convenience of paralyzed and disabled persons and can reduce electrical energy consumption reducing monthly electricity bill. 1p to *,& rooms can be controlled using our developed protocol.

1.2 .uture or%J


"emote access=e can interface our microcontroller with 7<( providing remote access. =e can also connect H(I to 2A3 and thus access H(I through internet. 'i&h data rate applications-

=ith higher order modulation scheme data rate can be increased, high data rate power line communication is also called broad band power line communication. (odem can be developing which will provide high data rate communications li$e computer networ$ing. #calabilit(J (ore slaves can be added to central control unit. "educe the si$e of componentsJ 4abrication on a single chip for slave board can ma$e it more reliable and efficient and ma$e a plug and play device. <ideo surveillanceJ 6o improve home security camera can be attached our e/isting system but it will re#uire high data rate power line modem. Improved D=I .Advance graphics can be used to give a more user friendly and attractive loo$.

"eferences
)*+ Home plug <tandards Association Available at httpJMMwww.homeplug.orgMhome.Accessed !A 9ctober ,0**". ),+ Dhurram .H. Tuberi (.< 6hesis !,00@" ,E-ower line communication systemH, D6H ?oyal Institute of 6echnology. )@+ 2ars <elander, (.< thesis !*BBB" E-ower;2ine ommunications hannel -roperties and ommunication. <trategiesH, 2und 1niversity. )5+ -ower 2ine ommunication by Hendri$ . 4erreira, 2utz 2ampe, Cohn 3ewbury, 6heo 7. <wart. )'+ :;*0 -rotocol specification Available at www./*0pro.com.Accessed !, Culu ,0**". )I+ 7erhard Dorf and, 7.A ?icher (.< 6hesis !,000",HDesign of powerline home Automation systemH, 1niversity of -retoria, <outh Africa. )A+ 8lena (ainardi and (arcello %onfY,! ,00'" E-owerline ommunication in Home;%uilding Automation systems H, 1niversity of 4errara ,Italy. )&+ Halid Hrasnica, Abdel.4.Haidine and ?alf 2ehner E%roadband powerline communications networ$sH, =illey ,005. )B+ www.simplymodbus.caMfa#.htm Accessed !*' 9ctober ,0**". )*0+ Modbus Application Protocol v1.1 b, Available atJ

www.modbus.orgMdocsM(odbusLApplicationL-rotocolLV*L*b.pdf Accessed !*A 3ovember ,0**". )**+ Datasheet of PIC18F !" Available at ww*.microchip.com Accessed ! @ Culy ,0**". )*,+ #DA !$!1 Datasheet Available at J www.n/p.comMdocumentsMdataLsheetM6DA'0'*A.pdf Accessed ! *@ <eptember ,0**". )*@+ M#!$!%i &MI Data sheet Available at ftpJMMftp.weinte$.comMData<heetM...M(6I0'IiLData<heetL837L**0 Accessed !,@ <eptember ,0**" . )*5+ Murata #ransfor'er Datasheet Available at J www.murata;ps.comMdataMmagneticsM$mpLA&,'0.pd Accessed !** December ,0**".

)ppendi; )
#ource code for #lave =nit .
(AI3.c Uinclude Zmain.h[

UI3 21D8 Zstdlib.h[ UI36L?DA V9ID I<?LHA3D!void"V r/Ofgetc!pc"W if!r/OO\a\" ?82AQ5L93W if!r/OO\b\" ?82AQIL93W if!r/OO\c\" ?82AQAL93W if!r/OO\d\" ?82AQ&L93W if!r/OO\e\" ?82AQ5L944W if!r/OO\f\" ?82AQIL944W if!r/OO\g\" ?82AQAL944W if!r/OO\h\" ?82AQ&L944W if!r/OO\i\"V fputc!input*,pc"W delayLms!*"W X if!r/OO\.\"V fputc!input,,pc"W delayLms!*"W X if!r/OO\t\"V fputc!ma$e&!temperature*I,0",pc"W delayLms!*0"W fputc!ma$e&!temperature*I,*",pc"W

delayLms!*0"W XMM if!r/OO\t\" XMM rda voidreadLtemp!"V setLadcLchannel!0"W delayLus!'0"W temperature*IO!int*I"!!readLadc!";,"M,"W delayLms!'"W XMM 8nd void readLtemp!"

void main!" V setLtrisLa!0b********"W setLtrisLb!0b00000000"W setLtrisLc!0b*00*****"W setLtrisLd!0b00000000"W setLtrisLe!0b00000000"W setupLadc!adcLcloc$Linternal"W setupLadcLports!A30"W enableLinterrupts!729%A2"W enableLinterrupts!I36L?DA"W %1TT8?L944W ?82AQ5L944W ?82AQIL944W

?82AQAL944W ?82AQ&L944W for!loopO0WloopZ5WloopNN"V 28DL93W %1TT8?L93W delayLms!@00"W %1TT8?L944W 28DL944W delayLms!@00"W XMM end for 28DL944W while!6?18"V input*OinputLstate!I3L*"W delayLms!*0"W input,OinputLstate!I3L,"W delayLms!*0"W readLtemp!"W X X

'eader file for slaveUinclude Z*&45',.h[ Udevice RO*I,adcO*0 U41<8< H< U41<8< 39=D6 U41<8< 39%?9=3916 U41<8< 392VIM9 MM3o =atch Dog 6imer MM3o brownout reset MM3o low voltage prgming, %@!-I *I" or %'!-I *&" used for

Uuse delay!cloc$O*0000000" Udefine 68(-LI3 Udefine I3L* Udefine I3L, -I3LA0

-I3LA* -I3LA, -I3L%@ -I3L%' -I3L%I -I3L%A

Udefine ?82AQL5 Udefine ?82AQLI Udefine ?82AQLA Udefine ?82AQL& Udefine 28D Udefine %1TT8? Udefine 28DL93 Udefine 28DL944

-I3LD0 -I3L8, outputLlow!28D" outputLhigh!28D"

Udefine %1TT8?L93 outputLhigh!%1TT8?" Udefine %1TT8?L944 outputLlow!%1TT8?" Udefine ?82AQ5L93 outputLhigh!?82AQL5" Udefine ?82AQ5L944 outputLlow!?82AQL5" Udefine ?82AQIL93 outputLhigh!?82AQLI" Udefine ?82AQIL944 outputLlow!?82AQLI" Udefine ?82AQAL93 outputLhigh!?82AQLA" Udefine ?82AQAL944 outputLlow!?82AQLA" Udefine ?82AQ&L93 outputLhigh!?82AQL&" Udefine ?82AQ&L944 outputLlow!?82AQL&"

Uuse ?<,@,!baudOI00,/mitO-I3L I,rcvO-I3L A,<6?8A(Opc" unsigned int*I temperature*IW static unsigned int& loop,input*,input,W static char r/W

#ource code for master


Uinclude Z*&45',.h[ Udevice RO*I AD O*0 Ufuses H<,-16,39=D6,392V-,39%?9=3916,-?968 6MMwatcdog Uuse delay!cloc$ O ,0000000" Uuse ?<,@,!baudOI00,/mitO-I3L%I,rcvO-I3L%A,<6?8A(Omodem,6I(8916O'00" Udefine H(IL(9D%1<L?61 static int& byteLl,byteLh,processLloopW Uuse fastLio!A" Uuse fastLio!%" MMUuse fastLio! " Udefine 93 Udefine 944 MM 4or Udefine L*DHz Udefine L'00Hz Udefine L(<L*000 Udefine L(<L'00 Udefine L-?8<86 * 0 50(Hz ,0(Hz '''@' MM I0'@' MM 5''@' MM '''@' '''@' MM I0'@'

'00 MM '00 ,'0 MM ,'0 L*DHz

Uinclude ]variables.h] Uinclude ]modbus.h] UI36L6I(8?* void t*LinterruptLhandler!"V setLtimer*!L-?8<86"W enableLinterrupts!729%A2"W X

void main!" V setLtrisLa!0b****0000"W setLtrisLb!0b********"W setLtrisLd!0b********"W

enableLinterrupts!I36L6I(8?*"W enableLinterrupts!729%A2"W setupLtimerL*!6*LI368?3A2 ^ 6*LDIVL%QL*"W

modbusLinit!"W setLtrisLc!0b*0******"W coils)0+O0/44W processLloopO0W while!6?18"V while!_modbusL$bhit!""W MMif!modbusL$bhit!""V processLmodbus!"WMM MMX

disableLinterrupts!729%A2"W switch!processLloop"V case 0J fputc!\i\,modem"W inputs)0+ O !int*I"!fgetc!modem""W brea$W case *J fputc!\t\,modem"W byteLlOfgetc!modem"W byteLhOfgetc!modem"W holdLregs)0+Oma$e*I!byteLh,byteLl"W brea$W case ,J if!bitLtest!coils)0+,@"" fputc!\a\,modem"W else fputc!\e\,modem"W brea$W case @J if!bitLtest!coils)0+,'"" fputc!\b\,modem"W else fputc!\f\,modem"W brea$W case 5J if!bitLtest!coils)0+,I"" fputc!\c\,modem"W else fputc!\g\,modem"W brea$W case 'J

if!bitLtest!coils)0+,A"" fputc!\d\,modem"W else fputc!\h\,modem"W brea$W defaultJ brea$W X processLloopNNW if!processLloop[OI" processLloopO0W enableLinterrupts!729%A2"W delayLms!'00"W rs,@,Lerrors O 0W XMM U83D while!6?18" XMM U83D main!"

Header file for variablesJ Udefine LLVA?IA%28<LH Udefine (A:L?87< Udefine (A:LI3-16< Udefine (A:L 9I2< *I MM @, MM Input signalsMswitches *Mbit @, MM 9utput signalsMrelays *Mbit

static unsigned int& static unsigned int&

coils)(A:L 9I2<M&+W inputs)(A:LI3-16<M&+W

static unsigned int*I inputLregs)(A:L?87<+W static unsigned int*I holdLregs)(A:L?87<+W static unsigned int& static unsigned int& Lbytes,LpointsW rdyLdata)(A:LI3-16<M&+W

)ppendi; 3
PC3 la( outs

- % layout of slave board .

)ppendi; C
#tep ise 'MI confi&uration in ?as( builder 4,,,

)ppendi; >
Components list"esistance*00 ohm *0 D ohm * ( ohm Capacitors0.*uf 5An4 ,'0V /, type ,Apf *0uf I.CCs (a/ ,@, -I *&45', 2(@' 2( A&0' 6DA'0'* 123,00@ - &*A Transistors?ed 28D,%uzzer TransformerJ A&,'0( "ela(s 1) 12<

You might also like