Manual
Using the Digital Outputs and Inputs 8-5
The WN command's <which> parameter lets you specify that you only want to include
certain Digital Input(s) in the test. Be sure to be as restrictive as possible about which Inputs
you test. If certain Inputs don't matter, don't test them, because they might not be in the
states you think they are. Usually you will only be testing one Input, so <which> will have
only one bit set (i.e. it will be 1, 2, 4, 8, 16, 32, 64, or 128).
For example, you might think that the command WN 2; just waits until Digital Input 1 is
True. However, it actually checks all 8 Inputs; if Input 5 were True the wait would not
terminate even when Input 2 went True. A better command would be WN 2, 2; . This one
looks at Input 2 and disregards all the rest.
The WN command's <timeout> parameter lets you place an upper limit on how long to wait.
This is useful, for example, if the external hardware might occasionally fail to respond. To
test for whether the timeout occurred, you can follow the WN command with an XI which
tests the same condition; if the XI's <else id> executes, the condition still doesn't exist and
the timeout probably occurred. (There is a small uncertainty since the Input(s) may have
changed between the WN command and the XI command.)
If you want your system to perform some other action while waiting for an input, try the XU
or XW command; see below.
Conditional Execution
The XI ("Execute If") command is like the "if" statement of a computer language. It says
"do this if and only if a certain condition is true". With XI, the condition is some specified
set of values on the Digital Inputs. Typically you will only be testing one Input, but you can
test more than one if necessary.
XI also has a <which> parameter. As with the WN command, you should be as restrictive as
possible when deciding how many Inputs to test.
Repeating
The XU ("Execute Until") and XW ("Execute While") commands are like the "repeat...until"
and "while...do" loops of a computer language. A Download Sequence is repeated until a
condition exists, or while a condition exists, on the Digital Inputs. Use XU if you want the
Sequence always to be executed at least once; use XW if the Sequence should not be
executed at all if the condition does not already exist.
XU and XW have a <which> parameter. As with WN and XI, you should be as restrictive as
possible about which Inputs you test.
Notice that XU quits when the condition is met, but XW quits when the condition is not met.
In switching from one to the other you must invert the sense of the crucial bit in the <value>
parameter. If you are testing more than one bit you may need to use XU instead of XW, or
vice-versa. You may also have to add one or more XI ("Execute If") commands to achieve
the desired behavior.