Reference

This guide provides an in-depth look at the Modbus-RTU protocol, detailing key commands, communication frames, and a comprehensive register table for enhanced sensor data management.

Communication Protocol Description

The sensor uses the Modbus-RTU protocol for communication. Two key commands are supported:

  • 0x03: Read register data
  • 0x06: Write data to a register

Host Sending Frame (HEX)

Slave address Function code Register address high bit Register address low bit Read length high bit Read length low bit CRC check high bit CRC check low bit
0x50 0x03 RegH RegL LenH LenL CRCH CRCL

Example: To read the measurement distance (register 0x34, default slave address 0x50):
Command: 50 03 00 34 00 01 C8 45

Slave Response Frame (HEX)

Slave address Function code Data length Data bit 1 Data bit 2 CRC check high bit CRC check low bit
0x50 0x03 LenH DataH DataL CRCH CRCL

Example: Response to the read command above:
Data: 50 03 02 07 0B 06 7F

  • 0x50: Slave address
  • 0x03: Function code
  • 0x02: Data length (2 bytes)
  • 0x07 0x0B: Measurement data (1803 mm)
  • 0x06 0x7F: CRC check

Register Table

Register name Register address Command Description
System recovery 0x00 MODADDR 06 00 00 00 01 CRCH CRCL Write 0x01 to restore factory settings.
Alarm threshold 0x02 MODADDR 06 00 02 MH ML CRCH CRCL Set alarm threshold (range: 40~4000 mm). MH = high bit, ML = low bit.
Baud rate setting 0x04 MODADDR 06 00 04 00 00 CRCH CRCL Write 0x00 for 2400 baud.
MODADDR 06 00 04 00 01 CRCH CRCL Write 0x01 for 4800 baud.
MODADDR 06 00 04 00 02 CRCH CRCL Write 0x02 for 9600 baud.
MODADDR 06 00 04 00 03 CRCH CRCL Write 0x03 for 19200 baud.
MODADDR 06 00 04 00 04 CRCH CRCL Write 0x04 for 38400 baud.
MODADDR 06 00 04 00 05 CRCH CRCL Write 0x05 for 57600 baud.
MODADDR 06 00 04 00 06 CRCH CRCL Write 0x06 for 115200 baud (default).
MODADDR 06 00 04 00 07 CRCH CRCL Write 0x07 for 230400 baud.
MODADDR 06 00 04 00 08 CRCH CRCL Write 0x08 for 460800 baud.
MODADDR 06 00 04 00 09 CRCH CRCL Write 0x09 for 921600 baud.
Timing preset time (default: 200 ms) 0x07 MODADDR 06 00 07 TIMEBUDGETH Range: 20~1000 ms (hex: 0x0014~0x03e8).
Measurement interval (default: 50 ms) 0x08 MODADDR 06 00 08 PERIODH PERIODL CRCH CRCL Range: 1~1000 ms (hex: 0x0001~0x03e8).
ID setting 0x1A MODADDR 06 00 1a 00 MODADDRL CRCH CRCL Set slave address (range: 0x00~0xFE).
Measurement data 0x34 MODADDR 03 00 34 00 01 CRCH CRCL Read distance (upper 8 bits + lower 8 bits).
Output state 0x35 MODADDR 03 00 35 00 01 CRCH CRCL Read sensor status: 0x07 (No Update), 0x00 (Valid), 0x01 (Sigma Fail), 0x02 (Signal Fail), 0x03 (Min Range Fail), 0x04 (Phase Fail), 0x05 (Hardware Fail).
Measurement mode 0x36 MODADDR 06 00 36 00 01 CRCH CRCL Write 0x01 for short distance (≤1.3m).
MODADDR 06 00 36 00 02 CRCH CRCL Write 0x02 for middle distance (≤3m).
MODADDR 06 00 36 00 03 CRCH CRCL Write 0x03 for long distance (≤4m).
Calibration mode 0x37 MODADDR 06 00 37 00 04 CRCH CRCL Write 0x04 to enter calibration mode.
MODADDR 03 00 37 00 01 CRCH CRCL Read calibration status: 0x01 (Start), 0x02 (Failed), 0x03 (Complete).

Was this article helpful?

TOP