Home Automation


Previous Topic Previous Next Topic Next
Xoc Software

Other Xoc managed sites:
http://grr.xoc.net
http://www.986faq.com
http://www.mayainfo.org
https://mayacalendar.xoc.net
http://www.yachtslog.com

Copyright © 2002 by Greg Reddick

This is from a paper presented at the ASP.NET Solutions conference in Palm Springs May 14-18, 2002.

Home Automation Links

This paper is a reflection of my ongoing project to automate some of the features of my house. In July of 2001, I closed on my house. This house is about 6800 square feet, although about 3000 square feet of that is an unfinished basement. In addition, there is a 1500 square foot garage. Control over the lights around the house for safety and security was one of my primary goals. I wanted a way to remotely turn on interior and exterior lights should some odd noise be heard. Also, with a house this size, I have discovered that it is incredibly easy to leave a light on in a remote part of the house for days without realizing it.

Home automation is the process of being able to control features of the house from remote locations. It can include control of:

  • lights
  • security system
  • heating control
  • audio-visual control
  • convenience features (such as camera monitoring of the front door, drape control, and detection of the mailbox being opened)

This is a work in process, and, although there are professionals who do this for a living, I am a relative novice figuring stuff out as I go. I am also still relatively early in the process of automating my house. One advantage I have over your typical licensed electrician who installs this stuff, is that I can handle the computer end of it pretty easily.

I'm going to talk about how to re-wire an existing house, since that is the project I am doing. If you are building a new house, you have some other issues to think about when wiring that house that I won't go into. There are some nice web sites that describe issues to think about when wiring a new house.

The X10 Standard

There are several schemes for doing home automation. The experts in this all agree that the most reliable mechanism for doing automation is a hardwired system. This involves running additional control wires to each light switch or other control point. It requires proprietary hardware to do the control. It is also virtually impossible to retrofit in an existing house without a very large expense. Running new wire to each switch is very expensive, and generally must be done by a professional.

As an alternative, there is a much cheaper proven technology called X10 that does not require running extra wire to the switches (except possibly a neutral wire). It is relatively cheap, and can be installed by the homeowner. There are different manufacturers that supply hardware conforming to the X10 standard, driving down the cost. This also allows you to mix and match parts from different manufacturers without problem. When done correctly, it can be extremely reliable, but there are issues that I will cover below that have to be addressed.

X10 was originally developed by Pico Electronics in the 1970s to allow remote automation of stereo equipment. It uses the existing power lines on a house as the transmission wires for a binary signal. The name comes from the 10th experimental system they developed.

In December 1997's, Pico's patent on X10 expired. When it did, many manufacturers started producing X10 standard devices.

The basic idea is to put a binary signal on the power line. They put a very minor increase in voltage (less than five volts) to represent a binary one or zero. To be reliable, the signal has to be placed on the Alternating Current at the place that the sine wave crosses the zero point. In power in the United States, that occurs 120 times a second. It takes two crossings to encode a single bit. So that transfer rate is only 7.5 bytes per second (120/8/2=7.5), fine for short code sequences, but transferring video over the power line doesn't work very well.

Transmitters put a coded signal on the power line, receivers decode the signal and respond. A transceiver performs both functions. Some devices act only as transmitters, some only as receivers, and some as transceivers.

Getting the Signal from "A" to "B"

The first (and so far only) thing I have attempted is wiring lights and electrical sockets. The first test was to acquire a plug in wall switch and a transmitter. You can buy these from several sources, including Lowe's and Radio Shack. You plug a floor lamp into the wall switch, then activate it from the transmitter. The whole setup will cost around $20. Hit the "on" button on the transmitter, and the light comes on. Hit the "off" button, and the light turns off.

This probably worked. If you move the transmitter to different places in the house, and continue to test it, though, you may start having trouble. Sometimes it works, sometimes it doesn't. Why?

Unfortunately, there are issues involved with X10, that are why the experts say that X10 is unreliable. First, there is the issue of distance. There are various things that diminish the voltage of the signal on the power line. If the voltage drops too low, the receiver can't tell a binary one from noise on the power line and the signal gets ignored. This can be tied to the distance between the transmitter and the receiver.

Realize that distance is not measured as the crow flies, instead it is measured as the electron runs. In other words, if the transmitter and receiver are on the same circuit from the electrical panel, then the signal is broadcast on the wire and the receiver gets it and everything is cool. But if they are on different circuits, then the signal is broadcast and it travels to the electrical panel along one wire, then back along another wire to the receiver. (Note, an X10 signal actually is broadcast to all power in the house, it is not point to point.)

But it gets worse than that. A typical household electrical panel in the U.S. has 220 volts coming into it. All 220 volts are used for the dryer and electric stoves, but a typical wall socket only gets 110 volts. The panel is divided into two "legs" labeled A and B. A signal on the "A" leg travels down the wire to the panel, then out to all other wires on the "A" leg. If the receiver is on the "A" leg, it will probably get it without too much voltage loss and everything will be fine.

However, if the receiver is on the "B" leg of the power panel, then the signal has to somehow get from "A" to "B". If the dryer or electric stove is on, then it goes through the dryer or stove on the "A" leg and back out on the "B" leg. If the dryer or stove is off, then it has to find another path. That path is that the signal runs out to the street to the transformer. At the transformer, it crosses to the "B" leg, and back into the house to the receiver. Yikes! That could be a long way. The signal may make it successfully, or it may not. The number of factors involved means that it can't be determined ahead of time whether this will work or not. In my house, it was unreliable.

The solution is to use a Passive Coupler. This is a simple device that is mounted in the electrical panel between the two legs. It makes a signal on one leg pass through to the other leg. There are also devices that can be plugged into a dryer socket that accomplishes the same task. A 75 cent capacitor in the electrical panel is also reputed to work, although some engineers recommend against it.

In some solutions, this may not be enough. The signal may still be too weak by the time it gets to the receiver on the other leg. In that case, a coupler-repeater may be necessary. This device acts as a Coupler, except that instead of just passing the signal through, it acts as a receiver on one leg, then a transmitter on the other leg. This boosts the voltage back up to 5 volts going down the "B" leg. I (at least so far) haven't needed one of these.

Noisemakers and Signal Suckers

There are other problems that you may run into. One is that you may have a noisy device on your power grid. There are no electrical standards for how much noise an appliance may put on the power line. So, if you noticed, running the vacuum cleaner puts snow on the TV. The same thing can happen with X10. A bad device may cause X10 signals to get lost in the noise it generates. To track down and fix this can be difficult, basically a job of trial and error.

The cheapest way to find the noisy device is to go to the electrical panel and flip off all the breakers except the ones where the transmitter and receiver are located. See if the signal gets through. If it doesn't, make sure all other appliances on those circuits are turned off. If it does, then flip on the breakers one at a time until the signal fails to get through. Then track down what appliance on that circuit is causing the problem by unplugging it. Some devices will put noise on the power line even when they are off.

A slight more expensive solution is to acquire an X10 signal measuring device. There is a device that has a meter showing when X10 signals are crossing the wire, and how much voltage they are generating. This makes it much easier to track down the noisy device.

Once you identify the noisy device, either get rid of it or isolate it. You can put a filter on that device that prevents any noise from it from getting on the power line. There are 5 amp, 15 amp, and 20 amp filters, which you select based on how much power draw you are placing on the circuit.

Another class of device is called a signal sucker. A signal sucker reduces the electrical voltage of the X10 signal on the wire. You track them down and isolate them using the same technique as a noise maker. UPS devices for computers are notorious signal suckers, since they filter the power line.

Another source for noise may be a neighbor that is also using X10 devices. You can get a whole-house filter that resides at the power panel that essentially signal sucks any signals coming into or out of the house.

Switches and Dimmers

Once you reliably get the signal from transmitter to receiver, you need the right kind of receiver. There are two general types of devices for controlling power: Dimmers and switches. You should never use a dimmer when you need a switch. A switch, on the other hand, can always be used.

A dimmer is capable of reducing how much voltage a load receives. (A load is a light, or TV or whatever you are controlling.) A switch does just on and off. Reducing the voltage that a TV receives is a good way to destroy it. On the other hand, it works really well with an incandescent bulb. Whether an X10 dimmer works with an overhead fan actually depends on the fan motor.

Switches should be used for halogen lights, florescent lights, TVs, stereos, and all other on/off type devices.

There are two kinds of dimmers and switches: Ones that are capable of reporting back their status and those that can't. The ones that can report back their status are actually tranceivers, since they transmit back information. Since these are much more complicated, they cost considerably more than ones that can't report their status.

To use the tranceiver type dimmers or switches, you run into another possible problem. These need to have the right kind of power. There are four possible wires in any switch box in the wall:

  • Hot (black)
  • Neutral (white)
  • Ground (green or bare copper)
  • Load (black) or Three-way circuit (red)

Each switch box is required to have hot, ground, and load (or three-way). However, it depends on how the wiring in the house was done on whether the switch box in the wall has a neutral wire. The light or socket has to have a neutral wire, but the switch box doesn't. If the electrician strung the wire to the light, then to the switch box, he might not have continued the neutral wire to the switch box, saving a little cost for copper. Unfortunately, this doesn't work for the tranceiver type dimmers or switches. Since these devices are essentially loads themselves, they requires a neutral to work.

You won't know until you open the switch box whether it has a white neutral wire running into it. If it doesn't have a neutral wire, then you will need to either use the cheaper and less functional non-tranceiver switches, or you will need to get an electrican to run a neutral wire into the box for you. Running neutral wires can be a major expense.

In my house, every switch box I've opened, fortunately, has had a neutral wire already.

Three-way, Four-way, etc., Circuits

If two sets of light switches control the same load, it is called a three-way circuit. If three sets of light switches control the same load, it is called a four-way circuit. These kinds of circuits can cause additional headaches when wiring the switches and dimmers. Once you have two wall switches controlling the same load, there are additional complications in how it is wired. There are a nice set of articles available describing all the permutations of three-way and up circuits. But what it boils down to is this, you have two ways of replacing existing circuits:

  • Use X10 3-way hardware
  • Use an X10 switch or dimmer and X10 transmitters

There are a number of manufacturers that make X10 switches that directly replace existing 3-way hardware. You just pull the existing 3-way hardware and wire in the new hardware. However, the switches that I chose didn't have a 3-way version. Instead, you use a standard X10 switch to control the load, then add transmitters at the other locations to tell the load switch what it should do. For example, the transmitter may place a signal on the wire telling the X10 load switch to turn on. The one gotcha here, is that with the equipment I used, the transmitter cannot act as a dimmer, so only the switch that controls the load can actually dim the lights.

When I was pulling apart the existing 3-way circuits in my house, the tricky bit was identifying which wire controlled the load. It had to be in one of the switch boxes. A bit of advice: before you disconnect anything, draw a picture of where every wire comes into the box connects to each switch. Any time I didn't do this, I regretted it later. Anyway, after you identify the wire that goes to the load, you want to place the dimmer or switch connected to that wire.

What if you want the dimmer at the other location? Well, it turns out that you are in luck. With this scheme, you have a left-over red wire that was used to control the 3-way circuit that runs to the other box. Hook the load wire to that, and the red wire in the other box becomes the load wire. So you can place the dimmer in any box if you wire it right. After I realized this, it meant that I didn't have to compromise on where the dimmers had to go.

House Codes and Unit Codes

Each X10 receiver that you put on the power line is given one of 256 addresses that it uses to indentify what signals it will respond to. For convenience to non-computer people, Pico broke the addresses into 16 groups of 16 addresses. The major groupings are called "house codes", and the minor groupings are called "unit codes". The house codes are lettered instead of numbered, from A through P. The unit codes are numbered from 1 through 16. So a particular address might be M3.

More than one receiver might be on the same address. So if a transmitter tells M3 to turn on, and there are two receivers on that address, then both of them will turn on.

Another instruction that can be placed on the wire is to turn all the units on house-code M on. This is the "All Lights On" command. There are also "All Lights Off" and "All Units Off" commands.

Each X10 receiver has to be programmed to respond to a given address. On many devices there are two dials for house code and unit code. On my wall dimmers, switches, and transmitters, though, there is a configuration mode, and X10 signals from the computer programs the switch.

Controlling X10 with a Computer

Now, all that I've discussed so far might be pretty interesting, but the cool part is when I can control this using my computer, and in particular controlling it from my iPaq. So the next step is to make the computer a tranceiver.

There are a number of devices that you can buy that allow the computer to send and receive commands on the power line. These devices plug into the serial port on the computer. The other end plugs into a standard wall socket. The one I am using is called a PowerLinc, although there are several others available, including the CM11A. Make sure you plug it directly into the wall instead of a powerstrip or UPS, as they will filter the output of the device.

You communicate with the PowerLinc by putting a standard message on the serial port using the X10 protocol. A typical message is:

  • Start code
  • House code
  • Unit code
  • Function code
  • End-Of-Message code

For various technical reasons, the way that a binary 1 is represented on the power line is 10, whereas a binary 0 is represented is 01. (In other words, a 5 volt spike at one crossing, followed by no spike on the next for a 1.) So each bit is followed by its compliment. The PowerLinc handles transmitting the signal correctly when passed the right info to the serial port.

Talking to the serial port is easy in Visual Basic using the ActiveX control. So it is trivial to create a Visual Basic program that will place the correct signal on the power line. The PowerLinc even has Visual Basic source code that does just that, so you don't even need to write it. The problem comes when I want to control it from a web page. An ActiveX control has to be placed onto a form. That requires a user interface, and IIS hates talking to stuff with a user interface. That precluded using the ActiveX control.

I could have written my own serial port controller, but there are a lot of threading issues and things that I didn't want to have to think about. Unfortunately, the .NET CLR doesn't have any functionality for controlling the serial port. So instead of writing it and debugging it, I found an existing library and bought it, including C++ source code. This produces a standard DLL.

I then wrote a Windows Service that acts as the home controller. It performs several tasks:

  1. Accepts commands to be sent to the serial port
  2. Checks to see if an event, such as sunset occurs and triggers the appropriate command
  3. Monitors the serial port looking for status messages about lights being turned on and off and records that info
  4. Reports the current status of the lights back to a requestor

I then created an ASPX page that calls the Windows Service. This ASPX page uses Windows Messaging to talk to the service and request the current state of the lights. It uses that info to change a graphic of the floorplan using GDI+ to show the current state. It also makes each of those points on the floorplan a hotspot that can be clicked. When the click occurs, it posts back to the page and a call is made to the Windows Service to turn the light on or off.

At this point, I could call up a web page and turn on and off lights at various addresses. This turns out to be especially convenient when I want to turn on the office lights without getting up from my computer. I just call up a page and click the buttons to turn the overhead light or wall lamp on.

The Web Server and House Network

I currently run a web server out of my house. I have a symmetric 768K DSL connection, with a static IP address. I have a dual Pentium II 333 server connected to this. I run Windows 2000 Server on the machine. This machine is on 24/7 already, so there is no additional cost to me to use this as my home automation controller. There are also dedicated devices that will act as transceivers available, but they don't provide the kind of control that I want. I actually have another machine that is also on 24/7 that acts as my firewall, among other tasks.

There is no requirement that the web server have an Internet connection. It could be internal to the house only, and could be a simple Windows NT/2000/XP Professional machine. The PowerLinc is plugged into its serial port on the web server.

I have an internal network in the house. Ethernet requires four wires (yeah, I know the standard ethernet cable has eight wires, but four of them are wasted unused copper). Instead of pulling new ethernet wires to each room in the house, I co-opted four wires out of the existing cat 3 phone lines to become ethernet wires. Cat 3 is substandard for ethernet, but I have had no problems using it for ethernet.

So I have ethernet running to each bedroom of the house from the firewall machine, as well as the two offices, and the kitchen. There is a hub in the garage that becomes the distribution point for the ethernet. So one ethernet wire runs from the web server in the office to the garage hub. Another line runs from there to the attic where the 802.11b Access Point is located.

Using the iPaq

The next step is being able to access the web page from the iPaq. Within the house, this can be done with 802.11b technology. This is a proven short-range scheme for doing wireless connections. The essential equipment:

An 802.11b Access Point is essentially an antenna that connects to an ethernet. It turns out that the optimal location for the Access Point is as high as you can get it. The center of the attic turned out to be optimal placement. Unfortunately, I have been a little disappointed with the range of the 802.11b. I fail to get connections from the far corners of the house. I will probably have to add a second 802.11b Access Point in the future to get full coverage. A smaller house probably wouldn't have this problem.

The iPaq fits into a sleeve that adds a PCCard (aka PCMCIA) slot to the back. An 802.11b PCCard slides into the slot. After configuring the Access Point and PCCard software to use encryption, I can download web pages into the built in version of IE on the iPaq. This includes the web page that I constructed above.

It just works!

Using the iPaq from Elsewhere

I have not done this step, but you can also get a wireless modem PCCard for the iPaq. This costs about $300. In the area where I live, one of the wireless providers allows unlimited service for $30 a month if you use a particular combination of hardware. The bandwidth on it, though, is rather pitiful, about equal to a 9600 baud modem. So optimizing the web page becomes rather important when dealing with this technology.

Using this technology would allow me to turn on and off the exterior lights from my car, for example.

I could also hook the web server machine to a modem, and send signals from a standard cell phone.

Summary

By using a combination of hardware and software, I have been able to control the automation of my house relatively easily.


Top