FB_EcReqMasterState
With this function block the EtherCAT state of a master device can be requested and set. The requested EtherCAT state is transferred in the state variable. The function block becomes inactive as soon as it has requested the EtherCAT state. Unlike the function block FB_EcSetMasterState it does not wait until the new state is set.
See also: FB_EcSetMasterState
Inputs
VAR_INPUT
sNetId : T_AmsNetId;
bExecute : BOOL;
tTimeout : TIME := DEFAULT_ADS_TIMEOUT;
state : 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. |
state | WORD | EtherCAT state requested from the master. |
State
EtherCAT state requested from the master. The possible State values 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
VAR_OUTPUT
bBusy : BOOL;
bError : BOOL;
nErrId : UDINT;
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. |
Example of an implementation in ST:
PROGRAM TEST_ReqMasterState
VAR
fbReqMasterState : FB_EcReqMasterState;
sNetId : T_AmsNetId:= '172.16.2.131.2.1';
bExecute : BOOL;
state : WORD :=EC_DEVICE_STATE_INIT;
bError : BOOL;
nErrId : UDINT;
END_VAR
fbReqMasterState(sNetId:= sNetId, bExecute:=bExecute, state:=state);
bError := fbGetMasterState.bError;
nErrId := fbGetMasterState.nErrId;
Requirements
Development environment | Target platform | PLC libraries to include |
---|---|---|
TwinCAT v3.1.0 | PC or CX (x86, x64, ARM) | Tc2_EtherCAT |