Calling a function block, L-force | plc designer – Lenze PLC Designer PLC Designer (R2-x) User Manual

Page 41

Advertising
background image

L-force | PLC Designer

What is What in PLC Designer



DMS 3.2 EN 02/2011 TD29

39

The declaration parts of function blocks and programs can contain instance
declarations. Instance declarations are not permitted in functions.

Access to a function block instance is limited to the POU in which it was declared
unless it was declared globally.

The instance name of a function block instance can be used as the input for a function
or a function block.

Note!

All values are retained after processing a function block until the next it is
processed. Therefore, function block calls with the same arguments do not always
return the same output values!

If there at least one of the function block variables is a retain variable, the total
instance is stored in the retain area.

4.1.6

Calling a function block

The input and output variables of a function block can be accessed from another POU
by setting up an instance of the function block and specifying the desired variable
using the following syntax:

<Instance name>.<Variable name>

Assigning parameters at call:

If you would like to set input and/or output parameters when you call the function
block, you can do this in the text languages IL and ST by assigning values to the

parameters after the instance name of the function block in parentheses (for input
parameters this assignment takes place using ":=" just as with the initialization of
variables at the declaration position, for output parameters "=>" is to be used).

If the instance is inserted via input assistant (<F2>) with option With arguments in the
implementation window of a ST or IL POU, it will be displayed automatically according
to this syntax with all of its parameters. But you not necessarily must assign these
parameters.

Example:

FBINST is a local variable of type of a function block, which contains the input variable
xx and the output variable yy. When FBINST is inserted in a ST program via input
assistant, the call will be displayed as follows and then can be supplemented with the
desired values: FBINST1(xx:= , yy=> );

Advertising