Zum Inhalt springen

Function blocks

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

Function blocks are created in logiccloud via the project tree. Within the node POUs you can create a new function block. To do this, right-click or go to the icon with the three dots and select Add POU, assign a name, select as type Function block and as Language Structured Text (ST). The structure is created automatically.

Function block structure
FUNCTION_BLOCK (* optional_begin *) FINAL|ABSTRACT (* optional_end *) Name
(* optional_begin *) USING Namespace_1;
USING Namespace_2; (* optional_end *)
(* optional_begin *) EXTENDS FB_name_1 (* optional_end *)
(* optional_begin *) IMPLEMENTS interface_1, interface_2, ... interface_n (* optional_end *)
(* optional: declaration of variables/instances *)
(* optional: declaration of methods *)
(* optional: body of function block *)
END_FUNCTION_BLOCK
Function block FunctionBlock_1
FUNCTION_BLOCK FunctionBlock_1
VAR_INPUT
INPUT_1: REAL;
INPUT_2: REAL;
END_VAR
VAR_OUTPUT
OUTPUT: REAL;
END_VAR
OUTPUT := INPUT_1 + INPUT_2;
END_FUNCTION_BLOCK
Program PRG calling FunctionBlock_1
PROGRAM PRG
VAR_INPUT
In1: REAL;
In2: REAL;
END_VAR
VAR_OUTPUT
Out: REAL;
END_VAR
VAR
FB: FunctionBlock_1; // Instance of the function block
END_VAR
FB(
INPUT_1 := In1,
INPUT_2 := In2,
OUTPUT => Out
);
END_PROGRAM