
To read Modbus RTU float values correctly, confirm the register address, data type, register count, word order and engineering unit before configuring your PLC or RTU. Where the device specifies an IEEE 754 32-bit float, read its two consecutive 16-bit registers together and reconstruct the documented four-byte sequence.
However, two registers do not automatically mean a floating-point value. A radar may use a 32-bit integer, a scaled measurement or another representation. Selecting “Float” simply because four bytes are returned can produce incorrect readings even when communication works.
Start with the Data Type, Not the Display Format
A successful Modbus transaction confirms that a response has been received and accepted. It does not prove that the application has interpreted the measurement correctly.
Before decoding radar sensor Modbus registers, establish:
- The exact radar model and firmware version.
- The applicable communication document.
- The measured quantity and its unit.
- The starting address and number of registers.
- The numeric representation and any scaling.
- The required arrangement of the returned words.
A PLC tag configured as REAL cannot turn integer data into a valid floating-point measurement merely by changing its display type.
There is also a difference between converting an integer numerically and reinterpreting its binary pattern as a float. For a documented float, the controller must reconstruct and reinterpret the bits correctly.
What the ZLYRADAR V7.2 Protocol Documents Confirm
The V7.2 ranging protocol documents reviewed for this guide list the following measurement entries:
| Register address | Documented quantity | Read quantity | Unit |
|---|---|---|---|
0x0000 |
Filtered air-gap distance | 1 register | cm |
0x0001 |
Filtered air-gap distance | 1 register | mm |
0x0002 |
Water level | 1 register | cm |
0x0003 |
Water level | 1 register | mm |
0x03E8–0x03E9 |
Filtered distance output | 2 registers | mm |
0x03EA–0x03EB |
Unfiltered distance output | 2 registers | mm |
These documents specify function 0x03 for reading. They also list default device address 1 and serial settings of 115200 baud, eight data bits, no parity and one stop bit.
Importantly, the two-register distance entries are not explicitly identified as IEEE 754 floats, and their cross-register word order is not defined in the supplied documents. Their length alone therefore does not justify a Float32 configuration.
Confirm the applicable encoding with ZLYRADAR before implementing those entries. Do not automatically apply this register map to another model or firmware.
Match the Address and Function Code
Modbus PDU register addresses start at zero. PLC software may instead ask for a one-based number or a reference such as 40001. Under that conventional holding-register notation, 40001 corresponds to PDU address zero; check the driver’s convention before entering a number.
For the documented V7.2 filtered-distance entry, 0x03E8 equals decimal 1000. A zero-based driver would use offset 1000. A one-based interface may require 1001. Verify the transmitted starting-address bytes rather than adding one automatically.
Function codes also matter. 0x03 reads holding registers; 0x04 reads input registers. The supplied V7.2 examples use 0x03; other equipment must follow its own map.
A value being read-only does not, by itself, mean that it must be accessed with 0x04.
Separate Byte Order from Word Order
A 32-bit float occupies four bytes, or two 16-bit registers. Modbus sends the high byte of each register first. The device’s mapping determines how the two words form the larger value.
For the following notation, define A, B, C and D as the bytes of the IEEE 754 bit pattern, from most significant to least significant.
| Arrangement | First register’s bytes | Second register’s bytes |
|---|---|---|
| ABCD | A B | C D |
| CDAB | C D | A B |
| BADC | B A | D C |
| DCBA | D C | B A |
These labels describe byte arrangements, not universal PLC menu names. Compare the actual bytes with the driver documentation.
Also check whether a gateway or communication library has already rearranged the data. Applying another swap can undo a correct conversion.
Worked Example: Four Bytes to an Engineering Value
Generic demonstration only—not a ZLYRADAR model-specific register definition.
Assume a device explicitly documents a Float32 measurement in metres with ABCD ordering. Its validated response contains these four measurement bytes:
41 45 70 A4
Only the measurement payload is shown here, not a complete Modbus RTU frame.
| Step | Interpretation |
|---|---|
| First register | 0x4145, decimal 16709 |
| Second register | 0x70A4, decimal 28836 |
| Reconstructed bit pattern | 0x414570A4 |
| IEEE 754 binary32 value | Approximately 12.34000015258789 |
| Engineering display | 12.34 m |
Do not add the register values or treat their decimal representations as the measurement.
A minimal Python check is:
import struct
# Generic example: measurement bytes already in ABCD order.
payload = bytes.fromhex("41 45 70 A4")
value = struct.unpack(">f", payload)[0]
print(value) # 12.34000015258789
print(f"{value:.2f}") # 12.34
Here, > explicitly selects big-endian ordering and f selects the four-byte IEEE 754 format. The extra decimal digits reflect binary representation; they do not imply corresponding sensor accuracy.
The unit comes from the device documentation. Float32 does not inherently mean metres, millimetres or metres per second.
Read Both Registers in One Transaction
For a documented two-register float, request both registers together. Separate requests can combine words from different measurement updates.
One request reduces that risk, but it does not establish that the device internally snapshots both words atomically. Confirm update consistency where rapidly changing measurements make it important.
Before decoding, validate the response address, function, expected byte count and CRC. An exception response or incomplete message is not measurement data.
Troubleshooting Incorrect Readings
| Symptom | Possible causes | Checks |
|---|---|---|
| Extremely large value | Wrong type, word order or starting address | Compare raw words with the applicable map |
| Extremely small value | Integer bits interpreted as a float; wrong arrangement | Confirm encoding before trying swaps |
| Unexpected negative value | Signedness, incorrect decoding, offset or valid directional data | Check the measurand and documented representation |
| Constant zero | Real zero, invalid measurement, wrong register or software substitution | Inspect raw payload, status and timeout handling |
| Sudden jumps | Mixed updates, target changes, wrong field or filtering differences | Log timestamps, raw words and selected output |
| Disagreement with PC software | Different units, fields, filtering, rounding or protocol modes | Compare equivalent measurements at the same time |
These are diagnostic possibilities, not one-to-one fault rules. A plausible number is insufficient proof: verify the configuration across several known conditions.
Keep Invalid Data Separate from Real Zero
Communication failure, decoding failure, invalid measurement and valid zero require different handling.
A timeout should set a communication-quality flag. An unsupported format should remain a decoding error. A documented invalid-measurement code should retain its meaning.
Do not replace every failure with zero. For distance or level monitoring, that can create a convincing but false reading. If retaining the last valid value, preserve its timestamp and mark it stale.
PLC and RTU Commissioning Checklist
For reliable PLC radar sensor integration:
- Match the model, firmware and protocol revision.
- Confirm Modbus mode and serial settings.
- Verify the transmitted address and function.
- Confirm type, register count, ordering and unit.
- Save the raw response before conversion.
- Compare several known measurement conditions.
- Test timeout and invalid-data handling.
- Archive the working configuration.
Need help interpreting a radar response? Send ZLYRADAR your radar model, PLC or RTU model, requested register address and raw response bytes. Include the protocol revision and displayed value so the team can help confirm the correct decoding method.




