How can I debug my EtherCAT network not getting to the operational state with Speedgoat & Simulink Real-Time?

40 views (last 30 days)
I’m using EtherCAT with Simulink Real-Time, where the Speedgoat target computer acts as the EtherCAT Main Device (previously "EtherCAT Master"). However, the network isn’t reaching the operational state ("state 8" or "OP state"), so it is unfortunately not working as expected as I can’t read or send data to subdevices.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 17 Apr 2025
Edited: MathWorks Support Team on 17 Apr 2025
When working with EtherCAT networks and Simulink Real-Time (SLRT), it is crucial to start with a simple setup to ensure basic functionality before integrating more complex logic. Follow the step-by-step guide below to debug issues with your EtherCAT network not reaching the OP state with SLRT:
.

Step 1: Start with a minimal model

Create a minimal model that includes only EtherCAT blocks, without any additional logic. The model's fixed-step size should be the same as the EtherCAT main cycle time. We recommend using the attached EtherCAT_Troubleshooting model:
This model showcases the new diagnostic blocks EtherCAT Get Emergency (R2023b+) and EtherCAT Get Scanbus Error Data (R2022b+). It also comes with the recommended settings for EtherCAT debugging:
  • 'Bus Shift DC' mode for synchronization.
  • 'DC Tuning' set to 'Small Model' in the EtherCAT Init block.
  • 'Force polling mode' enabled in model parameters.
  • 'DC Tuning' set to 'Small Model' in the EtherCAT Init block.
.

Step 2: Increase the cycle time

To initially get the network running, increase the cycle time in your EtherCAT configurator tool to a slower cycle time, such as 1 second or 500 milliseconds.
Impotant note: Every change in the configuration requires re-exporting the EtherCAT Network Information (ENI) file from the configurator tool (TwinCAT 3, EC-Master), and updating the EtherCAT Init block in Simulink. Use unique names for each .xml configuration file. Confirm that ALL subdevices reach OP mode in the configurator tool before exporting the ENI file (see this MATLAB answer). Before connecting Simulink to the EtherCAT network, ensure you have disconnected other tools from the network.
After loading the new ENI file, set the model's fixed-step size accordingly to match the reduced cycle time (1s or 500ms). With this slower cycle time, the network should reach the Operational (OP) State more reliably.

Step 3: Identify problematic EtherCAT subdevices

The network will reach the OP state only if all subdevices are confirmed to be in the OP state. Use EtherCAT Get Device State blocks to confirm this. If a single subdevice fails, investigate if it requires some configuration to reach a cycle time. Check the device manual or contact the vendor for assistance.
You can also try to manually send the '8' command to the network or single subdevices via an EtherCAT Set State and EtherCAT Set Device State blocks. As shown in the EtherCAT_Troubleshooting model, the EtherCAT Set State block must be within a triggered subsystem to ensure the command is sent only once per trigger event, avoiding unnecessary overhead caused by repeated commands at every sample time. Some networks or subdevices require a manual ‘8’ command to be sent after initialization phase.
If multiple devices fail to reach OP state, reduce your network to identify which EtherCAT subdevice is preventing the network from reaching the OP state. Start by removing any EtherCAT devices that aren't Beckhoff/Acontis devices. Re-scan the network in the configurator tool and re-export the ENI file to the Simulink model.
.

Step 4: Exchange data with subdevices

Once the network reliably reaches OP state, to confirm basic EtherCAT functionality, use PDO Receive / Transmit or CoE/SoE SDO Download / Upload blocks to exchange data with your subdevices. Make sure to place any Synchronous blocks inside Enabled Subsystems to enable or disable them as needed, as shown in the EtherCAT_Troubleshooting model. This allows on-demand usage of mailboxes and provides the capability to halt mailbox transactions gracefully before stopping the network.

Step 5: Reduce the cycle time and apply EtherCAT model best practices

Once the network operates correctly at a slower cycle time, and you can exchange data with the devices, gradually reduce the cycle time to the desired value. If issues arise, the following MATLAB answer has a list of strategies to possibly achieve faster cycle times (≤1ms, depending on the Speedgoat model and overall model complexity) with Simulink Real-Time:
For a deeper understanding of why your EtherCAT model does not reach the OP State when using DC synchronization, refer to the detailed article linked below. If your overall model is too complex, you might have to work on reducing its complexity and TET load, especially in the rate(s) used by the EtherCAT cycle(s).

More Answers (0)

Tags

No tags entered yet.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!