HomeKnowledgeDetailed explanation of how two XB6-C01SP serial port modules implement Modbus RTU master-slave communication

Detailed explanation of how two XB6-C01SP serial port modules implement Modbus RTU master-slave communication

2024-07-19

The SolidotXB6-C01SP is a slice 1-channel serial communication module that uses the X-bus Backplane bus and is compatible with Solidot XB6 series coupler modules. It provides three serial communication functions: Modbus master/slave, Freeport and Transparent Transmission. The module requires little space and features simple data exchange, meeting the serial communication requirements of various application scenarios.

Modbus RTU is a serial communication protocol and one implementation of the Modbus protocol. The Modbus protocol defines a master/slave structure in which the master device can initiate requests and the slave devices can respond to these requests. The most common Modbus RTU communication example in industrial applications is reading from and writing to devices such as intelligent instruments and frequency converters.

Detailed explanation of how two XB6-C01SP serial port modules implement Modbus RTU master-slave communication

↑ Solidot Slice serial communication moduleXB6-C01SP

1. System topology diagram

Detailed explanation of how two XB6-C01SP serial port modules implement Modbus RTU master-slave communication

2. Parameter settings for the Two serial port modules

1. Introduction to the relevant parameters in the Solidot XB6-C01SP product manual

Parameter name

Description

Value range

Explanation

Communicate Mode

Communication Mode

0

MRM

Modbus RTU master (Modbus RTU master mode)

1

MRS

Modbus RTU slave (Modbus RTU slave mode)

2

MAM

Modbus ASCII Master (Modbus ASCII master mode)

3

MAS

Modbus ASCII Slave (Modbus ASCII slave mode)

4

FP

Freeport (Freeport mode)

5

PT

PassThrough (Transparent Transmission mode)

Serial Baud

Serial port baud rate

0

1200 bps

1

2400 bps

2

4800 bps

3

9600 bps

4

19200 bps

5

38400 bps

6

57600 bps

7

115200 bps

Serial Stop Bit

Stop Bit

0

1 bit

1

2 bits

Serial Parity

Parity

0

None (no parity check)

1

Odd (odd parity check)

2

Even (even parity check)

Serial Word Format

Word Format

0

8 Bits

1

7 Bits

Modbus Slave ID

Modbus slave station number [1]

1 ... 247

Valid in slave mode, default 1

Modbus slave Respond Delay

Slave response delay / master polling delay / FP output data transmission interval [2]

0 ... 65535

Unit: ms, default 50

2. Parameter settings for the serial port module of slave 1

Detailed explanation of how two XB6-C01SP serial port modules implement Modbus RTU master-slave communication

3. Parameter settings for the serial port module of slave 2

Detailed explanation of how two XB6-C01SP serial port modules implement Modbus RTU master-slave communication

 

3. Examples of write Commands in Modbus RTU slave mode and read Commands in Modbus RTU master mode

1. Introduction to the relevant parameters for write commands in Modbus RTU slave mode in the Solidot XB6-C01SP product manual

Request (downstream data)

byte number

Function description

Note

Example

1

control word

See control word definition table

0 x 01

2

command code

See command code definition table

0 x 13

3

Register address HI

0 x 00 ... 0 x 01

0 x 00

4

Register address LO

0 x 00 ... 0xFF

0 x 0 A

5

Number of Registers HI

0 x 00 ... 0 x 01

0 x 00

6

Number of Registers LO

0 x 00 ... 0xFF

0 x 02

7

Data 1

0 x 00 ... 0xFF

0xAA

8

Data 2

0 x 00 ... 0xFF

0xAB

9

Data 3

0 x 00 ... 0xFF

0xAC

…

…

…

…

39

Data 33

0 x 00 ... 0xFF

0xAE

40

Data 34

0 x 00 ... 0xFF

0xAF

Response (upstream data)

byte number

Function description

Note

Example

1

status word

See status word definition table

0 x 00

2

command code

See command code definition table

0 x 13

3

Register address HI

0 x 00 ... 0 x 01

0 x 00

4

Register address LO

0 x 00 ... 0xFF

0 x 0 A

5

Number of Registers HI

0 x 00 ... 0 x 01

0 x 00

6

Number of Registers LO

0 x 00 ... 0xFF

0 x 03

.. 40

Reserve

NULL

-

2. Introduction to the relevant parameters for read commands in Modbus RTU master mode in the Solidot XB6-C01SP product manual

Request (downstream data)

byte number

Function description

Note

Example

1

control word

00H: command released; 01H: command enabled

0 x 01

2

station number

Interacting slave station number 1 ... 247

0 x 02

3

Function code

0FH, 10H

0 x 10

4

Register address HI

0000H ... FFFFH

0 x 00

5

Register address LO

0xC8

6

Number of registers HI

Discrete: 1 ... 256

Registers: 1 ... 16

0 x 00

7

Number of registers LO

0 x 03

8

Byte Count

Discrete: 1 ... 32, Register: 1 ... 32

0 x 06

9

Data 1 HI

0 x 00 ... 0xFF

0xFF

10

Data 1 LO

0 x 00 ... 0xFF

0xFF

11

Data 2 HI

0 x 00 ... 0xFF

0xAA

12

Data 2 LO

0 x 00 ... 0xFF

0xAA

13

Data 3 HI

0 x 00 ... 0xFF

0 x 55

14

Data 3 LO

0 x 00 ... 0xFF

0 x 55

.. 40

Reserved

NULL

-

Response (upstream data)

byte number

Function description

Note

Example

1

status word

See fault code

0 x 00

2

station number

Slave station number 1 ... 247

0 x 02

3

Function code

0FH, 10H

0 x 10

4

Register address HI

0000H ... FFFFH

0 x 00

5

Register address LO

0xC8

6

Number of Registers HI

Discrete: 1 ... 256

Register: 1 ... 32

0 x 00

7

Number of Registers LO

0 x 03

.. 40

Reserve

NULL

-

3. Example of master/slave data read/write

Detailed explanation of how two XB6-C01SP serial port modules implement Modbus RTU master-slave communication

3.1 XB6-C01SP slave mode data parsing

Downstream data: W16-W29 (20 words/40 bytes in total)

Byte 1

01

Control word (1: enable; 0: disable; other: clear)

Byte 2

14

Command code (14 in XB6-C01SP slave mode means write holding)

Byte 3

00

Register address high byte

Byte 4

00

Register address low byte

Byte 5

00

Number of registers high byte

Byte 6

03

Number of registers low byte

Byte 7

12

Data 1

Byte 8

34

Data 2

Byte 9

56

Data 3

Byte 10

78

Data 4

Byte 11

99

Data 5

Byte 12

99

Data 6

Upstream data: W2-W15 (20 words/40 bytes in total)

Byte 1

00

Status word (00: normal, 80: invalid command code, 01: Illegal data address)

Byte 2

14

command code

Byte 3

00

Register address High Byte

Byte 5

00

Register address Low Byte

Byte 6

00

Number of Registers High Byte

Byte 7

03

Number of Registers Low Byte

3.2 XB6-C01SP master mode data parsing

Downstream data: W40-W53 (20 words/40 bytes in total)

Byte 1

01

Control word (1: continuous polling transmission; 0: stop transmission)

Byte 2

01

Slave address

Byte 3

03

Function code

Byte 4

00

Register address high byte

Byte 5

00

Register address low byte

Byte 6

00

Number of registers high byte

Byte 7

03

Number of registers low byte

Upstream data: W2C-W3F (20 words/40 bytes in total)

Byte 1

00

status word

Byte 2

01

Slave number

Byte 3

03

Function code

Byte 4

06

Data field byte count

Byte 5

12

Data 1 high byte

Byte 6

34

Data 1 low byte

Byte 5

56

Data 2 high byte

Byte 6

78

Data 2 low byte

Byte 5

99

Data 3 high byte

Byte 6

99

Data 3 low byte