Explicit Messaging EtherNetIP Example Using Micrologix 850
Explicit Messaging EtherNetIP Example Using Micrologix 850
communicate with a YRC1000 by EtherNet/IP Explicit Messages. This PLC uses Connected Component
Workbench (CCW) to do the programming, which is completely different from Studio 5000, RSLogix
5000, or RSLogix 500.
The exercises below show how to exchange a D-Variable between the robot controller and PLC. Both
send and receive (to different variables). Other communication formats and structures are left to the
user.
The approach is the same as other Explicit Message examples. With some caveats:
The CCW software takes all data as decimal, while the robot manual lists some of these fields as
hexadecimal (and previous Studio 5000 software took the data as hexadecimal.) This note
applies to the “Service” and “Class” fields of the CIPAPPCFG data structure:
The IP address format is different. If you read the manual it seems to explain this a little, but
just do what is shown. The path starts with “4,” then the IP address of the robot controller:
o You can reuse the same CIPTARGETCFG variable in all AOI/Function Blocks for CIP Comm
in your project.
The Returned data and Sent data must be BTYE ARRAY (or USINT – also 8 bit), nothing else is
allowed.
o This means some math, byte copying, other byte shift merging techniques are needed
when sending data larger than 8 bits back and forth or dealing with data types other
than 8 bits.
o The complexity of dealing with P-Variable structure is NOT shown in this document. It’s
possible to do this data exchange, as we’ve shown with Logix 5000, but based on the
complexity of populating and/or deconstructing the data structure after utilizing the
MSG instruction and being forced into a Byte Array just makes things difficult – as you
will see in the simple case of a DINT.
In my opinion probably better for the user to just step up to a better PLC instead
of spending the extra time jumping through programming hoops.
The first example here is to read a D variable. A D-variable is 32 bits long, or 4 bytes. A byte array of
length 4 was defined to hold the return value.
Once the data is retrieved, I wrote some logic to rebuild it. For this example I only handled 2 bytes,
doing the full math of all 4 bytes is left to the end user following this example:
Data in YRC1000:
Data in PLC:
56,789
Next, try to write data from the PLC to the YRC100
In this example data was just loaded into each byte. In your own example you will need to break up the
DINT, essentially in reverse of the math done in the previous example. This results in the following data
being sent to the robot controller:
A new rung is created, with own AOI / function block variable, the “Control” and “Target” variable was
reused. But the AppConfig variable is new, such that the Service Code can be set specifically for the
Read request. Reference the EtherNet/IP LAN port manual for service codes for each variable type.
NOTE – the robot manual will mention the values as Hex, but this software expects Dec data.
After executing the rung successfully, expect to see this Data in YRC1000:
(20 x 256) + 11 =
5131