Hi, I am using the K8055 for relay switching in a program which uses a sound card to playback music. It may work for several days and the the program “freezes” and must be restarted. I have used both and earlier and the latest dll with the same results.
Is there a fix for this? We are also using a different manufacture’s USB interface with no problems so I don’t think it is a problem in our program.
'Initialization Module
Option Explicit
Public Declare Function OpenDevice Lib "k8055d.dll" (ByVal CardAddress As Long) As Long
Public Declare Sub CloseDevice Lib "k8055d.dll" ()
Public Declare Function ReadAnalogChannel Lib "k8055d.dll" (ByVal Channel As Long) As Long
Public Declare Sub ReadAllAnalog Lib "k8055d.dll" (Data1 As Long, Data2 As Long)
Public Declare Sub OutputAnalogChannel Lib "k8055d.dll" (ByVal Channel As Long, ByVal Data As Long)
Public Declare Sub OutputAllAnalog Lib "k8055d.dll" (ByVal Data1 As Long, ByVal Data2 As Long)
Public Declare Sub ClearAnalogChannel Lib "k8055d.dll" (ByVal Channel As Long)
Public Declare Sub SetAllAnalog Lib "k8055d.dll" ()
Public Declare Sub ClearAllAnalog Lib "k8055d.dll" ()
Public Declare Sub SetAnalogChannel Lib "k8055d.dll" (ByVal Channel As Long)
Public Declare Sub WriteAllDigital Lib "k8055d.dll" (ByVal Data As Long)
Public Declare Sub ClearDigitalChannel Lib "k8055d.dll" (ByVal Channel As Long)
Public Declare Sub ClearAllDigital Lib "k8055d.dll" ()
Public Declare Sub SetDigitalChannel Lib "k8055d.dll" (ByVal Channel As Long)
Public Declare Sub SetAllDigital Lib "k8055d.dll" ()
Public Declare Function ReadDigitalChannel Lib "k8055d.dll" (ByVal Channel As Long) As Boolean
Public Declare Function ReadAllDigital Lib "k8055d.dll" () As Long
Public Declare Function ReadCounter Lib "k8055d.dll" (ByVal CounterNr As Long) As Long
Public Declare Sub ResetCounter Lib "k8055d.dll" (ByVal CounterNr As Long)
Public Declare Sub SetCounterDebounceTime Lib "k8055d.dll" (ByVal CounterNr As Long, ByVal DebounceTime As Long)
Public Sub InitializeIOCard()
Dim CardAddress As Long
CardAddress = 0
vh = OpenDevice(CardAddress)
End Sub
'Read Velleman inputs
Sub VellIn()
vi = ReadAllDigital
vk = (vi And 1)
If vk = 0 Then mnuMenu.lblPlayRelay.Visible = False
If vk = 1 Then
mnuMenu.lblPlayRelay.Visible = True
If Play = 0 And Not kplay = 0 Then
StartPlay
End If
End If
vk = (vi And 2) / 2
RecordRelay = vk
vk = (vi And 4) / 4
PlayRelay2 = vk
If vk = 1 And FormControl = 0 And Not kplay = 0 Then CueEvent = mnuMenu.lstPlayList.ItemData(mnuMenu.lstPlayList.ListIndex): StartCue
If vk = 1 And LocalPlay = 1 Then StartCue 'if cue is playing turn it off
vk = (vi And 8) / 8
If vk = 0 Then TimeRelay = 0: mnuMenu.lblClockReset.Visible = False
If vk = 1 And TimeRelay = 0 And Mid$(Time$, 4, 2) = Left$(ClockResetTime, 2) Then
tset = Time$
Mid$(tset, 4, 5) = ClockResetTime
Time$ = tset
TimeRelay = 1
mnuMenu.lblClockReset.Visible = True
EventName = "Time Set " ' + tz
ta = 0
ia = 1 'keeps log from printing "bad file"
LogName = "PL"
ActivityLog
End If
If (vi And 16) / 16 = 0 Then
mnuMenu.Indicator(0).Visible = False
t = "F"
NetCase = 991
NetSend
End If
If (vi And 16) / 16 = 1 Then
NetCase = 991
t = "T"
NetSend
If mnuMenu.Indicator(0).Visible = False Then
mnuMenu.Indicator(0).Visible = True
If SwitchLog(13) = "1" Then
EventName = mnuMenu.Indicator(0).Caption
ta = 0
ia = 1
LogName = "PL"
ActivityLog
t = "991" + EventName
SendAlarm
End If
End If
End If
End Sub
Thank you for the reply. The variables are declared. I just didn’t show the main module that has the declarations and the forms with the controls…just the code that is dependent upon the Velleman.
I don’t found why yours prog freeze. just some tips
vk = (vi And 4) / 4
PlayRelay2 = vk
better ?
PlayRelay2 = Cbool((vi And 4) / 4)
Here are you sure to read all ways of code ?
vk = (vi And 8) / 8
If vk = 0 Then TimeRelay = 0: mnuMenu.lblClockReset.Visible = False
If vk = 1 And TimeRelay = 0 And Mid$(Time$, 4, 2) = Left$(ClockResetTime, 2) Then.....
if vk= 0 then timerelay=0, if vk=1 and timerrealy = 1 what’s possible ?
if not Cbool((vi And 8) / 8)= true then
Timerelay = 0
mnuMenu.lblClockReset.Visible = False
else
if Mid$(Time$, 4, 2) = Left$(ClockResetTime, 2) Then.....
end if
test your prog whit debug for a long time for see, if you don’t have a variable integer overload or else ?
regards
[/code]