Project conversion using the example of Modbus

Initial state:
In this example, an e!COCKPIT project is converted, consisting of a PFC200 (750-8212) as the master with a connected CANopen coupler (750-352) as the slave. There are three I/O modules plugged into the coupler: a 2-channel digital input module (750-400), a 2-channel analog input module (750-469) and a 2-channel analog output module (750-550). You can see the data points of these three I/O modules in the fieldbus configurator under “Local Bus Data Points.” These data points were mapped to master variables by dragging and dropping them.

Modbus Project in e!COCKPIT
Modbus Project in e!COCKPIT

In brief:
In the following description, you perform the following steps in CODESYS: You delete the slave device and update the master device. Global Modbus variables are retained. You then recreate the Modbus structure with the master and slave in the device tree and recreate the I/O image (channels, length of input/output data depending on I/O modules). You then reassign the existing global Modbus variables.

  1. First delete the slave device. It contains no data you will need.
  2. The required Modbus variables are generally created globally. In the device tree under “Application” > “Modbus,” you will find a structure that shows these globally stored variables:
  3. Global Variables via Modbus
  4. For the new slave that you will create, you will reuse these variables and assign them to the input/output data of your I/O modules in CODESYS.
  5. First, right-click on the device and select Update Device ... to load the device description for the device.
  6. Select your device from the list and click the [Update Device] button.
  7. The fieldbus elements are removed. However, the global variables are retained.
  8. Now recreate the master and the slave. To do so, right-click on the device and select Insert Device ....
  9. Leave the dialog open for the next three steps and click [Insert Device] to insert the “Ethernet” fieldbus, as well as the master and the slave inserted below it:
    - First select the “Ethernet” fieldbus in the dialog.
    - Click on the new “Ethernet” element in the device tree and select the Modbus master in the dialog.
    - Click on the new “Modbus_TCP_Master” element in the device tree and select the Modbus slave in the dialog.
  10. This procedure creates the following structure in the device tree:
  11. Modbus Master with Modbus Slave
  12. Double-click on the slave (“Modbus_TCP_Slave” element).
  13. The configuration opens.
  14. Click “Modbus Slave Channel” and click the [Add Channel ...] button there on the bottom right.
  15. Adding “Modbus Slave Channel”
  16. Set the channel, access type and length for reading and writing according to the I/O modules you use.
    Here, for example, the “READ Register” is set to a length of 3 (one 2-channel DI + one 2-channel AI) and the “WRITE Register” to length 2 (2-channel AO).
  17. Click “Modbus TCP Slave I/O Mapping.”
  18. You now see the channel and variables that were created. You will remap/reassign the global variables of the I/O modules to these.
  19. To do so, in the corresponding variable field, click the [...] button that appears to the right to open the Input Assistant.
  20. Under “Application” > “Modbus” > “FC_ETHERNET_G3_tcp,” you will find the global variables for selection.
  21. Performing the Mapping
  22. Go through these one by one to recreate your slave from the e!COCKPIT project in this way.
  1. Assigning Variables
  2. This completes the conversion.


Please note the following restrictions in CODESYS as opposed to e!COCKPIT:

• Modbus RTU and UDP are currently not supported in the configurator. However, you can use MODBUS functions for RTU and UDP via the IEC library “WagoAppPlcModbus”.
• Specific TCP/IP parameters (Keep Alive, Type of Service) are not supported.
• Function code FC22 (masking of registers) is not supported.
• Nor is function code FC66 (polling of larger amounts of data in one request).
• Device-specific special registers are not supported.
• The MODBUS service is only available when the PLC application is running.