FB_SoEReadClassXDiag_ByDriveRef
The function block FB_SoEReadClassXDiag_ByDriveRef can be used to read the actual Class 1 Diagnose (S-0-0011) ... Class 3 Diagnose (S-0-0013) as a WORD. There is a conversion function F_ConvWordToSTAX5000C1Dfor evaluation of the Class 1 Diagnose as a structure ST_AX5000_C1D.
VAR_INPUT
VAR_INPUT
stDriveRef : ST_DriveRef;
bExecute : BOOL;
iDiagClass : USINT:= 1; (* 1: C1D (S-0-0011) is default, 2: C2D (S-0-0012), 3: C3D (S-0-0013) *)
tTimeout : TIME := DEFAULT_ADS_TIMEOUT;
END_VAR
stDriveRef: The drive reference can be linked in the System Manager between PLC and drive. The link can be done to an instance of the ST_PlcDriveRef. The structure ST_PlcDriveRef contains the NetID as byte array. The byte array can be converted to a string. See ST_DriveRef.
bExecute: The block is activated by a rising edge at this input.
iDiagClass: Selects which diagnose should be read. The diagnose info can be different with different drive vendors. Not always all diagnose parameters (C1D ... C3D) or all bits in these parameters are implementiert.
1: Error: Class 1 Diag (S-0-0011)
2: Warning: Class 2 Diag (S-0-0012)
3: Informationen: Class 3 Diag (S-0-0013)
tTimeout: Maximum time allowed for the execution of the function block.
VAR_OUTPUT
VAR_OUTPUT
bBusy : BOOL;
bError : BOOL;
iAdsErrId : UINT;
iSercosErrId : UINT;
dwAttribute : DWORD;
wClassXDiag : WORD;
END_VAR
bBusy: This output is set when the function block is activated and remains set until an acknowledgement is received.
bError: This output is set up after the bBusy output has been reset if there has been an error in transmission of the command.
iAdsErrId: Supplies the ADS error code associated with the most recently executed command if the bError output is set.
iSercosErrId: Supplies the Sercos error code associated with the most recently executed command if the bError output is set.
dwAttribute: Supplies the attribut of the Sercos parameter.
wClassXDiag: Supplies the class X diagnose.
Sample
fbClassXDiag : FB_SoEReadClassXDiag_ByDriveRef;
bClassXDiag : BOOL;
iDiagClass : USINT := 1;
wClass1Diag : WORD;
stAX5000C1D : ST_AX5000_C1D;
wClass2Diag : WORD;
bInit : BOOL := TRUE;
stPlcDriveRef AT %I* : ST_PlcDriveRef;
stDriveRef : ST_DriveRef;
IF bInit THEN
stDriveRef.sNetId := F_CreateAmsNetId(stPlcDriveRef.aNetId);
stDriveRef.nSlaveAddr := stPlcDriveRef.nSlaveAddr;
stDriveRef.nDriveNo := stPlcDriveRef.nDriveNo;
stDriveRef.nDriveType := stPlcDriveRef.nDriveType;
IF (stDriveRef.sNetId <> '') AND (stDriveRef.nSlaveAddr <> 0) THEN
bInit := FALSE;
END_IF
END_IF
IF bClassXDiag AND NOT bInit THEN
fbClassXDiag(
stDriveRef := stDriveRef,
bExecute := TRUE,
iDiagClass := iDiagClass,
tTimeout := DEFAULT_ADS_TIMEOUT
);
IF NOT fbClassXDiag.bBusy THEN
fbClassXDiag(stDriveRef := stDriveRef, bExecute := FALSE);
bClassXDiag := FALSE;
CASE fbClassXDiag.iDiagClass OF
1:
wClass1Diag := fbClassXDiag.wClassXDiag;
stAX5000C1D := F_ConvWordToSTAX5000C1D(wClass1Diag);
2:
wClass2Diag := fbClassXDiag.wClassXDiag;
END_CASE
END_IF
END_IF