FB_EcSetMasterState
 
 
With this function block the EtherCAT state of a master device can be requested and set. The requested EtherCAT state is transferred with the reqState variable. The function block requests the EtherCAT state and, unlike the function block FB_EcReqMasterState, remains active until the new state is set or the maximum time tTimeout is exceeded. The current state is output in the currState variable.
See also: FB_EcReqMasterState
 Inputs
 Inputs
VAR_INPUT
    sNetId   : T_AmsNetId;
    bExecute : BOOL; 
    tTimeout : TIME := T#10s; 
    reqState : WORD;
END_VAR| Name | Type | Description | 
|---|---|---|
| sNetId | T_AmsNetId | String containing the AMS network ID of the EtherCAT master device. (Type: T_AmsNetId) | 
| bExecute | BOOL | The function block is activated by a positive edge at this input. | 
| tTimeout | TIME | Maximum time allowed for the execution of the function block. | 
| reqState | WORD | 
 | 
reqState
EtherCAT state requested from the master. The possible values for reqState are:
| Constant | Value | Description | 
|---|---|---|
| EC_DEVICE_STATE_INIT | 0x01 | Request Init state from master | 
| EC_DEVICE_STATE_PREOP | 0x02 | Request Pre-operational state from master | 
| EC_DEVICE_STATE_SAFEOP | 0x04 | Request Safe-operational state from master | 
| EC_DEVICE_STATE_OP | 0x08 | Request Operational state from master | 
 Outputs
 Outputs
VAR_OUTPUT
    bBusy     : BOOL;
    bError    : BOOL;
    nErrId    : UDINT;
    currState : WORD;
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. | 
| nErrId | UDINT | Supplies the ADS error code associated with the most recently executed command if the bError output is set. | 
| currState | WORD | Current EtherCAT state of the master | 
Prerequisites
| Development environment | Target platform | PLC libraries to include | 
|---|---|---|
| TwinCAT v3.1.0 | PC or CX (x86, x64, Arm®) | Tc2_EtherCAT |