FB_PMA_Protection

The FB_PMA_Protection function block is used to monitor network data or results using thresholds and hysteresis. Any number of input channels can be monitored simultaneously. An additional output summarizes whether at least one threshold value has been exceeded or not reached.

Syntax

Definition:

FUNCTION BLOCK FB_PMA_Protection
VAR_INPUT
    stInitPars        : ST_PMA_Protection_InitPars;
END_VAR
VAR_OUTPUT
    bError            : BOOL;
    ipResultMessage   : I_TcMessage;
    bNewResult        : BOOL;
    bProtectionResult : BOOL;
    tLastEvent        : ULINT;
END_VAR

FB_PMA_Protection 1: Inputs

The input parameters of this function block represent initialization parameters and must be assigned when declaring the function block instance (alternative: Init method). They may only be assigned once. A change at runtime is possible by calling the Init method again.

Name

Type

Description

stInitPars

ST_PMA_Protection_InitPars

Function-block-specific structure with initialization parameters

FB_PMA_Protection 2: Outputs

Name

Type

Description

bError

BOOL

TRUE if an error occurs.

ipResultMessage

I_TcMessage

The interface offers detailed information about the return value.

bNewResult

BOOL

TRUE once new results have been calculated.

bProtectionResult

BOOL

TRUE as soon as an input channel is outside the threshold values.

tLastEvent

ULINT

Timestamp at which the bProtectionResult output last changed.

FB_PMA_Protection 3: Methods

Methods can be used to scale different systems (single-phase or three-phase) and different resolutions (16 bits or 32 bits).

Name

Description

Call

The method is called to perform the calculation.

Init

Alternative to the function block initialization

Reconfigure

The method is called to reconfigure the function block at runtime.

Reset

The current calculations are reset with the method.

SetChannelValue

Method for transferring values to the algorithm.

Example

VAR CONSTANT
    cInitPars: ST_PMA_Protection_InitPars :=
    (
        nNumChannels := 3,
        fSetpoint := 230.0,
        fMinThreshold := 0.9,
        fMinThresholdHysteresis := 0.01,
        fMaxThreshold := 1.1,
        fMaxThresholdHysteresis := 0.01
    );
END_VAR
VAR
    fbProtection : FB_PMA_Protection := (stInitPars:= cInitPars);
    tTimestamp : ULINT;
    fVoltage_FeedIn : LREAL;
    fVoltage_Conumer1 : LREAL;
    fVoltage_Conumer2 : LREAL;
    aOut : ARRAY[1..3] OF BOOL
END_VAR
// Get current dc time - Tc2_EtherCAT lib has to be included
tTimestamp := Tc2_EtherCAT.F_GetActualDcTime64();

// Call algorithm
fbProtection.SetChannelValue(1, fVoltage_FeedIn);
fbProtection.SetChannelValue(2, fVoltage_Conumer1);
fbProtection.SetChannelValue(3, fVoltage_Conumer2);
fbProtection.Call(tTimestamp, ADR(aOut), SIZEOF(aOut));

Requirements

Development environment

Target platform

PLC libraries to include

TwinCAT v3.1.4024.0

PC or CX (x86, x64)

Tc3_PowerMonitoring