Modbus Addressing Basics
Introduction
Using Modbus, different address ranges and functional codes are used by the Master / Client to read or write process data from / to a Slave / IO Server.
This Application Notes gives an overview about the used ranges and functional codes, as well as different types of addressing.
Functional Codes (FC)
Functional Codes are sent by the Master / Client to indicate the Slave / IO Server, which action should be processed.
It also defines which kind of data (Single Coil (1Bit) or hole Register (16Bit)) that should be read or written and which address range should be used.
Typically, the following Functional Codes and Address ranges are used:
In-/Output Single Coil (1Bit) | |
---|---|
Address range 00001 - 09999 | FC1 - Read Coils FC5 Force Single Coil FC15 Force Multiple Coils |
Single Input (1Bit) | |
Address range 10001 - 19999 | FC2 Read Inputs |
Input Register (16Bit) | |
Address range 30001 - 39999 | FC4 Read Input Register |
In-/Output Holding Register (16Bit) | |
Address range 40001 - 49999 | FC3 Read Holding Register FC6 Preset Single Register FC16 Preset Multiple Register |
Address Range
The Address range is already defined by the functional code.
Therefore, in many cases only addresses from 0-9999 are used in engineering tools, no matter which functional code is used.
Example:
When using FC3 to read the first holding register in the address range, the address 1 is used instead of 40001.
Since there is no fixed specification, some manufacturers nevertheless use the whole address range, even if it is predefined by the Functional Code.
In this case, the Slave / IO Server will not accept the requested function if the requested address does not indicate the address range.
In the Diagnosis of Hilscher Master / Client devices, this will be indicated by the following error: "0xC06E000B - Global Exception Error".
The Error 0xC06E000B could also mean, that the requested Functional Code is not supported.
Register Start address
Manufacturers may use one of two types of addressing.
So-called "Zero based" or "One based" addressing.
Some may use address 0 for the first register, and some may use address 1.
Therefore, an Offset needs to be considered, in case devices from different manufacturers are used.