FB_SoEReadCommandState
The function block FB_SoEReadCommandState can be used to read the state of a command.
VAR_INPUT
VAR_INPUT
NetId : T_AmsNetId := '';
Idn : WORD;
Execute : BOOL;
Timeout : TIME := DEFAULT_ADS_TIMEOUT;
END_VAR
NetId: A string containing the AMS network identifier of the PC.
Idn: Parameter number for the command, i.e. "P_0_IDN + 160" for executing a P-0-0160 command
Execute: The block is activated by a rising edge at this input.
Timeout: Maximum time allowed for the execution of the function block.
VAR_IN_OUT
VAR_IN_OUT
Axis : AXIS_REF; (* Axis reference *)
END_VAR
Axis: Axis structure (see TcMC2.lib).
VAR_OUTPUT
VAR_OUTPUT
Busy : BOOL;
Error : BOOL;
CmdState : E_SoE_CmdState;
AdsErrId : UINT;
SercosErrId : UINT;
END_VAR
Busy: This output is set when the function block is activated and remains set until an acknowledgement is received.
Error: This output is set up after the bBusy output has been reset if there has been an error in transmission of the command.
AdsErrId: Supplies the ADS error code associated with the most recently executed command if the bError output is set.
SercosErrId: Supplies the Sercos error code associated with the most recently executed command if the bError output is set.
CmdState: Supplies the command state
eSoE_CmdState_NotSet =
0
- no command active
eSoE_CmdState_Set =
1
- command set (prepared) but (not yet) executed
eSoE_CmdState_Executed =
2
- command was executed
eSoE_CmdState_SetEnabledExecuted =
3 - command set (prepared) and executed
eSoE_CmdState_SetAndInterrupted =
5 - command was set but interupted
eSoE_CmdState_SetEnabledNotExecuted = 7 -
command execution is stll active
eSoE_CmdState_Error =
15
- error during command execution, switched to error state
Sample
fbReadCommandState : FB_SoEReadCommandState;
ReadCommandState : BOOL;
Idn : WORD;
CmdState : E_SoE_CmdState;
(* NcAxis *)
Axis : AXIS_REF;
IF ReadCommandState THEN
Idn := P_0_IDN + 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