beautypg.com

L-force | plc designer – Lenze PLC Designer PLC Designer (R2-x) User Manual

Page 37

background image

L-force | PLC Designer

What is What in PLC Designer

DMS 3.2 EN 02/2011 TD29

35

Example of a function Fct in IL, in which three input variables are declared:

The first both input variables get multiplicated and then divided by the third one. The
function returns the result of this operation:

Declaration part:

FUNCTION Fct: INT

VAR_INPUT

PAR1:INT;

PAR2:INT;

PAR3:INT;

END_VAR

Implementation part:

LD PAR1

MUL PAR2

DIV PAR3

ST Fct

Calling a function:

In ST a function call can be used as operand in an expression.

In SFC a function call can only take place within actions of a step or a transition.

Note!

»PLC Designer« allows using global variables within a function. This intentionally
deviates from the IEC61131-3 standard, which prescribes that return value of a
function only will be modified by the input parameters. Thus the difference
between functions and programs is just, that functions return only one return value
and that their parameters and return values are handled over the stack.