Communicating with EtherCAT Devices in Vision Builder AI

Publish Date: Aug 29, 2016 | 1 Ratings | 4.00 out of 5 | Print | Submit your review

Goal

Use the Modbus-TCP capabilities of Vision Builder AI to connect to an Anybus X-Gateway capable of Modbus-TCP to EtherCAT slave data transfer in order to quickly and easily share data with EtherCAT devices. 

Overview

Vision Builder for Automated Inspection (Vision Builder AI) can be configured as a Modbus server that holds a table of local registers which can be read from and written to using a TCP connection. Use a Modbus Slave inspection step to update local registers on the Modbus server in Vision Builder AI.

The gateway acts an intermediary between the Modbus server and the EtherCAT network by simultaneously configuring itself as a Modbus client and EtherCAT slave.  Polling of the Modbus server allows the gateway to update the values it broadcast to the EtherCAT network.  Polling the Modbus server also updates the server registers with any new values received by the gateway from the EtherCAT network.

Each Modbus read and write transaction performed by the gateway is configured using the gateway’s web interface which is automatically mapped to an EtherCAT I/O.  Configuration of the EtherCAT master allows the I/O data published by the gateway to be transmitted around the EtherCAT network.

 Figure 1. Example Network Overview

Table of Contents

  1. Setup
  2. Starting the Vision Builder AI Modbus Server
  3. Adding a Modbus Slave Inspection Step
  4. Configuring the Anybus X-Gateway
  5. Testing the Modbus-TCP Connection
  6. Configuring the EtherCAT Master
  7. Testing the EtherCAT Connection

 Setup

This tutorial provides step by step instructions for connecting an NI Smart Camera to an Anybus X-Gateway that communicates with a simulated EtherCAT Master on the host PC. The tutorial uses TwinCAT System Manager provided by Beckoff to simulate the EtherCAT Master. To complete this tutorial the following hardware and software is required.

·         NI Smart Camera (optional)

·         Vision Builder for Automated Inspection

·         Anybus X-Gateway: Modbus-TCP to EtherCAT

·         Anybus IPconfig Utility (available for download at www.anybus.com)

·         EDS file for the X-Gateway (optional, available for download on the product page at www.anybus.com)

·         TwinCAT (available for download at www.beckhoff.com)

·         Host PC with at least two Ethernet ports

·         Internet Explorer 7.0 or 8.0

Additional configuration manuals and tutorials for the gateway can be located at www.anybus.com.

Figure 2 provides an overview of the fully configured testing setup. This tutorial assumes that an NI Smart Camera hosts the Modbus Server. You can also use an Embedded Vision System or the host PC to host the Modbus Server.

Figure 2. Test Setup Overview

Starting the Vision Builder AI Modbus Server

Complete the following steps to enable the Modbus Server in Vision Builder AI.

1.     Launch Vision Builder AI.

2.     Select the Smart Camera that will host the Modbus Server and communicate with the EtherCAT network, as illustrated in Figure 3.  The Vision Builder AI welcome screen only lists a target if the same version of Vision Builder AI is installed on the target. Vision Builder AI only lists targets that share a subnet with the host PC and targets explicitly added using the IP address. If no targets are available, you can select My Computer for testing purposes. 

Figure 3. Selecting a Vision Target on the Vision Builder AI Welcome Screen

3.     Select New Inspection. The Configuration Interface appears. 

4.     Select Tools»Communication Device Manager to open the Communication Device Manager, as illustrated in Figure 4

Figure 4.  Accessing the Communication Device Manager

5.     Click New Device to open the New Communicator Device dialog box.  Enter a Device Name and select Modbus TCP in the Protocol list, as illustrated in Figure 5.

 Figure 5. Configuring a New Modbus TCP Device

6.     Click OK to create the device and return to the Communication Device Manager. 

7.     Click Start Server to start the Modbus Server. The Modbus Server status changes to running, as illustrated in Figure 6.

8.     Click OK to close the Communication Device Manager return to the Configuration Interface.

Figure 6. Enabling the Modbus Server

Adding a Modbus Slave  Inspection Step

Use a Modbus Slave inspection step to update local registers on the Modbus server in Vision Builder AI. Complete the following steps to add a Modbus Slave step to the current Vision Builder AI inspection.

1.     In the Inspection Steps pane, navigate to the Communicate tab and click the Modbus Slave step, as illustrated in Figure 7. The step opens for configuration.

Figure 7. Modbus Slave Step Located on the Communicate Tab

2.     Enter a Step Name.

3.     Click Write Registers.  The Write Local Register dialog box appears.

4.     Configure the register with the following settings, as illustrated in Figure 8.

a.     Select Numeric Constant and enter a value of 2.

b.     Select Holding Registers in the Table list.

c.     Enter 0 as the Start Address.

d.     Select 16-bit Unsigned Integer in the Type list.

Figure 8. Write Local Register Dialog Box

5.     Click OK to close the Write Local Register dialog box.

6.     Repeat steps 3, 4, and 5 to add two additional local write registers, specifying unique values for the Numeric Constant and Start Address controls. Figure 9 illustrates three write registers with unique addresses and values.

Figure 9. Modbus Slave Inspection Step Configured to Write Values to Three Unique Registers

7.     Click View Local Registers to confirm that the write transactions have been configured correctly. The Modbus Local Registers Terminal dialog box displays the current values of the Modbus server’s registers.  If the holding registers are not displayed, select View»Holding Registers.  Figure 10 illustrates the holding registers for the local write registers illustrated in Figure 9.

Figure 10. Holding Registers for Three Unique Local Write Registers

8.     Close the Modbus Local Registers dialog box.

9.     Click OK to save the Modbus Slave step settings.

10.   Select File»Save and save the Vision Builder AI inspection to the target.

 Configuring the Anybus X-Gateway

Use the Anybus IPconfig utility that ships with the X-Gateway to perform network discovery for the gateway.  The utility and user manual are available for download from the Anybus product page.  Complete the following steps to perform network discovery and configure the gateway.

1.     Install and launch the IPconfig utility.

2.     Click Scan.  The utility displays the network settings for the gateway, as illustrated in Figure 11.

Figure 11.  Gateways Located by Scanning with the Anybus IPconfig Utility

3.     Open Internet Explorer. The Anybus web configuration utility requires Internet Explorer 7 or Internet Explorer 8. If you have a different version of Internet Explorer, contact Anybus for support.

4.     Type the gateway IP address in the address bar to navigate to the web configuration utility, as illustrated in Figure 12.

Figure 12.  X-Gateway Web Configuration Interface

 

5.     Click the Modbus Client link at the left of the page under Configuration.

6.     Configure the following settings, as illustrated in Figure 13.

a.     Select Enabled in the DHCP list.

b.     Select Enabled in the Anybus IPconfig (HICP) list.

c.     Select Running in the Start-up operation mode list.

d.     Select Freeze data to Modbus servers in the When EtherCAT (Network1) is not exchanging I/O data list.

Figure 13.  Modbus Client Configuration Page

7.     Click the Modbus Server link at the left of the page under Configuration.

8.     Click Add New Server

9.     Click the Edit link for the new server.

10.   Configure the following settings as illustrated in Figure 14.

a.     Enter SmartCamera as the server Alias

b.     Enter the IP address of the Smart Camera running the Modbus server as the Server address.

Figure 14.  Editing the Modbus Server Configuration

11.   Click OK to save the server settings. 

12.   Click the Transactions link for the server. The transactions link is located to the right of the Edit link. Use the Transactions page to configure read and write transactions with the Smart Camera running the Modbus server. 

13.   Click Add new transaction three times to create three transactions, as illustrated in Figure 15.

Figure 15.  Adding Three Server Transactions

14.   Click the Edit link for the first transaction. 

15.   Configure the following settings. Use the default values for all other settings. The final setting configuration is illustrated in Figure 16.

a.     Enter Input1 as the transaction Alias.

b.     Select 3-Read Holding Registers in the Function code list.

c.     Enter 1 as the Starting address.

d.     Select uint16 in the Data Type list.

e.     Enter 1 as the number of Elements.

16.   Click OK to save the transaction settings.

Figure 16.  Editing Server Transactions

17.   Click Edit and configure the following settings for the second transaction:

a.     Enter Output1 as the transaction Alias.

b.     Select 6-Write Single Register in the Function code list.

c.     Enter 2 as the Starting address.

d.     Select uint16 in the Data Type list.

e.     Enter 1 as the number of Elements.

18.   Click OK to save the transaction settings.

19.   Click Edit and configure the following settings for the third transaction:

a.     Enter Input2 as the transaction Alias.

b.     Select 3-Read Holding Registers in the Function code list.

c.     Enter 3 as the Starting address.

d.     Select uint16 in the Data Type list.

e.     Enter 1 as the number of Elements.

20.   Click OK to save the transaction settings. Figure 17 illustrates the updated server transactions.

Figure 17.  Server Transactions after Configuration

21.   Click the X-gateway Management link at the left of the page under Tools.

22.   You must reboot the gateway before your changes can take effect. Click Apply to apply the changes and reboot the gateway.

Figure 18.  X-Gateway Management Page

 

 Testing the Modbus-TCP Connection

After restarting the gateway, complete the following steps to confirm communication between the gateway and the Modbus server.

In the Anybus web configuration utility click the Transaction Monitor link, at the left of the page under Tools.

The read transactions should reflect the values in register 1 and register 3, as illustrated in Figure 19. If the read transaction shows a value of 0, confirm that the Modbus server is running on the Smart Camera and that the registers have been updated using the saved Vision Builder AI inspection.

Figure 19.  X-Gateway Transaction Monitor Page

Notice that the write transaction writes a default value of 0 to register 2.  Complete the following steps to confirm that this write command was successfully received by the Modbus server running on the Smart Camera.

1.     Return to Vision Builder AI.

2.     In the Configuration Interface, select Tools»Modbus Local Register Terminals to view the local registers. Figure 20 illustrates the Modbus Local Registers Terminal dialog box.

Figure 20.  Modbus Local Register Terminal

Registers 0x0000 and 0x0002 retain the values that were written by the Modbus Slave step in the Vision Builder AI inspection.  If register 0x0001 holds a value of 0, the gateway and the Modbus server can communicate and the gateway has overwritten the previous value.

 Configuring the EtherCAT Master

Complete the following steps to use TwinCAT software to simulate an EtherCAT master on an available Ethernet port on the host PC. 

1.     Download TwinCAT software from www.beckhoff.com. Install and use the most recent, compatible version of the TwinCAT software. This tutorial uses TwinCAT version 2.11 R3 Build 2224.

2.     Select any installation configuration but ensure that TwinCAT System Manager is selected for installation.

3.     Place the X-Gateway EDS file in the <TwinCAT>\Io\EtherCAT folder, where <TwinCAT> is the location to which you installed the TwinCAT software.  The EDS file is an XML configuration file that is available for download from the X-Gateway product page on the Anybus website.

4.     Launch the TwinCAT System Manager.

5.     Select Options»Show Real Time Ethernet Compatible Devices, as illustrated in Figure 21.

Figure 21.  Selecting Compatible Ethernet Devices in the TwinCAT System Manager

6.     In the Ethernet Adapters tree, as illustrated in Figure 22, select the Ethernet device you wish to use for EtherCAT. You can select adapters listed under Compatible devices or Incompatible devices. The categories differ only in performance.

7.     Click Install.

Figure 22.  Selecting Compatible Ethernet Devices in the TwinCAT System Manager

8.     Wait for the EtherCAT driver installation to complete and close the Installation of TwinCAT RT-Ethernet Adapters dialog box.  

9.     In the TwinCAT System Manager, select I/O Devices, as illustrated in Figure 23.

10.   Click Scan sub devices in the toolbar, as illustrated in Figure 23.

Figure 23.  Scanning for Sub Devices on the TwinCAT System Manager

11.   Select the Ethernet interface you wish to use and click OK, as illustrated in Figure 24.

Figure 24.  Selecting the Ethernet Interface

12.   Select Yes when prompted to scan for boxes (or slaves).

13.   Select Yes when prompted to activate free run. Activating free run switches to operational mode.

Complete the following steps If you did not copy the EDS file to the T<TwinCAT>\Io\EtherCAT folder.

1.     Select the gateway in the tree control, as illustrated in Figure 25.

2.     Click the Process Data tab.

3.     Click Load PDO info from device

4.     Click Reload I/O Devices in the toolbar.

5.     Select Yes when prompted to activate free run.

Figure 25.  Setting Up the EtherCAT Slave I/O without the XML File

Testing the EtherCAT Connection

Complete the following steps to confirm that an output value written to the gateway is updated on the Modbus server.

1.     In the TwinCAT System Manager, navigate to I/O – Configuration»I/O Devices»Device #»Box # (gateway) »DO RxPDO-Map»Output1 in the tree control, as illustrated in Figure 26. 

2.     Click the Online tab.

Figure 26.  Accessing the EtherCAT Output

1.     Click Write to open the Set Value Dialog dialog box. 

2.     Enter 7 as the Dec value.

3.     Click OK to close the Set Value Dialog dialog box.

Figure 27.  Changing the Output Value on the EtherCAT Slave

1.     Return to Vision Builder AI.

2.     In the Configuration Interface, select Tools»Modbus Local Register Terminals to view the local registers.

If register 0x0001 holds a value of 7, as illustrated in Figure 28, output values written to the gateway are updated on the Modbus server.

Figure 28.  Modbus Local Registers with Values Updated from EtherCAT Master

Back to Top

Bookmark & Share


Downloads


Ratings

Rate this document

Answered Your Question?
Yes No

Submit