03/25/2026
How-to | PLC Engineering | CODESYS | Ethernet/Ip

Explicit CIP Messaging between ctrlX CORE (Adapter) and a Rockwell PLC (Scanner) using the CODESYS Ethernet/IP Adapter

Overview

In this example we will go through the necessary steps to establish CIP messaging between an ctrlX CORE (Ethernet/IP Adapter) and a Rockwell PLC (Scanner). The exchanged data will be a double integer array.

Explicit CIP messaging is a non-time-critical, request/response-based communication method in EtherNet/IP used for setup, configuration, and diagnostics. It uses TCP for reliable, asynchronous data transfer, requiring explicit addressing (Class, Instance, Attribute) to access specific device data, unlike real-time cyclic I/O messages.

Pre-Requisite

Exercise

Step 1: Add required libraries

Add required libraries (see Figure 1.1) to your existing ctrlX PLC Engineering project from the above mentioned how-to article. Library versions are dependent on your ctrlX PLC Engineering version.

Figure 1.1: Required Libraries

Step 2: Add CipObjectDintArray10 function block

Add CipObjectDintArray10 function block to your ctrlX PLC Engineering project by selection "Application" in your "Devices" explorer window and select "Project Menu -> Import PLCopenXML". The xml file can be found under the attachment section.

Step 3: Check CipObjectDintArray10 function block

Open the newly created CipObjectDintArray10 function block. The CIP Instance and Class IDs can be set under the VAR section as well as the type of the Value, which defines the exchanged data. This function block was written in such a way where any data type can be used either as a single entity or as an array, as long as the size limit is observed.

Warning: The value's (exchange data) size cannot exceed 468 Bytes!

Figure 3.1: CIP Object VAR section

Step 4: Create a program

Create a program POU under your application and schedule it in a task. Copy the declaration and implementation sections from the text boxes below. This will register our CIP Object under the Ethernet/IP Adapter at startup.

VAR
	bInit : BOOL;
	CipObject1 : CipObjectDintArray10;
END_VAR
IF NOT bInit THEN
	EtherNet_IP_Adapter.RegisterCIPObject(CipObject1);
	bInit  := TRUE;
END_IF

Step 5: Download PLC project

Download the PLC project to your ctrlX CORE.

Step 6: Create Studio5000 logic

Create the logic (see Figure 6.1) within your Studio5000 project.

Figure 6.1: Studio5000 code for CIP Messages.

Step 7: Set MSG instructions

Set MSG instructions as shown in Figure 7.1, 7.2, 7.3 and 7.4.

Both MSG instructions' path has to be set to the ctrlX CORE's name under the hardware tree.

Figure 7.1: MSG instruction's path.

For reading / receiving we use Get Attribute Single Service Type with the previously configured Class and Instance IDs. The attribute must be set to 3. The destination element must match the previously set Value type.

Figure 7.2: Get Attribute Single MSG.

For writing / sending we use Set Attribute Single Service Type with the previously configured Class and Instance IDs. The attribute must be set to 3. The source element must match the previously set Value type.

Figure 7.3: Set Attribute Single MSG.

The Source Length must match the Value's size, which is 10 x 4 = 40 in this example.

Figure 7.4: Set Attribute Single MSG's Source Length.

Step 8: Download Studio5000 project

Download your Studio5000 project.

Step 9: Randomize data array

Set random numbers to your ctrlxDintSent data array.  Set WriteCtrlxDint bit high. Make sure the sending MSG instruction's DN bit becomes true, which is indicates that the data exchange between the ctrlX CORE and the Rockwell PLC was successful. Trigger the read MSG instruction. You should have the same numbers in both DINT arrays.

Figure 9-1: Data sent / received.

Step 10: Verify data

Verify that the same data appears on the ctrlX CORE's side.

Figure 10.1: ctrlX CORE's data.

Summary

You can duplicate the CipObject function block if you need to send different type of data, even User Defined Data Types (DUT Structure). Just change the Instance ID and Value's type as needed. Make sure you create the same data structure on the Scanner's side and verify that the data type and size match for a successful CIP data transfer. The CIP Object must be registered at startup!

Strings can be difficult to send / receive as the String data type structure is different in CODESYS from Rockwell's. Contact me for a workaround.

CipObjectDintArray10.xml
15.36KB
Types
How-to
Products
Controls
IOT

Latest published/updated articles