2 structured text (st), Programming languages – Lenze DDS v2.0 User Manual

Page 15

Advertising
background image

Introduction to IEC 61131-3 programming

Programming languages

13

l

DDS-IEC61131 EN 2.0

5.2

Structured Text (ST)

(Structured Text)

Structured Text consists of instructions which can be executed like in high languages with
conditions (IF..THEN..ELSE) or in loops (WHILE..DO).

Structured Text is an easily readable and understandable programming language that does not only
offer powerful loop programming and the possibility of conditioned commands but also imaging
mathematical functions.

Example:

IF

value < 7 THEN

WHILE

value < 8 DO
value := value + 1;

END_WHILE

;

END_IF

;

Instructions (overview)

Type of instruction

Example

Assignment by assignment operator

A:=B;
CV:=CV + 1;
C:=SIN(X);

Call of a function block,
use of an FB

CMD_TMR(IN:=%IX5, PT:=300);
A:=CMD_TMR.Q

RETURN

RETURN

;

IF

condition

D:=B*B;
IF

D<0.0 THEN

C:=A;

ELSIF

D=0.0 THEN

C:=B;

ELSE
C:=D;
END_IF

;

CASE

selection

CASE

INT1 OF

1: BOOL1:=TRUE;
2: BOOL2:=TRUE;

ELSE

BOOL1:=FALSE;
BOOL2:=FALSE;

END_CASE

;

FOR

loop

J:=101;
FOR

I:=1 TO 100 BY 2 DO

IF ARR[I]=70 THEN

J:=I;
EXIT;

END_IF;

END_FOR

;

WHILE

loop

J:=1;
WHILE

J<=100 AND ARR[J]<>70 DO

J:=J+2;

END_WHILE

;

REPEAT

loop

J:=-1;
REPEAT

J:=J+2;

UNTIL

J= 101 OR ARR[J]=70

END_REPEAT

;

EXIT

EXIT

;

Empty instruction

;

Show/Hide Bookmarks

Advertising