How to use Ethernet/IP within Codesys

Introduction:
In 2023, Weintek’s R&D purchased the Ethernet/IP license for our Codesys implementation. This feature should be available on HMI’s produced in late 2023. However, if you have an HMI that has Codesys firmware prior to 20230204, you may update the Codesys firmware via the instructions provided below and begin using the Ethernet/IP Scanner within the Codesys IDE.

Software Version:
Codesys IDE 3.5.15.50
Codesys package
[Optional] Codesys firmware

Important:

Weintek, like other vendors has validated certain drivers as compatible with our Codesys runtime. If you do not use the drivers and Codesys IDE recommended within this post, the application may produce compilation errors that will be difficult to resolve.

Device Version
Codesys IDE 3.5.15.50 [Download]
Ethernet adapter 3.5.15.0
Ethernet IP Scanner 3.5.15.50
Generic Ethernet IP device 3.5.15.0

Instructions:
Depending on when you purchased your HMI, you may need to update the firmware in order to use the Ethernet/IP scanner within Codesys. If you do not have the latest firmware you may see the image symbol next to the EtherNet/IP Scanner while logged in. To determine what version of Codesys firmware was installed on your HMI, please see the “Codesys and IO Firmware” section of this document. If your HMI utilizes a firmware version prior to 20230204, please follow the steps below to update the device firmware.

Firmware update:

  1. Connect your PC to the HMI’s LAN-2 port.

  2. Open the “Utility Manager”:
    image

  3. Ensure that the “Model” is set to “cMT X Series – Advanced” or “cMT X Series – Standard”:
    Note: Select “Advanced” for 3000 series HMIs like the cMT3072XH or “Standard” for 2000 series HMIs like the cMT2078X.

  4. Select the “Maintenance” tab and click on “CODESYS Firmware Upgrade”:

  5. Download the latest Codesys Firmware: Click Here

  6. Within the “CODESYS Firmware Update” popup menu, locate the .bin file retrieved in step 5, enter the HMI’s IP or use the “Search All” button to find the device, then click “Update”:

  7. When finished, close the utility manager.

Codesys install:

We highly recommend using Codesys 3.5.15.50 as the Ethernet/IP scanner within Codesys was validated within this version. To install Codesys, please see the section labeled “Where can I download Codesys?” in this post: Click here

EDS install:

To import the EDS file of an EtherNet/IP device, please use the following method:

  1. Open the Codesys IDE and select “Device Repository…” within the “Tool” tab:
    image

  2. Within the “Device repository” click on the “Install…” button to locate and install an EDS file:

  3. Click “Close” to close the “Device repository” when finished.

Codesys project:

  1. Connect your PC to the HMI as shown within this tutorial: Link
    Note: The location of the “CODESYS login” function may vary by device type and firmware. The three possible locations of this option are shown below.

    • Note: The “CODESYS login” option may reside within the “Network” settings menu: Tutorial.
    • Note: The “CODESYS login” option may reside within the “CODESYS” settings menu under the “Modify Ethernet(LAN1)” option: Tutorial.
    • Note: The “CODESYS login” option may reside within the “CODESYS” settings menu within the web server. Here is a link to a post in which we demonstrate how to access the HMI’s webserver: Link.
  2. Open the Codesys IDE and create a new “Standard project” or open an existing project:
    [Optional]: Download, open, and extract this project template and skip to step 12.
    image

  3. When prompted, ensure that “Weintek Built-in CODESYS” is selected:
    image

  4. Within the project tree, double click “Device (Weintek Built-in CODESYS”:
    image

  5. Select the “Gateway” and click “Add Device…”:


    Note: If the “Device” tab appears as depicted below, please enter the HMI’s LAN-2 IP into the entry box on the far right and click the [Enter] key. When finished, proceed to step 9.

  6. Within the following menu, enter the IP address of the HMI’s LAN-2 port:
    image

  7. The HMI will append to the Gateway instance:
    image

  8. While the HMI is selected, click on the “Set Active Path…” button:

  9. Within the project tree, right-click “Device (Weintek Built-in CODESYS)” and select “Add Device…”:
    image

  10. Within the following menu, select an “Ethernet” adapter with version 3.5.15.0 and click the “Add Device…” button in the bottom right corner:
    Note: This driver should come equipped with the recommended version of Codesys (3.5.15.50, however, you may need to select the “Display all versions” check box to view this driver.

  11. With the “Add Device…” menu still open, click on the “Ethernet” driver within the project tree and select an instance of an “EtherNet/IP Scanner” with version 3.5.15.50 and click the “Add Device…” button in the bottom right corner:
    Note: This driver should come equipped with the recommended version of Codesys (3.5.15.50, however, you may need to select the “Display all versions” check box to view this driver.

  12. With the “Add Device…” menu still open, click on the “EtherNet/IP Scanner” driver within the project tree and select the device that you wish to communicate with from the list of applicable device types. Then, click the “Add Device…” button in the bottom right corner:
    Note: If using the project template, please right click on “Ethernet_IP_Scanner” and select “Add device…” to view this menu.

  13. Click on “ENIPScannerServiceTask” and configure a valid “Priority”:

  14. Double-click on the “Ethernet” device within the project tree and click on the ellipses within the following menu:

  15. Within the “Network Adapters” menu, please select eth0 and click “OK”:

  16. [Recommended] Double-click on “Ethernet_IP_Scanner” and ensure that “Auto-reestablish connections” is enabled:
    Note: This step is required when using Weintek’s iR-ETN I/O coupler.

  17. Within the “General” tab of the EtherNet/IP device, ensure that the IP address has the correct configuration:

  18. While the “EtherNet/IP I/O Mapping” tab is selected within the EtherNet/IP device, the I/O mapping can be configured:

  19. To map a variable to an I/O point, declare the variable within a POU or GVL:
    Note: Here is an example in which we declare a variable within a POU and map it to I/O within a Modbus TCP slave: 4:32.
    image

  20. Once a variable has been declared, select the “EtherNet/IP I/O Mapping” tab within the EtherNet/IP device and double-click next to the desired I/O point in the “Variable” column. When prompted, click on the ellipses:

  21. Ensure that the desired project variable is selected and click “OK” to map this variable to the I/O point:

  22. When the project is finished, right-click on “Application” and within the “Add Object” list click “Symbol Configuration…”:

  23. When prompted, click “Add”:
    image

  24. Select “Build” within the following menu to verify that the application is error-free:
    Note: If you receive error(s) during the build sequence, please see this section: Link

  25. Ensure that each tag that you wish to export is selected within this list:

  26. Within the “Build” tab, click on “Generate code” and an .xml file called “[PROJECT NAME].Device.Application.xml” will be saved within the same folder as the project file. We will use this file to import tags into EasyBuilder Pro:
    Note: New tags do not automatically import into EasyBuilder Pro. If you create a new tag within your Codesys project and wish to access it from EasyBuilder Pro, ensure that each tag you wish to export is selected before selecting “Generate Code”. Then, import the .xml file into EasyBuilder Pro.
    image

  27. Before you save and exit the application, please click the “Login” button to download this project to the HMI:

  28. If prompted to “proceed with download” click “Yes”:
    image
    Note: Subsequent changes may display the following menu. If prompted, ensure that “Login with download” and “Update bootproject” are enabled.
    image

  29. Click the “Start” button to place the Codesys application in “RUN” mode:

EasyBuilder Pro:

  1. Open an instance of EasyBuilder Pro and select the HMI that you will use within this application:

  2. Once open, select the “New Device/Server” button within the “System Parameters”:

  3. Within the following menu, click on the center of the “Device type” drop-down list:

  4. A popup dialog will appear, within this dialog please search for and select the “Weintek Built-in CODESYS” driver and then click “OK”:

  5. Configure any additional settings and then click “OK” once more:

  6. While the “Weintek Built-in CODESYS” driver is selected click on the “Import Tags…” button:

  7. Within the following menu, select either “One char per word” or “Two char per word” depending on your preference of STRING representation, and click “OK”:

  8. Locate the .xml tag file titled “[PROJECT NAME].Device.Application.xml” and click “Open”:

  9. The following popup will display, click “OK”:
    image

  10. It is now possible to reference objects by selecting a tag within an object that corresponds with its data type. Here is a link to a tutorial in which we demonstrate how to assign an object to a tag and download this project to your HMI: 7:09
    Note: Within EasyBuilder Pro tags can be viewed and selected within an object. There is no utility that allows you to view all tags simultaneously.

Appendix:

A:

If you have also installed a later version of Codesys such as 3.5.17.X+, you may receive an error during the build sequence that is caused by a version of the “CommonPacketFormat Interfaces” library file that is incompatible with Codesys version 3.5.15.50. To resolve this this issue, please uninstall “CommonPacketFormat Interfaces, 4.2.0.0” within the Library repository:
image

  1. Within the “Tool” tab, click on “Library Repository…”:
    image

  2. Within the following menu, click “Find”:
    image

  3. Search for and open “CommonPacketFormat Interfaces”:
    image

  4. Uninstall version 4.2.0.0:
    image

  5. Click on the “Build” button and the errors may be resolved:
    image

B:

During the first build sequence, certain library errors may occur. These errors may be denoted with error code C0032. If you receive this error or others like it and if the “Library Manager” has a blue double underline image please utilize the “Download missing libraries” option to resolve this issue:

  1. Double click on the “Library Manager”:
    image

  2. Within the following tab, select “Download Missing Libraries” if available:

  3. Follow the prompts to download any missing libraries:

  4. When finished, click on the “Build” button to resolve any remaining errors:

1 Like