Introduction to structure text (ST)


The Structured Text (ST) language defined by IEC 61131-3 is a high-level language
whose syntax is similar to Pascal. In general, ST is useful for implementing calculation intensive functions and other functions that are difficult to implement in the other languages. The ST language has a complete set of constructs to handle variable assignment, conditional statements, iteration, and function block calling.

Expressions

An expression is a construct which, when evaluated, yields a value corresponding to one of the data types.
Expressions are composed of operators and operands. An operand shall be a, a variable, a function invocation, or another expression.
The operators of the ST language are summarized in below table. 
The evaluation of an expression consists of applying the operators to the operands in a sequence defined by the operator precedence shown in below table. 
The operator with highest precedence in an expression shall be applied first, followed by the operator of next lower precedence, etc., until evaluation is complete. 
Operators of equal precedence shall be applied as written in the expression from left to right

For example, if A, B, C, and D are of type INT with values 1, 2, 3, and 4, respectively, then
A+B-C*ABS(D) shall evaluate to -9, 
and (A+B-C)*ABS(D) shall evaluate to 0 .

When an operator has two operands, the leftmost operand shall be evaluated first. For example, in the expression SIN(A)*COS(B), the expression SIN(A) shall be evaluated first, followed by COS(B), followed by evaluation of the product.

Boolean expressions may be evaluated only to the extent necessary to determine the resultant value. For instance, if A<=B, then only the expression (A>B) would be evaluated to determine that the value of the expression (A>B) & (C<D) is Boolean zero.

Functions shall be invoked as elements of expressions consisting of the function name followed by a parenthesized list of arguments.



Statements

The statements of the ST language are summarized in below table. Statements shall be terminated by semicolons


Comments

Popular posts from this blog

Control system documentation

Introduction to sequential function chart (SFC)