Home Control System III
The integrated system is
a central controller running
a custom application written in C/C++. It unifies the network
hardware distributed throughout the home to provide the inhabitants
an integrated system that appears to perform intelligent actions
This describes the third generation home control program (set up in
For a write-up of the previous version, see here.
A bit of history
In 1991, I purchased a PCjr
for $40 and wrote a Borland DOS C++ application to communicate with a TW523
(X-10's powerline interface). This allowed me to send and
power line commands to control and monitor the house. After a while, I
outgrew that configuration and found a third party parallel interface
and constructed a DTMF decoder and IR interface. I could now
touch tone commands from the phone, and send IR commands to my
system. I built a niche into the wall of my kitchen, and
system in there for a built-in look.
The first PCjr-based home control system. Installed in 1991.
The status of the units are in the left part of the screen, and events
are shown on the right.
More on the Jr here.
I could view the Jr's
screen on any TV in
house, and it would do somewhat intelligent actions such as mute the
system when a call came in. As the years went by, I had to
the floppy drive, as the Jr has no hard disk. This made me
that I had to upgrade to a conventional PC, or I would one day be dead
in the water with the old hardware. I had also wanted to add
I/O, and thought that a network of PIC microprocessors would give me
the expansion room that I would need. The network of PIC idea
from an existing home control system called HCS.
In 1996, I purchased a 200
computer, and rewrote the
interface with Borland's TurboVision GUI libraries. The RS485
network allowed me to add many more features such as a weather
node, complete phone
interface, a power
monitor node, etc. It still ran as a 16-bit DOS
Windows 95 (and later '98). Since '95 was not very stable, I
open the option of booting up in DOS only, and run in a dedicated mode
if I needed more than a few weeks of reliable operation.
The second generation system using a Pentium computer.
The home control program was augmented with a GUI interface.
See here for more, and here
for a screenshot. Note the PIC modules on top of the
monitor, they are connected by the RS485 network.
Upgrade for the future
In January 2003, the
and I had to run out and get another
PC at Best Buy. This time it came preloaded with Windows XP,
it would not run the 16-bit DOS based application properly (I was
tons of RS485 network errors and time-outs). I was able to
the new PC with my old hard disk running Windows 98, and continue
basically the same as before, but I knew I had to move with the times,
and upgrade the home control program to a 'real' Windows application.
I started to write the new
system, called G3
III), in March 2003. This time, I used the Borland Builder
a compiler I have used successfully for other projects at
allows you to build a Windows GUI application using the Visual based
and it has been very dependable for me. Although I did not
to, the new program is a complete rewrite, using only a few dozens
of code from the old system. Before G3, parts of the code
on the Pentium was from the original source that came with the TW523
than ten years ago (!). Since the DOS application ran in a
loop, it loaded down the PC very much, and other tasks such as web
were always very slow. Time delays were implemented with
delay loops. In the Windows way of programming, one uses
fire actions, and when the home control program is not doing anything,
it frees Windows to do other tasks. Timers fire at 1msec
to perform the background polling of the PIC network. As a
Windows indicates that the CPU is used less than 2% of the time when
only G3. This means web browsing is now smooth, and I can
a video with the DSL connection without disruption of the home control
program or the video.
The new G3 program was put
only two months after I
to write it. Several new features made the one-day trail run
and I had only some minor tweaks before it was left permanently
One significant feature is 'monitor mode'. This causes the
computer to not control the RS485 bus that it is attached to, but
and decode all the messages. In this manner, the new program
gather all the sensor readings and update the user interface and
as usual, except the original home control program is running the
This greatly avoided downtime of the system, a nice feature as we have
grown accustomed to its benefits.
Main screen of the new home control program called G3.
only four house codes are visible
at one time, the state of any unit can be determined by changing a
selection on the GUI.
Note the forecast for today is shown. It shows a mostly
a high of 53F.
Here are some of the features of the system. The new ones are
- Monitor mode
described above, this causes G3 to
the RS485 network and process all messages and sensor readings into its
internal database for display on the GUI. This allows more
computer on the network to run G3. They would all display the
readings, and take the same actions based on events, however only the
G3 program would control the network. This was very useful
the development of the GUI, allowing little downtime during the switch
Monitor mode (here shown as 'passive') causes G3 to process network
traffic on the RS485 line, but it does not generate any. An
has added an
'auto' feature to the irrigation control depending on the rain
- Connect to serial ports
COM1: and COM2: (new).
G2 program accessed the UART registers directly, which limited the type
of serial ports it could use. On the other hand, G3 uses a
compliant library. As a result, it can now use any serial
virtual serial ports such as those for USB-serial converters, serial
redirectors, and serial ports on PCI cards.
- Connect via TCP/IP
Normally, the RS485 network is
to the serial port on the Home Control PC via the first PIC on the
via its RS232 to RS485
However, this new feature causes the program to seek for the network on
the TCP/IP (Ethernet network) at a specific port. With an
serial to TCP/IP converter, the first PIC does not need to be located
the PC, but could in principle be anywhere in the world.
- TCP/IP Gateway
(new). G3 also
acts as a gateway between a
TCP/IP port and the RS485 network. This allows another
G3 (running on another computer on the network) to control the RS485
of PICs. The computer running the gateway function then drops
to monitor mode, and continues to update its database to display sensor
readings and home control events. This feature, combined with
previous one (Connect via TCP/IP) made it easy for me to test
version of G3. I could run the new copy from the comfort of my home
and it would connect to the running version in the kitchen.
The user can select from a wide range of options in order to connect
to the RS485 network,
including if it is made available on the TCP/IP network.
- Downloading of weather
from the internet (new).
forecasts are downloaded
web, and parsed for display on the main screen in a
form and the full contents is available in a separate dialog box.
- In the 'Weather' box
of the main
G3 screen above, we are
of percentage (POP) and a high of 72F.
- This information is
determine if the automatic
blinds are to be opened in the morning. If the
is over 80F, the eight blinds in the family room are not opened at dawn.
- After 3pm, the line
in the main
screen changes to tomorrow's
- The contents of this
dialog box is
also sent to the event log
the weather summary in e-mail reports (see below).
The forecast dialog box. Weatherforecasts for the next 7 days
are downloaded and displayed in textual form.
POP means 'Probability Of Percentage'.
- The names of X-10 units
hardcoded (new). The names
256 possible X-10 units are not hardcoded, but can be edited and saved
to disk. This makes it easier to configure the system without
In the previous generation of home control program this information was
All X-10 unit names can now be edited at run-time. Compare to
screen shot of the
main screen above.
Units not marked as 'Light' do not show dim/bright on
the Home Status
- E-mail reports
better Windows integration and
to Winsock, G3 can send e-mail reports at a preset time.
consist of the contents of the event window, and a summary of the day's
weather and power usage.
The user can customize the Internet options such as e-mail and pager
Some of the settings here are fictitious.
- Sending messages to my
(new). The system can be
to send me a text page when important events occur. Such as
arriving home, or the tripping of the alarm sensor. In the
case, the zone that caused the alarm trip will show up on the text
- Better display of
(new). In G2, the user would see
E-2 ON (with a time stamp) when that X-10 command was
the new system, the user will see Foyer Light (E2) ON (with time
This leads to better readability of the event window. In
if a user is controlling the system by phone (more below), the event
will be spoken out loud into the phone line, and the user can better
along what is occurring.
- Adoption of the concept
generalized house and unit code
Commands and events are attached to the concept of generalized house
unit code. House codes A through P are mapped directly to the
X-10 commands, other events such as from the security system are mapped
to the 'S' house code. For example, S14-ON means that the
system has been armed. W1-ON means that the sun has
latter quantity is from a calculation based on the home's longitude and
latititude. This is provided only as a backup to an X-10
module which uses a sensor to detect sunrise and sunset so that
actions can occur if it gets dark. The benefit of this
be made clear with the next item below.
- User interface for the
maps an event from a generalized house code into another based on
conditions, and simulates the actions of an intelligent home.
example, when the alarm is armed, I can use a Translator rule to
all the lights in the home, or to turn on a light when it is dark and
is detected. A collection of more than 70 of these rules help
the home appear to anticipate your needs. This very powerful
used to be hardcoded, but with the use of Borland Builder has been
to a run-time user interaction using the dialog box below.
any event that occurs can thus trigger another based on the Translator
rules, which leads to a more tightly integrated system. X-10
can trigger IR commands, weather activity can trigger X-10 commands,
by the security system (doors, PIR sensors, etc) can trigger the HVAC
Example of a Translator rule. If the front door is closed
and it is at
send an OFF command to the entry way light (D15) after a delay of 2
minutes. On the event window,
the exchange will be documented by the contents of the Comment
This very complex structure allows
great flexibility in defining Translator rules. If the user
help, each edit box will pop up a hint if the user
pauses the mouse cursor over it.
- The 'Custom' rules
rules too complex to
the structure of the Translator rules, they are implemented by
in C++. Although inflexible unless the user recompiles the
it brings to bear all the resources of C++ when firing complex logical
actions. About 12 rules are implemented by hardcoding.
- One example of such a complex rule is pathway
If a user
gets up late at night and walks around the home, lights will turn on
on which PIR sensor is tripped. However, I only want this to
if it is dark. If lights are already on, I do not want the
system interfering with the lighting setup.
- Another is irrigation control. If an irrigation
starts up unintentionally,
G3 will need to shut it down. However, the logic to detect
too complex for a translator rule.
- Control of HVAC
system. From the
the user can control setpoints, change the mode (Heat/Cool/Fan) and
status of the HVAC system as shown in the main G3 window
the security system is armed, the HVAC system is setback
This feature extends to phone control. A user can control the
system when calling in.
- Display of nine
distributed around the home
screen above) gathered by the thermostat
- Roof temperature. Temperature inside the weather
station on the roof.
- Attic temperuture. Sensor inside the attic near
the heat pump.
- Heat pump exhaust temperature. Temperature of
heat pump air handler.
- Heat pump intake temperature. Combined with the
determination of the performance of the heat pump.
- Upstairs temperature. Temperature inside the
on the second floor.
- Downstairs temperature. Temperature at the main
- Furnace exhaust temperature. Temperature at the
of the main furnace/air conditioner unit.
- Furnace intake temperature. Combined with the
of the performance of the main HVAC system.
- Outside temperuture. Temperature outside in the
pump compressor unit.
- Display of the power
Current, Actual Power, and line frequency. From this other
such as the power factor and imaginary (reactive) power can be
- Display of the
around the home. These are
Kitchen, Front, Basement and Deck door. The status of window
glass break sensors and other sensors are not shown, but change of
will show up on the event window.
- Display of the weather
node gathered data
wind speed, etc.
- Ability to send any
X-10 command by
clicking on the unit name on
Status' window. A pop-up menu allows the user to select the
- Control of the security
system, such as
and Disarming commands, and security levels (away, home, perimeter,
- Almost all of the data
G3 can be charted (augmented
See below for more information.
- 'Mapper' function that
commands received from 'A'
commands for the entire house. Using the unit codes A-1
a user can control all of the units in the 'Home Status' window on the
G3 screen. Two unit code commands within 15 seconds are
affect this action. The first code signifies which group of
and the second the individual unit within the group. The
arranged by column of the display, making it easy to determine the two
unit command based on a visualization of the 'Home Status'
For example, to turn on the front irrigation valve, the user sends A-1,
A-5, A-ON. This allows control of the entire home via a mini-controller,
interface, IR wrist watch,
- Phone interface
G2). The phone
node is connected to one extension of the phone
system, if a user connects to it (either from outside the
it will answer and speak the words 'Ready' once the password has been
The user can then hit a button to send a command to the 'A' house code
(thereby controlling any of the units via the 'mapper' function), or to
request for the help string. While the user is on the phone,
phone node will also speak out loud any new events printed to the event
window, so that he can verify commands sent (such as 'dishwasher ON',
'HVAC set forward').
- Incoming calls cause a
dialog box to pop up for 30
with the caller's name and number. Due to the open design of
home, it can be seen from a wide range of areas, allowing quick
of a caller, should he/she get past the auto-attendant in the phone
- Coupled with VNC
entire interface is available anywhere on the web with nothing more
a web browser.
Charts of gathered data
The last set of features
completed are the charting
Before I go into this section, I just want to mention that I like
at charts and graphs. I do a lot of it at work, and
and relationships in the data is something I find fun. This
feature existed to a limited extent in the G2 version, but I have
to chart all the analog data that G3 gathers (using the 'TeeChart'
from Borland Builder C++). Examples are ambient temperatures
power line status. This screenful can be switched to if the
selects that function. The horizontal axis of the chart is
during which the sample was taken. The chart autoscales the
axis depending on the max and min values of all the graphs
A user can select either the left or right vertical axis for a data
by clicking on a series of checkboxes on the left. If the
help on what a particular check box does, he/she can pause the mouse
it, and a hint will pop-up with the name of the corresponding
Alternately, by clicking on the 'Legend' button, a legend will appear
to each pair of checkboxes along with the color of the graph for the
For the user's convenience, a series of preset configurations have
been hardcoded, and can be cycled through to quickly show commonly
graphs. Alternately, the user can just click on the
to enable a graph.
Example of a set of charts showing temperatures around the
Here is another chart.
In the example chart
temperatures around the home are
charted. As the user moves the mouse over the chart, a faint
line snaps to its position. Where it intersects with data,
and name are displayed along with the time on the horizontal
In this example, at 2:39 pm, the temperature in the attic was 113.9 F,
while the outside temperature was 94.4 F, etc. The checkboxes
the left turn a particular chart on and off, i.e. if the left box is
the graph's axis will be the left one.
One can make some observations on these graphs:
- On the left hand side starting about 10pm (22:00), the
(dark green) cycles as the heat pump turns on and off to cool the
One can see that cycling reflected in the heat pump intake temperature
(light blue). On another graph this cycling is confirmed by
the temperature drop throught the heat pump and power draw.
cycling stops at around 2 am when there is enough cooling due to heat
to the outside air.
- After the sun rise causes rapid heating starting at 8 am,
heats up, exceeding the temperature on the weather station on the roof
(dark green roof temp) at around 10:30 am. The attic
heat up throughout the day, reaching a peak temperature at the vertical
- Since the heat pump/AC is turned off for the bedrooms
upstairs temperature starts to rise also (dark green) at around 10
At around 4 pm, the upstairs air-conditioning is enabled by G3, and
starts (light blue Heat Pump Intake falls rapidly). It takes
about 1 hour before the set point is reached.
- At around 2 pm, the Downstairs temp (dark maroon)
in temperature, and triggers the main unit downstairs to start
One can see the Main Intake Temp (brown) rise as warm air rushes
the system. This drops as the unit runs, and cools off the
When the temperature drops below the hysterisis of the thermostat, the
unit shuts off (small blip down in the Downstairs temperature).
All these temperature
have their corresponding change in
the power use of the home, which can be seen on another preset
The user can also turn that trace on by clicking on its corresponding
box. Combined with a trace that shows temperature rise or
the heating/cooling unit, one can tell how well they are working, or if
service is needed (by comparing the delta T vs power usage).
Long term update
complete. Software placed
Added municipal water meter.
Next level up