SHOCK
Home Automation System

 

See a working demo of the my home-automation control web page! This page is running from a CGI script which is interfaced to the control computer! Also, you can now download the SHOCK source, executable, and sample configuration!
SHOCK is constantly evolving. Please check back for updates.

 

SHOCK is a system which I designed to control lights, cameras, and various other devices in my home. I now have more than forty-two devices connected inside my home including five digital thermometers, a light sensor, a valve to fill my hot tub, and a video switcher for my web cam (with panning). My system controls the temperature in four zones (including my hot tub), garage doors, ten lights, and my alarm system. The beauty of the system is that, no matter how many devices are connected, the system speed remains nearly constant. I can monitor and control all devices through any browser over the Internet (see the working demo page). Using the INetCam software, I can also view the output of the video switcher.

SHOCK is home automation system in which one computer controls and manages many 'dumb' (non-computerized) devices. SHOCK is a wired system and is based on Dallas Semiconductor's 1-wire series of devices and runs on a Bagotronix DOS Stamp computer module. SHOCK differs from other home-automation systems in that device feedback is standard. Every I/O device communicates with the control computer and communication errors are continuously detected, logged, and corrected.

The control system is completely configurable using a simple language which connects the inputs and outputs of control 'blocks'. These blocks define input modules, processing functions, and output modules. For example, you might connect a light switch module directly to the input of a lamp module. If your kids are constantly leaving the light on, you may want to make it turn-off after ten minutes. This can easily be done by inserting a timer block between the switch and the light:

If you want to control a light from two or more switches, just configure another switch module to connect to the light module's input.

New Features
I recently designed a 1-wire MSP430-112 interface module. The module behaves similarly to the DS2407 bus has four inputs, three outputs, and an IR reciever (finally I can control the lights from my TV remote!). Of course, the board fits easily inside a standard switch box.

SHOCK can now be configured through a text file (config.txt). This means that you can now build the SHOCK home automation system without compiling any code! See the CONFIGURATION section.

A T-Bus controlled 1-of-8 video switcher and a servo output is used to pan a camera horizontally using a standard R/C servo. The servo output is switched between the cameras using the video switcher so only one DOS Stamp output is required to pan all of the cameras. I will soon add vertical panning and a simple pulse decoder.

The SHOCK software can now be compiled and run using Visual C++ 6.0 as a console app. Although there is no support for the T-Bus, the "emulation" is useful for testing new function blocks and overall program stability.

A wired control system- are you NUTS?
Unlike the X-10 system which communicates through existing power lines, SHOCK is a wired control system. This means that every device module must be wired to the control bus. Although running a set of wires to each light switch in a house sounds insane, the task is worthwhile in light of the advantages of such a system. All devices are connected using only one set of wires: power, ground, data, and (optionally) direction. The following illustration shows a simple bus configuration:

Features:

Small module size switch/output modules fit into existing switch boxes
Transparent existing light switches are used making the system transparent to the user
Multiple device types discreate input and output, analog input, and digital temperature sensors

High-speed

lights turn-on and off with no noticable delay
Flexible switches and software-configurable control blocks can be combined in almost any imaginable configuration
Internet Remote Control devices can be controlled and monitored via a browser
Expandable using bus amplifiers, there is almost no limit to the number of devices which can be controlled

Hardware
SHOCK hardware consists of the computer module, T-Bus (one-wire bus) interface, 2x20 character LED display, keyboard, power supply, and various I/O modules. The Bagotronix DOS Stamp was chosen as the computer module due to its low-cost, simplicity, and features which include a 40Mhz AM188ES core, 512K RAM, 128K FLASH disk, 16 digital I/O ports, two serial ports, real-time clock, and Disk-On-Chip socket. It was necessary to buy the optional 8M Disk-On-Chip in order to provide sufficient storage for the program. A simple two-chip circuit interfaces the DOS Stamp to the T-Bus and an optional LT694 provides watchdog functionality (the watchdog resets the DOS Stamp in the event of a crash). Below is a schematic of the interface. I added a watchdog timer since the DOS Stamp's watchdog is permanently disabled at startup. The keyboard is optional but is great for central control of temperature "zones" and groups of lights.

This T-Bus "extender" is just a two-way amplifier for the 1-wire bus. Althought the 1-wire I/O devices present a very low load, the long wires neccessary to control an entire house present a substantial inductance to the TTL T-Bus output. The T-Bus extender allows the bus to be split into two or more loads and does not require any additional software overhead. Actually Dallas Semiconductor has addressed the loading problem with their DS2409 MicroLAN Coupler device, but this is simply a T-Bus controlled 1-to-2 multiplexor and requires substantial programming overhead (it creates two completely independant networks). My T-Bus extender is transparent to system operation although it does require an extra wire for the direction control.

 

 

Software
The SHOCK program is written almost entirely in C++ and is compiled using the freely available Borland Turbo C++ 3.1 compiler. The program provides a low-level T-Bus interface combined with high-level real-time control processing and a command prompt for debugging and Internet interfacing. SHOCK is configured using a simple connect-the-blocks scheme which is contained in separate CONFIG.CPP module. Currently, any configuration change requires the entire program to be built and uploaded to the controller. Eventually the configuration will be read from a text file without the need to re-make the program.

In addition to a Turbo C++ 3.1 project, I have added compiler conditional statements and created a Visual Studio 6 application which simulates SHOCK on a PC. Although there is no I/O, this PC application can aid in testing new function blocks and other basic operations.

Configuration
NEW! Shock is now configured through a simple text configuration text file (config.txt) which is read at runtime. The SHOCK program no longer needs to be compiled every time the configuration is changed. Simply run the binary (SHOCK.EXE) in the same directory as the configuration text file (config.txt). Each line of the config file can either declare a new function block, set an input to a constant value, or connect an output to an input. For example:

new input BathrmSw1 A2000000 19613346 A ;Declares a new switch on port A
new input BathrmSw2 A2000000 19613346 B ;Declares another new switch on port B
new output MyLight 9F000000 1961B212 B ;Declares a new output on port B of a device

new gate MyAndGate ;declares a new AND gate
MyAndGate.gatetype = AND ;Makes the gate an AND gate.
BathrmSw1.out > MyAndGate.inA ;Connect switch 1 to AND gate input A
BathrmSw2.out > MyAndGate.inB ;Connect switch 2 to AND gate input B
MyAndGate > MyLight ; Connect output of AND gate to the light

Function block outputs can, of course, be connected to other function blocks to make very complex circuits. Because the blocks are only scanned when a value changes, these circuits are scanned completely using 100% of the CPU resource. This also means that multiple outputs can be connected to a single input. In the previous example, we could have simply connected both switches to the light:

BathrmSw1 > MyLight
BathrmSw2 > MyLight

When either switch is activated, its circuit is scanned so there is no contention.

Ouputs can also be connected to mutiple inputs. The only rule is that feedback loops must contain a FEEDBACK BUFFER block which prevents the scanning of infinite loops.

There are currently four interface blocks and sixteen processing blocks available as shown in the following table:

Discrete-Input
Discrete Output
Temperature Sensor
A/D Input
Pulse Detector
Display
Compare
Delay
User-Adjust
Time Compare
Time Pulse
4-Input Gate
Edge Trigger
Value Selector
10-input OR Gate
FeedBack Buffer
Temperature Selector
Antifreeze
Byte-to-Discrete
Switch Timer