Using Modbus.DLL

693 views
Skip to first unread message

Defende

unread,
May 19, 2009, 12:11:44 PM5/19/09
to NModbus
I would like to know if I can use the library modbus.dll with VB.Net?

Scott Alexander

unread,
May 19, 2009, 12:31:24 PM5/19/09
to NModbus...@googlegroups.com
Yes.

Scott

Defende

unread,
May 19, 2009, 1:52:32 PM5/19/09
to NModbus
ok, thanks.
Now another question - I will use with VB6.0 using modbus.dll? if so
how could I be using it because I can not reference the dll.

thanks.

On May 19, 1:31 pm, Scott Alexander <sja...@gmail.com> wrote:
> Yes.
>
> Scott
>
>
>
> On Tue, May 19, 2009 at 9:11 AM, Defende <rodrigodefe...@gmail.com> wrote:
>
> > I would like to know if I can use the library modbus.dll with VB.Net?- Hide quoted text -
>
> - Show quoted text -

Scott Alexander

unread,
May 19, 2009, 2:10:15 PM5/19/09
to NModbus...@googlegroups.com

Defende

unread,
May 19, 2009, 2:36:31 PM5/19/09
to NModbus
Ok i see but i don´t have any file .tlb for this modbus.dll.
Do you have it?

thanks

On May 19, 3:10 pm, Scott Alexander <sja...@gmail.com> wrote:
> http://migrationguide.artinsoft.com/Migration-Guide-Faq-Chapter-14.as...
>
>
>
> On Tue, May 19, 2009 at 10:52 AM, Defende <rodrigodefe...@gmail.com> wrote:
>
> > ok, thanks.
> > Now another question - I will use with VB6.0 using modbus.dll? if so
> > how could I be using it because I can not reference the dll.
>
> > thanks.
>
> > On May 19, 1:31 pm, Scott Alexander <sja...@gmail.com> wrote:
> >> Yes.
>
> >> Scott
>
> >> On Tue, May 19, 2009 at 9:11 AM, Defende <rodrigodefe...@gmail.com> wrote:
>
> >> > I would like to know if I can use the library modbus.dll with VB.Net?- Hide quoted text -
>
> >> - Show quoted text -- Hide quoted text -

Scott Alexander

unread,
May 19, 2009, 2:39:51 PM5/19/09
to NModbus...@googlegroups.com
No, you will have to create it.

Scott

Defende

unread,
May 20, 2009, 6:29:23 AM5/20/09
to NModbus
Hi.

I building the project and it gives several errors. One is this one:

Error 1 'Modbus.Data.DataStore.CoilDiscretes.get' must declare a body
because it is not marked abstract or extern D:\ProjetosVbNet\Vemax
\NModbus_net-2.0_1.11.0.0-source\source\src\Modbus\Data\DataStore.cs
41 53 Modbus

Error 9 'Modbus.Device.TcpConnectionEventArgs.EndPoint.get' must
declare a body because it is not marked abstract or extern D:
\ProjetosVbNet\Vemax\NModbus_net-2.0_1.11.0.0-source\source\src\Modbus
\Device\TcpConnectionEventArgs.cs 17 28 Modbus

How can I fix this error?

Scott Alexander

unread,
May 20, 2009, 12:37:48 PM5/20/09
to NModbus...@googlegroups.com
The .net 2.0 branch still requires the 3.5 compiler to build, which
supports automatic properties. At runtime only the 2.0 framework is
required.

Scott

Defende

unread,
May 20, 2009, 2:18:05 PM5/20/09
to NModbus
Hi.
I have this problem now - can you help me?
my code is:

Imports System.IO.Ports
Imports Modbus.Device

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Dim msCom As New SerialPort
Dim md As ModbusSerialMaster

msCom = New SerialPort("COM1")
msCom.BaudRate = 19200
msCom.DataBits = 8
msCom.Parity = Parity.None
msCom.StopBits = StopBits.Two
msCom.Open()

Dim retorno() As UShort

md = ModbusSerialMaster.CreateRtu(msCom)
retorno = md.ReadHoldingRegisters(1, 823, 1)

Label1.Text = retorno(0)

msCom.Close()

End Sub
End Class

But when i execute return me this error:

"The type initializer for 'Modbus.IO.ModbusRtuTransport' threw an
exception." - this line (md = ModbusSerialMaster.CreateRtu(msCom))

what could it be????

Thanks

Scott Alexander

unread,
May 20, 2009, 4:23:16 PM5/20/09
to NModbus...@googlegroups.com
you need to add a reference to the log4net.dll as well.

Scott

Defende

unread,
May 21, 2009, 7:59:21 AM5/21/09
to NModbus
HI.

I reference log4net.dll and this problem is stop, but i have another
problem: is return to me Timeout in this line: "(retorno =
md.ReadHoldingRegisters(1, 823, 1)".

I honestly do not know else to do.
you would not have an example in vb.net to show me at least how to use
the call ReadHoldingRegisters?

Again thanks.

Scott Alexander

unread,
May 21, 2009, 12:04:14 PM5/21/09
to NModbus...@googlegroups.com
Your problem is most likely in the serial port configuration. You can
try the blueSCADA GUI to help find the appropriate configuration for
your device.

http://www.bluescada.com

Also, post your entire sample.

Scott

Defende

unread,
May 21, 2009, 12:37:56 PM5/21/09
to NModbus
hi.
This is may sample:

==========================================================
Imports System.IO.Ports
Imports Modbus.Device

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Dim msCom As New SerialPort("COM1")
Dim md As ModbusSerialMaster
Dim registro As UShort
Dim escravo As Byte


registro = 823
escravo = 1

'msCom = New SerialPort("COM1")
msCom.BaudRate = 19200
msCom.DataBits = 8
msCom.Parity = Parity.None
msCom.StopBits = StopBits.One

msCom.Open()

Dim retorno() As UShort

md = ModbusSerialMaster.CreateRtu(msCom)
retorno = md.ReadHoldingRegisters(escravo, registro, 1)

Label1.Text = retorno(0)

msCom.Close()

End Sub
End Class

=================================================================

Thanks

Scott Alexander

unread,
May 21, 2009, 12:46:42 PM5/21/09
to NModbus...@googlegroups.com
That looks correct. I would play with the comm port settings now.
Enabling logging or using a tool like Wireshark can be useful for
debugging.

Scott
Reply all
Reply to author
Forward
0 new messages