Other functions of the K8055 / P8055N
Introduction
In the first article we used QB64 to control the digital outputs, and in this article we will use more of the functions of the board, including the DAC outputs, ADC inputs, counters, and digital inputs. Again, for convenience you can download the full bas file here.
DECLARE DYNAMIC LIBRARY "K8055D" FUNCTION Version& FUNCTION SearchDevices& FUNCTION SetCurrentDevice& (BYVAL CardAddress AS LONG) FUNCTION OpenDevice& (BYVAL CardAddress AS LONG) FUNCTION CloseDevice& FUNCTION ReadAnalogChannel& (BYVAL Channel AS LONG) FUNCTION ReadAllAnalog& (Data1 AS LONG, Data2 AS LONG) FUNCTION OutputAnalogChannel& (BYVAL Channel AS LONG, BYVAL Data1 AS LONG) FUNCTION OutputAllAnalog& (BYVAL Data1 AS LONG, BYVAL Data2 AS LONG) FUNCTION ClearAnalogChannel& (BYVAL Channel AS LONG) FUNCTION SetAllAnalog& FUNCTION ClearAllAnalog& FUNCTION SetAnalogChannel& (BYVAL Channel AS LONG) FUNCTION WriteAllDigital& (BYVAL Data1 AS LONG) FUNCTION ClearDigitalChannel& (BYVAL Channel AS LONG) FUNCTION ClearAllDigital& FUNCTION SetDigitalChannel& (BYVAL Channel AS LONG) FUNCTION SetAllDigital& FUNCTION ReadDigitalChannel& (BYVAL Channel AS LONG) FUNCTION ReadAllDigital& FUNCTION ReadCounter& (BYVAL CounterNr AS LONG) FUNCTION ResetCounter& (BYVAL CounterNr AS LONG) FUNCTION SetCounterDebounceTime& (BYVAL CounterNr AS LONG, BYVAL DebounceTime AS LONG) END DECLARE DIM wOut, nothing PRINT "Attempting to open device 0. Response="; OpenDevice(0) PRINT "Version="; Version PRINT "Search devices="; SearchDevices 1: PRINT "Setting Analog output1" nothing = OutputAnalogChannel(1, 128) PRINT "Setting Analog output2" nothing = OutputAnalogChannel(2, 254) PRINT "analog 1="; ReadAnalogChannel(1) PRINT "analog 2="; ReadAnalogChannel(2) PRINT "digital bits="; ReadDigitalChannel(1); ReadDigitalChannel(2); ReadDigitalChannel(3); ReadDigitalChannel(4); ReadDigitalChannel(5) PRINT "digital counter INP1="; ReadCounter(1); ", INP2="; ReadCounter(2); PRINT "All digital in="; ReadAllDigital PRINT "Writing the counter value (for DIG INP1) to the digital output"; WriteAllDigital(ReadCounter(1)) PRINT "press enter to read, -1 to exit" INPUT wOut CLS IF wOut < 0 THEN GOTO 2 GOTO 1: 2: PRINT "closing device, response="; CloseDevice