How to connect an iR-ETN or iR-ETN40R to Codesys

Introduction:
Weintek’s iR-ETN and iR-ETN40R support Modbus TCP and EtherNet/IP allowing easy integration with Codesys. To facilitate this process, Weintek has developed EasyRemote IO, a utility that will allow you to search for and modify parameters within our Ethernet-based IO couplers. Within this post, you will learn how to add an iR-ETN or iR-ETN40R as a Modbus TCP slave within your Codesys project.

Software Version:
Codesys IDE 3.5.15.50
Codesys package
EasyRemote IO 1.4.7.3+

Instructions:
Unlike the use of EtherNet/IP, Modbus TCP does not require you to update the the firmware of your device. However, you will need to install our Codesys package and an instance of the Codesys IDE.

Codesys install:

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

EasyRemote IO:

  1. While the coupler is powered off, connect the iR-ETN or iR-ETN40 to the iR Series IO couplers that you intend to use within this project:
    image

  2. Connect your PC to the iR-ETN or iR-ETN40R and open an instance of EasyRemote IO:

  3. Click the the “Automatic Scan” or “Scan” button and a popup will appear:

  4. Within this popup, click the “Scan” button to find the iR-ETN or iR-ETN40R:

  5. When found, the iR-ETN or iR-ETN40R will display within the white dialog box:

  6. If your PC has a different IP subnet than the iR-ETN or iR-ETN40R, use the “Modify” button to change the IP address of the coupler:
    Note: If the iR-ETN cannot be found when using the “Scan” utility, please follow the instructions within this post to add the iR-ETN and connected IO to EasyRemote IO.

  7. Click “Ok” to add the iR-ETN or iR-ETN40R to the EasyRemote IO project:

  8. Select an IO module and click on the “Parameter” tab to configure the module specifications:
    Note 1: Click or set a value within the “Project Value” column to configure the module settings.
    Note 2: For more infomration related to IO parameters, please see this post.

  9. When finished, select the “Download All” button to download these settings to the coupler:

  10. To add the IO to Codesys, click on “Export PLCopenXML” within the “File” tab:

  11. Configure the “Export file version” to 3.5.15.0 and ensure that you’ve installed the latest Codesys package:
    Note: If you have not installed the recommended version of Codesys and the latest Codesys package, Codesys may not recognize the iR-ETN or iR-ETN40R as a Modbus TCP slave device.

  12. Uncheck “Init” and ensure that only certain parameters you would like made available within the PLC are selected:
    Example: The “Life Guard time” can be re-initialized within the Codesys project.

  13. Click “Ok” to save this file when finished and connect the iR-ETN or iR-ETN40R to the HMI’s LAN-1 port.

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:
    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 is installed with Weintek’s Codesys package, 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 a “Modbus TCP Master” with version 3.5.15.0 and click the “Add Device…” button in the bottom right corner:
    Note: This driver is installed with Weintek’s Codesys package, however, you may need to select the “Display all versions” check box to view this driver.

  12. Within the “Add Device…” menu, click “Close”. Then, within the “Project” tab click “Import PLCopenXML”:

  13. Locate the PLCopenXML file generated by EasyRemote IO and click “Open”:

  14. Ensure that the “Modbus_TCP_Master” is selected and click “Ok”:
    Note: If “Modbus_TCP_Master” is not selected the dialog will state that “There are no objects in the export file which can be imported at the currently selected location”.

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

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

  17. Double-click on the “Modbus TCP Master” device in the project tree and ensure that “Auto-reconnect” is selected:

  18. Double-click on the “iR-ETN" or “iR-ETN40R" in the project tree and configure the "Unit-ID” to 1 if prompted:

  19. To map a variable to an I/O point, declare the variable within a POU, GVL, or PVL:
    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 .

  20. Once a variable has been declared, select the “ModbusTCPSlave I/O Mapping” tab within the iR-ETN or iR-ETN40R 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:
    Note: If the variable mapped to an IO point is not used within the ladder, the data within the IO point will not be polled by the PLC.

  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:

  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 that 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.