Modbus/TCP & Modbus RTU Function Codes
January 09 UDA2182 Communications User Guide 23
8.3 Function Code 04 - Read Input Registers
Description
Function code 04 (3X references) provides read access to the UDA signals.
If a request is made to an address that does not exist in the map in Section 101, the UDA will honor that
request and return zeros for that address. These registers are read-only.
Broadcast is not supported.
Query
The query message specifies the starting register and quantity of registers to be read. Registers are
addressed starting at zero: registers 1-16 are addressed as 0-15.
Example:
Read PV1, PV2, TEMP1, and TEMP2 as floating point values in the UDA at slave address 1.
Query message format for function code 04
Slave
Address
(00 for TCP)
Function
Code
Starting
Address
High
Starting
Address
Low
Number
Addresses
High
Number
Addresses
Low
CRC
(RTU)
CRC
(RTU)
TCP Example 00 04 00 00 00 08
RTU Example 01 04 00 00 00 08 CRC CRC
Response
The register data in the response message is packed as two bytes per register. For each register, the first
byte contains the high order bits and the second contains the low order bits.
The floating point values require two consecutive registers. The word order of the floating point number is
determined by the setting of the word swap configuration value. In this example, and the examples that
follow, the word swap is set to yes for big endian. Refer to subsection 7. The first 16 bits of the response
contain the IEEE MSB of the float value. The second 16 bits of the response contain the IEEE LSB of the
float value. If the master station requests only one register at an address of a floating point value, then half
of a float will be returned.
Example:
Return PV1, PV2, TEMP1, and TEMP2 where PV1=100.0, Analog PV2=100.0, TEMP1=100.0,
and TEMP2=55.32
Response message format for function codes 04
Slave
Address
(00 for TCP)
Function
Code
Byte
Count
Data Data Data Data CRC
(RTU)
CRC
(RTU)
TCP Example 00 04 08 42 C8 00 00
(100)
42 C8 00 00
(100)
42 C8 00 00
(100)
42 5D 47 AE
(55.32)
RTU Example 01 04 08 42 C8 00 00
(100)
42 C8 00 00
(100)
42 C8 00 00
(100)
42 5D 47 AE
(55.32)
CRC CRC