Modbus Tutorial

From beginner to proficiency, systematically learn the principles of Modbus protocol, message formats, debugging methods, and practical applications

Quick Start

Protocol tutorial

Modbus RTU

  • RTU frame format and timing
  • CRC check calculation
  • Master-slave communication mechanism
  • Common error handling
View details

Modbus TCP

  • MBAP message header structure
  • TCP connection establishment
  • Transaction identifier
  • Difference from RTU
View details

Modbus ASCII

  • ASCII frame format
  • LRC check calculation
  • Start/End Character
  • Application Scenarios
View details

Detailed explanation of function codes

  • 01/02: Read-write coil
  • 03/04: Read and write registers
  • 05/06: Write a single entry
  • 15/16: Write multiple
View details

Debugging in Practice

Serial Port Debugging

  • Serial port parameter setting
  • Message sending and receiving
  • Response timeout handling
  • Common error codes
Online debugging

TCP debugging

  • IP and port settings
  • TCP connection test
  • Packet capture and analysis
  • Network fault diagnosis
Online debugging

CRC calculation

  • CRC-16 algorithm
  • Online calculation tool
  • Check code verification
  • Common Mistakes
Online computation

message parsing

  • Automatically parse messages
  • Field Description
  • Error code explanation
  • Case Analysis
Online parsing

common problems

What is the difference between Modbus RTU and TCP?

RTU uses serial communication (RS485/RS232), with a frame format consisting of address, function code, data, and CRC check; TCP uses Ethernet communication, with a frame format consisting of an MBAP header and PDU, and does not require CRC check.

How to calculate the Modbus CRC check code?

CRC-16 uses a polynomial of 0x8005 and an initial value of 0xFFFF. After calculating each byte, it is XORed with 0xFFFF. You can use our online CRC calculation tool to automate the calculation.

What is the difference between Modbus function codes 03 and 04?

Function code 03 reads the holding register (readable and writable), while function code 04 reads the input register (read-only). The holding register is used for parameter settings, while the input register is used for real-time data.

How to solve the Modbus communication timeout issue?

Check whether the serial port parameters (baud rate, data bits, stop bits, parity bits) match, whether the wiring is correct, whether the slave address conflicts, and appropriately increase the timeout period.

Need help?

If you encounter any issues while learning or using Modbus, please feel free to contact our technical support team.