Software
The 'if' language construct is
described in detail in
"Controlling Program Flow:
Branching". Evaluation of
TRUE and FALSE
expressions are covered in
"Operators, Expressions,
and Statements" on page 22.
16 • SIMPL+
In this example, the digital output, d_out, and the analog output, a_out, are set to 0
on system startup in the Function Main. In the push function, the first conditional if
statement evaluates to FALSE because the digital output signal, d_out, is considered
OFF until this value is propagated to the SIMPL program. With digital outputs, this
does not happen until the SIMPL+ program performs a task switch. The analog and
string outputs, on the other hand, are propagated as soon as they are assigned new
values. Thus the second if condition evaluates to TRUE and the subsequent print
statement is executed. The third if statement can still evaluate to FALSE however,
due to the nature of serial signals in SIMPL, as previously described.
Notice the ProcessLogic function call in the last example. This function forces a task
switch from SIMPL+ to the SIMPL logic processor. This causes the digital signal to
be propagated out to the SIMPL program. The next time the logic processor passes
control back to this SIMPL+ program, it picks up where it left off. As a result, the
fourth if condition evaluates to TRUE, thus executing the print statement.
All About Variables
In addition to input and output signals, additional variables can be declared that are
only used inside the SIMPL+ program. That is, the outside SIMPL program has no
knowledge of these variables and no access to them. These variables are critical for
use as temporary storage locations for calculations.
Unless otherwise specified with a compiler directive, all variables in SIMPL+ are
"non-volatile," which means that they remember their values even after the control
system is shut off. This can be extremely useful, though it does require some
caution. In the 2-series control system, the compiler directive,
#DEFAULT_VOLATILE, can be used to change this behavior so that the variable's
values are not retained after the control system is shut off. Notably, it is generally a
good idea to explicitly initialize variables to some value before using them, except in
the cases where it becomes necessary to take advantage of their non-volatility. An
obvious place to do this is in Function Main.
SIMPL+ allows for two different types of variables: integers and strings. In addition,
variables of either type may be declared as one- or two-dimensional arrays. The
following sections explain these topics in detail.
Integers
Integers contain 16-bit "whole numbers." That is, they can range between 0 and
65,535 (unsigned, refer to paragraph after example) and cannot contain a decimal
point. SIMPL programmers may recognize that this range is identical to that of
analog signals. This is because analog signals are also treated as 16-bit values.
Integers are declared as follows:
INTEGER <int1>, <int2>,...,<intn>;
Depending on how they are used, integers can either be "unsigned" or "signed."
Unsigned integers have values between 0 and 65,535. Signed integers have values
between –32768 and +32767.
In reality, there is no difference between a signed and unsigned integer, the
difference is solely in how the control system views them. That is, for any given
value, that number can be thought of as either being a signed number or an unsigned
number. Depending upon which operations are perform on a number, the control
system decides whether to treat that number as signed or unsigned.
Crestron SIMPL+
Programming Guide – DOC. 5789A
Need help?
Do you have a question about the SIMPL+ and is the answer not in the manual?