How Can We Help?

Print

Modbus Addressing / Standard Modbus Data Address String / Modbus Function Codes

 

Coils = digital outputs equivalent to a coil in a relay scheme.
The Modbus data type is 0.
It is often noted as 0x, which makes addressing easier.
Data type 0x is available for reading and writing.
For reading, the function code 1 (FC01 and 01h in hexadecimal) is used.
To write such data, function code 5 (FC05 and 05h) is used.
For writing several consecutive data, function code 15 (0Fh) is used.
This data type is noted in different ways:
%M1, 00001, 000001 (for the first variable)…
According to the interpretation of the standard, the notation should be 0x0000 (up to 0xFFFF), in hexadecimal.

Input Status = digital inputs equivalent to a contact in a relay scheme.
The Modbus data type is 1.
It is often referred to as 1x, which makes addressing easier.
Data type 1x is available for reading only.
For reading, function code 2 (FC02 and 02h) is used.
This data type is noted in different ways:
%i1, 10001, 100001..,
The notation should be 1×0000 (up to 1xFFFF).

Input Registers = digital inputs equivalent to a register (hence the name), or a non-binary value (a 16-bit word).
At that time the choice was not like nowadays…
The Modbus data type is 3.
It is often referred to as 3x, which makes addressing easier.
Data type 3x is available for reading only.
For reading, function code 4 (FC04 and 04h) is used.
This data type is noted in different ways:
%IW1, 30001, 300001..,
The notation should be 3×0000 (up to 3xFFFF).

Holding Registers = digital outputs equivalent to a register (hence the name), or a non-binary value (a 16 bit word).
The Modbus data type is 4.
It is often referred to as 4x, which makes addressing easier.
Data type 4x is available for reading and writing
For reading, function code 3 (FC03 and 03h) is used.
To write data of this type, function code 6 (FC06 and 06h) is used.
For writing several consecutive data, function code 16 (10h) is used.
This type of data is noted in different ways:
%MW1, 40001, 400001..,
The notation should be 4×0000 (up to 4xFFFF).

There is often confusion between the notation (which is virtual) and the address.
The fact of using the address in hexadecimal, allows to get rid of the different notations as described above.
Indeed, for small applications, there will be no problem, the decimal value of the address is not higher than 9999.
But when you go to larger databases, it’s a mess

49999 is for example the 10000th word of type 4, what if the 10001st word should be used? In general, this is noted 410000 (but you change the scale, it is not practical), it is often e rit 50000 (but this is not very logical, the type is 4, not 5).
Some people also write it as 4×9999, then 4×10000…
By writing in hexadecimal, you can use all the available addresses and the notation is more readable.
The 10000th word is 4×2710, the next will be 4×2711… The conversion is easy with the Windows calculator, or in the PLC itself.