Modbus Value Encoder
Enter the value you want to send and pick the data type. You get the registers for every byte order in hex and decimal, plus the frame that writes them.
Value
ExampleAs in the register map: the device value is the register divided by this number. Integer types only.
Registers
| Order | Hex | Decimal | Bytes |
|---|
Write request
The frame a master sends to write these registers: function 06 for one register, 16 for more.
- Modbus RTU (CRC low byte first)
- Modbus TCP (transaction 1)
Runs entirely in your browser. Nothing you enter is sent to a server.
Data types at a glance
| Type | Registers | Range |
|---|---|---|
| UInt16 | 1 | 0 … 65535 |
| Int16 | 1 | −32768 … 32767 |
| UInt32 | 2 | 0 … 4294967295 |
| Int32 | 2 | −2147483648 … 2147483647 |
| Float32 | 2 | ±3.4e38, ~7 digits |
| UInt64 | 4 | 0 … 18446744073709551615 |
| Int64 | 4 | −9223372036854775808 … 9223372036854775807 |
| Float64 | 4 | ±1.8e308, ~15 digits |
How it works
A Modbus register holds 16 bits. Larger values are split into bytes and spread over two or four registers, and the device decides in which order. The encoder builds the bytes of your value and shows them in all four orders. Pick the row your device expects; if you are not sure, read a known value first with the register decoder and use the same order for writing.
Integer types with scaling work the way register maps describe them. A setpoint of 230.5 V with “÷10” is sent as 2305. The calculation is done in exact decimal, so 230.55 ÷10 is rounded to 2306 and you are told about it.
Common mistakes
- Writing half a value. A 32-bit value needs both registers in one request (function 16). Two separate writes with function 06 leave the device with a mixed value in between, and many devices reject them.
- Forgetting the scaling. Writing 230 to a register that expects tenths sets 23.0.
- Negative numbers in unsigned registers. -1 becomes 65535 (FFFF). Check whether the register is signed before writing below zero.
- Read-only registers. Input registers (3x) cannot be written at all. Some holding registers are read-only too and answer with exception 02 or 03.
Questions from practice
How do I write a float to a Modbus register?
Choose Float32, type the value and pick the byte order your device uses. Write both registers at once with function 16, starting at the first register of the pair. The Write request panel shows the complete frame.
Why does 0.1 become 0.100000001?
Float32 stores numbers in binary with about 7 significant digits, and 0.1 has no exact binary form. The nearest value it can hold is 0.100000001. Devices show it as 0.1, so this is normal. Use Float64 or a scaled integer if you need exact decimals.
How are negative numbers stored?
Signed types use two's complement. -1 is FFFF in Int16 and FFFF FFFF in Int32; -10 with scaling ÷10 is -100, which is FF9C. If the register map says UInt16, the device cannot take negative values at all.
Should I use function 06 or 16?
Function 06 writes exactly one register. Function 16 writes one or more registers in a single request, which is required for 32- and 64-bit values. Some devices only accept function 16, even for a single register; the manual usually says so.
What does scaling ÷10 mean here?
It is the same scaling the register map gives for reading: the device value is the register divided by 10. To write 230.5, the encoder sends 2305. ÷100 and ÷1000 work the same way.
Related tools
- Register DecoderFloat32, Int32, UInt16 and bits in every byte order, plus Find my value.
- Address Converter40001 ↔ offset 0, 4x/3x/0x/1x notation, 5- and 6-digit addresses.
- CRC-16 CalculatorModbus RTU checksum in wire order, plus a full frame check.