Modbus TCP Complete Technical Guide

Modbus TCP is a communication protocol that uses the Transmission Control Protocol (TCP) for communication over Ethernet networks. It allows devices to exchange data seamlessly and efficiently within a TCP/IP network.

Modbus TCP Technical Guide

Modbus TCP is a variant of the Modbus communication protocol that utilizes the Transmission Control Protocol (TCP) for communication over Ethernet networks. This version of Modbus retains the core concepts of the original Modbus protocol while adapting to the capabilities and characteristics of Ethernet-based communication. Here’s a more detailed explanation:

  1. Encapsulation of RTU Packets: Modbus TCP encapsulates the Modbus RTU request and response data packets within TCP packets. These packets are transmitted over standard Ethernet networks. This encapsulation allows Modbus messages to be transported efficiently and reliably over Ethernet.
  2. IP Address as the Primary Addressing Method: In Modbus TCP, the primary means of addressing is the IP address. Unlike Modbus RTU, where the unit or slave address is crucial for identifying devices, the IP address takes precedence in TCP-based communication.
  3. Port Number: The standard port for Modbus TCP communication is port number 502. However, this port number can often be customized or reassigned according to the application’s requirements.
  4. Checksum Handling: The checksum field, which is typically included at the end of an RTU packet to ensure data integrity, is omitted from Modbus TCP packets. Ethernet itself handles error checking and checksum verification, simplifying the communication process.
  5. OSI Network Reference Model: Modbus TCP aligns with the OSI Network Reference Model. It defines the presentation and application layers within the OSI model, making it compatible with modern networking principles.
  6. Client-Server Model: In the context of Ethernet-based networking, the roles of master and slave in traditional Modbus terminology are replaced by the client-server model. The device acting as the slave becomes the server, and the device acting as the master becomes the client. Ethernet’s peer-to-peer communication allows multiple clients (masters) to interact with multiple servers (slaves).
  7. Logical Associations: Unlike the one-to-one relationship between master and slave in Modbus RTU, Modbus TCP allows for more flexible and dynamic logical associations. The system designer is responsible for creating connections between clients and servers to manage data exchange efficiently.
  8. Multiple Masters and Slaves: Modbus TCP permits the existence of multiple masters and slaves within the same network. This scalability facilitates the integration of complex systems with multiple devices.

Modbus TCP combines the robustness of the original Modbus protocol with the capabilities of Ethernet-based communication. It leverages the IP address, TCP protocol, and client-server model to enable efficient data exchange over Ethernet networks, making it suitable for modern industrial automation and control applications.

Types of Modbus Ethernet Connections

Modbus TCP and Modbus over TCP

Modbus Ethernet connections come in two main types: Modbus TCP and Modbus over TCP. While both are often referred to collectively as Modbus TCP, they have distinct characteristics:

  • Modbus TCP: This variant encapsulates Modbus TCP packets within a TCP layer. It utilizes the Ethernet protocol for communication.
  • Modbus over TCP: In this variant, Modbus RTU packets are enclosed within a TCP layer. Like Modbus TCP, it employs Ethernet as its underlying communication medium.

Advantages of Ethernet Connections

Ethernet connections offer several advantages over serial connections:

  • Faster Speed: Ethernet provides higher data transfer rates, although speed may not be critical for all Modbus devices, such as those reporting temperatures.
  • Enhanced Reliability: Ethernet connections are more reliable, contributing to improved overall communication stability.
  • Extended Distance: Ethernet allows data transmission over longer distances, compared to the limitations of serial connections.

Modbus TCP Features

Modbus TCP introduces specific features that enhance its capabilities:

  • Multiple Devices, Single Port: Modbus TCP enables multiple devices to share a single network port, optimizing resource utilization.
  • Modbus Application Protocol (MBAP) Header: Each Modbus TCP message includes a 7-byte MBAP header, identifying the Modbus Application Data Unit (ADU) and facilitating transport protocol identification.
  • Concurrent Connections: Modbus TCP supports the concurrent connection of numerous server devices and accommodates multiple client devices within a network.

Industry-Specific Variants

Apart from the core Modbus protocols, industry-specific variants have been developed:

Pemex Modbus and Enron Modbus

  • Pemex Modbus: Designed for the oil, gas, and petroleum industries, Pemex Modbus addresses specific sector requirements for historical and event flow data.
  • Enron Modbus: Developed for similar industries, Enron Modbus natively supports 32-bit integers and floating-point variables, catering to specialized data needs.

These industry-focused variants extend the Modbus protocol’s applicability to meet the unique demands of specific sectors.

By organizing the information under headings, the different aspects and variants within the Modbus Ethernet connections are presented in a structured and easily navigable format.

Modbus TCP Frame Format

The Modbus TCP frame format is primarily utilized within Ethernet networks for communication between devices. It follows a structured format with specific fields that serve different functions during data transmission:

Modbus TCP Frame Format

Transaction Identifier (2 bytes)

  • Synchronizes messages between the server and the client. It assists in matching requests with corresponding responses.

Protocol Identifier (2 bytes)

  • Set to 0 for Modbus/TCP. Identifies the protocol being used, distinguishing it from other protocols.

Length Field (2 bytes)

  • Specifies the number of remaining bytes in the frame. This includes the bytes following the Length Field.

Unit Identifier (1 byte)

  • Represents the server address. If not used, it’s typically set to 255. It is used in cases where Modbus/TCP devices consist of multiple Modbus devices, such as Modbus/TCP to Modbus RTU gateways.

Function Code (1 byte)

  • Indicates the function to be performed, similar to other Modbus variants. It defines the specific operation, like reading or writing data.

Data Bytes (n bytes)

  • Contains the actual data being transmitted. This can be response data from the server or commands from the client.

The Unit Identifier serves a purpose in scenarios involving Modbus/TCP to Modbus RTU gateways, where a single Modbus/TCP device may manage communication with multiple Modbus RTU devices. Natively Modbus/TCP-capable devices usually disregard the Unit Identifier.

In summary, the Modbus TCP frame format follows this structured layout to ensure proper data exchange, synchronization, and identification of various elements within the communication process.

TCP/IP

The structure of the TCP ADU in Modbus TCP involves the combination of the Modbus Application Protocol (MBAP) Header with the Modbus Protocol Data Unit (PDU). This combined entity constitutes the TCP ADU, and its format is presented in Figure.

TCP/IP

The key elements within the header play specific roles in facilitating the communication process. Here’s an overview of these elements:

  1. Transaction Identifier:
    • Valuable for networks where multiple requests might be simultaneously in progress.
    • Enables matching requests with their corresponding responses, ensuring accurate parsing of data.
    • Particularly useful in Ethernet networks.
  2. Protocol Identifier:
    • Typically set to zero, but can be used to expand protocol behavior if needed.
    • A part of the header that allows for potential customization or extension.
  3. Length Field:
    • Indicates the length of the remaining packet, including the Modbus PDU.
    • Dependency on a reliable networking layer, like TCP, is evident due to this location.
    • In TCP networks, built-in error checking and data coherence ensure delivery.
  4. Unit Identifier:
    • Generally unused in TCP/IP devices for standard Modbus communication.
    • Relevant in cases of protocol conversion gateways where Modbus is translated into another protocol.
    • Used to determine the intended recipient slave device in certain scenarios.
  5. Protocol Data Unit (PDU):
    • A fundamental part of the ADU that carries the actual Modbus command, data, or response.
    • The maximum length of the PDU is 253 bytes for the standard Modbus protocol.

In essence, the TCP ADU structure combines the MBAP Header with the PDU to enable reliable and accurate communication in Modbus TCP networks. The various elements within the header serve distinct purposes in ensuring data integrity and effective transmission across the network.

FAQs about Modbus TCP

  1. What is Modbus TCP and how does it work?

    Modbus TCP is a protocol that encapsulates Modbus data in TCP packets, allowing communication over Ethernet networks. It’s used for connecting industrial devices and control systems.

  2. What are the advantages of using Modbus TCP over traditional Modbus?

    Modbus TCP offers faster data transfer, longer communication distances, and better reliability compared to Modbus RTU or ASCII. It’s well-suited for modern industrial networks.

  3. How do I set up a Modbus TCP network?

    To set up a Modbus TCP network, you need compatible devices, configure IP addresses, and ensure proper network settings. Consult device manuals and network guidelines.

  4. What is the function of the transaction identifier in Modbus TCP?

    The transaction identifier helps match requests with responses in cases where multiple transactions are happening concurrently. It’s crucial for data integrity in Ethernet networks.

  5. Can I use Modbus TCP for remote monitoring and control?

    Yes, Modbus TCP is suitable for remote monitoring and control applications. Devices can communicate over the internet or private networks, enabling remote access to data and control functions.

  6. How do I troubleshoot Modbus TCP communication issues?

    If facing communication problems, check network connections, IP settings, firewalls, and ensure proper device configurations. Device manuals and online resources can provide troubleshooting guidance.

Read Also: Full Guide on Modbus Protocol – How Modbus Works? Function Codes – Modbus variants….etc

Leave a Comment

error: Content is Protected.