Modbus dll Free Open source works well.Tried in vb2008. Is the bomb.

Suresoft

Member
Join Date
Jul 2009
Location
Location
Posts
28
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
On Error GoTo errorhandler
TextBox1.Text = Nothing
Using port As New SerialPort("COM2")
' configure serial port
port.BaudRate = 9600
port.DataBits = 7
port.Parity = Parity.Even
port.StopBits = StopBits.One
port.Open()

' create modbus master
Dim master As modbus.Device.IModbusSerialMaster = modbus.Device.ModbusSerialMaster.CreateAscii(port)

Dim slaveID As Byte = 1
Dim startAddress As UShort = 4546 'read address starting at D450
Dim numRegisters As UShort = 20

' read five registers
Dim registers As UShort() = master.ReadHoldingRegisters(slaveID, startAddress, numRegisters)

For i As Integer = 0 To numRegisters - 1
TextBox1.Text = TextBox1.Text & registers(i) & vbCrLf
Next
End Using
Exit Sub
errorhandler:
Dim rseponse As MsgBoxResult
rseponse = MsgBox(ErrorToString, MsgBoxStyle.OkCancel, "Fault Intercepted")
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
On Error GoTo errorhandler
TextBox1.Text = Nothing
Using port As New SerialPort("COM2")
' configure serial port
port.BaudRate = 9600
port.DataBits = 7
port.Parity = Parity.Even
port.StopBits = StopBits.One
port.Open()

' create modbus master
Dim master As modbus.Device.IModbusSerialMaster = modbus.Device.ModbusSerialMaster.CreateAscii(port)

Dim slaveID As Byte = 1
Dim startAddress As UShort = 1024 'read address starting at X0
Dim numRegisters As UShort = 20

' read five registers
Dim registers As Boolean() = master.ReadInputs(slaveID, startAddress, numRegisters)

For i As Integer = 0 To numRegisters - 1
TextBox1.Text = TextBox1.Text & registers(i) & vbCrLf
Next
End Using
Exit Sub
errorhandler:
Timer1.Enabled = False
Dim rseponse As MsgBoxResult
rseponse = MsgBox(ErrorToString, MsgBoxStyle.OkCancel, "Fault Intercepted")
If rseponse = MsgBoxResult.Ok Then
Timer1.Enabled = True
End If

End Sub
 
Last edited:
hi little problem

hi, i'm new of this site :)
i have just a question, i have try your sw and when i push the button vb replace a exception ( Modbus.IO.ModbusAsciiTransport )

where do you copy the dll? in system 32?
i've need to register whit regsrv32?
sorry but i'm new in vb2008, can you help me?
thanks
 
hi all thanks for that dll
but i want to ask about how do you convert D450 => 4546 and X0 => 1024
and what is the outher data map
 

Similar Topics

Somebody knows where can I get a dll?, I´m learning to comunicate with plc and I need the bigest help than you can give me. Sorry for my English...
Replies
2
Views
5,264
Hi folks, I have a Controllogix in communication with a zigbee coordinator using Logix AIO for modbus tcp. This zigbee coordinator have 3 slaves...
Replies
2
Views
100
Hi, I'm setting up a modbus master on an S7-300. It seems to work in OB1 but not when I use it in OB35. Does anyone have any ideas why? Could...
Replies
10
Views
110
Hi Everyone, i was hoping for a little help with this module. i have data that needs to be read from a different plc through the Modbus plus...
Replies
11
Views
261
I have a PH meter that I am trying to bring its data into 1756-L81. I have downloaded the Rockwell MODBUS AOI kit, but I am not sure if I need to...
Replies
5
Views
192
Back
Top Bottom