FB_SoEReadCommandState

FB_SoEReadCommandState 1:

With the FB_SoEReadCommandState function block the command execution can be checked.

FB_SoEReadCommandState 2: Inputs

VAR_INPUT
    NetId   : T_AmsNetID := '';
    Idn     : WORD;
    Execute : BOOL;
    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).

Idn

WORD

Parameter number that FB_SoEReadCommandState_ByDriveRef refers to, e.g. "P_0_IDNs + 160" for P-0-0160

Execute

BOOL

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

Timeout

TIME

Maximum time allowed for the execution of the function block.

FB_SoEReadCommandState 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_SoEReadCommandState 4: Outputs

VAR_OUTPUT
    Busy        : BOOL;
    Error       : BOOL;
    CmdState    : E_SoE_CmdState;
    AdsErrId    : UINT;
    SercosErrId : UINT;
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.

CmdState

E_SoE_CmdState

Returns the command status:

eSoE_CmdState_NotSet = 0
- kein Kommando aktiv

eSoE_CmdState_Set = 1
- Kommando gesetzt (vorbereitet) aber (noch) nicht ausgeführt

eSoE_CmdState_Executed = 2
- Kommando wurde ausgeführt

eSoE_CmdState_SetEnabledExecuted = 3 
- Kommando gesetzt (vorbereitet) und ausgeführt

eSoE_CmdState_SetAndInterrupted = 5
- Kommando wurde gesetzt aber unterbrochen

eSoE_CmdState_SetEnabledNotExecuted = 7
- Kommandoausführung ist noch aktiv

eSoE_CmdState_Error = 15
- Fehler bei der Kommandoausführung, es wurde in den Fehlerstate gewechselt

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.

Sample

fbReadCommandState : FB_SoEReadCommandState;
ReadCommandState   : BOOL;
Idn                : WORD;
CmdState           : E_SoE_CmdState;
(* NcAxis *)
Axis               : AXIS_REF; 

IF ReadCommandState THEN
 Idn := P_0_IDNs + 160;
 fbReadCommandState(
    Axis    := Axis,
    Execute := TRUE,
    Timeout := DEFAULT_ADS_TIMEOUT,
    Idn     := Idn,
    CmdState => CmdState
 );
 IF NOT fbReadCommandState.Busy THEN
    fbReadCommandState(Axis := Axis, Execute := FALSE);
    ReadCommandState := FALSE;
 END_IF
END_IF