This interface board has sixteen digital input/output channels which can be used as either input
or output as desired. In addition, there are eight analogue outputs with 6 bit resolution, one
analogue output with 8 bit resolution, and four analogue inputs of 8 bit resolution. If more digital
outputs are required, then the analogue outputs can be used by setting to minimum or
maximum output voltage. If there are too few inputs, then the analogue inputs may be used. In
this way it is very simple to track the state of a rotating switch by connecting in a different
voltage for every state. Please note that these extra input and output channels are not optically
isolated.
The number of inputs/outputs can be further expanded by connecting more cards together, up
to a maximum of four. Each card is given its own identification by means of a two pole DIPswitch SW1 (see table below for channel numbering).
To connect the card to the computer the printer port is used (note that there is no need to install
an extra printer port as the printer can be connected to the interface card). Three lines from this
port are used, namely, "Select" (pin 13), "Autofeed" (pin 14) and "Select in" (pin 17).
Communication between the computer and interface card is by means of a serial link. One line
(Select in) serves as the clock signal, the second (Autofeed) as the data output, and the third
(Select) as the data input.
All communication routines are contained in a Dynamic Link Library (DLL) K8D.DLL. This
document describes all the DLL functions and procedures that are available for your application
programme. Using the DLL allows you to write custom Windows 9x, NT or XP based
applications in Visual C++, Delphi, Visual Basic, or any other 32-bit Windows application
development tool that supports calls to a DLL. Thus, there is no need to be concerned about the
communication protocol.
A complete overview of all procedures, functions and variables that are used by the "K8D.DLL"
follows. The example program can also be carefully studied in order to gain an insight as to how
to construct your customised application programmes.
Note that all examples are written for Delphi.
At the end of this document there are full declarations for the DLL function and procedures for
Delphi and Visual Basic.
The application program has access to the the following variables via the k8d.dll:
INITIAL
VARIABLE TYPE VALUE DESCRIPTION
DA Array[1..4] of Integer 0 Contains the data (value between 0
and 255) of the four 8-bit Digital to
Analogue converters
DAC Array[1..32] of Integer 0 Contains the data (value between 0
and 63) of the thirty two 6-bit
Digital to Analogue Converter
channels
IOconfig Array[0..7] of Integer $0FF Each bit contains the configuration
of the corresponding channels of
the eight IO-ports. Bit high (1) =
input; bit low (0) = output
IOdata Array[0..7] of Integer Each bit contains the status of the
respective channel of the eight IOports. Bit high (1) = channel on; bit
low (0) = channel off
The global constants used in the following descriptions:
CONSTANT VALUE DESCRIPTION
MaxIOcard 3 Highest possible address of the interface card
MaxIOchip 7 Highest possible Input/Output chip number
MaxIOchannel 64 Highest possible Input/Output channel number
MaxDACchannel 32 Highest possible 6-bit Digital to Analogue
Converter channel number
MaxADchannel 16 Highest possible Analogue to Digital channel number
MaxDAchannel 4 Highest possible 8-bit Digital to Analogue channel
number
OVERVIEW OF 'K8D.DLL' PROCEDURES AND FUNCTIONS
8-bit Analogue to Digital converter procedures
ReadADchannel(Channelno) Reads the status of the analogue input-
channel
8-bit Digital to Analogue conversion procedures
OutputDAchannel(Channelno,Data) Sets the analogue output channel according
to the data
ClearDAchannel(Channelno) Sets the analogue output channel to
minimum
ClearAllDA Sets all analogue output channels to
minimum
SetDAchannel(Channelno) Sets the analogue output channel to
maximum
SetAllDA Sets all analogue output channels to
maximum
6-bit Digital to Analogue Conversion procedures
OutputDACchannel(Channelno,Data) Sets the analogue output channel according
to the data
ClearDACchannel(Channelno) Sets the analogue output channel to
minimum
ClearDACchip(Chipno) Sets the 8 analogue output channels of the
DAC-chip to minimum
ClearAllDAC Sets all analogue output channels to
minimum
SetDACchannel(Channelno) Sets the analogue output channel to
maximum
SetDACchip(Chipno) Sets the 8 analogue output channels of the
DAC-chip to maximum
SetAllDAC Sets all analogue output channels to
maximum
IO configuration procedures
ConfigAllIOasInput Configures all IO-channels as inputs
ConfigIOchipAsInput(Chipno) Configures all IO-channels of the IO -chip as
inputs
ConfigIOchannelAsInput(Channelno) Configures the IO-channel as input
ConfigAllIOasOutput Configures all IO-channels as outputs
ConfigIOchipAsOutput(Chipno) Configures all IO-channels of the IO-chip as
outputs
ConfigIOchannelAsOutput(Channel) Configures the IO -channel as output
Setting of IOdata & IO variables (the physical status of the IO-channels does not change)
UpdateIOdataArray(Chipno,Data) Sets the output status according to the data
(inputs do not change)
ClearIOchArray(Channelno) Clears the output status of the selected
channel (set low)
ClearIOdataArray(Chipno) Clears the output status of the channels of
the IO-chip (set low)
SetIOchArray(Channelno) Sets the output status of the selected
channel (set high)
SetIOdataArray(Chipno) Sets the output status of the channels of the
IO-chip (set high)
Output procedures
IOoutput(Chipno,Data) Sets the outputs of the IO-chip according to
the data (inputs do not change)
UpdateIOchip(Chipno) Sets the outputs of the IO-chip according to
the status of the 'IOdata' variable
UpdateAllIO Sets all outputs according to the status of the
'IOdata' variables
ClearIOchannel(Channelno) Clears the output channel
ClearIOchip(Chipno) Clears the output channels of the IO-chip
ClearAllIO Clears all output channels
SetIOchannel(Channelno) Sets the output channel
SetIOchip(Chipno) Sets the output channels of the IO-chip
SetAllIO Sets all output channels
Input procedures and functions
ReadIOchannel(Channelno) Reads the status of the input channel
ReadIOchip(Chipno) Reads the status of the input channels of the
IO-chip
ReadIOconficArray(Buffer) Reads the IO configuration data from the
DLL to the application program
ReadIOdataArray(Buffer) Reads the IO status data from the DLL to
the application program
ReadDACarray(Buffer) Reads the DAC data from the DLL to the
application program
ReadDAarray(Buffer) Reads the DA data from the DLL to the
application program
General procedures
SelectI2CprinterPort(Printer_no) Chooses the communication port
Start_K8000 Opens a link to the K8000 device
Stop_K8000 Closes the link to the K8000 device
'K8D.DLL' PROCEDURES AND FUNCTIONS
Start_K8000
Syntax
PROCEDURE Start_K8000;
Description
Initializes the communication routines for the K8000 card. Loads the drivers needed to
communicate via the LPT port. This procedure must be performed in the beginning of the
application program.
Example
BEGIN
Start_K8000;
END;
Sop_K8000
Syntax
PROCEDURE Stop_K8000;
Description
Unloads the communication routines for K8000 card and unloads the drivers needed to
communicate via the PLT port. This is the last action of the application program before
termination.
Printer_no:Value between 0 and 2 given by the printer port to which the interface card is
connected.
0: printer port address is 0BC (hex)
1: printer port address is 378 (hex), usually the address of LPT1
2: printer port address is 278 (hex), usually the address of LPT2
Result
Communication between the PC and the K8000 card will occur via the selected LPT port
address.
Description
The printer port to be used must be specified at the start of your programme in order to run the
interface card so that the communication routines are carried out correctly. The default
designation is LPT1, but this can be changed using this procedure.
Example
BEGIN
SelectI2CprinterPort(1);
// LPT1 address on mainboard is set to 378
END;
ReadADchannel AD
Syntax
FUNCTION ReadADchannel(Channel_no: Longint):Longint;
Parameter
Channel_no: Value between 1 and 16 which corresponds to the AD channel whose status is to
be read.
ResultAD:
The corresponding 'AD' data is read according to the status of the AD input.
Description
The input voltage of the selected 8-bit Analogue to Digital converter channel is converted to a
value which lies between 0 and 255 and registered in the respective 'AD' data variable.
Example
var data: longint;
BEGIN
data := ReadADchannel(1);
// AD channel 1 is read to variable 'data'
END;
Channel_no:Value between 1 and 4 which corresponds to the 8-bit DA channel number whose
data is to be changed.
Data:Value between 0 and 255 which is to be sent to the 8-bit Digital Analogue Converter .
ResultDA:
The 'DA' data variable of the selected channel is set according to the data which is to be sent.
The selected DA-channel is changed.
Description
The indicated 8-bit Digital to Analogue Converter channel is altered according to the new data.
This means that the data corresponds to a specific voltage. The value 0 corresponds to a
minimum output voltage (0 Volt) and the value 255 corresponds to a maximum output voltage
(Vmax) which is set according to the preset on the interface board. A value of 'Data' lying in
between these extremes can be translated by the following formula : Data x Vmax/255.
Example
BEGIN
OutputDAchannel(1,127);
// DA channel 1 is at 1/2 Vmax
END;
ClearDAchannel DA
Syntax
PROCEDURE ClearDAchannel(Channel_no: Longint);
Parameter
Channel_no:Value between 1 and 4 which corresponds to the 8-bit DA channel number in
which the data is to be erased.
ResultDA:
The 'DA' data variable of the selected DA-channel is set to minimum (0) .
The selected DA-channel is set to minimum output voltage (0 Volt).
Description
The selected 8-bit Digital to Analogue Converter channel is set to minimum output voltage (0
Volt).
Example
BEGIN
ClearDAchannel(1);
// DA channel 1 is at Vmin
END;
ClearAllDA DA
Syntax
PROCEDURE ClearAllDA;
Result
All DA-channels are set to minimum output voltage (0 Volt) .
Description
All DA-channels of the 8-bit Digital to Analogue Converters are set to minimum output voltage (0
Volt) .
Example
BEGIN
ClearAllDA;
// All DA channels 1...4 are at Vmin
END;
SetDAchannel DA
Syntax
PROCEDURE SetDAchannel(Channel_no: TDAchannel);
Parameter
Channel_no:Value between 1 and 4 which corresponds to the 8-bit DA channel number in
which the data is to be set to maximum.
Result
The selected DA-channel is set to maximum output voltage.
Description
The selected 8-bit Digital to Analogue Converter channel is set to maximum output voltage.
Example 15
PROGRAM Set_DA_channel;
USES I2C, WinCrt;
BEGIN
SetDAchannel(1);
Writeln('Set DA channel 1 at Vmax');
END;
SetAllDA DA
Syntax
PROCEDURE SetAllDA;
Result
All DA-channels are set to maximum output voltage.
Description
All DA-channels of the 8-bit Digital to Analogue Converters are set to maximum output voltage.
Example
BEGIN
SetAllDA;
// All DA channels 1...4 are at Vmax
END;
Channel_no: Value between 1 and 32 which corresponds to the 6-bit DAC channel number in
which the data is to be changed.
Data:Value between 0 and 63 which is to be sent to the 6-bit Digital Analogue Converter .
Result
Loading...
+ 20 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.