FB_EcSetSlaveState
The functionblock FB_EcSetSlaveState is used to set the EtherCAT slave in the state that is stated by the parameter reqState. The functionblock waits the maximum tTimeout time until the new state is set.
VAR_INPUT
VAR_INPUT
sNetId : T_AmsNetId;
nSlaveAddr : UINT;
bExecute : BOOL;
tTimeout : TIME := T#10s;
reqState : WORD;
END_VAR
sNetId: This is a string that contains the AMS network identifier of the EtherCAT master device.
nSlaveAddr: Fixed address of the EtherCAT slave whose state is to be set.
bExecute: The block is activated by a rising edge at this input.
tTimeout: Maximum time allowed for the execution of the function block.
reqState: EtherCAT state in which the slave is to be set. Possible values for reqState are:
Constant | Value | Description |
---|---|---|
EC_DEVICE_STATE_INIT | 0x01 | Set slave in Init state. |
EC_DEVICE_STATE_PREOP | 0x02 | Set slave in pre-operational state. |
EC_DEVICE_STATE_BOOTSTRAP | 0x03 | Set slave in bootstrap state. This state is used to make a firmware download. |
EC_DEVICE_STATE_SAFEOP | 0x04 | Set slave in safe-operational state. |
EC_DEVICE_STATE_OP | 0x08 | Set slave in operational state. |
EC_DEVICE_STATE_ERROR | 0x10 | If the error bit at the EtherCAT Slave is set in the status byte ( currState.deviceState AND EC_DEVICE_STATE_ERROR = TRUE), the error bit can be reset by setting EC_DEVICE_STATE_ERROR |
VAR_OUTPUT
VAR_OUTPUT
bBusy : BOOL;
bError : BOOL;
nErrId : UDINT;
currState : ST_EcSlaveState;
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.
nErrId: Supplies the ADS error code associated with the most recently executed command if the bError output is set.
currState: Current EtherCAT state of the slave.
Requirements
Development Environment | Target System | PLC Libraries to include |
---|---|---|
TwinCAT v2.10.0 Build > 1307 or higher | PC or CX (x86) | TcEtherCAT.Lib |