HCS II X P R E S S System Reference Manual Release 2.0 3/1/93 On-line Version Circuit Cellar, Inc. 4 Park St. Vernon, CT 06066 (203) 875-2751 Circuit Cellar will not be held responsible for any damages caused by use or misuse of XPRESS and the HCS II. Circuit Cellar provides XPRESS with the understanding that the user will determine its fitness for any particular application and Circuit Cellar specifically disclaims any implied warranties. While we have attempted to provide accurate and up-to-date information in this manual, Circuit Cellar makes no representations or warranties respecting its contents. We reserve the right to make periodic changes to the text and to issue new editions of this manual without notifica- tion. Occasionally in this manual we refer to the products of manufacturers other than ourselves. Such references do not constitute an endorsement of these products, but are included for the purpose of illustration or clarification. We do not intend such technical information to super- sede information provided by the individual manufacturers. All trademarks referenced are the property of the respective trademark owners. COMM-Link, PL-Link, IR-Link, MCIR-Link, LCD-Link, DIO-Link, DIO+-Link, ADIO-Link, Supervisory Controller, XPRESS, and HCS II are trademarks of Circuit Cellar Inc. XPRESS and this manual are copyright (c) 1992, 1993, Circuit Cellar, Inc. All Rights Reserved 1. System Overview . . . . . . . . . . . . . . . . . . . . . . 1 1.1 Definition of Terms . . . . . . . . . . . . . . . . . . 2 2. Software for the PC . . . . . . . . . . . . . . . . . . . . 3 2.1 COMPILE . . . . . . . . . . . . . . . . . . . . . . . . 3 2.2 HOST . . . . . . . . . . . . . . . . . . . . . . . . . . 4 2.3 HOST Windows . . . . . . . . . . . . . . . . . . . . . . 5 3. XPRESS Program Structure . . . . . . . . . . . . . . . . . . 7 3.1 Configuration Section Keywords . . . . . . . . . . . . . 8 3.2 Control Section Keywords . . . . . . . . . . . . . . . . 8 3.3 Configuration Section Details . . . . . . . . . . . . . 10 3.4 Control Section Details . . . . . . . . . . . . . . . . 12 3.4.1 IF/IFA Statements . . . . . . . . . . . . . . . . 12 3.4.2 Conditions . . . . . . . . . . . . . . . . . . . . 13 3.4.3 Actions and Assignments . . . . . . . . . . . . . 22 4. Data Logging . . . . . . . . . . . . . . . . . . . . . . . . 33 4.1 Hardware Setup . . . . . . . . . . . . . . . . . . . . . 33 4.2 Software Setup . . . . . . . . . . . . . . . . . . . . . 34 4.3 What to Log . . . . . . . . . . . . . . . . . . . . . . 34 4.4 Logged Data Format . . . . . . . . . . . . . . . . . . . 35 4.5 Sample Processing Software . . . . . . . . . . . . . . . 36 Appendix A: Example Programs . . . . . . . . . . . . . . . . . 39 Appendix B: Port Assignments . . . . . . . . . . . . . . . . . 43 Appendix C: HOST/SC Serial Protocol . . . . . . . . . . . . . . 47 1. System Overview ================== Welcome to the world of home automation. An automated home is a for- eign concept to many people used to living in a world of manual con- trol. The idea of lights turning on and off by themselves, drapes automatically opening or closing, or chimes ringing in response to a car in the driveway may take some getting used to. However, once you've lived with the conveniences for even a short time, you'll quickly come to rely on them. The Circuit Cellar Home Control System II is a new-generation control system with roots in industrial control. With its XPRESS (eXpandable, Programmable, Real-time Event Supervisory System) programming lan- guage, the HCS II gives users unprecedented control over their en- vironment. The basic HCS II setup consists simply of a Supervisory Controller (SC). The base SC gives the user 16 digital inputs, 8 digital outputs, and 8 channels of 8-bit analog-to-digital conversion. An optional plug-in expansion board increases the I/O on the SC to 40 inputs and 32 outputs. By adding one or more COMM-Link modules, the system's reach increases by leaps and bounds. Up to 31 COMM-Link modules may be connected to the system using inexpensive twisted-pair wiring. A single twisted pair (up to 4000 feet long) run throughout the house is all that's needed to tie the system together. Among the COMM-Link modules, the PL-Link is used to communicate with X-10 devices connected to the power line. The IR-Link allows you to issue commands to the HCS II using a standard trainable hand-held IR remote control. The LCD-Link gives the user a gateway to the HCS II with its 4-line by 20-character display and four push-button inputs. Each DIO-Link has 8 bits of digital I/O: four inputs and four outputs. Finally, the ADIO sports 16 digital inputs, 8 digital outputs, 8 chan- nels of 8-bit A/D conversion, and 4 channels of 8-bit D/A conversion. Up to eight of each kind of module may be connected to the network (up to the system-wide limit of 31 modules total). Only one PL-Link may be used in a system, however. An IBM PC or compatible computer is used for initial setup and pro- gramming of the HCS II. When all is working as expected, the PC may be removed from the system until the next time a change is required. The HCS II doesn't tie up your expensive (and power hungry) PC. HCS II System Reference Manual 1 1.1 Definition of Terms ----------------------- You should understand the meaning of a number of terms used throughout this manual before you proceed. Supervisory Controller (SC)--the main board that controls the whole HCS II. COMM-Link--a generic term used to describe any of the HCS II network modules, which include the PL-Link, IR-Link, MCIR-Link, LCD-Link, DIO-Link, DIO+-Link, and ADIO-Link. Local Input (or Direct Input)--any digital input connected directly to the SC or Buffer Terminator Board (which conditions those sig- nals). Local Output (or Direct Output)--any digital output connected directly to the SC or Buffer Terminator Board. Netbit--any digital input or output connected to any COMM-Link network module. Edge--an on-to-off or an off-to-on transition on any digital input. RS-485--an interface standard used as the basis for the HCS II network. It defines the use of a single twisted-pair cable to carry all system communications. XPRESS--eXpandable, Programmable, Real-time Event Supervisory System; the programming language supported by the HCS II. 2 HCS II System Reference Manual 2. Software on the PC ===================== A PC-compatible computer is used to program and monitor the HCS II. Once the system is working, the PC may be disconnected or shut off un- til changes are needed. While the PC software will work on any PC com- patible right down to an original 4.77-MHz IBM PC for small systems, we recommend at least an 8-MHz PC or an AT-class machine be used. The software will work with a single floppy disk drive and either color or monochrome display. There are two programs used on the PC: COMPILE, used to compile XPRESS programs from their original source form to a binary representation used by the SC; and HOST, used to set the time, send XPRESS programs to the SC, display system status, clear the system log memory, and transfer logged data from the SC to a disk file on the PC. 2.1 COMPILE ----------- XPRESS programs may be written using any text editor capable of producing flat ASCII (or text) files. If you're using a fancy word processing program (such as Word Perfect, Microsoft Word, WordStar, Volkswriter, or any of the hundreds of others), be sure you save your code as a plain text file that contains no control characters or formatting commands. Before your XPRESS program can be sent to the SC, the program must be compiled. The compiling process checks your program for correct syntax and value ranges, and creates a binary file containing the raw code to be sent to the SC. The form of the COMPILE command line is as follows (items in braces are optional): COMPILE {filename} where: filename is the name of the source file If the filename isn't given, COMPILE assumes the source file is called EVENTS.HCS. If the extension isn't given, COMPILE assumes an extension of .HCS. The following are valid command lines: COMPILE compiles the code found in EVENTS.HCS COMPILE MYPROG compiles the code found in MYPROG.HCS COMPILE PROG2.TXT compiles the code found in PROG2.TXT COMPILE always creates a binary file called EVENTS.BIN. The HOST pro- gram expects your compiled XPRESS program to be in EVENTS.BIN, so be sure not to change the name of the file. HCS II System Reference Manual 3 When errors are found during compilation, COMPILE will tell you what kind of error was found and what line it was on, and will display the offending piece of code. COMPILE will alert you to several kinds of errors. Syntax errors are usually typographical errors: a misspelled command or a missing state- ment. A single syntax error may result in more than one error message because COMPILE continues processing your program even after the error occurs. Often fixing a single error will eliminate multiple error mes- sages. Value errors are often more subtle. They occur when a value you've specified in a comparison or an assignment is too large or too small. For example, if you accidentally specify a time of 28:30 instead of 18:30, COMPILE will flag a value error because the hours may only be between 0 and 23. COMPILE also checks for unbalanced parentheses and IF/END pairs. 2.2 HOST -------- The HOST program is used to send compiled XPRESS programs to the SC and to display overall system status. HOST displays everything in a text-based windowing environment and works equally well on graphics and text-only systems, and on color and monochrome systems. You should connect the SC to either COM1 or COM2 on your PC before running HOST. The form of the HOST command line is as follows (items in braces are optional): HOST {/COM1|/COM2} {/M} {//} where: /COM1 tells HOST to use COM1 /COM2 tells HOST to use COM2 /M forces HOST into monochrome mode (display just black and white; usually used on systems with color adapter cards and monochrome monitors) // displays a short help screen and exits Examples of valid HOST command lines include: HOST start HOST in its default mode HOST /COM2 start HOST using COM2 HOST /M start HOST in monochrome mode HOST /M /COM2 start HOST in monochrome mode using COM2 HOST // tell HOST to display a short help screen and exit The default mode for HOST is to use COM1 and full-color windows. When HOST is started, it initializes all the windows, puts a command bar at the top of the screen, and displays a window containing in- formation about itself. The information window disappears after a few seconds. 4 HCS II System Reference Manual There are six valid commands that may be issued to HOST: ! : redisplay the information window for a few seconds T : set the SC's clock to the current time and date L : load a new XPRESS program into the SC C : clear the log memory D : dump the logged data to a disk file on the PC Q : quit HOST The T command reads the time and date from the PC's internal clock, so be sure you set the PC's clock and calendar to the correct time and date before running HOST. The L command expects to find your compiled XPRESS program in a file called EVENTS.BIN. If that file can't be found, an error message is displayed. The C command instructs the SC to clear its log memory. This command gives you a way to wipe out any old data and start logging new data at a known time. The D command dumps logged data from the SC's memory to a disk file on the PC. The data is always stored in a file called LOGDATA.BIN, so if you want to save any old data previously dumped to disk, be sure to rename the old data file before performing a new dump. See Chapter 6 for more information on data logging. If there is a problem with the connection between the PC and the SC, HOST will time out during the T, L, C, and D commands. If a timeout occurs, a "sad" beep will sound and a message will pop up informing you of the timeout and asking you to try again. If the timeouts per- sist, you should check the physical connection between the PC and the SC. During both the T and L commands, HOST and the SC verify that the transfer of information proceeded error free. If an error occurs dur- ing the transfer, a "sad" beep will sound and a message will pop up that asks you to try again. A second try will usually succeed. Successful transfers of information during the T, L, C, and D commands result in a "happy" beep and a message that informs you of the suc- cess. 2.3 HOST Windows ---------------- HOST displays HCS II system status information in individual windows on the PC's screen. Each type of information has its own window. For example, in the upper right corner of the screen is the current time and date. The sizes of most windows depend on the information being displayed. The X-10 module status window on the left side of the screen expands HCS II System Reference Manual 5 one line downward for each housecode you ask it to display. Using the DISPLAY configuration keyword in your XPRESS program, you may specify any or all housecodes to be displayed by HOST. Any modules that are on or dimmed (regardless of dim level) are designated by a "1" on the screen. Modules that are off or not used show up as "0" on the dis- play. The network module status window in the center of the screen displays the status of only those network modules defined by CONFIG statements in your XPRESS program. The following summarizes the three possible status indicators: * : module active and responding normally - : module didn't responded when polled by the SC E : response from module contained an error and was discarded An occasional "-" indicates there might be some noise on the network and shouldn't be a concern. Any module showing a consistent "-" should be checked out. Similarly, an occasional "E" indicates some noise on the network and can usually be safely ignored. Consistent errors indi- cate a problem with the network. Finally, inputs and outputs connected directly to the SC (local inputs and outputs) are displayed in two separate windows on the right side of the screen. The number of inputs and outputs displayed depends on the hardware you define with the CONFIG statement in your XPRESS pro- gram. In all cases, the input and output bits are displayed in groups of 24 horizontally (though a row may not contain a full 24 bits). A "1" in- dicates the bit is on and a "0" indicates the bit is off. The starting bit number for each row is shown at the left of each row. The numbers across the top of the rows are offsets from that starting bit number. For example, the first row might have "000" at the left, indicating the leftmost bit in the row is 0, followed by 1, then 2, and so forth. If the next row has "016" at its left, then the bit numbers in that row are 16, 17, 18, and so forth. 6 HCS II System Reference Manual 3. XPRESS Program Structure =========================== XPRESS programs consist of two sections: configuration and control. The configuration section defines what processor board is being used as the SC, how many of each kind of COMM-Link is present on the network, and what X-10 housecodes should be displayed by the HOST pro- gram. It also contains all the label definitions. The control section makes up the bulk of the XPRESS program and con- sists of a series of IF/THEN/ELSE statements. The IF portion is made up of any number of system conditions combined using Boolean opera- tions. When the IF portion is true, the list of actions in the THEN portion is carried out. When the condition is false, any actions in the optional ELSE portion are executed instead. The BEGIN keyword is used to denote the end of the configuration section and the start of the control section. Note: Whenever the condition in the IF portion is true, the action list is executed once. If the condition remains true on later passes through the program, the action list is not executed again. The ac- tions are only executed again after the condition has been false on at least one pass through the program, and is then true again. Similarly, the ELSE portion of an IF statement is executed just once when the condition is false, and not again until the condition is evaluated true, then false again. See Section 3.4.1 for more details. Throughout the program, case is ignored (i.e., upper- and lower-case letters are treated identically). The following is a basic outline of the structure of an XPRESS pro- gram: ________ CONFIG SC = ... | CONFIG PL-Link = ... | CONFIG DIO-Link = ... | | Configuration DISPLAY Modules = ... | Section | DEFINE ... | DEFINE ... ________| HCS II System Reference Manual 7 BEGIN ________ IF ... THEN | . | . | Control ELSE | Section . | . | END ________| 3.1 Configuration Section Keywords ---------------------------------- In the configuration section, the keywords shown below are valid. They may appear in any order within the section, but may not be used at all after the BEGIN. Config = n = "PL-Link", "IR-Link", "LCD-Link", "DIO-Link", "ADIO-Link", "DIO+-Link" n = number of modules connected (0-7) Config SC = = "SC1", "SC2", "SC3", "SC4", "SC5" Define