You are on page 1of 93

Page |1

X10 HOME AUTOMATION SYSTEM Gujarat


University

CONTENTS
1. INTRODUCTION............................................................................................................................................5
1.1 HOME WIRING HISTORY............................................................................................................................6
HISTORY
1.2 OVERVIEW AND BENEFITS.........................................................................................................................7
BENEFITS
1.3 STANDARDS AND BRIDGES........................................................................................................................8
BRIDGES
1.4 SOME HOME AUTOMATION STANDARDS.................................................................................................9
STANDARDS
1.5 THE ELEMENTS OF A DOMOTICS SYSTEM ARE:.......................................................................................11
ARE:
1.6 ARCHITECTURE........................................................................................................................................11
ARCHITECTURE
1.6.1 CENTRALIZED ARCHITECTURE...........................................................................................................11
1.6.2 DISTRIBUTED ARCHITECTURE...........................................................................................................11
1.6.3 MIXED ARCHITECTURE.....................................................................................................................11
1.7 INTERCONNECTION.................................................................................................................................11
INTERCONNECTION
1.7.1 BY WIRE:..........................................................................................................................................11
1.7.2 WIRELESS:........................................................................................................................................12
1.7.3 BOTH WIRELESS AND WIRE...............................................................................................................12
1.8 CLASSIFICATIONS OF DOMESTIC NETWORK TECHNOLOGIES..................................................................12
TECHNOLOGIES
1.8.1 DEVICE INTERCONNECTION:.............................................................................................................12
1.8.2 CONTROL AND AUTOMATION NETS:...................................................................................................12
1.8.3 DATA NETS:......................................................................................................................................13
1.9 TASKS......................................................................................................................................................13
TASKS
1.9.1 HVAC..............................................................................................................................................13
HVAC
1.9.2 LIGHTING.........................................................................................................................................13
1.9.3 NATURAL LIGHTING..........................................................................................................................14
1.9.4 AUDIO..............................................................................................................................................14
1.9.5 VIDEO..............................................................................................................................................14
1.9.6 SECURITY.........................................................................................................................................14
1.9.7 DETECTION OF POSSIBLE INTRUSION.................................................................................................15
1.9.8 INTERCOMS.......................................................................................................................................15
1.9.9 ROBOTICS.........................................................................................................................................15
1.9.10 OTHER SYSTEMS...............................................................................................................................15
1.10 COSTS......................................................................................................................................................16
COSTS
1.11 SMART GRID............................................................................................................................................16
GRID
MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)
PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
Page |2
X10 HOME AUTOMATION SYSTEM Gujarat
University

2. X10 HOME AUTOMATION.........................................................................................................................17


2.1 POWER LINE CARRIER CONTROL OVERVIEW...........................................................................................18
OVERVIEW
2.2 X10 PROTOCOL........................................................................................................................................19
PROTOCOL
2.3 HOW DOES THE X-10 PROTOCOL WORK?...............................................................................................19
WORK?
2.4 LIST OF X10 COMMANDS:.......................................................................................................................23
COMMANDS:
2.5 POWER LINE PROTOCOL PHYSICAL LAYER DETAILS.................................................................................24
DETAILS
2.6 THE RADIO PROTOCOL............................................................................................................................25
PROTOCOL
2.7 DEVICE MODULES...................................................................................................................................26
MODULES
2.8 CONTROLLERS.........................................................................................................................................27
CONTROLLERS
2.9 X10 THEORY............................................................................................................................................28
THEORY
3. HARDWARE.................................................................................................................................................33
3.1 BASIC MODEL OF THE SYSTEM................................................................................................................34
SYSTEM
3.2 SUMMARY OF MICROCONTROLLER RESOURCE USE...............................................................................35
USE
3.3 MEMORY USAGE.....................................................................................................................................36
USAGE
3.4 ZERO-CROSSING DETECTOR....................................................................................................................37
DETECTOR
3.5 BASIC LOW FREQUENCY CIRCUIT............................................................................................................38
CIRCUIT
3.5.1 COMPARATORS.................................................................................................................................41
3.6 120 KHZ CARRIER DETECTOR...................................................................................................................44
DETECTOR
3.7 120 KHZ CARRIER GENERATOR................................................................................................................45
GENERATOR
3.8 TRANSFORMER-LESS POWER SUPPLY.....................................................................................................47
SUPPLY
3.9 LOAD SWITCH..........................................................................................................................................48
SWITCH
3.10 LCD MODULE...........................................................................................................................................49
MODULE
3.11 REAL-TIME CLOCK...................................................................................................................................49
CLOCK
3.12 PUSH BUTTONS.......................................................................................................................................50
BUTTONS
3.13 LIGHT SENSOR.........................................................................................................................................50
SENSOR
3.14 IN-CIRCUIT DEBUGGER...........................................................................................................................50
DEBUGGER
3.15 CONTROL DATA STORAGE.......................................................................................................................51
STORAGE
3.16 ENVELOPE DETECTOR..............................................................................................................................52
DETECTOR
3.16.1 DEFINITION OF THE ENVELOPE.........................................................................................................53
3.16.2 DIODE DETECTOR.............................................................................................................................54
3.16.3 PRECISION DETECTOR.......................................................................................................................54
3.16.4 DRAWBACKS.....................................................................................................................................54
MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)
PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
Page |3
X10 HOME AUTOMATION SYSTEM Gujarat
University

3.16.5 DEMODULATION OF SIGNALS............................................................................................................55


3.16.6 AUDIO..............................................................................................................................................55
3.17 SCOPE ADAPTER CIRCUIT........................................................................................................................56
CIRCUIT
3.18 HIGH-PASS FILTER...................................................................................................................................57
FILTER
3.18.1 FIRST-ORDER CONTINUOUS-TIME IMPLEMENTATION..........................................................................58
3.18.2 DISCRETE-TIME REALIZATION............................................................................................................59
4. ALL CIRCUIT DIAGRAM AT A SCOPE.....................................................................................................61
5. SOFTWARE...................................................................................................................................................66
5.1 APPLICATION FIRMWARE OVERVIEW.....................................................................................................66
OVERVIEW
5.2 X-10 LIBRARY...........................................................................................................................................66
LIBRARY
5.2.1 SKIPIFTXREADY...............................................................................................................................67
5.2.2 SENDX10ADDRESS (HOUSE, UNIT)...................................................................................................67
5.2.3 SENDX10ADDRESSVAR.....................................................................................................................68
5.2.4 SENDX10COMMAND (HOUSE, FUNCTION)........................................................................................68
5.2.5 SENDX10COMMANDVAR...................................................................................................................69
5.2.6 SKIPIFRXDONE................................................................................................................................69
5.2.7 SKIPIFADDRESSRCVD.......................................................................................................................70
5.2.8 SKIPIFCOMMANDRCVD.....................................................................................................................70
5.2.9 READX10MESSAGE...........................................................................................................................70
5.3 INTRODUCTION TO KEIL SOFTWARE.......................................................................................................71
SOFTWARE
5.4 WHAT IS ΜVISION3?...............................................................................................................................71
ΜVISION3?
5.5 STEPS FOLLOWED IN CREATING AN APPLICATION IN ΜVISION3:...........................................................71
ΜVISION3:
5.6 DEVICE DATABASE...................................................................................................................................77
DATABASE
5.7 PERIPHERAL SIMULATION.......................................................................................................................77
SIMULATION
5.8 PROGRAMMER........................................................................................................................................77
PROGRAMMER
5.9 PROLOAD PROGRAMMING SOFTWARE..................................................................................................78
SOFTWARE
6. HOME CONTROLLER OPERATING INSTRUCTIONS.............................................................................80
6.1 “WELCOME SCREEN”..............................................................................................................................80
SCREEN”
6.1.1 SELECT FUNCTION SCREEN...............................................................................................................81
6.1.2 SET SYSTEM TIME SCREEN................................................................................................................82
6.1.3 SELECT SYSTEM ADDRESS SCREEN....................................................................................................83
6.1.4 SET LIGHT SENSOR SCREEN..............................................................................................................84
MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)
PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
Page |4
X10 HOME AUTOMATION SYSTEM Gujarat
University

6.1.5 PROGRAM UNIT SCREEN...................................................................................................................85


7. WEAK POINTS AND LIMITATIONS..........................................................................................................86
7.1 COMPATIBILITY WITH INSTALLED WIRING AND APPLIANCES.................................................................86
APPLIANCES
7.2 COMMANDS GETTING LOST...................................................................................................................87
LOST
7.3 RELATIVELY SLOW...................................................................................................................................88
SLOW
7.4 LIMITED FUNCTIONALITY........................................................................................................................88
FUNCTIONALITY
7.5 INTERFERENCE AND LACK OF ENCRYPTION............................................................................................88
ENCRYPTION
7.6 BRIDGES..................................................................................................................................................88
BRIDGES
8. ADVANTAGE...............................................................................................................................................89
9. CONCLUSION...............................................................................................................................................90
10. TROUBLE SHOOTING.............................................................................................................................91

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
Page |5
X10 HOME AUTOMATION SYSTEM Gujarat
University

1. INTRODUCTION

W e live in a world where everything can be controlled and operated


automatically, but there are still a few important sectors in our country where
automation has not been adopted or not been put to a full-fledged use, perhaps because
of several reasons one such reason is cost. One such field is that of Home Automation.

Home automation (also called Domotics) designates an emerging practice of


increased automation of household appliances and features in residential dwellings,
particularly through electronic means that allow for things impracticable, overly
expensive or simply not possible in recent past decades. The term may be used in
contrast to the more mainstream "building automation", which refers to industrial uses of
similar technology, particularly the automatic or semi-automatic control of lighting,
doors and windows, Heating, Ventilation and Air Conditioning, and security and
surveillance systems.

The techniques employed in home automation include those in building


automation as well as the control of home entertainment systems, houseplant watering,
pet feeding, changing the ambiance "scenes" for different events (such as dinners or
parties), and the use of domestic robots.

Typically, it is easier to more fully outfit a house during construction due to the
accessibility of the walls, outlets, and storage rooms, and the ability to make design
changes specifically to accommodate certain technologies. Wireless systems are
commonly installed when outfitting a pre-existing house, as they obviate the need to
make major structural changes. These communicate via radio or infrared signals with a
central controller.

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
Page |6
X10 HOME AUTOMATION SYSTEM Gujarat
University

1.1 HOME WIRING HISTORY


Traditionally, homes have been wired for four systems: electrical power,
telephones, TV outlets (cable or antenna), and a doorbell. Typically, components and
wiring for these are kept within a closet, power metering box or a patch panel.

A television remote control was first


patented in 1950, [citation needed] and a remote
control device was first used by the Germans in
World War I to control motorboats. With the
invention of the electronic micro (auto)
controller and the widespread uptake of digital
communication technology, the cost of
electronic control fell rapidly and reliability
improved. Remote and intelligent control
technologies were adopted by the building
services industry and appliance manufacturers
worldwide, as they offer the end user easily
accessible and/or greater control of their
products.

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
Page |7
X10 HOME AUTOMATION SYSTEM Gujarat
University

1.2 OVERVIEW AND BENEFITS


As the amount of controllable fittings and domestic appliances in the home rises,
the ability of these devices to interconnect and communicate with each other digitally
becomes a useful and desirable feature. The consolidation of control or monitoring
signals from appliances, fittings or basic services is an aim of Home automation.

In simple installations this may be as straightforward as turning on the lights when


a person enters the room. In advanced installations, rooms can sense not only the
presence of a person inside but know who that person is and perhaps set appropriate
lighting, temperature, music levels or television channels, taking into account the day of
the week, the time of day, and other factors. Other automated tasks may include setting
the air conditioning to an energy saving setting when the house is unoccupied, and
restoring the normal setting when an occupant is about to return. More sophisticated
systems can maintain an inventory of products, recording their usage through an RFID
tag, and prepare a shopping list or even automatically order replacements. Home
automation can also provide a remote interface to home appliances or the automation
system itself, via telephone line, wireless transmission or the internet, to provide control
and monitoring via a Smart Phone or Web browser. An example of a remote monitoring
implementation of home automation could be when a smoke detector detects a fire or
smoke condition, and then all lights in the house will blink to alert any occupants of the
house to the possible fire. If the house is equipped with a home theatre, a home
automation system can shut down all audio and video components to display the alert or
make an audible announcement. The system could also call the home owner on their
mobile phone to alert them, or call the fire brigade or alarm monitoring company to bring
it to their attention.

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
Page |8
X10 HOME AUTOMATION SYSTEM Gujarat
University

1.3 STANDARDS AND BRIDGES


There have been many attempts to standardise the forms of hardware, electronic
and communication interfaces needed to construct a home automation system. Specific
domestic wiring and communication standards include:

BACnet
INSTEON
X10
KNX (Standard)
LonWorks
C-Bus
SCS BUS with OpenWebNet
Universal Powerline bus (UPB)
ZigBee
Z-Wave

Some standards use additional communication and control wiring, some embed
signals in the existing power circuit of the house, some use radio frequency (RF) signals,
and some use a combination of several methods. Control wiring is hardest to retrofit into
an existing house. Some appliances include USB that is used to control it and connect it
to a domotics network. Bridges translate information from one standard to another (eg.
from X10 to European Installation Bus).

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
Page |9
X10 HOME AUTOMATION SYSTEM Gujarat
University

1.4 SOME HOME AUTOMATION STANDARDS

Maximum
Technology Transmission medium Transmission speed distance to
the device

Unshielded twisted pair 10 Mbit/s – 1 Gbit/s 100 m

Ethernet {IEEE 802.3}
Optical fiber 1 Gbit/s – 10 Gbit/s 2 km – 15 km

Electrical wiring 14 Mbit/s - 200 Mbit/s 200 m


HomePlug {IEEE P1901}

Electrical wiring 200 Mbit/s 200 m


Universal Powerline Association

Electrical wiring / Telephone up to 1 Gbit/s N/A


ITU G.hn {G.9960} line / Coaxial cable

HomePNA {G.9951, G.9952, G.9953, Telephone line 10 Mbit/s 300 m


and G.9954}

Radio frequency 11 Mbit/s – 248 Mbit/s 30 m – 100 m


Wi-Fi {IEEE 802.11}

Unshielded twisted pair / Optical fiber 400 Mbit/s – 3.2 4.5 m – 70 m


FireWire {IEEE 1394} Gbit/s

Bluetooth {IEEE 802.15.1 (v1.1 Radio frequency 1 Mbit/s – 10 Mbit/s 10 m – 100 m


only)}

Infrared 9600 bit/s – 4 Mbit/s 2m


IRDA

Twisted pair / Electrical 1200 bit/s – 9600 bit/s 1000 m


C-Bus wiring / Radio
frequency / Infrared / Ethernet / Wi-Fi
MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)
PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 10
X10 HOME AUTOMATION SYSTEM Gujarat
University

Twisted pair / Electrical 1.70 kbit/s – 1.28 1500 m – 2700


wiring / Radio Mbit/s m
LonWorks {ISO/IEC 14908}
frequency / Infrared / Coaxial /Optical
fiber / IP tunneling

Electrical wiring / Radio frequency 1.2 kbit/s 1,000 m+


(Electrical
INSTEON
wiring), 50 m+
(Wireless)

Electrical wiring 50 bit/s – 60 bit/s


X10

Twisted pair / Electrical 1200 bit/s – 9600 bit/s 300 m – 1000


European Installation
wiring / Radio m
Bus / KNX {ISO/IEC 14543-3}
frequency / Infrared / Ethernet

Twisted pair / Electrical wiring 2.4 kbit/s – 48 kbit/s


EHS

Twisted pair 4800 bit/s 200 m – 1500


Batibus m

ZigBee / ZigBee Pro{IEEE Radio frequency 20 kbit/s – 250 kbit/s 10 m – 1500 m


802.15.4 (radio-layer only, not
protocol)}

Radio frequency 9.6 kbit/s – 40 kbit/s 1 m – 75 m


Z-Wave

Twisted pair 12 Mbit/s – 480 Mbit/s 5m


USB

Table: 1.1

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 11
X10 HOME AUTOMATION SYSTEM Gujarat
University

1.5 THE ELEMENTS OF A DOMOTICS SYSTEM ARE:


Hardware controllers or software controllers
Sensors
Actuators

1.6 ARCHITECTURE
From the point of view of where the intelligence of the domotic system resides,
there are three different architectures:

1.6.1 CENTRALIZED ARCHITECTURE


A centralized controller receives information of multiple sensors and, once
processed, generates the opportune orders for the actuators.

1.6.2 DISTRIBUTED ARCHITECTURE


All the intelligence of the system is distributed by all the modules that are sensors
or actuators. Usually it is typical of the systems of wiring in bus.

1.6.3 MIXED ARCHITECTURE


Systems with decentralized architecture as far as which they have several small
devices able to acquire and to process the information of multiple sensors and to
transmit them to the rest of devices distributed by the house.

1.7 INTERCONNECTION

1.7.1 BY WIRE:
Optical fiber
Cable (coaxial and twisted pair), including : xDSL
Powerline, including : INSTEON
X10

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 12
X10 HOME AUTOMATION SYSTEM Gujarat
University

1.7.2 WIRELESS:
Radio frequency, including: INSTEON
Wi-Fi
GPRS and UMTS
Bluetooth
DECT
ZigBee
Z-Wave
ONE-NET
EnOcean
Infra-red, including : Consumer IR

1.7.3 BOTH WIRELESS AND WIRE


INSTEON

1.8 CLASSIFICATIONS OF DOMESTIC NETWORK


TECHNOLOGIES

1.8.1 DEVICE INTERCONNECTION:


FireWire
Bluetooth
USB
IrDA

1.8.2 CONTROL AND AUTOMATION NETS:


C-Bus (protocol)
Universal Powerline Bus
Konnex
Lonworks
X10
ONE-NET
EIB
EHS
BatiBUS
MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)
PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 13
X10 HOME AUTOMATION SYSTEM Gujarat
University

ZigBee
EnOcean
SCS BUS - OpenWebNet

1.8.3 DATA NETS:


Ethernet
Homeplug
HomePNA
WiFi

1.9 TASKS

1.9.1 HVAC
Heating, Ventilation and Air Conditioning (HVAC) solutions include temperature
and humidity control. This is generally one of the most important aspects to a
homeowner. An Internet-controlled thermostat, for example, can both save money and
help the environment, by allowing the homeowner to control the building's heating and
air conditioning systems remotely.

1.9.2 LIGHTING
Lighting control systems can be used to control household electric lights in a
variety of ways:

Extinguish all the lights of the house.


Replace manual switching with Automation of on and off signals for any or all
lights.
Regulation of electric illumination levels according to the level of ambient light
available.
Change the ambient color of lighting via control of LEDs or electronic dimmers

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 14
X10 HOME AUTOMATION SYSTEM Gujarat
University

1.9.3 NATURAL LIGHTING


Natural lighting control involves controlling window shades, LCD shades,
draperies and awnings. Recent advances include use of RF technology to avoid wiring to
switches and integration with third party home automation systems for centralized
control.

1.9.4 AUDIO
This category includes audio switching and distribution. Audio switching
determines the selection of an audio source. Audio distribution allows an audio source to
be heard in one or more rooms. This feature is often referred to as 'multi-zone' audio.

There are three major components that allow listen to audio throughout your
home, or business:

CAT 5e/ CAT6 cable from a central audio unit.


A keypad to control volume and sources.
2 sets of speaker cabling (4 ply from amplifier, and 2 ply from key pad to the
speakers).

1.9.5 VIDEO
This includes video switching and distribution, allowing a video source to be
viewed on multiple TVs. This feature is often referred to as 'multi-zone' video.
Integration of the intercom to the telephone, or of the video door entry system to the
television set, allowing the residents to view the door camera automatically.

1.9.6 SECURITY
With Home Automation, the consumer can select and watch cameras live from an
Internet source to their home or business. Security cameras can be controlled, allowing
the user to observe activity around a house or business right from a Monitor or touch
panel. Security systems can include motion sensors that will detect any kind of
unauthorized movement and notify the user through the security system or via cell
phone.

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 15
X10 HOME AUTOMATION SYSTEM Gujarat
University

1.9.7 DETECTION OF POSSIBLE INTRUSION


Sensors of detection of movement
Sensors of magnetic contact of door/window
Sensors of glass breaking
Sensors of pressure changes
Simulation of presence.
Detection of fire, gas leaks, water leaks (see fire alarm and gas alarm)
Medical alert. Teleassistance.
Precise and safe closing of blinds.

1.9.8 INTERCOMS
An intercom system allows communication via a microphone and loud speaker
between multiple rooms. Ubiquity in the external control as much internal, remote
control from the Internet, PC, wireless controls (eg. PDA with WiFi), electrical
equipment.

Transmission of alarms.
Intercommunications.

1.9.9 ROBOTICS
Control of home robots, using if necessary domotic electric beacon.

Home robot communication (i.e. using WiFi) with the domotic network and other home
robots.

1.9.10 OTHER SYSTEMS


A homemade Internet-enabled cat feeder. Using special hardware, almost any
device can be monitored and controlled automatically or remotely.

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 16
X10 HOME AUTOMATION SYSTEM Gujarat
University

Including:

Coffee pot
Garage door
Pet feeding and watering
Plant watering
Pool pump(s) and heater, Hot tub and Spa
Sump Pump

1.10 COSTS
An automated home can be a very simple grouping of controls, or it can be heavily
automated where any appliance that is plugged into electrical power is remotely
controlled. Costs mainly include equipment, components, furniture, and custom
installation.

1.11 SMART GRID


In 2009 President Barack Obama asked the United States Congress "to act without
delay" to pass legislation that included doubling alternative energy production in the next
three years and building a new electricity "smart grid". On April 13, 2009, George W.
Arnold was named the first National Coordinator for Smart Grid Interoperability. In June
2009, the NIST announced a smart grid interoperability project via IEEE P2030.

Home automation technologies like Zigbee, INSTEON and Zwave are viewed as
integral additions to the Smart Grid. The ability to control lighting, appliances, HVAC as
well as Smart Grid applications (load shedding, demand response, real-time power usage
and price reporting) will become vital as Smart Grid initiatives are rolled out.

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 17
X10 HOME AUTOMATION SYSTEM Gujarat
University

2. X10 HOME AUTOMATION

X 10 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. A wireless radio based
protocol transport is also defined.

X10 was developed in 1975 by PICO Electronics of Glenrothes, Scotland, in order


to allow remote control of home devices and appliances. It was the first general
purposedomotic network technology and remains the most widely available.The official
website for PICO Electronics is “http://www.picoelectronics.com/”. Although a number
of higher bandwidth alternatives exist including KNX, INSTEON, BACnet, and
LonWorks, X10 remains popular in the home environment with millions of units in use
worldwide, and inexpensive availability of new components. Plug-in modules available
from various vendors enable users to create home automation systems by using the AC
wiring ready installed within a home.

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. This
application note discusses the implementation of X-10 on a PIC MCU to create a home
controller that can both send and receive X-10 signals. The reader may implement the
home controller as is, or adapt the circuits and firmware to other applications. A library

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 18
X10 HOME AUTOMATION SYSTEM Gujarat
University

of X-10 functions is provided to facilitate development of other X-10 applications using


PIC MCUs.

2.1 POWER LINE CARRIER CONTROL OVERVIEW


Household electrical wiring (the same which powers lights and appliances) is used
to send digital data between X10 devices. This digital data is encoded onto a 120 kHz
carrier which is transmitted as bursts during the relatively quiet zero crossings of the 50
or 60 Hz AC alternating current waveform. One bit is transmitted at each zero crossing.

The digital data consists of an address and a command sent from a controller to a
controlled device. More advanced controllers can also query equally advanced devices to
respond with their status. This status may be as simple as "off" or "on", or the current
dim level, or even the temperature or other sensor reading. Devices usually plug into the
wall where a lamp, television, or other household appliance plugs in; however some
built-in controllers are also available for wall switches and ceiling fixtures.

carrying the signal cannot pass through a


power transformer or across the phases of a
multiphase system. For split phase systems, the
signal can be passively coupled from phase-to-phase
using a passive capacitor, but for three phase
systems or where the capacitor provides insufficient
coupling, an active X10 repeater can be used. To
allow signals be coupled across phases and still match each phase's zero crossing point,
each bit is transmitted three times in each half cycle, offset by 1/6th cycle.

It may also be desirable to block X10 signals from leaving the local area so, for
example, the X10 controls in one house don't interfere with the X10 controls in a

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 19
X10 HOME AUTOMATION SYSTEM Gujarat
University

neighboring house. In this situation, inductive filters can be used to attenuate the X10
signals coming into or going out of the local area.

2.2 X10 PROTOCOL


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.

The protocol may transmit a message that says "select code A3", followed by "turn
on", which commands unit "A3" to turn on its device. Several units can be addressed
before giving the command, allowing a command to affect several units simultaneously.
For example, "select A3", "select A15", "select A4", and finally, "turn on", causes units
A3, A4, and A15 to all turn on.

2.3 HOW DOES THE X-10 PROTOCOL WORK?


X-10 transmissions are synchronized with the zero-crossings on the AC power line. By
monitoring for the zero-crossings, X-10 devices know when to transmit or receive X-10
information. A binary ‘1’ is represented by a 1 ms long burst of 120 kHz, near the zero-
crossing point of the AC. A binary zero is represented by the lack of the 120 kHz burst.

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 20
X10 HOME AUTOMATION SYSTEM Gujarat
University

X-10 TRANSMISSION TIMING

Note 1: These 120 kHz carrier bursts are timed to coincide with the zero-crossing of the
other phases, when implemented.

A complete X-10 message is composed of a start code (1110), followed by a house code,
followed by a key code. The key code may be either a unit address or a function code,
depending on whether the message is an address or a command. Table 1 and Table 2
show the possible values of the house and key codes.

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 21
X10 HOME AUTOMATION SYSTEM Gujarat
University

TABLE 1: HOUSE CODES TABLE A-2: KEY CODES

When transmitting the codes in Table 1 and Table 2, two zero-crossings are used to
transmit each bit as complementary bit pairs (i.e., a zero is represented by 0-1, and a one
is represented by 1-0). For example, in order to send the house code A, the four-bit code
in Table A-1 is 0110, and the code transmitted as complimentary bit pairs is 01101001.
Since house and key codes are sent using the complimentary format, the start code is the
only place where the pattern 1110 will appear in an X-10 data stream.

The key code, which is 5-bits long in Table 2, takes 10 bits to represent in the
complimentary format. Because the last bit of the key code is always zero for a unit
address and one for a function code, the last bit of the key code can be treated as a suffix
MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)
th
PATEL JIGAR MANUBHAI (06EC030) 8
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 22
X10 HOME AUTOMATION SYSTEM Gujarat
University

that denotes whether the key code is a unit address or function code. A complete block of
data consists of the start code, house code, key code and suffix. Each data block is sent
twice, with 3 power line cycles, or six zero-crossings, between each pair of data blocks.
For example, to turn on an X-10 module assigned to house code A, unit 2, the following
data stream would be sent on the power line, one bit per zero-crossing.

First, send the address twice:

Next, wait for three cycles (six zero-crossings):

000000

Then, send the command twice:

Lastly, wait for three cycles (six zero-crossings) before sending the next block:

000000

There are exceptions to this format. For example, the bright and dim codes do not require
the 3-cycle wait between consecutive dim commands or consecutive bright commands.

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 23
X10 HOME AUTOMATION SYSTEM Gujarat
University

2.4 LIST OF X10 COMMANDS:

Code Function Description

0000 All units off Switch off all devices with the house code indicated in the message

0001 All lights on Switches on all lighting devices (with the ability to control brightness)

0010 On Switches on a device

0011 Off Switches off a device

0100 Dim Reduces the light intensity

0101 Bright Increases the light intensity

0111 Extended code Extension code

1000 Hail request Requests a response from the device(s) with the house code indicated in the message

1001 Hail acknowledge Response to the previous command

101x Pre-set dim Allows the selection of two predefined levels of light intensity

1101 Status is on Response to the Status Request indicating that the device is switched on

1110 Status is off Response indicating that the device is switched off

1111 Status request Request requiring the status of a device

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 24
X10 HOME AUTOMATION SYSTEM Gujarat
University

2.5 POWER LINE PROTOCOL PHYSICAL LAYER DETAILS


In the 60 Hz AC current flow, a bit value of one is represented by a 1 millisecond
burst of 120 kHz at the zero crossing point (nominally 0°, but within 200 microseconds
of the zero crossing point), immediately followed by the absence of a pulse. A zero value
is represented by the absence of 120 kHz at the zero crossing point (pulse), immediately
followed by the presence of a pulse. All messages are sent twice to reduce false
signaling. After allowing for retransmission, line control, etc, data rates are around 20
bit/s, making X10 data transmission so slow that the technology is confined to turning
devices on and off or other very simple operations.

In order to provide a predictable start point, every data frame transmitted always
begin with a start code of 1110. Immediately after the start code, a house code (A–P)
appears, and after the letter code comes afunction code. Function codes may specify a
unit number code (1–16) 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.

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.

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.

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 25
X10 HOME AUTOMATION SYSTEM Gujarat
University

2.6 THE RADIO PROTOCOL


To allow the operation of wireless keypads, remote
switches, and the like, a radio protocol is also defined.
Operating at a frequency of 310 MHz in the U.S. and 433
MHz inEuropean systems, the wireless devices send data
packets that are very similar to ordinary X10 power line
control packets. A radio receiver then provides a bridge
which translates these radio packets to ordinary X10
power line control packets.

The devices available using the radio protocol include:

Keypad controllers ("clickers").


Keychain controllers that can control one to four X10 devices.
Burglar alarm modules that can transmit sensor data.
Passive infrared switches to control lighting and X-10 chimes.
Non-passive information bursts.

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 26
X10 HOME AUTOMATION SYSTEM Gujarat
University

2.7 DEVICE MODULES


Depending on the load that is to be controlled,
different modules must be used. For incandescent lamp
loads, a lamp module or wall switch module can be used.
These modules switch the power using a TRIAC solid state
switch and are also capable of dimming the lamp load.
Lamp modules are almost silent in operation, and generally
rated to control loads ranging from around 40 watts to 500
watts.

For loads other than incandescent lamps, such as


fluorescent lamps, high-intensity discharge lamps, and electrical home appliances, the
TRIAC-based electronic switching in the lamp module is unsuitable and an appliance
module must be used instead. These modules switch the power using an impulse relay.
Many device modules offer a feature called local control. If the module is switched off,
operating the power switch on the lamp or appliance will cause the module to turn on. In
this way, a lamp can still be lit or a coffee pot turned on without the need to use an X10
controller. Wall switch modules may not offer this feature. Some wall switch modules
offer a feature called local dimming. Ordinarily, the local push button of a wall switch
module simply offers on/off control with no possibility of locally dimming the controlled
lamp. If local dimming is offered, holding down the push button will cause the lamp to
cycle through its brightness range. Higher end modules have more advanced features
such as programmable on levels, customizable fade rates, the ability to transmit
commands when used (referred to as 2-way devices), and scene support.There are sensor
modules that sense and report temperature, light, infra-red, motion, or contact openings
and closures. Device modules include thermostats, audible alarms and controllers for low
voltage switches.
MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)
PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 27
X10 HOME AUTOMATION SYSTEM Gujarat
University

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 28
X10 HOME AUTOMATION SYSTEM Gujarat
University

2.8 CONTROLLERS
X10 controllers range from extremely simple to
very sophisticated.

The simplest controllers are arranged to control four


X10 devices at four sequential addresses (1–4 or 5–8).
The controllers typically contain the following buttons:

Unit 1 on/off
Unit 2 on/off
Unit 3 on/off
Unit 4 on/off
Brighten/dim (last selected unit)
All lights on/all units off

More sophisticated controllers can control more units and/or incorporate timers
that perform preprogrammed functions at specific times each day. Units are also
available that use passive infrared motion detectors or photocells to turn lights on and off
based on external conditions. Finally, very sophisticated units are available that can be
fully programmed or, like the X10 Firecracker, use a program running in an external
computer. These systems can execute many different timed events, respond to external
sensors, and execute, with the press of a single button, an entire scene, turning lights on,
establishing brightness levels, and so on. Control programs are available for computers
running Microsoft Windows, Apple's Macintosh, Linux and FreeBSD operating systems.
Burglar alarm systems are also available. In these systems, the controller uses X10
protocols or ordinary wiring to interrogate a number of remote sensors that may monitor
doors, windows, and other access points. The controller may then use X10 protocols to
activate lights, sirens, etc.
MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)
PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 29
X10 HOME AUTOMATION SYSTEM Gujarat
University

2.9 X10 THEORY


X-10 communicates between transmitters and receivers by sending and receiving
signals over the power line wiring. These signals involve short RF bursts which represent
digital information.

X10 transmissions are synchronized to the zero


crossing point of the AC power line. The goal should
be to transmit as close to the zero crossing point as
possible, but certainly within 200 microseconds of the
zero crossing point. The PL513 and TW523 provide a
60 Hz square wave with a maximum delay of 100
microseconds from the zero crossing point of the AC power line. The maximum delay
between signal envelope input and 120 kHz output bursts is 50 microseconds. Therefore,
it should be arranged that outputs to the PL513 and TW523 be within 50 microseconds
of this 60 Hz zero crossing reference square wave.

A Binary 1 is represented by a 1 millisecond


burst of 120 kHz at the zero crossing point, and a
Binary 0 by the absence of 120 kHz. The PL513 and
TW523 modulate their inputs (from the O.E.M.) with
120 kHz, therefore only the 1 ms "envelope" need be
applied to their inputs. These 1 millisecond bursts should equally be transmitted three
times to coincide with the zero crossing point of all three phases in a three phase
distribution system. Figure 1 shows the timing relationship of these bursts relative to
zero crossing.

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 30
X10 HOME AUTOMATION SYSTEM Gujarat
University

A complete code transmission encompasses


eleven cycles of the power line. The first two
cycles represent a Start Code. The next four
cycles represent the House Code and the last
five cycles represent either the Number Code (1
thru 16) or a Function Code (On, Off, etc.). This
complete block, (Start Code, House Code, Key
Code) should always be transmitted in groups of
2 with 3 power line cycles between each group
of 2 codes. Bright and dim are exceptions to this
rule and should be transmitted continuously (at
least twice) with no gaps between codes. See
Figure 2

Within each block of data, each four or


five bit code should be transmitted in true
compliment form on alternate half cycles of the power line. I.E. if a 1 millisecond burst
of signal is transmitted on one half cycle (binary 1) then no signal should be transmitted
on the next cycle, (binary 0). See Figure 3. The Tables in Figure 4 show the binary codes
to be transmitted for each House Code and Key Code. The Start Code is always 1110
which is a unique code and is the only code which does not follow the true
complimentary relationship on alternate half cycles. 

Hail Request is transmitted to see if there are any X10 transmitters within listening
range. This allows the O.E.M. to assign a different Housecode if a "Hail Acknowledge"
is received. In a Pre-Set Dim instruction, the D8 bit represents the Most Significant Bit
of the level and H1, H2, H4 and H8 bits represent the Least Significant Bits. 

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 31
X10 HOME AUTOMATION SYSTEM Gujarat
University

The Extended Data code is followed by 8 bit bytes which can represent Analog
Data (after A to D conversion). There should be no gaps between the Extended Data
code and the actual data, and no gaps between data bytes. The first 8 bit byte can be used
to say how many bytes of data will follow. If gaps are left between data bytes, these
codes could be received by X10 modules causing erroneous operation. 

Extended Code is similar to Extended Data: 8 Bit bytes which follow Extended
Code (with no gaps) can represent additional codes. This allows the designer to expand
beyond the 256 codes presently available.

NOTE 1. X10 Receiver Modules require a "silence" of at least 3 power cycles


between each pair of 11 bit code transmissions (no gaps between each pair). The one
exception to this rule is bright and dim codes. These are transmitted continuously with
no gaps between each 11 bit dim code or 11 bit bright code. A 3 cycle gap is necessary
between different codes, i.e. between bright and dim, or 1 and dim, or on and bright, etc. 

NOTE 2. The TW523 Two-Way Power Line Interface cannot receive Extended
Code or Extended Data because these codes have no gaps between them. The TW523
can only receive standard "pairs" of 11 bit X10 codes with 3 power line cycle gaps
between each pair. 

NOTE 3. The TW523 can receive dim and bright codes but the output will
represent the first dim or bright code received, followed by every third code received. i.e.
the output from the TW523 will not be a continuous stream of dim and bright codes like
the codes which are transmitted.

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 32
X10 HOME AUTOMATION SYSTEM Gujarat
University

A Square wave representing zero


crossing detect is provided by the
PL513/TW523 and is within 100
microseconds of the zero crossing point of the
AC power line. The output signal envelope
from the O.E.M. should be within 50 microseconds of this zero crossing detect. The
signal envelope should be 1 ms (-50 microseconds +100 microseconds). See Figure 5

Opto-Coupled 60 Hz reference output (from the PL513/TW523) Transmissions are


to be synchronized to the zero crossing point of the AC power line and should be as
close to true zero crossing as possible. The PL513 and TW523 are designed to be
interfaced to other microprocessor circuitry which outputs X10 codes synchronized to
the zero crossing point of the AC power line. It is therefore necessary to provide a zero
crossing reference for the O.E.M. microprocessor. It is likely that this microprocessor
will have its own "isolated" power supply. It is necessary to maintain this isolation,
therefore the trigger circuit normally used in X10 POWERHOUSE controllers is not
desirable as this would reference the O.E.M. power supply to the AC power line. It is
also not desirable to take the trigger from the secondary side of the power supply
transformer as some phase shift is likely to occur. It is therefore necessary to provide an
opto-coupled 60 Hz reference. 

An opto-coupled 60 Hz square wave is provided at the output of the PL513 and


TW523. X10 codes generated by the O.E.M. product are to be synchronized to this zero
crossing reference. The X10 code envelope generated by the O.E.M. is applied to the
PL513 or TW523 which modulates the envelope with 120 kHz and capacitively couples
it to the AC power line.

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 33
X10 HOME AUTOMATION SYSTEM Gujarat
University

Opto-Coupled Signal Input (to the


PL513/TW523)

The input signal required from the O.E.M.


product is the signal "envelope" of the X10 code
format, i.e. 

High for 1 ms. coincident with zero crossing represents a binary "1" and gates the
120 kHz oscillator through to the output drive circuit thus transmitting 120 kHz onto the
AC power line for 1 ms.

Low for 1 ms. coincident


with the zero crossing point
represents a binary "0" and turns
the 120 kHz oscillator/output
circuit off for the duration of the 1 ms. input.

Opto-Coupled Signal Output (from the TW523)

The "X10 received" output from the TW523 coincides with the second half of
each X10 transmission. This output is the envelope of the bursts of 120 kHz received.
Only the envelope corresponding to the first burst of each group of 3 bursts is available
at the output of the TW523. See Figures 6, 7 and 8.

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 34
X10 HOME AUTOMATION SYSTEM Gujarat
University

3. HARDWARE

T he home controller application described in this application note allows the user to
program on and off times for up to sixteen devices, using a 2 x 16 liquid crystal
display and five push buttons. A built-in light sensor can be used to turn on lights at
dusk, and turn them off at dawn. The home controller is designed to facilitate
experimentation with home automation using the PIC16F877A. In addition to the
PIC16F877A, the board will accept any other PIC MCU that shares the same pinout,
such as the PIC18F452. Therefore, experimenters may expand on the application using
the higher performance of the PIC18 family of parts without changing the hardware.
With care, engineers and home control enthusiasts can experiment with home automation
using the MPLAB ICD 3 development tool. However, proper circuit isolation
precautions must be taken to avoid damage to your computer or development tools.

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 35
X10 HOME AUTOMATION SYSTEM Gujarat
University

3.1 BASIC MODEL OF THE SYSTEM

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

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

Zero-crossing detector
120 kHz carrier detector
120 kHz signal generator
Transformer less power supply

There are several application functions that are not directly associated with the X-
10 interface. User interface functions are accomplished with an LCD display and five
push buttons. A real-time clock is created using Timer1 and an external 32 kHz
oscillator. User modified control data, such as unit on and off times, are stored in the PIC
MCU’s built-in EEPROM. A light sensor and load switch are also used in this
application.
MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)
PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 36
X10 HOME AUTOMATION SYSTEM Gujarat
University

3.2 SUMMARY OF MICROCONTROLLER RESOURCE USE

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 37
X10 HOME AUTOMATION SYSTEM Gujarat
University

3.3 MEMORY USAGE


Memory usage for the X-10 portion of the application is summarized in Table below

SUMMARY OF MEMORY USAGE FOR X-10 FUNCTIONALITY

Memory usage for the entire home controller application is summarized in Table below

SUMMARY OF MEMORY USAGE FOR THE HOME CONTROLLER

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 38
X10 HOME AUTOMATION SYSTEM Gujarat
University

3.4 ZERO-CROSSING DETECTOR


In X-10, information is timed with the zero-crossings of the AC power. A zero-
crossing detector is easily created by using the external interrupt on the RB0 pin and just
one external component, a resistor, to limit the current into the PIC MCU. In the United
States, Vrms = 117 VAC, and the peak line voltage is 165V. If we select a resistor of 5
MΩ, Ipeak = 165V/5 MΩ = 33 μA, which is well within the current capacity of a PIC
MCU I/O pin. Input protection diodes (designed into the PIC MCU I/O pins) clamp any
voltage higher than VDD or lower than VSS. Therefore, when the AC voltage is in the
negative half of its cycle, the RB0 pin will be clamped to VSS - 0.6V. This will be
interpreted as a logic zero. When the AC voltage rises above the input threshold, the
logical value will become a ‘1’. In this application, RB0 is configured for external
interrupts, and the input buffer is a Schmitt trigger. This makes the input threshold 0.8
VDD = 4V on a rising edge and 0.2 VDD = 1V on a falling edge. Upon each interrupt,
the Interrupt Edge Select bit within the OPTION_REG register is toggled so that an
interrupt occurs on every zero-crossing. Using the following equation, it is possible to
calculate when the pin state will change relative to the zero-crossing:

V = Vpk*sin(2*π*f*t),

where Vpk = 165Vand f = 60 Hz On a rising edge, RB0 will go high about 64 μs after
the zero-crossing, and on a falling
edge, it will go low about 16 μs before
the zero-crossing. More information on
interfacing PIC MCUs to AC power
lines can be found in the application

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 39
X10 HOME AUTOMATION SYSTEM Gujarat
University

note AN521, “Interfacing to AC Power Lines”, which is available for download from the
Microchip web site.

A zero crossing detector literally detects the transition of a signal waveform from
positive and negative, ideally providing a narrow pulse that coincides exactly with the
zero voltage condition. At first glance, this would appear to be an easy enough task, but
in fact it is quite complex, especially where high frequencies are involved. In this
instance, even 1 kHz starts to present a real challenge if extreme accuracy is needed.

The not so humble comparator plays a vital role - without it, most precision zero crossing
detectors would not work, and we'd be without digital audio, PWM and a multitude of
other applications taken for granted.

3.5 BASIC LOW FREQUENCY CIRCUIT


Figure below shows the zero crossing detector as used for the dimmer ramp
generator in Project 62. This circuit has been around (almost) forever, and it does work
reasonably well. Although it has almost zero phase inaccuracy, that is largely because
the pulse is so broad that any inaccuracy is completely swamped. The comparator
function is handled by transistor Q1 - very basic, but adequate for the job.

Basic 50/60Hz Zero Crossing Detector


MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)
PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 40
X10 HOME AUTOMATION SYSTEM Gujarat
University

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 41
X10 HOME AUTOMATION SYSTEM Gujarat
University

The circuit is also sensitive to level, and for acceptable performance the AC
waveform needs to be of reasonably high amplitude. 12-15V AC is typical. If the voltage
is too low, the pulse width will increase. The arrangement shown actually gives better
performance than the version shown in Project 62 and elsewhere on the Net. In case you
were wondering, R1 is there to ensure that the voltage falls to zero - stray capacitance is
sufficient to stop the circuit from working without it. The pulse width of this circuit (at
50Hz) is typically around 600us (0.6ms) which sounds fast enough. The problem is that
at 50Hz each half cycle takes only 10ms (8.33ms at 60Hz), so the pulse width is over 5%
of the total period. This is why most dimmers can only claim a range of 10%-90% - the
zero crossing pulse lasts too long to allow more range. While this is not a problem with
the average dimmer, it is not acceptable for precision applications. For a tone burst
generator (either the cosine burst or a 'conventional' tone burst generator), any
inaccuracy will cause the switched waveform to contain glitches. The seriousness of this
depends on the application. Precision zero crossing detectors come in a fairly wide range
of topologies, some interesting, others not. One of the most common is shown in Project
58, and is commonly used for this application. The exclusive OR (or XOR) gate makes
an excellent edge detector, as shown

Exclusive OR Gate Edge Detector

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 42
X10 HOME AUTOMATION SYSTEM Gujarat
University

There is no doubt that the circuit shown above is more than capable of excellent
results up to quite respectable frequencies. The upper frequency is limited only by the
speed of the device used, and with a 74HC86 it has a propagation delay of only 11ns [1],
so operation at 100 kHz or above is achievable.

The XOR gate is a special case in logic. It will output a 1 only when the inputs are
different (i.e. one input must be at logic high (1) and the other at logic low (0v). The
resistor and cap form a delay so that when an edge is presented (either rising or falling),
the delayed input holds its previous value for a short time. In the example shown, the
pulse width is 50ns. The signal is delayed by the propagation time of the device itself
(around 11ns), so a small phase error has been introduced. The rise and fall time of the
squarewave signal applied was 50ns, and this adds some more phase shift.

There is a pattern emerging in this article - the biggest limitation is speed, even for
relatively slow signals. While digital logic can operate at very high speeds, we have well
reached the point where the signals can no longer be referred to as '1' and '0' - digital
signals are back into the analogue domain, specifically RF technology.

The next challenge we face is converting the input waveform (we will assume a
sinewave) into sharply defined edges so the XOR can work its magic. Another terribly
under-rated building block is the comparator. While opamps can be used for low speed
operation (and depending on the application), extreme speed is needed for accurate
digitisation of an analogue signal. It may not appear so at first glance, but a zero crossing
detector is a special purpose analogue to digital converter (ADC).

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 43
X10 HOME AUTOMATION SYSTEM Gujarat
University

3.5.1 COMPARATORS
The comparator used for a high speed zero crossing detector, a PWM converter or
conventional ADC is critical. Low propagation delay and extremely fast operation are
not only desirable, they are essential. Comparators may be the most underrated and
under utilised monolithic linear component. This is unfortunate because comparators are
one of the most flexible and universally applicable components available. In large
measure the lack of recognition is due to the IC Opamp, whose versatility allows it to
dominate the analog design world. Comparators are frequently perceived as devices that
crudely express analog signals in digital form - a 1-bit A/D converter. Strictly speaking,
this viewpoint is correct. It is also wastefully constrictive in its outlook. Comparators
don't “just compare” in the same way that opamps don't "just amplify". The above quote
was so perfect that I just had to include it. Comparators are indeed underrated as a
building block, and they have two chief requirements ... low input offset and speed. For
the application at hand (a zero crossing detector), both of these factors will determine the
final accuracy of the circuit. The XOR has been demonstrated to give a precise and
repeatable pulse, but its accuracy depends upon the exact time it 'sees' the transition of
the AC waveform across zero. This task belongs to the comparator.

Comparator Zero Crossing Detector

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 44
X10 HOME AUTOMATION SYSTEM Gujarat
University

In Figure of previoua page we see a typical comparator used for this application.
The output is a square wave, which is then sent to a circuit such as that in Figure 2. This
will create a single pulse for each square wave transition, and this equates to the zero
crossings of the input signal. It is assumed for this application that the input waveform is
referenced to zero volts, so swings equally above and below zero.

Comparator Timing Error

Figure above shows how the comparator can mess with our signal, causing the
transition to be displaced in time, thereby causing an error. The significance of the error
depends entirely on our expectations - there is no point trying to get an error of less than
10ns for a dimmer, for example.

The LM339 comparator that was used for the simulation is a very basic type
indeed, and with a quoted response time of 300ns it is much too slow to be usable in this
application. This is made a great deal worse by the propagation delay, which (as
simulated) is 1.5us. In general, the lower the power dissipation of a comparator, the
slower it will be, although modern IC techniques have overcome this to some extent.

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 45
X10 HOME AUTOMATION SYSTEM Gujarat
University

You can see that the zero crossing of the sine wave (shown in green) occurs well
before the output (red) transition - the cursor positions are set for the exact zero crossing
of each signal. The output transition starts as the input passes through zero, but because
of device delays, the output transition is almost 5us later. Most of this delay is caused by
the rather leisurely pace at which the output changes - in this case, about 5us for the total
7V peak to peak swing. That gives us a slew rate of 1.4V/us which is useless for
anything above 100Hz or so.

One of the critical factors with the comparator is its supply voltage. Ideally, this
should be as low as possible, typically with no more than ±5V. The higher the supply
voltage, the further the output voltage has to swing to get from maximum negative to
maximum positive and vice versa. While a slew rate of 100V/us may seem high, that is
much too slow for an accurate ADC, pulse width modulator or zero crossing detector.

At 100V/us and a total supply voltage of 10V (±5V), it will take 0.1us (100ns) for
the output to swing from one extreme to the other. To get that into the realm of what we
need, the slew rate would need to be 1kV/us, giving a 10ns transition time. Working
from Figure 3, you can see that even then there is an additional timing error of 5ns - not
large, and in reality probably as good as we can expect.

The problem is that the output doesn't even start to change until the input voltage
passes through the reference point (usually ground). If there is any delay caused by slew
rate limiting, by the time the output voltage passes through zero volts, it is already many
nanoseconds late. Extremely high slew rates are possible, and Reference 2 has details of
a comparator that is faster than a TTL inverter! Very careful board layout and attention
to bypassing is essential at such speeds, or the performance will be worse than woeful.

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 46
X10 HOME AUTOMATION SYSTEM Gujarat
University

3.6 120 KHZ CARRIER DETECTOR


To receive X-10 signals, it is necessary to detect the presence of the 120 kHz
signal on the AC power line. This is accomplished with a decoupling capacitor, a high-
pass filter, a tuned amplifier, and an envelope detector. Because the impedance of a
capacitor is: Zc = 1/(2*π*f*C), a 0.1 μF capacitor presents a low impedance (13Ω) to the
120 kHz carrier frequency, but a high impedance (26.5 kΩ) to the 60 Hz power line
frequency. This high-pass filter allows the 120 kHz signal to be safely coupled to the 60
Hz power line, and it doubles as the coupling stage of the 120 kHz carrier generator

described in the next section. Since the 120 kHz carrier frequency is much higher than
the 60 Hz power line frequency, it is straightforward to design an RC filter that will pass
the 120 kHz signal and completely attenuate the 60 Hz. For a simple high-pass filter, the
-3 db breakpoint is: ƒ3 db = 1/(2*π*R*C). For C = 150 pF and R = 33 kΩ, ƒ3 db =
1/(2*π*150 pF *33 kΩ) = 32 kHz. This ƒ3 db point assures that the 60 Hz signal is
completely attenuated, while the 120 kHz signal is passed through to the amplifier
stages. Next, the 120 kHz signal is amplified using a series of inverters configured as
high gain amplifiers. The first two stages are tuned amplifiers with peak response at 120
kHz. The next two stages provide additional amplification. The amplified 120 kHz signal
is passed through an envelope detector, formed with a diode, capacitor, and resistor. The
envelope detector output is buffered through an inverter and presented to an input pin
(RC3) of the PIC16F877A. Upon each zero-crossing interrupt, RC3 is simply checked
within the 1 ms transmission envelope to see whether or not the carrier is present.
MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)
th
PATEL JIGAR MANUBHAI (06EC030) 8
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 47
X10 HOME AUTOMATION SYSTEM Gujarat
University

3.7 120 KHZ CARRIER GENERATOR


X10 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. Calculations for setting the PWM period and duty cycle are shown in
the code listing comments for the function InitPWM. 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

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 48
X10 HOME AUTOMATION SYSTEM Gujarat
University

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.

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 49
X10 HOME AUTOMATION SYSTEM Gujarat
University

3.8 TRANSFORMER-LESS POWER SUPPLY


The PIC16F877A and other board circuits require a 5V supply. In this application,
the X-10 controller must also transmit and receive its data over the AC line. Since X-10
components are intended to be plugged into a wall outlet and have a small form factor, a
transformer-less power supply is used. Two characteristics of transformer-less supplies
that should be kept in mind are limited current capacity, and lack of isolation from the
AC mains.

To protect the circuit from spikes on the AC power line, a 130V VDR (voltage
dependent resistor) is connected between Line and Neutral. The 47Ω resistor limits
current into the circuit, and the 1 MΩ resistor provides a discharge path for the voltage
left on the capacitor when the circuit is unplugged from the wall. Two diodes rectify the
voltage across the 1000 ΜF capacitor and 5.1V Zener diode to produce a 5V supply. The
reader may wish to refer to the application note AN954, “Transformer-less Power.

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 50
X10 HOME AUTOMATION SYSTEM Gujarat
University

3.9 LOAD SWITCH


A load switch is included on the home controller so that it may act as a lamp
module, with its own house and unit address. A TRIAC was selected as the load switch,
because its medium power switching capacity and rapid switching capability make it
well-suited for lamp control and dimming. A TRIAC is an inexpensive, three-terminal
device that basically acts as a high-speed, bidirectional AC switch. Two terminals, MT1
and MT2, are wired in series with the load. A small trigger current between the gate and
MT1 allow conduction to occur between MT1 and MT2. Current continues to flow after
the gate current is removed, as long as the load current exceeds the latching value.
Because of this, the TRIAC will automatically switch off near each zero-crossing as the
AC voltage falls below the latching voltage.

A Teccor® L4008L6 Triac was selected because it has a sensitive gate that can be
directly controlled from the logic level output of the PIC MCU I/O pin. The sensitive
gate Triac can control AC current in both directions through the device, even though the
PIC MCU can provide only positive voltages to the gate. A variable dimmer is created
by including a delay between the time of each zero-crossing and the time that the trigger
current is provided to the Triac from the PIC MCU. The design and control of a lamp
dimmer using a PIC MCU is discussed in detail in PICREF-4 Reference Design,
“PICDIM Lamp Dimmer for the PIC12C508”.

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 51
X10 HOME AUTOMATION SYSTEM Gujarat
University

3.10 LCD MODULE


The 2-line x 16-character display uses the
HD44780U Display Controller. Eight data lines
and three control lines are used to interface to
the PIC MCU. If fewer I/O pins are available,
the LCD can be operated in Nibble mode using
only four data lines, with some additional
software overhead. A basic LCD library is included in this application, which provides
the necessary functions for controlling this type of LCD.

3.11 REAL-TIME CLOCK


A real-time clock is implemented using Timer1. The real-time clock keeps track of
the present time using a routine called UpdateClock. It also determines the rate that the
buttons are read by a routine called ScanKeys. Timer1 is set to cause an interrupt each
time it overflows. By adding a specific offset to Timer1 each time it overflows, the time
before the next overflow can be precisely controlled. The button reading routine,
ScanKeys, is called each time a Timer1 interrupt occurs. Since ScanKeys performs
debouncing of the button presses, a suitable rate to check the buttons is once every 25
ms. With a 32 kHz crystal, the counter increments once every 31.25 Μs when the
prescaler is set to 1:1. In order for Timer1 to generate an interrupt once every 25 ms,
TMR1H:TMR1L are pre-loaded with 0xFCE0h. The Timer1 interrupt interval, or tick,
can be seen in the following equation: (FFFFh – FCE0h)*1/32 kHz = .025 s = 1 tick.
Each time ScanKeys is called (every 25 ms), it calls UpdateClock. UpdateClock keeps
track of the time unit variables: ticks, seconds, minutes, and hours. Since every 25 ms

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 52
X10 HOME AUTOMATION SYSTEM Gujarat
University

equals one tick, seconds are incremented every 40 ticks. Minutes and hours are
incremented in a similar fashion.

3.12 PUSH BUTTONS


Five push buttons, connected to RB1-RB5, are used for user interaction with the
application. Each normally open push button will pull a port pin low when it is pressed.

3.13 LIGHT SENSOR


To detect the ambient light level, a CdS photoresistor is
used in conjunction with an 820Ω resistor to create a voltage
divider. The voltage on the divider varies with the intensity of
ambient light and is connected to an analog channel (AN0) of
the microcontroller.

3.14 IN-CIRCUIT DEBUGGER


RB6 and RB7 have been reserved for In-Circuit Serial ProgrammingTM
(ICSPTM) and the In-Circuit Debugger (ICD). However, do not connect the ICD or any
other development tool, without taking first isolating the entire application from wall
power.

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 53
X10 HOME AUTOMATION SYSTEM Gujarat
University

3.15 CONTROL DATA STORAGE


Certain control data that is programmable by the user must be stored in non-
volatile memory. The PIC MCU’s built-in EEPROM is well-suited to this task. To use
EEPROM memory space most
efficiently (by avoiding wasted bits),
on/off times and light sensor control
flags are stored using the format shown
in Figure 8. Figure 9 shows the location
of on/off times and other information within the
data EEPROM. Using this data organization, only
48 bytes of EEPROM are required to store the
on/off times and light sensor control flags for 16
units.

Each time that minutes are incremented


within the UpdateClock routine, a flag is set that
enables a routine called CheckOnOffTimes to be
called from the main loop. CheckOnOff Times
compares the present time with the unit on and off
times stored in EEPROM memory. If there is a
match, then a flag is set to either turn the unit on or
off, by sending it the appropriate X-10 command when the routine ControlX10Units is
called.

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 54
X10 HOME AUTOMATION SYSTEM Gujarat
University

3.16 ENVELOPE DETECTOR


An envelope detector is an electronic circuit that takes a high-frequency signal as
input and provides an output which is the "envelope" of the original signal. The capacitor
in the circuit stores up charge on the rising edge, and releases it slowly through the
resistor when the signal falls. The diode in series rectifies the incoming signal, allowing
current flow only when the positive input terminal is at a higher potential than the
negative input terminal.

A signal and its envelope marked with red

A simple envelope demodulator circuit.

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 55
X10 HOME AUTOMATION SYSTEM Gujarat
University

A signal in blue and the magnitude of its analytic signal in red, showing the
envelope effect

Most practical envelope detectors use either half-wave or full-wave rectification of


the signal to convert the AC audio input into a pulsed DC signal. Filtering is then used to
smooth the final result. This filtering is rarely perfect and some "ripple" is likely to
remain on the envelope follower output, particularly for low frequency inputs such as
notes from a bass guitar. More filtering gives a smoother result, but decreases the
responsiveness; thus, real-world designs must be optimized for the application.

3.16.1 DEFINITION OF THE ENVELOPE


Any AM or FM signal can be written in the following form

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 56
X10 HOME AUTOMATION SYSTEM Gujarat
University

In the case of AM, φ(t), the phase component of the signal, is constant and can be
ignored, so all the information in the signal is in R(t). R(t) is called theenvelope of the
signal. Hence an AM signal is given by the equation

with m(t) representing the original audio frequency message, C the carrier amplitude


and R(t) equal to C + m(t). So, if the envelope of the AM signal can be extracted, the
original message can be recovered.

3.16.2 DIODE DETECTOR


The simplest form of envelope detector is the diode detector which is shown
above. A diode detector is simply a diode between the input and output of a circuit,
connected to a resistor and capacitor in parallel from the output of the circuit to the
ground. If the resistor and capacitor are correctly chosen, the output of this circuit should
approximate a voltage-shifted version of the original (baseband) signal. A simple filter
can then be applied to filter out the DC component.

3.16.3 PRECISION DETECTOR


An envelope detector can also be constructed to use a precision rectifier feeding
into a low-pass filter.

3.16.4 DRAWBACKS
The envelope detector has several drawbacks:

The input to the detector must be band-pass filtered around the desired signal, or else the
detector will simultaneously demodulate several signals. The filtering can be done with a
tunable filter or, more practically, a superheterodyne receiver

It is more susceptible to noise than a product detector

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 57
X10 HOME AUTOMATION SYSTEM Gujarat
University

If the signal is over modulated, distortion will occur

Most of these drawbacks are relatively minor and are usually acceptable tradeoffs
for the simplicity and low cost of using an envelope detector.

3.16.5 DEMODULATION OF SIGNALS


An envelope detector can be used to demodulate a previously modulated signal by
removing all high frequency components of the signal. The capacitor and resistor form a
low-pass filter to filter out the carrier frequency. Such a device is often used to
demodulate AM radio signals because the envelope of the modulated signal is equivalent
to the baseband signal.

3.16.6 AUDIO
An envelope detector is sometimes referred to as an envelope
follower in musical environments. It is still used to detect the amplitude variations of an
incoming signal to produce a control signal that resembles those variations. However, in
this case the input signal is made up of audible frequencies.

Envelope detectors are often a component of other circuits, such as


a compressor or an auto-wah or envelope-followed filter. In these circuits, the envelope
follower is part of what is known as the "side chain", a circuit which describes some
characteristic of the input, in this case its volume.

Both expanders and compressors use the envelope's output voltage to control of


the gain of an amplifier. Auto-wah uses the voltage to control the cutoff frequency of a
filter. The voltage-controlled filter of an analog synthesizer is a similar circuit.

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 58
X10 HOME AUTOMATION SYSTEM Gujarat
University

3.17 SCOPE ADAPTER CIRCUIT


An AC adapter which reduces the amount of power drawn
from an AC power source when a system is disconnected from
the adapter, includes: a rectifier bridge for rectifying an AC
voltage from an AC power supply; a conversion circuit coupled
to the rectifier bridge for converting the rectified AC voltage to a
DC voltage; and an opto-coupler coupled to the conversion
circuit for monitoring an output connection of the circuit,
wherein when a system is not coupled to the output connection,
the opto-coupler substantially prevents the AC voltage from
being drawn from the AC power supply. The adapter circuit uses an opto-coupler
comprising a diode and a transistor to reduce the amount of current drawn from an AC
power supply when a system is not connected to the AC adapter. In this manner, the AC
adapter is prevented from becoming heated when no system is connected.

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 59
X10 HOME AUTOMATION SYSTEM Gujarat
University

3.18 HIGH-PASS FILTER


A high-pass filter, or HPF, is an LTI filter that passes high frequencies well
but attenuates (i.e., reduces the amplitude of) frequencies lower than the filter's cutoff
frequency. The actual amount of attenuation for each frequency is a design parameter of
the filter. It is sometimes called a low-cut filter or bass-cut filter.

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 60
X10 HOME AUTOMATION SYSTEM Gujarat
University

3.18.1 FIRST-ORDER CONTINUOUS-TIME IMPLEMENTATION

A passive, analog, first-order high-pass filter, realized by an RC circuit

The simple first-order electronic high-pass filter shown in Figure 1 is implemented


by placing an input voltage across the series combination of a capacitor and
a resistor and using the voltage across the resistor as an output. The product of the
resistance and capacitance (R×C) is the time constant (τ); it is inversely proportional to
the cutoff frequency fc, at which the output power is half the input power. That is,

where fc is in hertz, τ is in seconds, R is in ohms, and C is in farads.

An active high-pass filter

Figure  shows an active electronic implementation of a first-order high-pass filter


using an operational amplifier. In this case, the filter has a pass band gain of -R2/R1 and
has a corner frequency of

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 61
X10 HOME AUTOMATION SYSTEM Gujarat
University

Because this filter is active, it may have non-unity passband gain. That is, high-
frequency signals are inverted and amplified by R2/R1.

3.18.2 DISCRETE-TIME REALIZATION


For another method of conversion from continuous- to discrete-time, see Bilinear
transform.

Discrete-time high-pass filters can also be designed. Discrete-time filter design is


beyond the scope of this article; however, a simple example comes from the conversion
of the continuous-time high-pass filter above to a discrete-time realization. That is, the
continuous-time behavior can be discretized.

From the circuit in Figure 1 above, according to Kirchoff's Laws and the definition
of capacitance:

where Qc(t) is the charge stored in the capacitor at time t. Substituting Equation (Q) into
Equation (I) and then Equation (I) into Equation (V) gives:

This equation can be discretized. For simplicity, assume that samples of the input
and output are taken at evenly-spaced points in time separated by ΔT time. Let the
samples of Vin be represented by the sequence  , and let Vout be

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 62
X10 HOME AUTOMATION SYSTEM Gujarat
University

represented by the sequence   which correspond to the same points in


time. Making these substitutions:

And rearranging terms gives the recurrence relation

That is, this discrete-time implementation of a simple continuous-time RC high-


pass filter is

By definition,  . The expression for parameter α yields the


equivalent time constant RC in terms of the sampling period ΔT and α:

If α = 0.5, then the RC time constant equal to the sampling period. If  ,
then RC is significantly smaller than the sampling interval, and 

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 63
X10 HOME AUTOMATION SYSTEM Gujarat
University

4. ALL CIRCUIT DIAGRAM AT A SCOPE

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 64
X10 HOME AUTOMATION SYSTEM Gujarat
University

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 65
X10 HOME AUTOMATION SYSTEM Gujarat
University

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 66
X10 HOME AUTOMATION SYSTEM Gujarat
University

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 67
X10 HOME AUTOMATION SYSTEM Gujarat
University

5. SOFTWARE

5.1 APPLICATION FIRMWARE OVERVIEW

T he firmware is divided into several different files to facilitate adaptation of the


code to other applications.

Following is a summary of the files associated with this application note:

x10lib.asm Defines X-10 functions.


x10lib.inc Defines X-10 constants and macros.
x10hc.asm Main application code for the home controller.
x10demo.asm Example code that shows how to use the X-10 library macros.
lcd.asm Defines the routines necessary for driving the LCD.
p16f877A.lkr Standard linker file for PIC16F877A parts.
p16f877A.inc Standard include file for PIC16F877A parts.

Detailed descriptions of operation can be found in the comments within the code
listing.

5.2 X-10 LIBRARY


A simple library of commands was developed and used for the home controller. It
can be used with little or no modification in a user’s application. The library consists of
two files: x10lib.asm and x10lib.inc.

To use the library, a user need only understand the function of the macros defined
in x10lib.inc. The macros greatly simplify the use of the library by eliminating the need
for the user to understand every X-10 function in x10lib.asm. Examples of how the
macros are used are included in the file x10demo.asm.

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 68
X10 HOME AUTOMATION SYSTEM Gujarat
University

The macros are explained below:

InitX10

This macro is used to initialize the peripherals that provide X-10 functionality. It
must be called in the application program before any of the below macros will work. It is
used as follows:

InitX10

5.2.1 SKIPIFTXREADY
Before sending an X-10 message, it is necessary tomake sure that another message
is not already being sent, which is signified by the X10TxFlag being set. This macro
simply checks that flag and skips the next instruction if it is okay to begin a new
transmission. Otherwise, there is a chance that a new transmission will interrupt an
ongoing transmission. It is used as follows:

SkipIfTxDone

GOTO $-1 ;loop until ready to


;transmit next message
5.2.2 SENDX10ADDRESS (HOUSE, UNIT)
This macro is used to send an X-10 address for a particular unit. It requires two
arguments, a house address and unit address. The definitions for all house and unit
addresses are defined in x10lib.inc. To use this macro to send the address for unit 16 at
house P, one simply types:

SendX10Address HouseP, Unit16

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 69
X10 HOME AUTOMATION SYSTEM Gujarat
University

5.2.3 SENDX10ADDRESSVAR
This macro is used to send an X-10 address, defined by variables rather than
constants. To send an address contained in the user variables MyHouse and MyUnit, the
following sequence would be applied:

MOVF MyHouse, W ;contains a value


;from 0-16
MOVWF TxHouse

MOVF MyUnit, W ;contains a value


;from 0-16
MOVWF TxUnit

SendX10AddressVar

5.2.4 SENDX10COMMAND (HOUSE, FUNCTION)


This macro is used to send an X-10 command. It requires two arguments, the
house address and function code. The definitions for all house addresses and function
codes are defined in x10lib.inc. To use this macro to send the command ‘All Lights On’
to all units at house A, one types:

SendX10Command HouseA, AllLightsOn

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 70
X10 HOME AUTOMATION SYSTEM Gujarat
University

5.2.5 SENDX10COMMANDVAR
This macro is used to send an X-10 command, defined by a variable rather than a
constant. To use this macro to send the command stored in the user variable
MyCommand to all units at MyHouse, one types:

MOVF MyHouse, W ;contains a value


;from 0-16
MOVWF TxHouse

MOVF MyCommand, W ;any X-10


;function
;defined in
;x10lib.inc
MOVWF TxFunction

SendX10CommandVar

5.2.6 SKIPIFRXDONE
Before reading an X-10 message, it is necessary to make sure that a complete
message has been received. This is signified by the X10RxFlag being set. This macro
simply checks that flag and skips the next instruction if a new X-10 message has been
received. It is used as follows:

SkipIfRxDone

GOTO $-1 ;loop until message


;received

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 71
X10 HOME AUTOMATION SYSTEM Gujarat
University

5.2.7 SKIPIFADDRESSRCVD
It may be necessary to make sure that an address was received by using this
macro, which checks to see if the RxCommandFlag is clear. It is used as follows:

SkipIfAddressRcvd

GOTO $-1 ;loop until address


;received
5.2.8 SKIPIFCOMMANDRCVD
Or, it may be necessary to make sure that a command was received by using this
macro, which checks to see if the RxCommandFlag is set. It is used as follows:

SkipIfCommandRcvd

GOTO $-1 ;loop until command


;received
5.2.9 READX10MESSAGE
This macro is called to read a received X-10 message, which may be either an
address or a command. If the message was an address, then the received house and unit
codes will be stored in the variables RxHouse and RxUnit, respectively. If the message
was a command, then the received house address and function code will be stored in the
variables RxHouse and RxFunction. It is simply called as follows:

ReadX10Message

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 72
X10 HOME AUTOMATION SYSTEM Gujarat
University

5.3 INTRODUCTION TO KEIL SOFTWARE


Keil Micro Vision is an integrated development environment used to create
software to be run on embedded systems (like a microcontroller). It allows for such
software to be written either in assembly or C programming languages and for that
software to be simulated on a computer before being loaded onto the microcontroller.

5.4 WHAT IS ΜVISION3?


µVision3 is an IDE (Integrated Development Environment) that helps write,
compile, and debug embedded programs. It encapsulates the following components:

A project manager.
A make facility.
Tool configuration.
Editor.
A powerful debugger.

5.5 STEPS FOLLOWED IN CREATING AN APPLICATION IN


ΜVISION3:
To create a new project in uVision3:
Select Project - New Project.
Select a directory and enter the name of the project file.
Select Project –Select Device and select a device from Device Database.
Create source files to add to the project
Select Project - Targets, Groups, and Files. Add/Files, select Source Group1, and
add the source files to the project.
Select Project - Options and set the tool options. Note that when the target device
MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)
th
PATEL JIGAR MANUBHAI (06EC030) 8
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 73
X10 HOME AUTOMATION SYSTEM Gujarat
University

is selected from the Device Database™ all-special options are set automatically.
Default memory model settings are optimal for most applications.
Select Project - Rebuild all target files or Build target
To create a new project, simply start Micro Vision and select
“Project”=>”New Project” from the pull–down menus. In the file dialog that appears,
choose a name and base directory for the project. It is recommended that a new
directory be created for each project, as several files will be generated. Once the project
has been named, the dialog shown in the figure below will appear, prompting the user
to select a target device. In this lab, the chip being used is the “AT89S52,” which is
listed under the heading “Atmel

Window for choosing the Target Device

Next, Micro Vision must be instructed to generate a HEX file upon program
compilation. A HEX file is a standard file format for storing executable code that is to
be loaded onto the microcontroller. In the “Project Workspace” pane at the left, right–
click on “Target 1” and select “Options for ‘Target 1’ ”.Under the “Output” tab of the
resulting options dialog, ensure that both the “Create Executable” and “Create HEX
MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)
PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 74
X10 HOME AUTOMATION SYSTEM Gujarat
University

File” options are checked. Then click “OK” as shown in the two figures below.

Project Workspace Pane Project Options Dialog


Next, a file must be added to the project that will contain the project code. To do
this, expand the “Target 1” heading, right–click on the “Source Group 1” folder, and
select “Add files…” Create a new blank file (the file name should end in “.asm”), select
it, and click “Add.” The new file should now appear in the “Project Workspace” pane
under the “Source Group 1” folder. Double-click on the newly created file to open it in
the editor. All code for this lab will go in this file. To compile the program, first save
all source files by clicking on the “Save All” button, and then click on the “Rebuild All
Target Files” to compile the program as shown in the figure below. If any errors or
warnings occur during compilation, they will be displayed in the output window at the
bottom of the screen. All errors and warnings will reference the line and column
number in which they occur along with a description of the problem so that they
can be easily located. Note that only errors indicate that the compilation failed,
warnings do not (though it is generally a good idea to look into them anyway).

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 75
X10 HOME AUTOMATION SYSTEM Gujarat
University

“Save All” and “Build All Target Files” Buttons


When the program has been successfully compiled, it can be simulated using the
integrated debugger in Keil Micro Vision. To start the debugger, select
“Debug”=>”Start/Stop Debug Session” from the pull–down menus.

At the left side of the debugger window, a table is displayed containing several
key parameters about the simulated microcontroller, most notably the elapsed time
(circled in the figure below). Just above that, there are several buttons that control code
execution. The “Run” button will cause the program to run continuously until a
breakpoint is reached, whereas the “Step Into” button will execute the next line of code
and then pause (the current position in the program is indicated by a yellow arrow to
the left of the code).

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 76
X10 HOME AUTOMATION SYSTEM Gujarat
University

µVision3 Debugger window

Breakpoints can be set by double–clicking on the grey bar on the left edge of the
window containing the program code. A breakpoint is indicated by a red box next to the
line of code.

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 77
X10 HOME AUTOMATION SYSTEM Gujarat
University

‘Reset’, ‘Run’ and ‘Step into’ options

The current state of the pins on each I/O port on the simulated microcontroller
can also be displayed. To view the state of a port, select “Peripherals”=>”I/O
Ports”=>”Port n” from the pull–down menus, where n is the port number. A checked
box in the port window indicates a high (1) pin, and an empty box indicates a low (0)
pin. Both the I/O port data and the data at the left side of the screen are updated
whenever the program is paused.
The debugger will help eliminate many programming errors, however the
simulation is not perfect and code that executes properly in simulation may not always
work on the actual microcontroller.

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 78
X10 HOME AUTOMATION SYSTEM Gujarat
University

5.6 DEVICE DATABASE


A unique feature of the Keil µVision3 IDE is the Device Database, which
contains information about more than 400 supported microcontrollers. When you
create a new µVision3 project and select the target chip from the database, µVision3
sets all assembler, compiler, linker, and debugger options for you. The only option you
must configure is the memory map.

5.7 PERIPHERAL SIMULATION


The µVision3 Debugger provides complete simulation for the CPU and on-chip
peripherals of most embedded devices. To discover which peripherals of a device are
supported, in µVision3 select the Simulated Peripherals item from the Help menu. You
may also use the web-based Device Database. We are constantly adding new devices
and simulation support for on-chip peripherals so be sure to check Device Database
often.

5.8 PROGRAMMER
The programmer used is a powerful programmer for the Atmel 89 series of
microcontrollers that includes 89C51/52/55, 89S51/52/55 and many more.
It is simple to use & low cost, yet powerful flash microcontroller programmer for the
Atmel 89 series. It will Program, Read and Verify Code Data, Write Lock Bits, Erase
and Blank Check. All fuse and lock bits are programmable. This programmer has
intelligent onboard firmware and connects to the serial port. It can be used with any
type of computer and requires no special hardware. All that is needed is a serial
communication port which all computers have.

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 79
X10 HOME AUTOMATION SYSTEM Gujarat
University

All devices also have a number of lock bits to provide various levels of software
and programming protection. These lock bits are fully programmable using this
programmer. Lock bits are useful to protect the program to be read back from
microcontroller only allowing erase to reprogram the microcontroller.
Major parts of this programmer are Serial Port, Power Supply and Firmware
microcontroller. Serial data is sent and received from 9 pin connector and converted
to/from TTL logic/RS232 signal levels by MAX232 chip. A Male to Female serial
port cable, connects to the 9 pin connector of hardware and another side connects to
back of computer.
All the programming ‘intelligence’ is built into the programmer so you do not
need any special hardware to run it. Programmer comes with window based software
for easy programming of the devices.

5.9 PROLOAD PROGRAMMING SOFTWARE


‘Proload’ is a software working as a user friendly interface for programmer
boards from Sunrom Technologies. Proload gets its name from “Program Loader” term,
because that is what it is supposed to do. It takes in compiled HEX file and loads it to
the hardware. Any compiler can be used with it, Assembly or C, as all of them generate
compiled HEX files. Proload accepts the Intel HEX format file generated from
compiler to be sent to target microcontroller. It auto detects the hardware connected to
the serial port. It also auto detects the chip inserted and bytes used. The software is
developed in Delphi and requires no overhead of any external DLL.

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 80
X10 HOME AUTOMATION SYSTEM Gujarat
University

The programmer connects to the computer’s serial port (Comm 1, 2, 3 or 4) with


a standard DB9 Male to DB9 Female cable. Baud Rate - 57600, COMx Automatically
selected by window software. No PC Card Required. After making the necessary
selections, the ‘Auto Program’ button is clicked as shown in the figure below which
burns the selected hex file onto the microcontroller.

Programming window

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 81
X10 HOME AUTOMATION SYSTEM Gujarat
University

6. HOME CONTROLLER OPERATING


INSTRUCTIONS

6.1 “WELCOME SCREEN”


The home controller user interface consists of five buttons and a 2 x 16 LCD.
Upon power-up, the Welcome screen is displayed. This screen displays a welcome
message and the time. Immediately, the seconds begin incrementing and the PIC MCU
begins keeping track of the time. Figure below shows the Welcome screen and the
location and functionality of each button. Depending on the screen viewed, each of the
five buttons performs a different function. When the Welcome screen is displayed, the
buttons enable access to the following functions:
Press menu to enter the Select Function screen.
Press up to brighten the lamp that is plugged into the home controller.
Press down to dim the lamp.
Press enter to turn the lamp on.
Press exit to turn the lamp off.

WELCOME SCREEN

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 82
X10 HOME AUTOMATION SYSTEM Gujarat
University

6.1.1 SELECT FUNCTION SCREEN


When viewing the Welcome screen, the menu button enables access to the Select
Function screen. Each successive press of the menu button cycles through the four main
functions of the user interface: setting the system time, setting the system address,
setting the light sensor, or programming the unit on and off times, as illustrated in
Figure below.

SELECT FUNCTION SCREENS

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 83
X10 HOME AUTOMATION SYSTEM Gujarat
University

6.1.2 SET SYSTEM TIME SCREEN


Use the Set System Time screen to set the time.

SETTING SYSTEM TIME


1. Starting from the Welcome screen, press menu until the Set System Time screen is
displayed and press enter.
2. Press up/down to set the hours.
3. Press enter when the correct hour, including AM or PM, has been selected.
4. Repeat this process to set the minutes.
5. If the time is correct, select Y (the default) using the up/down buttons and press
enter. This returns to the Welcome screen with the new time displayed.
6. If the time is not correct, select N and press enter. This will return the user to step 2
so the correct time can be entered.
7. Press exit at any time to return the user to the Welcome screen without saving the
new time.

SET SYSTEM TIME SCREENS

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 84
X10 HOME AUTOMATION SYSTEM Gujarat
University

6.1.3 SELECT SYSTEM ADDRESS SCREEN


Use the Set System Address screen to set the house address and unit address of
the home controller.

SETTING HOUSE/UNIT ADDRESS


1. From the Welcome screen, press menu until the Set System Addr screen is displayed
and press enter.
2. Press up or down to set the house address (a letter from A - P).
3. Press enter when the house address has been selected.
4. Repeat steps 2 and 3 to set the unit address (a number from 1 - 16).
5. If the house and unit addresses are correct, select Y (the default) using the up/down
buttons and press enter. This returns to the Welcome screen with the new address
stored in non-volatile memory.
6. If the address is not correct, select N and press enter. This will return the user to step
2.
7. Press exit at any time to return the user to the Welcome screen without saving the
new address.

SET SYSTEM ADDRESS SCREENS


MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)
PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 85
X10 HOME AUTOMATION SYSTEM Gujarat
University

6.1.4 SET LIGHT SENSOR SCREEN


Use the Set Light Sensor screen to select whether units turn on at dusk, or off at
dawn.

SETTING THE LIGHT SENSOR


1. From the Welcome screen, press menu until the Set Light Sensor screen is displayed
and press enter.
2. Press up or down to select the desired unit. The house address will already be set to
the system house address.
3. Press enter when the desired unit address has been selected.
4. Press up or down to select whether or not the unit should turn on at dusk, and press
enter.
5. Repeat this process to set other units as desired.
6. Press exit to return to the Welcome screen.
Pressing exit while the “On at Dusk” or “Off at Dawn” prompt is displayed will return
the user to the Welcome screen without modifying that parameter.

SET LIGHT SENSOR SCREENS

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 86
X10 HOME AUTOMATION SYSTEM Gujarat
University

6.1.5 PROGRAM UNIT SCREEN


Use the Program Unit screen to program on and off
times for different units.
PROGRAMMING UNIT ON AND OFF TIMES
1. From the Welcome screen, press menu repeatedly until
the Program Unit screen is displayed and press enter.
2. Press up or down to select the desired unit. The house
address will already be set to the system house address.
3. Press enter when the unit address has been selected.
4. Press up or down to set the ‘on’ time hours. Hours set to
‘00’ means that the unit will not be turned on at any time.
5. Press enter when the correct hour, including AM or PM,
has been selected.
6. Repeat this process to set the ‘on’ time minutes. If the
hour has been set to ‘00’, then the minutes will be set to ‘00’ automatically.
7. If the time is correct, select Y (the default) using the up/down buttons and press
enter. The user will be prompted to program the ‘off’ time in a similar fashion.
8. If the time is not correct, select N and press enter. This allows the user to re-enter the
hour and minutes by returning to step 2.
9. Repeat this process to set the ‘on’ and ‘off’ time for other units as desired.
10. Press exit to return to the Welcome screen. Pressing exit while the “Set Hours” or
“Set Min” prompt is displayed will return the user to the Welcome screen without
modifying any parameters.

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 87
X10 HOME AUTOMATION SYSTEM Gujarat
University

7. WEAK POINTS AND LIMITATIONS

7.1 COMPATIBILITY WITH INSTALLED WIRING AND


APPLIANCES
One problem with X10 is excessive attenuation of signals between the two live
conductors in the 3-wire 120/240 volt system used in typical North
American residential construction. Signals from a transmitter on one live conductor
may not propagate through the high impedance of the distribution transformer winding
to the other live conductor. Often, there's simply no reliable path to allow the X10
signals to propagate from one phase wire to the other; this failure may come and go as
large 240 volt devices such as stoves or dryers are turned on and off. (When turned on,
such devices provide a low-impedance bridge for the X10 signals between the two
phase wires.) This problem can be permanently overcome by installing
a capacitor between the phase wires as a path for the X10 signals; manufacturers
commonly sell signal couplers that plug into 240 volt sockets that perform this
function. More sophisticated installations install an active repeater device between the
phases, while others combine signal amplifiers with a coupling device. A repeater is
also needed for inter-phase communication in homes with three-phase electric power.
In many countries outside North America, entire houses are typically wired from a
single 240 volt single phase wire so this problem does not occur.
An RCD/GFCI can attenuate X10 signals passing through the device. This means
that X10 signals passing through an RCD may not be strong enough to provide reliable
communication.

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 88
X10 HOME AUTOMATION SYSTEM Gujarat
University

Other problems: 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 also
filter out X10 signals traveling on the branch circuit to which the appliance is
connected.
Also, certain types of power supplies used in modern electronic equipment (such
as computers, television sets, and satellite receivers) "eat" passing X10 signals by
providing a low impedance path to high frequency signals. Typically, the capacitors
used on the inputs to these power supplies short the X10 signal from line to neutral,
suppressing any hope of X10 control on the circuit near that device. Filters are
available that will block the X10 signals from ever reaching such devices; plugging
offending devices into such filters can cure mysterious X10 intermittent failures.
Some X10 controllers may not work well or at all with low power devices (below 50
watts) or devices like fluorescent bulbs that do not present resistive loads. Use of an
appliance module rather than a lamp module may resolve this problem.

7.2 COMMANDS GETTING LOST


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.

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 89
X10 HOME AUTOMATION SYSTEM Gujarat
University

7.3 RELATIVELY SLOW


The X10 protocol is also slow. It takes roughly three quarters of a second to
transmit a device address and a command. While generally not noticeable when using a
tabletop controller, it becomes a noticeable problem when using 2-way switches or
when utilizing some sort of computerized controller. The apparent delay can be
lessened somewhat by using slower device dim rates. With more advanced modules
another option is to use group control (lighting scene) extended commands. These
allow to adjust several modules at once by a single command.

7.4 LIMITED FUNCTIONALITY


X10 protocol does support more advanced control over the dimming speed,
direct dim level setting and group control (scene settings). This is done via extended
message set, which is an official part of X10 standard. However support for all
extended messages is not mandatory, and a lot of cheaper modules implement only the
basic message set. These require adjusting each lighting circuit one after the other,
which can be visually unappealing and also very slow.

7.5 INTERFERENCE AND LACK OF ENCRYPTION


The standard X10 power line and RF protocols lack support for encryption, and
can only address 256 devices. Unless filtered, power line signals from close neighbours
using X10 may interfere with each other if the same device addresses are used by each
party. Interfering RF wireless signals may similarly be received, with it being easy for
anyone nearby with an X10 RF remote to wittingly or unwittingly cause mayhem if an
RF to power line device is being used on a premises.

7.6 BRIDGES

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 90
X10 HOME AUTOMATION SYSTEM Gujarat
University

There are bridges to translate X10 to other domotic standards.

8. ADVANTAGE

It is estimated that X10 compatible products can be found in over 10 million American
homes. This is because it has so many advantages over other types of remote control
products and systems:

Inexpensive
No new wiring is required -- perfect for retrofit
Simple to install
100's of compatible products
Control up to 256 lights and appliances
Time proven

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 91
X10 HOME AUTOMATION SYSTEM Gujarat
University

9. CONCLUSION

The PIC MCU is well-suited to X-10 applications. With its plethora of on-chip
peripherals and a few external components, a PIC MCU can be used to implement an

X-10 system that can transmit and receive messages over the AC power line wiring.
The small code size of the X-10 library leaves ample space for the user to create
application specific code. PIC MCUs, such as the PIC16F877A, have plenty of
additional resources for creating more complex X-10 applications, while smaller PIC
MCUs can be selected for economical use in simpler X-10 applications.

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM
P a g e | 92
X10 HOME AUTOMATION SYSTEM Gujarat
University

10. TROUBLE SHOOTING

In case of a system hang-up condition, the reset button in the vicinity of the
Microcontroller can be used to revive the system.

MANI PRINCE SUBROTO SWAPAN KUMAR (06EC019)


PATEL JIGAR MANUBHAI (06EC030) 8th
L D R P I n s ti t u t e o f T e c h n o l o g y & R e s e a r c h ,
Gandhinagar SEM

You might also like