FB_SoEReadCommandState

FB_SoEReadCommandState 1:

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

FB_SoEReadCommandState 2: Inputs

VAR_INPUT
    sNetId   : T_AmsNetId := '';
    nIdn     : WORD;
    bExecute : BOOL;
    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).

nIdn

WORD

Parameter number to which FB_SoEExecuteCommand refers, e.g. "P_0_IDN + 160" for P-0-0160.

bExecute

BOOL

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

tTimeout

TIME

Maximum time allowed for the execution of the function block.

FB_SoEReadCommandState 3: Inputs/outputs

VAR_IN_OUT
    Axis : NCTOPLC_AXIS_REF;(* reference to NC axis *)
END_VAR

Name

Type

Description

Axis

NCTOPLC_AXIS_REF

Axis data structure of the type NCTOPLC_AXIS_REF

FB_SoEReadCommandState 4: Outputs

VAR_OUTPUT
    bBusy        : BOOL;
    bError       : BOOL;
    eCmdState    : E_SoE_CmdState;
    iAdsErrId    : UINT;
    iSercosErrId : UINT;
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.

eCmdState

E_SoE_CmdState

Returns the command state (see below).

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.

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

Sample

fbReadCommandState : FB_SoEReadCommandState;
bReadCommandState : BOOL;
nIdn : WORD;
eCmdState : E_SoE_CmdState;
(* NcAxis *)
NcToPlc AT %I* : NCTOPLC_AXIS_REF; 

IF bReadCommandState THEN
 nIdn := P_0_IDN + 160;
 fbReadCommandState(
    Axis := NcToPlc,
    bExecute := TRUE,
    tTimeout := DEFAULT_ADS_TIMEOUT,
    nIdn := nIdn,
    eCmdState => eCmdState
 );
 IF NOT fbReadCommandState.bBusy THEN
    fbReadCommandState(Axis := NcToPlc, bExecute := FALSE);
    bReadCommandState := FALSE;
 END_IF
END_IF