Click here to Skip to main content
15,885,365 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
does anyone has a code for c# for writing a single coil (RTU Modbus)?

What I have tried:

tried to search on google for the code but didnt find anything
Posted
Updated 28-May-18 0:05am

1 solution

You might write your own code. It is not difficult. Start by studying : the MODBUS specifications[^].
Suppose you want to write 1 to the coil at address 250. Then you have to send on the serial line the following request (assuming the lave address is 1):
slv  fun   address    data    checksum
0x01 0x05 0x00 0xFA 0xFF 0x00 0x0B 0xAC

The only tricky part is the checksum computation. However, just Googling you could find available code for that.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900