Creating a Simple Modbus Network

  1. Select two devices from the Product Catalog and drag them with the mouse into the Network view (Communication view).
  2. Dragging Devices to the Network View
  3. To change the settings or parameters of the devices added, click the respective device, open the “Settings” panel in the context menu and make your changes there.
  4. Opening the “Settings” Panel
  5. Now connect the devices. Click the gray connector (ETHERNET/Modbus) for one of the devices in the Network view (Communication view) and hold down the mouse button.
  6. To connect the devices to each other, drag the connection line to the same type connector of the second device. Release the mouse button as soon as a green plus sign appears.
  7. Establishing Network Connections
  8. The devices are connected. The role of the device defines the connection direction. The connection direction is indicated by an arrow and goes from master to slave.

    You can change the master and slave device roles later as needed:
  9. Click the Modbus connector of one or both devices.
  10. Click [Communication Relation] in the context menu.
  11. Select Communication Relation
  12. The current communication relationship is highlighted in blue and displayed first.
  13. Select the second entry as needed.
    In this example, you retain the communication relationship.
  14. You can also specify the connection protocol.
  15. Click the [Protocol] button in the context menu of the Modbus connector.
  16. Selecting the Protocol
  17. Select the required connection.
    In this example, select “MODBUS (TCP)”.
  18. The choices depend on the devices used.
    If your device can be used as a router for off-network devices, “Port forwarding” can also be selected (see Connecting Off-Network Devices (Port Forwarding)).
    You have defined the role of the device and the protocol used for the connection. Below you open the Modbus data point configurator.
    Use the data point configurator to define what slave variables should be available on the master.
  19. To open the Modbus data point configurator for the connection, double-click on the device tile of the slave device in the Network view (Communication view).
  20. The Device Detail view appears. The Modbus data point configurator opens in the “Modbus slave” tab.
    The figure below shoes the Modbus data point configurator after opening. No communication variables between the master and slave have been defined yet.
  21. Modbus Data Point Configurator
  22. To create variables, right-click “Program variables”.
  23. Click the [Add] button in the context menu.
  24. Creating New Variables on the Slave
  25. The variable has been created as a global variable in the slave application and can be used there.
    The table row displays the default values for Modbus access to the new variable.
  26. New Variable on the Slave (Default Values)
  27. To change the default values, double-click the individual fields “Direction”, “Variable”, “Data type”, etc.
  28. To make settings regarding the Modbus address, right-click on the row of the newly created variable.
  29. In the context menu, click [Edit] and adjust the settings as needed.
  30. Note

    Additional Information to “Generic data points”

    You can also create “Generic data points” in the same way as “Program variables”. The [Edit] button is used for generic data points and Modbus special registers to open a dialog with further setting options, e.g., for setting function codes.

    Generic data points and Modbus special registers are not available via the slave application: Modbus special registers are only available in the Modbus stack of the slave and accessible via Modbus only. There are application cases in which it makes sense to use generic data points. For example, you can group multiple data points into one register to access different masters without having to create manual channels for every access in the master.

  31. Go back to the Network view (Communication view).
  32. Below you open the Modbus fieldbus configurator. Mainly connection settings are made here, Modbus master variables displayed and created.
  33. Click the Modbus connector of one or both connected devices.
  34. Open the Modbus fieldbus configurator by clicking the button [Configurator].
  35. The Modbus fieldbus configurator for the master opens.
    The configurator is divided into two columns: The variables on the master are displayed on the left. The variables available on the slave and used in the slave application are displayed on the right. The tree displays them in a hierarchical view according to the program structure.
  36. Select the slave variable created in the right column.
  37. Note

    Simple and complex data types possible!

    I/O modules make their data available as individual variables. Some I/O modules also make data available as an array/structure. Depending on where and how deep you are in the tree structure of the fieldbus configurator and where you click [Map], you can either access the individual variables, arrays or the entire I/O module for these I/O modules. This option is available if a fieldbus coupler is used as the head station because it forwards data unchanged from the I/O modules via the bus and allows full access to the data structures of the I/O modules.

    Controllers, on the other hand, have the task of first processing data from the I/O modules and only passing on the result via the bus. Application variables ("Program variables") are linked within the application with data from the I/O modules and only then are they communicated via the bus. The configuration is therefore not created automatically.

  38. Note

    Tip: Providing i/o modules with all data points

    In addition to providing individual data points, some I/O modules*) can also be provided as a whole with all data points for the master. The data points of the I/O modules are accessed uniformly, regardless of whether the I/O modules are connected directly to the controller or are addressed remotely via Modbus. When the data points are provided, program blocks and instances of prepared function blocks are automatically generated, via which the data exchange is implemented. You can use these program blocks directly in your program without further adjustments.

    *) The provision of complete data structures is possible for those I/O modules whose associated function blocks offer an iPort for connections:
    0750-0636, 0750-0642, 0750-0643, 0753-1630, 0753-1631, 0753-0646, 0753-0647, 0753-0649, 075x-0482, 075x-0484, 075x-0493, 075x-0494, 075x-0495, 75x-0632, 075x-0635, 075x-0640, 075x-0644, 075x-0645, 075x-0650, 075x-0651, 075x-0652, 075x-0653, 075x-0655, 075x-0657, 075x-0658, 075x-0670, 075x-0671, 075x-0672, 075x-0673, 075x-0511, 075x-0633

  39. Click [Map] in the context menu of the variable.
  40. Creating a New Variable on the Master
  41. According to the path (namespace) in the slave application, the created slave variable is generated in the master application. It is then available on the master directly.

    The slave data point (1), the variable created on the master (2), the selection field for the data type (3), the cycle time for updating the variables via Modbus (4) and Modbus access to the variables (5) are displayed.

    ReadOnly (RO): Master reads the slave output.
    WriteOnly (WO): Master writes to the slave input.
    ReadWrite (RW): Master reads the slave output or writes to the slave input
  42. New Variable on the Master
  43. Open the “Program Structure” panel and the main program of the master.
Opening the Main Program of the Master
Opening the Main Program of the Master

In the master application, access to the “ModbusDataPoint” variable as shown in the following figure.

Tip: Press the [F2] key to open the Input Assistant for easy variable selection.

Accessing the “ModbusDataPoint” Variable in the Master Application
Accessing the “ModbusDataPoint” Variable in the Master Application

In this way, a variable has been declared in the slave application, made accessible via Modbus and read in the master application.

For additional information see: