Tektronix DASCard-1000 Series ASO Function Call Driver Users Guide

D ASCard-1000 Series Function Call Driver
USER’S GUIDE
DASCard-1000 Series
Function Call Driver
Revision A – June 1995
Part Number: 91880
New Contact Information
Keithley Instruments, Inc.
28775 Aurora Road
Cleveland, OH 44139
Technical Support: 1-888-KEITHLEY
Monday – Friday 8:00 a.m. to 5:00 p.m (EST)
Fax: (440) 248-6168
Visit our website at http://www.keithley.com
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.
MetraByte is a trademark of Keithley Instruments, Inc. All other brand and product names are trademarks or registered trademarks of their respective companies.
© Copyright Keithley Instruments, Inc., 1995.
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 the DASCard-1000 Series using the DASCard-1000 Series Function Call Driver. The DASCard-1000 Series Function Call Driver supports the following DOS-based languages:
Microsoft
QuickBasic  (Version 4.5)
Microsoft Professional Basic (Version 7.0)
Microsoft C/C++ (Versions 7.0 and 8.0)
Borland
C/C++ (Versions 3.1 and 4.0)
The DASCard-1000 Series Function Call Driver also supports the following W indows  -based languages:
Microsoft C/C++ (Versions 7.0 and 8.0)
Borland C/C++ (Versions 3.1 and 4.0) Microsoft Visual Basic
Microsoft Visual C++  (Version 1.5)
for Windows (Version 3.0)
The manual is intended for application programmers using a DASCard-1000 Series card in a notebook or desktop computer. It is assumed that users have read the DASCard-1000 Series User’s Guide to familiarize themselves with the card’s features and that they have completed the appropriate hardware and software installation and configuration. It is also assumed that users are experienced in programming in their selected language and that they are familiar with PCMCIA and data acquisition principles.
ix
The DASCard-1000 Series Function Call Driver User’s Guide is organized as follows:
Chapter 1 provides an overvie w of the Function Call Driv er , describes how to get started using the Function Call Driver, and describes how to get help.
Chapter 2 contains the background information needed to use the functions included in the Function Call Driver.
Chapter 3 contains programming guidelines and language-specific
information related to using the Function Call Driver.
Chapter 4 contains detailed descriptions of the functions, arranged in alphabetical order.
Appendix A contains a list of the error codes returned by the Function Call Driver.
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 DASCard-1000 Series cards apply to the
DASCard-1001, DASCard-1002, and DASCard-1003 cards. When a feature applies to a particular card, that card’s name is used.
References to BASIC apply to the DOS-based BASIC languages
(Microsoft QuickBasic and Microsoft Professional Basic). When a feature applies to a specific language, the complete language name is used. References to Visual Basic for Windows apply to Microsoft Visual Basic for Windows.
Keyboard keys are shown in bold typeface.
x
Table of Contents
Preface
1
Getting Started
2
Available Operations
System Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-1
Initializing the Driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-2
Initializing a Card . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-2
Retrieving Card Information. . . . . . . . . . . . . . . . . . . . . . . . . .2-3
Retrieving Revision Levels . . . . . . . . . . . . . . . . . . . . . . . . . . .2-4
Handling Errors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-4
Analog Input Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-5
Operation Modes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-5
Single Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-5
Synchronous Mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-6
Interrupt Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-6
Memory Allocation and Management. . . . . . . . . . . . . . . . . . .2-7
Dimensioning Local Arrays. . . . . . . . . . . . . . . . . . . . . . . .2-7
Dynamically Allocating Memory Buffers . . . . . . . . . . . . .2-8
Assigning the Starting Addresses. . . . . . . . . . . . . . . . . . . .2-9
Gains and Ranges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-10
Channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-11
Specifying a Single Channel . . . . . . . . . . . . . . . . . . . . . .2-13
Specifying a Group of Consecutive Channels . . . . . . . . .2-13
Specifying Channels in a Channel-Gain Queue. . . . . . . .2-14
Pacer Clocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-15
Internal Pacer Clock. . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-16
External Pacer Clock . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-17
Buffering Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-17
Triggers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-18
Analog Trigger. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-18
Digital Trigger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-22
Data Correction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-22
Digital I/O Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-24
Digital Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-25
Digital Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2-26
iii
iv
Programming with the Function Call Driver
3
How the Driver Works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-1
Programming Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-6
Preliminary Tasks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-7
Analog Input Programming Tasks . . . . . . . . . . . . . . . . . . . . . . . .3-7
Single-Mode Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-7
Synchronous-Mode Operations. . . . . . . . . . . . . . . . . . . . . . . .3-8
Interrupt-Mode Operations . . . . . . . . . . . . . . . . . . . . . . . . . .3-10
Digital I/O Programming Tasks . . . . . . . . . . . . . . . . . . . . . . . . .3-12
C/C++ Programming Information . . . . . . . . . . . . . . . . . . . . . . .3-13
Dynamically Allocating and Assigning Memory Buffers. . .3-13
Allocating a Single Memory Buffer. . . . . . . . . . . . . . . . .3-13
Allocating Multiple Memory Buffers. . . . . . . . . . . . . . . .3-14
Accessing the Data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-15
Dimensioning and Assigning Local Arrays. . . . . . . . . . . . . .3-15
Dimensioning a Single Array. . . . . . . . . . . . . . . . . . . . . .3-16
Dimensioning Multiple Arrays. . . . . . . . . . . . . . . . . . . . .3-16
Creating a Channel-Gain Queue . . . . . . . . . . . . . . . . . . . . . .3-17
Correcting Data (for DOS) . . . . . . . . . . . . . . . . . . . . . . . . . .3-18
Correcting Data (for Windows). . . . . . . . . . . . . . . . . . . . . . .3-19
Handling Errors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-20
Programming in Microsoft C/C++ (for DOS). . . . . . . . . . . .3-20
Programming in Microsoft C/C++ (for Windows) . . . . . . . .3-21
Programming in Borland C/C++ (for DOS) . . . . . . . . . . . . .3-23
Programming in Borland C/C++ (for Windows). . . . . . . . . .3-24
Visual Basic for Windows Programming Information. . . . . . . .3-25
Dynamically Allocating and Assigning Memory Buffers. . .3-25
Allocating a Single Memory Buffer. . . . . . . . . . . . . . . . .3-26
Allocating Multiple Memory Buffers. . . . . . . . . . . . . . . .3-26
Accessing the Data from Buffers with
Fewer than 64K Bytes . . . . . . . . . . . . . . . . . . . . . . . . . .3-27
Accessing the Data from Buffers with
More than 64K Bytes . . . . . . . . . . . . . . . . . . . . . . . . . . .3-28
Dimensioning and Assigning Local Arrays. . . . . . . . . . . . . .3-30
Dimensioning a Single Array. . . . . . . . . . . . . . . . . . . . . .3-30
Dimensioning Multiple Arrays. . . . . . . . . . . . . . . . . . . . .3-30
Creating a Channel-Gain Queue . . . . . . . . . . . . . . . . . . . . . .3-31
Correcting Data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-32
Handling Errors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-33
Programming in Microsoft Visual Basic for Windows . . . . .3-33
BASIC Programming Information. . . . . . . . . . . . . . . . . . . . . . .3-34
Dynamically Allocating and Assigning Memory Buffers. . .3-34
Reducing the Memory Heap . . . . . . . . . . . . . . . . . . . . . .3-34
Allocating a Single Memory Buffer. . . . . . . . . . . . . . . . .3-34
Allocating Multiple Memory Buffers. . . . . . . . . . . . . . . .3-35
Accessing the Data from Buffers with
Fewer than 64K Bytes . . . . . . . . . . . . . . . . . . . . . . . . . .3-36
Accessing the Data from Buffers with
More than 64K Bytes . . . . . . . . . . . . . . . . . . . . . . . . . . .3-36
Dimensioning and Assigning Local Arrays. . . . . . . . . . . . . .3-39
Dimensioning a Single Array. . . . . . . . . . . . . . . . . . . . . .3-39
Dimensioning Multiple Arrays. . . . . . . . . . . . . . . . . . . . .3-39
Creating a Channel-Gain Queue . . . . . . . . . . . . . . . . . . . . . .3-40
Correcting Data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-41
Handling Errors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3-42
Programming in Microsoft QuickBasic . . . . . . . . . . . . . . . .3-42
Programming in Microsoft Professional Basic . . . . . . . . . . .3-43
4
Function Reference
DAS1000_DevOpen. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-6
DAS1000_GetCardInfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-8
DAS1000_GetDevHandle . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-10
K_ADRead. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-12
K_BufListAdd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-14
K_BufListReset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-16
K_ClearFrame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-18
K_CloseDriver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-19
K_ClrContRun . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-20
K_CorrectData . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-22
K_DASDevInit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-24
K_DIRead . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-25
K_DOWrite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-27
K_FormatChnGAry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-29
K_FreeDevHandle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-31
K_FreeFrame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-32
K_GetADConfig . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-33
K_GetADFrame. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-35
K_GetADMode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-37
K_GetCalData . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-39
K_GetClkRate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-42
K_GetDevHandle. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-44
K_GetErrMsg. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-46
v
K_GetShellVer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-47
K_GetVer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-49
K_IntAlloc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-51
K_IntFree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-53
K_IntStart. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-54
K_IntStatus. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-55
K_IntStop. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-58
K_MoveBufToArray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-60
K_OpenDriver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-62
K_RestoreChnGAry. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-64
K_SetADConfig. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-65
K_SetADMode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-67
K_SetADTrig. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-69
K_SetBuf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-71
K_SetBufI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-73
K_SetCalMode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-75
K_SetChn. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-77
K_SetChnGAry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-79
K_SetClk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-81
K_SetClkRate. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-83
K_SetContRun . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-85
K_SetDITrig. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-87
K_SetG. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-89
K_SetStartStopChn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-91
K_SetStartStopG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-93
K_SetTrig. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-96
K_SetTrigHyst . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-98
K_SyncStart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-100
A
Error/Status Codes
B
Data Formats
Converting Corrected Counts to Voltage . . . . . . . . . . . . . . . . . . B-2
Converting Voltage to Counts. . . . . . . . . . . . . . . . . . . . . . . . . . . B-4
Specifying a Trigger Level . . . . . . . . . . . . . . . . . . . . . . . . . . B-4
Specifying a Hysteresis Value . . . . . . . . . . . . . . . . . . . . . . . . B-5
Index
vi
List of Figures
Figure 2-1. Analog Input Channels . . . . . . . . . . . . . . . . . . . .2-12
Figure 2-2. Analog Trigger Conditions . . . . . . . . . . . . . . . . .2-19
Figure 2-3. Using a Hysteresis Value. . . . . . . . . . . . . . . . . . .2-21
Figure 2-4. Digital Input Bits . . . . . . . . . . . . . . . . . . . . . . . . .2-25
Figure 2-5. Digital Output Bits. . . . . . . . . . . . . . . . . . . . . . . .2-26
Figure 3-1. Single-Mode Function . . . . . . . . . . . . . . . . . . . . . .3-2
Figure 3-2. Interrupt-Mode Operation . . . . . . . . . . . . . . . . . . .3-3
List of Tables
Table 2-1. Supported Operations . . . . . . . . . . . . . . . . . . . . . .2-1
Table 2-2. Analog Input Ranges . . . . . . . . . . . . . . . . . . . . . .2-10
Table 2-3. Logical Channels . . . . . . . . . . . . . . . . . . . . . . . . .2-12
Table 3-1. A/D Frame Elements . . . . . . . . . . . . . . . . . . . . . . .3-4
Table 3-2. Setup Functions for Synchronous-Mode
Analog Input Operations . . . . . . . . . . . . . . . . . . . .3-8
Table 3-3. Setup Functions for Interrupt-Mode
Analog Input Operations . . . . . . . . . . . . . . . . . . .3-11
Table 3-4. Protected-Mode Memory Architecture . . . . . . . .3-28
Table 3-5. Real-Mode Memory Architecture . . . . . . . . . . . .3-37
Table 4-1. Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4-2
Table 4-2. Data Type Prefixes. . . . . . . . . . . . . . . . . . . . . . . . .4-5
Table A-1. Error/Status Codes. . . . . . . . . . . . . . . . . . . . . . . . A-1
Table B-1. Span Values for A/D Conversion Equations . . . . B-2
vii
1
Getting Started
The DASCard-1000 Series Function Call Driver 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:
DASCard-1000 Series standard software package - This is the
software package that is shipped with DASCard-1000 Series cards; it includes the following:
Libraries of FCD functions for Microsoft QuickBasic and
Microsoft Professional Basic.
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 and Windows, that allow
you to allocate resources for, configure, calibrate, and test the
features of DASCard-1000 Series cards. – Language-specific example programs. – Support files for using the DASCard-1000 Series cards with
Visual Test Extensions
ASO-1000 software package - This is the advanced software option
for the DASCard-1000 Series cards. It includes the following: – Libraries of FCD functions for Microsoft C/C++ and Borland
C/C++. – Dynamic Link Libraries (DLLs) of FCD functions for Microsoft
C/C++, Borland C/C++, Microsoft Visual Basic for Windows,
and Microsoft Visual C++. – Support files, containing program elements, such as function
prototypes and definitions of variable types, that are required by
the FCD functions.
(VTX
).
1-1
Utility programs, running under DOS and Windows, that allow
you to allocate resources for, configure, calibrate, and test the
features of the DASCard-1000 Series cards. – Language-specific example programs. – Support files for using the DASCard-1000 Series cards with
VTX.
Before you use the Function Call Driver, make sure that you have installed the software and your DASCard-1000 Series cards using the procedures described in Chapter 3 of the DASCard-1000 Series User’s
Guide .
If you need help installing or using the DASCard-1000 Series Function Call Driver, call your local sales office or the Keithley MetraByte Applications Engineering Department at:
(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.
1-2 Getting Started
Please make sure that you have the follo wing information av ailable before you call:
DASCard-1000 Series card
Computer
Operating system
Card and socket services
Software package
Model Serial # Revision code Input configuration Input range type
Manufacturer CPU type Clock speed (MHz) Math coprocessor Amount of RAM Video system BIOS type PCMCIA controller Memory manager
DOS version Windows version Windows mode
Type Version
Name Serial # Version Invoice/Order #
_____________________ _____________________ _____________________ Single-ended Differential Unipolar Bipolar
_____________________ 386 486 Pentium 20 25 33 50 66 75 100 Yes No _____________________ EGA VGA SVGA _____________________ _____________________ _____________________
_____________________
3.0 3.1 Standard Enhanced
_____________________ _____________________
_____________________ _____________________ _____________________ _____________________
Compiler (if applicable)
Accessories
Language Manufacturer Version
Type/Number Type/Number Type/Number Type/Number Type/Number Type/Number Type/Number Type/Number
_____________________ _____________________ _____________________
_____________________ _____________________ _____________________ _____________________ _____________________ _____________________ _____________________ _____________________
1-3
2
Available Operations
This chapter contains the background information you need to use the FCD functions to perform operations on DASCard-1000 Series cards. The supported operations are listed in Table 2-1.
System Operations
This section describes the miscellaneous and general maintenance operations that apply to DASCard-1000 Series cards and to the DASCard-1000 Series Function Call Driver. It includes information on the following operations:
Initializing the driver
Initializing a card
Retrieving card information Retrieving revision levels
Table 2-1. Supported Operations
Operation Page Reference
System page 2-1 Analog input page 2-5 Digital input and output (I/O) page 2-24
Handling errors
System Operations 2-1
Initializing the Driver
You must initialize the DASCard-1000 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.)
Note:
K_CloseDriver are not available. You must use the DAS1000_DevOpen
function instead. DAS1000_DevOpen initializes the DASCard-1000 Series Function Call Driver according to the configuration file you specify. Refer to page 4-6 for more information. In BASIC, closing the DASCard-1000 Series Function Call Driver is not required.
Initializing a Card
The DASCard-1000 Series Function Call Driver supports up to two DASCard-1000 Series cards. You must use the K_GetDevHandle function to specify the cards you want to use. The driver returns a unique identifier for each card; this identifier is called the device handle.
Device handles allow you to communicate with more than one Keithley MetraByte DAS card or board. You use the device handle returned by
K_GetDevHandle in subsequent function calls related to the card or
board.
If you are programming in BASIC, K_OpenDriver and
2-2 Available Operations
You can specify a maximum of 30 device handles for all the Keithley MetraByte DAS cards or boards accessed from all your application programs. If a card or 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.
Note:
If you are programming in BASIC, K_GetDevHandle and
K_FreeDevHandle are not available. You must use the DAS1000_GetDevHandle function instead. Refer to page 4-10 for more
information. In BASIC, freeing a device handle is not required.
To reinitialize a Keithley MetraByte DAS card or board during an operation, use the K_DASDevInit function. DAS1000_GetDevHandle ,
K_GetDevHandle , and K_DASDevInit perform the following tasks:
Abort all operations currently in progress that are associated with the card or board identified by the device handle.
Verify that the card or board identified by the device handle is the
device specified in the configuration file associated with the device.
Retrieving Card Information
The Keithley MetraByte Enabler (KMENABLE.EXE) requests a base address, interrupt level, and memory segment address for each DASCard-1000 Series card from PCMCIA Card Services and then provides information about the assigned resources to your application program. To determine which system resources PCMCIA Card Services assigned, you can use the DAS1000_GetCardInfo function in your application program. Y ou specify a D ASCard-1000 Series card; the dri v er returns the socket in which the card is installed, the interrupt level, the base address, the memory segment address, and the card type. Refer to the DASCard-1000 Series User’s Guide for more information about the Enabler.
System Operations 2-3
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 used by your Keithley MetraByte DAS card or board.
The K_GetVer function allows you to get both the revision number of the Function Call Driver and the re vision number of the K eithley 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 Keithley MetraByte DAS cards and 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 language uses a different procedure for error checking; refer to the following pages for more information:
C/C++ page 3-20 Visual Basic for Windows page 3-33 BASIC page 3-42
For C-language application programs only, the Function Call Driver provides the K_GetErrMsg function, which gets the address of the string corresponding to an error code.
2-4 Available Operations
Analog Input Operations
This section describes the following:
Analog input operation modes available. How to allocate and manage memory for analog input operations.
How to specify the following for an analog input operation: – Channels and gains – Clock source – Buffering mode – Trigger source
How to correct analog input data using calibration factors.
Operation Modes
The operation mode determines which attributes you can specify for an analog input operation and how data is transferred from the DASCard-1000 Series card to computer memory. You can perform analog input operations in single mode, synchronous mode, and interrupt mode, as described in the following sections.
Single Mode
In single mode, the card acquires a single sample from an analog input channel. The driver initiates the con v ersion; you cannot perform any other operation until the single-mode operation is complete.
Use the K_ADRead function to start an analog input operation in single mode. Y ou specify the card you want to use, the analog input channel, the gain at which you want to read the signal, and the variable in which to store the converted data.
Analog Input Operations 2-5
Synchronous Mode
In synchronous mode, the card acquires a single sample or multiple samples from one or more analog input channels. A hardw are pacer clock initiates conversions. The hardware temporarily stores the acquired data in the 512-word FIFO (first-in, first-out data buffer) on the card, and then transfers the data from the FIFO to a user-defined buffer in computer memory. After the driver transfers the specified number of samples to computer memory, the driver returns control to the application program. You cannot perform any other operation until a synchronous-mode operation is complete.
Use the K_SyncStart function to start an analog input operation in synchronous mode.
Interrupt Mode
In interrupt mode, the card acquires a single sample or multiple samples from one or more analog input channels. A hardware clock initiates conversions. Once the analog input operation begins, control returns to your application program. The hardware temporarily stores the acquired data in the FIFO, and then transfers the data from the FIFO to a user-defined buffer in computer memory using an interrupt service routine.
Use the K_IntStart function to start an analog input operation in interrupt mode.
You can specify either single-cycle or continuous buffering mode for interrupt-mode operations. Refer to page 2-17 for more information on buffering modes. Use the K_IntStop function to stop a continuous-mode interrupt operation. Use the K_IntStatus function to determine the current status of an interrupt operation.
2-6 Available Operations
Memory Allocation and Management
Analog input operations require memory buffers in which to store acquired data. For synchronous mode and interrupt mode, you can allocate a single memory buffer; for interrupt mode only, you can allocate multiple buffers (up to a maximum of 150) to increase the number of samples you can acquire. The ways you allocate and manage memory are described in the following sections.
Note:
For interrupt-mode operations, the hardware transfers data either when the FIFO is half full (the number of samples is greater than or equal to 256) or when the FIFO has any data (when the number of samples is between 1 and 255). For best performance when using multiple-buffer or continuous-mode operations to acquire data, it is recommended that you allocate a buffer equal to or greater than 256 samples, even if you are not acquiring 256 samples. For single-buffer or single-cycle operations, you can allocate a buffer of any allowable size.
Dimensioning Local Arrays
The simplest way to reserve memory buf fers is to dimension arrays within your application program. The advantage of this method is that the arrays are directly accessible to your application 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.
Since the DASCard-1000 Series Function Call Dri ver stores data in 16-bit integers (12 bits of which determine the data), you must dimension all local arrays as integers.
Analog Input Operations 2-7
Dynamically Allocating Memory Buffers
The recommended way to reserve memory buffers is to allocate them dynamically outside of your application program’s memory area. The advantages of this method are as follows:
The number of memory buffers and the size of the b uffers are limited by the amount of free physical memory available in your computer at run-time.
Dynamically allocated memory buffers can be freed to make them available to other programs or processes.
The limitation of this method is that for Visual Basic for Windows and BASIC, the data in a dynamically allocated memory buffer is not directly accessible to your program. You must use the K_MoveBufToArray function to move the data from the dynamically allocated memory buffer to the program’s local array. For Visual Basic for Windows, refer to page 3-27 for more information; for BASIC, refer to page 3-36 for more information.
Use the K_IntAlloc function to dynamically allocate a memory buffer for a synchronous-mode or interrupt-mode operation. You specify the operation requiring the buffer and the number of samples to store in the buffer (maximum of 5,000,000 for interrupt mode or 32,767 for synchronous mode). 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.
2-8 Available Operations
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.
Assigning the Starting Addresses
After you allocate your buffers or dimension your arrays, you must assign the starting addresses of the arrays or buffers and the number of samples to store in the arrays or buffers. Each supported programming language requires a particular procedure for assigning the starting addresses; refer to the following pages for more information:
C/C++ page 3-13 Visual Basic for Windows page 3-25 BASIC page 3-34
If you are using multiple buffers, use the K_BufListAdd function to add each buffer to the list of multiple buffers associated with each operation and to assign the starting address of each buffer. Use the K_BufListReset function to clear the list of multiple buffers.
Analog Input Operations 2-9
Gains and Ranges
Each channel on a DASCard-1001 or D ASCard-1002 can measure analog input signals in one of four, software-selectable unipolar or bipolar analog input ranges. Each channel on a DASCard-1003 can measure analog input signals in one unipolar or bipolar analog input range. You specify the input range type (unipolar or bipolar) for the card in the configuration file. Refer to your DASCard-1000 Series User’s Guide for more information. To set the input range type in your application program, use the
K_SetADMode function.
Table 2-2 lists the analog input ranges supported by DASCard-1000 Series cards and the gain and gain code associated with each range. Gain codes are used by the FCD functions to represent the gain.
Table 2-2. Analog Input Ranges
Analog Input Range
Card
DASCard-1001 ±5.0 V 0.0 to +5.0 V 1 0
±0.5 V 0.0 to +0.5 V 10 1 ±50 mV 0 to +50 mV 100 2 ±5 mV 0 to +5 mV 1000 3
DASCard-1002 ±5.0 V 0.0 to +5.0 V 1 0
±2.5 V 0.0 to +2.5 V 2 1 ±1.25 V 0.0 to +1.25 V 4 2 ±0.625 V 0.0 to +0.625 V 8 3
DASCard-1003 ±5.0 V 0.0 to +5.0 V 1 0
Gain
Gain CodeBipolar Unipolar
2-10 Available Operations
Channels
For single-mode operations, you specify the gain code in the K_ADRead function.
For synchronous-mode and interrupt-mode analog input operations, you specify the gain code in the K_SetG or K_SetStartStopG function; the function you use depends on how you specify the channels, as described in the following section.
DASCard-1000 Series cards are software-configurable for either 16 single-ended analog input channels (numbered 0 through 15) or eight differential analog input channels (numbered 0 through 7).
You specify the input configuration (single-ended or differential) in the configuration file. Refer to the DASCard-1000 Series User’s Guide for more information. To set the input configuration in your application program, use the K_SetADConfig function.
If you require more than the 16 single-ended or eight differential channels, you can use up to 16 EXP-1600 expansion accessories to increase the number of available channels to a maximum of 256.
T o use EXP-1600 e xpansion accessories, the analog input channels on the DASCard-1000 Series card must be configured as single-ended. You assign expansion accessories to consecutive channels on the card, beginning with channel 0. You can also use the remaining channels on the card. Refer to the DASCard-1000 Series User’s Guide and to the
EXP-800/1600 User’s Guide for more information on using expansion
accessories.
The maximum supported configuration is 16 EXP-1600 expansion accessories. Table 2-3 lists the software (or logical) channels associated with each expansion accessory.
Analog Input Operations 2-11
Table 2-3. Logical Channels
Physical Channel on Card
Software (Logical) Channels
Physical Channel on Card
Software (Logical) Channels
0 0 to 15 8 128 to 143 1 16 to 31 9 144 to 159 2 32 to 47 10 160 to 175 3 48 to 63 11 176 to 191 4 64 to 79 12 192 to 207 5 80 to 95 13 208 to 223 6 96 to 111 14 224 to 239 7 112 to 127 15 240 to 255
Figure 2-1 illustrates the use of three EXP-1600 expansion accessories on a DASCard-1000 Series card configured for single-ended mode.
EXP-1600 channels 0 to 15
EXP-1600 channels 16 to 31
EXP-1600 channels 32 to 47
DASCard-1000 Series Card
15
0 1 2 3 . . .
Channels (on the card) 48 to 60
Figure 2-1. Analog Input Channels
2-12 Available Operations
Note: Because of the overhead required to perform interrupt-mode
operations under Windows, it is recommended that you use EXP-1600 expansion accessories in single mode or synchronous mode. The throughput of your DASCard-1000 Series card is reduced when using EXP-1600 expansion accessories.
You can perform an analog input operation on a single channel or on a group of multiple channels. The following sections describe how to specify the channels you are using.
Specifying a Single Channel
You can acquire a single sample or multiple samples from a single analog input channel.
For single-mode analog input operations, you can acquire a single sample from a single analog input channel. Use the K_ADRead function to specify the channel and the gain code.
For synchronous-mode and interrupt-mode analog input operations, you can acquire a single sample or multiple samples from a single analog input channel. Use the K_SetChn function to specify the channel and the K_SetG function to specify the gain code.
Specifying a Group of Consecutive Channels
For synchronous-mode and interrupt-mode analog input operations, you can acquire samples from a group of consecutive channels. Use the K_SetStartStopChn function to specify the first and last channels in the group. The channels are sampled in order from first to last; the channels are then sampled again until the required number of samples is read.
For example, assume that you have an EXP-1600 expansion accessory attached to channel 0 on a DASCard-1000 Series card configured for single-ended mode. You specify the start channel as 14, the stop channel as 17, and you want to acquire five samples. Your program reads data first from channels 14 and 15 (on the EXP-1600), then from channels 16 and 17 (physical channels 1 and 2 on the DASCard-1000 Series card), and finally from channel 14 again.
Analog Input Operations 2-13
You can specify a start channel that is higher than the stop channel. For example, assume that you are not using any expansion accessories, the card uses a differential input configuration, the start channel is 7, the stop channel is 2, and you want to acquire five samples. Your program reads data first from channel 7 then from channels 0, 1, and 2, and finally from channel 7 again.
Use the K_SetG function to specify the gain code for all the channels in the group. (All channels must use the same gain code.) Use the K_SetStartStopG function to specify the gain code, the start channel, and the stop channel in a single function call.
Refer to Table 2-2 on page 2-10 for a list of the analog input ranges supported by the DASCard-1000 Series and the gain code associated with each range.
Specifying Channels in a Channel-Gain Queue
For synchronous-mode and interrupt-mode analog input operations, you can acquire samples from channels in a software channel-gain queue. In the channel-gain queue, you specify the channels you want to sample, the order in which you want to sample them, and the gain code for each channel.
Note: Because of the overhead required to perform interrupt-mode
operations under Windows, it is recommended that you use channel-gain queues in synchronous mode. The throughput of the DASCard-1000 Series card is reduced when using a channel-gain queue. However, performance is optimized when the channels in the channel-gain queue are sequential and when the gains of all the channels are the same.
You can set up the channels in a channel-gain queue either in consecutive order or in nonconsecutive order. You can also specify the same channel more than once.
The channels are sampled in order from the first channel in the queue to the last channel in the queue; the channels in the queue are then sampled again until the specified number of samples is read.
2-14 Available Operations
Pacer Clocks
Refer to Table 2-2 on page 2-10 for a list of the analog input ranges supported by the DASCard-1000 Series and the gain code associated with each range.
The way that you specify the channels and gains in a channel-gain queue depends on the language you are using. Refer to the following pages for more information:
C/C++ page 3-17 Visual Basic for Windows page 3-31 BASIC page 3-40
After you create the channel-gain queue in your program, use the K_SetChnGAry function to specify the starting address of the channel-gain queue.
For synchronous-mode and interrupt-mode analog input operations, the pacer clock determines the period between 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 sections; refer to the DASCard-1000 Series User’s Guide for more information.
Note: The rate at which the computer can reliably read data from the card
depends on a number of factors, including your computer, the operating system/environment, the number of channels you are using, the gains of the channels, and other software issues.
Analog Input Operations 2-15
Internal Pacer Clock
The internal pacer clock uses a 16-bit counter on the card. The counter is normally in an idle state. When you start the analog input operation (using K_SyncStart or K_IntStart), the counter is loaded with its initial value and begins counting down. When the counter counts down to 0, the first conversion is initiated. After the first conversion is initiated, the counter is loaded again and the process repeats.
Use the K_SetClkRate function to specify a count value, which represents the number of clock ticks between conversions; each clock tick represents 0.1 period between conversions is 987.6
If you are using a DASCard-1003 or if you are using a single channel on a DASCard-1001 or DASCard-1002, you can specify a count value between 71 and 655,350 (7.1 are using multiple channels on a DASCard-1001 or DASCard-1002, you can specify a count value between 294 and 655,350 (29.4 between conversions).
Use the following formula to determine the number of clock ticks to specify:
µs. For example, if you specify 9,876 clock ticks, the
µs.
µs to 65.54 ms between conversions). If you
µs to 65.54 ms
Number of clock ticks
10 000 000,,
------------------------------------= conversion rate
For example, if you want a conversion rate of 1 ksamples/s, specify 10,000 clock ticks, as shown in the following equation:
10 000 000,,
----------------------------- -10000,= 1 000,
The conversion rate is the rate at which the analog-to-digital converter (ADC) initiates conversions; it does not take into account the number of channels you are using. For example, if you are using five channels and want a conversion rate of 1 ksamples/second per channel, specify 2,000 clock ticks, as shown in the following equation:
10 000 000,,

----------------------------- -

1 000,
2-16 Available Operations
5÷ 2 000,=
Loading...
+ 179 hidden pages