HCS_C Xpress USERS GUIDE
Version 0.01 5/14/05
Version 0.02 5/14/05 some quick error fixes
Version 0.03 6/4/05 IF-IS, Changed, Changed_val implementation
Version 0.04 6/26/05 New Logging and Timer functions
Version 0.05 7/30/05 Voice, HCSNET support added, fixed old syntax. This goes with version 0.03
Version 0.06 8/15/05 fixed left-over format problem with tilde
Version 0.07 12/3/05 fixed Voice syntax, changed hcs_byte to hcs_fpga, added special char
Version 0.08 01/07/07 Changed HCS_NET to HCSNET, syntax for HCSNET read registers
Version 1.04 02/06/07 Added bit set to variable
Version 1.04a 020607 Added bit variable read, X10 readback
Version 021507 added more info on recording, playback of voice. changed inbyte to more accurate HCS_FPGA, and added register names in addition to register numbers. X10 is now an operand as well as an action.
version 021707 Added info on BIT syntax
version 060207 Added video support (1.06)
version 012608 Added Insteon support (1.08), fixed missing X10 description
version 020908 Added new caret string escape sequences (1.08a)
version 031508 Added defines, configuration info
version 032408 Added WAIT capability, compiler limits, added the X10 and X10_ERROR read operands.
version 071308 Added ALERT
version 080810 New HTML display syntax, fixed hcsnet syntax, added tick defines, added HCS register list
version 080811 Added new console term control
version 080816 Comma separated specials
version 080820 Special character example fixes
version 080827 changed video ctl chars to be consistent with HCS_Combo
Bob Morrison, Zeta Engineering
Welcome to HCS_C Xpress! This document will provide information necessary to configure and operate your HCS_C running the HCS_C Xpress operating system. Since HCS_C Xpress is in the early stages of development, you should update periodically to get the latest versions of the HCS_C firmware and the compiler.
To quickly find changes from the previous version of this document, search for this: (UPDATED)
The HCS_C Xpress operating system attempts to maintain similarity with the original HCS2 Xpress. However many enhancements are present or are planned, since HCS_C has substantially increased power and many more peripheral devices. This document describes the programming necessary to use the HCS_C features. Feel free to write to zeta@zetaengineering.com if you have features in HCS2 Xpress that you want to see ported to HCS_C Xpress.
INDEX
INTRODUCTION TO HCS_C XPRESS PROGRAMMING
(UPDATED)
HCS_C_XPRESS SPECIAL STRING CHARACTERS
HCS_C Xpress operates very much like the HCS2 Xpress compiler: Using a text editor, you create a simple control file (events.hcs) with HCS_C Xpress commands in it. You compile the events.hcs file with the hcs_compile.exe compiler. This produces an events.bin file, a binary file that contains configuration infromation and the sequence of commands (tokens) that you want HCS_C to execute. While internally HCS_C operates dramatically differently than HCS2 (for example, much more efficiently due to the interrupt driven architecture used in HCS_C), this is hidden from the user. You upload the events.bin file to the HCS_C board using the (updated) host.exe file, just like on HCS2, although the user view is different for HCS_C. When this is done, HCS_C will attempt to continuously loop through the token sequence that was just uploaded.
Every events.hcs file has three sections, the configuration text, the reset initialization commands indicated by the intial BEGIN statement, and the regular execution commends section. Right now, there are no configurations you can set, so leave that blank. Put in the begin statement, then put in a set of operations to do if the system is emerging from reset. When this portion is complete, follow it with a list of commands that will be executed continuously in sequence. There is no longer a sequential command.
Now you are ready to run the program on your HCS_C. Connect the HCS_C to a PC serial port just like on HCS2, using 9600 baud 8 bit. This will be changed to 115200 baud soon, but currently use 9600. Run the host program on your PC. As soon as you turn on power to the HCS_C, you should see a console message appear "!ROK" which indicates HCS_C initialization was successful. You should also see the date and time window update--probably with the wrong date, so type C, then T to get the date updated. If this all works, everything is set, so you are ready to update the host program.
If the host program wont run and complains about the serial port (Message says: The system cannot open COM1 port requested by the application), you may need to restart the serial port (on windows, it sometimes locks up--resetting the HCS_C will not fix this problem). In this case, you need to disable, then re-enable the serial port. In windows XP you can do this in the System Properties/Hardware/Device Manager/ports/communications port (COM1) settings. You don't need to reboot the system, even if it tells you to. Just disable, then enable, then run the host.exe program again, this should fix it.
If the host program runs, but you don't get the !ROK after pushing reset, the HCS_C didn't come up in the HCS_C Xpress operating system. Your flash memory may not have the HCS_C Xpress firmware in it or it may be corrupted--you may want to reload the flash memory. If you get the !ROK but not the date and time window, HCS_C tried to execute but died somewhere before running the main firmware loop. In both cases, you can connect the JTAG emulator and step through the HCS_C initialization sequence to see where things went wrong--usually it will be something obvious--like the HCS_C DIP switch 1 set in the open position (indicating waiting for a downloaded program). If that is OK, use the JTAG emulator command "x/16 0x400000" to check if the flash memory has some valid instructions in it, you should see something like:
(arm-gdb) x/32h 0x400000
0x400000: 0xe00e 0xffff 0xffff 0xffff 0xffff 0xffff 0xffff 0xffff
0x400010: 0xffff 0xffff 0xffff 0xffff 0xffff 0xffff 0xffff 0xffff
0x400020: 0xb580 0x466f 0xb082 0xf001 0xfd3f 0x1f3a 0x4b13 0x6013
0x400030: 0x1f3b 0x681a 0x23c0 0x6013 0x4a11 0x230d 0x7013 0x4a11
(arm-gdb)
If this area is all 0xffff then you have nothing programmed into flash. If this looks ok, try repeating the command several times. If the values change, then the HCS_C flash memory is not being read correctly, you may want to make sure that the FPGA configuration EPROM is correctly programmed. Try another command in this case:
(arm-gdb) x 0x8000fe
0x8000fe: 0x5555
(arm-gdb)
If the value of this FPGA register (locations in the 0x800000-0x80ffff range access FPGA registers) is not 0x5555, then the FPGA is not configured and you should try to reload the FPGA configuration EPROM. If reloading it doesn't work, you've got an HCS_C hardware problem you'll have to track down.
Note that the first values shown in the 0x400000 dump conform to the linking boot loader format, which will allow subsequent versions to be flash programmed without erasing the flash memory. The first instruction jumps to address 0x400020, skipping the link location at 0x400004. If this were a link, location 0x400000 would be zero and 0x400004 would contain the address of the link destination.
If everything is OK up to this point, you are ready to load the compile program, use the usual process on hcs_c host.exe: The host menu item FILE LOAD (type F, then L) will transfer your compiled events.bin file into the HCS_C main board memory. At that point, the events.bin program will begin executing.
It should be obvious, but I'll state it anyway--bugs are really likely. The more bug reports I get, the quicker you'll get fixes. Don't just live with the bug(s), send me a detailed bug report! You'll help everybody that uses HCS_C. When you send me a bug report, *please* be detailed--otherwise I will waste precious time trying to duplicate the bug. Don't be afraid to send even the most trivial problem in--don't assume that I am sure to see it! Here's what I like to see in a bug report:
BUG REPORT FOR HCS_C XPRESS
a: version of host (you can see it on the startup banner. Currently I am releasing version 0.03)
b: version of the HCS_C Xpress compiler (Currently I am releasing version 0.03)
c: version of the HCS_C firmware in flash memory (Currently I am releasing version 0.03)
d: Your name, email address, date of bug found, and what computer and OS you are using (some problems are host speed related)
e: The events.hcs file causing the failure
e: Description of bug, including any error messages, description of where the failure occurs in the events.hcs file, and other symptoms
f: Frequency of the bug--every time the program is run, occasional, once in a long while
g: Severity of the bug--have you figured out a workaround and what is it
h: It would be especially nice if you included an actions log dump file. Put a LOG MODE ACTIONS in your if-reset statement, followed by a LOG MODE OFF. Then, at the start of the if statement that has the problem, put a LOG MODE ON, then a LOG MODE OFF at the end of the if statement block (just before the last end statement of that if statement).
Thank you for helping make HCS_C the best it can be!
Note that this just shows currently working commands. At this very early stage of development, bugs aren't just likely, they are probable! But if you send me a bug report (use the sample just above this section), I'll put those on my priority list for fixing. If you feel like digging in, all of the source is available to you, so you can trying fixing, compiling, and downloading your own version.
HCS_C Xpress has four main groups of keywords. HCS_C Xpress is currently case insensitive, although I recommend keeping commands in lower case for easier readability. In addition, for some odd reason, HCS2 Xpress had equations, assignments, etc, terminated by carriage returns. Now in HCS C Xpress, carriage returns are treated as white space, all statements can be broken up by CRs to improve readability without affecting how it is compiled. Also HCS_C Xpress now permits a hexadecimal number in 0xnn format anywhere that an integer is permitted. HCS_C Xpress currently does not have precedence for operands, use parentheses to ensure correct operator ordering. I'll put this in at some point but not now.
Program Block specifiers:
begin
Program control specifiers:
(UPDATED)
config
end
define
!
`<string>`
Program control commands
if
is
then
else
end
Program operands
reset
timer(n)
variable(n)
input(n)
random(n)
change_value(<expression>)
changed(<expression>)
keybd
day
week
year
dow
hour
minute
second
inbyte(n)
hcsnet(<DEV ID> <DEV REG>)
x10
x10_error
on
off
<constant value>
0x<constant value>
Program operators. PLEASE NOTE. This version does NOT have precedence, for example, 2+3*4 will compute as 20, not 24! I'll put that in at some point, but in the meantime, use parentheses to enforce the order you want (for example, 2 + (3*4) will work as expected). I usually find it's good coding practice to be very specific about how you want your equation grouped for computation.
+ (add)
- (minus)
* (multiply)
/ (divide)
& (logical and)
| (logical or)
~ (logical not) (note, now no space is required: "x + ~4" is now legal syntax
and (functional and)
or (functional or)
not (functional not)
bit (nth bit of operand, syntax <op> bit <bitnumber>)
signum
>
<
=
=>
<=
<>
&&
||
Program actions
(UPDATED)
timer(n) =
wait <expression>
wait_seconds <expression>
wait_minutes <expression>
variable(n) =
output(n) =
x10(n) =
insteon(xxxxxx) = <number>
hcs_fpga(n) = (used to be outbyte, hcs_byte)
hcsnet = <string>
video = <string>
hcs_string(n) = <string>
console = <string>
voice(n) = <mode>
log(n,<expression>) =
log mode <mode>
alert(n)
Program string register select code
0 low 16 bits of HCS_C main board IO input
1 high 16 bits of HCS_C main board IO input
2 low 16 bits of HCS_C main board IO output setting (internal shadow copy)
3 high 16 bits of HCS_C main board IO output setting (internal shadow copy)
4 16 bits of HCS_C Combo board IO state
256-511 select one of 256 HCS_C variables
COMPILER HCS_C XPRESS LIMITS
16384 maximum size of token file
256 maximum number of timers
256 maximum number of variables
1024 maximum number of IF statements
32 maximum number of HCSNET devices
256 maximum number of changed_value checks
256 maximum number of WAIT statements
DETAILED DESCRIPTION OF HCS_C XPRESS COMMANDS
(UPDATED)
HCS_C_XPRESS SPECIAL STRING CHARACTERS
(UPDATED) The overall program structure is a configuration and define section followed by the program block itself, which consists of a sequence of if-then statements. You must always use an if statement to initiate an action, although you can use an IF 1 THEN to do a continous action sequence. Because of the multitasking nature of how HCS_C works, do not be afraid to use as many of these as you wish, there is no significant performance degradation when using continous assigns.
CONFIG
<peripheral list>
(example)
HCSNET CMB1
HCSNET TERM1
END
(UPDATED) Use this to tell HCS_C you have a peripheral, such as the HCS_Combo card, attached. The CONFIG must be eventually followed by an END command. NOTE: anything listed here will have its local receive array (that is, the HCS_C copy of all remote module readable registers) automatically be dumped to the console every second-- but these values only reflect the state that was dumped by the remote module. It is the events.hcs file writer's responsibility to issue a status read out to the remote card at the desired interval in order that the HCS_C copy will correctly reflect the state of the remote card readable registers. This is typically done like this:
if reset then
console = "Starting automated read of CMB1 status readback registers..."
timer(3) = on
end
! Issue readback of the CMB1 remote card every 4 seconds
if change_value(timer(3)) = 4 then
hcsnet = "CMB1 E"
end
You could also do it simpler with the following: This example will be higher performance (less wasted processing time) than the prior example, because no time is wasted computing the change_value expression. (aren't localized waits supremely cool??!! )
if 1 then
hcsnet = "CMB1 E"
wait 4
end
(UPDATED)
`<label>`
This is called a tick define instantiation, and can be used in any quoted string. It will replace the <label> with the equivalent specified with a define statement (see below, next). If you just want to insert a tick, use a double tick ("``"). Obviously, ticks may not be used in a defined label if it will be used in a quoted string, although the definition value can include a tick.
!
This is the comment specifier. Anything in a line after this is ignored by HCS_C.
(UPDATED)
DEFINE <string to be replaced> =<string to replace>
Use this to create names for variables or timers. It is a substitution command that creates a text string bounded by spaces that substitutes for another text string bounded by spaces. This can also be used for tick defines within a string. Note that everything immediately after the '=' is included in the string. If spaces are placed in the string, they will all be part of the defined string. Note that the defines that are used in a string are exact, but that if a define is used to substitute for a keyword (that is, is not part of a quoted string), a space is added afterwards to prevent unintended keyword concatenation. This space will have no effect in HCS_Xpress compilation except to prevent forming a new keyword from being formed from two immediately adjacent keywords. It is permissable to have embedded spaces in a define, the entire string up to a <CR> is used as the definition.
SAMPLE:
DEFINE DOOR_SENSOR = 13
DEFINE SENSOR_REGISTER = 2
DEFINE DOOR_SENSOR_VAR = variable(22)
DOOR_SENSOR_VAR = input(DOOR_SENSOR)
CONSOLE = "Door sensor var ^VD4N22^ is set to ^IB`DOOR_SENSOR`:`SENSOR_REGISTER`^" !will look at bit 13 of register 2
BEGIN
The actual control portion of the program starts here. Configuration and defines must precede this.
SEQUENTIAL
This is gone! HCS_C does not use a "sequential" section like HCS_II.
IF
Every HCS_C command starts with an if command, and may have an IF-THEN-ELSE-END format or an IF-IS-THEN-IS-THEN (...) ELSE-END format. In both cases, the ELSE is optional, and the number of IS clauses is also selectable. The format for the IF-THEN-ELSE_END format looks like this (capitalized word may also be lower case):
IF compare_expression THEN
action_statement
action_statement
...
ELSE
action_statement
action_statement
...
END
The format of the IF-IS-THEN-ELSE-END format looks like this (any number of IS clauses are allowed)
IF compare_expression
IS compare_value THEN
action_statement
action_statement
...
IS compare_value THEN
action_statement
action_statement
...
ELSE
action_statement
action_statement
...
END
This command evaluates the compare_expression, and if that is true, the following action expressions are executed. If it is false, it executes the action_statements following the else clause, if there is one. HCS2 had both an ifa and an if statement, the former always performed the compare check, whereas the if statement only executed the action_statements if the compare_expression changed in value (allowing the if action_statements to only execute once if the if-statement compare became true). HCS_C Xpress does not use the IFA/IF functionality since I find this extremely difficult to follow if nested if-statements are used. Instead, HCS_C Xpress will introduce new keywords that are both more powerful and yet easier to understand. It will have the CHANGED or CHANGE_VALUE keyword, which will go true if the operand has changed its value. However, version 0.01 does not yet have this functionality. Version 0.02, coming out very soon now, has this implemented, it is undergoing testing at this time.
Note that unlike HCS2 Xpress, the IF statement compare expression now uses exactly the same interpreter as the action statement assignment, rather than the single term compares. This means that any math expression with functional compares is now allowed (for example, "IF timer(0) + variable(30) = (22 - variable(1)) THEN <actions>" is now a legal IF statement).
THEN
This must follow the if statement compare expression section (if the IF statement is a standard IF THEN ELSE statement. Note that case statements with multiple comparisons are now allowed in HCS_C Xpress by using the IS keyword) and defines the actions to be taken if the compare expression is true.
IS
This keyword follows the IF compare expression, and permits multiple compares against the IF compare expression. Note that the FIRST IS clause to match causes execution, and all others are skipped. Unlike other case formats, such as used in the C language, there is no fall through. The IS action clause is executed, and then execution passes to after the end of the entire IF statement.
ELSE
This optional keyword must follow the if statement action statement section and defines the following section actions to be taken if all compare expressions are false.
END
This must be used at the end of every if statement or if-else statement
DEFINE
This can be used to specify a name for a particular numeric value. This is commonly used to specify user defined (and hence easier to remember) names for variables and input or output bits.
coming very soon: a subroutine call capability
All keywords may be lowercase if desired
RESET
This is used in a compare expression and is true if the HCS_C has just started to execute the events.bin program. Once the HCS_C has run through one sequence of programmed statements, this value becomes false. This can be used to cause one-time startup initialization of variables, timers, and peripherals.
TIMER(n)
This operand is a simple way to control how long to wait before performing an action. In HCS_C there are 256 general purpose 16 bit timers, any one of which can count seconds (the default) or minutes. Since they are 16 bit timers, note that when a timer is turned on, it will start at value zero and increment up to 65535. At that point the counter will start over at zero. Use the TIMER(n) = <mode> command described below in the ACTIONS section to control the timer.
VARIABLE(n)
This operand is the "n"th holding location in memory that can contain any desired 16 bit (0-65535) value. In HCS_C there are 256 general purpose 16 bit variables. They will hold the last value written until overwritten with a new value.
VARIABLE(n,m)
This operand obtains the "m"th bit in the "n"th holding location in memory that can contain any desired 16 bit (0-65535) value. In HCS_C there are 256 general purpose 16 bit variables. They will hold the last value written until overwritten with a new value.
INPUT(n)
This operand monitors the current value of the HCS_C input pins. There are 32 input pins in two banks. Setting n to 0-31 reads the corresponding bit of the HCS_C input circuitry. Note that the value returned is just the zero or one value at the input. Bits 32 and higher are not yet defined but are coming soon. No EDGE capability is provided--use the CHANGED(input(n)) command to accomplish that function. Coming soon is the inputword(n) function which will read 16 bits at a time.
(UPDATED)
HCSNET(<DEV ID> <DEV REG>)
This operand is the value of the holding register for the soecified HCSNet device. Note that HCS_C is a streaming environment, not polled, so getting data from a serial device is a two step process--HCS_C will not sit and wait for results from an HCSNet command. You must write your events.hcs file to send an update command to the HCSNet device to fill this holding register, wait for HCS_C to eventually get the results into this holding register, then read using this operand. For example, periodically sending a HCSNET = "CMB1 E" command will (eventually) load this holding register. Then the command HCSNET(CMB1 I) will return, for example, the contents of the I register (the IO bits on the HCS_C Combo card. To make this process easier, there will be an HCSNET(<DEVID> U) operand that will indicate when the holding register has been updated, stay tuned for that this coming weekend.
RANDOM(n)
This operand references the FPGA pseudo-random number generator. n specifies the range of the generator, which can be set from 1 to 255. The 8 bit value of this operand goes from 0 to n.
CHANGE_VALUE(<expression>)
This operand computes the expression and compares the value with the previously computed value. If they don't match (the value changed), this returns the new value. If not, it returns false (0). Currently a maximum of 256 variables that hold the change compare value are stored, and these are initialized to 0xffff (implying that no more than 256 CHANGED calls are allowed per events file, and a startup value of 0xffff will not trigger this change_value). Unlike HCS2, these saved locations are not stored within the HCS events token array, so storing your events file in Flash ROM or other non-volatile locations will now work. Since a change to 0 is possible for the expression, this only should be used to check for non-zero changed values. To check for the zero value as a changed value, use an equation similar to: IF CHANGED (timer(0)) * timer(0) = 0 THEN <actions>.
CHANGED(<expression>)
This operand computes the expression and compares the value with the previously computed value. If they match, this returns true (1). If not, it returns false (0). Currently a maximum of 256 variables that hold the change compare value are stored, and these are initialized to 0xffff (implying that no more than 256 CHANGED calls are allowed per events file, and a startup value of 0xffff will not trigger this change_value). Unlike HCS2, these saved locations are not stored within the HCS events token array, so storing your events file in Flash ROM or other non-volatile locations will now work.
KEYBD
This operand retrieves the ASCII value of the keyboard (the last key pressed). There is a buffer of 256 keys--if there are no keypresses to read, the value will be zero.
DAY
This operand returns the current day of the month from 1 to 31 out of the HCS_C realtime clock.
MONTH
This operand returns the current month from 1 to 12 out of the HCS_C realtime clock.
YEAR
This operand returns the current year from 0 to 255 (offset from the year 2000) out of the HCS_C realtime clock.
DOW
This operand returns the current day of the week from 1 (Sunday) to 7 (Saturday) out of the HCS_C realtime clock.
HOUR
This operand returns the current hour from 0 to 23 out of the HCS_C realtime clock.
MINUTE
This operand returns the current minute from 0 to 59 out of the HCS_C realtime clock.
SECOND
This operand returns the current second from 0 to 59 out of the HCS_C realtime clock.
HCS_FPGA(n)
HCS_FPGA(<HCS_REG_NAME>)
This operand returns a value from a register in the HCS_C FPGA specified by the number n or the HCS FPGA register name, the compiler will accept either.
FPGA registers: It's possible to read any of the FPGA registers (see the FPGA source code command_dec.v), but the registers not listed here are not really useful for events.hcs programming.
1: FPGA_VOICE
2: FPGA_SPI
3: FPGA_RS232_0 (or FPGA_INSTEON)
5: FPGA_RS485_0 (or FPGA_HCSNET)
6: FPGA_RS485_1 (or FPGA_FASTNET)
7: FPGA_RS485_2
8: FPGA_KEYBD
10, 11: FPGA_X10A, FPGA_X10B
This operand returns the selected FPGA register 16-bit register value. See the HCS_C user manual for a list of register functions.
ON
This operand enables and turns on one of the timers or an X10 module.
OFF
This operand disnables and clears one of the timers or an X10 module.
<constant value>
This operand returns a specified decimal value.
0x<constant value>
This operand returns a specified hexadecimal value.
X10
This operand reads the X10 input register. This is buffered four levels, but must be read sufficiently quickly or read values will be lost. This value is encoded from the FPGA_X10 registers 10 and 11. If this value is read and the X10 redundant bits don't match correctly, that is, a corrupt X10 value was read, this read also sets the X10_ERROR value to 1, otherwise it becomes set to 0.
+ (add)
- (minus)
* (multiply)
/ (divide)
& (logical and)
| (logical or)
^ (exclusive or) (new) (UPDATED)
~ (logical not) (the space bug fixed, now x = ~4 is legal syntax)
and (functional and--if both operands are not 0, the result is 1)
or (functional or--if either operand is 1, the result is 1)
not (functional not--if the operand is 0, the result is 1, else it is 0)
bit(n)
signum
>
<
=
=>
<=
<>
&& (compare and--if both operands are true, the compare is true)
|| (compare or--if either operand is true, the compare is true)
Program actions
TIMER(n) = OFF | ON | CLEAR | PAUSE | CONTINUE | MINUTES | SECONDS
This operand is a simple way to control how long to wait before performing an action. In HCS_C there are 256 general purpose 16 bit timers, any one of which can count seconds (the default) or minutes. Since they are 16 bit timers, note that when a timer is turned on, it will start at value zero and increment up to 65535. At that point the counter will start over at zero. Normally, an IF statement will start the timer, and when it reaches a certain value, it will restart or turn off the timer. The OFF command will turn off a timer and reset its value to zero. The ON command will turn on a timer and start it counting from zero once every second (the default) or once every minute if this timer has been set to run in MINUTES mode. The PAUSE command will stop the timer, but will leave the timer value unchanged. The CONTINUE command will cause the timer to begin counting seconds (or minutes) from the current timer value.
Note that seconds or minutes are counted using the Real Time Clock, so the first second (or minute, in minutes mode) of waiting may be any fraction of a second (or minute).
WAIT <expression>
This is a powerful wait capability, far better than the original HCS2 version. As expected, it causes a wait of <expression> seconds, but unlike HCS2, only the actions in the current IF module are affected. All other IF modules continue to process normally. HCS2 shuts down all operation (all independent modules in the events file) until the WAIT completes, but HCS_C is far better because the desired time delay is inserted into only that particular if module while permitting HCS_C to continue to operate all other modules while the WAIT is in progress. Multiple WAITs are permitted in each IF module. Note that seconds are counted using the Real Time Clock, so the first second of waiting may be any fraction of a second. Up to 65535 seconds can be specified.
WAIT_SECONDS <expression>
Same as WAIT above.
WAIT_MINUTES <expression>
Same as WAIT above, except the wait is counted in minutes. NOTE: Minutes is counted using the Real Time Clock, so the first minute of waiting may be any fraction of a minute. For waits that are more precise, use the WAIT_SECONDS function. Up to 65535 minutes can be specified.
VARIABLE(n) =
This action sets one of the 256 general purpose 16-bit variables in HCS_C. These are used as temporary variables (holding registers). A define statement can be used to make the specified variable number easier to remember.
VARIABLE(n,m) =
This action sets the "m"th bit one of the 256 general purpose 16-bit variables in HCS_C. These are used as temporary variables (holding registers). A define statement can be used to make the specified variable number and bit number easier to remember.
OUTPUT(n) =
This action sets one of the output bits in HCS_C. There are currently 32 bits available to set. Setting n to 0-31 specifies the corresponding HCS_C output bit while leaving the other output bits unchanged. In the near future, many more output bits will be defined in HCS_C Xpress. Note that the input and output definition is completely different than HCS2. Coming soon is an setword(n) and clrword(n) function which will set or clear up to 16 bits at once, where n will specify the bank of bits to set.
MODULE(n) =
This action sets one of the 256 X10 devices in HCS_C. Valid options are currently only on and off.
OUTBYTE(n) =
This action sets one of the 256 FPGA 16-bit registers in HCS_C. See the HCS_C users manual for a list of register functions.
HCS_FPGA(n) = <value>
HCS_FPGA(<HCS_REG_NAME>) = <value>
This action sends an expression value to a register in the HCS_C FPGA specified by n or the HCS FPGA register name, the compiler will accept either.
FPGA registers:
0: FPGA_MODE
bits 2-0: Voice select; 0=playback only, 4= playback or record
bits 4-3: SPI device select (Vulcan connector)
bits 7:5: RTC mode select: leave this 0 for normal HCS_C operation
bit 8: X10 TX select: 0=60Hz (USA) 1=50Hz (non-USA)
all other bits must be set to 0
1: FPGA_VOICE
2: FPGA_SPI
3: FPGA_RS232_0 (or FPGA_INSTEON)
5: FPGA_RS485_0 (or FPGA_HCSNET)
6: FPGA_RS485_1 (or FPGA_FASTNET)
7: FPGA_RS485_2
8: FPGA_LCD
10: FPGA_X10A
11: FPGA_X10B
12: FPGA_RELAY bit 0: enables intercom Voice out; bit 1: enables door intercom voice out
(UPDATED)
HCSNET = <string>
This action sends an output string to an HCSNET (HCS2 RS485 legacy network module) register. There are no longer any parameters to this action, the string is simply sent out, and must include the device ID. The new string escape sequence no longer allows indirect variable specification. Tick defines are permitted within the string.
sample: HCSNET = "CMB1 E"
(UPDATED)
VIDEO = <string>
This action sends an output string to the Video module on the HCS_C main board FPGA.
Video compatible commands (VIDEO, CONSOLE)accept strings with cursor control escape sequences as follows. Commands can be concatenated with a comma.
This command correctly interprets string special characters and adds a few new ones:
^Mn^ specifies a color and flashing attributes to all characters that follow.
^n1^ clears the screen. (Note that 1.09 no longer requires a leading zero)
^n2^ clears the line from the current position.
^n3,<X VALUE>^ moves the cursor to the X position specified.
^n4,<Y VALUE>^ moves the cursor to the Y position specified.
^n5,<X VALUE>,<Y VALUE>^ moves the cursor to the X and Y position specified. (not supported by Combo or Mini yet)
^n6^ clears the line from the current position. (not supported by Combo or Mini yet)
^n10^ acts like a CR character (you can't send an actual CR because that terminates the string) (not supported by Combo or Mini yet)
^n16^ moves the cursor right one position. (NOTE: Combo and Mini still use 10,11,12,13, but 13 cannot be supported (is same as CR))
^n17^ moves the cursor left one position.
^n18^ moves the cursor down one position.
^n19^ moves the cursor up one position.
(UPDATED)
CONSOLE = <string>
This action sends an output string to the PC console and should appear in the host.exe console window. This capability is very handy for debugging events in HCS_C Xpress operation. This command supports all string special character modes listed in the "Program String Special Characters" section. Strings no longer support the comma, variable syntax, this is now imbedded in the escape sequence. Tick defines are supported in the string. Cursor control codes are supported by the console, as shown above.
NOTE: Console strings NO LONGER display a starting '!' character--you now have exact control of what appears on the console
WARNING!!! The compiler allows anything to be output as a string--but bad escape sequences in your events file often will HANG the HCS! You must get the syntax exactly right, no white space, no unexpected characters. Future versions will include compiler string checks as warnings and the escape sequence FW will be made more robust.
sample: console = "The variable(3) is set to ^VD5Z3^"
console = "The door sensor is ^IB`door_sensor`:`sensor_inputs`^
console = "^n1,5,5,4^The Console is now cleared" (clears the console, then places string about in the middle)
VOICE(n) = OFF | ON | RECORD
This initiates voice playback or recording at the recorder address n. When recording, be sure to send a VOICE(n) = OFF command when you are done otherwise the entire voice chip will be overwritten.
LOG(n) = <expression>) or LOG MODE NORMAL | OFF | ON | SHORT | ACTIONS
This function permits tracking of information to a log memory, which can be dumped at any time via the host program. The LOG(n,<expression>) action computes the expression and stores it to the log memory in the format specified by the LOG MODE command. On reset, the log mode is NORMAL and stores data in the old HCS2 format--a byte n that is a user selectable tag byte, then a byte of computed information, then the date and time. In short mode, the date and time are not present. The ACTIONS mode is intended for debugging your HCS_C program. It stores each IF token encountered, along with the offset into the token_array. It also stores every ACTION token encountered along with its offset. Use the OFF and ON functions to pause or restart logging, this can help reduce the amount of log data to sort through. Note that there are about 100000 bytes of log data available, it can be dumped with a host log dump command or by examining the SRAM at address 0x600000. A very handy debugging function is to turn off logging on reset, then do a LOG MODE ON at the start of the if-statement that has a problem. At the end of the if-statement, put a LOG MODE OFF just before the if-statement END. This will capture only the tokens within the if-statement.
X10(n) = OFF | ON | ALLON | ALLOFF | DIM | BRIGHT
This sends an X10 command to unit n. Specify the unit number with <A-P> and number <1-16>. For example, X(B10) = ON
INSTEON(xxxxxx) = <0-255> or <0-0xFF>
This sends an Insteon ON command to unit xxxxxx. Specify the unit number with the Insteon three byte code that is stamped on your Insteon module, this is specified as a hexadecimal number, just like the number on the Insteon device. Setting the value determines whether you turn the device on or off or some dimming value. 0 is off, 0xFF is on, and everything in between controls the amount of dimming provided. Currently no Insteon readback is available yet.
(UPDATED)
ALERT(n) = OFF | ON | "<ALERT STRING>"
This sets or clears one of 16 alerts. Alerts automatically show up on the console and can be viewed on a webpage. The alert string can be set (overwriting any previous alert string) and will then be output on the console.
PROGRAM STRING SPECIAL CHARACTERS
(UPDATED)