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:
-
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:
-
Connect your PC to the iR-ETN or iR-ETN40R and open an instance of EasyRemote IO:
-
Click the the “Automatic Scan” or “Scan” button and a popup will appear:
-
Within this popup, click the “Scan” button to find the iR-ETN or iR-ETN40R:
-
When found, the iR-ETN or iR-ETN40R will display within the white dialog box:
-
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.
-
Click “Ok” to add the iR-ETN or iR-ETN40R to the EasyRemote IO project:
-
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.
-
When finished, select the “Download All” button to download these settings to the coupler:
-
To add the IO to Codesys, click on “Export PLCopenXML” within the “File” tab:
-
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.
-
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.
-
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:
-
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.
- Note: The “CODESYS login” option may reside within the “Network” settings menu: Tutorial.
-
Open the Codesys IDE and create a new “Standard project” or open an existing project:
-
When prompted, ensure that “Weintek Built-in CODESYS” is selected:
-
Within the project tree, double click “Device (Weintek Built-in CODESYS)”:
-
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.
-
Within the following menu, enter the IP address of the HMI’s LAN-2 port:
-
The HMI will append to the Gateway instance:
-
While the HMI is selected, click on the “Set Active Path…” button:
-
Within the project tree, right-click “Device (Weintek Built-in CODESYS)” and select “Add Device…”:
-
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.
-
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.
-
Within the “Add Device…” menu, click “Close”. Then, within the “Project” tab click “Import PLCopenXML”:
-
Locate the PLCopenXML file generated by EasyRemote IO and click “Open”:
-
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”.
-
Double-click on the “Ethernet” device within the project tree and click on the ellipses within the following menu:
-
Within the “Network Adapters” menu, please select eth0 and click “OK”:
-
Double-click on the “Modbus TCP Master” device in the project tree and ensure that “Auto-reconnect” is selected:
-
Double-click on the “iR-ETN" or “iR-ETN40R" in the project tree and configure the "Unit-ID” to 1 if prompted:
-
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 .
-
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:
-
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.
-
When the project is finished, right-click on “Application” and within the “Add Object” list click “Symbol Configuration…”:
-
When prompted, click “Add”:
-
Select “Build” within the following menu to verify that the application is error-free:
-
Ensure that each tag that you wish to export is selected within this list:
-
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.
-
Before you save and exit the application, please click the “Login” button to download this project to the HMI:
-
If prompted to “proceed with download” click “Yes”:
Note: Subsequent changes may display the following menu. If prompted, ensure that “Login with download” and “Update bootproject” are enabled.
-
Click the “Start” button to place the Codesys application in “RUN” mode:
EasyBuilder Pro:
-
Open an instance of EasyBuilder Pro and select the HMI that you will use within this application:
-
Once open, select the “New Device/Server” button within the “System Parameters”:
-
Within the following menu, click on the center of the “Device type” drop-down list:
-
A popup dialog will appear, within this dialog please search for and select the “Weintek Built-in CODESYS” driver and then click “OK”:
-
Configure any additional settings and then click “OK” once more:
-
While the “Weintek Built-in CODESYS” driver is selected click on the “Import Tags…” button:
-
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”:
-
Locate the .xml tag file titled “[PROJECT NAME].Device.Application.xml” and click “Open”:
-
The following popup will display, click “OK”:
-
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.