Modbus TCP – A Classic Technology for Modern Applications

In the ever-evolving landscape of industrial automation and networking, certain technologies have stood the test of time, proving their worth repeatedly. One such technology is Modbus TCP, a classic protocol that continues to be a cornerstone in modern industrial solutions.

The origins of Modbus TCP

Modbus TCP is a variant of the Modbus protocol, which was developed in the late 1970s by Modicon (now part of Schneider Electric). The original Modbus protocol was designed for serial communication (RS-232 and RS-485) and has since evolved into different versions, with Modbus TCP being one of the most commonly used ones. Unlike its serial counterparts, Modbus TCP operates over Ethernet networks, making it a more versatile and widely adopted solution in modern industrial settings.

Modbus TCP uses a client-server architecture, where a Modbus master (client) sends requests to a Modbus slave (server) to read or write data. The protocol relies on a request-response mechanism, ensuring that communication between devices is both structured and reliable.

The Modbus TCP Technology

Addressing and Data Types

In Modbus TCP, each device on the network is assigned a unique identifier, known as a Unit Identifier (UID) or Slave ID. This UID is used by the master to address and communicate with specific slaves. It’s essential to keep in mind that Modbus TCP operates in a 16-bit addressing scheme, meaning that the UID can range from 1 to 247.

Modbus TCP supports various data types, including discrete inputs (bits), coils (bits that can be written to), input registers (16-bit integer values), and holding registers (16-bit integer values that can be read and written). Understanding the different data types is crucial when configuring Modbus devices and ensuring data integrity in your industrial network.

Data format

Modbus TCP follows the Modbus application protocol while adapting it for use over TCP/IP networks. The data format in Modbus TCP is organized to facilitate communication between devices over these networks. Here’s a breakdown of the Modbus TCP data format:

MBAP Header (Modbus Application Protocol Header):

This is unique to Modbus TCP and is used to route the request to the correct device and identify the transaction. The MBAP header is 7 bytes long and includes:

  • Transaction Identifier (2 bytes): Uniquely identifies a particular message and matches responses with requests.
  • Protocol Identifier (2 bytes): Always zero for Modbus TCP.
  • Length Field (2 bytes): Indicates the length of the remaining fields (including the Unit Identifier and data, but excluding the MBAP header itself).
  • Unit Identifier (1 byte): Identifies the remote server (slave) within the server (slave) device. This is useful when Modbus is used within other, larger networks.
PDU (Protocol Data Unit):

This part is common with Modbus RTU and contains:

  • Function Code (1 byte): Indicates the type of action the server (slave) is supposed to perform (e.g., read coils, write registers).
  • Data Field (variable length): Contains additional information the server (slave) needs to perform the action or the data the client (master) is writing to the server (slave). The structure of the data field depends on the function code.
Error Checking: 

Unlike Modbus RTU, Modbus TCP does not include a checksum for error verification in each message. This is because TCP/IP, the underlying transport protocol, already has built-in error checking and correction mechanisms.

Why Modbus TCP is still in the game

Despite being several decades old, Modbus TCP remains relevant and widely used for several reasons:

      1. Simplicity and Ease of Integration: Modbus TCP retains the simplicity of the original Modbus protocol, making it easy to understand, implement, and integrate with a variety of devices and systems. This simplicity also translates to cost-effectiveness, an attractive feature for many industries.

      1. Open Protocol: Being an open protocol, Modbus TCP doesn’t tie users to specific vendors. This flexibility allows for a diverse and cost-effective selection of hardware and software.

      1. Reliability and Stability: Modbus TCP is known for its reliability and stability in data exchange, making it a trusted choice for critical industrial applications.

      1. Wide Acceptance and Support: The widespread acceptance of Modbus TCP means a vast array of tools, libraries, and resources are available, making development and troubleshooting more accessible.

    Modbus TCP in Modern Applications

    Today, Modbus TCP finds its place in various sectors, including manufacturing, building automation, and energy management. Its application in modern solutions can be seen in:

        • Smart Grids: For monitoring and controlling electrical devices and systems.

        • Industrial Internet of Things (IIoT): As a communication protocol for sensors and actuators.

        • Building Management Systems (BMS): For HVAC, lighting, and security control.

      Challenges and the Future

      While Modbus TCP is robust, it faces challenges like limited data types and security concerns, especially in the context of the Internet of Things (IoT) and cybersecurity threats. However, ongoing developments and the integration of secure layers are ensuring that Modbus TCP adapts to these modern requirements.

      Looking for a reliable modbus stack?