The leader in industrial automation and control solutions

Before setting up a CODESYS project to communicate with an iR-ETN module, it is assumed that the development PC running CODESYS, the cMT device running the CODESYS runtime, and the iR-ETN module have all been connected via Ethernet and are on the same IP subnet. If this is not the case, the devices will be unable to communicate.

Connect iR-ETN to CODESYS

Follow these steps to connect an iR-ETN product to CODESYS.

  1. Add Device

    Right click on Device (Weintek Built-in CODESYS) and select Add Device
    Right-clicking the Device (Weintek Built-in CODESYS) gives you a popup menu; select the 'add device' entry.
  2. Add an Ethernet Adapter

    In the Add Device window, select Fieldbuses -> Ethernet Adapter -> Ethernet version 3.5.10 and click Add Device
    The iR-ETN is an Ethernet based device, so you’re selecting it via device type, not specific model number.
    In the Add Device window, select Fieldbuses -> Ethernet Adapter -> Ethernet version 3.5.10 and click Add Device
  3. Select ‘Device’ from the newly added Ethernet Adapter

    Right click on the newly added Ethernet adapter and select Add Device:
    Once the Ethernet Adapter has been added, we need to now reference the actual iR-ETN
  4. Choose MODBUS TCP Master

    Select Fieldbuses -> Modbus -> Modbus TCP Master -> Modbus TCP Master and click Add Device
    As the iR-ETN uses the MODBUS TCP Protocol, the CODESYS project needs to identify it by the protocol.
    Selecting the Modbus TCP Master Fieldbus entry. As the iR-ETN uses the MODBUS TCP Protocol, the CODESYS project needs to identify it by the protocol.
  5. Add a MODBUS TCP Slave device, nested under the Master device created in the previous step

    Select the new Modbus TCP Master device, then select Fieldbuses -> Modbus -> Modbus TCP Slave -> Modbus TCP Slave and click Add Device
    Select the new Modbus TCP Master device, then select Fieldbuses -> Modbus -> Modbus TCP Slave -> Modbus TCP Slave and click Add Device
  6. Enter the IP Address

    Double click the newly added Ethernet adapter to open the Ethernet device configuration. In the General tab, enter the IP address and Subnet mask to match your iR-ETN’s configuration
    This is the Ethernet Adapter, the first device that was added (the iR-ETN itself).
    Defining the IP address of the iR-ETN (the base device in this nested tree we just created
  7. Enable Auto Reconnect of MODBUS TCP Device

    Double click the Modbus TCP Master device and navigate to the ModbusTCPMasterParameters tab and set AutoReconnect to TRUE
    Enabling Automatic Reconnect of the Modbus_TCP device. Double click the Modbus TCP Master device and navigate to the ModbusTCPMasterParameters tab and set AutoReconnect to TRUE
  8. Select the network interface corresponding to the iR-ETN IP.

    With CODESYS connected to the base device, i.e. Device (Weintek Built-in CODESYS), click […] in the Ethernet device General tab and select the Network interface corresponding to the Ethernet device’s IP address
    click […] in the Ethernet device General tab and select the Network interface corresponding to the Ethernet device’s IP address
  9. Change ‘Unit ID’ of MODBUS TCP Slave Device

    Double click on the Modbus TCP Slave device and go to the ModbusTCPSlave Parameters tab. There, change the Unit-ID Parameter to match the Unit ID on the iR-ETN module
    Change the Unit-ID Parameter of the Modbus TCP Slave Device. This Unit ID parameter should match the Unit ID of the iR-ETN.
  10. Add a tag to the MODBUS Device

    To add a tag to the Modbus device, go to the Modbus Slave Channel tab and click Add Channel to open the Modbus Channel window. Select the access type to match the data type of the tag.
    In this case, a bool-type tag is being added, so the Read Discrete Input type is used
    Adding a BOOL type tag, using the "Read Discrete Input" type.
  11. Add the same tag to the CODESYS program

    Double click on PLC_PRG in the Devices pane and add a Boolean tag
    Adding the same BOOL tag to the CODESYS program that we just created in the Modbus device.
  12. Connect the tag references

    With the tag added, double click on the Modbus TCP Slave device once more, go to the ModbusTCPSlave I/O Mapping tab, expand the Variable tree entirely and click the […] button to connect it to the new read Boolean tag
    Linking the two instances of the BOOL tag we created, from the Modbus Slave device entry.
  13. Attach the tag

    In the Input Assistant window, select Application -> PLC_PRG -> read to attach the read Bool tag to the Modbus channel created prior.
    Finally, attaching the Read tag to the CODESYS program.