Modbus Register Definitions

This guide details Modbus Register Definitions, covering both input and holding registers. Learn about function codes and how to read 3-axis acceleration data from a 6DOF IMU sensor.

Register Definitions

Register Type Register Address Register Name R/W Property Value Range Default Value Function Description
Input Register 0x0000 VID Vendor ID R 0x3343 0x3343 Vendor identifier, fixed as DFRobot
Input Register 0x0001 PID Product ID R 0x0006 Model Dependent 0x0006 represents 6DOF IMU sensor
Input Register 0x0002 Device Address R 0x004A~0x004D DIP Switch Defined MODBUS device address, configurable via DIP switch
Input Register 0x0003 Reserved R 0x0000~0xFFFF 0xFFFF Reserved register
Input Register 0x0004 Module Parity Bit(H) Stop Bit(L) R 0x0001 0x0001 Parity Bit (H): 0x00--None;
Stop Bit (L): 0x01--1Byte
Input Register 0x0005 VERSION Firmware Version R 0x0000~0xFFFF 0x1000 0x1000 indicates firmware version V1.0.0.0
Input Register 0x0006 Accelerometer X-axis Data R 0x0000~0xFFFF 0x0000 6DOF IMU accelerometer X-axis data
Input Register 0x0007 Accelerometer Y-axis Data R 0x0000~0xFFFF 0x0000 6DOF IMU accelerometer Y-axis data
Input Register 0x0008 Accelerometer Z-axis Data R 0x0000~0xFFFF 0x0000 6DOF IMU accelerometer Z-axis data
Input Register 0x0009 Gyroscope X-axis Data R 0x0000~0xFFFF 0x0000 6DOF IMU gyroscope X-axis data
Input Register 0x000A Gyroscope Y-axis Data R 0x0000~0xFFFF 0x0000 6DOF IMU gyroscope Y-axis data
Input Register 0x000B Gyroscope Z-axis Data R 0x0000~0xFFFF 0x0000 6DOF IMU gyroscope Z-axis data
Input Register 0x0014 Pedometer Low Word Data R 0x0000~0xFFFF 0x0000 6DOF IMU pedometer low word data
Input Register 0x0015 Pedometer High Word Data R 0x0000~0xFFFF 0x0000 6DOF IMU pedometer high word data
Input Register 0x0016 Tap Status Data R 0x0000~0x0003 0x0000 0x0001=Single Tap;
0x0002=Double Tap;
0x0003=Triple Tap
Input Register 0x0017 Orientation Detection Data R 0x0000~0xFFFF 0x0000 High Byte: Landscape/Portrait orientation;
Low Byte: Forward/Backward direction
Holding Register 0x0000 Reserved R/W 0x0000~0xFFFF 0xFFFF Reserved register
Holding Register 0x0001 Reserved R/W 0x0000~0xFFFF 0xFFFF Reserved register
Holding Register 0x0002 Reserved R/W 0x0000~0xFFFF 0xFFFF Reserved register
Holding Register 0x0003 Device Baud Rate R/W 0x0000~0x00FF 0x0003 Device Baud Rate
0x0001=2400
0x0002=4800
0x0003=9600
0x0004=14400
0x0005=19200
0x0006=38400
0x0007=57600
0x0008=115200
Other=115200
Holding Register 0x0004 Reserved R/W 0x0000~0xFFFF 0xFFFF Reserved register
Holding Register 0x0005 Reserved R/W 0x0000~0xFFFF 0xFFFF Reserved register
Holding Register 0x0006 Device Working Mode R/W 0x0000~0x0003 0x0002 0x0000 - Sleep Mode (Enter sleep with sensor config lost, lowest power consumption)
0x0001 - Low Power Mode (Measure data with lower power consumption)
0x0002 - Normal Mode (Balance of measurement accuracy and power consumption)
0x0003 - High Performance Mode (Highest measurement accuracy, maximum power consumption)
Holding Register 0x0007 Factory Reset R/W 0x0000~0x0001 0x0001 Write 0x0001 to trigger factory reset
Holding Register 0x0008 Accelerometer Range R/W 0x0000~0x0003 0x0002 Accelerometer measurement range:
0x0000=±2G
0x0001=±4G
0x0002=±8G
0x0003=±16G
Holding Register 0x0009 Gyroscope Range R/W 0x0000~0x0004 0x0004 Gyroscope measurement range:
0x0000=±125DPS
0x0001=±250DPS
0x0002=±500DPS
0x0003=±1000DPS
0x0004=±2000DPS
Holding Register 0x000E Interrupt Pin 1 Configuration R/W 0x0000~0x0009 0x0000 6DOF IMU interrupt pin 1 configuration
0x0000 - Interrupt Disable
0x0001 - Enable 6DOF Data Ready Interrupt0x0002 - Enable Any Motion Detection Interrupt
0x0003 - Enable Stillness Detection Interrupt
0x0004 - Enable Significant Motion Detection Interrupt
0x0005 - Enable Pedometer Data Interrupt
0x0006 - Enable Flat Detection Interrupt
0x0007 - Enable Orientation Detection Interrupt
0x0008 - Enable Tap Detection Interrupt
0x0009 - Enable Tilt Detection Interrupt
Holding Register 0x000F Interrupt Pin 2 Configuration R/W 0x0000~0x0009 0x0000 Configuration functions are exactly the same as Interrupt Pin 1

Common Function Codes for Modbus-RTU:

Function Code Name Function
0x03 Read Multiple Registers Read integer, character, status word, floating-point (read N words) --- Read holding registers, byte operation
0x04 Read Input Registers Read integer, status word, floating-point (read N words) --- Read input registers, byte operation
0x06 Write Single Holding Register Write integer, character, status word, floating-point (write one word) --- Write holding register, byte operation
0x10 Write Multiple Holding Registers Write multiple holding registers --- Load specific binary values into a series of consecutive holding registers

Input and holding registers can be read and written using the above commands.

Example of Reading 3-Axis Acceleration Data

Objective

Read the current acceleration values detected by the 6-axis IMU sensor via the Modbus RTU protocol.

Hardware Preparation

General Operation Steps

  • Hardware Connection: Connect the sensor to the host (computer) via the RainbowLink USB protocol converter. Switch the sensor's communication mode to UART and the address to 0x4A.

  • Parameter Configuration: Set the following parameters in the serial port debugging tool (must match the sensor settings):

    • Baud rate: 9600 (default)
    • Data bits: 8 bits
    • Stop bits: 1 bit
    • Parity: None
  • Send Command: Enter the following hexadecimal command in the "Transmission Area" of the debugging tool, check "Send in Hexadecimal", and send the command.

Command Transmission and Parsing

Field Name Hexadecimal Value Description
Device Address 4A MODBUS device address, default 0x4A (modifiable via DIP switch)
Function Code 04 Read Input Registers (fixed command)
Starting Register Address 00 06 Acceleration X-axis register address (0x0006)
Number of Registers 00 03 Read 3 registers (Acceleration X, Y, Z)
CRC Check 5F B1 CRC16 check value of the command

Complete Command to Send: 4A 04 00 06 00 03 5F B1

Return Data and Parsing

After receiving the command, the sensor returns the following data (example):

Field Name Hexadecimal Value Description
Device Address 4A Matches the device address in the sent command
Function Code 04 Confirm execution of "Read Input Registers" operation
Number of Bytes 06 Total number of bytes in the returned data (6 bytes)
Read Data FF AD FF DD EF E1 Raw values of acceleration X, Y, Z axes (2 bytes each)
CRC Check B7 E1 CRC16 check value of the returned data

Complete Returned Data: 4A 04 06 FF AD FF DD EF E1 B7 E1

SEN0692-Modbus Result

Data Parsing Steps

The returned raw data (FF AD, FF DD, EF E1) are 16-bit signed integers (two's complement). Convert them to actual acceleration values (unit: g) following these steps:

  1. Convert Hexadecimal to Signed Decimal

    • X-axis raw value: FF AD
      Unsigned value = 0xFFAD = 65453
      Signed value = 65453 − 65536 = -83

    • Y-axis raw value: FF DD
      Unsigned value = 0xFFDD = 65493
      Signed value = 65493 − 65536 = -43

    • Z-axis raw value: EF E1
      Unsigned value = 0xEFE1 = 61409
      Signed value = 61409 − 65536 = -4127

  2. Convert to Physical Values Based on Range and Sensitivity

    The default range of the BMI323 accelerometer is ±8 g, with a sensitivity of 4096 LSB/g (see Table 3 on Page 9 of the datasheet).

    Formula:

    Acceleration (g) = Signed raw value / Sensitivity

    • X-axis: −83/4096 ≈ −0.0203 g
    • Y-axis: −43/4096 ≈ −0.0105 g
    • Z-axis: −4127/4096 ≈ −1.0076 g
  3. Result Interpretation

    • X and Y axes are close to 0 g, indicating the sensor is level with no tilt on the horizontal plane.
    • Z-axis is approximately -1 g, indicating the direction of gravity is negative (sensor front side up, Z-axis pointing to the center of the Earth).
    • This data is consistent with the expected output when the sensor is stationary.

Why This Processing?

  1. Digital Output: The sensor converts analog signals to digital signals internally and outputs them as 16-bit binary two's complement. The sensitivity defined in the datasheet must be used to convert these values back to physical quantities.
  2. Range Impact: Sensitivity is related to the selected range (different ranges correspond to different LSB/g values). Confirm the current range setting before parsing (default ±8 g; if modified, read via holding register 0x0008).
  3. Significance: Acceleration has direction, so signed numbers are used. Two's complement format requires subtracting 65536 to convert to negative values.

Notes

  • If the accelerometer range is modified (e.g., ±2 g, ±4 g, ±16 g), the sensitivity will change accordingly, and the denominator in the parsing formula must be adjusted synchronously.
  • The CRC check in the returned data can verify transmission integrity (CRC is correct in this example, so the data is reliable).
  • For continuous reading, repeat sending the same command directly—the sensor will return the latest sampled values.

Was this article helpful?

TOP