5 calling a function block in st, 6 return instruction, 7 if instruction – Lenze DDS v2.3 User Manual

Page 44: Calling a function block in st, Return instruction, If instruction, Drive plc developer studio

Advertising
background image

Drive PLC Developer Studio

Programming languages

4-6

l

DDS EN 2.3

4.3.5

Calling a function block in ST

A function block in ST is called by using the name of the function block instance followed by
parentheses in which the parameters are assigned the required values.

Example

A timer is called with assignments for parameters IN and PT:

CMD_TMR(IN := %IX1.0.1, PT := T#300);

The result variable Q is then assigned to variable A:

A:=CMD_TMR.Q

As in IL, the result variable is addressed using the function block name followed by a period
and the variable name.

4.3.6

RETURN instruction

The RETURN instruction is used to complete the processing of the organization unit and to return to
the calling organization unit, depending on a condition, for instance.

4.3.7

IF instruction

Use the IF instruction to check a condition. Instructions can be executed depending on this
condition.

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 curly brackets {} is optional.

If <Boolean_expression1> returns TRUE, only <IF_instructions> will be
executed.

Otherwise the Boolean expressions starting with <Boolean_expression2> will be evaluated
one after the other until one of the expressions returns TRUE. Then only the instructions after
this Boolean expression and before the next ELSE or ELSIF will be evaluated.

If none of the Boolean expressions is TRUE, only the <ELSE_instructions> will be
evaluated.

Show/Hide Bookmarks

Advertising