Read or Write Registers (Function 23)

A number of analog outputs can be written and a number of analog inputs read with one telegram using the Read / Write Registers function. In this example the first two analog output words are written, and the first two analog inputs are read. The analog outputs start at offset 0x0800, while the inputs start at offset 0x0000. Here the offset always describes a word. Offset 0x0003 writes to the fourth word in the output process image. The length indicates the number of words, and the Byte count is formed from the combination of all the bytes that are to be written. Example: 4 words – correspond to a byte count of 8.

The data bytes contain the values for the analog outputs. In this example, two words are to be written. The first word is to receive the value 0x3FFF, and the second word is to receive the value 0x7FFF.

Query

Byte Name

Modbus RTU

Modbus ASCII

Start - Frame

":"

0x3A

Address

11

0x0B

"0B"

0x30, 0x42

Function-Code

23

0x17

"17"

0x31, 0x17

Read Start-Address high

0

0x00

"00"

0x30, 0x30

Read Start-Address low

0

0x00

"00"

0x30, 0x30

Read Länge high

0

0x00

"00"

0x30, 0x30

Read Länge low

2

0x02

"02"

0x30, 0x32

Write Start-Address high

8

0x08

"08"

0x30, 0x38

Write Start-Address low

0

0x00

"00"

0x30, 0x30

Write Länge high

0

0x00

"00"

0x30, 0x30

v Länge low

2

0x02

"02"

0x30, 0x32

Byte Count

4

0x04

"04"

0x30, 0x34

Data 1 high

63

0x3F

"3F"

0x33, 0x46

Data 1 low

255

0xFF

"FF"

0x46, 0x46

Data 2 high

127

0x7F

"7F"

0x37, 0x46

Data 2 low

255

0xFF

"FF"

0x46, 0x46

Error Check, LRC/CRC

 

0x76, 0xD3 

"12"

0x31, 0x32

End - Frame

 

t1-t2-t3

CRLF

0x0D, 0x0A

Response

The coupler replies with the start address and the length of the bytes to be transferred in Byte count. The data information follows. In this example the first word contains 0x0038 while the second word contains 0x3F0B.

Byte Name

Modbus RTU

Modbus ASCII

Start - Frame

":"

0x3A

Address

11

0x0B

"0B"

0x30, 0x42

Function-Code

23

0x17

"17"

0x31, 0x17

Byte Count

4

0x04

"04"

0x30, 0x34

Data 1 high

0

0x00

"00"

0x30, 0x30

Data 1 low

56

0x38

"38"

0x33, 0x38

Data 2 high

63

0x3F

"3F"

0x33, 0x46

Data 2 low

11

0x0B

"0B"

0x30, 0x42

Error Check, LRC/CRC

 

0xF8, 0xA7 

"E3"

0x45, 0x33

End - Frame

 

t1-t2-t3

CRLF

0x0D, 0x0A