Connecting Controller (Master) to Controller (Slave)

The basic procedure largely corresponds to the description in Connecting Controller (Master) to Fieldbus Coupler (Slave). The main difference is the assignment of the direction of communication. This is not assigned automatically, since programmable devices can perform both master and slave functions. Thus the roles must be set. Furthermore, the data points of programmable slave devices must be created and configured for the communication.

Place Devices on the Communication View

  1. Select the controllers from the product catalog and use the mouse to drag them into the Network view (communication view).
Drag Devices into the Network View
Drag Devices into the Network View

Configure I/O Modules Used in the Device Detail View

  1. Open the Device Detail view (in either graphical and tabular view) by double-clicking the controller.
  2. Arrange the I/O modules used analogously to your hardware by dragging them from the product catalog and positioning them after the device.
  3. Drag I/O Modules into the Network View
  4. Parameterize the I/O modules as needed by selecting them and making changes on the “Settings” panel for each.
  5. Go back to the Network view.
  6. Proceed in the same way with the second device.

Connect Devices

First consider which device should serve as the master and which as the slave, since the order in which you connect the devices to each other is relevant to the device roles. The connection line starts at the master and ends at the slave.

  1. Click the gray connector (ETHERNET/Modbus) of the Master in the Network view (communication view) and hold down the mouse button.
  2. Drag the connection onto the connector of the Slave of the same type and release the mouse button as soon as a green plus symbol appears.
  3. Connect Devices
  1. The devices are connected. The arrow of the connection line indicates the device roles you have assigned: The connection line starts at the master and ends at the slave.
Direction of Communication: Master → Slave
Direction of Communication: Master → Slave

Tip: You can change the master and slave device roles later as needed. Click the Modbus connector of one of the two devices and then click [Communication Relationship]. The current communication relationship is highlighted in blue and displayed first. If necessary, select another entry.

Change Communication Relation/Direction
Change Communication Relation/Direction

Set the Protocol for the Connection

  1. To set the protocol for the connection, click the [Protocol] button in the context menu of the Modbus connector or connection.
  2. Select the desired connection (in this example: “Modbus (TCP)”).
Select Protocol
Select Protocol

The selection options depend on the devices used.

Make the Device Settings on the “Settings” Panel

You can change the settings or parameters of the devices that have been added on the “Settings” panel. The panel is open by default. If it is not, open it using the context menu of the device and the [Settings] button.

Open the “Settings” Panel
Open the “Settings” Panel
  1. Select the device in the network view.
  2. The tabs, entry screens and selection fields on the “Settings” panel depend on the specific device. The settings options displayed depend on the content of the particular device description file.
  3. Make all the general settings concerning the device, PLC and local bus on the first tabs. For example, you can change the IP address.
  4. Make Modbus settings on the “Modbus” tab.
  5. Make General Modbus Settings
  6. Proceed in the same way with the second device.

Program Application

  1. Select the controller (master).
  2. Open the “Program Structure” panel by clicking the [Program Structure] button on the “VIEW” tab of the menu ribbon.
  3. Open “Program Structure” Panel
  4. Create your program (in the main “PLC_PRG” program or in a POU).
  5. Compile and validate your program on the “PROGRAM” tab with [Compile].

Configure Slave

You configure the slave in the data point configurator.

  1. To switch to the data point configurator, double-click the Device tile of the slave device.
  2. The Device Detail view appears. The Modbus data point configurator opens on the “Modbus Slave” tab of the Device Detail view.
  3. Open Data Point Configurator
  4. Now specify which data points the slave should make available via the fieldbus. The following options are available and are explained below:
    • Use existing variables from the application
    • Use variables from I/O modules
    • Create generic data points

Use Existing Variables from the Application:

Since a programmable device is used as a slave in this case, the slave’s data points consist of variables of the slave application, among other things. These can be selected and created directly from the application.

  1. In the “Program variables” context menu, click [Add from Program].
  2. Select an existing variable from the slave’s application.
  3. Note: Simple data types are transferred directly via Modbus, while complex data types (including structures) are mapped to word arrays. These are then transferred via Modbus instead. If the data type used is known globally in the project, the master can directly access the individual elements of the complex variables, although Modbus does not use such a data type itself (see also Access to Simple and Complex Data Types).
  4. Select Variable from Application
  5. Transfer this with [OK].
  6. Select the direction of communication (Input, Output or Input / Output).
  1. Select Direction of Communication
  2. You can use the new data point.

Use Variables from I/O Modules:

  1. In order to use variables from I/O modules of your application, first switch to the “Local Bus I/O Mapping” tab in the data point configurator.
  2. In the Device Detail view, select the I/O module whose variables you want to access.
  3. Select I/O Module
  4. Create variables for the individual channels of the I/O modules (here “var1” and “var2”).
  5. Create Variables
  6. These variables are available globally.
  7. Switch back to the data point configurator by clicking on the controller and then on the “Modbus Slave” tab.
  8. In the “Program variables” context menu, click [Add].
  9. Add Variables
  10. A new data point, “ModbusDataPoint,” is created.
  11. Switch to the slave’s application and assign the local bus variable of the I/O module to the data point that was created.
Mapping the Local Bus Variable to the Data Point
Mapping the Local Bus Variable to the Data Point

Note

Always map variables of I/O modules via newly created data points!

For variables of I/O modules, use the [Add] button (as described above), not [Add from Program].
Although you can also select the variable with [Add from Project] (the variable is shown under “Program variables”), this method does not allow access, since the variable is already accessed via the local bus. .

When you click [Generate Code], a corresponding message is output in the message window:

var1: map to existing variable with address is not allowed!

Therefore, only use [Add from Program] for application variables, not for variables of I/O modules.

Create Generic Data Points:

There are applications in which it makes sense to use generic data points. For example, you can group multiple data points into one register. You can then access them from different masters without having to create manual channels for every access point in the master.

  1. To create new generic data points, click [Add] in the context menu of “Generic Data Points.”
  2. Add Generic Data Points
  3. If necessary, change the data type and Modbus address.
  4. Select Data Type and Modbus Address
  5. In the context menu of the variable, click [Edit] and, if necessary, modify further settings, such as function code settings.

Note: Generic data points are not available via the slave application.

Configure Connection between Master and Slaves

You can configure the connection between the master and slaves in the fieldbus configurator. Here you primarily make connection settings, display variables to transfer and create new variables.

  1. Click the Modbus connector of one of the two connected devices.
  2. Open the Modbus fieldbus configurator by clicking the [Configurator] button.
  3. Open Fieldbus Configurator
  4. The fieldbus configurator opens. The connection is shown in the header section of the configurator. If multiple slaves are connected to one master, you can modify the selection under “Selected Connection.”
  5. The fieldbus configurator is divided into two columns:
    The left side shows the variables that are transferred from the slave to the master via the bus.
    The right side shows the data points available on the slave. Besides “Program variables,” “Generic Data Points” and other standard variables that are automatically available to every Modbus slave (“WAGO Modbus special register”) are also shown here.
  6. In the right-hand column, select a slave data for the master to access.
    Tip: You can select multiple data points by holding down the Control key.
  7. Click [Map] in the context menu of the data point.
  8. Made Slave Data Point Available to Master
  9. The variable is generated in the master application. This establishes the connection to the slave data point.
  10. You see the slave data point (1), the variable that has been created on the master (2), the drop-down list for modifying the data type (3), the cycle time for updating variables via Modbus and (4) the type of Modbus access to the variables (5).

    ReadOnly (RO): Master reads the slave’s output
    WriteOnly (WO): Master writes to the slave’s output
    ReadWrite (RW): Master reads the output/writes to the input of the slave
  11. New Variable on the Master
  12. Change the cycle time (column T [ms]) to the required cycle time.
  1. You can now use the master variable in the master’s application.

Access Data Points

  1. Open the program structure and the main program of the master.
  2. Open the Master’s Main Program
  3. In the master’s application, the variable is accessed as shown in the following figure.
  4. Tip: Press the [F2] key to open the input assistant for easy variable selection.
  1. Access to the Variable of the Master Application
  2. In this way, an existing slave data point has been made accessible via Modbus and read out in the master application.