Drive plc developer studio, Introduction, 2 calling a function block – Lenze DDS v2.3 User Manual

Page 17

Advertising
background image

Drive PLC Developer Studio

Introduction

2-5

l

DDS EN 2.3

Example of access to an input variable:

(* The function block fb has an input variable in1 of type int. *)
PROGRAM prog
VAR

inst1:fb;

END_VAR

LD 17
ST inst1.in1
CAL inst1

END_PROGRAM

The declaration parts of function blocks and programs may contain instance declarations.
Instance declarations are not allowed in functions. A function cannot call a function block.

Access to the instance of a function block is restricted to the organization unit in which it was
instanced, unless it was globally declared. Function blocks should never be globally declared
as this would lead to logical errors.

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

L_IOParCounterModule

byAnalogModuleNr
byFunction_CH1

bExecute

byNodeAdr

nState

byFunction_CH2

CTRL

EPM-T110

Ixxxh

Counter

PROGRAM Counter
VAR

Counter: DINT;

END_VAR

Counter is the instance name of function block

L_IOParCounterModule and can be

used as input in the code.

Note!

All values remain the same from one execution of the function block to the next. Therefore function
block calls with the same arguments do not necessarily return the same output values!

Should the function block include at least one Retain variable, the whole instance is stored in the
Retain area.

2.2.4.2

Calling a function block

The input and output variables of a function block can be approached by another organization unit.
For this purpose, a function block instance must be generated and the desired variable specified
with the help of the following syntax:

<Instance name>.<Variable name>

Input writes only

Input and output reads

To set the input parameters on call in the IL and ST text languages, assign values to the
parameters in brackets after the function block instance name (assignment via := as for the
initialization of variables at the point of declaration).

Tip!

SFC allows function block calls in steps only.

Show/Hide Bookmarks

Advertising