Beginner Help...

34 views
Skip to first unread message

David H

unread,
Nov 3, 2009, 11:42:33 PM11/3/09
to NModbus
Hello all,

I am looking for some guidance to get started using the NModbus
library.

Please forgive me if I am not using the right terms... remember
beginner :-)

I am trying to develop an application that will monitor the traffic
on the modbus network. The computer this app will run on has a slave
device to the network on COM 1. A crude application was developed in
VB6 using an activeX control from modbustools.com. I am working to
create a more robust solution using .Net.

Here is a snippet of code from the OpenConnection function that uses
the ActiveX control:

Modbus.Connection = 1 ' Port 1 Use 0 if TCP/IP
Modbus.BaudRate = 5 ' 9600 Baud
Modbus.DataBits = 1 ' 8 data bits
Modbus.Parity = 0 ' None parity
Modbus.StopBits = 0 ' 1 Stop bit

Modbus.ProtocolMode = 0 ' 0=RTU, 1=ASCII
Modbus.Timeout = 1000

bResult = Modbus.OpenConnection

' Parameters are :
' Handle As Integer,
' SlaveID As Integer,
' Address As Long,
' Quantity As Integer,
' UpdateRate As Integer
bResult = Modbus.ReadHoldingRegisters(1, 1, 0, 100, 30000) ' slave
1
bResult = Modbus.ReadHoldingRegisters(2, 1, 99, 100, 30000) '
slave 1
bResult = Modbus.ReadHoldingRegisters(3, 1, 199, 100, 30000) '
slave 1
bResult = Modbus.ReadHoldingRegisters(4, 1, 299, 95, 30000) '
slave 1

'start the tasks
Modbus.UpdateEnable (1)
Modbus.UpdateEnable (2)
Modbus.UpdateEnable (3)
Modbus.UpdateEnable (4)
OpenConnection = bResult

Any help to guidance would be greatly appreciated.

Thanks,
David
Reply all
Reply to author
Forward
0 new messages