I really enjoy working with my K8055 but I noticed that my favorite Programming language (Python) was not included in the instructions. After some research, I wrote this demo program that exercises most of the functions in the DLL. For you Python programmers, I hope you find this useful.
# K8055_DEMO.py
# Date Written: 12/24/2011
# Author: Jim S
# Purpose: To demo the various functions of the K8055 dll using the Python 2.7 language
import ctypes
import time
K8055dll = ctypes.WinDLL("D:\\Program Files\\velleman\\K8055\\K8055D.dll")
p0 = ctypes.c_long(0)
p1 = ctypes.c_long(1)
p2 = ctypes.c_long(2)
px = ctypes.c_long(0)
print "\nOpening Device\n"
rc = K8055dll.OpenDevice(p0)
if (rc == -1):
print "Card was not found"
exit(1)
print "\nTesting Analog-to-Digital Channels\n"
ad1 = K8055dll.ReadAnalogChannel(p1)
ad2 = K8055dll.ReadAnalogChannel(p2)
print "the value of Analog Channel 1 is: ", ad1
print "the value of Analog Channel 2 is: ", ad2
print "\nTesting the Digital Input Channels\n"
print "\nPress Input Switch#1 to continue\n"
while (not K8055dll.ReadDigitalChannel(p1)):
time.sleep(0.1)
print "\nTesting the Digital Output Channels\n"
K8055dll.ClearAllDigital()
for px in range(1,9):
if (px > 1):
K8055dll.ClearDigitalChannel(px-1)
K8055dll.SetDigitalChannel(px)
time.sleep(1)
K8055dll.ClearDigitalChannel(px)
time.sleep(1)
for px in range(1,256):
K8055dll.WriteAllDigital(px)
time.sleep(.25)
time.sleep(1)
K8055dll.ClearAllDigital()
time.sleep(1)
print "\nTesting Digital-to-Analog Channels\n"
K8055dll.ClearAnalogChannel(p1)
K8055dll.SetAnalogChannel(p2)
for px in range(1,251):
K8055dll.OutputAnalogChannel(p1,px)
K8055dll.OutputAnalogChannel(p2,251-px)
if (not px % 10):
print px, "(", 251-px, ").." ,
time.sleep(0.1)
print px, "(", 251-px, ").."
time.sleep(2)
K8055dll.ClearAllAnalog()
print "\n\nClosing Device\n"
K8055dll.CloseDevice()
exit(0)