K8055 Liberty Test Code Rev2
K8055 Liberty Test Code Rev2
K8055 Liberty Test Code Rev2
David Deane
'Test Program for Velleman K8055 USB Interface Card by David Deane, Vidalia, GA. Jan 2, 2010
'Free for Educational Use
'The VB6 sample code works fine, but I was never able to get the program to work with
'Visual Basic Express 2008
'This code works in Liberty Basic, but you will need to the Gold edition to create executable files.
' I have tried to use most of the DLL calls available to test for channel and returned values.
'The card must have both address jumpers installed to be Connected as Addr(0)
'Tested with the K8055 card Jan 2, 2002
'Rev2 uses checkboxes and textboxes to output data and continuous input checking
[setup.main.Window]
WindowWidth = 550
WindowHeight = 410
UpperLeftX=int((DisplayWidth-WindowWidth)/2)
UpperLeftY=int((DisplayHeight-WindowHeight)/2)
nomainwin
Open "k8055d.dll" for DLL as #user
channel=1
CardAddress=0
Calldll #user, "OpenDevice", CardAddress as Long, retrn as long
If retrn=-1 then
print "Board 0 Not Located"
print "Program Terminated"
close #user
end
Else
print "retrn=";retrn;" ";"Board 0 Connected"
End If
[Rerun]
print #main.statictext31,"Testing"
For blink=1 to 3
Calldll #user, "SetAllDigital", channel as Long
Call Pause 100
Calldll #user, "ClearAllDigital", channel as Long
Call Pause 100
Next blink
For DCount=1 to 8
CallDll #user, "SetDigitalChannel", DCount as long, retDigiSet as long
If DCount=1 then print #main.checkbox21, "set"
If DCount=2 then print #main.checkbox22, "set"
If DCount=3 then print #main.checkbox23, "set"
If DCount=4 then print #main.checkbox24, "set"
If DCount=5 then print #main.checkbox25, "set"
If DCount=6 then print #main.checkbox26, "set"
If DCount=7 then print #main.checkbox27, "set"
If DCount=8 then print #main.checkbox28, "set"
Call Pause 100
Next DCount
For DCount=8 to 0 step -1
CallDll #user, "ClearDigitalChannel", DCount as long, retDigiSet as long
If DCount=8 then print #main.checkbox28, "reset"
If DCount=7 then print #main.checkbox27, "reset"
If DCount=6 then print #main.checkbox26, "reset"
If DCount=5 then print #main.checkbox25, "reset"
If DCount=4 then print #main.checkbox24, "reset"
If DCount=3 then print #main.checkbox23, "reset"
If DCount=2 then print #main.checkbox22, "reset"
If DCount=1 then print #main.checkbox21, "reset"
Call Pause 100
Next DCount
Playwave "Beep.wav"
[ReadDigs]
Print "Digital Channels 1 thru 5 = ";
CallDll #user, "ReadDigitalChannel", 1 as long, retrnedval1 as long
print #main.textbox3,retrnedval1
CallDll #user, "ReadDigitalChannel", 2 as long, retrnedval2 as long
print #main.textbox4,retrnedval2
CallDll #user, "ReadDigitalChannel", 3 as long, retrnedval3 as long
print #main.textbox5,retrnedval3
CallDll #user, "ReadDigitalChannel", 4 as long, retrnedval4 as long
print #main.textbox6,retrnedval4
CallDll #user, "ReadDigitalChannel", 5 as long, retrnedval5 as long
print #main.textbox7,retrnedval5
[ReadAnalogs]
Print "Analog Channels 1 and 2 (Value 0-255) = ";
CallDll #user, "ReadAnalogChannel", 1 as long, retrnedAVal1 as long
print #main.textbox12,retrnedAVal1
CallDll #user, "ReadAnalogChannel", 2 as long, retrnedAVal2 as long
print #main.textbox13,retrnedAVal2
[SetAnalogs]
print #main.textbox15, "!contents? SetAna1$"
ADataOut1=VAL(SetAna1$)
CallDll #user, "OutputAnalogChannel", 1 as long, ADataOut1 as long, retAna as long
scan
goto [ReadDigs]
[loop]
wait
[button29Click]
goto [Rerun]
[button30Click]
Close #user
Close #main
End
[checkbox21Set]
CallDll #user, "SetDigitalChannel", 1 as long, retDigiSet as long
goto [ReadDigs]
[checkbox22Set]
CallDll #user, "SetDigitalChannel", 2 as long, retDigiSet as long
goto [ReadDigs]
[checkbox23Set]
CallDll #user, "SetDigitalChannel", 3 as long, retDigiSet as long
goto [ReadDigs]
[checkbox24Set]
CallDll #user, "SetDigitalChannel", 4 as long, retDigiSet as long
goto [ReadDigs]
[checkbox25Set]
CallDll #user, "SetDigitalChannel", 5 as long, retDigiSet as long
goto [ReadDigs]
[checkbox26Set]
CallDll #user, "SetDigitalChannel", 6 as long, retDigiSet as long
goto [ReadDigs]
[checkbox27Set]
CallDll #user, "SetDigitalChannel", 7 as long, retDigiSet as long
goto [ReadDigs]
[checkbox28Set]
CallDll #user, "SetDigitalChannel", 8 as long, retDigiSet as long
goto [ReadDigs]
[checkbox21Reset]
CallDll #user, "ClearDigitalChannel", 1 as long, retDigiSet as long
goto [ReadDigs]
[checkbox22Reset]
CallDll #user, "ClearDigitalChannel", 2 as long, retDigiSet as long
goto [ReadDigs]
[checkbox23Reset]
CallDll #user, "ClearDigitalChannel", 3 as long, retDigiSet as long
goto [ReadDigs]
[checkbox24Reset]
CallDll #user, "ClearDigitalChannel", 4 as long, retDigiSet as long
goto [ReadDigs]
[checkbox25Reset]
CallDll #user, "ClearDigitalChannel", 5 as long, retDigiSet as long
goto [ReadDigs]
[checkbox26Reset]
CallDll #user, "ClearDigitalChannel", 6 as long, retDigiSet as long
goto [ReadDigs]
[checkbox27Reset]
CallDll #user, "ClearDigitalChannel", 7 as long, retDigiSet as long
goto [ReadDigs]
[checkbox28Reset]
CallDll #user, "ClearDigitalChannel", 8 as long, retDigiSet as long
goto [ReadDigs]
End