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

insert image description here

1. 0F (0x0F) write multiple coil output

Use this function code to write the status of multiple coils into 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 coil start address + low bit of coil start address + high byte of coil quantity + low byte of coil quantity + number of bytes occupied by coil + coil output Value low byte +... + coil output value high byte + LRC + terminator, a total of 19+2N bytes, N is the number of bytes occupied by the coil, and the start character and terminator are excluded during LRC calculation.

3. Return message format

insert image description here

The more detailed format is as follows:
start character + slave station address + function code + coil start address high + coil start address low + coil quantity high byte + coil quantity low byte + LRC + terminator, a total of 17 bytes, Among them, the start character and the end character are excluded during LRC calculation.

4. Case

Slave station address: 1
Coil start address: 0
Coil number: 10
Suppose you want to set the value of a total of 10 coils with the slave station address as 1 and the start address as 0 ࿰

Guess you like

Origin blog.csdn.net/qq_34059233/article/details/131860108
Recommended