C# Modbus communication from entry to proficiency (18) - Modbus ASCII (0x06 function code and C# code implementation)

insert image description here

1. 06 (0x06) write a single register

Use this function code to write the value of a holding register to the remote address

2. Send message format

insert image description here

The more detailed format is as follows:
start character + slave station address + function code + high bit of register address + low bit of register address + high byte of output value + low byte of output value + LRC + terminator, a total of 17 bytes, of which LRC is calculated The start character and end character are excluded.

3. Return message format

insert image description here

The more detailed format is as follows:
start character + slave station address + function code + high bit of register address + low bit of register address + high byte of output value + low byte of output value + LRC + terminator, a total of 17 bytes, of which LRC is calculated The start character and end character are excluded.

4. Case

Slave station address: 1
Holding register address: 8
Output value: 1000
Suppose you want to set the value of the holding register with slave station address 1 and address 8 as 1000

4.1 Send the message as follows:

0x3a、0x30、0x31、0x30

Guess you like

Origin blog.csdn.net/qq_34059233/article/details/131859814