Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi guys, I have C# programming wish to connected to my controller based on RTU Modbus, I wish record temperature in my PC real time using Visual Studio C# my project. Any body help me to solve my problem by received Serial Code Samples of yours. i wishing connected Real Time Controller with PC.

What I have tried:

VB
"Connect!" Then
    scm485.PortName = cbComm0.Text
    scm485.BaudRate = "9600"
    scm485.DataBits = "8"
    scm485.Parity = Parity.None
    scm485.StopBits = StopBits.Two
    scm485.RtsEnable = False
    scm485.DtrEnable = False
    scm485.WriteTimeout = 10000
    scm485.ReadTimeout = 10000
    scm485.Handshake = Handshake.XOnXOff
    scm485.Open()

    if scm485.IsOpen = True Then
        cmdEx.Text = "Disconnect!"
Posted
Updated 11-Jun-16 22:19pm
v2
Comments
OriginalGriff 12-Jun-16 3:56am    
And?
What is the problem?
What help do you need?
George Jonsson 12-Jun-16 4:12am    
This is not C# code you are showing, it looks more like VB.
Which language are you really using?
Philippe Mori 12-Jun-16 19:09pm    
My vote of 1... You are not even able to tag the proper language!

1 solution

Well, you need to know what registers/coils you need to read - that is, what MODBUS functions, and the register/coil addresses you need to get data from - If you're using the .Net serial port implementation you're already up sh*t creek unfortunately, its DataReceived event may or may not play well with your device on the other end of the serial cable

There's a project set up here Simple Modbus Protocol in C# / .NET 2.0[^] that may help you get started, and a MODBUS protocol manual here http://modbus.org/docs/PI_MBUS_300.pdf[^] that may be useful

since as OG points out, you havnt told us what information/help you need and/or what MODBUS device you're using, thats about as much as one can offer you by way of help

[edit]
this GitHub - NModbus4/NModbus4: NModbus4 is a C# implementation of the Modbus protocol.[^] may also help
[/edit]
 
Share this answer
 
v2

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