Modbus Register Offset Calculator
Convert between Hex, Decimal, and traditional 40001 holding register offsets.
Modbus Parameters
Enter a 5-digit or 6-digit address starting with 0, 1, 3, or 4.
Calculated Offset
Introduction to Modbus Addressing
In industrial automation, the Modbus protocol remains one of the most ubiquitous communication standards. However, one of the most common pitfalls engineers face during system integration—whether programming a PLC, configuring an HMI, or setting up a SCADA system—is correctly addressing Holding Registers. The discrepancy between the human-readable 1-based Application Layer addressing and the 0-based Data Link Layer addressing often leads to the notorious “off-by-one” error.
The Difference Between Application and Protocol Layers
Modbus documentation typically presents register addresses using a 5-digit or 6-digit schema, where the leading digit denotes the memory block and function code. For Holding Registers, this leading digit is a 4. Thus, the first holding register is commonly referred to as 40001.
However, the actual data frame transmitted over the wire (the protocol address) does not include this leading ‘4’ and is zero-indexed. To successfully request data from register 40001 using Function Code 03 (Read Holding Registers) or Function Code 06/16 (Write), the protocol address transmitted must be 0x0000.
The Formula for Calculating Modbus Offsets
Converting a standard holding register number to its decimal or hexadecimal protocol offset requires two straightforward steps:
- Strip the prefix: Ignore the leading ‘4’ (or ’40’ in 6-digit addressing).
- Subtract one: Since the protocol is 0-based, subtract 1 from the remaining value to get the decimal offset.
Protocol Address (Decimal) = Register Value – 40001
Practical Conversion Examples
- Register 40001: 40001 – 40001 = 0 (Hex: 0x0000)
- Register 40002: 40002 – 40001 = 1 (Hex: 0x0001)
- Register 40100: 40100 – 40001 = 99 (Hex: 0x0063)
- Register 41000: 41000 – 40001 = 999 (Hex: 0x03E7)
Common Integration Pitfalls and Manufacturer Nuances
While the standard dictates a 0-based protocol offset, not all manufacturers implement this uniformly. Some devices, particularly in legacy systems, utilize 1-based addressing at the protocol level. It is crucial to consult the specific vendor documentation.
If the device manual lists addresses purely in hexadecimal (e.g., 0x0063), it is highly likely that this is the exact offset to be transmitted, and no further subtraction is required. Conversely, if the documentation provides a 4xxxx number, the subtraction rule applies.