99BProgramming concepts
6.5 Programming language
S7-1200 Programmable controller
System Manual, 11/2011, A5E02486680-05
147
In the section of the SCL code block you can declare the following types of parameters:
●
Input, Output, InOut, and Ret_Val: These parameters define the input tags, output tags,
and return value for the code block. The tag name that you enter here is used locally
during the execution of the code block. You typically would not use the global tag name in
the tag table.
●
Static (FBs only; the illustration above is for an FC): Static tags are used for storage of
static intermediate results in the instance data block. Static data is retained until
overwritten, which may be after several cycles. The names of the blocks, which are called
in this code block as multi-instance, are also stored in the static local data.
●
Temp: These parameters are the temporary tags that are used during the execution of
the code block.
If you call the SCL code block from another code block, the parameters of the SCL code
block appear as inputs or outputs.
In this example, the tags for "Start" and "On" (from the project tag table) correspond to
"StartStopSwitch" and "RunYesNo" in the declaration table of the SCL program.
Constructing an SCL expression
An SCL expression is a formula for calculating a value. The expression consists of operands
and operators (such as *, /, + or -). The operands can be tags, constants, or expressions.
The evaluation of the expression occurs in a certain order, which is defined by the following
factors:
●
Every operator has a pre-defined priority, with the highest-priority operation performed
first.
●
For operators with equal priority, the operators are processed in a left-to-right sequence.
●
You use parentheses to designate a series of operators to be evaluated together.
The result of an expression can be used either for assigning a value to a tag used by your
program, as a condition to be used by a control statement, or as parameters for another SCL
instruction or for calling a code block.
Table 6- 2
Operators in SCL
Type
Operation
Operator
Priority
Parentheses
(
Expression
)
( , )
1
Power
**
2
Sign (unary plus)
+
3
Sign (unary minus)
-
3
Multiplication
*
4
Math
Division
/ or DIV
4