Modbus
The following is a complete overview of the Modbus registers and functions for your STATOTEST-LASER device:
π MODBUS REGISTERS AND FUNCTIONSβ
π READ HOLDING REGISTERS (0x03)β
| Address | Type | Description | Unit | Range | Example |
|---|---|---|---|---|---|
| 0 | uint16 | Device status | - | 0-1 | 1 (active) |
| 1 | uint16 | Firmware version | - | 0-65535 | 1 |
| 2 | uint16 | Hardware version | - | 0-65535 | 2 |
| 3 | uint16 | Measurement state | - | 0-4 | 0=idle, 2=measuring, 3=done, 4=continuous |
| 4 | uint16 | Distance (low part) | 0.1mm | 0-65535 | 12345 (=1.2345m) |
| 5 | uint16 | Distance (high part) | 0.1mm | 0-65535 | 0 |
| 6 | uint16 | Laser state | - | 0-1 | 0=OFF, 1=ON |
| 7 | uint16 | Temperature | 0.1Β°C | -400-800 | 235 (=23.5Β°C) |
| 8 | uint16 | Voltage | 0.1V | 0-100 | 33 (=3.3V) |
| 9 | uint16 | Signal quality | % | 0-100 | 85 |
| 10 | uint16 | Device address | - | 1-254 | 1 |
| 11 | uint16 | Baudrate code | - | 1-7 | 4 (=19200) |
| 12 | uint16 | Error code | - | 0-17 | 0=OK |
| 13 | uint16 | Bluetooth state | - | 0-1 | 1=enabled |
| 14 | uint16 | WiFi state | - | 0-1 | 0=disabled |
Special distance reading:β
- Address 4, 2 words: Returns the complete 32-bit distance (low + high part)
- Address 4, 1 word: Returns only the low part of the distance
- Address 5, 1 word: Returns only the high part of the distance
π§ WRITE SINGLE REGISTER (0x06)β
| Address | Function | Values | Description | Example |
|---|---|---|---|---|
| 3 | Measurement control | 0=stop, 1=single, 4=continuous | Starts/stops a measurement | 1 |
| 5 | Laser control | 0=OFF, 1=ON | Turns the laser on/off | 1 |
| 10 | Address setting | 1-254 | Changes the Modbus address | 5 |
| 11 | Baudrate setting | 1-7 | Changes the RS485 speed | 4 |
| 13 | Bluetooth control | 0=disable, 1=enable | Turns BT on/off | 1 |
| 14 | WiFi control | 0=disable, 1=enable | Turns WiFi on/off | 1 |
Baudrate codes (address 11):β
| Code | Baudrate |
|---|---|
| 1 | 2400 |
| 2 | 4800 |
| 3 | 9600 |
| 4 | 19200 |
| 5 | 38400 |
| 6 | 57600 |
| 7 | 115200 |
π WRITE SINGLE COIL (0x05)β
| Address | Function | Values | Description |
|---|---|---|---|
| 13 (0x0D) | Start measurement | 0x0000=stop, 0xFF00=start | Alternative way to start a measurement |
βοΈ COMMUNICATION CONFIGURATIONβ
| Parameter | Value |
|---|---|
| Default address | 1 |
| Default baudrate | 19200 |
| Data bits | 8 |
| Parity | None |
| Stop bits | 1 |
| Broadcast address | 255 (supported) |
π MEASUREMENT DATA FORMATβ
Distance (32-bit):β
- Unit: 0.1 mm (0.0001 m)
- Range: 0 - 4294967295 (0-429496.7295 m)
- Example: 12345 = 1.2345 m
Temperature:β
- Unit: 0.1Β°C
- Range: -40.0Β°C to +80.0Β°C
- Example: 235 = 23.5Β°C
Voltage:β
- Unit: 0.1V
- Range: 0.0V to 10.0V
- Example: 33 = 3.3V
π¨ ERROR CODES (Address 12)β
| Code | Description |
|---|---|
| 0 | No error |
| 1 | Low voltage |
| 2 | Internal error |
| 3 | Low temperature |
| 4 | High temperature |
| 5 | Target out of range |
| 6 | Invalid result |
| 7 | Background too strong |
| 8 | Weak reflected signal |
| 9 | Strong reflected signal |
| 10-14 | Hardware errors |
| 15 | Vibration too high |
| 16-17 | Hardware errors |
π COMMAND EXAMPLESβ
Reading the distance (32-bit):β
Command: 01 03 00 04 00 02 CRC
Response: 01 03 04 30 39 00 00 CRC
Result: 12345 = 1.2345 m
Starting a measurement:β
Command: 01 06 00 03 00 01 CRC
Response: 01 06 00 03 00 01 CRC
Turning the laser on:β
Command: 01 06 00 05 00 01 CRC
Response: 01 06 00 05 00 01 CRC
Setting the address to 5:β
Command: 01 06 00 0A 00 05 CRC
Response: 01 06 00 0A 00 05 CRC
Starting a measurement via Write Coil:β
Command: 01 05 00 0D FF 00 CRC
Response: 01 05 00 0D FF 00 CRC
π MEASUREMENT STATES (Address 3)β
| State | Description |
|---|---|
| 0 | Idle |
| 2 | Measurement in progress |
| 3 | Measurement completed |
| 4 | Continuous measurement |
β οΈ NOTESβ
- Broadcast address 255 is supported for all functions
- Configuration changes are saved to the flash memory
- A measurement automatically resets the state to 0 after it is read
- Continuous measurement runs until it is stopped
- All registers are read-only except addresses 3, 5, 10, 11, 13, 14