An X-10 Sprinkler Controller (XSC)

An X-10 Sprinkler Controller (XSC)
Introduction

For some time now, I've wanted the ability to control my sprinklers from my home automation network. The easiest way to integrate it was via my house's X-10 system. Commercial units are available, such WGL Designs' Rain8 units, but at the end of the day I'm cheap and I'd rather build my own anyway.

Fast forward to Saturday, 29-Apr-2006. After spending yesterday digging, raking, laying irrigation piping, and then laying sod on one of my friend's yards, I was way too sore to do anything productive today - at least anything requiring physical effort. So, I plunked myself down at my workbench and started working on my own irrigation controller. Initial codename: Project Tinkles By 1900h, the code was working well enough that I actually ran through a programmed sequence and watered my front lawn with the unit. By 2330h, I had the code in a finished state, and had managed to sketch out a crappy schematic.

The unit is capable of controlling up to 8 zones individually. It consumes the first 9 unit codes of a single house code. It can either run an individual zone for a user-selectable length of time, for a preset amount of time, or execute a program that will run through a preset amount of time on all 8 zones. (Unused zones can be skipped by programming them for zero time.)

In addition, while the unit is idle, it acts as an X-10 line monitor, displaying the last two commands that it saw go across the power line. I figured I had an LCD screen and some spare real estate, so why not?

X-10 Commands for the XSC

  • ON Commands - Each zone has a programmed maximum amount of time (configured in EEPROM, see below) that it is allowed to be on. Zones 1-8 occupy unit codes 1-8 on the chosen housecode (A-P, defaults to K). The zone will remain on until either an off command is received for that unitcode/zone or the zone runs for the maximum allowed time. An ON command to unit code 9 will load the predefined run times for all eight zones and start running them in sequence (1-8). Note: Issuing a command to a zone while another zone is active will queue the new zone up for when the current zone finishes. Issuing commands to unit code 9 overrides immediately.
  • PRESET DIM Commands - In addition, each zone can be turned on for a chosen amount of time by using the preset dim commands. Sending a preset dim between 0-31 to any of the unit codes will turn that zone on for 0-31 minutes respectively. Note: If the maximum time for the zone is less than 31 minutes, any greater preset dim will be ignored and the unit will run for the maximum configured time.
  • OFF Commands - Sending an off command to unit codes 1-8 will turn off the zone, if currently active, or de-queue it if it is queued up to run. Sending an off to unit code 9 will shut off all zones immediately.

The XSC Display

In its idle mode, the unit will show *All Off* in the upper left corner, with the software version number on the right side of the first line. Below it, you'll see X-10: followed by the last two commands to pass over the power line. A housecode followed by a number is an address. A housecode followed by alpha characters is a command word. The only exception is preset dim commands, which appear as *00 (where 00 is the preset between 00-31), because no housecode is encoded with preset dims.

Commands you might see:
(x = Housecode)

  • xAOF - All units off
  • xON - Addressed units on
  • xOFF - Addressed units off
  • xLON - All lights on
  • xLOF - All lights off
  • xBRT - Brighten
  • xDIM - Dim
  • xEXT - Extended Code/Data (can't decode)
  • xHRQ - Hail Request
  • xHAK - Hail Acknowledge
  • xSRQ - Status Request
  • xSON - Status On
  • xSOF - Status Off

Configuration

Configuration is entirely done by changing EEPROM values. This is quite easy using a PC serial port, since the unit has a bootloader that can be interacted with using a serial console (19200 baud, 8-n-1). Connect up the console and hit Z (yes, it must be a capital Z) within the first second or two that the unit has power (or after you briefly ground the MCLR line on the PIC). You'll get a prompt. The syntax for writing to EEPROM is: W DD @ AA, where % is a two-digit hex number to write and % is the address at which to write it. So, if I wanted to program housecode K (0x4B in ASCII), I'd type W 4B @ 00

Maximum Minutes - The maximum time a zone will stay on. This is a safety to prevent X-10 communication problems from wasting water by running a zone forever. A zero disables the zone.
Program Minutes - When the program is activated by sending an ON command to unitcode 9, these are the times at will be loaded for each zone. A zero disables a zone.

EEPROM
Address
Purpose
0x00Housecode, in ASCII - A=0x41, K=0x4B, etc.
0x10Zone 1, Maximum Minutes - 0x20 = 32 minutes, 0x0B = 11 minutes, etc.
0x11Zone 2, Maximum Minutes - 0x20 = 32 minutes, 0x0B = 11 minutes, etc.
0x12Zone 3, Maximum Minutes - 0x20 = 32 minutes, 0x0B = 11 minutes, etc.
0x13Zone 4, Maximum Minutes - 0x20 = 32 minutes, 0x0B = 11 minutes, etc.
0x14Zone 5, Maximum Minutes - 0x20 = 32 minutes, 0x0B = 11 minutes, etc.
0x15Zone 6, Maximum Minutes - 0x20 = 32 minutes, 0x0B = 11 minutes, etc.
0x16Zone 7, Maximum Minutes - 0x20 = 32 minutes, 0x0B = 11 minutes, etc.
0x17Zone 8, Maximum Minutes - 0x20 = 32 minutes, 0x0B = 11 minutes, etc.
0x20Zone 1, Program Minutes - 0x20 = 32 minutes, 0x0B = 11 minutes, etc.
0x21Zone 2, Program Minutes - 0x20 = 32 minutes, 0x0B = 11 minutes, etc.
0x22Zone 3, Program Minutes - 0x20 = 32 minutes, 0x0B = 11 minutes, etc.
0x23Zone 4, Program Minutes - 0x20 = 32 minutes, 0x0B = 11 minutes, etc.
0x24Zone 5, Program Minutes - 0x20 = 32 minutes, 0x0B = 11 minutes, etc.
0x25Zone 6, Program Minutes - 0x20 = 32 minutes, 0x0B = 11 minutes, etc.
0x26Zone 7, Program Minutes - 0x20 = 32 minutes, 0x0B = 11 minutes, etc.
0x27Zone 8, Program Minutes - 0x20 = 32 minutes, 0x0B = 11 minutes, etc.
Documentation and Source Code

Documentation

Version 1.0
Released: 30-Apr-2006
I apologize for it being crude and hand-drawn - cleaned up version coming...
[png]

Firmware

Version 1.0
Note: Compiled with C2C 5.97 compiler, targetted for PIC16F877A with bootloader
[src] - [hex]
  Questions? Email Nathan Holmes
© NDHolmes, but freely usable under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License.
Last modified on April 30, 2006, at 12:13 AM
Edit Page | Page History