Sorry but 20 ms is the highest polling rate of the low speed USB that this PIC microcontroller is made for.
Strange that the macro didn’t run under your Excel 2000.
Here is my other test code that reads the counter of the K8055 and displays the count in RPM on Excel sheet. The update rate is 3 sec to get higher resolution.
[code]Private Declare Function SetTimer Lib “user32” ( _
ByVal HWnd As Long, ByVal nIDEvent As Long, _
ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Private Declare Function KillTimer Lib “user32” ( _
ByVal HWnd As Long, ByVal nIDEvent As Long) As Long
Private Declare Function OpenDevice Lib “k8055d.dll” (ByVal CardAddress As Long) As Long
Private Declare Function ReadCounter Lib “k8055d.dll” (ByVal CounterNr As Long) As Long
Private Declare Sub ResetCounter Lib “k8055d.dll” (ByVal CounterNr As Long)
Private Declare Sub SetCounterDebounceTime Lib “k8055d.dll” (ByVal CounterNr As Long, ByVal DebounceTime As Long)
Dim NewCount As Long
Dim OldCount As Long
Dim h As Long
Dim TimerID As Long
Dim TimerSeconds As Single
Dim Connected As Boolean
Sub StartTimer()
TimerSeconds = 3 ’ the timer interval is now 3 sec.
TimerID = SetTimer(0&, 0&, TimerSeconds * 1000&, AddressOf TimerProc)
End Sub
Sub EndTimer()
On Error Resume Next
KillTimer 0&, TimerID
End Sub
Sub TimerProc(ByVal HWnd As Long, ByVal uMsg As Long, ByVal nIDEvent As Long, ByVal dwTimer As Long)
On Error Resume Next
NewCount = ReadCounter(1)
If NewCount > OldCount Then
Sheet1.Cells(3, 1).Value = (NewCount - OldCount) * 20 ’ displays the RPM value
End If
OldCount = NewCount
End Sub
Sub Start_Click()
If Not Connected Then
h = OpenDevice(Sheet1.Cells(1, 3).Value)
Select Case h
Case 0, 1, 2, 3
Sheet1.Cells(1, 1) = “Card connected”
Connected = True
Case -1
Sheet1.Cells(1, 1) = “Card not found”
End Select
End If
If Connected Then
ResetCounter 1
SetCounterDebounceTime 1, 0 ’ select different debounce time if needed (now 0 ms)
StartTimer
Sheet1.Cells(2, 1) = “Running”
End If
End Sub
Sub Stop_Click()
EndTimer
Sheet1.Cells(2, 1) = “Stopped”
End Sub[/code]