Tektronix ASO for DAS-TC/DAS-TC/B Users Guide

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 assumes no 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
I.1
1.2
1.3
1.4
1.5
Chapter 2
2. I
2.2
2.3
2.4
2.5
Chapter 3
3.1
3.2
Introduction . . . , . . . . . . . .
About the ASO-TC Prerequisites Getting help Installing the AS0 for DOS Installing the AS0 for Windows
....
......
......
......
......
......
The Function Call Driver . . . . . . ,
Awilahle operations Overview of programming with the Function Call Driver Board/Driver initialization tasks Operation-specific programming tasks Language-specific progranming notes
Functions
Functional grouping Function reference
.............................
..................................
...................................
. . .
. .
..........
.............
............
............
............
............
. 1
I
2 2 2 4
7
I
I? I3 I4
21
43
43 47
Appendix A Function Call Driver error messages . . . . . , . . 85
A.1 Error Codes A.2
Error Conditions
XS
99
Introduction
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 :IISO includes 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 ;L singlc­point. A/D input operation.
1
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 assumes that you understand die information presented in the
Guidr.
Addiliomdly, you must complete the hoard installation and configurat,ion procedures oullined in the 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
DAS-TC User’s Guide
DA.!?-TC Uxr’s
before you
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
.
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
r
Keithley Data Acquisition
Applications Engineering
508-880-3000
Monday - Friday, 8
ASO package
DAS-TC Serial #
Computer
Version Invoice/Order #
Base address serting
MklllUfXXUlW CPU type Clock speed (MHz) Math co-processor’!
A.M. - 7 P.M.
xoxx 2X6 3X6 4X6 ort1cr X I2 20 25 33 Olhcr Yes No
Compiler
Amount of RAM Video system
Language Manufacrurer Version
CGA Hcrculcs EGA VGA
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 that the floppy drive is designaled u drive A):
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
The imtallation program prompts you for your insl,alla~ion preferences, 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
these files.
[Enter]
in your ASO-TC suhtlireclory for the names and descriplions of
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 descrihcd in the
RLESMJC.
The configuration utility antI the dntalogger are
DAS-TC Usrr Guide.
Chapter I - Introduction 5
Single-call operatlons
A/D
The Function Call Driver
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.
In a
Input
sirqle-cdl
single call to a titnction. Analog-to-Digital conversion is performed automatically.
2
A/D input operation, you mad an analog input value using a
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 :IS a sequence of function calls. At a
minimurn, a frame-hased sequence includes 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
I
Chrumel-Gain Array
I
Address
I
Number of Samples
Data Buffer Address
Buffering Mode
I
K-SetStartStopChn
I
1 K~FonnntClmGArv 1 57
K_Rcs~o~cCI~GA~ 15
1 K SetClmGArv 1 7!, 11
le
K.JntAlloc
K-SetBuf
K-SetButL
K-SetButR
I
K-SetContRun K ClrContRun
I
I
I
x2
69
76 17
7x
XI 5s
I
II
I
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 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~ tile that contains a
definition of the FRAMEH variahle type. Therefore, you must tleclarc ;iII
frame handles to he of this type.
hrmlle.
which idcntilies the frame (;ud the
Chapter 2 - The Function Cd1 Driver
9
Operation Modes
For the DAS-TC, frame-hased A/D operations ;Lre availahlc in two modes: * Sytlcllrotlous
.
Interrupt
In
Synchronous
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. USC the 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.
mode, the frame-hased sequence passes control to the Function
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 ii K SetRuf 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 a combination of local and dynamically allocated huffem fur 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 application’s requirements
Wrltlng the program code
Compiling and linking Reitir to Section 2.5 for compile and link instructions and other language-
the program specific considerations for each supported language.
Before you begin writing the program code, you should have a clear idea of’ the operations you expect your program to execute. Addidonally, you should 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.
Several sources of information relate to this step:
* Section 2.3 explains the initial programming tasks that all Function Call
Driver programs must execute
* Section 2.4 describes typical frame-hased sequences of 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 file in the ASO-DOS installation directory lists and describes the example programs. The FILES.IX)C in the ASO­Windows installation directory lists and discribes the example programs that run in Windows only.
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 ;L amvcnicnt 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~ic tasks, 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-specilic tasks 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~rcal huffcrs dynamically allocated buffers, or both. For the page number that corresponds to the operation you want to perform. set the table shown below.
Note
Operation
I
I Sy”cllr”n”us /
/ Synchronous I
I
I
’ Do not use this sequence if you are running in Windows standard mode 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.
mode
Syncl1r”n0us
Syncllr”n”us Channel-Gain army
Interrupt Interrupt Interrupt Interrupt Interrupt
Intermpt
I
Method of specifying
acquisition channels
Start/Stop clxumels Slarl/St”p channels 1 Dynamic
Channel-Gain array Start/Stop channels Local ’
Start/Stop channels Dynamic I7 start/stop ch:ulnels Both
Cllannel-Gain array I Local ‘ / IX 1
I
Channel-Gain array Dynamic
I
Chamu3-Gain anay
I
I
I
Dynamic
I
Local
Local
Both
I I I ‘5 I
I I
I I
I I
I I
IS
I6
I6
17
IX
I9
20
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. if this function is no1 included; however, the frame element, default value of zero, and no samples arc rcturncd.
14 ASO-TC User’s Guide - Rev. A
No error mcssagc occurs
BufAddr,
h;~s ii
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 :L local 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;~I huffer.
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 accessed via the pnintcr
.
returned hy K-IntAlloc.
6.
Call K-IntFree to deallocate the buffer, Call K-FreeFrame IO return Ilie fmnte In rltc pool of available frames
I.
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. Define and assign values to a Channel-Gain array.
2. Call K,SetRuf, K-SetRufL. or K-SetRufR to assign the buffer address
3. previously declared to the Buffer Address elemenl in Ihe frame.
4.
Cal I 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
USC This calling sequence I0 perform a synchrontrus transfer using a Channcl-
Gain array and a local huffer only.
Call K-GetADFrame to get the handle to an A/D frame.
1. Define and assign values 1o a Channel-Cain array.
2.
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 accessed via 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 Strop Channel elenients in the frame associated with the frame handle previously obtained.
Call K-IntStart to start the operation.
5.
6.
Call K-InkStatus to monitor the status of the operation. When cwnpletion is
detected, the data is accessed via the pointer returned hy K-IntAlloc.
Call K-IntFree to deallocate the buffer.
I.
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 sequence that 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~els and 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 accessed via 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 OT the 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 Call K-IntStatus to monitor the status of the operation. When completion is
I.
detected, the data is accessed via 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.
Call K-GetADFrrme to gel the handle to an A/D frame.
I.
2.
Define and assign values to a Chatmel-Gain array. Call K-IntAlloc to allocate a buffer into which the driver stores the A/D
3. 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.
Call K,SetChnGAry to assign the channel-gain array previously obtained to
5
the Channel-Gain Army Address clement in the frame. Call K-IntStart to start the operation
6.
Call K-IntStatus to monitor the status of the operation. When completion is
I.
detected, the data is accessed via the pointer returned hy K-IntAlloc.
Call K-MoveDataBuf to transfer data from a buffer you have allocaled by
8.
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
InstructIons
Code example
Rorland C:
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. USC the BCC -1’ command line switch.
Microsoft C/C++:
CL /AL /c fi1ename.c LINK filename
,,,DASTC+DASRFACE;
This example executes an interrupt-mode A/D sequence using a Channct-Cain array.
,**********~************~**.****~*~**~***~~~**.~**~*.*.*~.*j
/* CEXAMP2.C /*
,* 'C' /* /*
/* To create ~11 EXE using Microsoft C: /* /* /*
/* 1' To create an EXE using Borland C++ (Ver 2.0 dnd up!:
/*
- Interrupt Mode A/D transfer with Channel/Gain Array
CL /c CEXAMP2.C (use /Tp<FileName.. for C++ compile)'; LINK CEXAMPZ,,,DASTC+DASRFACE;
DRSTC‘ f,
* ,' f/
t 'i
f, f.
*i +i .I
*,
Chapter 2 - The Function Call Driver
21
/*
BCC -ml -c CEXAMP2.C dastc.lib dasrface.11b
/* ,***************"*******************~*************~~~*******,
//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" )
*/
*I */
#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 :
22
ASO-TC User’s Guide - Rev. A
main0
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,
1 !=O)
(
printf(
"Error getting Devic!e Handle" I;
LDASTCCbrdO 1
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,
// The variable is suffixed with a
if ( (err = K-GetADFrame(
Analog
Input.
DASTC-brd0,
"0" to reference board 0.
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)
1
(
PrintfVError %x Occurred during K-SetChnGAry call.
.\n", Err);
return I;
)
// u-comment this block of code for continuous run //printf("Continuous //if
(
(Err
= K-SetContRun(
Run
Selected.\n");
AD_brdO ) ) != 0 1
// ( //
Printf("Error %x Occurred duriny K_SetContinRun call.
//.\n", Err);
return 1;
// // 1
) !=
) !=O
if
( i
(
Printf("Error
Err);
return 1;
1
printf("TYPE any key to stop\n\n"); do
(
if ( ( Err = K-IntStatus( AD-brd0 , &Status, &Index ) )
!= 0 )
.\P',
Err);
24 ASO-TC User’s Guide - Rev. A
Err
= K-IntStart(
%x
Occurred during
AD-brd0 ) ) !=O)
K-IntStart call. .\n",
(
Printf("Error %x Occurred during K_IntStatus call.
printf("Conversions completed= %tid\r", Index);
1
while
if ( ( Err = K-IntStop( AD-brd0 , &Status, &Index 1 1 != 0
Err);
printf("\n");
for
printf("\n");
,,~~~~~~~~~~~~~~~~~~~---------~~~~~.....~.~~~~~-~-----------
// Release memory used by the frame. if ( ( Err = K-FreeFrame( AD_brdO 1
.\W,
( (Status
(
Printf("Error %x Occurred during K_IntStop call. .'ln*
return 1;
I
Cm
= 0; m i Samples ;
printf("Sample No. %d
(
PrintfVError %x Occurred during
Err) ;
return 1:
1
& 1) && !-kbhit0 1;
m++)
%ld\n", mcl, LocnlBuffel~[mJ,;
, != 0,
K-FreeFrame
call.
Borland Turbo Pascal
Related Files DASTCTPU Complle and Link
instructions
TPC/$E+ /$N+
In the Turhn environment
filename.pas
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
)
uses crt, DASTC;
GainChanTable = Record
num-of-codes : Integer;
queue : Array[0..31]
end;
of Byte;
FLOATING
POINT.
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
Loading...
+ 63 hidden pages