L-force | plc designer – Lenze PLC Designer PLC Designer (R3-1) User Manual

Page 76

Advertising
background image

L-force | PLC Designer

Concepts and Base Components

74

DMS 4.1 EN 03/2011 TD29

Examples for accessing function block variables
Assume: Function block fb has an input variable in1 of the type INT. See here the call of
this variable from within program prog. See declaration and implementation in ST:

PROGRAM prog
VAR
inst1:fb;
res:INT;
END_VAR

inst1.in1:=22; (* fb is called and input variable in1 gets assigned value 22 *)
inst1(); (* fb is called, this is needed for the following access on the output
variable *)
res:=fbinst.outl; (* output variable of fb is read *)

Example in FBD:

Assigning parameters at call:
In the text languages IL and ST you can set input and/or output parameters
immediately when calling the function block. The values can be assigned to the
parameters in parentheses after the instance name of the function block. 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.
Example, call with assignments:
In this example a timer function block (instance CMD_TMR) is called with assignments
for the parameters IN and PT. Then the result variable Q is assigned to the variable A.
The result variable is addressed with the name of the function block instance, a
following point, and the name of the variable:

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

Advertising