An Introduction to Modbus RTU & Modbus TCP (they are still popular!)

An Introduction to Modbus RTU & Modbus TCP (they are still popular!)

Introduction

Hello automation enthusiasts and curious individuals! In this post, we will explore the fascinating world of Modbus - a widely adopted communication protocol that has become an indispensable component in industrial and commercial automation and control systems. With a multitude of Modbus-compatible devices already in use (since 1979!), it is the perfect opportunity to delve into the inner workings of Modbus RTU and Modbus TCP and understand their widespread appeal, so that we can integrate them into our projects.

Modbus RTU: The Serial Communication Master

Let's start with Modbus RTU, the original version of Modbus published by Modicon in 1979.. Operating over serial interfaces like RS-232 or RS-485, Modbus RTU is a binary communication protocol that uses a primary-secondary architecture (traditionally called master-slave, the term is now being retired). The primary device initiates communication with multiple secondary devices. The typical Modbus RTU communication protocol utilizes the RS-485 standard. Modbus RTU networks utilize a single Modbus RTU Primary device, which communicates with up to 254 secondary devices. A maximum length of 4,000 feet (approximately 1,200 meters) is generally accepted for RS-485 communication, making it a robust, easy, and reliable solution for data exchange.

Modbus RTU employs a simple and efficient messaging structure, where data is transmitted using function codes and register addresses. The protocol's error-checking mechanism, Cyclic Redundancy Check (CRC), ensures data integrity during transmission.

One of the reasons Modbus RTU has been so popular is its simplicity - it's easy to implement and understand, making it accessible to engineers and hobbyists alike. This has led to a diverse range of Modbus RTU-compatible devices, such as:

  1. Programmable Logic Controllers (PLCs): These versatile controllers are widely used in industrial automation systems, and many models support Modbus RTU communication for seamless integration with other devices.
  2. Direct Digital Controllers (DDCs): DDCs are commonly used in building automation systems for HVAC, lighting, and other applications. Many DDCs support Modbus RTU communication, allowing seamless integration with other Modbus RTU-compatible devices in the system.
  3. Remote Terminal Units (RTUs): Designed for data acquisition and remote monitoring, RTUs often use Modbus RTU for communication with master devices like SCADA systems, PLCs, or DDCs.
  4. Sensors: From temperature and humidity sensors to pressure transmitters, many industrial sensors use Modbus RTU to communicate their readings to control systems.
  5. Actuators: Modbus RTU-compatible actuators, such as motor drives and valve controllers, can receive commands and provide feedback to the control system.

So, whether you're working with PLCs, DDCs, sensors, or actuators, Modbus RTU has got you covered with its extensive device compatibility and straightforward communication protocol!


Modbus TCP: Ethernet Connectivity on the Rise

Let's now turn our attention to Modbus TCP, which was developed when industrial Ethernet emerged, and it retains much of Modbus' simplicity while being wrapped in a TCP/IP protocol. Modbus TCP utilizes the same data model and function codes as Modbus RTU, but with a modern twist.

Modbus TCP brings faster and more efficient communication between devices, thanks to the higher data rates supported by Ethernet networks. It also enables more extended network distances and improved error detection and recovery, courtesy of the underlying TCP/IP protocol. No more fiddling with RS-232 or RS-485 converters, just plug in and play (almost!)!

The widespread adoption of Ethernet networks in industrial and smart spaces has led to an increasing number of Modbus TCP-compatible devices, such as:

  1. Ethernet-enabled PLCs: A growing number of PLCs now come with built-in Ethernet ports, supporting Modbus TCP communication for seamless integration with other devices in the network.
  2. Direct Digital Controllers (DDCs) with Ethernet connectivity: Ethernet-enabled DDCs offer increased flexibility and scalability in building automation systems. They support Modbus TCP communication, allowing seamless integration with other Modbus TCP-compatible devices and simplifying network management.
  3. Remote I/O Modules: These versatile modules allow you to connect various sensors and actuators to your Ethernet network, simplifying data exchange and remote control.
  4. Human Machine Interfaces (HMIs): Modern HMIs often support Modbus TCP, enabling them to monitor and control Modbus TCP-compatible devices directly from the user interface.
  5. Industrial Ethernet Switches: These robust network switches are specifically designed for industrial environments and support Modbus TCP communication and other protocols for network management and monitoring.

Embracing Modbus TCP in your automation projects offers the advantages of faster data transfer, simpler network configuration, and a broader range of compatible devices, making it an excellent choice for modern control and automation systems.

Another advantage of Modbus TCP is its compatibility with multi-protocol gateways (not Industrial Ethernet Switches). These flexible devices allow for seamless conversion between various communication protocols like Bacnet/IP, OPC UA, Obix, SNMP, and many others, making it easier to integrate Modbus TCP devices into diverse automation systems. By using a multi-protocol gateway, you can ensure smooth communication between devices that utilize different protocols, further expanding the versatility and usefulness of Modbus TCP in the world of automation.

Some Technical Basics

Modbus supports different object types, frame formats, and function codes to enable data access and management across these networks:

Object Types

Modbus servers provide the following object types to Modbus client devices:

  1. Coil: Read-write access, 1-bit size, address space 00001 - 09999
  2. Discrete Input: Read-only access, 1-bit size, address space 10001 - 19999
  3. Input Register: Read-only access, 16-bit size, address space 30001 - 39999
  4. Holding Register: Read-write access, 16-bit size, address space 40001 - 49999

Frame Formats

Modbus uses different frame formats for communication:

  1. Modbus RTU: Primarily used on asynchronous serial data lines like RS-485/EIA-485
  2. Modbus ASCII: Primarily used on 7-bit or 8-bit asynchronous serial lines
  3. Modbus TCP: Primarily used on Ethernet networks

Function Codes

Function codes are used to perform operations on the supported object types. There are three categories of Modbus function codes: public, user-defined, and reserved.

Some public function codes include:

  • Read Coils (1)
  • Read Discrete Inputs (2)
  • Read Input Registers (4)
  • Read Multiple Holding Registers (3)
  • Write Single Coil (5)
  • Write Multiple Coils (15)
  • Write Single Holding Register (6)
  • Write Multiple Holding Registers (16)

Exception Responses

When a Modbus server encounters an error, it will reply with an exception response that includes the requested function code plus 128 and a single byte of data called the exception code.

Entity Numbers and Addresses

Modbus entities (coils, discrete inputs, input registers, holding registers) are referenced with specific conventions that include entity numbers and entity addresses. Entity numbers combine entity type and location, while entity addresses are 16-bit values ranging from 0 to 65,535 (0000 to FFFF in the packets).

A World of Modbus Devices

The beauty of Modbus lies in its wide adoption and compatibility. With so many Modbus devices already developed and deployed in various industrial settings, it's easy to find a solution that fits your needs. For, example, you can find a PWM-based DC-motor controller with Modbus.

Whether it's a PLC, DDC, remote I/O module, sensor, or actuator, there's a good chance you'll encounter a device that speaks Modbus.


Flecnode: Bridging the Modbus Gap and making it even more flexible

Here at Flecnode, we're all about making automation accessible and enjoyable. That's why we've designed our universal IoT controller to support both Modbus RTU and Modbus TCP to work with our universal I/O terminals, ensuring seamless and flexible integration with a vast array of industrial automation and control systems for your projects.


Finally

So there you have it, a simple introduction to the fascinating world of Modbus RTU and Modbus TCP. As you can see, these communication protocols have been crucial in shaping the industrial automation landscape since 1979, and their widespread adoption guarantees their continued relevance in the future. With Flecnode's support for both protocols, we're excited to help you unlock the full potential of your automation projects, no matter which flavor of Modbus you choose!

Stay tuned for more automation insights, and don't hesitate to reach out if you have any questions or need help with your Modbus adventures. Happy automating!

Back to blog

Leave a comment

Please note, comments need to be approved before they are published.