EtherNet/IP Explicit Message Example: Read Modbus Object
(Original Document)
Overview
The following unconnected explicit messaging example shows you how to use the SEND_REQ function block to retrieve data from a remote device (for example a 140 NOC 771 01, a TSX ETC 101, or a BMX NOC 0401 Ethernet communication module) at IP address 192.168.1.102 using the Read_Holding_Registers service of the Modbus object.
You can perform the same explicit messaging service using the EtherNet/IP Explicit Message window of the Control Expert Ethernet Configuration Tool.
Implementing the SEND_REQ Function Block
To implement the SEND_REQ function block, you need to create and assign variables for the following blocks:
NOTE: In the above configuration, the target module is located at slot number 4.
Declaring Variables
In this example, the following variables are defined. You can, of course, use different variable names in your explicit messaging configurations.
Configuring the Address Variable
The Address variable identifies the explicit message originating device—in this example, the TSX ETC 101 communication module—and the target device. Note that the Address variable does not include the Xway address elements {Network.Station} because we are not bridging through another PLC station. Use the ADDR function to convert the following character string to an address:
ADDR(‘0.4.0’), where:
Configuring the ReqCode Variable
The ReqCode variable identifies the function type for the SEND_REQ function block—in this case, a CIP request:
Variable
Description
Value (hex)
ReqCode
Code identifies a CIP request
16#000E
Configuring the DataToSend Variable
The DataToSend variable identifies the type of explicit message and the CIP request:
Variable
Description
Value (hex)
DataToSend[0]
Message type:
  • 16#0000 (unconnected), or
  • 16#0001 (connected)
In this example, the message is unconnected.
16#0000
DataToSend[1]
First two octets of the target device IP address (192.168.1.102):
  • High byte = byte 4: 16#C0 (192 decimal))
  • Low byte = byte 3: 16#A8 (168 decimal)
16#C0A8
DataToSend[2]
Last two octets of the target device IP address (192.168.1.102):
  • High byte = byte 2: 16#01 (1 decimal)
  • Low byte = byte 1: 16#66 (106 decimal)
16#0166
DataToSend[3]
CIP request service information:
  • High byte = request size in words: 16#02 (2 decimal)
  • Low byte = service code: 16#4E (78 decimal)
16#024E
DataToSend[4]
CIP request class information:
  • High byte = class: 16#44 (68 decimal)
  • Low byte = class segment: 16#20 (32 decimal)
16#4420
DataToSend[5]
CIP request instance information:
  • High byte = instance: 16#01 (1 decimal)
  • Low byte = instance segment: 16#24 (36 decimal)
16#0124
DataToSend[6]
Starting register (for example, %MW255):
  • High byte = 16#00 (0 decimal)
  • Low byte = 16#FF (255 decimal)
16#00FF
DataToSend[7]
Number of registers to read:
  • High byte = 16#00 (0 decimal)
  • Low byte = 16#05 (5 decimal)
16#0005
Viewing the Response
Use a Control Expert Animation table to display the ReceivedData variable array. Note that the ReceivedData variable array consists of the entire data buffer.
To display the CIP response, follow these steps:
Step
Action
1
In Control Expert, select Tools → Project Browser to open the Project Browser.
2
In the Project Browser, select the Animation Tables folder, then click the right mouse button. A pop-up menu appears.
3
Select New Animation Table in the pop-up menu. A new animation table and its properties dialog both open.
4
In the Properties dialog, edit the following values:
Name
Type in a table name. For this example: ReceivedData.
Functional module
Accept the default <None>.
Comment
(Optional) Type your comment here.
Number of animated characters
Type in 100, representing the size of the data buffer in words.
5
The completed Properties dialog looks like this:
Click OK to close the dialog.
6
In the animation table’s Name column, type in the name of the variable assigned to the RECP pin: ReceivedData and hit Enter. The animation table displays the ReceivedData variable.
7
Expand the ReceivedData variable to display its word array, where you can view the CIP response contained in the ReceivedData variable:
Note: Each array entry presents 2 bytes of data in little endian format, where the least significant byte is stored in the smallest memory address. For example, ‘CE’ in word[0] is the lower byte, and ‘00’ is the upper byte.