286 • Common MODBUS functions
Function code FC4 (Read input registers)
Modular I/O System
ETHERNET TCP/IP
6.2.4
Function code FC4 (Read input registers)
This function serves to read a number of input words (also ”input register”).
Request
The request determines the address of the start word (start register) and the
quantity of the registers to be read. Addressing starts with 0.
Example: An inquiry of the registers 0 and 1:
Byte
Field name
Example
Byte 0, 1
Transaction identifier
0x0000
Byte 2, 3
protocol identifier
0x0000
Byte 4, 5
length field
0x0006
Byte 6
unit identifier
0x01 not used
Byte 7
MODBUS function code
0x04
Byte 8, 9
reference number
0x0000
Byte 10, 11
Word count
0x0002
Response
The register data of the answer is packed as 2 bytes per register. The first byte
has the higher value bits, the second the lower values.
Byte
Field name
Example
.....
Byte 7
MODBUS function code
0x04
Byte 8
Byte count
0x04
Byte 9, 10
Value Register 0
0x1234
Byte 11, 12
Value Register 1
0x2345
The contents of register 0 are shown by the value 0x1234 and the contents of
register 1 is 0x2345.
Exception
Byte
Field name
Example
.....
Byte 7
MODBUS function code
0x84
Byte 8
Exception code
0x01 or 0x02