The information contained in this manual is believed to be accurate and reliable. However, Keithley
Instruments, Inc., assumes no responsibility for its use or for any infringements of patents or other rights
of third parties that may result from its use. No license is granted by implication or otherwise under any
patent rights of Keithley Instruments, Inc.
KEITHLEY INSTRUMENTS, INC., SHALL NO T BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
OR CONSEQUENTIAL DAMAGES RELATED TO THE USE OF THIS PRODUCT. THIS
PRODUCT IS NOT DESIGNED WITH COMPONENTS OF A LEVEL OF RELIABILITY
SUITABLE FOR USE IN LIFE SUPPORT OR CRITICAL APPLICATIONS.
Refer to your Keithley Instruments license agreement for specific warranty and liability information.
All brand and product names are trademarks or registered trademarks of their respective companies.
All rights reserved. Reproduction or adaptation of any part of this documentation beyond that permitted
by Section 117 of the 1976 United States Copyright Act without permission of the Copyright owner is
unlawful.
Keithley MetraByte Division
Keithley Instruments, Inc.
440 Myles Standish Blvd. Taunton, MA 02780
FAX: (508) 880-0179
Telephone: (508) 880-3000
●
Preface
This manual describes how to write application programs for
DAS-4301/8K boards using the DAS-4300 Series Function Call Driver.
The DAS-4300 Series Function Call Driver supports the following
DOS-based languages:
●
●
Microsoft
Borland
C/C++ (Version 4.0 and higher)
C/C++ (Version 1.0 and higher)
The DAS-4300 Series Function Call Driver supports the following
Windows-based languages:
●
Microsoft C/C++ (Version 7.0 and higher)
Borland C/C++ (Version 4.0 and higher)
●
Microsoft Visual Basic
●
for Windows (Version 3.0 and higher)
The manual is intended for application programmers using a
DAS-4301/8K board in an IBM
PC AT
or compatible computer. It is
assumed that users have read the DAS-4300 Series User’s Guide to
familiarize themselves with the board’s features, and that they have
completed the appropriate hardware installation and configuration. It is
also assumed that users are experienced in programming in their selected
language and that they are familiar with data acquisition principles.
vii
The DAS-4300 Series Function Call Driver User’s Guide is organized as
follows:
●
Chapter 1 contains the information needed to install the DAS-4300
Series Function Call Driver and to get help.
Chapter 2 contains the background information needed to use the
●
functions included in the DAS-4300 Series Function Call Driver.
●
Chapter 3 contains programming guidelines and language-specific
information related to using the DAS-4300 Series Function Call
Driver.
●
Chapter 4 contains detailed descriptions of the DAS-4300 Series
Function Call Driver functions, arranged in alphabetical order.
●
Appendix A contains a list of the error codes returned by DAS-4300
Series Function Call Driver functions.
●
Appendix B contains instructions for converting counts to v oltage and
for converting voltage to counts.
●
Appendix C present bandwidth charts for the supported input ranges.
Figure C-5.±0.125 V Input Range (Gain Code 4) . . . . . . . . . C-3
Figure C-6.±0.15625 V Input Range (Gain Code 5) . . . . . . . C-4
Figure C-7.±0.3125 V Input Range (Gain Code 6) . . . . . . . . C-4
Figure C-8.±0.625 V Input Range (Gain Code 7) . . . . . . . . . C-5
Figure C-9.±0.1 V Input Range (Gain Code 8) . . . . . . . . . . . C-5
Figure C-10. ±0.125 V Input Range (Gain Code 9) . . . . . . . . . C-6
Figure C-11. ±0.25 V Input Range (Gain Code 10) . . . . . . . . . C-6
Figure C-12. ±0.5 V Input Range (Gain Code 11) . . . . . . . . . . C-7
Figure C-13. ±0.025 V Input Range (Gain Code 12) . . . . . . . . C-7
Figure C-14. ±0.03125 V Input Range (Gain Code 13) . . . . . . C-8
Figure C-15. ±0.0625 V Input Range (Gain Code 14) . . . . . . . C-8
Figure C-16. ±0.125 V Input Range (Gain Code 15) . . . . . . . . C-9
1
Getting Started
The DAS-4300 Series Function Call Dri ver is a library of data acquisition
and control functions (referred to as the Function Call Driver or FCD
functions). It is part of the following two software packages:
●
DAS-4300 Series Standard Software package - This is the software
package that is shipped with DAS-4301/8K boards; it includes utility
programs, running under DOS, that allow you to configure, calibrate,
and test the DAS-4301/8K boards.
●
ASO-4300 software package - This is the Advanced Software
Option for DAS-4301/8K boards. You purchase the ASO-4300
software package separately from the board; it includes the following:
–Libraries of FCD functions for Microsoft C/C++ (for DOS) and
Borland C/C++ (for DOS).
–Dynamic Link Libraries (DLLs) of FCD functions for Microsoft
Visual Basic for Windows, Microsoft C/C++ (for Windows), and
Borland C/C++ (for Windows).
–Support files, containing program elements, such as function
prototypes and definitions of variable types, that are required by
the FCD functions.
–Utility programs, running under DOS, that allow you to
configure, calibrate, and test the DAS-4301/8K boards.
–Language-specific example programs.
Before you use the Function Call Driver, make sure that you have
installed the software, set up the board, and created a configuration file
using the setup and installation procedures described in the DAS-4300
Series User’s Guide .
1-1
If you need help installing or using the DAS-4300 Series Function Call
Driver, call your local sales office or the Keithley Metrabyte Applications
Engineering Department at:
(508) 880-3000
Monday - Friday, 8:00
An applications engineer will help you diagnose and resolve your
problem over the telephone.
Please make sure that you have the follo wing information av ailable before
you call:
DAS-4301/8K board
configuration
Computer
A.M.
- 6:00
Serial #
Revision code
Base I/O address setting
Memory address setting
Interrupt level setting
Manufacturer
CPU type
Clock speed (MHz)
KB of RAM
Video system
BIOS type
Memory manager
This chapter contains the background information you need to use the
FCD functions to perform operations on DAS-4301/8K boards. The
supported operations are listed in Table 2-1.
Table 2-1. Supported Operations
OperationPage Reference
Systempage 2-1
Analog inputpage 2-4
System Operations
This section describes the miscellaneous operations and general
maintenance operations that apply to DAS-4301/8K boards and to the
DAS-4300 Series Function Call Driver. It includes information on
initializing a driver, initializing a board, retrieving revision levels, and
handling errors.
System Operations2-1
Initializing the Driver
You must initialize the DAS-4300 Series Function Call Driver and any
other Keithley DAS Function Call Drivers you are using in your
application program. To initialize the drivers, use the K_OpenDriver
function. You specify the driver you are using and the configuration file
that defines the use of the driver. The driver returns a unique identifier for
the driver; this identifier is called the driver handle.
You can specify a maximum of 30 driver handles for all the Keithley
MetraByte drivers initialized from all your application programs. If you
no longer require a driver and you want to free some memory or if you
have used all 30 driver handles, you can use the K_CloseDriver function
to free a driver handle and close the associated driver.
If the driver handle you free is the last driver handle specified for a
Function Call Driver, the driver is shut down. (For Windows-based
languages only, the DLLs associated with the Function Call Driver are
shut down and unloaded from memory.)
Initializing a Board
The DAS-4300 Series Function Call Driver supports up to two boards.
You must use the K_GetDevHandle function to specify the boards you
want to use. The driver returns a unique identifier for each board; this
identifier is called the device handle.
Device handles allow you to communicate with more than one board. You
use the device handle returned by K_GetDevHandle in subsequent
function calls related to the board.
You can specify a maximum of 30 device handles for all the Keithley
MetraByte boards accessed from all your application programs. If a board
is no longer being used and you want to free some memory or if you have
used all 30 device handles, you can use the K_FreeDevHandle function
to free a device handle.
2-2Available Operations
To reinitialize a board during an operation, use the K_DASDevInit
function. K_GetDevHandle and K_DASDevInit perform the following
tasks:
Abort all operations currently in progress that are associated with the
●
board identified by the device handle.
●
Verify that the board identified by the device handle is the board
specified in the configuration file associated with the board.
Retrieving Revision Levels
If you are using functions from different Keithley DAS Function Call
Drivers in the same application program or if you are having problems
with your application program, you may want to verify which versions of
the Function Call Driver, Keithley DAS Driver Specification, and
Keithley DAS Shell are installed on your computer.
The K_GetVer function allows you to get both the revision number of the
DAS-4300 Series Function Call Driver and the revision number of the
Keithley DAS Driver Specification to which the driver conforms.
The K_GetShellVer function allows you to get the revision number of
the Keithley DAS Shell (the Keithley DAS Shell is a group of functions
that are shared by all DAS boards).
Handling Errors
Each FCD function returns a code indicating the status of the function. To
ensure that your application program runs successfully, it is
recommended that you check the returned code after the execution of
each function. If the status code equals 0, the function executed
successfully and your program can proceed. If the status code does not
equal 0, an error occurred; ensure that your application program takes the
appropriate action. Refer to Appendix A for a complete list of error codes.
Each supported programming language uses a different procedure for
error checking. Refer to the following for information:
C/C++page 3-10
Visual Basic for Windowspage 3-17
System Operations2-3
For C-language application programs only, the DAS-4300 Series
Function Call Driver provides the K_GetErrMsg function, which gets
the address of the string corresponding to an error code.
Analog Input Operations
This section describes the following:
Analog input operation mode available.
●
●
How to allocate and manage memory for analog input operations.
●
How to specify the following for an analog input operation: a
channel, a gain and range, a clock source, a trigger source, and the
trigger acquisition type.
Operation Mode
DAS-4301/8K boards support interrupt mode only. In interrupt mode, the
board acquires multiple samples from a single analog input channel. A
hardware clock initiates A/D conversions. Once the analog input
operation begins, control returns to your application program. The
hardware continues to store the acquired data in its onboard memory until
the specified number of samples is acquired, then transfers the data all at
once to a user-defined array or buffer in the computer using an interrupt
service routine.
Use the K_IntStart function to start an analog input operation in
interrupt mode. Use the K_IntStop function to stop an interrupt-mode
operation. Use the K_IntStatus function to determine the current status
of an interrupt-mode operation.
The converted data is stored as counts. For information on converting
counts to voltage, refer to Appendix B.
2-4Available Operations
Memory Allocation and Management
Interrupt-mode analog input operations require a memory location in
which to store acquired data. DAS-4301/8K boards can transfer up to
8,192 samples (bytes) to this memory location.
Note:
Even though you can reserve a memory location greater than the
board requires, to conserve memory it is recommended that you allocate
only the required amount (maximum of 8,192 bytes).
The ways you can allocate and manage memory are described in the
following sections.
Dimensioning a Local Array
The simplest way to reserve a memory location is to dimension an array
within your application program’s memory area. This is the
recommended way to reserve memory for this driver. The advantage of
this method is that the array is directly accessible to your application
program. The limitation of this method is that local arrays occupy
permanent memory areas; these memory areas cannot be freed to make
them available to other programs or processes.
Since the DAS-4300 Series Function Call Driver stores data in 16-bit
integers, you must dimension a local array as an integer data type.
Dynamically Allocating a Memory Buffer
You can allocate a memory buffer dynamically outside of your
application program’s memory area. The adv antages of this method are as
follows:
●
The size of the buffer is limited by the amount of free physical
memory available in your computer at run time.
●
A dynamically allocated memory buffer can be freed to make it
available to other programs or processes.
Analog Input Operations2-5
The limitation of this method is that, for Visual Basic for Windows, data
in a dynamically allocated buffer is not directly accessible to your
program. You must use the K_MoveBufToArray function to move the
data from the dynamically allocated buffer to the program’s local array;
refer to page 3-16 for more information.
Use the K_IntAlloc function to dynamically allocate a memory buffer.
You specify the operation requiring the buffer and the number of samples
to store in the buffer (maximum of 8,192). The driver returns the starting
address of the buffer and a unique identifier for the buffer (this identifier
is called the memory handle). When the buffer is no longer required, you
can free the buffer for another use by specifying this memory handle in
the K_IntFree function.
Notes:
For DOS-based languages, the area used for dynamically
allocated memory buffers is referred to as the far heap; for
Windows-based languages, this area is referred to as the global heap.
These heaps are areas of memory left unoccupied as your application
program and other programs run.
For DOS-based languages, the K_IntAlloc function uses the DOS Int
21H function 48H to dynamically allocate far heap memory. For
Windows-based languages, the K_IntAlloc function calls the
GlobalAlloc API function to allocate the desired buffer size from the
global heap.
For Windows-based languages, dynamically allocated memory is
guaranteed to be fixed and locked in memory.
2-6Available Operations
Assigning the Starting Address
After you dimension your array or allocate your buffer, you must assign
the starting address of the array or buffer and the number of samples to
store in the array or buffer. Each supported programming language
requires a particular procedure for assigning a starting address. Refer to
the following for information:
Channels
Input Ranges
Language
C/C++Array or
Visual Basic for WindowsArrayK_SetBufIpage 3-15
The DAS-4301/8K board provides two analog input channels; the
software refers to the analog input signal from the Ch A connector as
channel 0 and the analog input signal from the Trg/Ch B connector as
channel 1. Y ou can perform an analog input operation on a single channel
at a time. To acquire samples from both channels, you must alternate
between the two channels after an acquisition is done.
You can acquire a single sample or multiple samples from a single analog
input channel. Use the K_SetChn function to specify the channel.
Memory
Location
Buffer
BufferK_SetBufpage 3-16
FunctionSee...
K_SetBufpage 3-9
Each channel on the DAS-4301/8K board can measure signals in one of
16, software-selectable bipolar analog input ranges.
T able 2-2 lists the analog input ranges supported by D AS-4301/8K boards
and the gain code associated with each range. Use the K_SetG function
to specify the gain code. Refer to Appendix C to understand the effect of
the input range on the bandwidth of the DAS-4301/8K board.
The pacer clock determines the period between A/D conversions. Use the
K_SetClk function to specify an internal or an external pacer clock. The
internal pacer clock is the default pacer clock.
The internal and external pacer clocks are described in the following
subsections; refer to the DAS-4300 Series User’s Guide for more
information.
Internal Pacer Clock
When you start an analog input operation (using K_IntStart ),
conversions are performed at a rate of 20 Gsamples/s divided by a count
value of 20, 40, 80, 200, 400, 800, 1600, 3200, 6400, 12800, or 25600.
Use the K_SetClkRate function to specify the count value. Each count
represents .05 ns between conversions.
Table 2-3 lists the conversion rates, sample periods, and count values for
the internal pacer clock.
2-8Available Operations
Table 2-3. Available Conversion Rates Using Internal Clock
If you enter a count value that is not one of those listed in Table
Count
Value
2-3, the driver uses the next f astest rate. F or e xample, if you enter a count
value of 50, the driver uses a count value of 40 to perform the faster
conversion rate. To determine the actual count value used, use the
K_GetClkRate function.
External Pacer Clock
When you start an analog input operation (using K_IntStart ),
conversions are armed. At the next rising edge of the external pacer clock
(and at every subsequent rising edge of the external pacer clock), a
conversion is initiated.
Do not use a conversion rate less than 100 Msamples/s when using an
external pacer clock or an error will result.
Analog Input Operations2-9
Triggers
A trigger is an event that occurs based on a specified set of conditions.
The operation must have a start trigger that determines when the
acquisition starts. In addition, you can choose the optional about trigger to
determine when the acquisition stops.
You can define operations that acquire data after the trigger event occurs
(post-trigger acquisition), operations that acquire data before a trigger
event (pre-trigger acquisition), and operations that acquire data before
and after a trigger event (about-trigger acquisition). For post-trigger
acquisitions, you can also specify a post-trigger delay. If you specify an
about trigger, the operation stops when a specified number of samples has
been acquired after the occurrence of the about-trigger event.
When the trigger event occurs, a TTL-le v el, signal is output on the T r g IO
connector. The signal is edge sensitive with a positive polarity.
Trigger Sources
The following sections describe the supported trigger sources and the
ways to acquire data using triggers.
Use K_SetTrig to specify an internal or an external trigger source.
External triggers can be either analog triggers or digital triggers. The
trigger event is not significant until the operation the trigger governs has
been started (using K_IntStart ).
The internal trigger, external analog trigger, and external digital trigger
are described in the following subsections.
Internal T rigger
An internal trigger is a software trigger. The trigger event occurs when
you start the operation using the K_IntStart function. Note that there is a
slight delay between the time you start the operation and the time the
trigger event occurs. The internal trigger is the default trigger source.
2-10Available Operations
External Analog Trigger
You can select the digitized analog input signal from the Ch A connector
(referred to in software as analog trigger channel 0) or from the Tr g/Ch B
connector (referred to in software as analog trigger channel 1) as the
trigger signal. You program the trigger level as a count value in 256 steps
(
128 to +127). If you use analog trigger channel 0 or 1, you must acquire
−
data from the same channel you are using as the trigger channel. For
example, if you specify 0 as the trigger channel, you must also acquire
analog input data from the Ch A connector by specifying 0 in K_SetChn .
You can also select the ±10 V trigger input signal from the Trg/Ch B
connector (referred to in software as analog trigger channel 2) as the
trigger signal. You program the trigger level as a count value in 256 steps
(
127 to 128) from
−
10 V to +9.922 V. If you use analog trigger channel
−
2, you can acquire analog input data from either the Ch A connector or
from the Trg/Ch B connector.
Note:
Even though the resolution of the ±10 V range is 12 bits in
hardware, the driver accepts only 8 bits, resulting in the loss of some
accuracy.
The trigger conditions for external analog triggers are illustrated in Figure
2-1 and described as follows:
Positive-Edge Trigger - A trigger event occurs the first time the
●
trigger signal changes from a voltage that is less than the trigger level
to a voltage that is greater than the trigger level.
Negative-Edge Trigger - A trigger event occurs the first time the
●
trigger signal changes from a voltage that is greater than the trigger
level to a voltage that is less than the trigger level.
Analog Input Operations2-11
Level + 5 V
0 V
Negative-edge
Positive-edge trigger occurs
trigger occurs
Analog input operation
start function is executed
Figure 2-1. Analog Trigger Conditions
Use the K_SetADTrig function to specify the analog input channel to use
as the trigger channel, the trigger level, and the trigger polarity. The
trigger sensitivity is always edge for the DAS-4301/8K board.
Refer to Appendix B for information on how to convert a voltage to a
count value.
External Digital Trigger
The digital trigger signal is connected to the Trg IO connector of the
DAS-4301/8K board. Use K_SetDITrig to specify the digital input
channel to use as the trigger channel and whether you want the trigger
event to occur on the rising edge of the digital trigger signal
(positive-edge trigger) or on a falling edge of the digital trigger signal
(negative-edge trigger). The trigger sensitivity is always edge for
DAS-4301/8K boards. The trigger events are illustrated in Figure 2-2.
2-12Available Operations
Trigger Acquisition
Positive-edge
trigger event occurs
Trigger signal
Negative-edge
trigger event occurs
Figure 2-2. Digital Trigger Conditions
The maximum number of samples you can collect for each trigger event
is 8,192. The minimum number of samples you can collect for each
trigger event depends on the conversion rate as follows:
Conversion rate of 100 Msamples/s and slower : minimum of 1
●
sample in increments of 1 sample.
Conversion rate of 250 Msamples/s and faster : minimum of 10
●
samples in increments of 10 samples.
The ways you can acquire data using triggers are described in the
following subsections.
Post-Trigger Acquisition
Use post-trigger acquisition in applications where you want to collect
data after a specific trigger event. You specify a start trigger only; the start
trigger determines when the operation starts and can be either an internal,
an external analog, or an external digital trigger. To stop the operation,
use the K_IntStop function. If desired, you can specify the number of
samples to wait between when the trigger event occurs and when the data
is collected by using the K_SetPostTrigDelay function.
Analog Input Operations2-13
At a conversion rate of 100 Msamples/s or slower, the post-trigger delay
can range from 0 to 65,536 samples (in increments of 1); at a conversion
rate of 250 Msamples/s or faster, the post-trigger delay can range from 0
to 655,360 samples (in increments of 10).
To specify post-trigger acquisition, perform the following steps:
1. Specify the start trigger.
–Use K_SetTrig to specify an internal or an external trigger
source (specify external for an analog or digital trigger).
–If you specify an external start trigger in K_SetTrig, define the
start trigger conditions using K_SetADTrig (for an analog
trigger) or K_SetDITrig (for a digital trigger).
2. If you specified an external analog or digital start trigger, use
K_ClrAboutTrig to disable the about trigger.
3. T o specify the number of post-trigger samples to wait after the trigger
event occurs and before data is collected, use K_SetPostTrigDelay.
Pre-Trigger Acquisition
Use pre-trigger acquisition in applications where you want to collect data
before a specific trigger event. The operation starts when your application
program calls the K_IntStart function. The about trigger can be either an
external analog or external digital trigger; the operation stops when the
about-trigger event occurs.
Note: The memory buffer must fill up with data at least once before the
board can accept a trigger event.
To specify pre-trigger acquisition, perform the following steps:
1. Use K_SetTrig to specify an external about-trigger source (external
analog or external digital trigger).
2. Use K_SetAboutTrig to enable the about trigger and to set the
number of samples to 1.
2-14Available Operations
Note: The minimum number of samples that you can specify in
K_SetAboutTrig is 1.
3. Specify the trigger conditions for the about trigger.
–If the about trigger is an external analog trigger, use
K_SetADTrig to specify the trigger conditions for the about
trigger.
–If the about trigger is an external digital trigger, use K_SetDIT rig
to specify the trigger conditions for the about trigger.
About-Trigger Acquisition
Use about-trigger acquisition in applications where you want to collect
data both before and after a specific trigger event. The operation starts
when your application program calls the K_IntStart function. The about
trigger can be either an external analog or external digital trigger; the
operation stops after a specified number of samples has been acquired
after the about-trigger event occurs.
Note: The memory location must fill up with data at least once before the
board can accept a trigger event.
To specify about-trigger acquisition, perform the following steps:
1. Use K_SetTrig to specify an external about-trigger source (external
analog or external digital trigger).
2. Use K_SetAboutTrig to enable the about trigger and to specify the
desired number of post-trigger samples.
3. Specify the trigger conditions for the about trigger.
–If the about trigger is an external analog trigger, use
K_SetADTrig to specify the trigger conditions for the about
trigger.
–If the about trigger is an external digital trigger, use K_SetDIT rig
to specify the trigger conditions for the about trigger.
Analog Input Operations2-15
After the about-trigger acquisition is completed, the software
automatically ensures that the post-trigger samples are the last samples in
the array or buffer.
For example, suppose you set the the number of post-trigger samples in
K_SetAboutTrig to 4,160 and start the about-trigger acquisition.
Pre-trigger data is collected and begins to fill the 8,192 byte buffer. Once
the buffer is filled, the board can accept a trigger; pre-trigger data
continues to be collected and overwrites the data in the buffer until the
trigger event occurs. When a v alid trigger event occurs, the board collects
4,160 post-trigger samples then stops the acquisition. The number of
pre-trigger samples in the buffer is 8,192 minus 4,160 or 4,032.
2-16Available Operations
3
Programming with
the Function Call Driver
This chapter contains an overview of the structure of the DAS-4300
Series Function Call Driver, as well as programming guidelines and
language-specific information to assist you when writing application
programs with the DAS-4300 Series Function Call Driver.
How the Driver Works
When writing application programs, you can use functions from one or
more Keithley MetraByte DAS Function Call Drivers. You initialize each
driver according to a particular configuration file. If you are using more
than one driver or more than one configuration file with a single driver,
the driver handle uniquely identifies each driver or each use of the driver.
You can program one or more boards in your application program. You
initialize each board using a device handle to uniquely identify each
board. Each device handle is associated with a particular driver.
The driver uses frames to perform operations. A frame is a data structure
whose elements define the attributes of the operation. Each frame is
associated with a particular board, and therefore, with a particular driver.
How the Driver Works3-1
Frames help you create structured application programs. You set up the
attributes of the operation in advance, using a separate function call for
each attribute, and then start the operation at an appropriate point in your
program. Frames are useful for operations that have many defining
attributes, since providing a separate argument for each attribute could
make a function’s argument list unmanageably long.
You indicate that you want to perform an analog input operation by
getting an available frame for the driver. The DAS-4300 Series Function
Call Driver provides analog input frames, called A/D (analog-to-digital)
frames. You use the K_GetADFrame function to access an available A/D
frame. The driver returns a unique identifier for the frame; this name is
called the frame handle.
You then specify the attributes of the operation by using setup functions
to define the elements of the frame associated with the operation. For
example, to specify the channel on which to perform an analog input
operation, you would use the K_SetChn setup function.
You use the frame handle you specified when accessing the frame in all
setup functions and other functions related to the operation. This ensures
that you are defining the same operation.
When you are ready to perform the operation you have set up, you can
start the operation by referencing the appropriate frame handle. Figure
3-1 illustrates the syntax of the interrupt-mode operation function
K_IntStart .
3-2Programming with the Function Call Driver
K_IntStart (
Channel
Clock Source
Trigger Source
Frame
.
.
.
frameHandle
)
Attributes of Operation
Analog input channel
Pacer clock source
Trigger source
.
.
.
Figure 3-1. Interrupt-Mode Operation
If you want to perform an interrupt-mode operation and all frames have
been accessed, you can use the K_FreeFrame function to free a frame
that is no longer in use. You can then redefine the elements of the frame
for the next operation.
When you access a frame, the elements are set to their default values. You
can also use the K_ClearFrame function to reset all the elements of a
frame to their default values.
Table 3-1 lists the elements of a DAS-4300 Series A/D frame. This table
also lists the default value of each element and the setup function used to
define each element.
How the Driver Works3-3
Table 3-1. A/D Frame Elements
ElementDefault ValueSetup Function
Buffer
1
0 (NULL)K_SetBuf
Number of Samples 0K_SetBuf
Channel0K_SetChn
Input range0 (±200 mV)K_SetG
Clock SourceInternal A/D pacer
K_SetClk
clock
Pacer Clock Rate0K_SetClkRate
Trigger SourceInternalK_SetTrig
Trigger Type DigitalK_SetADTrig
The default value of this element cannot be changed.
3
Use this function to reset the value of this particular frame element to its
default setting without clearing the frame or getting a new frame. Whenever
you clear a frame or get a new frame, this frame element is set to its default
value automatically.
3-4Programming with the Function Call Driver
The DAS-4300 Series Function Call Driver provides many other
Note:
functions that are not related to controlling frames or defining the
elements of frames. These functions include initialization functions,
memory management functions, and miscellaneous functions.
For information about using the FCD functions in your application
program, refer to the following sections of this chapter. For detailed
information about the syntax of FCD functions, refer to Chapter 4.
Programming Overview
To write an application program using the DAS-4300 Series Function
Call Driver, perform the following steps:
1. Define the application's requirements. Refer to Chapter 2 for a
description of the board operations supported by the Function Call
Driver and the functions that you can use to define each operation.
2. Write your application program. Refer to the following for additional
information:
–Preliminary Tasks, the next section, which describes the
programming tasks that are common to all application programs.
–Analog Input Programming Tasks on page 3-6, which describes
operation-specific programming tasks and the sequence in which
these tasks must be performed.
–Chapter 4, which contains detailed descriptions of the FCD
functions.
–The example programs in the ASO-4300 software package. The
FILES.TXT file in the installation directory lists and describes
the example programs.
3. Compile and link the program. Refer to the language-specific
programming information (page 3-11 to page 3-14 for C/C++ or page
3-18 for Visual Basic for Windows), or to the EXAMPLES.TXT file
in the installation directory for compile and link statements and other
language-specific considerations for each supported language.
Programming Overview3-5
Preliminary Tasks
For every Function Call Driver application program, you must perform
the following preliminary tasks:
1. Include the function and variable type definition file for your
language. This file is included in the ASO-4300 software package.
2. Declare and initialize program variables.
3. Use K_OpenDriver to initialize the driver.
4. Use K_GetDevHandle to specify the board you want to use and to
initialize the board. If you are using more than one board, use the
board initialization function once for each board you are using.
After completing the preliminary tasks, perform the analog input
programming tasks described in the following section.
Analog Input Programming Tasks
For an interrupt-mode analog input operation, perform the following
tasks:
1. Use the K_GetADFrame function to access an A/D frame.
2. Dimension a local array within your program’s memory area or use
the K_IntAlloc function to allocate a buffer dynamically outside your
program's memory area.
3. If you are programming in Visual Basic for Windows and are using a
local array , use the K_SetBufI function to assign the starting address
of the array and to specify the number of samples in the array.
Otherwise , use the K_SetBuf function to assign the starting address
of the array or buffer and to specify the number of samples in the
array or buffer.
4. Use the appropriate setup functions to specify the attributes of the
operation. The setup functions are listed in Table 3-2.
3-6Programming with the Function Call Driver
Note:
When you access a new A/D frame, the frame elements
contain default values. If the default value of a particular element is
suitable for your operation, you do not have to use the setup function
associated with that element. Refer to Table 3-1 on page 3-4 for a list
of the default values of A/D frame elements.
Refer to Chapter 2 for background information about the setup
functions; refer to Chapter 4 for detailed descriptions of the setup
functions.
5. Use the K_IntStart function to start the interrupt-mode operation.
6. Use the K_IntStatus function to monitor the status of the
interrupt-mode operation.
Analog Input Programming Tasks3-7
7. Use the K_IntStop function to stop the interrupt-mode operation
when the appropriate number of samples has been acquired.
8. If you are programming in Visual Basic for Windows and you are
using a dynamically allocated memory buffer , use the
K_MoveBufToArray function to transfer the acquired data from the
allocated buffer to a local array that your program can use.
9. If you used a dynamically allocated memory buffer , use the
K_IntFree function to free the memory.
C/C++ Programming Information
The following sections contain information you need to dimension an
array or dynamically allocate a memory buffer when programming in C
or C++, as well as language-specific information for Microsoft C/C++
and Borland C/C++ for DOS and Windows.
When programming in C/C++, proper typecasting may be required
Note:
to avoid C/C++ type-mismatch warnings.
Dimensioning and Assigning a Local Array
You can use a single, local array for an interrupt-mode analog input
operation. The following code fragment illustrates how to dimension an
array of 8,192 samples for the frame defined by hFrame and how to use
K_SetBuf to assign the starting address of the array.
Refer to the example programs on disk for more information.
3-8Programming with the Function Call Driver
Dynamically Allocating and Assigning a Memory Buffer
This section provides code fragments that describe how to dynamically
allocate and assign a memory buffer when programming in C or C++ and
how to access the data in the buffer. Refer to the example programs on
disk for more information.
If you are programming in Windows Enhanced mode, you may be
Note:
limited in the amount of memory you can allocate. It is recommended that
you install the Keithley Memory Manager before you begin programming
to ensure that you can allocate a large enough buffer; refer to the
DAS-4300 Series User’s Guide for information on the Keithley Memory
Manager.
Allocating a Memory Buffer
You can use a single, dynamically allocated memory buffer for an
interrupt-mode analog input operation. The following code fragment
illustrates how to use K_IntAlloc to allocate a buffer of size Samples for
the frame defined by hFrame and how to use K_SetBuf to assign the
starting address of the buffer.
. . .
void far *AcqBuf;//Declare pointer to buffer
WORD hMem;//Declare word for memory handle
. . .
wDasErr = K_IntAlloc (hFrame, Samples, &AcqBuf, &hMem);
wDasErr = K_SetBuf (hFrame, AcqBuf, Samples);
. . .
The following code illustrates how to use K_IntFree to later free the
allocated buffer, using the memory handle stored by K_IntAlloc .
. . .
wDasErr = K_IntFree (hMem);
. . .
C/C++ Programming Information3-9
Accessing the Data
You access the data stored in a dynamically allocated buffer through
C/C++ pointer indirection. For example, assume that you want to display
the first 10 samples of the buffer described in the previous section
(AcqBuf). The following code fragment illustrates how to access and
display the data.
. . .
int huge *pData;//Declare a pointer called pData
. . .
pData = (int huge *) AcqBuf; //Assign pData to buffer
for (i = 0; i < 10; i++)
printf ("Sample #%d %X", i, *(pData+i));
. . .
Note:
Declaring pData as a huge pointer allows the program to directly
access all data within the computer’s memory buffer, regardless of the
buffer size.
Handling Errors
It is recommended that you always check the returned value (wDasErr in
the previous examples) for possible errors. The following code fragment
illustrates how to check the returned value of the K_GetDevHandle
function.
{
printf (“Error %X during K_GetDevHandle”, wDASErr);
exit (1);
}
. . .
3-10Programming with the Function Call Driver
Programming in Microsoft C/C++ (for DOS)
To program in Microsoft C/C++ (for DOS), you need the following files;
these files are provided in the ASO-4300 software package.
FileDescription
DAS4300.LIBLinkable driver
DASRFACE.LIBLinkable driver
DASDECL.HInclude file when compiling in C (.c programs)
DASDECL.HPPInclude file when compiling in C++ (.cpp
programs).
USE4300.OBJLinkable object
To create an executable file in Microsoft C/C++ (for DOS), use the
following compile and link statements. Note that filename indicates the
name of your application program.
Type of CompileCompile and Link Statements
CCL /c filename .c
LINK filename +use4300.obj,,,das4300+dasrface;
C++CL /c filename .cpp
LINK filename +use4300.obj,,,das4300+dasrface;
Notes
1
These statements assume a large memory model; in DOS, only the large
memory model is acceptable.
1
C/C++ Programming Information3-11
Programming in Microsoft C/C++ (for Windows)
To program in Microsoft C/C++ (for Windows), including Microsoft
Visual C++, you need the following files; these files are provided in the
ASO-4300 software package.
FileDescription
DASSHELL.DLLDynamic Link Library
DASSUPRT.DLLDynamic Link Library
DAS4300.DLLDynamic Link Library
DASDECL.HInclude file when compiling in C (.c programs)
DASDECL.HPPInclude file when compiling in C++ (.cpp programs)
DASIMP.LIBDAS Shell Imports
To create an executable file in Microsoft C/C++ (for Windows), use the
following compile and link statements. Note that filename indicates the
name of your application program.
To create an executable file in the Microsoft C/C++ (for Windows)
environment, perform the following steps:
1. Create a project file by choosing New from the Project menu.
2. Add all necessary files to the project make file by choosing Edit from
the Project menu. Make sure that you include filename.c (or
filename.cpp), filename.rc, filename.def, and DASIMP.LIB, where
filename indicates the name of your application program.
3. From the Project menu, choose Rebuild All FILENAME.EXE to
create a stand-alone executable file (.EXE) that you can execute from
within Windo ws.
Programming in Borland C/C++ (for DOS)
To program in Borland C/C++ (for DOS), you need the following files;
these files are provided in the ASO-4300 software package.
FileDescription
DAS4300.LIBLinkable driver
DASRFACE.LIBLinkable driver
DASDECL.HInclude file when compiling in C (.c programs)
DASDECL.HPPInclude file when compiling in C++ (.cpp programs)
USE4300.OBJLinkable object
To create an executable file in Borland C/C++ (for DOS), use the
following compile and link statements. Note that filename indicates the
name of your application program.
These statements assume a large memory model; in DOS, only the large memory
model is acceptable.
C/C++ Programming Information3-13
1
Programming in Borland C/C++ (for Windows)
To program in Borland C/C++ (for Windows), you need the following
files; these files are provided in the ASO-4300 software package.
FileDescription
DASSHELL.DLLDynamic Link Library
DASSUPRT.DLLDynamic Link Library
DAS4300.DLLDynamic Link Library
DASDECL.HInclude file when compiling in C (.c programs)
DASDECL.HPPInclude file when compiling in C++ (.cpp programs)
DASIMP.LIBDAS Shell Imports
To create an executable file in Borland C/C++ (for Windows), use the
following compile and link statements. Note that filename indicates the
name of your application program.
To create an executable file in the Borland C/C++ (for Windows)
environment, perform the following steps:
1. Create a project file by choosing New from the Project menu.
2. Inside the Project window, select the project name and click on the
right mouse button.
3. Select the Add node option and add all necessary files to the project
make file. Make sure that you include filename.c (or filename.cpp),
3-14Programming with the Function Call Driver
filename.rc, filename.def, and D ASIMP.LIB, where filename indicates
the name of your application program.
4. From the Options menu, select Project.
5. From the Project Options dialog box, select Linker\General and make
sure that you turn OFF both the Case sensitive link and Case sensiti ve
exports and imports options.
6. From the Project menu, choose Build All to create a stand-alone
executable file (.EXE) that you can execute from within Windows.
Microsoft Visual Basic for Windows
Programming Information
The following sections contain information you need to dimension an
array or dynamically allocate a memory buffer when programming in
Microsoft Visual Basic for Windows, as well as language-specific
information for Microsoft Visual Basic for Windows.
Dimensioning and Assigning a Local Array
You can use a single, local array for an interrupt-mode analog input
operation. The following code fragment illustrates how to dimension an
array of 8K samples for the frame defined by hFrame and how to use
K_SetBufI to assign the starting address of the array.
Refer to the example programs on disk for more information.
Microsoft Visual Basic for Windows Programming Information3-15
Dynamically Allocating and Assigning a Memory Buffer
This section provides code fragments that describe how to dynamically
allocate and assign a memory buffer and how to access the data in the
buffer when programming in Microsoft Visual Basic for Windows. Refer
to the example programs on disk for more information.
Note: If you are programming in Windows Enhanced mode, you may be
limited in the amount of memory you can allocate. It is recommended that
you use the Keithley Memory Manager before you begin programming to
ensure that you can allocate a large enough buffer. Refer to your
DAS-4300 Series User’s Guide for more information about the Keithley
Memory Manager.
Allocating a Memory Buffer
You can use a single, dynamically allocated memory buffer for an
interrupt-mode analog input operation. The following code fragment
illustrates how to use K_IntAlloc to allocate a buffer of size Samples for
the frame defined by hFrame and how to use K_SetBuf to assign the
starting address of the buffer.
. . .
Global AcqBuf As Long’ Declare pointer to buffer
Global hMem As Integer’ Declare integer for memory handle
. . .
wDasErr = K_IntAlloc (hFrame, Samples, AcqBuf, hMem)
wDasErr = K_SetBuf (hFrame, AcqBuf, Samples)
. . .
The following code illustrates how to use K_IntFree to later free the
allocated buffer, using the memory handle stored by K_IntAlloc.
. . .
wDasErr = K_IntFree (hMem)
. . .
3-16Programming with the Function Call Driver
Accessing the Data
In Microsoft Visual Basic for Windo ws, you cannot directly access analog
input samples stored in a dynamically allocated memory buffer. You must
use K_MoveBufToArray to move a subset (up to 32,766 samples) of the
data into a local array as required. The following code fragment illustrates
how to move 100 samples from the buffer described in the previous
section (AcqBuf) to a local array.
. . .
Dim Buffer(1000) As Integer’ Declare local array
. . .
wDasErr = K_MoveBufToArray (Buffer(0), AcqBuf, 100)
. . .
Handling Errors
It is recommended that you always check the returned value (wDasErr in
the previous examples) for possible errors. The following code fragment
illustrates how to check the returned value of the K_GetDevHandle
function:
. . .
wDASErr = K_GetDevHandle (hDrv, BoardNum, hDev)
If (wDASErr <> 0) Then
MsgBox “K_GetDevHandle Error: ” + Hex$ (wDASErr),
MB_ICONSTOP, “DAS-4300 SERIES ERROR”
End
End If
. . .
Microsoft Visual Basic for Windows Programming Information3-17
Programming in Microsoft Visual Basic for Windows
To program in Microsoft Visual Basic for Windows, you need the
following files; these files are provided in the ASO-4300 software
package.
FileDescription
DASSHELL.DLLDynamic Link Library
DASSUPRT.DLLDynamic Link Library
DAS4300.DLLDynamic Link Library
DASDECL.BASInclude file; must be added to the Project List
To create an executable file from the Microsoft Visual Basic for Windows
environment, choose Make EXE File from the File menu.
3-18Programming with the Function Call Driver
4
Function Reference
The FCD functions are organized into the following groups:
The particular functions associated with each function group are presented
in Table 4-1. The remainder of the chapter presents detailed descriptions
of all the FCD functions, arranged in alphabetical order.
Keep the following conventions in mind throughout this chapter:
●
The data types DWORD, WORD, and BYTE are defined in the
language-specific include files.
●
Variable names are shown in italics.
The return value for all DAS-4300 Series FCD functions is the
●
error/status code. A value of 0 indicates that the function executed
successfully . A non-zero value indicates that an error occurred. Refer
to Appendix A for more information.
The description shows the prototype for the function.
●
In the Usage section, the variables are not defined. It is assumed that
●
the variables are defined as shown in the prototype.
.4-3
The name of each function argument in the Prototype and Usage sections
includes a prefix that indicates the associated data type. These prefixes are
described in Table 4-2.
Table 4-2. Data Type Prefixes
PrefixData T ypeComments
szPointer to string terminated by
zero
hHandle to device, frame, and
memory block
phPointer to a handle-type variableThis data type is used when calling the FCD functions
pPointer to a variableThis data type is used for pointers to all types of
nNumber valueThis data type is used when passing a number,
w16-bit wordThis data type is typically used when passing an
aArrayThis data type is typically used in conjunction with
This data type is typically used for variables that
specify the driver's configuration file name.
This data type is used for handle-type variables. You
declare handle-type variables in your program as long
or DWORD, depending on the language you are using.
The actual variable is passed to the driver by value.
to get a driver handle, a frame handle, or a memory
handle. The actual variable is passed to the driver by
reference.
variables, except handles (h). It is typically used when
passing a parameter of any type to the driver by
reference.
typically a byte, to the driver by value.
unsigned integer to the driver by value.
other prefixes listed here; for example, anVar denotes
an array of numbers.
fFloatThis data type denotes a single-precision floating-point
number.
dDoubleThis data type denotes a double-precision
floating-point number.
dw32-bit double wordThis data type is typically used when passing an
unsigned long to the driver by value.
4-4Function Reference
K_ClearFrame
Purpose
PrototypeC/C++
Sets the elements of a frame to their default values.
DASErr far pascal K_ClearFrame (DWORD hFrame );
Visual Basic for Windows
Declare Function K_ClearFrame Lib "DASSHELL.DLL"
(ByVal hFrame As Long) As Integer
Parameters
Return Value
Remarks
hFrame
Error/status code. Refer to Appendix A.
This function sets the elements of the frame specified by hFrame to their
default values.
Refer to T able 3-1 on page 3-4 for the def ault v alues of the elements of an
A/D frame.
See Also
UsageC/C++
K_GetADFrame
#include "DASDECL.H" // Use "DASDECL.HPP for C++
...
wDasErr = K_ClearFrame (hAD);
Handle to the frame that defines the operation.
Visual Basic for Windows
(Add DASDECL.BAS to your project)
...
wDasErr = K_ClearFrame (hAD)
4-5
K_CloseDriver
Purpose
PrototypeC/C++
Closes a previously initialized Keithley DAS Function Call Driver.
DASErr far pascal K_CloseDriver (DWORD hDrv );
Visual Basic for Windows
Declare Function K_CloseDriver Lib "DASSHELL.DLL"
(ByVal hDrv As Long) As Integer
Parameters
Return Value
Remarks
hDrv
Error/status code. Refer to Appendix A.
This function frees the driver handle specified by hDrv and closes the
associated use of the Function Call Driver. This function also frees all
device handles and frame handles associated with hDrv .
If hDrv is the last driver handle specified for the Function Call Dri v er, the
driver is shut down (for all languages) and unloaded (for Windows-based
languages only).
See Also
K_FreeDevHandle
Driver handle you want to free.
UsageC/C++
#include "DASDECL.H" // Use "DASDECL.HPP for C++
...
wDasErr = K_CloseDriver (hDrv);
Visual Basic for Windows
(Add DASDECL.BAS to your project)
...
wDasErr = K_CloseDriver (hDrv)
4-6Function Reference
K_ClrAboutTrig
Purpose
PrototypeC/C++
Disables the about trigger for an analog input operation.
DASErr far pascal K_ClrAboutTrig (DWORD hFrame );
Visual Basic for Windows
Declare Function K_ClrAboutTrig Lib "DASSHELL.DLL"
(ByVal hFrame As Long) As Integer
Parameters
Return Value
Remarks
hFrame
Error/status code. Refer to Appendix A.
This function disables the about trigger for the operation defined by
hFrame .
K_GetADFrame and K_ClearFrame also disable the about trigger.
See Also
UsageC/C++
K_ClearFrame, K_GetADFrame, K_SetAboutTrig
#include "DASDECL.H" // Use "DASDECL.HPP for C++
...
wDasErr = K_ClrAboutTrig (hAD);
Handle to the frame that defines the operation.
Visual Basic for Windows
(Add DASDECL.BAS to your project)
...
wDasErr = K_ClrAboutTrig (hAD)
4-7
K_DASDevInit
Purpose
PrototypeC/C++
Reinitializes a board.
DASErr far pascal K_DASDevInit (DWORD hDev );
Visual Basic for Windows
Declare Function K_DASDevInit Lib "DASSHELL.DLL"
(ByVal hDev As Long) As Integer
Parameters
Return Value
Remarks
hDev
Error/status code. Refer to Appendix A.
This function stops all current operations on the board specified by hDev
and verifies that the board identified by the device handle is the board
specified in the configuration file associated with the board.
UsageC/C++
#include "DASDECL.H" // Use "DASDECL.HPP for C++
...
wDasErr = K_DASDevInit (hDev);
Handle associated with the board.
Visual Basic for Windows
(Add DASDECL.BAS to your project)
...
wDasErr = K_DASDevInit (hDev)
4-8Function Reference
K_FreeDevHandle
Purpose
PrototypeC/C++
Frees a previously specified device handle.
DASErr far pascal K_FreeDevHandle (DWORD hDev );
Visual Basic for Windows
Declare Function K_FreeDevHandle Lib "DASSHELL.DLL"
(ByVal hDev As Long) As Integer
Parameters
Return Value
Remarks
hDev
Error/status code. Refer to Appendix A.
This function frees the device handle specified by hDev as well as all
frame handles associated with hDev .
See Also
UsageC/C++
K_GetDevHandle
#include "DASDECL.H" // Use "DASDECL.HPP for C++
...
wDasErr = K_FreeDevHandle (hDev);
Device handle you want to free.
Visual Basic for Windows
(Add DASDECL.BAS to your project)
...
wDasErr = K_FreeDevHandle (hDev)
4-9
K_FreeFrame
Purpose
PrototypeC/C++
Frees a frame.
DASErr far pascal K_FreeFrame (DWORD hFrame);
Visual Basic for Windows
Declare Function K_FreeFrame Lib "DASSHELL.DLL"
(ByVal hFrame As Long) As Integer
Parameters
Return Value
Remarks
hFr ameHandle to frame you want to free.
Error/status code. Refer to Appendix A.
This function frees the frame specified by hFrame, making the frame
available for another operation.
See Also
UsageC/C++
K_GetADFrame
#include "DASDECL.H" // Use "DASDECL.HPP for C++
...
wDasErr = K_FreeFrame (hAD);
Visual Basic for Windows
(Add DASDECL.BAS to your project)
...
wDasErr = K_FreeFrame (hAD)
4-10Function Reference
K_GetADFrame
Purpose
PrototypeC/C++
Accesses an A/D frame for an analog input operation.
DASErr far pascal K_GetADFrame (DWORD hDev,
DWORD far * phFrame);
Visual Basic for Windows
Declare Function K_GetADFrame Lib "DASSHELL.DLL"
(ByVal hDev As Long, phF rame As Long) As Integer
Parameters
hDevHandle associated with the board.
phFrameHandle to the frame that defines the operation.
Return Value
Remarks
Error/status code. Refer to Appendix A.
This function specifies that you want to perform an interrupt-mode analog
input operation on the board specified by hDev, and accesses an available
A/D frame with the handle phFrame. The frame is initialized to its default
settings; the default settings are given in Table 3-1 on page 3-4.
The value stored in phFrame is intended to be used exclusively as an
argument to functions that require a frame handle. Your program should
not modify the value stored in phFrame.
See Also
UsageC/C++
K_ClearFrame, K_FreeFrame
#include "DASDECL.H" // Use "DASDECL.HPP for C++
...
DWORD hAD;
...
wDasErr = K_GetADFrame (hDev, &hAD);
4-11
K_GetADFrame (cont.)
Visual Basic for Windows
(Add DASDECL.BAS to your project)
...
Global hAD As Long
...
wDasErr = K_GetADFrame (hDev, hAD)
4-12Function Reference
K_GetClkRate
Purpose
Gets a count value that determines the time between conversions for the
internal pacer clock.
PrototypeC/C++
DASErr far pascal K_GetClkRate (DWORD hFrame,
DWORD far *pRate);
Visual Basic for Windows
Declare Function K_GetClkRate Lib "DASSHELL.DLL"
(ByVal hFrame As Long, pRate As Long) As Integer
Parameters
hFr ameHandle to the frame that defines the operation.
pRateCount value.
For the operation defined by hFrame, this function stores the number of
clock ticks between conversions in pRate.
The pRate variable contains the value of the Pacer Clock Rate element.
See Also
UsageC/C++
K_SetClkRate
#include "DASDECL.H" // Use "DASDECL.HPP for C++
...
DWORD dwRate;
...
wDasErr = K_GetClkRate (hAD, &dwRate);
Visual Basic for Windows
(Add DASDECL.BAS to your project)
...
Global dwRate As Long
...
wDasErr = K_GetClkRate (hAD, dwRate)
4-14Function Reference
K_GetDevHandle
Purpose
PrototypeC/C++
Initializes any Keithley DAS board.
DASErr far pascal K_GetDevHandle (DWORD hDrv,
WORD nBoardNum, DWORD far * pDev);
Visual Basic for Windows
Declare Function K_GetDevHandle Lib "DASSHELL.DLL"
(ByVal hDrv As Long, ByVal nBoardNum As Integer, pDev As Long) As
Integer
Parameters
hDrvDriver handle of the associated Function Call
nBoardNumBoard number.
pDevHandle associated with the board.
Return Value
Remarks
Error/status code. Refer to Appendix A.
This function initializes the board associated with hDrv and specified by
nBoardNum, and stores the device handle of the specified board in pDev.
Driver.
Valid values: 0 to 1
The value stored in pDev is intended to be used exclusively as an
argument to functions that require a device handle. Your program should
not modify the value stored in pDev.
See Also
UsageC/C++
K_FreeDevHandle
#include "DASDECL.H" // Use "DASDECL.HPP for C++
...
DWORD hDev;
...
wDasErr = K_GetDevHandle (hDrv, 0, &hDev);
4-15
K_GetDevHandle (cont.)
Visual Basic for Windows
(Add DASDECL.BAS to your project)
...
Global hDev As Long
...
wDasErr = K_GetDevHandle (hDrv, 0, hDev)
4-16Function Reference
K_GetErrMsg
Purpose
PrototypeC/C++
Gets the address of an error message string.
DASErr far pascal K_GetErrMsg (DWORD hDev, short nDASErr,
char far * far * pErrMsg);
Visual Basic for Windows
Not supported
Parameters
hDevHandle associated with the board.
nDASErrError message number.
pErrMsgAddress of error message string.
Return Value
Remarks
Error/status code. Refer to Appendix A.
For the board specified by hDev, this function stores the address of the
string corresponding to error message number nDASErr in pErrMsg.
Refer to page 2-3 for more information about error handling. Refer to
Appendix A for a list of error codes and their meanings.
UsageC/C++
#include "DASDECL.H" // Use "DASDECL.HPP for C++
...
char far *pErrMsg;
...
wDasErr = K_GetErrMsg (hDev, wDASErr, &pErrMsg);
4-17
K_GetShellVer
Purpose
PrototypeC/C++
Gets the current DAS shell version.
DASErr far pascal K_GetShellVer (WORD far *pVersion);
Visual Basic for Windows
Declare Function K_GetShellVer Lib "DASSHELL.DLL"
(pVersion As Integer) As Integer
Parameters
Return Value
Remarks
pV er sionA word value containing the major and minor
Error/status code. Refer to Appendix A.
This function stores the current DAS shell version in pVersion. To obtain
the major version number of the DAS shell, divide pVersion by 256. To
obtain the minor version number of the DAS shell, perform a Boolean
AND operation with pVersion and 255 (0FF hex).
Usage
version numbers of the DAS shell.
C/C++
#include "DASDECL.H" // Use "DASDECL.HPP for C++
...
WORD wShellVer;
wDasErr = K_GetShellVer (&wShellVer);
printf ("Shell Ver %d.%d", wShellVer >> 8, wShellVer & 0xff);
Visual Basic for Windows
(Add DASDECL.BAS to your project)
...
Global wShellVer As Integer
...
wDasErr = K_GetShellVer (wShellVer)
ShellVer$ = LTRIM$(STR$(INT(wShellVer / 256))) + "." + :
LTRIM$(STR$(wShellVer AND &HFF))
PRINT "Driver Ver: " + ShellVer$
4-18Function Reference
K_GetVer
Purpose
PrototypeC/C++
Gets revision numbers.
DASErr far pascal K_GetVer (DWORD hDev, short far * pSpecVer,
short far * pDrvVer);
Visual Basic for Windows
Declare Function K_GetVer Lib "DASSHELL.DLL"
(ByVal hDev As Long, pSpecV er As Integer, pDrvV er As Integer)
As Integer
Parameters
hDevHandle associated with the board.
pSpecVerRevision number of the Keithley DAS Driver
pDrvVerDriver version number.
Return Value
Remarks
Error/status code. Refer to Appendix A.
For the board specified by hDev, this function stores the revision number
of the DAS-4300 Series Function Call Dri v er in pDrvVer and the revision
number of the driver specification in pSpecVer.
Specification to which the driver conforms.
The values stored in pSpecVer and pDrvV er are two-byte (16-bit) inte gers;
the high byte of each contains the major revision lev el and the lo w byte of
each contains the minor revision level. For example, if the driver version
number is 2.1, the major revision lev el is 2 and the minor revision level is
10; therefore, the high byte of pDrvVer contains the value of 2 (512) and
the low byte of pDrvVer contains the value of 10; the value of both bytes
is 522.
To extract the major and minor revision levels from the value stored in
pDrvVer or pSpecVer, use the following equations:
major revision levelInteger portion of
=
returned value
----------------------------------
256
minor revision levelreturned value MOD 256=
4-19
K_GetVer (cont.)
Usage
C/C++
#include "DASDECL.H" // Use "DASDECL.HPP for C++
...
short nSpecVer, nDrvVer;
...
wDasErr = K_GetVer (hDev, &nSpecVer, &nDrvVer);
printf ("Driver Ver %d.%d", nDrvVer >> 8, nDrvVer & 0xff);
Visual Basic for Windows
(Add DASDECL.BAS to your project)
...
Global nSpecVer As Integer
Global nDrvVer As Integer
...
wDasErr = K_GetVer (hDev, nSpecVer, nDrvVer)
DrvVer$ = LTRIM$(STR$(INT(nDrvVer / 256))) + "." + :
LTRIM$(STR$(nDrvVer AND &HFF))
PRINT "Driver Ver: " + DrvVer$
4-20Function Reference
K_IntAlloc
Purpose
PrototypeC/C++
Dynamically allocates a buffer for an interrupt-mode operation.
DASErr far pascal K_IntAlloc (DWORD hFrame , DWORD dwSamples ,
void far * far *pBuf , WORD far *pMem );
Visual Basic for Windows
Declare Function K_IntAlloc Lib "DASSHELL.DLL"
(ByVal hFrame As Long, ByVal dwSamples As Long, pBuf As Long,
pMem As Integer) As Integer
Parameters
hFrame
dwSamples
pBuf
pMem
Return Value
Remarks
Error/status code. Refer to Appendix A.
For the operation defined by hFrame , this function dynamically allocates
a buffer of the size specified by dwSamples, and stores the starting
address of the buffer in pBuf and the handle of the buffer in pMem.
Handle to the frame that defines the operation.
Number of samples.
Valid values: 1 to 8192
Starting address of the allocated buffer.
Handle associated with the allocated buffer.
The data in the allocated buffer is stored as counts. Refer to Appendix B
for information on converting a count value to voltage.
See Also
UsageC/C++
K_IntFree, K_SetBuf
#include "DASDECL.H" // Use "DASDECL.HPP for C++
...
void far *pBuf; // Pointer to allocated buffer
WORD hMem; // Memory Handle to buffer
...
wDasErr = K_IntAlloc (hAD, 8192, &pBuf, &hMem);
4-21
K_IntAlloc (cont.)
Visual Basic for Windows
(Add DASDECL.BAS to your project)
...
Global pBuf As Long
Global hMem As Integer
...
wDasErr = K_IntAlloc (hAD, 8192, pBuf, hMem)
4-22Function Reference
K_IntFree
Purpose
PrototypeC/C++
Frees a buffer dynamically allocated for an interrupt-mode operation.
DASErr far pascal K_IntFree (WORD hMem);
Visual Basic for Windows
Declare Function K_IntFree Lib "DASSHELL.DLL"
(ByVal hMem As Integer) As Integer
Parameters
Return Value
Remarks
hMemHandle to interrupt buffer.
Error/status code. Refer to Appendix A.
This function frees the buffer specified by hMem; the buffer was
previously allocated dynamically using K_IntAlloc.
See Also
UsageC/C++
K_IntAlloc
#include "DASDECL.H" // Use "DASDECL.HPP for C++
...
wDasErr = K_IntFree (hMem);
Visual Basic for Windows
(Add DASDECL.BAS to your project)
...
wDasErr = K_IntFree (hMem)
4-23
K_IntStart
Purpose
PrototypeC/C++
Starts an interrupt-mode operation.
DASErr far pascal K_IntStart (DWORD hFrame);
Visual Basic for Windows
Declare Function K_IntStart Lib "DASSHELL.DLL"
(ByVal hFrame As Long) As Integer
Parameters
Return Value
Remarks
hFr ameHandle to the frame that defines the operation.
Error/status code. Refer to Appendix A.
This function starts the interrupt-mode operation defined by hFrame.
Refer to page 3-6 for a discussion of the programming tasks associated
with interrupt-mode operations.
See Also
UsageC/C++
K_IntStatus, K_IntStop
#include "DASDECL.H" // Use "DASDECL.HPP for C++
...
wDasErr = K_IntStart (hAD);
Visual Basic for Windows
(Add DASDECL.BAS to your project)
...
wDasErr = K_IntStart (hAD)
4-24Function Reference
K_IntStatus
Purpose
Gets the status of an interrupt-mode operation.
PrototypeC/C++
DASErr far pascal K_IntStatus (DWORD hFrame, short far *pStatus,
DWORD far *pCount);
Visual Basic for Windows
Declare Function K_IntStatus Lib "DASSHELL.DLL"
(ByVal hFrame As Long, pStatus As Integer , pCount As Long)
As Integer
Parameters
hFrameHandle to the frame that defines the operation.
pStatusStatus of interrupt operation; see Remarks
pCountCurrent number of samples transferred into the
Return Value
Remarks
Error/status code. Refer to Appendix A.
For the interrupt-mode operation defined by hFrame, this function stores
the status in pStatus and the current number of samples transferred into
the array or buffer in pCount.
below for value stored.
array or buffer.
Bit
15
The value stored in pStatus depends on the settings in the Status word, as
shown below:
14
13
12
11
10
7
9
8
6
About-trigger
00 = Disabled
01 = Armed
11 = Done
4
5
0 = Interrupt operation inactive
1 = Interrupt operation active
3
2
0 = Buffer not filled
1 = Buffer filled
1
0
4-25
K_IntStatus (cont.)
The bits are described as follows:
●Bit 0: This bit indicates whether an interrupt-mode operation is in
progress.
●Bits 1 to 3: Not used.
●Bit 4: This bit is set when the array or buffer that is assigned to the
active operation has been filled with data.
●Bits 6 and 7: These bits indicate the state of the about trigger.
●Bits 8 to 15: Not used.
Figure 4-1. Status Word Settings
See Also
K_IntStart, K_IntStop
4-26Function Reference
UsageC/C++
#include "DASDECL.H" // Use "DASDECL.HPP for C++
...
WORD wStatus;
DWORD dwCount;
...
wDasErr = K_IntStatus (hAD, &wStatus, &dwCount);
Visual Basic for Windows
(Add DASDECL.BAS to your project)
...
Global wStatus As Integer
Global dwCount As Long
...
wDasErr = K_IntStatus (hAD, wStatus, dwCount)
K_IntStatus (cont.)
4-27
K_IntStop
Purpose
PrototypeC/C++
Stops an interrupt-mode operation.
DASErr far pascal K_IntStop (DWORD hFrame, short far *pStatus,
DWORD far *pCount);
Visual Basic for Windows
Declare Function K_IntStop Lib "DASSHELL.DLL"
(ByVal hFrame As Long, pStatus As Integer, pCount As Long) As
Integer
Parameters
hFr ameHandle to the frame that defines the operation.
pStatusStatus of interrupt operation. Refer to page 4-26
pCountCurrent number of samples transferred into the
Return Value
Remarks
Error/status code. Refer to Appendix A.
This function stops the board from acquiring data, disables the
interrupt-mode operation, and returns the status of the operation when
your program called this function. No data is transferred into the array or
buffer in computer memory.
for more information on the status word returned.
array or buffer.
If you are using an external start or about trigger, call this function if the
trigger event does not occur.
See Also
UsageC/C++
4-28Function Reference
K_IntStart, K_IntStatus
#include "DASDECL.H" // Use "DASDECL.HPP for C++
...
WORD wStatus;
DWORD dwCount;
...
wDasErr = K_IntStop (hAD, &wStatus, &dwCount);
K_IntStop (cont.)
Visual Basic for Windows
(Add DASDECL.BAS to your project)
...
Global wStatus As Integer
Global dwCount As Long
...
wDasErr = K_IntStop (hAD, wStatus, dwCount)
4-29
K_MoveBufToArray
Purpose
Transfers data from a buffer allocated through K_IntAlloc to a locally
dimensioned array.
PrototypeC/C++
Not supported
Visual Basic for Windows
Declare Function K_MoveBufToArray Lib "DASSHELL.DLL" Alias
"K_MoveDataBuf" (pDest As Integer, ByVal pSource As Long,
ByV al nCount As Integer) As Integer
Parameters
pDestAddress of destination array.
pSourceAddress of source buffer.
nCountNumber of samples to transfer.
Return Value
Remarks
Error/status code. Refer to Appendix A.
This function transfers the number of samples specified by nCount from
the buffer at address pSource to the array at address pDest.
Value values: 1 to 8192
In Visual Basic for Windows, the buffer allocated through K_IntAlloc is
not accessible to your program; you must use K_MoveBufToArray to
move the data from the allocated buffer to the program’s local array.
Initializes any Keithley DAS Function Call Driver.
DASErr far pascal K_OpenDriver (char far * szDrvName,
char far * szCfgName, DWORD far * pDrv);
Visual Basic for Windows
Declare Function K_OpenDriver Lib "DASSHELL.DLL"
(ByVal szDrvName As String, ByVal szCfgName As String,
pDrv As Long) As Integer
Parameters
szDrvNameBoard name.
szCfgNameDriver configuration file.
pDrvHandle associated with the driver.
Return Value
Error/status code. Refer to Appendix A.
Valid value:"DAS4300" (for DAS-4301/8K
boards)
Valid values: The name of a configuration file;
0 if driver has already been
opened
Remarks
This function initializes the DAS-4300 Series Function Call Driver
according to the information in the configuration file specified by
szCfgName, and stores the driver handle in pDrv.
You can use this function to initialize the Function Call Driver associated
with any Keithley MetraByte DAS board. For DAS-4301/8K boards, the
string stored in szDrvName must be DAS4300. Refer to other Function
Call Driver user’s guides for the appropriate string to store in szDrvName
for other Keithley MetraByte DAS boards.
The value stored in pDrv is intended to be used exclusively as an
argument to functions that require a driver handle. Your program should
not modify the value stored in pDrv.
You create a configuration file using the CFG4300.EXE utility. Refer to
your DAS-4300 Series User’s Guide for more information.
4-31
K_OpenDriver (cont.)
If szCfgName = 0, K_OpenDriver checks whether the driver has already
been opened and linked to a configuration file and if it has, uses the
current configuration; this is useful in the Windows environment.
Usage
C/C++
#include "DASDECL.H" // Use "DASDECL.HPP for C++
...
DWORD hDrv;
...
wDasErr = K_OpenDriver ("DAS4300", "DAS4300.CFG", &hDrv);
Visual Basic for Windows
(Add DASDECL.BAS to your project)
...
DIM hDrv As Long
...
wDasErr = K_OpenDriver("DAS4300", "DAS4300.CFG", hDrv)
4-32Function Reference
K_SetAboutTrig
Purpose
Enables the about trigger and specifies the number of post-trigger
samples.
PrototypeC/C++
DASErr far pascal K_SetAboutTrig (DWORD hFrame,
DWORD dwSamples);
Visual Basic for Windows
Declare Function K_SetAboutTrig Lib "DASSHELL.DLL"
(ByVal hFrame As Long, ByVal dwSamples As Long) As Integer
Parameters
hFr ameHandle to the frame that defines the operation.
dwSamplesNumber of post-trigger samples.
Return Value
Remarks
Error/status code. Refer to Appendix A.
This function enables the about trigger and specifies the number of
post-trigger samples in dwSamples. At least one pre-trigger sample must
be in the buffer.
Note that you cannot use an about trigger with an external start trigger.
Valid values: 0 to 8191
See Also
UsageC/C++
K_ClrAboutTrig
#include "DASDECL.H" // Use "DASDECL.HPP for C++
...
wDasErr = K_SetAboutTrig (hAD, 100);
Visual Basic for Windows
(Add DASDECL.BAS to your project)
...
wDasErr = K_SetAboutTrig (hAD, 100)
4-33
K_SetADTrig
Purpose
PrototypeC/C++
Sets up an external analog start or about trigger.
DASErr far pascal K_SetADTrig (DWORD hFrame, short nOpt,
short nChan, DWORD dwLevel);
Visual Basic for Windows
Declare Function K_SetADTrig Lib "DASSHELL.DLL"
(ByVal hFrame As Long, ByVal nOpt As Integer,
ByV al nChan As Integer, ByVal dwLevel As Long) As Integer
Parameters
hFr ameHandle to the frame that defines the operation.
nOptAnalog trigger polarity and sensitivity.
nChanTrigger channel.
Valid values: 0 for Positive edge
2 for Negative edge
Valid values: 0 for ±1 V signal from
Ch A connector
1 for ±1 V signal from
Trg/Ch B connector
2 for ±10 V signal from
Trg/Ch B connector
dwLevelLevel at which the trigger event occurs, specified
in counts.
Return Value
Remarks
Valid values:
Error/status code. Refer to Appendix A.
For the operation defined by hFrame, this function specifies the channel
−128 to 127
used for an analog trigger in nChan, the level used for the analog trigger
in dwLevel, and the trigger polarity and trigger sensitivity in nOpt.
If you specified a value of 0 for nChan, you must specify channel 0 in
K_SetChn. If you specified a value of 1 for nChan, you must specify
channel 1 in K_SetChn. If you specified a value of 2 for nChan, you can
specify either channel 0 or channel 1 in K_SetChn.
4-34Function Reference
You specify the value for dwLevel in counts. Refer to Appendix B for
information on converting the actual voltage to a count value.
The values you specify set the following elements in the frame identified
by hFrame:
●nOpt sets the value of the Trigger Polarity and Trigger Sensitivity
elements.
●nChan sets the value of the Trigger Channel element.
●dwLevel sets the value of the Trigger Level element.
K_SetADTrig does not affect the operation defined by hFr ame unless the
Trigger Source element is set to External (by a call to K_SetTrig) before hFrame is used as a calling argument to K_IntStart.
UsageC/C++
#include "DASDECL.H" // Use "DASDECL.HPP for C++
...
wDasErr = K_SetADTrig (hAD, 0, 1, 127);
K_SetADTrig (cont.)
Visual Basic for Windows
(Add DASDECL.BAS to your project)
...
wDasErr = K_SetADTrig (hAD, 0, 1, 127)
4-35
K_SetBuf
Purpose
Specifies the starting address of a previously allocated array or buf fer and
the number of samples in the array or buffer.
PrototypeC/C++
DASErr far pascal K_SetBuf (DWORD hFrame, void far *pBuf,
DWORD dwSamples);
Visual Basic for Windows
Declare Function K_SetBuf Lib "DASSHELL.DLL"
(ByVal hFrame As Long, ByVal pBuf As Long,
ByV al dwSamples As Long) As Integer
Parameters
hFr ameHandle to the frame that defines the operation.
pBufStarting address of array or buffer.
dwSamplesNumber of samples.
Return Value
Remarks
Error/status code. Refer to Appendix A.
For the operation defined by hFrame, this function specifies the starting
address of a previously allocated array or buffer in pBuf and the number
of samples (the size of the array or buffer) in dwSamples.
Valid values: 1 to 8192
For Visual Basic for Windows, use this function only for dynamically
allocated buffers. For locally dimensioned arrays, use K_SetBufI.
For C application programs, make sure that you use proper typecasting to
prevent C/C++ type-mismatch warnings.
The values you specify set the following elements in the frame identified
by hFrame:
●pBuf sets the value of the Buffer element.
●dwSamples sets the value of the Number of Samples element.
See Also
4-36Function Reference
K_IntAlloc, K_SetBufI
UsageC/C++
#include "DASDECL.H" // Use "DASDECL.HPP for C++
...
void far *pBuf; // Pointer to allocated buffer
...
wDasErr = K_IntAlloc (hAD, 8192, &pBuf, &hMem);
wDasErr = K_SetBuf (hAD, pBuf, 8192);
Visual Basic for Windows
(Add DASDECL.BAS to your project)
...
Global pBuf As Long
...
wDasErr = K_IntAlloc (hAD, 8191, pBuf, hMem)
wDasErr = K_SetBuf (hAD, pBuf, 8192)
K_SetBuf (cont.)
4-37
K_SetBufI
Purpose
Specifies the starting address of a locally dimensioned integer array and
the number of samples in the array.
PrototypeC/C++
Not supported
Visual Basic for Windows
Declare Function K_SetBufI Lib "DASSHELL.DLL" Alias "K_SetBuf"
(ByVal hFrame As Long, pBuf As Integer, ByVal dwSize As Long) As
Integer
Parameters
hFr ameHandle to the frame that defines the operation.
pBufStarting address of the locally dimensioned
dwSizeNumber of samples.
Return Value
Remarks
Error/status code. Refer to Appendix A.
For the operation defined by hFrame, this function specifies the starting
address of a locally dimensioned integer array in pBuf and the number of
samples stored in the array in dwSize.
integer array.
Valid values: 1 to 8192
Do not use this function for C; instead, use K_SetBuf.
For Visual Basic for Windows, use this function only for locally
dimensioned arrays. For buffers allocated dynamically using K_IntAlloc,
use K_SetBuf.
The pBuf v ariable sets the value of the Buf fer element; the dwSize variable
sets the value of the Number of Samples element.
See Also
4-38Function Reference
K_IntAlloc, K_SetBuf
UsageVisual Basic for Windows
(Add DASDECL.BAS to your project)
...
Global ADData(8191) As Integer
...
wDasErr = K_SetBufI (hAD, ADData(0), 8192)
K_SetBufI (cont.)
4-39
K_SetChn
Purpose
PrototypeC/C++
Specifies a single channel.
DASErr far pascal K_SetChn (DWORD hFrame, short nChan);
Visual Basic for Windows
Declare Function K_SetChn Lib "DASSHELL.DLL"
(ByVal hFrame As Long, ByVal nChan As Integer) As Integer
Parameters
hFr ameHandle to the frame that defines the operation.
nChanChannel on which to perform the operation.
Return Value
Remarks
Error/status code. Refer to Appendix A.
For the operation defined by hFrame, this function specifies the single
channel used in nChan.
Software channel 0 corresponds to the analog input signal from the Ch A
connector on the board; software channel 1 corresponds to the analog
input signal from the Trg/Ch B connector on the board.
Valid values: 0 for signal from Ch A connector
1 for signal from Trg/Ch B
connector
The value you specify in nChan sets the Channel element in the frame
identified by hFrame.
UsageC/C++
#include "DASDECL.H" // Use "DASDECL.HPP for C++
...
wDasErr = K_SetChn (hAD, 0);
Visual Basic for Windows
(Add DASDECL.BAS to your project)
...
wDasErr = K_SetChn (hAD, 0)
4-40Function Reference
K_SetClk
Purpose
PrototypeC/C++
Specifies the pacer clock source.
DASErr far pascal K_SetClk (DWORD hFrame, short nMode);
Visual Basic for Windows
Declare Function K_SetClk Lib "DASSHELL.DLL"
(ByVal hFrame As Long, ByVal nMode As Integer) As Integer
Parameters
hFr ameHandle to the frame that defines the operation.
nModePacer clock source.
Return Value
Remarks
Error/status code. Refer to Appendix A.
For the operation defined by hFrame, this function specifies the pacer
clock source in nMode. The value you specify in nMode sets the Clock
Source element in the frame identified by hFrame.
K_GetADFrame and K_ClearFrame specify internal as the default
clock source.
Valid values: 0 for Internal
1 for External
UsageC/C++
#include "DASDECL.H" // Use "DASDECL.HPP for C++
...
wDasErr = K_SetClk (hAD, 1);
Visual Basic for Windows
(Add DASDECL.BAS to your project)
...
wDasErr = K_SetClk (hAD, 1)
4-41
K_SetClkRate
Purpose
Specifies a count value that determines the time between conversions for
the internal pacer clock.
PrototypeC/C++
DASErr far pascal K_SetClkRate (DWORD hFrame,
DWORD dwDivisor);
Visual Basic for Windows
Declare Function K_SetClkRate Lib "DASSHELL.DLL"
(ByVal hFrame As Long, ByVal dwDivisor As Long) As Integer
Parameters
hFr ameHandle to the frame that defines the operation.
dwDivisorCount value.
For the operation defined by hFrame, this function specifies the count
value, which is divided into 20 Gsamples/s, for the internal pacer clock in
dwDivisor.
The value you specify in dwDivisor sets the Pacer Clock Rate element in
the frame identified by hFrame.
Refer to page 2-8 for more information on the internal pacer clock.
See Also
UsageC/C++
K_GetClkRate
#include "DASDECL.H" // Use "DASDECL.HPP for C++
...
wDasErr = K_SetClkRate (hAD, 20);
Visual Basic for Windows
(Add DASDECL.BAS to your project)
...
wDasErr = K_SetClkRate (hAD, 20)
4-43
K_SetDITrig
Purpose
PrototypeC/C++
Sets up an external digital start or about trigger.
DASErr far pascal K_SetDITrig (DWORD hFrame, short nOpt,
short nChan, DWORD nPattern);
Visual Basic for Windows
Declare Function K_SetDITrig Lib "DASSHELL.DLL"
(ByVal hFrame As Long, ByVal nOpt As Integer,
ByV al nChan As Integer, ByVal nPattern As Long) As Integer
Parameters
hFr ameHandle to the frame that defines the operation.
nOptTrigger polarity and sensitivity.
nChanDigital input channel.
nPatternTrigger pattern.
Return Value
Error/status code. Refer to Appendix A.
Valid values: 0 for Positive edge
2 for Negative edge
Valid value:0
Remarks
This function specifies the use of a digital trigger for the operation defined
by hFrame.
Since an external digital trigger is always connected to the Trg IO
connector on the board, the value of nChan is meaningless. In addition,
the DAS-4300 Series Function Call Dri ver does not support digital pattern
triggering; therefore, the value of nP attern is meaningless. The nChan and
nP attern parameters are provided for future compatibility.
4-44Function Reference
The values you specify set the following elements in the frame identified
by hFrame:
●nOpt sets the value of the Trigger Polarity element.
●nChan sets the value of the Trigger Channel element.
●nPattern sets the value of the Trigger Pattern element.
K_SetDITrig does not affect the operation defined by hFrame unless the
Trigger Source element is set to External (by a call to K_SetTrig) before hFrame is used as a calling argument to K_IntStart.
UsageC/C++
#include "DASDECL.H" // Use "DASDECL.HPP for C++
...
wDasErr = K_SetDITrig (hAD, 0, 0, 0);
Visual Basic for Windows
(Add DASDECL.BAS to your project)
...
wDasErr = K_SetDITrig (hAD, 0, 0, 0)
K_SetDITrig (cont.)
4-45
K_SetG
Purpose
PrototypeC/C++
Sets the input range.
DASErr far pascal K_SetG (DWORD hFrame, short nGain);
Visual Basic for Windows
Declare Function K_SetG Lib "DASSHELL.DLL"
(ByVal hFrame As Long, ByVal nGain As Integer) As Integer
Parameters
hFr ameHandle to the frame that defines the operation.
nGainGain code.
For the operation defined by hFr ame, this function specifies the gain code,
which represents the input voltage range, for a single channel in nGain.
Refer to Appendix C to understand the effect of input voltage ranges on
the bandwidth of the DAS-4301/8K board.
The value you specify in nGain sets the Gain element in the frame
identified by hFrame.
K_GetADFrame and K_ClearFrame specify 0 as the default gain code.
4-46Function Reference
UsageC/C++
#include "DASDECL.H" // Use "DASDECL.HPP for C++
...
wDasErr = K_SetG (hAD, 1);
Visual Basic for Windows
(Add DASDECL.BAS to your project)
...
wDasErr = K_SetG (hAD, 1)
K_SetG (cont.)
4-47
K_SetPostTrigDelay
Purpose
PrototypeC/C++
Sets the number of post-trigger delay samples.
DASErr far pascal K_SetPostTrigDelay (WORD hFrame,
DWORD nDelay);
Visual Basic for Windows
Declare Function K_SetPostTrigDelay Lib "DAS4300.DLL"
(ByVal hFrame As Long, nDelay As Long) As Integer
Parameters
hFr ameHandle to the frame that defines the operation.
nDelayPost-trigger delay samples.
Return Value
Remarks
Error/status code. Refer to Appendix A.
For the operation defined by hFr ame, this function specifies the number of
post-trigger delay samples in nDelay .
Valid values:
0 to 65536 (at conversion rate of
100 Msamples/s or slower)
0 to 655360 (at conversion rate of
250 Msamples/s or faster)
At a conversion rate of 100 Msamples/s or slower, the post-trigger delay
can range from 0 to 65,536 samples (in increments of 1); at a conversion
rate of 250 Msamples/s or faster, the post-trigger delay can range from 0
to 655,360 samples (in increments of 10).
You cannot specify a post-trigger delay if you are using an about trigger.
UsageC/C++
#include "DASDECL.H" // Use "DASDECL.HPP for C++
...
WORD nDelay;
...
wDasErr = K_SetPostTrigDelay (hFrame, hDelay);
4-48Function Reference
K_SetPostTrigDelay (cont.)
Visual Basic for Windows
(Add DASDECL.BAS to your project)
...
Global Delay As Long
...
wDasErr = K_SetPostTrigDelay (hFrame, nDelay)
4-49
K_SetTrig
Purpose
PrototypeC/C++
Specifies the trigger source.
DASErr far pascal K_SetTrig (DWORD hFrame, short nMode);
Visual Basic for Windows
Declare Function K_SetTrig Lib "DASSHELL.DLL"
(ByVal hFrame As Long, ByVal nMode As Integer) As Integer
Parameters
hFr ameHandle to the frame that defines the operation.
nModeTrigger source.
Return Value
Remarks
Error/status code. Refer to Appendix A.
For the operation defined by hFrame, this function specifies the trigger
source in nMode.
An internal trigger is a software trigger; conversions begin when your
application program calls K_IntStart. An external trigger is either an
analog trigger or a digital trigger. Refer to page 2-10 for more information
on trigger sources.
Valid values: 0 for Internal start trigger
1 for External start or about
trigger
You cannot use an external start trigger (as required for post-trigger
acquisition) when the about trigger is enabled. If you want to use an
external start trigger, ensure that the about trigger is disabled by using the
K_ClrAboutTrig function. Refer to page 2-13 for more information on
trigger acquisitions.
If nMode = 1, an external digital trigger is assumed. Use K_SetDITrig to
change the conditions of the digital trigger. Use K_SetADTrig to specify
the conditions for an external analog trigger.
K_GetADFrame and K_ClearFrame set the trigger source to internal.
4-50Function Reference
Loading...
+ 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.