FB_SoEReadClassXDiag
With the function block FB_SoEReadClassXDiag, the current Class 1 diagnosis (S-0-0011) ... Class 3 diagnosis (S-0-0013) can be read out as WORD. There is the conversion function F_ConvWordToSTAX5000C1D for the evaluation of the Class 1 diagnosis as a structure ST_AX5000_C1D, (see TwinCAT 3 PLC Lib Tc2_Drive documentation).
Inputs
VAR_INPUT
sNetId : T_AmsNetId := '';
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
Name | Type | Description |
---|---|---|
sNetId | T_AmsNetId | String, which contains the AMS Network ID of the PC (type: T_AmsNetId). |
bExecute | BOOL | The function block is enabled via a positive edge at this input. |
iDiagClass | USINT | Specifies which diagnosis should be read. The diagnostics parameters may vary from vendor to vendor. All diagnostics parameters (C1D ... C3D) or all bits are not always implemented in them. 1: Error: Class 1 Diag (S-0-0011) 2: Warnings: Class 2 Diag (S-0-0012) 3: Information: Class 3 Diag (S-0-0013) |
tTimeout | TIME | Maximum time allowed for the execution of the function block. |
Inputs/outputs
VAR_IN_OUT
Axis : NCTOPLC_AXIS_REF;(* reference to NC axis *)
END_VAR
Name | Type | Description |
---|---|---|
Axis | Axis data structure of the type NCTOPLC_AXIS_REF |
Outputs
VAR_OUTPUT
bBusy : BOOL;
bError : BOOL;
iAdsErrId : UINT;
iSercosErrId : UINT;
wClassXDiag : WORD;
dwAttribute : DWORD;
END_VAR
Name | Type | Description |
---|---|---|
bBusy | BOOL | This output is set when the function block is activated, and remains set until a feedback is received. |
bError | BOOL | This output is set after the bBusy output has been reset when an error occurs in the transmission of the command. |
iAdsErrId | UINT | Returns the ADS error code of the last executed command when the bError output is set. |
iSercosErrId | UINT | In the case of a set bError output returns the Sercos error of the last executed command. |
wClassXDiag | WORD | Returns the current Class X diagnosis. |
dwAttribute | DWORD | Returns the attributes of the Sercos parameter. |
Sample
fbClassXDiag : FB_SoEReadClassXDiag;
bClassXDiag : BOOL;
iDiagClass : USINT := 1;
wClass1Diag : WORD;
stAX5000C1D : ST_AX5000_C1D;
wClass2Diag : WORD;
(* NcAxis *)
NcToPlc AT %I* : NCTOPLC_AXIS_REF;
IF bClassXDiag THEN
fbClassXDiag(
Axis := NcToPlc,
bExecute := TRUE,
iDiagClass := iDiagClass,
tTimeout := DEFAULT_ADS_TIMEOUT
);
IF NOT fbClassXDiag.bBusy THEN
fbClassXDiag(Axis := NcToPlc, 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