What are the function codes of Modbus (RTU)and their requests and responses?

Panisetti prudhviraj
Analytics Vidhya
Published in
8 min readNov 24, 2020

--

Today, we are going to see few basic functions of Modbus registers like how to write data to a register and read the data from the register using the functional codes. This is the communication between a Modbus master and its slaves.

Functional codes of Modbus registers

Basically, when you start working on the Industrial standard communication protocol like Modbus for the first time, this will give you a detail understanding of how things work and how to start working on Modbus from scratch.

Introduction:

To have a Quick intro, Modbus protocol is defined as a master/slave protocol, meaning a device operating as a master will poll one or more devices operating as a slave.

  • The most commonly used form of Modbus protocol is RTU over RS-485.
  • A Modbus RTU network has one Master and one or more Slaves. Each slave has a unique 8-bit device address or unit number.

The general outline of each request and response is shown as below:

The Modbus RTU message consists of the address of the SlaveID device/Device Address, the function code, the special data, depending on the function code and the CRC of the checksum.

The Request:

--

--

Panisetti prudhviraj
Analytics Vidhya

Passionate Full Stack Developer based in Germany with a strong advocacy for Python, Go. Let's connect on LinkedIn for a tech-centric journey!