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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.