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
The DAS-4200 Series Function Call Driver User’s Guide describes how
to write programs for DAS-4200 Series boards using the DAS-4200
Series Function Call Driver. The DAS-4200 Series Function Call Driver
supports the following DOS-based languages:
●
●
Microsoft
Borland
C/C++ (Version 6.0 and higher)
C/C++ (Version 1.0 and higher)
The DAS-4200 Series Function Call Driver supports the following
Windows-based languages:
●
Microsoft C/C++ (Version 7.0 and higher)
Microsoft Visual C++ (Version 1.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 programmers using a DAS-4200 Series board
in an IBM
PC AT
or compatible computer. It is assumed that users
have read the DAS-4200 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-4200 Series Function Call Driver User’s Guide is organized as
follows:
●
Chapter 1 contains installation information, a brief description of
available functions, and an illustration of the procedures to follow
when programming a DAS-4200 Series board using the DAS-4200
Series Function Call Driver. The last section of this chapter explains
how to get help.
Chapter 2 contains the background information needed to use the
●
functions included in the DAS-4200 Series Function Call Driver.
Chapter 3 contains a programming overview and language-specific
●
information related to using the DAS-4200 Series Function Call
Driver.
●
Chapter 4 contains detailed descriptions of the DAS-4200 Series
Function Call Driver functions, arranged in alphabetical order.
Appendix A contains a list of the error codes returned by DAS-4200
●
Series Function Call Driver functions.
Appendix B contains instructions for converting counts to v oltage and
●
for converting voltage to counts.
An index completes this manual.
Keep the following conventions in mind as you use this manual:
●
References to DAS-4200 Series boards apply to both the
DAS-4201/128K and the DAS-4201/512K boards. When a feature
applies to a particular board, that board’s name is used.
●
Unless otherwise noted, references to W indows include W indo ws 3.1,
Windows 3.11 for Workgroups, and Windows 95.
●
Keyboard keys and function names are represented in bold typeface.
Overview - a description of the DAS-4200 Series Function Call
●
Driver.
Summary of Functions - a brief description of the DAS-4200 Series
●
Function Call Driver functions.
Programming Flow Diagrams - an illustration of the procedures to
●
follow when programming a DAS-4200 Series board using the
DAS-4200 Series Function Call Driver.
Getting Help - information on how to get help when installing or
●
using the DAS-4200 Series Function Call Driver.
1-1
Overview
The DAS-4200 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 ASO-4200 software package, which includes
the following:
Libraries of FCD functions for Microsoft C/C++ 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-4200 Series 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-4200
Series User’s Guide .
1-2Getting Started
Summary of Functions
Table 1-1 provides a brief description of the functions in the DAS-4200
Series Function Call Driver. For more detailed information about the
functions, refer to Chapter 4.
Table 1-1. Summary of Functions
Function TypeFunction NameDescription
InitializationK_OpenDriverInitializes any Function Call Driver.
K_CloseDriverCloses a Function Call Driver.
K_GetDevHandleInitializes any Keithley DAS board.
K_FreeDevHandleFrees a device handle.
K_DASDevInitReinitializes a board.
Operation K_IntStartStarts an interrupt-mode operation.
K_IntStatusGets the status of an interrupt-mode operation.
K_IntStopStops an interrupt-mode operation.
Frame ManagementK_GetADFrameAccesses a frame for an analog input operation.
K_FreeFrameFrees a frame.
K_ClearFrameSets all frame elements to their default values.
Memory ManagementK_IntAllocDynamically allocates a memory buffer for an
interrupt-mode operation.
K_IntFreeFrees a memory buffer that was dynamically
allocated for an interrupt-mode operation.
K_MoveBufToArrayTransfers data from a dynamically allocated
memory buffer to a local integer array.
Buffer AddressK_SetBufSpecifies the starting address of a local array
(C/C++) or a dynamically allocated memory
buffer (C/C++, Visual Basic for Windows) for an
interrupt-mode operation.
K_SetBufISpecifies the starting address of a local array
(Visual Basic for W indo ws) for an interrupt-mode
operation.
Summary of Functions1-3
Table 1-1. Summary of Functions (cont.)
Function TypeFunction NameDescription
Channel and GainK_SetChnSpecifies the channel to use for the operation.
K_SetGSpecifies the gain for the specified channel.
Clock K_SetClkSpecifies the pacer clock source.
K_SetClkRateSpecifies the clock rate for the internal pacer
clock.
K_GetClkRateGets the clock rate for the internal pacer clock.
TriggerK_SetTrigSpecifies the trigger source.
K_SetADTrigSets up an external analog trigger.
K_SetDITrigSets up an external digital trigger.
K_SetAboutTrigEnables the about trigger and specifies the
number of post-trigger samples.
K_ClrAboutTrigDisables the about trigger.
MiscellaneousK_GetErrMsgGets the address of an error message string.
K_GetVerGets revision numbers.
K_GetShellVerGets the current DAS shell version.
Programming Flow Diagrams
This section contains a series of programming flow diagrams illustrating
the procedures used when programming each of the operations supported
by the DAS-4200 Series Function Call Dri ver. Although error checking is
not shown in the flow diagrams, it is recommended that you check the
error/status code returned by each function used in your program.
1-4Getting Started
Preliminary Steps
Install all required files,
including the function and
variable type definition file.
Declare and initialize program
variables.
Initialize the driver
(K_OpenDriver).
Initialize a board
(K_GetDevHandle).
Access a frame
(K_GetADFrame).
Using another
board?
No
For each board, perform the remaining
steps appropriate to the analog input
operation (beginning on the next page).
Yes
Programming Flow Diagrams1-5
Steps for an Analog Input Operation
Continued from previous page
How is
memory to be
allocated?
Dynamically allocated
memory buffer
Allocate a buffer
(K_IntAlloc).
Specify the starting address of the buffer
(K_SetBuf).
Specify the channel to use
(K_SetChn).
Specify the gain
for the channel
(K_SetG).
Local array
Declare and dimension
a local array.
Specify the starting
address of the local
array (K_SetBufI).
What type
of clock
source?
Specify an external pacer clock source
(K_SetClk) and set up the external clock
(hardware setup).
Continued on next page
Internal
External
Specifiy an internal clock
source (K_SetClk).
Set the clock rate
(K_SetClkRate).
1-6Getting Started
Steps for an Analog Input Operation (cont.)
Continued from previous page
Using a
trigger?
No
Specify an internal
start trigger
(K_SetTrig)l
Yes
What type of
Specify an external start
trigger (K_SetTrig)
What type of
external start
Specify digital trigger
conditions (K_SetDITrig)
trigger?
External start trigger.
trigger?
Digital
About trigger
Analog
Specify an internal
start trigger
(K_SetTrig)l
Continued on next page
Specify the
analog
trigger conditions
Disable the
about trigger
(K_ClrAboutTrig)
Specify the number of
Delaying
data
collection?
Yes
No
post-trigger delay samples
(K_SetPostTrigDelay)
Go to page 1-9
Programming Flow Diagrams1-7
Steps for an Analog Input Operation (cont.)
Continued from previous page
When reading
data?
Only before about
trigger occurs
Enable the about trigger
and specify 1 sample
(K_SetAboutTrig)
What type
of about
trigger?
Digital
Before and after the about
trigger occurs
Analog
Enable the about trigger
and specify the number of
post-trigger samples
(K_SetAboutTrig)
Specify the analog
about trigger conditions
(K_SetADTrig)
Specify digital
about trigger
conditions
(K_SetDITrig)
Continued on next page
1-8Getting Started
Steps for an Analog Input Operation (cont.)
Continued from previous page or from page 1-7
Start the operation
(K_IntStart)
Monitor the status of the operation
(K_IntStatus)
Stop the operation
(K_IntStop)
Which
programming
language?
Visual Basic for
Windows
Transfer data from the buffer to a
local array (K_MoveBufToArray)
Read data from the array
Convert data
from the array
Free the frame
K_FreeFrame
Operation complete
C / C++
Read data
from the buffer
Convert data
from the buffer
Free the buffer
(K_IntFree)
Programming Flow Diagrams1-9
Getting Help
If you need help installing or using the DAS-4200 Series Function Call
Driver, call your local sales office or call the following number for
technical support:
(508) 880-3000
Monday - Friday, 8:00
A.M.
- 6:00
P.M.
, Eastern Time
An applications engineer will help you diagnose and resolve your
problem over the telephone.
Please make sure that you have the information on the following page
available before you call.
1-10Getting Started
DAS-4200Series
board configuration
Computer
Operating system
Software package
Compiler
(if applicable)
Model
Serial #
Revision code
Base address setting
Interrupt level setting
Input configuration
Input range type
Manufacturer
CPU type
Clock speed (MHz)
Amount of RAM
Video system
BIOS type
System Operations - descriptions of the miscellaneous operations
●
and general maintenance operations that apply to DAS-4200 Series
boards and to the DAS-4200 Series Function Call Driver.
Analog Input Operations - description of the operation mode
●
available for analog input operations and instructions for allocating
memory and setting parameters for an analog input operation.
2-1
System Operations
Initializing the Driver
This section describes the miscellaneous operations and general
maintenance operations that apply to DAS-4200 Series boards and to the
DAS-4200 Series Function Call Driver. It includes information on
initializing a driver, initializing a board, retrieving revision levels, and
handling errors.
You must initialize the DAS-4200 Series Function Call Driver and any
other Keithley D AS Function Call Dri v ers you are using in your program.
T o initialize the dri v ers, use the K_OpenDriver function. Y ou specify the
driver you are using and the configuration file that defines the use of the
driver . The driv er returns a unique identifier for the driv er; 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 programs. If you no longer
require a driver and you want to free some memory or if you ha ve 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-4200 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.
2-2Available Operations
You can specify a maximum of 30 device handles for all the Keithley
MetraByte boards accessed from all your 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.
Use K_GetDevHandle the first time you initialize a board only. Once
you have a device handle, you can reinitialize a board as needed by using
the K_DASDevInit function.
Retrieving Revision Levels
If you are using functions from different Keithley DAS Function Call
Drivers in the same program or if you are having problems with your
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-4200 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 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 program takes the appropriate action. Refer to Appendix A for a
complete list of error codes.
System Operations2-3
Each supported programming language uses a different procedure for
error checking. Refer to the following for information:
C/C++page 3-5
Visual Basic for Windowspage 3-14
For C-language programs only, the DAS-4200 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:
●
●
●
Operation Mode
DAS-4200 Series 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 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 buf fer 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 the operation. Use
the K_IntStatus function to determine the current status of the operation.
The converted data is stored as counts. For information on converting
counts to voltage, refer to Appendix B.
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.
2-4Available Operations
Frames
The DAS-4200 Series Function Call Driver uses frames to perform
interrupt-mode analog input operations. A frame is a data structure whose
elements define the attributes of the operation. For each board you are
using in a program, use the K_GetADFrame function to access an
analog input frame, called an A/D (analog-to-digital) frame. The driver
returns a unique identifier for the frame; this identifier is called the frame
handle.
Specify the attributes of the operation by using a separate setup function
to define each element of the A/D frame. Use the frame handle returned
by the driver in each setup function to ensure that you always define the
same operation. For example, assume that you access an A/D frame with
the frame handle ADFrame. To specify the channel on which to perform
the operation, use the K_SetChn setup function, referencing the frame
handle ADFrame. To specify the gain at which to read the channel, use
the K_SetG setup function, also referencing the frame handle ADFrame.
When you are ready to perform the operation you have set up, use the
K_IntStart function to start the operation, again referencing the
appropriate frame handle. Figure 2-1 illustrates the use of an A/D frame
for an interrupt-mode operation, where the frame handle is ADFrame.
K_IntStart (ADFrame)
ADFrame
Channel
Clock Source
Trigger Source
.
.
.
Figure 2-1. Interrupt-Mode Operation
Attributes of Operation
Analog input channel
Pacer clock source
Trigger source
.
.
.
Analog Input Operations2-5
Frames help you create structured programs. They 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.
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 2-1 lists the elements of an A/D frame, the default value of each
element, the setup function used to define each element, and the pages in
this guide on which to find information specific to the function.
Table 2-1. A/D Frame Elements
ElementDefault ValueSetup FunctionSee Also
1
Buffer
Number of Samples0K_SetBufpage 4-37
Channel0K_SetChnpage 4-41
Gain 0 (gain of 1)K_SetGpage 4-47
Clock SourceInternal A/D pacer clockK_SetClkpage 4-42
Pacer Clock Rate
Trigger SourceInternalK_SetTrigpage 4-49
Trigger Type DigitalK_SetADTrigpage 4-35
Trigger Channel0 (for analog trigger)K_SetADTrigpage 4-35
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. Whene v er you clear a frame or get a ne w
frame, this frame element is set to its default value automatically.
DisabledK_SetAboutTrigpage 4-33
K_ClrAboutTrig
3
Memory Allocation and Management
Interrupt-mode analog input operations require a memory buffer in which
to store acquired data. DAS-4201/128K boards can acquire 131,072
samples (128K); DAS-4201/512K boards can acquire 524,288 samples
(512K).
Note:
board requires, it is recommended that you allocate a maximum buffer
size of 128K for DAS-4201/128K boards and 512K for DAS-4201/512K
boards.
Even though you can allocate a memory buffer greater than the
page 4-7
The ways you can allocate and manage memory are described in the
following sections.
Analog Input Operations2-7
Dynamically Allocating a Memory Buffer
You can allocate a memory buffer dynamically outside of your program’ s
memory area. This way is recommended for the D AS-4200 Series boards.
The advantages 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.
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. 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.
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 4-30 for more
information.
Notes:
If you are writing W indows 95, 32-bit programs, you must install
the Keithley Memory Manager. See your board user’s guide for details.
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 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-8Available Operations
Dimensioning a Local Array
A simpler way to reserve a memory location is to dimension an array
within your program’s memory area. The adv antage of this method is that
the array is directly accessible to your program. The limitations of this
method are as follows:
●
Certain programming languages limit the size of local arrays.
Local arrays occupy permanent memory areas; these memory areas
●
cannot be freed to make them available to other programs or
processes.
●
You cannot use local arrays with Windows 95, 32-bit programs.
Because of these limitations and because the DAS-4200 Series boards can
store up to 524,288 samples onboard, dimensioning a local array is not
recommended.
Since the DAS-4200 Series Function Call Driver stores data in 16-bit
integers, you must dimension all local arrays as integers.
Assigning the Starting Address
After you allocate a buffer or dimension an array, you must assign the
starting address of the array or buffer and the number of samples to store
in the buffer or array. Each supported programming language requires a
particular procedure for assigning a starting address. Refer to the
following table for information:
LanguageMemory LocationFunctionRefer to
C/C++Array or BufferK_SetBufpage 3-4
Visual Basic for
Windows
ArrayK_SetBufIpage 3-11
BufferK_SetBufpage 3-10
Analog Input Operations2-9
Channels
DAS-4200 Series boards provide tw o analog input channels; the software
refers to Channel A as channel 0 and Channel B as channel 1. You 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.
Gains and Ranges
Each channel on the DAS-4200 Series board can measure signals in one
of eight, software-selectable bipolar analog input ranges.
Table 2-2 lists the analog input ranges supported by DAS-4200 Series
boards and the gain and gain code associated with each range. Use the
K_SetG function to specify the gain code (the gain code is used by
K_SetG to represent the gain).
Table 2-2. Analog Input Ranges and Gains
Analog Input
Range
±2 V10
±1 V21
±500 mV42
±250 mV83
±125 mV164
±62.5 mV325
±31.25 mV646
±15.625 mV1287
Gain
Gain
Code
2-10Available Operations
Pacer Clocks
The pacer clock determines the period between A/D conversions. You can
specify an internal or an external pacer clock, as described in the
following subsections. Refer to the DAS-4200 Series User’s Guide for
more information.
Internal Pacer Clock
The internal pacer clock is the 100-MHz oscillator on the DAS-4200
Series board. The default clock source is internal; to reset the clock source
to the internal clock, use the K_SetClk function.
When you start an analog input operation (using K_IntStart ),
conversions are performed at a rate of 3.2 Gsamples/s divided by a clock
divider value. Use the K_SetClkRate function to specify the clock
divider value. Table 2-3 lists the supported clock divider values and the
corresponding conversion rates and sample periods for the internal pacer
clock.
Table 2-3, the driver uses the next fastest rate. For example, if you enter a
clock divider value of 63, the driver uses a clock divider value of 32 to
perform the faster conversion rate. To determine the actual clock divider
value used, use the K_GetClkRate function.
External Pacer Clock
You connect an external clock to the Clock I/O connector of the
DAS-4200 Series board. To specify an external clock source, use the
K_SetClk function.
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.
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.
If you enter a clock divider value that is not one of those listed in
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). 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.
The following sections describe the supported trigger sources and the
ways to acquire data using triggers.
2-12Available Operations
Trigger Sources
You can specify an internal or an external trigger source. An internal
trigger is a software trigger . 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. To reset the trigger
source to internal, use the K_SetTrig function.
External Analog Trigger
You can use the signal on the analog input channel being sampled as the
trigger signal for an analog trigger. The trigger conditions for analog
triggers are illustrated in Figure 2-2 and described as follows:
●Positiv e-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.
●Positiv e-Level Trigger - A trigger event occurs the first time the
trigger signal is a voltage that is greater than the trigger level.
●Negative-Lev el Trigger - If the trigger polarity is negative and the
sensitivity is level, a trigger event occurs the first time the trigger
signal is a voltage that is less than the trigger level.
Analog Input Operations2-13
Positive-level
trigger occurs
Level + 5 V
0 V
Negative-edge
or negative-level
trigger occurs
Analog input operation
start function is executed
Positive-edge trigger occurs
Figure 2-2. Analog Trigger Conditions
To specify an external analog trigger, first use the K_SetTrig function to
specify an external trigger. Then, use the K_SetADTrig function to
specify the analog input channel to use as the trigger channel, the trigger
level, and the trigger polarity and sensiti vity. You specify the trigger level
as a count value.
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 Trigger I/O connector of the
DAS-4200 Series boards. To specify an external digital trigger, first use
the K_SetTrig function to specify an external trigger. Then, use the K_SetDITrig function to specify 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 events are illustrated in Figure 2-3.
2-14Available Operations
Trigger Acquisition
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.
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.
Analog Input Operations2-15
Pre-Trigger Acquisition
Use pre-trigger acquisition in applications where you want to collect data
before a specific trigger event. The start trigger is always an internal
trigger; the operation starts when your program calls the K_IntStart
function. The operation stops when the about-trigger event occurs. The
about trigger can be either an external analog or external digital trigger.
To specify pre-trigger acquisition, perform the following steps:
1.Use K_SetTrig to specify an internal start-trigger source.
2.Use K_SetAboutTrig to enable the about trigger and to set the
number of samples to 1.
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 start trigger is
always an internal trigger; the operation starts when your program calls
the K_IntStart function. The operation stops after a specified number of
samples has been acquired after the about-trigger event occurs. The about
trigger can be either an external analog or external digital trigger.
To specify about-trigger acquisition, perform the following steps:
1.Use K_SetTrig to specify an internal start-trigger source.
2.Use K_SetAboutTrig to enable the about trigger and to specify the
desired number of post-trigger samples.
2-16Available Operations
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.
After the about-trigger acquisition is completed, the software
automatically ensures that the post-trigger samples are the last samples in
the buffer.
Analog Input Operations2-17
3
Programming with
the Function Call Driver
This chapter contains a programming overview and language-specific
information related to using the DAS-4200 Series Function Call Dri ver. It
includes the following sections:
●
Programming Overview - an overview of the tasks required to write
a program using the DAS-4200 Series Function Call Driver.
●
C/C++ Programming Information - language-specific information
for programming in Microsoft C/C++ (including Visual C++) and
Borland C/C++.
●
Visual Basic for Windows Programming Information -
language-specific information for programming in Microsoft Visual
Basic for Windows.
3-1
Programming Overview
To write a program using the DAS-4200 Series Function Call Driver,
perform the following steps:
1.Define the program'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 program. Refer to the following for additional
information:
–Programming flow diagrams for the preliminary tasks, on page
1-5, which illustrate the programming tasks common to all
programs.
–Programming flow diagrams for an analog input operation, on
page 1-6.
–Chapter 4, which contains detailed descriptions of the FCD
functions.
–The example programs in the ASO-4200 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-2 to page 3-9 for C/C++ or page
3-15 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.
C/C++ Programming Information
The following sections contain information you need to allocate and
assign a memory buffer when programming in C or C++, as well as
language-specific information for Microsoft C/C++ (including
Visual C++) and Borland C/C++ for DOS and Windows.
3-2Programming with the Function Call Driver
When programming in C/C++, proper typecasting may be required
Note:
to avoid C/C++ type-mismatch warnings. Make sure that linker options
are set so that case-sensitivity is disabled.
Dynamically Allocating and Assigning a Memory Buffer
This section provides code fragments that describe how to allocate and
assign a single, dynamically allocated memory buffer when programming
in C or C++. Refer to the example programs on disk for more
information.
Note:
To ensure that you can allocate a large enough buffer or buffers, it
is recommended that you install the Keithley Memory Manager before
you begin programming. Refer to the DAS-4200 Series User’s Guide for
information on the Keithley Memory Manager.
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-3
Accessing Data from a Dynamically Allocated Memory Buffer
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.
Dimensioning a Local Array
Although it is not generally recommended for this driver, you can use a
single, local array for an interrupt-mode analog input operation. A local
array is useful when you are acquiring small amounts of data (less than
32,767 samples). 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-4Programming with the Function Call Driver
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.
To program in Microsoft C/C++ (for DOS), you need the following files;
these files are provided in the ASO-4200 software package.
FileDescription
DAS4200.LIBLinkable driver
DASRFACE.LIBLinkable driver
DASDECL.HInclude file when compiling in C
DASDECL.HPPInclude file when compiling in C++
USE4200.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 program.
Type of CompileCompile and Link Statements
CCL /c filename .c
LINK filename +use4200.obj,,,das4200+dasrface;
C++CL /c filename .cpp
LINK filename +use4200.obj,,,das4200+dasrface;
Notes
1
These statements assume a large memory model; in DOS, only the large
memory model is acceptable.
1
3-6Programming with the Function Call Driver
Programming in Microsoft C/C++ (for Windows)
The files you need to program in Microsoft C/C++ (for Windows),
including Microsoft Visual C++, depend on whether you are writing
16-bit or 32-bit programs. The following files are provided either in the
ASO-4200 software package or on the ASO-Win95/32-Bit disk, which is
shipped with the ASO-4200 software package:
ProgramFileDescription
16 bitsDASSHELL.DLLDynamic Link Library of Shell functions
DASSUPRT.DLLDynamic Link Library of support functions
DAS4200.DLLDynamic Link Library of board-specific functions
DASDECL.HInclude file of Shell function definitions (used when
compiling in C or C++)
DASIMP.LIBImport library of Shell functions
32-bitsDASSHL32.DLLDynamic Link Library of Shell functions
DASSUPRT.DLLDynamic Link Library of support functions
DASSHL16.DLLDynamic Link Library of support functions
DAS4200.DLLDynamic Link Library of board-specific functions
DASDECL.HInclude file of Shell function definitions (used when
compiling in C or C++)
DASSHL32.LIBImport library of Shell functions
To create an executable file in the Microsoft C/C++ for Windows
environment, perform the following steps. Refer to the documentation
supplied with your compiler for information.
1.Create a project file.
2.Add all necessary files to the project make file. Make sure that you
include filename .c (or filename .cpp), filename .rc, filename .def,
DASIMP.LIB (or DASSHL32.LIB), and D4200IMP.LIB (16-bit
programs only), where filename indicates the name of your program.
3.Create a stand-alone executable file (.EXE) that you can run from
within Windo ws.
C/C++ Programming Information3-7
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-4200 software package.
FileDescription
DAS4200.LIBLinkable driver
DASRFACE.LIBLinkable driver
DASDECL.HInclude file when compiling in C
DASDECL.HPPInclude file when compiling in C++
USE4200.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 program.
These statements assume a large memory model; in DOS, only the large memory
model is acceptable.
1
3-8Programming with the Function Call Driver
Programming in Borland C/C++ (for Windows)
The files you need to program in Borland C/C++ (for Windows) depend
on whether you are writing 16-bit or 32-bit programs. The following files
are provided either in the ASO-4200 software package or on the
ASO-Win95/32-Bit disk, which is shipped with the ASO-4200 software
package:
ProgramFileDescription
16 bitsDASSHELL.DLLDynamic Link Library of Shell functions
DASSUPRT.DLLDynamic Link Library of support functions
DAS4200.DLLDynamic Link Library of board-specific functions
DASDECL.HInclude file of Shell function definitions (used when
compiling in C or C++)
DASIMP.LIBImport library of Shell functions
32-bitsDASSHL32.DLLDynamic Link Library of Shell functions
DASSUPRT.DLLDynamic Link Library of support functions
DASSHL16.DLLDynamic Link Library of support functions
DAS4200.DLLDynamic Link Library of board-specific functions
DASDECL.HInclude file of Shell function definitions (used when
compiling in C or C++)
DASSHL32.LIBImport library of Shell functions
To create an executable file in the Borland C/C++ (for Windows)
environment, perform the following steps:
1.Create a project file.
2.Add all necessary files to the project make file. Make sure that you
include filename .c (or filename .cpp), filename .rc, filename .def,
DASIMP.LIB (or DASSHL32.LIB), and D4200IMP.LIB (16-bit
programs only), where filename indicates the name of your program.
C/C++ Programming Information3-9
3.Make sure that you turn OFF the following options for the project:
–Case sensitive link
–Case sensitive exports and imports
–Ignore default libraries
4.Create a stand-alone executable file (.EXE) that you can run from
within Windo ws.
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.
Dynamically Allocating and Assigning a Memory Buffer
This section provides code fragments that describe how to allocate and
assign a single, dynamically allocated memory buffer when programming
in Microsoft Visual Basic for Windows. Refer to the example programs
on disk for more information.
Note:
recommended that you use the Keithley Memory Manager before you
begin programming. Refer to your DAS-4200 Series User’s Guide for
more information on the Keithley Memory Manager.
To ensure that you can allocate a large enough buffer, it is
3-10Programming with the Function Call Driver
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)
. . .
Accessing Data from a Dynamically Allocated Memory Buffer
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.
When Windows is running, the CPU operates in 16-bit protected mode.
Memory is addressed using a 32-bit selector:offset pair. The selector is
the CPU’s handle to a 64K byte memory page; it is a code whose value is
significant only to the CPU. No mathematical relationship exists between
a selector and the memory location it is associated with. In general, even
consecutively allocated selectors have no relationship to each other.
When a memory buffer of more than 64K bytes (32K values) is used,
multiple selectors are required. Under Windows, K_IntAlloc uses a
“tiled” method to allocate memory whereby a mathematical relationship
does exist among the selectors. Specifically , when you allocate a b uf fer of
more than 64K bytes, each selector that is allocated has an arithmetic
value that is eight greater than the previous one. The format of the address
is a 32-bit value whose high word is the 16-bit selector value and low
word is the 16-bit offset value. When the offset reaches 64K bytes, the
Microsoft Visual Basic for Windows Programming Information3-11
next consecutive memory address location can be accessed by adding
eight to the selector and resetting the offset to zero; to do this, add
&h80000 to the buffer starting address.
Table 3-1 illustrates the mapping of consecutive memory locations in
protected-mode “tiled” memory, where xxxxxxxx indicates the address
calculated by the CPU memory mapping mechanism.
Table 3-1. Protected-Mode Memory Architecture
Selector:Offset32-Bit Linear
Address
. . . . : . . . .. . . . .
32E6:FFFE
32E6:FFFF
32EE:0000
32EE:0001
. . . . : . . . .. . . . .
The following code fragment illustrates moving 1,000 values from a
memory buffer (AcqBuf) allocated with 50,000 values to the program’s
local array (Array), starting at the sample at buffer index 40,000. First,
start with the buffer address passed in K_SetBuf . Then, determine how
deep (in 64K byte pages) into the buffer the desired starting sample is
located and add &h80000 to the buffer address for each 64K byte page.
Finally, add any additional offset after the 64K byte pages to the buffer
address.
To move more than 32,767 values from the memory buffer to the
program’s local array, the program must call K_MoveBufToArray more
than once. For example, assume that pBuf is a pointer to a dynamically
allocated buffer that contains 65,536 v alues. The follo wing code fragment
illustrates how to move 65,536 values from the dynamically allocated
buffer to a local array within the program:
...
Dim Data [3, 16384] As Integer
...
wDasErr = K_MoveBufToArray (Data(0,0), pBuf, 16384)
If you request fewer than 32,767 samples for an interrupt-mode analog
input operation, you can use a single, local array. The following code
fragment illustrates how to dimension an array of 8192 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-13
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-4200 SERIES ERROR"
End
End If
. . .
3-14Programming with the Function Call Driver
Programming in Microsoft Visual Basic for Windows
The files you need to program in Microsoft Visual Basic for Windows
depend on whether you are writing a 16-bit or 32-bit program. The
following files are provided either in the ASO-4200 software package or
on the ASO-Win95/32-Bit disk, which is shipped with the ASO-4200
software package.
ProgramFileDescription
16 bitsDASSHELL.DLLDynamic Link Library
DASSUPRT.DLLDynamic Link Library
DAS4200.DLLDynamic Link Library
DASDECL.BASInclude file
DAS4200.BASInclude file of board-specific function definitions
32 bitsDASSHL32.DLLDynamic Link Library of Shell functions
DASSUPRT.DLLDynamic Link Library of support functions
DASSHL16.DLLDynamic Link Library of support functions
DASDEC32.BASInclude file of Shell function definitions
To create an executable file from the Microsoft Visual Basic for Windows
environment, perform the following steps:
1.Start Visual Basic for Windows, and open your project.
2.Add the appropriate include file(s) to your project:
–16-bit programs - DASDECL.BAS and DAS4200.BAS files
–32-bit programs - DASDEC32.BAS file
3.Create an executable (EXE) file.
Microsoft Visual Basic for Windows Programming Information3-15
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-4200 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, frame handle, device handle, or
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 2-1 on page 2-6 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 or DASDEC32.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 or DASDEC32.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 .
If you disable the about trigger, the trigger source specified in K_SetTrig
is always the start trigger.
K_GetADFrame and K_ClearFrame also disable the about trigger.
See Also
K_ClearFrame, K_GetADFrame, K_SetAboutTrig
Handle to the frame that defines the operation.
UsageC/C++
#include "DASDECL.H" // Use "DASDECL.HPP for C++
...
wDasErr = K_ClrAboutTrig (hAD);
Visual Basic for Windows
(Add DASDECL.BAS or DASDEC32.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.
Use K_GetDevHandle the first time you initialize a board only . Once you
have a device handle, use this function to reinitialize the board.
See Also
UsageC/C++
K_GetDevHandle
#include "DASDECL.H" // Use "DASDECL.HPP for C++
...
wDasErr = K_DASDevInit (hDev);
Handle associated with the board.
Visual Basic for Windows
(Add DASDECL.BAS or DASDEC32.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 or DASDEC32.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 or DASDEC32.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 analog input operation
on the board specified by hDev , and accesses an a v ailable A/D frame with
the handle phFrame. The frame is initialized to its default settings; the
default settings are given in Table 2-1 on page 2-6.
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 or DASDEC32.BAS to your project)
...
Global hAD As Long
...
wDasErr = K_GetADFrame (hDev, hAD)
4-12Function Reference
K_GetClkRate
Purpose
PrototypeC/C++
Gets the clock divider for the internal pacer clock.
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.
pRateClock divider.
The following table shows the clock divider values stored and the
corresponding conversion rates and sample periods for the internal pacer
clock
For the operation defined by hFr ame, this function stores the clock divider
for the internal pacer clock 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 or DASDEC32.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 * phDev);
Visual Basic for Windows
Declare Function K_GetDevHandle Lib "DASSHELL.DLL"
(ByVal hDrv As Long, ByVal nBoardNum As Integer, phDev As Long)
As Integer
Parameters
hDrvDriver handle of the associated Function Call
nBoardNumBoard number.
phDevHandle 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 phDev.
Driver.
Valid values: 0 to 1
See Also
The value stored in phDev 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 phDev.
Use this function the first time you initialize a board only . Once you have
a device handle (phDev), use the
K_DASDevInit function to reinitialize
the board.
K_DASDevInit, K_FreeDevHandle
4-15
K_GetDevHandle (cont.)
UsageC/C++
#include "DASDECL.H" // Use "DASDECL.HPP for C++
...
DWORD phDev;
...
wDasErr = K_GetDevHandle (hDrv, 0, &phDev);
Visual Basic for Windows
(Add DASDECL.BAS or DASDEC32.BAS to your project)
...
Global phDev As Long
...
wDasErr = K_GetDevHandle (hDrv, 0, phDev)
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 (0FFh).
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 or DASDEC32.BAS to your project)
...
Global wShellVer As Integer
...
wDasErr = K_GetShellVer (wShellVer)
ShellVer$ = LTRIM$(STR$(INT(wShellVer / 256))) + "." +
LTRIM$(STR$(wShellVer AND &HFF))
Msgbox "Shell Version: " + 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-4200 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.10, the major revision level 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 obtain the major version number of the Function Call Driver, divide
pDrvVer by 256; to obtain the minor version number of the Function Call
Driver, perform a Boolean AND operation with pDrvVer and 255 (0FFh).
To obtain the major version number of the driver specification, divide
pSpecVer by 256; to obtain the minor version number of the driver
specification, perform a Boolean AND operation with pSpecVer and 255
(0FFh).
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 or DASDEC32.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))
Msgbox "Driver Version: " + DrvVer$
4-20Function Reference
K_IntAlloc
Purpose
PrototypeC/C++
Allocates a buffer for an analog input operation.
DASErr far pascal K_IntAlloc (DWORD hFrame, DWORD dwSamples,
void far * far *pBuf, WORD far *phMem);
Visual Basic for Windows
Declare Function K_IntAlloc Lib "DASSHELL.DLL"
(ByVal hFrame As Long, ByVal dwSamples As Long, pBuf As Long,
phMem As Integer) As Integer
Parameters
hFr ameHandle to the frame that defines the operation.
dwSamplesNumber of samples.
pBufStarting address of the allocated buffer.
phMemHandle associated with the allocated buffer.
Return Value
Error/status code. Refer to Appendix A.
Valid values:
1 to 131072 for the DAS-4201/128K board
1 to 524288 for the DAS-4201/512K board
Remarks
See Also
For the operation defined by hFrame, this function 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 phMem.
The data in the allocated buffer is stored as counts. Refer to Appendix B
for information on converting a count value to voltage.
The value stored in phMem is intended to be used exclusively as an
argument to functions that require a memory handle. Your program
should not modify the value stored in phMem.
K_IntFree, K_SetBuf
4-21
K_IntAlloc (cont.)
UsageC/C++
#include "DASDECL.H" // Use "DASDECL.HPP for C++
...
void far *pBuf; // Pointer to allocated buffer
WORD phMem; // Memory Handle to buffer
...
wDasErr = K_IntAlloc (hAD, 131072, &pBuf, &phMem);
Visual Basic for Windows
(Add DASDECL.BAS or DASDEC32.BAS to your project)
...
Global pBuf As Long
Global phMem As Integer
...
wDasErr = K_IntAlloc (hAD, 131072, pBuf, phMem)
4-22Function Reference
K_IntFree
Purpose
PrototypeC/C++
Frees a buffer allocated for an analog input operation.
DASErr far pascal K_IntFree (WORD phMem);
Visual Basic for Windows
Declare Function K_IntFree Lib "DASSHELL.DLL"
(ByVal phMem As Integer) As Integer
Parameters
Return Value
Remarks
phMemHandle to buffer.
Error/status code. Refer to Appendix A.
This function frees the buffer specified by phMem; 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 (phMem);
Visual Basic for Windows
(Add DASDECL.BAS or DASDEC32.BAS to your project)
...
wDasErr = K_IntFree (phMem)
4-23
K_IntStart
Purpose
PrototypeC/C++
Starts an analog input 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 operation defined by hFrame. Refer to page 1-4
for a summary of the programming tasks associated with analog input
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 or DASDEC32.BAS to your project)
...
wDasErr = K_IntStart (hAD)
4-24Function Reference
K_IntStatus
Purpose
Gets the status of an analog input 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 operation; see Remarks below for
pCountCurrent number of samples transferred into the
Return Value
Remarks
Error/status code. Refer to Appendix A.
For the operation defined by hFrame, this function stores the status in
pStatus andthe current number of samples transferred into the buffer in
pCount.
value stored.
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 analog input operation is in
progress.
●Bits 1 to 3: Not used.
●Bit 4: This bit is set when the 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 or DASDEC32.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 analog input 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 operation.
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 operation,
and returns the status of the operation at the point when your program
called this function. No data is transferred into the buffer in computer
memory.
buffer.
Refer to page 4-25 for more information on the status word returned.
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 or DASDEC32.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 32767
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.
See Also
UsageVisual Basic for Windows
4-30Function Reference
K_IntAlloc
(Add DASDECL.BAS or DASDEC32.BAS to your project)
...
Dim ADArray(2000) As Integer
...
wDasErr = K_IntAlloc (hAD, 131072, pBuf, hMem)
...
wDasErr = K_MoveBufToArray (ADArray(0), pBuf, 1000)
K_OpenDriver
Purpose
PrototypeC/C++
Initializes any Keithley DAS Function Call Driver.
DASErr far pascal K_OpenDriver (char far * szDrvName,
char far * szCfgName, DWORD far * phDrv);
Visual Basic for Windows
Declare Function K_OpenDriver Lib "DASSHELL.DLL"
(ByVal szDrvName As String, ByVal szCfgName As String,
phDrv As Long) As Integer
Parameters
szDrvNameBoard name.
szCfgNameDriver configuration file.
phDrvHandle associated with the driver.
Return Value
Error/status code. Refer to Appendix A.
Valid value:"DAS4200" (for DAS-4200
Series boards)
Valid values: The name of a configuration file;
0 if driver has already been
opened
Remarks
This function initializes the DAS-4200 Series Function Call Driver
according to the information in the configuration file specified by
szCfgName, and stores the driver handle in phDrv.
You can use this function to initialize the Function Call Driver associated
with any Keithley MetraByte DAS board. For DAS-4200 Series boards,
the string stored in szDrvName must be DAS4200. 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 phDrv 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 phDrv.
You create a configuration file using the CFG4200.EXE utility. Refer to
your DAS-4200 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.
...
DIM phDrv As Long
...
wDasErr = K_OpenDriver("DAS4200", "DAS4200.CFG", phDrv)
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.
Valid values:
1 to 131072 for the DAS-4201/128K board
1 to 524288 for the DAS-4201/512K board
Note that you cannot use an about trigger with an external start trigger. If
you enable the about trigger and specify an external trigger source in
K_SetTrig, the software assumes that the external trigger is the about
trigger. For pre-trigger and about-trigger acquisition, the start trigger is
always an internal trigger.
See Also
UsageC/C++
K_ClrAboutTrig
#include "DASDECL.H" // Use "DASDECL.HPP for C++
...
wDasErr = K_SetAboutTrig (hAD, 100);
4-33
K_SetAboutTrig (cont.)
Visual Basic for Windows
(Add DASDECL.BAS or DASDEC32.BAS to your project)
wDasErr = K_SetAboutTrig (hAD, 100)
4-34Function Reference
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.
nChanAnalog input channel.
dwLevelLevel at which the trigger ev ent occurs, specified
Valid values: 0 for Positive edge
1 for Positive level
2 for Negative edge
3 for Negative level
Valid values: 0, 1
in counts.
Valid values:
−128 to 127
Return Value
Remarks
Error/status code. Refer to Appendix A.
For the operation defined by hFrame, this function specifies the channel
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.
The analog input channel you specify in nChan must be the same as the
analog input channel that is sampled; otherwise, the driver returns an
error.
You specify the value for dwLevel in counts. Refer to Appendix B for
information on converting the actual voltage to a count value.
4-35
K_SetADTrig (cont.)
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);
Visual Basic for Windows
(Add DASDECL.BAS or DASDEC32.BAS to your project)
...
wDasErr = K_SetADTrig (hAD, 0, 1, 127)
4-36Function Reference
K_SetBuf
Purpose
Specifies the starting address of a previously allocated buffer and the
number of samples in the 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 buffer.
dwSamplesNumber of samples.
Return Value
Error/status code. Refer to Appendix A.
Valid values:
1 to 131072 for the DAS-4201/128K board
1 to 524288 for the DAS-4201/512K board
Remarks
See Also
For the operation defined by hFrame, this function specifies the starting
address of a previously allocated buffer in pBuf and the number of
samples (the size of the buffer) in dwSamples.
For C/C++ programs, make sure that you use proper typecasting to
prevent C/C++ type-mismatch warnings.
For Visual Basic for Windows, use this function only for dynamically
allocated buffers. For locally dimensioned arrays, use K_SetBufI.
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.
K_IntAlloc, K_SetBufI
4-37
K_SetBuf (cont.)
UsageC/C++
#include "DASDECL.H" // Use "DASDECL.HPP for C++
...
void far *pBuf; // Pointer to allocated buffer
...
wDasErr = K_IntAlloc (hAD, 131072, &pBuf, &hMem);
wDasErr = K_SetBuf (hAD, pBuf, 131072);
Visual Basic for Windows
(Add DASDECL.BAS or DASDEC32.BAS to your project)
...
Global pBuf As Long
...
wDasErr = K_IntAlloc (hAD, 131072, pBuf, hMem)
wDasErr = K_SetBuf (hAD, pBuf, 131072)
4-38Function Reference
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 32768
See Also
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 variable sets the value of the Buffer element; the dwSize
variable sets the value of the Number of Samples element.
K_IntAlloc, K_SetBuf
4-39
K_SetBufI (cont.)
UsageVisual Basic for Windows
(Add DASDECL.BAS or DASDEC32.BAS to your project)
...
Global ADData(8191) As Integer
...
wDasErr = K_SetBufI (hAD, ADData(0), 8192)
4-40Function Reference
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 an analog input
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 Channel A on the board; software
channel 1 corresponds to Channel B on the board.
operation.
Valid values: 0, 1
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, 1);
Visual Basic for Windows
(Add DASDECL.BAS or DASDEC32.BAS to your project)
...
wDasErr = K_SetChn (hAD, 1)
4-41
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 or DASDEC32.BAS to your project)
...
wDasErr = K_SetClk (hAD, 1)
4-42Function Reference
K_SetClkRate
Purpose
PrototypeC/C++
Specifies the clock divider for the internal pacer clock.
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.
dwDivisorClock divider.
The following table shows the valid clock divider values and the
corresponding conversion rates and sample periods for the internal pacer
clock:
For the operation defined by hFrame, this function specifies the clock
divider 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.
If you enter a clock divider value that is not one of those specified as a
valid value abo ve, the dri v er uses the next f astest rate. For e xample, if you
enter a clock divider value of 63, the driver uses a clock divider value of
32 to perform the faster conversion rate. To determine the actual clock
divider used, use K_GetClkRate.
Refer to page 2-11 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, 64);
Visual Basic for Windows
(Add DASDECL.BAS or DASDEC32.BAS to your project)
...
wDasErr = K_SetClkRate (hAD, 64)
4-44Function Reference
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.
Valid values: 0 for Positive edge
2 for Negative edge
Valid value:0
Valid value:0
Return Value
Remarks
Error/status code. Refer to Appendix A.
For the operation defined by hFrame, this function specifies the trigger
polarity and sensitivity in nOpt.
Since an external digital trigger is always connected to the Trigger I/O
connector on the board, the value of nChan is meaningless. In addition,
the DAS-4200 Series Function Call Driver does not support digital
pattern triggering; therefore, the value of nPattern is meaningless. The nChan and nPattern parameters are provided for future compatibility.
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.
4-45
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.