Structured text
The structured text (English Structured Text , abbreviation: ST ; in Siemens S7 also English Structured Control Language , abbreviation SCL ) is a programming language for programmable logic controllers (PLC). The EN 61131-3 standard also defines the language scope of ST, among others. The syntax of the language elements is similar to that of the high-level language Pascal and, as with all languages of EN 61131-3, no distinction is made between upper and lower case for keywords (case insensitive).
ST offers more structuring options than STL and is therefore increasingly replacing them. Complex algorithms and mathematical functions can be programmed more clearly and quickly in ST.
Structured text language elements
allocation
": =" Is used as the assignment operator in the structured text.
Wert := Wert1 + Wert2;
The operand on the left is assigned the value of the expression on the right. The assignment operator is not to be confused with the comparison operator "=". Each statement ends with a semicolon.
IF statement
IF statements can be used to program statements that are dependent on conditions. The conditions are checked in turn. If condition 1 of the IF statement is true, the condition of the ELSIF branch is no longer checked.
IF Bedingung1 THEN
Anweisung1;
ELSIF Bedingung2 THEN
Anweisung2;
ELSE
Anweisung3;
END_IF;
CASE statement
Several conditional statements can be programmed with a CASE statement, all of which are dependent on the same conditional variable. If the condition variable does not take on any of the specified values, the ELSE branch is executed.
CASE Bedingungsvariable OF
1 : Anweisung1;
2 : Anweisung2;
3 : Anweisung3;
ELSE Anweisung4;
END_CASE;
FOR statement
Repetitive processes can be programmed with the aid of for loops. The statement is repeated in the loop until the variable i exceeds the end value. The variable is increased by one step with each loop pass.
FOR i := 0 TO 499 BY 1 DO
Zahl := Zahl +1;
D[i] := Zahl;
END_FOR;
The code example describes an array with 500 locations.
WHILE statement
With WHILE loops, processes can be programmed that have to be repeated often. The statement in the loop is repeated as long as the condition is met. If the number of loop runs is known, a FOR loop is usually used. With a WHILE loop, you should note that the condition is not permanently fulfilled. Otherwise, endless loops are created.
WHILE Bedingung DO
Anweisung;
END_WHILE;
REPEAT statement
The REPEAT statement is very similar to a WHILE statement. The difference to a WHILE loop is that the termination condition is only checked after the loop has been executed (C ++: do {} / while ()).
REPEAT
Anweisung;
UNTIL Bedingung
END_REPEAT;
In this example, the statement is executed until the condition is met. The statement is executed at least once because the termination condition is only queried after the statement has been executed.
EXIT statement
A FOR, WHILE, or REPEAT loop can be left prematurely with an EXIT statement.
pointer
Pointers contain the addresses of the memory location of variables. The address of a variable is determined by the address operator ADR. A pointer is dereferenced with the help of the content operator "^".
pAdresse := ADR(Wert1);
Wert2 := pAdresse^;
In this example the content of the variable Value1 is assigned to the variable Value2 with the help of a pointer. The assignment takes place via the dereferencing of the pointer pAdresse.
literature
- Dr. Ulrich Becker: Basics of Automation Technology, Chapter 13: Introduction to the Structured Text (ST) programming language
- Karl Schmitt: PLC programming with ST: according to IEC 6113 with CoDeSys and with information on STEP 7 in the TIA portal. Vogel Business Media 2015, ISBN 978-3-8343-3369-8
- Ulrich Kanngießer: Programming with structured text: Create control function blocks with ST or SCL quickly and easily. For beginners and those switching to AWL. VDE VERLAG 2014, ISBN 978-3-8007-3463-4
- Heinrich Lepers: PLC programming according to IEC 61131-3. 4th edition. Franzis Publishing House. Haar 2011, ISBN 978-3-645-65092-2
- 3S - Smart Software Solutions GmbH: Manual for PLC programming with CoDeSys 2.3: http://www.wago.com/wagoweb/documentation/759/ger_manu/333/m07590333_00000000_1de.pdf (accessed April 29, 2017)
- Tom Mejer Antonsen (2018), "PLC Controls with Structured Text (ST): IEC 61131-3 and best practice ST programming" ISBN 978-87-430-0241-3 , ISBN 978-87-430-0242-0 , ISBN 978-87-430-0637-4 (eBook)
Individual evidence
- ↑ a b c Dr. Ulrich Becker: Introduction to the Structured Text (ST) programming language. (PDF) Retrieved August 9, 2018 .
- ↑ a b Manual for PLC programming with CoDeSys 2.3. (PDF) Retrieved June 21, 2017 .
- ↑ Beckhoff Information System - German. Retrieved May 22, 2017 .