FB_SoEWriteCommandControl
The functionblock FB_SoEWriteCommandControl can be used to prepare, start or cancel a command.
VAR_INPUT
VAR_INPUT
sNetId : T_AmsNetId := '';
nIdn : WORD;
eCmdControl : E_SoE_CmdControl;
bExecute : BOOL;
tTimeout : TIME := DEFAULT_ADS_TIMEOUT;
END_VAR
sNetId: A string containing the AMS network identifier of the PC.
nIdn: Parameter number for the command, i.e. "P_0_IDN + 160" for executing a P-0-0160 command
eCmdControl: prepare a command with eSoE_CmdControl_Set := 1, execute a command with eSoE_CmdControl_SetAndEnable := 3 or abort a command with eSoE_CmdControl_Cancel := 0
bExecute: The block is activated by a rising edge at this input.
tTimeout: Maximum time allowed for the execution of the function block.
VAR_IN_OUT
VAR_IN_OUT
Axis : NCTOPLC_AXLESTRUCT;(* reference to NC axis *)
END_VAR
Axis: Axis structure.
VAR_OUTPUT
VAR_OUTPUT
bbBusy : BOOL;
bError : BOOL;
iAdsErrId : UINT;
iSercosErrId : UINT;
END_VAR
bBusy: This output is set when the function block is activated, and remains set until an acknowledgement is received.
bError: This output is set up after the bBusy output has been reset if there has been an error in transmission of the command.
iAdsErrId: Supplies the ADS error code associated with the most recently executed command if the bError output is set.
iSercosErrId: Supplies the Sercos error code associated with the most recently executed command if the bError output is set.
Sample
fbWriteCommandControl : FB_SoEWriteCommandControl;
bWriteCommandControl : BOOL;
nIdn : WORD;
eCmdControl : E_SoE_CmdControl;
(* NcAxis *)
stNcToPlc AT %I* : NCTOPLC_AXLESTRUCT;
IF bWriteCommandControl THEN
nIdn := P_0_IDN + 160;
fbWriteCommandControl(
Axis := stNcToPlc,
bExecute := TRUE,
tTimeout := DEFAULT_ADS_TIMEOUT,
nIdn := nIdn,
eCmdControl := eCmdControl
);
IF NOT fbWriteCommandControl.bBusy THEN
fbWriteCommandControl(Axis := stNcToPlc, bExecute := FALSE);
bWriteCommandControl := FALSE;
END_IF
END_IF