FB_SoEWriteCommandControl

FB_SoEWriteCommandControl 1:

The functionblock FB_SoEWriteCommandControl can be used to prepare, start, or cancel a command.  

VAR_INPUT

VAR_INPUT
    NetId       : T_AmsNetId := '';
    Idn         : WORD;
    CmdControl  : E_SoE_CmdControl;
    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

CmdControl: 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

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;
    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 Error output is set.

SercosErrId: Supplies the Sercos error code associated with the most recently executed command if the Error output is set.

Sample

fbWriteCommandControl : FB_SoEWriteCommandControl;
WriteCommandControl   : BOOL;
Idn                   : WORD;
CmdControl            : E_SoE_CmdControl;

(* NcAxis *)
Axis            : AXIS_REF;
IF WriteCommandControl THEN
    Idn := P_0_IDN + 160;
    fbWriteCommandControl(
       Axis        := Axis,
       Execute     := TRUE,
       Timeout     := DEFAULT_ADS_TIMEOUT,
       Idn         := Idn,
       CmdControl  := CmdControl
    );
    IF NOT fbWriteCommandControl.Busy THEN
       fbWriteCommandControl(Axis := Axis, Execute := FALSE);
       WriteCommandControl := FALSE;
    END_IF
END_IF