FB_EcGetExtSlaveState

The function block FB_EcGetExtSlaveState allows the EtherCAT status, the extended EtherCAT status and the link status of an individual EtherCAT slave to be read. If the call is successful, the output variable extState, whose type is ST_EcSlaveState, contains the requested status information. The function block FB_EcGetExtSlaveState is required when using the MX-System in order to detect empty MX slots (without an MX module inserted) in the PLC.
Inputs
VAR_INPUT
sNetId : T_AmsNetId;
nSlaveAddr : UINT;
bExecute : BOOL;
tTimeout : TIME := DEFAULT_ADS_TIMEOUT;
END_VARName | Type | Description |
|---|---|---|
sNetId | String containing the AMS network ID of the EtherCAT master device. | |
nSlaveAddr | UINT | Fixed address of the EtherCAT slave whose state is to be read. |
bExecute | BOOL | The function block is enabled by a positive edge at this input. |
tTimeout | TIME | Maximum time allowed for the execution of the function block. |
Outputs
VAR_OUTPUT
bBusy : BOOL;
bError : BOOL;
nErrId : UDINT;
extState : ST_EcExtendedSlaveState;
END_VARName | Type | Description |
|---|---|---|
bBusy | BOOL | This output is set when the function block is activated, and remains set until 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. |
extState | ST_EcExtendedSlaveState | Structure that contains the extended EtherCAT status and the link status of the slave. (Type: ST_EcExtendedSlaveState) |
Example for implementation in ST:
PROGRAM TEST_GetExtSlaveState
VAR
fbGetExtSlaveState : FB_EcGetExtSlaveState;
sNetId : T_AmsNetId := '172.16.2.131.2.1';
bExecute : BOOL;
extState : ST_EcExtendedSlaveState;
nSlaveAddr : UINT := 1001;
bError : BOOL;
nErrId : UDINT;
END_VAR
fbGetExtSlaveState(sNetId:= sNetId, nSlaveAddr:= nSlaveAddr, bExecute:=bExecute);
extState := fbGetExtSlaveState.extState;
bError := fbGetExtSlaveState.bError;
nErrId := fbGetExtSlaveState.nErrId;Requirements
Development environment | Target platform | PLC libraries to include |
|---|---|---|
TwinCAT v3.1.4026.26 | PC or CX (x86, x64, Arm®) | Tc2_EtherCAT >= 3.8.1.0 |