101modbus protocol

This protocol is applicable to HWT101CT-485 and HWT101DT-485

101modbus protocol

Register Table

ADDR

(Hex)

ADDR

(Dec)

REGISTER NAME

FUNCTION

SERIAL

I/F

Bit15

Bit14

Bit13

Bit12

Bit11

Bit10

Bit9

Bit8

Bit7

Bit6

Bit5

Bit4

Bit3

Bit2

Bit1

Bit0

00

00

SAVE

Save/Restart/Restore to Factory Defaults

R/W

SAVE[15:0]

04

04

BAUD

Serial port baud rate

R/W

BAUD[3:0]

1A

26

IICADDR

Device Address

R/W

IICADDR[7:0]

38

56

GY

Angular velocity Y

R

GY[15:0]

39

57

GZ

Angular velocity Z

R

GZ[15:0]

3F

63

Yaw

Heading Angle

R

Yaw[15:0]

41

65

AUTOPTP

Automatically obtain zero bias peak-to-peak value

R/W

AUTOPTP[15:0]

43

67

AUTOT

Automatically obtain zero bias time

R/W

AUTOT[15:0]

44

68

AUTOTH

Automatically obtain zero bias threshold

R/W

AUTOTH[15:0]

48

72

WORKMODE

Working Mode

R/W

WORKMODE[2:0]

4A

74

GYROPTP

Z-axis static peak-to-peak value

R/W

GYROPTP[15:0]

4B

75

GPTPTIME

Z-axis peak-to-peak acquisition time

R/W

GPTPTIME[15:0]

4C

76

GYROBAIS

Z-axis zero offset

R/W

GYROBAIS[15:0]

4D

77

GBAISSTIME

Z-axis zero offset acquisition time

R/W

GYROBAIS[15:0]

4E

78

GSTATICTHRE

Z-axis stationary threshold

R/W

GSTATICTHRE[15:0]

4F

79

GSTATICTIME

Z-axis stabilization time

R/W

GSTATICTIME[15:0]

50

80

PGSCALE

Z-axis calibration factor P

R/W

PGSCALE[15:0]

52

82

GSCALERANGE

Z-axis calibration angle

R/W

GSCALERANGE[15:0]

61

97

GYROCALITHR

Static detection threshold

R/W

GYROCALITHR[15:0]

63

99

GYROCALTIME

Gyroscope automatic calibration time

R/W

GYROCALTIME[15:0]

6A

106

WERROR

Gyroscope change value

R/W

GYROPTP[15:0]

6E

110

WZTIME

Angular velocity continuous stationary time

R/W

WZTIME[15:0]

6F

111

WZSTATIC

Angular velocity integral threshold

R/W

WZSTATIC[15:0]

74

116

MODDELAY

485 data response delay

R/W

MODDELAY[15:0]

76

118

CALIYAW

Z axis angle reset

R/W

CALIYAW[15:0]

Read register format

  • The data is sent in hexadecimal format, not ASCII.

  • Each register address, register number, and data are represented by two bytes. The high and low bits of the register address are represented by ADDRH and ADDRL, the high and low bits of the register number are represented by LENH and LENL, and the high and low bits of the data are represented by DATA1H and DATA1L.

  • The last two digits of the read instruction are standard CRC check bits. You can use the CRC check bit calculation tool to calculate it. CRC online calculation website arrow-up-right.

Send command

Modbus Address

Function code

Register high 8 bits

Register lower 8 bits

Read length high 8 bits

Read length lower 8 bits

Check digit high 8 bits

Check digit lower 8 bits

ID

0x03 (Read)

ADDRH[15:8]

ADDRL[7:0]

LENH[15:8]

LENL[7:0]

CRCH[15:8]

CRCL[7:0]

Data return

Modbus Address

Function code

Read length

Data high 8 bits

Data lower 8 bits

Data high 8 bits

Data lower 8 bits

Data high 8 bits

Data lower 8 bits

Check digit high 8 bits

Check digit lower 8 bits

ID

0x03 (Read)

LEN[7:0]

DATA1H[15:8]

DATA1L[7:0]

DATAnH

DATAnL

CRCH[15:8]

CRCL[7:0]

Note: All the following examples are instructions when the Modbus address is 0x50 (default). If you change the Modbus address, you need to change the address and CRC check bit in the instruction accordingly.

GX~GZ (angular velocity)

Register name: GX~GZ

Register address: 56~57 (0x38~0x39)

Read/write direction: R

Default value: 0x0000

Note: The y-axis angular velocity does not need to be read

Bit

NAME

FUNCTION

15:0

GY[15:0]

Angular velocity Y = GY[15:0]/32768*2000°/s

15:0

GZ[15:0]

Angular velocity Z = GZ[15:0]/32768*2000°/s

Example:

Send: 50 03 00 39 00 01 59 86 (read Z-axis angular velocity)

Return: 50 03 02 GZH GZL CRCH CRCL

GZ[15:0]=((short)GZH <<8)|GZL;

Roll~Yaw (angle)

Register Name: Roll~Yaw

Register address: 63 (0x3F)

Read/write direction: R

Default value: 0x0000

Bit

NAME

FUNCTION

15:0

Yaw[15:0]

Heading angle Z = Yaw[15:0]/32768*180°

Example:

Send: 50 03 00 3F 00 01 B9 87 (read Z-axis angle)

Return: 50 03 02 YawH YawL CRCH CRCL

Yaw[15:0]=((short)YawH <<8)|YawL;

Write register format

  • The data is sent in hexadecimal format, not ASCII.

  • Each register address and write data are represented by two bytes. The high and low bits of the register address are represented by ADDRH and ADDRL, and the high and low bits of the write data are represented by DATAH and DATAL.

Send command

Modbus Address

Function code

Register high 8 bits

Register lower 8 bits

Data high 8 bits

Data lower 8 bits

Check digit high 8 bits

Check digit lower 8 bits

ID

0x06 (Write)

ADDRH[15:8]

ADDRL[7:0]

DATAH[15:8]

DATAL[7:0]

CRCH[15:8]

CRCL[7:0]

Data return

Modbus Address

Function code

Register high 8 bits

Register lower 8 bits

Data high 8 bits

Data lower 8 bits

Check digit high 8 bits

Check digit lower 8 bits

ID

0x06 (Write)

ADDRH[15:8]

ADDRL[7:0]

DATAH[15:8]

DATAL[7:0]

CRCH[15:8]

CRCL[7:0]

Note: All the following examples are instructions when the Modbus address is 0x50 (default). If you change the Modbus address, you need to change the address and CRC check bit in the instruction accordingly.

CALIYAW (Z-axis angle reset to zero)

Register Name: CALIYAW

Register address: 118 (0x76)

Read/write direction: R/W

Bit

NAME

FUNCTION

15:0

CALIYAW[15:0]

Set the Z axis to zero:

0(0x00): Z axis reset

Example:

Send: 50 06 00 76 00 00 65 91 ( Z-axis angle returns to zero )

Return: 50 06 00 76 00 00 65 91

SAVE (Save/Restart/Restore to Factory)

Register Name: SAVE

Register address: 0 (0x00)

Read/write direction: R/W

Default value: 0x0000

Bit

NAME

FUNCTION

15:0

SAVE[15:0]

Save: 0x0000

Restart: 0x00FF

Factory Reset: 0x0001

Example:

Send: 50 06 00 00 00 FF C4 0B (restart)

Return: 50 06 00 00 00 FF C4 0B

BAUD (serial port baud rate)

Register name: BAUD

Register address: 4 (0x04)

Read/write direction: R/W

Default value: 0x0002

Bit

NAME

FUNCTION

15:4

3:0

BAUD[3:0]

Set the serial port baud rate:

0001(0x01): 4800bps

0010(0x02): 9600bps

0011(0x03): 19200bps

0100(0x04): 38400bps

0101(0x05): 57600bps

0110(0x06): 115200bps

0111(0x07): 230400bps

Example:

Send: 50 06 00 04 00 06 45 88 (set serial port baud rate to 115200)

Return: 50 06 00 04 00 06 45 88

IICADDR (device address)

Register Name: IICADDR

Register address: 26 (0x1A)

Read/write direction: R/W

Default value: 0x0050

Bit

NAME

FUNCTION

15:8

7:0

IICADDR [7:0]

Set the device address for I2C and Modbus communication

0x01~0x7F

Example:

Send: 50 06 00 1A 00 02 24 4D (set the device address to 0x02)

Return: 50 06 00 1A 00 02 24 4D

WORKMODE (Z-axis operation mode)

Register Name: WORKMODE

Register address: 72 (0x48)

Read/write direction: R/W

Default value: 0x0000

Bit

NAME

FUNCTION

15:4

3:0

WORKMODE[3:0]

Set the Z-axis operation mode:

0000(0x00): Normal data mode

0001(0x01): Peak-to-peak mode

0010(0x02): Request zero bias mode

0011(0x03): Calculate the scaling factor mode

Example: Send: 50 06 00 48 00 01 C5 9D (automatically obtain zero offset)

Return: 50 06 00 48 00 01 C5 9D

GYROPTP (Z-axis static peak-to-peak value)

Register Name: GYROPTP

Register address: 74 (0x4A)

Read/write direction: R/W

Default value: 0x0000

Bit

NAME

FUNCTION

15:0

GYROPTP[15:0]

Parameters used in calculating zero bias, automatically obtained by the sensor without setting

Write 0x01 to the "WORKMODE" register to enter the "Peak-to-Peak Mode". In this mode, the sensor automatically calculates the maximum and minimum Z-axis angular velocity within the time set by "GPTPTIME" and records them in "GYROPTP". This data will be used for zero bias calculation filtering in the "Zero Bias Mode".

Z-axis static peak-to-peak value = GYROPTP/1000 (°/s)

Example:

Send: 50 03 00 4A 00 01 A8 5D (read the peak-to-peak value of the Z axis at rest)

Return: 50 03 02 00 4B 05 BF

0x004B=75, Z-axis static peak-to-peak value = 75/1000=0.075 (°/s)

GPTPTIME (Z-axis peak-to-peak acquisition time)

Register Name: GPTPTIME

Register address: 75 (0x4B)

Read/write direction: R/W

Default value: 0x000A

Bit

NAME

FUNCTION

15:0

GPTPTIME[15:0]

Calculate the peak-to-peak time, the default is 10S

Example: Send: 50 06 00 4B 00 0A 74 5A (Set the Z-axis peak-to-peak value acquisition time to 10S)

Return: 50 06 00 4B 00 0A 74 5A

After entering the "Peak-to-Peak Mode", the difference between the maximum and minimum Z-axis angular velocity within the " GPTPTIME " time is obtained and stored in "GYROPTP". This data will be used for zero bias calculation and filtering in the "Bias Mode " .

GYROBAIS (Z-axis zero bias value)

Register name: GYROBAIS

Register address: 76 (0x4C)

Read/write direction: R/W

Default value: 0x0000

Bit

NAME

FUNCTION

15:0

GYROBAIS[15:0]

Horizontal gyro zero bias value, which can be obtained through "zero bias mode"

The Z-axis horizontal gyroscope has a certain zero bias value when it is stationary, and this zero bias value can be used to eliminate the angular velocity when it is stationary. The zero bias value can be automatically calculated by automatically obtaining the zero bias. Enter the "zero bias calculation mode" to automatically calculate the zero bias value based on the peak-to-peak value of "GYROPTP" and the zero bias acquisition time of "GBAISTIME".

Z-axis zero bias value = GYROBAIS/1000 (°/s)

Example:

Send: 50 03 00 4C 00 01 48 5C (read the peak-to-peak value of the Z axis at rest)

Return: 50 03 02 FF A9 C4 06

0x FFA9 = -87, Z-axis static peak-to-peak value = -87/1000 = -0.087 (°/s)

GBAISTIME (Z-axis zero bias acquisition time)

Register name: GBAISTIME

Register address: 77 (0x4D)

Read/write direction: R/W

Default value: 0x000A

Bit

NAME

FUNCTION

15:0

GB A S TIME [15:0]

Time required for horizontal gyro zero bias calculation

Example: Send: 50 06 00 4D 00 0A 94 5B (Set the Z-axis zero offset acquisition time to 10S)

Return: 50 06 00 4D 00 0A 94 5B

The time required to obtain the Z-axis zero offset is used to obtain the zero offset value based on this time.

GSTATICTHRE (Z-axis static threshold)

Register Name: GSTATICTHRE

Register address: 78 (0x4E)

Read/write direction: R/W

Default value: 0x0032

Bit

NAME

FUNCTION

15:0

GSTATICTHRE [15:0]

the GSTATICTHRE [15:0], the stronger the anti-vibration performance and the larger the error.

GSTATICTHRE [15:0] is, the weaker the anti-vibration performance is and the smaller the error is.

Default value: 50

The Z-axis horizontal gyroscope has slight data jitter when it is stationary. This parameter can filter out these slight jitters. When the angular velocity is less than the " GSTATICTHRE " setting value and lasts for the " GSTATICTIME" setting time, it is considered stationary and the Z-axis angular velocity is zero. When the scene with jitter causes Z-axis accumulation, this parameter can be appropriately increased. When it is used in a scene with very slow and uniform rotation, this parameter can be appropriately reduced.

Z-axis zero offset value = GSTATICTHRE/1000 (°/s)

Example:

Send: 50 06 00 4E 00 64 E5 B7 (set the Z-axis static threshold to 0.1g)

Return: 50 06 00 4E 00 64 E5 B7

0x0064=100,100/10000=0.1 (°)

GSTATICTIME (Z-axis stabilization time)

Register name: GSTATICTIME

Register address: 79 (0x4F)

Read/write direction: R/W

Default value: 0x0064

Bit

NAME

FUNCTION

15:0

GSTATICTIME [15:0]

Z-axis determination of stationary time

Z-axis static judgment time threshold. When the angular velocity is less than the value set by "GSTATICTHRE" and lasts for the time set by "GSTATICTIME", it is considered static. If you have high requirements for stabilization time, you can appropriately reduce this parameter. Reducing this parameter can speed up the stabilization time but may also increase the error.

Z-axis stabilization time = GSTATICTIME/1000 (s)

Example:

Send: 50 06 00 4F 00 64 B4 77 (set Z-axis stabilization time to 0.1s)

Return: 50 06 00 4F 00 64 B4 77

0x0064=100, 100/1000=100ms

PGSCALE (Z-axis calibration factor P)

Register name: PGSCALE

Register address: 80 (0x50)

Read/write direction: R/W

default value:

Bit

NAME

FUNCTION

15:0

PGSCALE [15:0]

Range: 0~20000

This parameter is written by the factory using a high-precision turntable. Please do not modify it.

There is an error in the Z-axis gyroscope measurement. This error is measured using a high-precision turntable at the factory and this parameter is written into the sensor. Do not modify this parameter unless necessary. This parameter can be automatically calculated in the "Calculation Factor Mode". After entering the "Calculation Factor Mode", the sensor can be rotated by the angle set by " GSCALERANGE " to calculate the calibration factor.

Z-axis calibration factor P = PGSCALE/10000.0

Example:

Send: 50 03 00 50 00 01 89 9A (read Z-axis calibration factor P )

Return: 50 03 02 27 3B 1F AB

0x273B = 10043, read the Z-axis calibration factor P = 10043 /10000=1.00430

GSCALERANGE (Z-axis angle calibration range)

Register Name: GSCALERANGE

Register address: 82 (0x52)

Read/write direction: R/W

Default value: 0x02D0

Bit

NAME

FUNCTION

15:0

GSCALERANGE [15:0]

When calibrating factors, it is necessary to calibrate according to this parameter

Example:

Send: 50 06 00 52 01 68 25 E4 (set Z-axis calibration angle to 360)

Return: 50 06 00 52 01 68 25 E4

0x0168=360

The angle of rotation required in the Z-axis "scaling factor mode" is generally set to an integer multiple of 360°.

GYROCALITHR (gyro stationary threshold)

Register name: GYROCALITHR

Register address: 97 (0x61)

Read/write direction: R/W

Default value: 0x0000

Bit

NAME

FUNCTION

15:0

GYROCALITHR[15:0]

Set the gyroscope inactivity threshold:

Gyroscope static threshold = GYROCALITHR[15:0]/1000(°/s)

Example:

Send: 50 06 00 61 00 32 54 40 ( set the gyroscope static threshold to 0.05 °/s)

Return: 50 06 00 61 00 32 54 40

When the angular velocity changes less than 0.05 °/s and lasts for "GYROCALTIME", the sensor recognizes it as stationary and automatically resets the angular velocity less than 0.05 °/s to zero.

The setting rule of the gyroscope static threshold can be determined by reading the value of the "WERROR" register. The general setting rule is: GYROCALITHR=WERROR*1.2, unit: °/s

This register needs to be used in conjunction with the GYROCALTIME register.

GYROCALTIME (gyro automatic calibration time)

Register name: GYROCALTIME

Register address: 99 (0x63)

Read/write direction: R/W

Default value: 0x03E8

Bit

NAME

FUNCTION

15:0

GYROCALTIME[15:0]

Set the gyroscope automatic calibration time

Example: Set the gyroscope automatic calibration time to 500ms

Send: 50 06 00 63 01 F4 74 42 ( set high level alarm )

Return: 50 06 00 63 01 F4 74 42

When the angular velocity change is less than " GYROCALITHR " and lasts for 500ms, the sensor recognizes it as stationary and automatically resets the angular velocity less than 0.05 °/s to zero.

This register needs to be used in conjunction with the GYROCALITHR register.

WERROR (gyroscope change value)

Register Name: WERROR

Register address: 106 (0x6A)

Read/write direction: R

Default value: 0x0000

Bit

NAME

FUNCTION

15:0

WERROR[15:0]

Gyroscope change value = WERROR[15:0]/1000*180/3.1415926(°/s)

When the sensor is stationary, the "GYROCALITHR" register can be set by changing this register

WZTIME (angular velocity continuous stationary time)

Register name: WZTIME

Register address: 110 (0x6E)

Read/write direction: R/W

Default value: 0x01F4

Bit

NAME

FUNCTION

15:0

WZTIME[15:0]

Angular velocity continuous stationary time

Example:

Send: 50 06 00 6E 01 F4 E5 81 ( set angular velocity continuous static time 500ms )

Return: 50 06 00 6E 01 F4 E5 81

When the angular velocity is less than " WZSTATIC" and lasts for 500ms, the angular velocity output is 0 and the Z-axis heading angle is not integrated.

This register needs to be used in conjunction with the "WZSTATIC" register.

WZSTATIC (angular velocity integral threshold)

Register name: WZSTATIC

Register address: 111 (0x6F)

Read/write direction: R/W

Default value: 0x012C

Bit

NAME

FUNCTION

15:0

WZSTATIC[15:0]

Angular velocity integral threshold = WZSTATIC[15:0]/1000(°/s)

Example:

Send: 50 06 00 6F 01 F4 E5 81 ( set the angular velocity integral threshold to 0.5 °/s)

Return: 50 06 00 6F 01 F4 E5 81

When the angular velocity is greater than 0.5 °/s, the Z-axis heading angle begins to integrate the acceleration

When the angular velocity is less than 0.5 °/s and lasts for the time set by the register "WZTIME", the angular velocity output is 0 and the Z-axis heading angle is not integrated.

This register needs to be used in conjunction with the "WZTIME" register.

MODDELAY (485 data response delay)

Register Name: MODDELAY

Register address: 116 (0x74)

Read/write direction: R/W

Default value: 0x0BB8

Bit

NAME

FUNCTION

15:0

MODDELAY[15:0]

Set 485 data response delay, default is 3000, unit: us

Example:

Send: 50 06 00 74 03 E8 C4 EF ( set 485 data response delay to 1000us)

Return: 50 06 00 74 03 E8 C4 EF

When the sensor receives the Modbus read command, the sensor delays 1000us and returns the data

This register only supports the Modbus version of the sensor