An interesting idiosyncrasy of Modbus communication is that the address values specified within Modbus data frames are relative rather than absolute.
Since each Modbus read or write function only operates on a limited range of register addresses, there is no need to specify the entire address in the data frame.
For example, Modbus function code 02 reads discrete input registers in the device with an absolute address range of 10001 to 19999 (i.e. all the addresses beginning with the digit “1”).
Therefore, it is not necessary for the “read” command function 02 to specify the first digit of the register address.
Instead, the read command only needs to specify a four-digit “relative address” specifying how far up from the beginning of the address range (in this case, from 10001) to go.
An analogy to aid your understanding of relative addressing is to envision a hotel building with multiple floors.
The first digit of every room number is the same as the floor number, so that the first floor only contains rooms numbered in the 100’s, the second floor only contains rooms numbered in the 200’s, etc.
With this very orderly system of room numbers, it becomes possible to specify a room’s location in more than one way.
For example, you could give instructions to go to room 314 (an absolute room number), or alternatively, you could specify that same room as “number 14 (a relative room number) on the third floor”. To a hotel employee who only works on the third floor, the shortened room number might be easier to remember.
In Modbus, relative addresses are just a little bit more complicated than this. Relative addresses actually span a range beginning at zero, while absolute addresses begin with “1” as the leastsignificant digit.
This means there is an additional offset of 1 between a Modbus relative address and its corresponding absolute address.
Returning to the hotel analogy, imagine the very first room on the third floor was room 301 (i.e. there was no room 300) and that the relative address represented the number of rooms past that first room.
In this unintuitive scheme, room 314 could be specified as “the 13th room after the starting room on the third floor”. If this seems needlessly confusing, you are not alone. Welcome to Hotel Modbus.
A few examples are given here for illustration:
In each case, the pattern is the same: the relative address gets added to the first address of that range in order to arrive at the absolute address within the Modbus device. Referencing the first example shown above: 2439 (relative address) + 10001 (first address of register range) = 12440 (absolute address).
Thankfully, the only time you are likely to contend with relative addressing is if you program a computer using some low-level language such as assembly or C++.
Most high-level industrial programming languages such as Function Block or Ladder Diagram make it easy for the end-user by allowing absolute addresses to be directly specified in the read and write commands.
In a typical PLC program, for example, you would read contact register 12440 by simply specifying the number 12440 within the address field of a “read 02” instruction.
© 2019-2021 by Tony R. Kuphaldt – under the terms and conditions of the Creative Commons Attribution 4.0 International Public License
VFD simulator download: Master the online tool from the Yaskawa V1000 & programming software for…
The conveyor sorting machine is widely used in the packing industries using the PLC program…
Learn the example of flip-flop PLC program for lamps application using the ladder logic to…
In this article, you will learn the STAR DELTA programming using PLC controller to start…
Lube oil consoles of rotary equipment packages in industrial process plants are usually equipped with…
Rotating equipment packages such as pumps, compressors, turbines need the lube oil consoles for their…