FB_SoEReadClassXDiag

FB_SoEReadClassXDiag 1:

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).

FB_SoEReadClassXDiag 2: Inputs

VAR_INPUT
    NetId     : T_AmsNetId := ''; 
    Execute   : BOOL; 
    DiagClass : USINT:= 1; (* 1: C1D (S-0-0011) is default, 2: C2D (S-0-0012), 3: C3D (S-0-0013) *)
    Timeout   : TIME := DEFAULT_ADS_TIMEOUT;
END_VAR

Name

Type

Description

NetId

T_AmsNetId := ''

String, which contains the AMS Network ID of the PC (type: T_AmsNetId).

Execute

BOOL

The function block is enabled via a positive edge at this input.

DiagClass

USINT:= 1; (* 1: C1D (S-0-0011) is default, 2: C2D (S-0-0012), 3: C3D (S-0-0013) *)

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)

Timeout

TIME := DEFAULT_ADS_TIMEOUT

Maximum time allowed for the execution of the function block.

FB_SoEReadClassXDiag 3: Inputs/outputs

VAR_IN_OUT
   Axis : AXIS_REF;
END_VAR

Name

Type

Description

Axis

AXIS_REF

Axis data structure that unambiguously addresses an axis in the system. Among other parameters it contains the current axis status, including position, velocity or error state.

FB_SoEReadClassXDiag 4: Outputs

VAR_OUTPUT
    Busy        : BOOL;
    Error       : BOOL;
    AdsErrId    : UINT;
    SercosErrId : UINT;
    ClassXDiag  : WORD;
    Attribute   : DWORD;
END_VAR

Name

Type

Description

Busy

BOOL

This output is set when the function block is activated, and remains set until a feedback is received.

Error

BOOL

This output is set after the Busy output has been reset when an error occurs in the transmission of the command.

AdsErrId

UINT

In the case of a set Error output returns the ADS error code of the last executed command.

SercosErrId

UINT

In the case of a set Error output returns the Sercos error of the last executed command.

ClassXDiag

WORD

Returns the current Class X diagnosis.

Attributes

DWORD

Returns the attributes of the Sercos parameter.

Sample

fbClassXDiag : FB_SoEReadClassXDiag;
bClassXDiag  : BOOL;
DiagClass    : USINT := 1;
Class1Diag   : WORD;
stAX5000C1D  : ST_AX5000_C1D;
Class2Diag   : WORD;
(* NcAxis *)
Axis         : AXIS_REF; 

IF bClassXDiag THEN
 fbClassXDiag(
    Axis      := Axis,
    Execute   := TRUE,
    DiagClass := DiagClass,
    Timeout   := DEFAULT_ADS_TIMEOUT
 );
 IF NOT fbClassXDiag.Busy THEN
    fbClassXDiag(Axis := Axis, Execute := FALSE);
    bClassXDiag := FALSE;
    CASE fbClassXDiag.DiagClass OF
    1:
     Class1Diag  := fbClassXDiag.ClassXDiag;
     stAX5000C1D := F_ConvWordToSTAX5000C1D(Class1Diag);
    2:
     Class2Diag  := fbClassXDiag.ClassXDiag;
    END_CASE
 END_IF
END_IF