Init

The Init method is usually not required in a Power Monitoring application. It offers an alternative to function block initialization, which enables encapsulation of the function block. The method FB_init or the attribute 'call_after_init' must be used for this (see TwinCAT 3 PLC > Programming Reference). The Init method may only be called during the initialization phase of the PLC. It cannot be used at runtime.

The input parameters of the function block instance may not be assigned in the declaration if the initialization is to take place using the Init method.

Syntax

METHOD Init : BOOL
VAR_INPUT
    nOwnID      : UDINT;
    stInitPars  : ST_PMA_Frequency_Period_InitPars;
END_VAR

Init 1: Inputs

Name

Type

Description

nOwnID

UDINT

Identifies the function block instance with a unique ID. This must always be greater than zero. A proven approach is to define an enumeration for this purpose.

stInitPars

ST_PMA_Frequency_Period_InitPars

Function block-specific structure with initialization parameters. The parameters must match the definition of the input and output buffers.

Init 2: Return value

Name

Type

Description

Init

BOOL

Indicates whether the method was executed successfully. Further information is provided in the Event interface of the function block.