Example Code

EtherCAT Monitoring and Recovery

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Operating System

  • NI Linux Real-Time

Code and Documents

Attachment

Description

We have developed an application that utilizes EtherCAT for bidirectional communication with a third-party slave device. 

One of our challenges was to monitor and recover EtherCAT communication between the master and slave devices through unplanned events such as out-of-order startup, power loss on one side of the communication link, temporary disconnection of physical wiring, or runtime software errors.

Our solution was to implement programmatic and automated detection and reset of a failed EtherCAT link.  During the operational state, we monitor the distributed clock SYNC0 signal.  We found that the slave device "DC.Sync0.Enable" property node returns a value of TRUE when the connection is functioning as desired.  The property node returns a value of FALSE if the connection is broken.

If the connection is broken, our LabVIEW EtherCAT state machine enters a "RESET" state, which is given in the attached VI.  We have found this code to work reliably for our purposes, but it has not been optimized.  Further research and testing may yield simplifications and elimination of unnecessary portions of the code.

We are using a cRIO-9048 that is running LabVIEW Real-Time 2024Q3 as our EtherCAT Master with the NI-Industrial Communications for EtherCAT driver.

blobid1780419239015.jpg

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.