-

Programming ST

This chapter contains descriptions that are specific to the textual IEC 61131-3 programming language ST (Structured Text), its specific objects and the handling of variables in ST. The general and language-independent handling of the text editor and the steps how to use and set up the editor are described in the topic "Text editor".

Safety-related POUs in ST are not supported. Use the SNOLD (Safety Network Oriented Ladder) editor for programming FBD/LD instead.

ST syntax

A code worksheet programmed in the textual language ST consists of statements and expressions. An expression is a construct which returns one value for the execution of statements. Expressions consist of operators and operands. The operators have to be applied to the operands in the way that the operator with the highest precedence is followed by the operators with the next lower precedence. Operands in ST can be literals, variables or names of functions. Operands are used together with operators in expressions.

Code worksheets in ST are edited using the text editor by typing the statements and expressions or inserting them by drag and drop from the COMPONENTS area. The COMPONENTS area contains all functions and function blocks that can be used when programming the code.

When entering the statements by typing, it is recommended for a better orientation to start each statement in a new line and to use indents for statements and loops. Each statement has to end with a semicolon.

The syntax highlighting represents the different elements by colors: keywords are displayed blue, variables and instance names are black, comments are green. Comments can be inserted to improve the comprehensibility of the code.

Note
Automatic background compilation
While editing the project, the compiler is continuously running. This way, detected errors are reported without a manual compiler start. The error list in the message window is only updated after completing the compilation.