Function block instance, Calling a function block, L-force | plc designer – Lenze PLC Designer PLC Designer (R3-1) User Manual

Page 75

Advertising
background image

L-force | PLC Designer

Concepts and Base Components

DMS 4.1 EN 03/2011 TD29

73

Function Block Instance
Function blocks are always called through an instance which is a reproduction (copy) of
a function block.
Each instance has its own identifier (instance name), and a data structure containing
its inputs, outputs, and internal variables.
Instances like variables are declared locally or globally, whereby the name of the
function block is indicated as the data type of an identifier.
Syntax for declaring a function block instance:
<identifier>:<function block name>;
Example
Declaration (e.g. in the declaration part of a program) of instance INSTANCE of
function block FUB:

INSTANCE: FUB;

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

Calling a function block
Function blocks are always called through a function block instance. Thus a function
block instance must be declared locally or globally.
Then the desired function block variable can be accessed using the following syntax:
Syntax:
<instance name>.<variable name>
Regard the following:
• Only the input and output variables of a function block can be accessed from

outside of an function block instance, not its internal variables.

• Access to a function block instance is limited to the POU in which it was declared

unless it was declared globally.

• At calling the instance the desired values can be assigned to the function block

parameters. See below.

• Please regard, that the InOutVariables (VAR_IN_OUT) of a function block are

passed as pointers.

• In SFC function block calls can only take place in steps.
• The instance name of a function block instance can be used as an input parameter

for a function or another function block.

• All values of a function block are retained until the next processing of the function

block. Therefore function block calls do not always return the same output values,
even if done with identic arguments!

Note: If there at least one of the function block variables is a

remanent

variable, the

total instance is stored in the retain data area.

Advertising