24• WAGO-I/O-PRO 32 V2.2 Overview
Languages
ST |
ERG *BOOL2 in ERG*) |
It is also possible in IL to put parentheses after an operation. The value of the parenthesis is then considered as an operand.
For example:
LD 2
MUL 2
ADD 3
ST ERG
Here is the value of Erg 7. However, if one puts parentheses:
LD 2
MUL (2
ADD 3
)
ST ERG
Here the resulting value for Erg is 10, the operation MUL is only then evaluated if you come to ")"; as operand for MUL 5 is then calculated.
The Structured Text consists of a series of instructions which, as determined in high level languages, ("IF..THEN..ELSE") or in loops (WHILE..DO) can be executed.
Example:
IF value < 7 THEN
WHILE value < 8 DO
value:=value+1;
END_WHILE;
END_IF;
An expression is a construction which returns a value after its evaluation.
Expressions are composed of operators and operands. An operand can be a constant, a variable, a function call, or another expression.
WAGO-I/O-SYSTEM 759 WAGO-I/O-PRO 32
WAGO-I/O-PRO 32 V2.2 Overview |
• 25 |
Languages |
|
|
|
The evaluation of expression takes place by means of processing the operators according to certain binding rules. The operator with the strongest binding is processed first, then the operator with the next strongest binding, etc., until all operators have been processed.
Operators with equal binding strength are processed from left to right.
Below you find a table of the ST operators in the order of their binding strength:
Operation |
Symbol |
Binding strength |
Put in parentheses |
(expression) |
Strongest binding |
|
|
|
Function call |
Function name |
|
|
(parameter list) |
|
|
|
|
Exponentiation |
EXPT |
|
|
|
|
Negate |
- |
|
Building of complements |
NOT |
|
|
|
|
|
|
|
Multiply |
* |
|
Divide |
/ |
|
Modulo |
MOD |
|
|
|
|
Add |
+ |
|
Subtract |
- |
|
|
|
|
|
|
|
Compare |
<,>,<=,>= |
|
|
|
|
Equal to |
= |
|
Not equal to |
<> |
|
|
|
|
Boolean AND |
AND |
|
|
|
|
Boolean XOR |
XOR |
|
|
|
|
Boolean OR |
OR |
Weakest binding |
|
|
|
There are the following instructions in ST, arranged in a table together with example:
|
Instruction type |
Example |
|
|
Assignment |
A:=B; CV := CV + 1; C:=SIN(X); |
|
|
|
|
|
|
|
|
|
WAGO-I/O-SYSTEM 759 WAGO-I/O-PRO 32
26 • WAGO-I/O-PRO 32 V2.2 Overview
Languages
Instruction type |
Example |
Calling a function block and |
CMD_TMR(IN := %IX5, PT := 300); |
use of the FB output |
A:=CMD_TMR.Q |
|
|
|
|
RETURN |
RETURN; |
|
|
IF |
D:=B*B; |
|
IF D<0.0 THEN |
|
C:=A; |
|
ELSIF D=0.0 THEN |
|
C:=B; |
|
ELSE |
|
C:=D; |
|
END_IF; |
|
|
CASE |
CASE INT1 OF |
|
1:BOOL1 := TRUE; |
|
2:BOOL2 := TRUE; |
|
ELSE |
|
BOOL1 := FALSE; |
|
BOOL2 := FALSE; |
|
END_CASE; |
|
|
FOR |
J:=101; |
|
FOR I:=1 TO 100 BY 2 DO |
|
IF ARR[I] = 70 THEN |
|
J:=I; |
|
EXIT; |
|
END_IF; |
|
END_FOR; |
|
|
WAGO-I/O-SYSTEM 759 WAGO-I/O-PRO 32
|
|
WAGO-I/O-PRO 32 V2.2 Overview • 27 |
|
|
|
Languages |
|
|
|
|
|
|
|
|
|
|
Instruction type |
Example |
|
|
WHILE |
J:=1; |
|
|
|
WHILE J<= 100 AND ARR[J] <> 70 |
|
|
|
DO |
|
|
|
J:=J+2; |
|
|
|
END_WHILE; |
|
|
|
|
|
|
REPEAT |
J:=-1; |
|
|
|
REPEAT |
|
|
|
J:=J+2; |
|
|
|
UNTIL J= 101 OR ARR[J] = 70 |
|
|
|
END_REPEAT; |
|
|
|
|
|
|
EXIT |
EXIT; |
|
|
|
|
|
|
Empty instruction |
; |
|
|
|
|
|
On the left side of an assignment there is an operand (variable, address) to which is assigned the value of the expression on the right side with the assignment operator :=
Example:
Var1 := Var2 * 10;
After completion of this line Var1 has the tenfold value of Var2.
A function block is called in ST by writing the name of the instance of the function block and then assigning the values of the parameters in parentheses. In the following example a timer is called with assignments for the parameters IN and PT. Then the result variable Q is assigned to the variable A.
The result variable, as in IL, is addressed with the name of the function block, a following point, and the name of the variable:
CMD_TMR(IN := %IX5, PT := 300);
A:=CMD_TMR.Q
WAGO-I/O-SYSTEM 759 WAGO-I/O-PRO 32
28• WAGO-I/O-PRO 32 V2.2 Overview
Languages
The RETURN instruction can be used to leave a POU, for example depending on a condition
With the IF instruction you can check a condition and, depending upon this condition, execute instructions.
Syntax:
IF <Boolean_expression1> THEN
<IF_instructions>
{ELSIF <Boolean_expression2> THEN
<ELSIF_instructions1>
ELSIF <Boolean_expression n> THEN
<ELSIF_instructions n-1>
ELSE
<ELSE_instructions>}
END_IF;
The part in braces {} is optional.
If the <Boolean_expression1> returns TRUE, then only the <IF_Instructions> are executed and none of the other instructions.
Otherwise the Boolean expressions, beginning with <Boolean_expression2>, are evaluated one after the other until one of the expressions returns TRUE. Then only those instructions after this Boolean expression and before the next ELSE or ELSIF are evaluated.
If none of the Boolean expressions produce TRUE, then only the <ELSE_instructions> are evaluated.
Example:
IF temp<17
THEN heating_on := TRUE;
ELSE heating_on := FALSE;
WAGO-I/O-SYSTEM 759 WAGO-I/O-PRO 32