EtherNet/IP Scanner - Explicit Mode

Within EtherNet/IP (ENIP), the explicit message connection can be thought of as a client/server relationship. The client which is called a Scanner, such as the PLC controller, asks or requests the information from the server which is called an Adapter. The Adapter can be a VFD field device, and the adapter sends the requested information back to the controller.

Because the Scanner requests the information from the adapter via TCP/IP services, the request has all the information needed to respond explicitly to the message. The Scanner basically says, “Adapter, I need this information, formatted exactly as specified in this message, please send it.”

The Adapter responds with a message containing the formatted information, perhaps setting the VFD speed set point.

This configuring and monitoring ability, common to explicit messaging, works well for non-real time messaging as the Scanner can send a message request anytime, and the Adapter (field device) can respond when its available.

Note

Explicit messaging utilizes the TCP protocol and is typically used for client/server communication which is not time critical, but insuring that the communications packet is received is paramount.

Project Scope

This project will setup an ENIP Master or Scanner on the P2CDS-622 talking to a Raspberry Pi that is configured as the target or Adapter.

We will utilize the two explicit commands- Get_Attribute_Single to access data in the server and Set_Attribute_Single to control a variable in the Adapter.

This project will demonstrate:

  • Adding a EtherNet/IP Master fieldbus to the project.

  • Configuring the fieldbus parameters for connection.

  • Example program code that will write and read access a servers/slave’s Object in Explicit Unconnected Messaging mode.

  • Illustrate the normal operation visual aspects.

The objects within the Server we will access are the Identity Object (Class 0x01h) and the Assembly Object (Class 0x04h).

The IDENTITY Class Object (0x01h) is defined as follows:

Instance
  • Identity - ID 0x01h

Attributes
  • Vendor ID - ID 0x01h

  • Device Type - ID 0x02h

  • Product Code - ID 0x03h

The ASSEMBLY Object (0x04) is defined as follows:

Instance
  • Output Buffer - ID 0x64h

  • Input Buffer - ID 0x65h

Attributes
  • Get/Set - ID 0x03h

Services
  • Get Single - ID 0x0Eh

  • set Single - ID 0x10h

Create/Import the Scanner P2CDS-622 Project

Caution

To do this project, the steps outlined in the previous section Preparation have to be completed successfully.

Two projects are provided in an Archive format. One is the Scanner or Originator that will run on the P2CDS-622 and the Adapter that will be hosted by a Raspberry Pi unit.

The Scanner project provided is downloadable below in an *Archive* format. It is the Scanner or Originator that will run on the P2CDS-622.

Download here-ENIP ExplicitScanner project

The Adapter or Target is provided also for reference and was run on a Raspberry Pi 4 Model B using an evaluation license from CODESYS that can be found here https://us.store.codesys.com/codesys-control-for-raspberry-pi-sl.html.

The downloadable RPi Adapter project- is here- RPI Adapter.

Start CODESYS and Create a Project

Start CODESYS

(1). Start CODESYS from the Start menu (by default, the path is Programs > CODESYS (version).

You can also click the CODESYS icon that is located on the desktop after installation.

Import the project

Tip

If you want to start a project from scratch, do not import the project and just follow the steps in the next sections.

(2). With CODESYS IDE launched, click File > Project Archive > Extract Archive. Select all options in pop-up. Click “yes” on next pop-ups.

Update everything (including Library’s) to latest revisions. You may need to add a Library, e.g. Basic OSCAT.

Your Project Tree view should look something like the image below with the Name of your project and the associated Device (P2CDS622) as the target.

alternate text

The default Base (P2-04B) is inserted in the tree with no modules added yet, i.e. <Empty>. If your hardware topology is a different Base, see the section below on changing the Base type.

The elements of the project tree can be investigated further by going to the Help section online by pressing <F1> in the device tree area and searching for a specific item of interest.

Project Comments

Tip

The following steps are for a guide to show you how to create your own project in lieu of the completed Demo project.

Network Configuration “NetConfig”

(3). Setup Ethernet ports by adding the NetConfig functionality per NetConfig

Fieldbus Comm Port: “Ethernet”

The first step in adding the ENIP fieldbus is to instantiate an Ethernet port, assign it to the applicable P2CDS-622 port.

  • Ethernet Port: Add Device > Fieldbus > Ethernet Adapter > Ethernet

  • Assign IP Address: Ethernet > General > Browse

The edits that are required are as follows:

  • Under the General tab, select the applicable Ethernet port out of the P2CDS-622. The IP address should match the expected.

EtherNet/IP Originator: “EtherNet_IP_Scanner”

Next the ENIP Master/Scanner is added.

(4). Right click on Ethernet: Add Device > Fieldbus > EtherNet/IP Scanner > EtherNet/IP Scanner

The edits that are required are as follows:

  • (use defaults)

EtherNet/IP Target: “Generic_EtherNet_IP_device”

The Generic adapter will be added. NOTE: if you have the connected device/adapter’s EDS file it can be imported into the Device Directory and then added in lieu of “generic”

(5). Right click on Ethernet_IP_Scanner: Add Device > Fieldbus > EtherNet/IP Remote Adapter > Generic EtherNet/IP device

The edits that are required are as follows:

  • Under General tab, assign the IP Address that corresponds to the connected Adapter.

  • All other items can be default.

Program “PLC_PRG”

The program that has been provided is comprised of two sections.

Section 1 - Read the Adapter data
  • Use the getAttributeSingle Explicit service (Code 0x0E) from the EtherNet/IP Library located at

The number of bytes to receive in this example is three(3) and are stored in local variables bTempMotor1-3.

The function is executed whenever startEIP is enabled.

Section 2 - Write out to the Adapter
  • Use the setAttributeSingle Explicit service (Code 0x0E) from the EtherNet/IP Library.

The variable bScannerWriteVar is incremented to be able to see the variable changing and be verified at the Adapter also.

The function is executed whenever startEIP2 is enabled.

Create/Import the Adapter Raspberry PI Project

The second project is the Adapter or Target and is provided also for reference. It is targeted for the Raspberry Pi 4 Model B using an evaluation license from CODESYS that can be found at RPi License

Start CODESYS and Create a Project

(As in the above example)

Fieldbus Comm Port: “Ethernet”

The first step in adding the ENIP fieldbus is to instantiate an Ethernet port, assign it to the applicable P2CDS-622 port.

  • Ethernet Port: Add Device > Fieldbus > Ethernet Adapter > Ethernet

  • Assign IP Address: Ethernet > General > Browse

The edits that are required are as follows:

(6). Under the General tab, select the applicable Ethernet port out of the P2CDS-622. The IP address should match the expected.

EtherNet/IP Target: “EtherNet_IP_Adapter”

Next the ENIP Target/Adapter is added.

(7).Right click on Ethernet: Add Device > Fieldbus > EtherNet/IP > EtherNet/IP Local Adapter Scanner > EtherNet/IP Adapter

The edits that are required are as follows:

  • (use defaults or General can be modified as desired)

EtherNet/IP Target: “Generic_EtherNet_IP_device”

The Generic adapter will be added. NOTE: if you have the connected device/adapter’s EDS file it can be imported into the Device Directory and then added in lieu of “generic”

(8). Right click on Ethernet_IP_Adapter: Add Device > Fieldbus > EtherNet/IP > EtherNet/IP Module > EtherNet/IP Module

The edits that are required are as follows, under the “Assemblies” tab:

  • The Consuming Assembly (Scanner data –> Adapter) with Object ID of 0x64h. One(1) variable, single byte.

  • The Producing assembly (Adapter data –> Scanner) with Object ID of 0x65h. Three(3) variables, single byte.

  • Additional items could be added if desired.

In the “EtherNet/IP Module I/O Mapping” tab, variables have been assigned to the respective assembly.

Program “PLC_PRG”

The program that has been provided reads in the Scanner data ( bMotor_VoltSet ) and writes three bytes out to the Scanner. ( bTemperature_Motor11-3 ).