Read Input Register (Function 4)

The Read Input Register function reads the analog inputs.

In this example the first two analog inputs of slave number 11 are read. The analog outputs start at an offset of 0x0000. The length indicates the number of words to be read. A KL3002 has two words of input data, which is why the value to be entered in Count low is two.

Query

Byte Name

Modbus RTU

Modbus ASCII

Start - Frame

":"

0x3A

Address

11

0x0B

"0B"

0x30, 0x42

Function-Code

4

0x04

"04"

0x30, 0x34

Start-Address high

0

0x00

"00"

0x30, 0x30

Start-Address low

0

0x00

"00"

0x30, 0x30

Count high

0

0x00

"00"

0x30, 0x30

Count  low

2

0x02

"02"

0x30, 0x32

Error Check, LRC/CRC

 

0x71, 0x61 

"EF"

0x45, 0x46

End -Frame

 

t1-t2-t3

CRLF

0x0D, 0x0A

The fieldbus coupler answers with byte count 4, i.e. four bytes of data are returned. The query was for two analog channels, and these are now distributed over 2 words. In the analog input process image, the first channel has the value 0x0038, while the second channel has the value 0x3F1B.

Response

Byte Name

Modbus RTU

Modbus ASCII

Start - Frame

":"

0x3A

Address

11

0x0B

"0B"

0x30, 0x42

Function-Code

4

0x04

"04"

0x30, 0x34

Byte Count

4

0x04

"04"

0x30, 0x34

Data 1 High-Byte

0

0x00

"00"

0x30, 0x30

Data 1 Low-Byte

56

0x38

"38"

0x33, 0x38

Data 2 High-Byte

63

0x3F

"3F"

0x33, 0x46

Data 2 Low-Byte

11

0x0B

"0B"

0x30, 0x42

Error Check, LRC/CRC

 

0x80, 0x7E 

"6A"

0x36, 0x41

End - Frame

 

t1-t2-t3

CRLF

0x0D, 0x0A