Modbus Rtu Detail

Modbus RTU in Detail: Serial Communication Essentials

Modbus RTU (Remote Terminal Unit) is like sending a carefully structured letter through a narrow, single-lane road. It uses serial communication—sending data one bit at a time—to connect industrial devices. While newer protocols like Modbus TCP get more attention, RTU remains the backbone of many industrial networks because of its reliability, simplicity, and long-distance capabilities.

Let’s dive into the technical details of Modbus RTU, starting with its foundation in UART communication.

UART: The Foundation of Serial Communication

Before understanding Modbus RTU, we need to grasp the basics of UART (Universal Asynchronous Receiver/Transmitter) communication. UART is the hardware that handles serial data transmission between devices.

How UART Works: A Simple Analogy

Imagine sending a Morse code message with a flashlight: you turn the light on and off in a specific pattern to represent letters. This is exactly how UART works, but with electrical signals instead of light.

  • Parity Bit (Optional): An extra bit to help detect transmission errors.

Serial Parameters in Modbus RTU

Modbus RTU devices must agree on four key serial parameters to communicate successfully. These are like the “rules of the road” for your serial communication.

1. Baud Rate: Speed of Communication

What it is: The rate at which data bits are transmitted, measured in bits per second (bps).

Common Values: 9600, 19200, 38400, 57600, 115200 bps

Modbus RTU Default: 9600 bps (legacy default, still widely used)

Analogy: The speed limit on a road. All devices must drive at the same speed to communicate effectively.

Example: At 9600 bps, a single byte takes approximately 1 millisecond to transmit.

2. Parity: Error Detection Helper

What it is: An optional extra bit that checks for single-bit transmission errors.

Options: None, Even, Odd, Mark, Space

Modbus RTU Common Settings: None or Even parity

How it works:

  • None: No parity bit is used

Analogy: A simple checksum for each byte—like counting the letters in a word to make sure it’s spelled correctly.

3. Stop Bits: End-of-Byte Markers

What it is: One or more bits that indicate the end of a byte.

Options: 1, 1.5, or 2 stop bits

Modbus RTU Common Setting: 1 stop bit

Analogy: A period at the end of a sentence—letting the receiver know the byte has finished.

4. Data Bits: The Actual Information

What it is: The number of bits that make up the actual data being transmitted.

Modbus RTU Requirement: 8 data bits

Why 8 bits?: Modbus RTU uses 8-bit bytes for all fields (address, function code, data, CRC).

Typical Modbus RTU Configuration

The most common Modbus RTU configuration is:

  • Data Bits: 8

This is often abbreviated as “9600-N-8-1” (baud-parity-data-stop).

Modbus RTU Message Framing: The Structure of Communication

Modbus RTU messages are structured as a sequence of 8-bit bytes. Unlike Modbus ASCII, RTU uses binary format for compact, efficient communication.

RTU Message Structure

| Field | Size (bytes) | Description |

|———–|—————–|—————–|

| Slave Address | 1 | Unique identifier (1-247) for the target device |

| Function Code | 1 | Action to perform (e.g., 03 = Read Holding Registers) |

| Data | N | Variable length (0-252 bytes) containing request/response data |

| CRC Check | 2 | Cyclic Redundancy Check for error detection |

Example RTU Request Message

Let’s break down a real Modbus RTU request:

Scenario: A master (PLC) wants to read register 40001 from slave device 5.

“`

Hexadecimal: [05] [03] [00] [00] [00] [01] [41] [C8]

Binary: 00000101 00000011 00000000 00000000 00000000 00000001 01000001 11001000

“`

Breakdown:

  • `41 C8`: CRC Check (calculated based on previous bytes)

Example RTU Response Message

The slave responds with the requested data:

“`

Hexadecimal: [05] [03] [02] [08] [CA] [91] [D3]

“`

Breakdown:

  • `91 D3`: CRC Check

CRC Error Checking: Ensuring Data Integrity

CRC (Cyclic Redundancy Check) is the “quality control” of Modbus RTU. It detects errors in transmission, such as flipped bits or missing bytes.

How CRC Works in Modbus RTU

1. Calculation: The sending device calculates a 16-bit CRC value based on all bytes in the message (address, function code, data).

2. Appending: The CRC is appended to the end of the message, low byte first.

3. Verification: The receiving device recalculates the CRC from the received bytes and compares it to the CRC in the message.

4. Validation: If the CRCs match, the message is valid; if not, the message is discarded.

CRC Calculation Example

For the request message `[05] [03] [00] [00] [00] [01]`, the CRC is calculated as `41 C8`:

1. Initialize CRC register to 0xFFFF

2. For each byte in the message:

– XOR the byte with the CRC register

– Shift right and apply polynomial (0xA001) if the least significant bit is 1

3. Repeat for all bytes

4. Final CRC value is the 16-bit result

Why CRC is Better Than Parity

  • Higher Reliability: Essential for industrial environments where noise can corrupt data.

RS-485 Wiring: Textual Diagrams

Modbus RTU typically uses RS-485 for physical communication, which allows for long distances and multiple devices on a single network.

RS-485 Basics

  • Termination: Requires 120Ω resistors at both ends

Two-Wire RS-485 Network: Textual Diagram

“`

┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐

│ MASTER DEVICE │ │ SLAVE DEVICE │ │ SLAVE DEVICE │

│ │ │ 1 │ │ N │

├─────────────────┤ ├─────────────────┤ ├─────────────────┤

│ RS-485 PORT │ │ RS-485 PORT │ │ RS-485 PORT │

│ ┌─────────┐ │ │ ┌─────────┐ │ │ ┌─────────┐ │

│ │ │ │ │ │ │ │ │ │ │ │

│ │ A B │ │ │ │ A B │ │ │ │ A B │ │

│ └──┬───┬──┘ │ │ └──┬───┬──┘ │ │ └──┬───┬──┘ │

└──────┼───┼──────┘ └──────┼───┼──────┘ └──────┼───┼──────┘

│ │ │ │ │ │

│ │ ┌───────────────┘ └───────────────┐ │

│ │ │ │ │

│ └──┼───────────────────────────────────┼───┘

│ │ │

│ │ RS-485 BUS │

│ │ ┌──────────────────────────┐ │

│ │ │ │ │

└──────┼───┤ A B ├─────┘

│ │ │

│ └──────────────────────────┘

┌─────────────┴─────────────────────────────────────────────┐

│ TERMINATION RESISTORS (120Ω) AT BOTH ENDS OF THE NETWORK │

└─────────────────────────────────────────────────────────┘

“`

Key RS-485 Wiring Rules

1. Daisy Chain Topology: Always use daisy chain (linear) wiring—star or tree topologies cause signal reflections.

2. Termination Resistors: Install 120Ω resistors at the first and last devices in the chain.

3. Cable Type: Use twisted-pair cable (Cat5e or better) for best noise immunity.

4. A/B Polarity: Ensure A connects to A and B connects to B across all devices—reversed polarity is a common error.

5. Shielding: Ground the cable shield at one end only to prevent ground loops.

Three-Wire RS-485 (Optional Common Ground)

Some installations add a third wire for common ground, which improves noise immunity:

“`

┌─────────┐ ┌─────────┐ ┌─────────┐

│ MASTER │ │ SLAVE 1 │ │ SLAVE N │

├─────────┤ ├─────────┤ ├─────────┤

│ A B │ │ A B │ │ A B │

│ GND │ │ GND │ │ GND │

└──┬───┬──┘ └──┬───┬──┘ └──┬───┬──┘

│ │ │ │ │ │

│ └───────────┼───┼───────────┼───┘

│ │ │ │

└───────────────┼───┼───────────┘

│ │

RS-485 BUS: A B GND

│ │ │

┌───────────────┘ └───┴───────────────────┐

│ TERMINATION RESISTORS (120Ω) │

└───────────────────────────────────────────┘

“`

Practical Modbus RTU Configuration Example

Let’s put it all together with a real-world example:

System Components

  • Distance: 500 meters total length

Configuration Settings

  • Addresses: 1 (PLC is master, doesn’t need address), 2-6 for slaves

Example Communication Flow

1. Master sends request to slave 2 (temperature controller):

– Address: 02

– Function: 03 (Read Holding Registers)

– Data: Read register 40001 (temperature setpoint)

– CRC: Calculated checksum

2. Slave 2 processes the request and responds with:

– Address: 02 (echo)

– Function: 03 (echo)

– Data: Current temperature setpoint (e.g., 2500 = 25.0°C)

– CRC: Calculated checksum

3. Master verifies the CRC and processes the data

Common Modbus RTU Issues and Troubleshooting

| Issue | Possible Cause | Solution |

|———–|——————-|————–|

| No Communication | Wrong serial parameters | Verify baud rate, parity, stop bits match on all devices |

| Intermittent Errors | Reversed A/B polarity | Check wiring to ensure A→A and B→B connections |

| CRC Errors | Noise or improper termination | Add termination resistors, use twisted-pair cable, check grounding |

| Slave Not Responding | Wrong slave address | Verify device address matches configuration |

| Slow Communication | Too low baud rate | Increase baud rate if network allows |

| Signal Degradation | Too many devices | Reduce number of devices (max 32 per network) |

UART vs. Modbus RTU: Understanding the Relationship

| UART | Modbus RTU |

|———-|—————-|

| Hardware/Protocol for serial communication | Application-layer protocol using UART |

| Handles bit-level transmission | Defines message structure and function codes |

| Manages start/stop bits, parity | Uses UART for physical transmission |

| Device-to-device communication | Multi-device network communication |

Conclusion: The Reliability of Modbus RTU

Modbus RTU is like the workhorse of industrial communication—reliable, efficient, and proven over decades. Its simplicity and robustness make it ideal for harsh industrial environments where reliability is critical.

By understanding the UART foundation, serial parameters, message framing, CRC error checking, and RS-485 wiring, you can effectively design, configure, and troubleshoot Modbus RTU networks.

While newer protocols like Modbus TCP offer faster speeds and internet connectivity, Modbus RTU remains essential for legacy systems and applications where long distances, simplicity, and low cost are priorities.

Whether you’re working with PLCs, sensors, or industrial controllers, a solid understanding of Modbus RTU will help you build reliable, efficient industrial communication systems.