Main Content

EtherCAT Set State

Set state of EtherCAT network

Since R2020b

  • EtherCAT Set State block

Simulink Real-Time / EtherCAT


The EtherCAT Set State block sets the state of the EtherCAT® network to the value passed in through the New State port.



expand all

INIT1Initialization — The system finds terminal devices and initializes the communication controller.
PREOP2Preoperational — The system uses the communication controller to exchange system-specific initialization data. In this state, the network cannot transmit or receive signal data.
SAFEOP4Safe operational — The network is running and ready for full operation. The supervisor sends input data to the terminal device. The terminal device output remains in a safe state.
OP8Operational — The network is in full operation. The supervisor sends input data to the terminal device. The terminal device responds with output data.


expand all

This port returns the value of the previous setting of the New State port.

If no error occurs, this port returns 0. Otherwise, it returns a nonzero value.


expand all

To associate a block with an EtherCAT network, enter the Network Device Index value from the EtherCAT Init block representing that network into the Network Device Index for the block.

Programmatic Use

Block Parameter: device_id

Enter the number of seconds to wait for the EtherCAT network state to transition.

Set the timeout to 0 to return immediately. If you specify a nonzero Timeout value, in the Configuration Parameters Solver pane, set the Fixed-step size parameter to a value larger than the Timeout value.

Programmatic Use

Block Parameter: timeout

Enter the base sample time or a multiple of the base sample time. -1 means that the sample time is inherited.

Programmatic Use

Block Parameter: sample_time

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Version History

Introduced in R2020b