Modbus TCP

Modbus TCP

Modbus TCP, a widely used communication protocol in industrial automation and control systems, is designed to establish a connection between a server device, typically possessing input/output (I/O) capabilities, and a client device, such as a computer or a programmable logic controller (PLC), over a TCP/IP network.

In a Modbus TCP configuration, data is stored in a structured format known as registers within the server device. These registers are categorized into different types, including input registers, and holding registers, which house various data types such as sensor readings, control values, or status information.

Requests to interact with a Modbus TCP server are initiated by the client device through Modbus TCP messages. These messages encompassspecific function codes and address references, enabling the reading or writing of data to and from the registers of the server. This facilitates efficient and reliable data exchange within an industrial network.

Additional features supported by Modbus TCP include error checking and exception handling, ensuring the integrity and reliability of data transmission. The protocol permits the transmission of both single and multiple requests within a single TCP packet, optimizing communication efficiency.

With Modbus TCP, the monitoring and control of diverse devices within a network become easily achievable, allowing for real-time data retrieval and remote-control capabilities. The protocol's versatility and extensive adoption make it a valuable tool for the integration of various devices and systems within industrial environments.

There are some important concepts and terms:

Master Device: The master device initiates communication with slave devices by sending requests for data or issuing commands. The master device is responsible for sending Modbus TCP messages to the slave device and receiving responses. The Modbus TCP message sent by the master device includes a unit identifier, a function code, and data.

Slave Device: The slave device responds to requests from the master device and provides data or performs commands as directed. The slave device is responsible for processing the Modbus TCP messages received from the master device and sending responses. The response sent by the slave device includes a unit identifier, a function code, and data.

Registers: Registers are a type of data storage in Modbus TCP that hold data values such as integers or floating-point numbers. Registers can be read or written by the master device. Modbus TCP supports different types of register data, such as holding registers, input registers, and coil registers.

Coils: Coils are another type of data storage in Modbus TCP that hold binary data values, such as on/off states or boolean values. Coils can be read or written by the master device.

Function Codes: Function codes are codes that define the type of Modbus request being made by the master device. Different function codes are used for reading or writing registers and coils. Modbus TCP supports various function codes, such as function code 3 for reading holding registers and function code 5 for writing a single coil.

Unit Identifier: The unit identifier is a field in the Modbus TCP message that identifies the slave device being addressed by the master device. The unit identifier is used to ensure that the correct slave device responds to the request.

Transaction Identifier: The transaction identifier is a field in the Modbus TCP message that uniquely identifies each request and response pair. This is used to ensure that responses are matched with the correct request.

Data Length: The data length field specifies the number of bytes in the data field of the Modbus TCP message. The data length field is used to ensure that the correct amount of data is sent and received.

Error Codes: Error codes are codes that are returned by the slave device to indicate that an error occurred during the request. Error codes can provide information about the type of error that occurred. Modbus TCP supports various error codes, such as error code 2 for illegal data address and error code 3 for illegal data value.

To check if you have access to the relevant device, you can perform a network test using the Network test feature within Maestro, as described in section 2. This will allow you to verify the connectivity.

To establish a connection with Modbus TCP, there are specific parameters that must be filled by the user. These parameters, along with their corresponding data types, are crucial for technical users who are setting up a Modbus TCP connection. It outlines the specific parameters required and their corresponding data types, which must be correctly entered to successfully establish a connection with Modbus TCP.

Modbus

Host

Server Host

String

Port

Server Port

Int

SlaveID

Slave node ID to connect to

Int

RequestTimeout

Request timeout in seconds

Int

UserName (Optional)

Username to connect to server

String

Password (Optional)

Password to connect to server

String

Inputs

Connection Inputs

List

Outputs

Connection Outputs

List

 

Once the connection with the Modbus TCP source has been successfully established, the "input" page is used to define the data. This step involves specifying the necessary details related to the data or dataset, including its format and structure. It is crucial to accurately enter all the relevant information on the "input" page to ensure the proper handling and processing of data within the Modbus TCP network.

 

To retrieve data from a register using Modbus, you need to start by selecting a function. The available functions include "Read Coils," "Read Holding Registers," "Read Input Registers," and "Read Discrete Inputs." Choose the appropriate function for reading the desired register.

Next, specify the data type of the information you want to retrieve. Enter the address of the register you wish to read. Depending on whether the first register index of the connection is 0 or 1, the address may vary. It is recommended to verify the first register index and enter the address accordingly. Indicate the number of words or data to be read from the specified address.

Use the "Read" button to initiate the data retrieval process from the selected address. It provides a convenient way to verify the successful exchange of data between the client and server within the Modbus TCP network.

Input

DataType

Type of data

String

Address

Address

Int

WordCount

Word Count

Int

SelectedFunction

Selected Function

String

 

To transfer the data package created by the user to a destination in the Modbus TCP network, it is necessary to define an output. By choosing the "Create Output " option, users can create a new register the Modbus TCP network. This process involves specifying the necessary details such as the register address, data type, and size, as well as any specific configuration parameters or constraints required for the register.

It is essential to accurately enter all the relevant information when creating or modifying a register in the Modbus TCP network to ensure proper data storage and retrieval. This includes providing the correct register address, selecting the appropriate data type and size to match the intended data, and considering any limitations or constraints that may apply.

By following these steps and accurately defining the output, users can successfully transfer data from the Modbus TCP client device to the designated location or register within the Modbus TCP network.

Output

Address

Address

Int

Quantity

Quantity

Int

SelectedFunction

Selected Functiom

String

Values

Output Values

List

 

Values

Address

Address

Int

Value

Value

String

 

2. Testing the Connection

Before attempting to establish a connection with a Modbus TCP server, it is important to ensure that the client device has the necessary network access to reach the server. This may involve configuring firewalls or adjusting network settings to enable communication between the client and the Modbus TCP server, depending on the specific network setup.

Once the network access is confirmed, you can proceed with providing the required information to establish the Modbus TCP connection. This typically includes details such as the server's IP address or hostname and the corresponding port number. Additionally, you may need to specify the unit or device ID if multiple devices are connected to the Modbus TCP network.

In cases where the desired data or registers are not yet available, you may need to configure the Modbus TCP server to create or modify the necessary registers. This process may involve granting appropriate permissions and configuring the server to store the relevant data in the appropriate register types, such as input registers or holding registers.

By carefully and accurately completing these steps, you can establish a successful connection with the Modbus TCP server, enabling you to effectively monitor and control the connected devices and access the desired data.

 

2.1 Maestro Network Test

A Network Test can be performed with Maestro to verify the accessibility of the desired device. As outlined in section 2.1 of the user manual, the Network Test feature allows users to establish data flow by entering the host and port information of the device.

To check the connectivity, the host and port details of the intended device should be entered. For example, if data communication with a device located at IP address 192.168.3.24 using Modbus is desired, the host should be set as "192.168.3.24," and port 502 should be used for Modbus communication.

Once the host and port information is entered, the Test button can be clicked to initiate a Telnet connection check with the target device. This Telnet test will determine whether there is a successful connection to the desired device.

If the Telnet test yields a successful response, indicating a successful connection, a "Connected" pop-up will be generated on the right side of the screen. This confirmation signifies that the connection has been established and validated.

By following the steps outlined in the user manual and performing the Maestro Network Test, users can effectively verify the accessibility and connectivity of the desired device. This process ensures that data flow can be established and maintained as required.



    • Related Articles

    • Modbus

      Modpoll is a command line-based Modbus master simulator and test utility utilizing the FieldTalk™ Modbus driver. To check Modbus connection using modpoll: cd modpoll cd x86_64-linux-gnu/ ./modpoll -t 1 -a 50 -c 2 -r 4 -m tcp 192.168.110.128 Parameter ...