One common cause for this issue could be CPU chatter preventing distributed clocks (DC) synchronization in the EtherCAT network. Distributed clocks are only able to synchronize if the Master-to-network clock difference settles below 5% of the model's sample time.
To determine if this is in fact the issue that you are facing, log the "Status" output of the EtherCAT Init block. Open Simulation Data Inspector and specifically look at the 'MasterToNetworkClkDiff' and 'NetworkToSlaveClkDiff' components (depending on whether you are using Master Shift or Bus Shift mode). See if these signals are above the 5% of base sample time threshold as mentioned above. If yes, that explains why the distributed clocks are unable to sync and why the EtherCAT network does not go into operational state.
Below is an example of an EtherCAT network in Master Shift DC mode working at a 500 Hz sample rate (MasterState reaches 8), but no longer working at a 2 kHz rate (MasterState stuck at 2):
- At 500 Hz, the sample time is 2 milliseconds, 5% of that corresponds to a threshold of 1.0e5 nanoseconds. We can see from the plot that the master-to-network clock difference is well below that, so it's able to sync the distributed clocks.
- At 2 kHz, the sample time is 0.5 milliseconds, which corresponds to a threshold of 2.5e4 nanoseconds. In this case, the master-to-network clock difference consistently exceeds this value, so the distributed clocks are not able to synchronize.
There is no easy way of solving this issue. You could try a few things but these are not guaranteed to make a difference:
- Toggle the EtherCAT DC algorithm in the configurator (e.g., from Bus Shift to Master Shift mode or vice versa) and see if chatter is small enough in the other mode to allow DC synchronization.
- Try different values for the "DC tuning" parameter in the EtherCAT Init block.
- If available, try a more performant Speedgoat machine.
- In R2020a and earlier, disable graphics mode.
Otherwise, you will need to reduce the model sample time or reduce the model's complexity.