How do I detect if an EtherCAT device is added to my network using EtherCAT Get Notifications?

1 view (last 30 days)
I have an EtherCAT network with multiple subordinate nodes. I want to be able to detect when a subordinate node is added in real-time, so that I can react to this change in my Simulink Real-time model. How can I get this information about the EtherCAT network in my model?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 21 Jun 2023
Edited: MathWorks Support Team on 22 Jun 2023
You can use the 'EtherCAT Get Notifications' block. This block allows you to monitor the status of your network, and can be used to react to changes in your network in real-time. 
Since EtherCAT networks can get quite complex, there may be multiple signals from this block that are important to monitor, and often determining the best way to react to a change in the network requires analyzing the log for specific patterns when changes in the network occur.
That being said, the following code may be useful for detecting if a new subordinate device is added in the network:
(262148): HC topology change done
The example below demonstrates how to detect a failure in the network and restart the network once the failure is corrected. To be able to react to different network scenarios, modify the example's 'MATLAB Function' block to react to the desired message(s) outputted by the 'EtherCAT Get Notifications' block.
Additional Resources:
EtherCAT Get Notifications block:
Description of notification codes:

More Answers (0)

Community Treasure Hunt

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

Start Hunting!