We work with the interfaceboard K8055 under Windows XP (USB 2) and Visual Basic.net from Visual Studio 2005 . We need fast input answer (20 ms) ; the first routine with timer1 runs fast enough, but the second one with timer2 is too slow (250 ms). Could anybody explain the difference between these routines?
We need the second version for our applications.
This is our source-code:
[color=#0000FF]Public Class Form1
Private Declare Function OpenDevice Lib "k8055d.dll" (ByVal CardAddressChannel As Integer) As Integer
Private Declare Sub CloseDevice Lib "k8055d.dll" ()
Private Declare Sub WriteAllDigital Lib "k8055d.dll" (ByVal Data As Integer)
Private Declare Function ReadAllDigital Lib "k8055d.dll" () As Integer[/color]
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Connector_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Connector.Click
OpenDevice(0)
End Sub
Private Sub Disconnector_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Disconnector.Click
CloseDevice()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Start() : Timer2.Stop()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
WriteAllDigital(ReadAllDigital)
Label1.Text = ReadAllDigital
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
Dim K As Integer
K = ReadAllDigital
WriteAllDigital(K)
Label1.Text = K
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Timer2.Start() : Timer1.Stop()
End Sub
End Class