FUNCTION_BLOCK FB_PN_ALARM_DIAG

FUNCTION_BLOCK FB_PN_ALARM_DIAG 1:
FUNCTION_BLOCK FB_PN_ALARM_DIAG

Diagnosis alarms can be read out using this function block. Each instance of this function block makes a PLC input available ("PnIoBoxDiag"). This input must be linked to the “PnIoBoxDiag” input of the device that is to be evaluated. After successful reading of the diagnosis alarms/warnings, the alarm status of the device is reset. The function block must be called once for each PROFINET device.  A running index (iNrAlarms) indicates how many diagnosis alarms have been read from the buffer.

VAR_INPUT

VAR_INPUT
    bEnable : BOOL;
    NETID   : T_AmsNetId;(* AMS Net ID from Controller *)
    PORT    : T_AmsPort; (* Port used by Controller to communicate with Device *)
END_VAR

bEnable: Activation of the function block

NETID: AMS Net ID of the controller

PORT: Port via which the controller communicates with the device (port = Device ID + 1000 hex)

VAR_OUTPUT

VAR_OUTPUT
    bBusy       : BOOL;
    stAlarmDiagData : ST_PN_AlarmDiagData;
    bError      : BOOL;         
    iErrorID        : UDINT;
    iNrAlarms           : INT;
END_VAR

bBusy: When the function block is activated this output is set. It remains set until a feedback is received. While Busy = TRUE, no new command will be accepted at the inputs.

stAlarmDiagData: Diagnosis messages are output via this structure. An alarm is output via the structure in each cycle as long as the status bit [0x0010 = at least one AlarmCR got a diagnosis alarm] is present at the PLC input.

bError: If an error should occur during the transmission of the command, this output is set after the bBusy output has been reset.

iErrorID: Supplies an ADS error number when the output bError is set.

iNrAlarms: Number of alarms last read out.

VAR

VAR
        PnIoBoxDiag AT %I* : WORD; (*Hardware Input*)
END_VAR

PnIoBoxDiag : Hardware input: this variable must be linked to the PROFINET device. A change of state of this variable indicates to the PLC program that there are new diagnosis alarms in the linked PROFINET device.

FUNCTION_BLOCK FB_PN_ALARM_DIAG 2:
Linking of the variables in the TwinCAT tree

Development environment

Target platform

PLC libraries to be linked

TwinCAT v2.11.0 R3

PC or CX (x86, ARM)

TcProfinetDiag.Lib