Overview
The Modbus Tutorial explains how to configure platform-to-device communication using the Modbus protocol. In the software platform, the Devices module manages communication with field devices through Channels, Nodes, and Points, allowing stable and secure data exchange between multiple devices across different networks.
The concepts presented apply to all communication drivers. You can define multiple protocol interfaces using abstraction layers like Channels and Nodes. The main difference between protocols is the syntax in some fields, but the configuration and testing procedures are similar for all communication protocol drivers.
Note that not all available protocols may be installed on your computer. Check the Communication Drivers page for more detailed information on what to do if you require a device protocol not listed on your system.
On this page:
Configuration Outline
Protocols define communication rules between the platform and devices. Channels define global parameters for the use of a communication protocol. Nodes represent physical field devices (like a PLC) with a unique field address (PrimaryStation). Points represent tags within a device. Additionally, AccessType defines how the device interacts with the platform (Read and/or Write). All initial configurations for devices in the solutions on the software platform follow this workflow:
Define a Channel using a target communication Protocol. It will create the base instance for linking a Node;
Define the Node linked to the created Channel;
Define the Point that you want to monitor.
Solution creation
Solutions refer to the applications developed on the software platform. Their purpose is to store all configuration information for applications. The solution saves its configuration in a file with the ".dbsln" extension, a database file that stores all configuration items of an application, such as tags, alarms, device configurations, graphical displays, scripts, etc.
You open the solution file in Solution Manager and edit the solution through the Solution Designer. These interfaces allow you to manage and design your solutions on the software platform. The Solution Designer organizes engineering configurations by modules, accessible on the left in the Solution Explorer menu.
Installing the software platform is the only requirement to create a solution. Once installed, go to Solution Manager and create a new solution to configure the device.
To create a new solution, in Solution Manager, at the top of the solution list, click the "New..." button to start the New Solution Wizard:
- Define the Product Series for your solution by selecting the product family and model.
- Define the target platform for your solution by selecting Windows or Multi-platform.
- Define the name and location for saving your solution file. Then, you can select a solution template and press the "Create New Solution" button, or simply press the button to create a new solution using a blank template.
Once created, go to Solution Manager and double-click to open it in Solution Designer.
After that, you can start the device configuration by creating a Channel.
Channels configuration
Channels refer to implemented communication protocol within a solution. Their purpose is to define global parameters for the protocol usage. They group the devices that use the same protocol logically.
Creating a Solution within the software platform is the only requirement for configuring a Channel in the Devices module using a standard protocol.
To create a new Channel, follow the steps:
On the Solution Designer, find the left menu, go to Devices, and expand it. There are two following ways to create a Device's Channel:
Go to Devices → Protocols, select the desired protocol on the main grid, then click the New Channel button to open the Create New Channel dialog.
Go to Devices → Channels, click the Add button on the grid's top-left to open the Create New Channel dialog.
In the Create New Channel dialog:
Select the Modbus Master Protocol.
Choose a name for the Channel.
Select the interface. For this tutorial, select TCPIP.
Press the OK button to create a Channel using the selected protocol.
It will insert a new line in the Channels data grid. Some configurations are accessible through the Channels data grid, such as ProtocolOptions, Channel Settings, Timeout, and InitialState options, which are detailed in the following sections:
Nodes configuration
Nodes refer to the individual representation of each physical device on the platform. Their purpose is to uniquely identify and address devices, allowing individual access and control.
Creating a channel within the solution is the only requirement for configuring a node in the Devices module.
To create a new node, follow these steps:
- In the Solution Designer, go to Devices → Nodes and click the "New" button to open the Create New Node screen.
- Select the previously created channel and click "OK."
This will insert a new line in the Nodes data grid.
After that, you must configure the PrimaryStation. To do this:
In Devices → Nodes, find the "PrimaryStation" column. This column contains the network IP and port needed to locate the device on the network. In the specific node you created, the PrimaryStation cell has a combo box to assist with this configuration.
The PrimaryStation configuration can change according to each protocol.
Points configuration
Points refer to specific tags within a device, such as a temperature value or an engine start command. Their purpose is to allow granular access to device data and functionalities, enabling the monitoring and control of each Point.
Creating a Node within the Channel and having a tag are the only requirements for configuring a Point on the Devices module.
To create a new Point follow the steps:
In the Solution Designer, go to Devices → Points, click on the first line of the data grid, and insert the tag name.
In the Node column, select the target Node and press Enter.
It will insert a new line in the Points data grid.
Some configurations accessible through the Points data grid, such as Address, DataType, AccessType, Modifiers, Scaling, and more, are detailed in the following:
Modbus Protocols
The Modbus communication protocols allow data exchange between Master and Slave devices. Each uses a specific protocol; therefore, there is one protocol for Masters and another for Slaves. Both protocols are available on the software platform. You can check and manage which protocols are available by clicking on the Product Series in Solution Manager. You can also check this in Solution Designer. To do so, go to Devices → Protocols or Devices → Channels. Both interfaces allow you to start device configuration by creating a channel using a target protocol.
The terminology Master and Slaves refers to outdated terms. The Modbus Organization announced the replacement of "master-slave" terminology with "client-server" in its communications protocol. The new nomenclature reflects the specific roles of the devices within the Modbus network. Here's a clearer explanation:
Modbus Master (Client): In the context of the Modbus protocol, the "master" is the device that initiates communications. It’s called a Client because it requests data from other devices. The master actively controls when and how data is requested and collected in the network.
Modbus Slave (Server): Slave devices are referred to as Servers because they serve data to the master upon request. They passively wait for requests and respond by sending the requested data or performing actions based on the commands received. They do not initiate communication; they only respond to the master’s requests.
Modbus Master
The Modbus Master protocol dynamically creates blocks based on the AccessType configurations set for each data point. It allows for selecting message encoding types such as ASCII, RTU, or RTU TCP - a combination of RTU and TCP/IP. It is worth noting that TCP/IP and UDP/IP are transport layer protocols in the OSI model.
The Modbus Master Protocol supports serial, multi-serial, and TCP/IP interfaces. This results in slight differences in some attributes for each supported interface. For example, considering the Modbus Master Protocol, the Settings column presents different parameters according to the selected communication interface. It happens on the Nodes, where the PrimaryStation settings differ according to each protocol. However, generally, the procedure is very similar, and most settings are the same.
Modbus Simulator
The Modbus Simulator is a tool for testing communication drivers. It simulates interactions between a software platform and field devices or other automation systems on a Modbus TCP/IP network. This ensures that components can communicate before deployment in a production environment.
In a Modbus network, a Channel is a communication path established by the Master to manage interactions with Nodes. The simulator enables the creation and configuration of Nodes, allowing testing of network scenarios and topologies without needing a physical network.
Each node within the network represents a device or a logical entity capable of communication via the Modbus protocol. Nodes can be configured within the simulator with communication properties such as IP addresses, ports, and device IDs. This feature allows for testing the integration and communication among devices and nodes without a physical environment.
Configuring and testing
The PrimaryStation defines the essential parameters for communication with a target device. In the context of this tutorial, the Modbus Simulator emulates a Master device in the Modbus Network.
Follow the steps to test communication:
Step 1: Run the Modbus Simulator before starting.
On Solution Designer, use the Solution Explorer to navigate to:
A. Devices/Channels: select a Channel created using the Modbus Master Protocol;
B. Devices/Nodes: select a Node linked to the created Modbus Channel;
The Modbus Simulator button will appear on the top of the data grid. Press the button to start the simulator.
Step 2: Configure and test PrimaryStation.
On Solution Designer, use the Solution Explorer to navigate to Devices/Nodes:
Select a Node linked to a created Modbus Channel;
Click the PrimaryStation cell to edit;
Change the default IP address
[192.168.0.1]
to[127.0.0.1].
Press the Test button to test.
Testing on Runtime
You can use a display to view and interact with device data to test communication with the device during the solution runtime. You can include the test tag that will reflect the data from a Modbus device and configure a "Set Value" action for the test tag. This will enable the manual setting of a new value to the test tag, helping to verify the communication between the solution and the device.
Diagnostic Tools
Diagnostic tools include Property Watch, Trace Window, and Module Information. These tools help identify communication blocks, address errors, provide property access to pinpoint error causes, and display system messages for device management and troubleshooting, offering a comprehensive approach to managing and troubleshooting solutions on the software platform.
Module Information
This tool provides insights into module operations and communication channels, offering information about virtual reading groups, error codes, and communication events. It helps users identify communication blocks and effectively address errors in industrial automation systems.
Property Watch
This tool enables users to access, read, and write tags and internal properties of the system. It assists in identifying the root cause of errors through negative error codes, allowing real-time adjustments and optimizations to the system configuration.
Trace Window
This tool displays system messages in a data grid interface, providing information about the status of reads, writes, and communication frames. It is particularly useful for various PLCs and communication protocols, as it presents invalid addresses in the configuration, assisting in device management and troubleshooting.
In this section: