MODBUS TCP PROJECT VB NET

After searching for days I found this project that communicate with an I/O module via Modbus TCP. The program works fine reading the inputs and displaying them on the the text boxes. The only problem is I have to click the button all the time to re-read the inputs I am wondering if anyody has ever use this project and can advice a way to keep reading the inputs constantly so the text boxes get update every time a change has been made, on the inputs.
http://www.codeproject.com/Tips/16260/Modbus-TCP-class?msg=5043651#xx5043651xx
tonzur40Asked:
Who is Participating?
 
tonzur40Author Commented:
I end up solving the problem adding a delegate when the data is received

      Private Sub ShowAs.......
..............
    Dim senmsgtomachine As readinputs
                senmsgtomachine = New readinputs(AddressOf talktomachine)
                senmsgtomachine.Invoke()

And my talktomachine is

    Public Sub talktomachine()
        Dim ID As UShort = 2
        Dim unit As Byte = Convert.ToByte(txtUnit.Text)
        Dim StartAddress As UShort = ReadStartAdr()
        Dim Length As Byte = Convert.ToByte(txtSize.Text)

        MBmaster.ReadDiscreteInputs(ID, unit, StartAddress, Length)
    End Sub
0
 
David Johnson, CD, MVPOwnerCommented:
use a timer to refresh instead of the button_onclick is one way
0
 
ThommyCommented:
I also suggest using a timer to permanently re-read the Inputs.

In VB.NET you can create a timer as follows:

Dim MyTimer as New Timer

MyTimer.Interval = 5000   'every 5 seconds
MyTimer.Enabled = True
AddHandler MyTimer.Tick, AddressOf MyTimerTick

Private Sub MyTimerTick (Byval sender as Object, Byval e as EventArgs)
   ' call your button_click to re-read the inputs
End Sub

Open in new window

0
 
tonzur40Author Commented:
A timer was my first thought too but it is impractical when I want to trigger the request  modbus event as soon as   i have received the data from the IO module.
0
 
tonzur40Author Commented:
A timer was my first thought too but it is impractical when I want to trigger the request  modbus event as soon as   i have received the data from the IO module.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.