UpdateDiagnosisEntry (FB)

FUNCTION_BLOCK UpdateDiagnosisEntry

This function block is used by a Profinet-Device application to add and remove Profinet diagnosis-data.

The device application adds or removes diagnosis information according to the status of its real periphery.

The real periphery is specified through the diagnosis source (API, Slot, Subslot, Channel, Direction, Accumulative).

A diagnosis information (ChannelErrorType, optionally ExtChannelErrorType) exist only once per diagnosis source.

If severity or ExtChannelErrorAddValue changes, the diagnosis information is updated regarding these values.

If the diagnosis of a particular submodule changes during operation (submodule is in data-exchange), a diagnosis alarm is issued to the IO controller owning this submodule.

Update Diagnosis

PROGRAM PLC_PRG
VAR
    ID : UDINT;
    exec : BOOL;
    appears : BOOL;
    updateDiag : ProfinetCommon.UpdateDiagnosisEntry;
END_VAR


ID := CommFB.SUBSLOT_ID(EN := TRUE, ID := PN_Device.DeviceID, SLOT := 2, SUBSLOT := 1);

updateDiag.ID := ID;
updateDiag.xAppears := appears;
updateDiag.ChannelNumber := 1;
updateDiag.ChannelProperties.ChannelType := ProfinetCommon.ChannelProperties_Type.BitSize1;
updateDiag.ChannelProperties.Direction := ProfinetCommon.DiagnosisDirection.In;
updateDiag.Diagnosis.Severity := ProfinetCommon.DiagnosisSeverity.Fault;
updateDiag.Diagnosis.ChannelErrorType := ProfinetCommon.ChannelErrorType.Line_break;    //0x0006 Line break
updateDiag(xExecute := exec);

IF(updateDiag.xDone OR updateDiag.xError) THEN
    exec := FALSE;
END_IF
InOut:

Scope

Name

Type

Initial

Comment

Input

xExecute

BOOL

Rising edge: Execute update of submodule's diagnosis

ID

UDINT

Submodule-ID

xAppears

BOOL

TRUE: Diagnosis appears - add new diagnosis or update Severity and additional value

FALSE: Diagnosis disappears - clear diagnosis specified by source(Submodule, Channel) and error/ext-error

ChannelNumber

UINT

16#8000

The channel number of the diagnosis source (0x8000 means the whole submodule)

ChannelProperties

ChannelProperties

additional channel data, not used for diagnosis that affect the whole submodule.

Diagnosis

ChannelDiagnosisData

The diagnosis-data entry

Output

xDone

BOOL

Action successfully completed

xBusy

BOOL

Function block active

xError

BOOL

error occurred, function block aborts action

Status

UpdateDiagnosis_Status

Error related to local update of diagnosis data, e.g. duplicate entry, no ressource...

PNIOStatus

UDINT

PNIOStatus of Alarm processing (only with established AR)