Text preview for : 24469A(ASO_TC).pdf part of Keithley 24469A(ASO TC) Keithley Misc 24469A(ASO_TC).pdf



Back to : 24469A(ASO_TC).pdf | Home

ASO-TC
User's Guide




Revision A
Plimxl June. 1993
Part No. 24469
0 Keithley Data Acquisition 1993
WARNING
Keithley Data Acquisition assumes no liability for damages
consequent to the use of this Product. This Product is not designed
with components of a level of reliability that is suitable for use in
life support or critical applications.




The information contained in this manual is believed to he accurate and reliable.
However, Keithley Data Acquisition assumesno responsihilit,y for its use; nor for any
infringements or patents or other rights of third parties that may result from its use.
No license is granted by implication or olhetwise under any patent rights of Keithley
Data Acquisition.


Keithley Data Acquisition does not wnrrnnr that the Product will meet the Customer's
requirements or will operate in the combinations which may he selected for use by Ihe
Customer or that the operation of the Program will he uninterrupted or error free or
that all Program defects will he corrected.


Keithley Data Acquisition does not and cannot wxrant the performance or results thar
may he obtained hy using the Program. Accordingly, the Program and its
documentation are sold "as is" without warranty as to their performance
merchantability, or fimess for any particular purpose. The entire risk as to the results
and performruxe of the program is assumed hy you.


All brand and product names mentioned in this manual are trademarks or registered
lrademarks of their respective companies.


Reproduction or adaptation of any part of this documentation beyond that pemiitted
hy Section I I7 of the 1976 United States Copyright Act without permission of
Keithley Data Acquisition is unlawful.




Keithley Data Acquisition - 440 Myles Standish Blvd. - Taunton, MA 02780
Telephone: (508) 8X0-3000 - Fax: (508) 8X0-0179
Contents

Chapter 1 Introduction ...,........ .... . . . . . . 1
I.1 About the ASO-TC ...... I
1.2 Prerequisites ...... 2
1.3 Getting help ...... 2
1.4 Installing the AS0 for DOS ...... 2
1.5 Installing the AS0 for Windows ...... 4



Chapter 2 The Function Call Driver ......, .......... 7
2. I Awilahle operations ............. I
2.2 Overview of programming with
the Function Call Driver ............ I?
2.3 Board/Driver initialization tasks ............ I3
2.4 Operation-specific programming tasks ............ I4
2.5 Language-specific progranming notes ............ 21



Chapter 3 Functions ............................. 43
3.1 Functional grouping .................................. 43
3.2 Function reference ................................... 47



Appendix A Function Call Driver error messages . . . . . , . . 85
A.1 Error Codes XS
A.2 Error Conditions 99
Introduction 1

1.1 About the ASO-TC
The ASO-TC is the Advanced Soliwarc Option (ASO) for the DAS-TC analog
input hoard. The AS0 includes a set of soliwarc components that you can USC.
in conjunction with a programming language. to crate application progrxns
that execute the operations available on the DAS-TC.

The primaty component of the AS0 is the Function Call Driver. This driver
provides your application program with high-level access to the acquisition and
control operations available on the DAS-TC. The AS0 :IISOincludes suppon
files, example programs, a configuration utility, antI a data togging utility.
For information on the contiguratiori and data logging utilities. refer to the
DAS-TC User's Guide.

The Function Call Driver enahles your program to define and execute txzml
operations hy using calls to driver-provided fimctiolls. For example. your
program can call the driver-provided K-ADRead function to execute ;Lsinglc-
point. A/D input operation.

The AS0 includes several different veaions of the Function C;dI Driver. The
.LIB and .TPU versions are prnvided for DOS application development in `C'
and Pascal languages. The Dynamic Link Library (DLL) is provided for
Windows application development.

The AS0 and this manual provide the necessary tools, example programs
and information to develop Function Call Driver prr,grilms in the following
languages:

. Borland C/C++ (version 2.0 and higher)



Chapter I - Introduction 1
. Borland Turbo Pascal (version 6.0)
* Borland Turbo Pascal for Windows (version I .O)
* Microsoft C (version 5. I and ahove)
* Microsoft C++ (version 7.0)
* Microsoft Quick C for Windows (version I .O)
. Microsoft Visual Basic for Windows (version I .O and higher)

Note If you are using :I version of Turbo Pascal higher 111x1
version 6.0, see section
2.5 for the procedure required to make a Turho Pascal unit compuihle with
your version.

1.2 Prerequisites
The AS0 is designed exclusively for use with the DAS-TC. This manual
assumesthat you understand die information presented in the DA.!?-TC Uxr's
Guidr. Addiliomdly, you must complete the hoard installation and
configurat,ion procedures oullined in the DAS-TC User's Guide before you
attempt,rmy of the procedures described in this manual.

The fundamental goal of this manurtl is (0 provide you with the informalinn
you need Lo write DAS-TC applicmion progmms lhal use die AS0 driver. II is
recommended that you proceed through this manual according to the sequcncc
suggested hy the rahle of conlents; this will minimize the amounl of time and
effort required to develop your AS0 applicalion programs for the DAS-TC.

1.3 Getting help
The following resources provide infommlion ahout using the ASO:
. this manual
. Ihe LIAS-TC User's Guide
. the AS0 example programs (these are copied to your system's hard disk
during the inslallrrtion procedure)
. the documentation for the programming language you are using

Call our Applications Engineering Department if you need additional
assistance.An applications engineer will help you diagnose and solve you,
problem over Ihe telephone.




2 ASO-TC User's Guide - Rev. A
r



Keithley Data Acquisition
Applications Engineering
508-880-3000
Monday - Friday, 8 A.M. - 7 P.M.




ASO package Version
Invoice/Order #


DAS-TC Serial #
Base address serting


Computer MklllUfXXUlW
CPU type xoxx 2X6 3X6 4X6 ort1cr
Clock speed (MHz) X I2 20 25 33 Olhcr
Math co-processor'! Yes No
Amount of RAM
Video system CGA Hcrculcs EGA VGA


Compiler Language
Manufacrurer
Version
1.4 Installing the AS0 for DOS
To code AS0 applidons progruns in a DOS-based language. land the
sofiwarc using the ASO-DOS distribution diskettes.

The tiles on the ASO-DOS distribution diskettes are in compressed formar.
You must use the installation program included on the diskettes 1o install the
AS0 sotburc. Since the aggregate size of the expanded AS0 files is
approximately 1.5 MB, check Ihat there is at lea,,r this much space available on
your PC's hard disk before you attempt to install the ASO.

Perform the following procedure to install the AS0 software (nole Ihat it is
;~ssumed the floppy drive is designaled u drive A):
that
I. Make a hack-up copy of the dislrihution diskette(s).
2. Insert ASO-DOS diskette #I into the lloppy drive
3. Type Ihe following comnmmls at the DOS prompt:
A: [Enter]
install [Enter]

The imtallation program prompts you for your insl,alla~ionpreferences,
including the name of the subdirectory int,o which the ASO-DOS files arc
copied. The installation progr;un expands the tiles on the AS0 diskette(s) and
copies them inter the ASO-TC subdirectory you specilied; refer to the lile
FILESIXX in your ASO-TC suhtlireclory for the names and descriplions of
these files.

1.5 Installing the AS0 for Windows
To code AS0 applications progrruns in a Windows-hued language, load rhc
software using the ASO-Windows distribution diskettes.

The files on Ihe ASO-Windows diskette are in compressed format. You must
use lhe serup progmm included on rhe diskette to install the software. Since
the aggregate size of the expanded files is approximately 2 MB, check lhiu
there is at least lhis much space available on your PC's hard disk hefbre you
attempt to install Ihe tiles.

Perfmm the following procedure 10 install the Windows-hased software
(assume thal the floppy drive is designated as drive A):
I. M&e a hack-up copy of the ASO-Windows diskette.
2. Sun Windows.
3. Insert the ASO-Windows diskelte into Ihe lloppy drive.
4. From the Program Manager menu, choose File then Run....
5. AT rhe Command Line t,ype A : \ SETUP. EXE




4 ASO-TC User's Guide - Rev. A
The setup progrrun prompts you for your instnllation preferences, including the
name of the subdirectory into which the ASO-Windows files we copied. If you
press Continue after you type in the p:~thniune.the setup program expands the
files and copies them into the ASO-TC subdirectory you speciticd; refer trl the
file FlLES.MJC in your ASO-TC subdirectory for rhe names and descriptions 01
these tiles.

The instdlatitrn process also creates a DAS-TC icon. This icon includes ;L C
eXal@e program, the WI)ASTCCF.EXE cOllfigUratiw1 utility, the dritdtrgger
utility, and RLESMJC. The configuration utility antI the dntalogger are
descrihcd in the DAS-TC Usrr Guide.




Chapter I - Introduction 5
The Function Call Driver 2

2.1 Available operations
The ASO-TC provides you with two types of analog-to-digital (A/D) input
operations:
* Single-call
* Frame-based

The following subsections describe these operations in mom detail

Both types of operations are implemented with functions, to which you pass
parameters. As with any function, you declare the corresponding arguments
hefore making the call.

Single-call A/D Input In a sirqle-cdl A/D input operation, you mad an analog input value using a
operatlons single call to a titnction. Analog-to-Digital conversion is performed
automatically.

You specify the attributes of the operation, such as the hoard that executes the
operation, the channel from which to read data, and the buffer in which to
store the data, as arguments to the function. The data is returned as a single
voltage or temperature value in cngineeting units.

Note The Function Call Driver reads the contiguration lile to determine the gain;
therefore. the gain parameter is ignored.

Use the K-ADRead function to read a single analog input value from a
specitied analog input channel.




Chapter 2 - The Function Call Driver 7
The DASTC-GETCJC function is a special-purpose single-call hmction for
reading the value of the CJC (Cold Junction Compensation) channel. You cxn
use the resulting value to correct a temperature reading in cases where you
want to perform your own linearization.

It" you wish, you can use K-ADRead or DASTC-GETCJC with software
looping to acquire more than one value from one or more channels. Typically,
when you are acquiring more than one value you may want to exercise more
control over the data transfer than is possible with single-call operations. In
such caes, use a frame-based operation, described next.

Frame-based A/D Input A frame-based input operadon is nornndly used to sample more than one value
operatlons from one or more channels. In the case of the DAS-TC, the data returned
consists of as many voltage or temperature values as there are analog input
samples. The values we returned in engineering units.

A frame-hased operation uses a single data structure called a frme to
represent the controllable attributes of the operation for a particular hoard. You
request a frame hy calling the function, K-ADFrame.

A frame-based operation is realized :ISa sequence of function calls. At a
minimurn, a frame-hased sequenceincludes functions that nnmage and set
frame elements, followed hy a function that performs the actual transfer 01
values.

The controllable attributes of the operation, such as die start channel, stop
channel, and number of wnples, arc known as frame &m~ws. The follrrwing
table lists the frame elements awilahle for the ASO-TC and the corresponding
function used to set each element. Refer to the appropriat,e function descripl,ion
in Section 3.2 for the valid settings of a frame's elements.




8 ASO-TC User's Guide - Rev. A
Element Function Page
Start/Stop Cliannel K-SetStartStopChn x2
I I I
I
Chrumel-Gain Array
1 K~FonnntClmGArv 1 I 57 II
K_Rcs~o~cCI~GA~ 15
I Address I
I 1 K SetClmGArv 1 7!, 11


le
Number of Samples


K.JntAlloc 69
K-SetBuf 76

Data Buffer Address K-SetButL 17

I K-SetButR I 7x



I Buffering Mode
K-SetContRun
K ClrContRun
XI
5s I



One fr;lme corresponds to one set of element vdues. Once you set the frame`s
elements. you can pass all of the settings to the function Itiat sliww the A/D
operation, using only the franw hrmlle. which idcntilies the frame (;ud the
hoard from which you called K-GetADFrame).

lf several operations acquiring data from a particular howd use the s;une
element settings, they can pass the same frame handle. Aftcwartls. you should
rele&se the frame by calling K-FreeFrame. The Function Call Driver allows
you to request up to eight frames, regardless of which hoard you arc using
when you call K-CktADFrame. For example. you could use live francs for
hoard I and three frames for hoard 2. Similarly, you could use eight fnlmes for
hoard I: however, no frxnes would he available for hoard 2 ill this exanlple.

Note Each of the programming languages is supported hy 2~ that contains a
tile
definition of the FRAMEH variahle type. Therefore, you must tleclarc ;iII
frame handles to he of this type.




Chapter 2 - The Function Cd1 Driver 9
Operation Modes
For the DAS-TC, frame-hased A/D operations ;Lreavailahlc in two modes:
* Sytlcllrotlous
. Interrupt

In Synchronous mode, the frame-hased sequence passescontrol to the Function
Call Driver, which acquires and converts data in the foreground. After the
specilied number of samples is acquired, the driver retutns control to lhe
application program. This operation mode is easier to program than interrupt
mode operations. It should not be used if some procedure requires a block of
data before executing and/or needs to monitor or contt'd the transfer. USCthe
K,SyncStart function to start a frame&used operation in synchronous mode.

Inlerrupt mode allows the hoard to acquire and convert data in the hackground
while the application program retains control. The DAS-TC interrupts the
application when an acquired block of samples is ready to he transferred to a
user-defined buffer. The Function Call Driver's interrupt handler gets control
just long enough to complete a block transfer; this period is sufficiently hricf
as to he imperceptible. Interrupt mode is useful when monitoring and contrd
over the tramfer is desired, concurrent, processing (without loss of data
integrily) is desired. or when blocks of acquired data must be partially
processed hefore the requested t,ransfcr is completed. Use the K-IntStart
function to starl a frame-based operation in interrupi mode.

Note On the DAS-TC, data is transferred in blocks. where block size = the numhcr
of channels specilied. Suppose, for example, you have requested 43 samples
using ten channels. The Function Cdl Driver actudly acquires 50 values in
tive blocks of ten samples each. The first 40 values are transferred from the
first four blocks that have been acquired, and the remaining three samples are
transferred from the fifth acquired block of ten samples.

Input Buffers
The Function Call Dtiver stores acquired samples in a buffer that you deline
with one of two methods:
* Locally delined (user-delined)
. Dynamically allocated

Once you have delined a buffer hy one of the two methods, USC K - SetRuf
ii
call to pass the buffer Wlress to lhe Function Call Driver.




10 ASO-TC User's Guide - Rev. A
You must define a local huffer as an array hefore you call K-SetBuf. You can
also use a local buffer for more permanent storage hy using K-MoveDataHuf
to move acquired data into your local buffer.

Use K-IntAlloc to dynamically allocate memory outside of your program arca
for later release with K-IntFree. If you are running in Windows standard
mode and transferring data using interrupts, you must use a dynimtically
allocated huffer to receive the acquired data, since your program's memory
pointers may shift.

You can USC combination of local and dynamically allocated huffem fur
a
storing blocks of acquired samples. The function. K-MoveDataBuf, provides a
convenient method, particularly in Visual Basic, for moving acquired data from
a dynamically allocated huffer into a local buffer.

Buffering Mode
You can specify either SINGLE-CYCLE or CONTINUOUS huffcring mode for
interrupt operations. In Single-Cycle mode, the spcciticd munher of samples is
stored in the huffer and the operation stops automatically. Use the
K-ClrContRun function to specify Single-Cycle buffering mode.

In Continuous mode, the hoard keeps acquiring the same number of new
values, placing the data in the huffer until it receives the stop function.
K-IntStop. The transfer index and huffcr pointers are reset hefore another
transfer cycle is initiated. and acquired values in the huffcr are overwritten
Use the K-SetContRun function to specify Continuous buffering mode.
If you do not specify Continous buffering mode, the DAS-TC defaults to
Single-Cycle mode.

Note If you are acquiring data using interrupts and Continuous huffcring. as soon as
the last,block of samples is transferred,
. the transfer count and huffcr pointer are reset te zero.
. K-IntStatus returns zero instead of the requested satnplc size in the inrle\-
parameter, and
. the driver hegins to overwrite your buffer's data.

If your application requires consecutive blocks of data, you shuuld hcgin
processing your huffer Oefore your huffer is full, using K-IntStatus tn
determine how many blocks have heen transferred (this function's in&.r
parameter increments by the block size).




Chapter 2 - The Functinn Call Driver 11
2.2 Overview of programming with the Function Call Driver
The procedure to write a Function Call Driver program is as follows:
I. Define the application's requirements.
2. Write the program code.
3. Compile and link the program.

The subsections Ihat follow describe the details of each of thcsc st,eps.

Defining the Before you begin writing the program code, you should have a clear idea of'
application's the operations you expect your program to execute. Addidonally, you should
requirements determine the order in which these operations must he executed and the
characteristics (number of samples, start and stop channels, and so on) that
define each operation. You may find it helpful to review the list of availahlc
operations in Section 2. I and to hmwse through the short descriptions of the
Functions in Section 3. I.

Wrltlng the Several sources of information relate to this step:
program code
* Section 2.3 explains the initial programming tasks that all Function Call
Driver programs must execute
* Section 2.4 describes typical frame-hased sequencesof function calls
. Section 3.2 provides detailed information on individual fuunctions
* The AS0 includes several example source code tiles for Function Call
Driver programs. The FILES.IX)C in the ASO-DOS installation directory
file
lists and describes the example programs. The FILES.IX)C the ASO-
in
Windows installation directory lists and discribes the example programs
that run in Windows only.

Compiling and linking Reitir to Section 2.5 for compile and link instructions and other language-
the program specific considerations for each supported language.




12 ASO-TC User's Guide - Rev. A
2.3 Board/Driver initialization tasks
Every Function Call Driver program must execute the following progr:unming
tasks:
1. Identify a function/variable type definition file
The method to identify this file is language-specilic; reler to Section 2.5
for additional infomlation.
2. Declare/initialize program wriahles
3. Call DASTC DevOpen to initialize the driver
4. Call DASTC-GetDevHandle to initialize the hoard and get a device
handle for the hoard.

The tasks listed are the minimum tasks your progrxil must complete hcforc it
attempts to execute sly operation-spccilic tasks. Your application may require
additional hoard/driver initialization tasks. For example. if your program
requires access to two hoards. then it must call I)ASTC_(;etI)evHandle tilr
each hoard.

Note A device handle is a variable whose value identities an installed hoard. The
purpose of a device handle is to provide a mechanism through which the
Function Call Driver can access a hoard. A device handlc is also ;Lamvcnicnt
method for different function calls to reference ihe same hoard. Each twwd
must have n unique device handle.

Each of the programming languages is supported by ;I file that contains a
definition of the DDH (for DAS fhice Hrmdle) varinhle type: you should
declare all device handles to he of this type.




Chapter 2 - The Function Call Driver 13
Operation-specific programming tasks
After you perform the hoard/driver initialization tasks. perform the appropriate
openrtion-specil~ictasks, as follows:
. For Single-Call A/D Operations - The only operation-spccitic task required
is using the appropriate single-call A/D function (K-ADRead or
DASTC-GETCJC).
. For Frame-Bared A/D Operations - The operatiol~l-specilictasks required
for frame-hased A/D operations depend on whether you are using
synchronous or interrupt mode, whether you are using Stan and Stop
channels or Channel-Gain arrays, and whether you are using I~rcalhuffcrs
dynamically allocated buffers, or both. For the page number that
corresponds to the operation you want to perform. set the table shown
below.


I Operation
mode
Method of specifying
acquisition channels
Syncl1r"n0us Start/Stop clxumels I Local I IS I
I Sy"cllr"n"us / Slarl/St"p channels 1 Dynamic I `5 I
Syncllr"n"us Channel-Gain army I Local I I6 I
/ Synchronous I Channel-Gain array Dynamic I I6 I
Interrupt Start/Stop channels Local ' 17

Interrupt Start/Stop channels Dynamic I7
Interrupt start/stop ch:ulnels Both IX
I Interrupt I Cllannel-Gain array I Local ` / IX 1
I Interrupt I Channel-Gain array Dynamic I I9 I
I Intermpt I Chamu3-Gain anay I Both I 20 I
' Do not use this sequence if you are running in Windows standard mode

Note If you do no1 use the functions that set a frame`s elements, the Function Call
Driver defaults to the values that resulted fnmi frame inilialization.

You must pass the address of the buffer that is receiving the data, by calling
K-SetRuf, K-SetRufI,, or K-SetHufR. The choice of K-SetHuf. K-SetHufl,,
or K,SetBufR depends on the pr"granm~ing language and buffer type. See
Section 3.2 for more information on these functions. No error mcssagc occurs
if this function is no1 included; however, the frame element, BufAddr, h;~sii
default value of zero, and no samples arc rcturncd.




14 ASO-TC User's Guide - Rev. A
Synchronous, Start/Stop channels, local buffer only
Use this calling sequence tn perform a synchronous transfer, using Start/stop
channels and a local buffer only. Before calling the functions in the sequence.
define :Llocal buffer as ;m army of four-hyte elements.
I. Call K-GetADFrame to get the handle to :UI A/D frame.

2. Call K,SetRuf, K-SetRufL. or K-SetRufR to assign the huffcr xldrcss
previously ohtainetl to lhe Buffer Address element in the frame.

3 Call K-SetStartStopChn lo assign values IO the SIXT and Stnp Chrumcl
elements in the frame.

4. Call K-SyncStart tn start the operation. Data is stored in the I~x;~Ihuffer.

5. Call K-FreeFrame to return the franc tn the pool of available fmmcs
obtained. unless you are starting another sequence that uses the wne frame.


Synchronous Start/Stop channels, dynamically allocated
buffer only
Use this calling sequence to perform a synchronous transfer using Start/Stnp
channels and a dynamically allocated buffer only.

I. Call K-GetADFrame to get the handle to an A/D frame

2. Call K-IntAlloc tn allocate the huffcr into which the driver stnres the A/D
values outside of the program's memory area.

3 Call K,SetRuf, K-SetBufL. or K,SetRufR to assign the buffer :alrlress
previously ohtnined In the Buffer Address element in the frame.

4. Call K,SetStartStopChn to assign values to the Stwt and Stop Channel
elements in the frame.

.5 Call K-SyncStart to start the operation. Data is accessedvia the pnintcr
returned hy K-IntAlloc.

6. Call K-IntFree to deallocate the buffer,

I. Call K-FreeFrame IO return Ilie fmnte In rltc pool of available frames
obtained, unless you are starting annther sequence that uses IIIC same fmmc.




Chapter 2 The Function Call Driver 15
Synchronous, Channel-Gain array, local buffer only
Use tllis calling sequence to perfoml a synchronous lransfer using a Chaxnel-
Gain array and a local buffer only. Before calling the timctions in the
sequence, define a local huffcr as an array of four-hyte elements.
I. Call K-GetADFrame to ger the handle to an A/D frame.

2. Define and assign values to a Channel-Gain array.

3. Call K,SetRuf, K-SetRufL. or K-SetRufR to assign the buffer address
previously declared to the Buffer Address elemenl in Ihe frame.

4. CalI K-SetChnGAry to assign the Channel-Gain array IO Ihe Channel-Gain
Array Address elemenr in the frame.

5
_ Call K,SyncStart to start the operation. Data is stored in lhc local buffer.

6. Call K-FreeFrame to return the frame to ke pool of available frames


Synchronous, Channel-Gain array, dynamically allocated
buffer only
USCThiscalling sequence I0 perform a synchrontrus transfer using a Channcl-
Gain array and a local huffer only.

1. Call K-GetADFrame to get the handle to an A/D frame.

2. Define and assign values 1o a Channel-Cain array.

3. Call K-IntAlloc to allocate the buffer into which the driver stores the A/D
values outside of the program's memory area.

4. Call K,SetBuf. K-SetRufl,, or K,SetRufR to assign the address of the hul'kr
previously declared 10 Ihe Buffer Address elemenl in the frame.

5
_. Call K-SetChnGAry tr, assign rhc Channel-Gain array to the Channel-Gain
Array Address element in the frame.

6. Call K-SyncStart to start the operation. Data is accessedvia the pointer
returned hy K-IntAlloc.

7. Call K-IntFree to deallocate Ihe buffer.

8. Call K-FreeFrame to ret,um lhe frame 10 rhe pool of availahlc frames, unless
you are starting another sequence that uses the same frame.




16 ASO-TC User's Guide - Rev. A
Interrupt, Start/Stop channels, local buffer only
Use this calling sequence to perform an intermpt transfer using Start/Stop
channels and a local buffer only. Before calling the functions in the sequence.
define a local huffcr as an array of four-byte elements.

I. Call K-GetADFrame to get the handle to an A/D fr:une

2. Call K-SetRuf, K-SetBufL. or K-SetRufR to assign the huffcr address
previously declared to the Buffer Address element in the frarnc.

3. Call K,FetStartStopChn to assign values to the Start and Stop Channel
elements in the frame associated with the fnunc handle previously ohrained.

4. Call K-IntStart to start the operation

5 Call K-IntStatus to monitor the status of the operation. When cwnpletion is
detected, the data is available in the local huffcr.

6. Call K-FreeFrame to return the fnunc tn the pool of nvailahlc frames. unless
you are starting another sequence that uses the same frame.


Interrupt, Start/Stop channels, dynamically allocated buffer
only
Use this calling sequence to perform an interrupt transfer using Start/Stop
channels and a dynamically allocated huffcr only.

I. Call K-GetADFrame to get the handle to an A/D frame.

2. Call K-IntAlloc to allocate a buffer into which the driver stores the A/D
values outside of the program's memory area.

3. Call K,SetRuf, K-SetBufL, or K-SetBufR to assign the huffer address
previously declared to the Buffer Address element in the frame.

4. Call K,SetStartStopChn to assign values to the Stan and StropChannel
elenients in the frame associated with the frame handle previously obtained.

5. Call K-IntStart to start the operation.

6. Call K-InkStatus to monitor the status of the operation. When cwnpletion is
detected, the data is accessedvia the pointer returned hy K-IntAlloc.

I. Call K-IntFree to deallocate the buffer.



Chapter 2 - The Function Call Driver 17
8 Call K-FreeFrame to return the frame to the pool of available frames, unless
you are starting another sequencethat uses the same frame.


Interrupt, Start/Stop channels, dynamically allocated and local
buffers
Use this calling sequence to perform an interrupt transfer using Start/Stop
cltam~elsand hoth huffcrs. Before calling the functions in the sequence,dctine
a local huffer as an array of four-byte elements.

I. Call K-GetADFrame te get the handle to an A/D fraane.

2. Call K-IntAlloc to allocate a buffer into which the driver stores the A/D
values outside of me program's memory area.

3. Call K-SetBuf, K-SetBufL. or K-SetBufR tn assign the huffcr address
previously declared to the Buffer Address element in the frante.

4. Call K-SetStartStopChn to assign values to the Srart and Stop Chamtel
elements in the frame associated with me frame handle previously ohtained.

5. Call K-IntStart to start the operation

6. Call K-IntStatns to monitor the status of the operation. When completion is
detected, the data is accessedvia the pointer returned by K-IntAlloc.

I. Call K-MoveDataBuf to transfer the acquired data from a huffer allocated hy
K-IntAlloc to the user-defned array.

x. Call K-IntFree to deallocate the huffcr

9. Call K-FreeFrame IO return the frame to the pool of available frames, unless
you arc starting another sequence that uses the same frame.


Interrupt, Channel-Gain array, local buffer only
Use this calling sequence Lo perform :m interrupt transfer using a Channel-Gain
array and a local buffer only. Before calling the functions in the sequence,
deline a local huffcr as an array of four-byte elements.

I. Call K-GetADFrame to get the handle to an A/D frame, unless you arc
starting another sequence that uses the same frame.

2. Detine and assign values tn a Channel-Gain array.




18 ASO-TC User's Guide - Rev. A
3. Call K-SetRuf, K-SetBuf'I,, or K-SetBuf'R to assign the address of the huffcr
previously declared to the Buffer Address element in the frame.

4. Call K,SetChnC.Ary to assign rhc Channel-Gain array previously nhtained to
the Channel-Gain Array Address element in the frame.

5. Call K-IntStart to start the operation.

6. Call K-IntStatus to monitor the status of the operation. When completion is
detected, data is available in the local huffcr.

I. Call K-FreeFrame to rchmi the frame 10 the pool of available frames. unless
you are starling a another sequence that uses the same frame.


Interrupt, Channel-Gain array, dynamically allocated buffer
only
Use this calling sequence lo perform an intermpt transfer using a Channel-Gain
array and a dynamically allocated buffer only.

I. Call K-GetADFrame tn get the handle tn an A/D frame.

2. Deline and assign values to a Channel-Gain array

3. Call K-IntAllac to allocate Ihe buffer into which the driver stores the A/D
values outside of the program's memory area.

4. Call K,SetRuf, K-SetHufL, or K-SetBufR to assign the address OTthe hurfer
previously declared to the Buffer Address element in the frame.

5. Call K,SetChnGAry to &ssign the Channel-Gain array previously ohtaincd mu
the Channel-Gain Array Address element in the frame.

6. Call K-IntStart to start the operation

I. Call K-IntStatus to monitor the status of the operation. When completion is
detected, the data is accessedvia the pointer returned hy K-IntAlloc.

8. Call K-IntFree to deallocate the buffer.

9. Call K-FreeFrame to return the frame to the pool of available frames. unless
you are starting a sequence that uses the same frame.




Chapter 2 - The Function Call Driver 19
Interrupt, Channel-Gain array, dynamically allocated and local
buffers
Use this calling sequence to perform an interrupt transfer using a channel-Gain
array and both a local and a dynamically allocated buffer. Before calling lhc
funcdons in the sequence,detine a local buffer as im array.
I. Call K-GetADFrrme to gel the handle to an A/D frame.

2. Define and assign values to a Chatmel-Gain array.

3. Call K-IntAlloc to allocate a buffer into which the driver stores the A/D
values outside of the program's memory area.

4. Call K-Set&If. K-SetBufL, or K-SetBufR to assign the hul'fer address
previously declared to the Buffer Address element in lhe frame.

5 Call K,SetChnGAry to assign the channel-gain array previously obtained to
the Channel-Gain Army Address clement in the frame.

6. Call K-IntStart to start the operation

I. Call K-IntStatus to monitor the status of the operation. When completion is
detected, the data is accessedvia the pointer returned hy K-IntAlloc.

8. Call K-MoveDataBuf to transfer data from a buffer you have allocaled by
K-IntAlloc to the array.

9. Call K-IntFree to deallocate the buffer

IO. Call K-FreeFrame to return the frame to the pool of available frames.




20 ASO-TC User's Guide - Rev. A
2.5 Language-specific programming notes
This sectinn provides specific programming guidelines for each of the
supported liuiguages. Additional programming infomlation is available in the
AS0 example progrzuns. Rcfcr to the FILESDOC lile for names ;1nd
descriptions of the AS0 cxamplc programs.

Note The example progrruns in this section are no1 actual programs hut arc
fragments that arc designed to illustrate iul interrupt-mode A/D input sequence
that uses a Channel-Gain array.

Borland C/C++ and Microsoft C/C++
Related Flies DASTCLIB
DASRFACE.LIB
USERPR0T.H
USERPROT,BCP

Compile and Link Rorland C:
InstructIons BCC -ml fi1ename.c dastc.lib dasrface.lib

Borland C++
If you want to compile your prtrgram as a Borlruid C++ progr:un.
1. Use the supplied tile USERPROT,BCP instead of USERPR0T.H
2. Specify the C++ compilation in one of the following two ways:
a. Specify .CPP iis the extcrision for your source tile. or
h. USCthe BCC -1' command line switch.

Microsoft C/C++:
CL /AL /c fi1ename.c
LINK filename ,,,DASTC+DASRFACE;

Code example This example executes an interrupt-mode A/D sequence using a Channct-Cain
array.
,**********~************~**.****~*~**~***~~~**.~**~*.*.*~.*j
/* CEXAMP2.C DRSTC` f,
/* * ,'
,* 'C' - Interrupt Mode A/D transfer f/
/* with Channel/Gain Array t
/* 'i
/* To create ~11 EXE using Microsoft C: f,
/* f.
/* CL /c CEXAMP2.C (use /Tp /* LINK CEXAMPZ,,,DASTC+DASRFACE; *i
/* +i
1' To create an EXE using Borland C++ (Ver 2.0 dnd up!: .I
/* *,




Chapter 2 - The Function Call Driver 21
/* BCC -ml -c CEXAMP2.C dastc.lib dasrface.11b *I
/* */
,***************"*******************~*************~~~*******,




//use this include file statement for MS C
#include "userpr0t.h"

//use this include file statement for MS C++
/*
extern "C" (
#include "userprot.h"
1
*/

//use this include file for Borland C++ and use -P switc!h
//for C++ compile
/*
extern "C" (
#include "userprot.bcp"
)
*/

#include -:stdio.h,
#define Samples 16
DWORD LocnlBuffer[Samples];

GainChanTable ChanGainArray =
(
16,
o,o,
2,o.
4,o.
6.0.
8.0.
lO,O,
12,0,
14.0,
l,O,
3,0,
5.0.
7.0.
9.0,
11.0,
13.0,
15,O
I :

main0




22 ASO-TC User's Guide - Rev. A
I
DDH DASTC-brd0 ; // handle for board 0
FRAMEH AD-brd0 ; // frame for board 0 A/D operations

long Index;
short BoardNumber, Err, Status, m;
char NumberOfBoards;
float C.JC=O:

,,----------------------------------------.~.-~-........~~..
// init~ialize board hardware and drivel-

printf("\n");
printf("Initializiny the board - - - PLEASE waitin');

if (( Err = DASTC-DevOpen( "DASTC.CFG". &Numbel-OfBoalds iI
!=O )
(
printf( ' Error %x on Device open ', Err 1 ;
return Err- ;
1

,,~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-~-----------------~~~.~.~.
// The DEVICE Handle must be obtained in order to war-k wirh
// a specific board
// It is used subsequently to obtain FRAME Handles

BoardNumber = 0;
if ( ( Err = DASTC_GetDevHandle( BoardNumber, LDASTCCbrdO 1
1 !=O)
(
printf( "Error getting Devic!e Handle" I;
return 1 ;
1

if ( ( Err=DASTC-GETCJC(Bon1-dNumber, LCJC) 1 != 0 !
(
printf( "Error getting CJC Temperature" 1;
return 1 ;
I

printf("C.JC Temperature = %f\n", CJC);

,,------------------------------------.--..--..-.-.--~~~~--~
// The FRAME Handle must be obtained using the DEVICE Handle
// in order to make each type of function call,
// in this case, Analog Input.
// The variable is suffixed with a "0" to reference board 0.

if ( (err = K-GetADFrame( DASTC-brd0, GADpb~dO I I != 0 1




Chapter 2 - The Function Call Driver 23
,
printf ( "Error gett.ing Frame Handle" 1;
return 1 ;
1

,,------------------------------------------~---~--~~-.-..--
// The FRAME Handle is now used in Analog Input czalls.

printf("\n\nInterrupt Mode with Chan Gain Array\n\n\n" 1;

if ( ( Err = K-SetBuf( AD-brd0, LocalBuffer, Samples ) ) !=
0 1
(
printf("Error %x Occ!urred during K-SetBuf call. .\I>',
Err);
retLlrn 1;
I

if ( ( Err = K-SetChnGAry( AD.,brdO, &ChanGainArray) ) !=O
1
(
PrintfVError %x Occurred during K-SetChnGAry call.
.\n", Err);
return I;
)

// u-comment this block of code for continuous run
//printf("Continuous Run Selected.\n");
//if ( (Err = K-SetContRun( AD_brdO ) ) != 0 1
// (
// Printf("Error %x Occurred duriny K_SetContinRun call.
//.\n", Err);
// return 1;
// 1

if ( i Err = K-IntStart( AD-brd0 ) ) !=O)
(
Printf("Error %x Occurred during K-IntStart call. .\n",
Err);
return 1;
1


printf("TYPE any key to stop\n\n");
do
(
if ( ( Err = K-IntStatus( AD-brd0 , &Status, &Index ) )
!= 0 )
(
Printf("Error %x Occurred during K_IntStatus call.
.\P', Err);




24 ASO-TC User's Guide - Rev. A
printf("Conversions completed= %tid\r", Index);
1
while ( (Status & 1) && !-kbhit0 1;

if ( ( Err = K-IntStop( AD-brd0 , &Status, &Index 1 1 != 0
(
Printf("Error %x Occurred during K_IntStop call. .'ln*
Err);
return 1;
I

printf("\n");

for Cm = 0; m i Samples ; m++)
printf("Sample No. %d %ld\n", mcl, LocnlBuffel~[mJ,;

printf("\n");

,,~~~~~~~~~~~~~~~~~~~---------~~~~~.....~.~~~~~-~-----------
// Release memory used by the frame.
if ( ( Err = K-FreeFrame( AD_brdO 1 , != 0,
(
PrintfVError %x Occurred during K-FreeFrame call.
.\W, Err) ;
return 1:
1




Borland Turbo Pascal
Related Files DASTCTPU

Complle and Link TPC/$E+ /$N+ filename.pas
instructions

In the Turhn environment




Chapter 2 - The Function Call Driver 25
the exmple program shown below, you must create a TPU (Turbo Pascal unit)
tile that is comprttihle with your version. In FILESDOC you will find ;I
reference to DASTCTPU.BAT. Rml this hatch file in order to crcatc the
compatible TPU. The Ale, DASTCTPU.BAT contains the DOS command:

tpc DASTC.PAS

This tile also includes the sources for the TPU, and a description of this
procedure.

Code example This example executes :m interrupt-mode A/D sequence using a Channel-&tin
array.

Program tpexamp2;
(
Interrupt Mode A/D transfer with Channel/Gain Array

For this example ONLY;
the configuration file must speclify FLOATING POINT.
)


uses crt, DASTC;


GainChanTable = Record
num-of-codes : Integer;
queue : Array[0..31] of Byte;
end;

const
ChanGainArray : GainChanTable = (
num_of_codes : (16):
queue : (O,O,
1.0.
2,0,
3.0.
4.0.
5,0,
6,0,
7.0.
8.0.
9.0.
10.0,
11,O.
12,0,
13.0,
14,0,
15.0)




26 ASO-TC User's Guide - Rev. A
"Fir
BufPtr : ^1nteger;
BoardNumber, m : Integer;
NumberOfBoards : Inteyel- ;
status, Ertn : Word;
Samples, Index, DASTC-brd0, AD_brdO : Longint:
ConfiyFile : Striny;
DataBuffer : Array[0..20] of Real;
CJC : Real:

begin

(-----~---~--------~~~~.~~~~~~--------...~..~~~~---------
initialize board hardware and driver 1

BufPtr := @DataBuffer[O];
ConfigFile := 'DASTC.CFG' + #0 ;

Ertn := DASTC-DevOpen( ConfigFile[l], NumberOfBoards i:

if Ertn .:> 0 then
begin
writeln( 'Error ', Ertn, 'on Devicr open' 1;
Halt(l);
end:

(~-~--~-~--~------------------~~~.~~~~~.~~~~~-~~~-~~~----.-~

The DEVICE Handle must be obtained in order to work with a
specific board It is used subsequently to obtain FRAME
Handles )

BoardNumber := 0;
Ertn := DASTC-GetDevHandle( BoardNumbrl, DASTC-brd0 );

if Ertn -:~I 0 then
begin
writeln( 'Error getting Device Handle' );
Halt(l);
end;




Ertn := DASTC-GETCJC( BoardNumber, CJC );

if Ert~n -:r'. 0 then
begin
writeln( 'Error getting CJC Temperature' 1:
Halt(l);




Chapter 2 - The Function Call Driver 27
writeln( 'CJC Temperatur-e = ', CJC 1 ;

(-~------------------------------------------~~-~-~-.----~~~-


The FRAME Handle must be obtained using the DEVICE Handle
in order to make each type of function call, in this case,
Analog Input. The variable is suffixed with a "0' Tao
reference board 0. )

Ertn := K_GetADFrame( DASTC-brd0, AD-brd0 1 ;

if Ertn in> 0 then
begin
writeln( 'Error getting Frame Handle' 1;
Halt(l);
end;


(----------~-----------------------------------..-.


The FRAME Handle is now used in Analog Input calls. 1

writeln( 'Interrupts Mode with Chan Gain Array' 1;

samples := 20;
Ertri := I<-SetBuf( AD-brd0, Longint(BufPtr), Samples ) ;

if Ertn <~> 0 then
begin
writeln( 'Error in I<-SetBuf call 1;
Halt(l);
end;

Ertn := K-SetChnGAry( AD-&do, ChanGainArray.num_of_c!ud-ies )


if Ertn .r> 0 then
begin
writrln( 'Error in I<-SetChnGAry czall );
Halt(l1;
end:

Ertn := K-IntStart( AD-brd0 , ;

if Ertn <> 0 then
begin
writeln( 'Error in K-IntStart call' );
Halt(l);
end;




28 ASO-TC User's Guide - Rev. A
repeat

Ertn := K-IntStatus( AD-brd0 , Status. Index ! ;

if Ertn c:. 0 then