Example Code

EtherCAT Programmatic and Static I/O Access Benchmark Example Code

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.

    Hardware

  • NI-9144

Code and Documents

Attachment

Description

Overview

 

The attached code shows four different ways to read data from a 9144 EtherCAT Slave Chassis and conducts benchmark tests for relative speed. These examples build on the "Configure Scan.vi" included in EtherCAT Programmatic Slave and Module Discovery.

 

Description

 

There are four VIs included in the project that each implement a different method for reading from the 9144. Here is a summary table of the relative access speeds obtained on a 9074 chassis:

 

VI used Access Method Average Access Time
Programmatic Access by Individual Channel.vi Programmatically reading each channel inside a for loop 43.10 ms
Static Access.vi Individual Shared Variable nodes 15.27 ms
Programmatic Access by Entire Module.vi Programmatically reading the entire module all at once 10.98 ms
Raw Data Access.vi Raw Data Mode using RawData.Read Method 4.85 ms

 

 

Steps to Implement or Execute Code

 

  • Setup a cRIO or PXI EtherCAT master following the instructions in the EtherCAT KnowledgeBase article
  • The example is configured for a cRIO. If a PXI is used the project must be modified.
  • Connect an 9144 EtherCAT Slave to the EtherCAT Master
  • Open the attached "EtherCAT Static VS Programmatic.lvproj"
  • Open "Programmatic Access by Individual Channel.vi" and observe the method used to read data from the chassis.

 

Programmatic Access by Individual Channel.png

 

    • Note that the programmatic method of discovering modules is used and then each channel is individually read in a nested for loop. This is the slowest method of reading data from an EtherCAT slave.
    • If you are using modules differnt from the 9425, 9485, 9213, and 9221, you will need to add an appropriate case to the case structure.
  • Go through each of the four example VIs and run them. You will probably need to edit "Static Access.vi" to include the correct shared variable nodes for the corresponding I/O module.
  • Compare the relative speeds of the four examples and post your configuration and results in the comments!

 

 

Requirements

Software

  • LabVIEW 2010 or above
  • Industrial Communications for EtherCAT 2.3 or above

Hardware

  • cRIO or PXI with two Ethernet NICs
  • 9144 EtherCAT slave

 

Support and Contact

This add-on is provided as open-source software.  If it does not meet your exact specification, you are encouraged to modify the source code to meet your needs.  It is not officially supported by National Instruments.

 

National Instruments does not support this code or guarantee its quality in any way. THIS EXAMPLE PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).

 

 

 

 

Joey S.
Senior Product Manager, Software
National Instruments

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