Skip to main content
Skip table of contents

MODBUS RTU

Modbus RTU is a serial transmission version of Modbus, typically used over RS-232 or RS-485 physical interfaces.

Modbus RTU frame structure

The structure of a Modbus RTU frame can be seen below. Note that Modbus RTU uses a binary format rather than ASCII and does not include explicit frame delimiters like <CR><LF>.

Modbus RTU frame structure

Field

Size

Description

Start

3.5-character silence

Minimum silent period used as frame delimiter to indicate the beginning of a new Modbus RTU message (*).

Address

1 byte

Identifies the target slave device. Range: [1,247], with 0 reserved for broadcast.

Function code

1 byte

Defines the register type. See function code table below for details.

Data

N bytes

Contains the requested data (register addresses and values).

CRC

2 bytes

A cyclic redundancy check (CRC) to verify the integrity of the transmitted data and detect communication errors.

End

3.5-character silence

Minimum silent period used as frame delimiter to indicate the end of a Modbus RTU message (*).

Modbus register addressing

Modbus typically organizes data into four register types:

Modbus register addressing

Register type

Address range

Size

Read/write

Purpose

Coils

00001 - 09999

1-bit

Read/Write

Controls binary outputs (e.g., turning devices ON/OFF).

Discrete inputs

10001 - 19999

1-bit

Read-only

Stores binary input signals from e.g. sensors or switches.

Input registers

30001 - 39999

16-bit

Read-only

Stores input data (e.g., sensor readings or status) that the master can only read.

Holding registers

40001 - 49999

16-bit

Read/Write

Stores output or configuration data that the master can read and modify.

Modbus function codes

The function codes define the type of action or request made by the master device.

Modbus function codes

Function code

Description

01

Read coils

02

Read discrete inputs

03

Read holding registers

04

Read input registers

05

Write single coil

06

Write single holding register

15

Write multiple coils

16

Write multiple holding registers

Example

In Modbus communication, you can define the order in which data appears within register addresses. For example, if input registers are selected (see Modbus RTU configuration under serial configuration for instructions) and you select roll, pitch, and yaw as shown in the table below, roll will be stored in registers 30001 and 30002, pitch in 30003 and 30004, and so on. Since each value is stored as a 32-bit IEEE 754 single-precision floating-point number, it occupies two 16-bit Modbus registers.

Register address

Parameter

Data type

Unit

Register value (U16) decimal

Numerical value

30001

roll (MSB)

Single precision float (IEEE 754)

[deg]

-16751

-0.28

30002

roll (LSB)

-10128

30003

pitch (MSB)

Single precision float (IEEE 754)

[deg]

16648

8.55

30004

pitch (LSB)

-17940

30005

yaw (MSB)

Single precision float (IEEE 754)

[deg]

17331

359.91

30006

yaw (LSB)

-3246

Let's examine how the roll value (2.34 degrees) is retrieved from Modbus registers.

Register address

Parameter

Data type

Unit

Register value (U16) binary

Register value (U16) decimal

Numerical value

30001

roll (MSB)

Single precision float (IEEE 754)

[deg]

01000000 00010101

16405

 

-0.28

30002

roll (LSB)

11000010 10001111

49807

These two 16-bit registers form a 32-bit binary word in big-endian format. When combined in big-endian order, the full 32-bit IEEE 754 floating-point representation is: 10111110 10010001 11011000 01110000.

IEEE 754 single-precision floating-point numbers are structured as follows:

Bit position

Component

Extracted bits

Bit 1

Sign (S)

1 (negative)

Bits 2-9

Exponent (E)

01111101 (decimal: 125)

Bits 10-32

Mantissa (M)

00100011101100001110000

The roll value is computed using the IEEE 754 formula:

Roll value = (-1)s x 1.M x 2(E-127) = (-1)1 x 1.001000111011000011100002 x 2(125−127) = −1.139708 x 2-2 = −0.284854.

Due to rounding errors, the final roll angle is -0.28 degrees.

(*) The duration of the silent period depends on the baud rate. The available baud rates for RS-232 and RS-485 can be seen in serial configuration.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.