Text preview for : 24841C(PCF16G_252CPCFuC16G).pdf part of Keithley 24841C(PCF16G 252CPCFuC16G) Keithley Misc 24841C(PCF16G_252CPCFuC16G).pdf



Back to : 24841C(PCF16G_252CPCFuC16 | Home

PCF-16G
at
PCF-pCl6G




Data Acquisition Division
Keithley Instruments, Inc.
User Guide
for the


Keithley MetraByte
PCF-16G & PCF-pC16G
PASCAL, C, & FORTRAN Callable Drivers

for the

DAS-16, DAS16F, DAS16G, & pCDas-16G Boards




Keithley Instruments, Inc. Data Acquisition Division
440 MYLES STANDISH BLVD., Taunkm, MA 02780
TEL .509B9O%QO. FAX5OW90.0179




- 11,-
Warranty lnfomwtlon




Note:
Kdthley BhhByta- ls a trademark of Kcithly Instruments. Inc. Data
Acquisttton DMslon.




- iv -
Contents

CHAPTER 1 INTRODUCTION
1.1 Overview .............................. ......... l-l
1.2 Suppofted Languages ....................... ......... 1-l
1.3 Copying The Distribution Sofhvare ................. ......... 1-l
1.4 Generating Your Application Program ............... ......... l-2
1.5 This Manual. ............................ ......... l-3


CHAPTER 2: DRIVER INFORMATION
2.1 Overview . . . . . . . . . . . . . . . . . . . ......... 2-1
2.2 Driver Source Modules . . . . . . . . . . . . . ......... 2-1
2.3 Drivers. . . . . . . . . . . . . . . . . . . ......... 2-2
2.4 Mode Calls . . . . . . . . . . . . . . . ......... 2-2
2.5 Calling The Driver. . . . . . . . . . . . . . ......... 2-4
2.6 Creating New Drivers. . . . . . . . . . . . ......... 2-5


CHAPTER 3: DRIVER USAGE
3.1 Overview , . . . . . . . . . . . . . . . . , . . . . . . . . . . . . .3-l
3.2 Microsoft C~urbo C . -. .3-l
3.3 Microsoft PASCAL . : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : . .3-3
3.4 BorlandTurboPASCAL . . . . . . . . . . . . . . . . . . . . . . . 1: .3-5
3.5 Microsoft FORTRAN . . . . . . . . . . . . . . . . . .3-7
3.6 Microsoft QuickBASIC . . . . . . . . . . . . . . . . . . . . . . . . . . .3-E


CHAPTER 4 SUMMARY OF ERROR CODES



n n n




-V-
CHAPTER 1

INTRODUCTION


1 .l OVERVIEW
The FCF-16G is a software package for programmers using Pascal,Turbo PASCAL, C, FORTRAN,
and QuickBAsIC to write data acquisition and control routines freferred to herein as Appfidion Code)
for the D&16/F/G and uCDAS16G. The Distribution Software for this package is nomtally
supplied on 5.25" (3.5" for uCDAS16GI low-density diskettes but is also available (upon request) on
35" diskettds). Contents of the package include the folIowing:

l DA%6/F/G and uCDAS16G Drivers for each of the supported languages
l Drher Source Modules for creating new Drivers
l Miscellsoecus documentation (.IXX) files
l Example program files in all supported languages



1.2 SUPPORTED LANGUAGES
The PCF-16Gsupports all memory modules of the following languages:

l Microscft C (V4.0 - 6.0)
l Microsoft Quick C fV1.0 - 2.0)
l Microsoft Pascal fV3.0 - 4.01
l Mltmsoft FORTRAN fV4.0,4.1)
l Microsoft QuickBAsIC fV4.0 and higher)
l Borland Turbo Pascal fV3.0 - 5.01
l Borland Turbo C tVl.0 - 2.0)
l GW, COMPAQ and IBM BASIC fV2.0 and higher)



1.3 COPYING DISTRIBUTION SOFTWARE
As soon as possible, make a working copy of your Distribution Software. You may put the working
copy on diskettes or on the PC Hard Drive. In either case,making a working copy allows you to store
your original software in a safe place as a backup.

To make a working copy of your Distribution Software, you will use the DO5 COPY or DISKCOPY
function according to one of the instructions in the following two subsections.




l-l
PCF-16G USER GUIDE


To Copy Distribution Software To Another Diskette
Note that the source diskette is the diskette containing your Distribution Software; the target diskette
is the diskette you copy to. Before you start, be sure to have one (or more,as needed) formatted
diskettes on hand to serve as target diskettes.

First, place your Distribution Softwam diskette in your PC's A Drive and log to that drive by typing
A: . Then, use one of the following instructions to copy the diskette files.

l If your FC has lust one diskette drive (Drive Al, type COPY * . * B : fin a singledrive PC,
Drive A also servesas Drive Bl and follow the instructions on the screen.

If you prefer to use the DOS DISKCOPY function, instead of COPY, you will type DISKCOPY
A: A: and follow instructions on the screen. This alternative is faster, but requires accessto
DlSKCOpY.COM, in your DOS files.
l If your PC has two diskette drives (Drive A and Drive 81, type COPY * . * 8: (the same as
above) and follow the instructions on the screen.

lf you prefer to use the DOS DISKCOPY function, instead of COPY, you will type DIBKCDPY
A : B : and follow instructions on the screen. This alternative is faster, but requires accessto
DISKCOPY.COM, in your DOS files.


To Copy Distribution Software To The PC Hard Drive
Before copying Distribution Software to a hard drive, make a directory on the hard drive to contain
the files. While the directory name is your choice, the following instructions use PCFXG

1. After making a directory named PCFZ6G, place your Distribution Software diskette in your PCs
A Drive and log to that drive by typing A :
2. Then,type COPY l . l path\PCP16G, where path is the drive designation and DOS path (if
needed) to the FCpl6C directory.

When you finish copying your Distribution Software, store it in a safe place (away from heat,
humidty, and dust) for possible future use as a backup.




1.4 GENERATING AN APPLICATION PROGRAM
In the Distribution Software, the example program for the language you are using provides most of
the information you need to start your own Application Program. The overall procedure for a typical
executable program, however, is as follows:

1. Write your Application Code using a text editor or the language environment.
2. Compile your program.
3. Link the compiled program to a Driver (from the Distribution Software) suited to the language of
your Application Code.

This procedure gives you an executable Application Program, ready to test. Repeat all three steps as
you modify/fix this program.

l-2
CHAPTER 1: INTRODUCTION


1.5 THIS MANUAL

Chapter 2 presents information on the DAS16 and uCDA!+16 Drivers required for the supported
languages. Since the Drivers support the full series of D-16 and uCDAS-16 Mode Calls, Chapter 2
also lists and briefly desaihes the Mode Calls. And since the Drivers may not be perfecdy suited to
your particular applications, Chapter 2 discusses the Driver Source Modules, which are the source-
code files you may use for creating new Drivers. Finally, the chapter includes instructions for creating
new Drivers.

Chapter 3 presents brief instructions and examples for using the Drivers with your Application
Fhgrams.




1-3
CHAPTER 2

DRIVER INFORMATION


2.1 OVERVIEW
When you write a progmm for your own DAS16 (DAS-16 hereinafter refers to DAS-16/F/G and
uCDAS-16G) application, your program is refarred to harain as the Appliatbn Code. You have a
choice of writing this Code in BASIC, QuickBASIC, PASCAL, Turbo PASCAL, C, or PORTRAN. You
then compile your Application Code and link the resulting program with a D&r. The linking
process develops the AppZfcstfoa Program, which is the program giving you software control of your
hardware.

The Driver you link with your Application Code must be suited to the language used for the Code.
For example, if you write your Application Code in C, your must link it with a Driver suited to C

The Distribution Software contains Drivers for BASIC, QuickBASIC, PASCAL, Turbo PASCAL, C, and
PORTRAN. The Distribution Software also contains the Drier SourceModules, which are the
Assembly Language source f&s provided for the purposa of allowing you to create new Drivers
customized to your particular needs.

Section 2.2 of this chapter lists and desaibes the Driver Source Modules, with which you may create
new Drivers. Section 2.3 lists and describes the Drivers available in the Distribution Software. Section
2.4 lists the Mode Calls supported by the Drivers. Section 2.5 instructs you on how to maka calls from
your Application Code. The final section &ction 2.6) instructs you on how to use the Driver Source
Modules to create new Drivers.




2.2 DRIVER SOURCE MODULES
The following three Driver Source Modules are the essential building blocks for creating a DAS-16
Driver in any language:

DASGASM Core of the driver.
PCDASCASM Core of the driver.
DASGPCFASM Driver interface module for PASCAL, C, FORTRAN, and QuickBASIC.

As mentioned earlier, these three modules are available in your Distribution Software. Also available
in the Distribution Software is TURBOPAS.ASM , which is a Driver Source Module available strictly
for Turbo PASCAL. TURBOPASASM actually has a source equivalent to all the above three modules.

For instructions on using these modules to create Drivers, refer to Section 2.6.




2-1
PCF-16G USER GUIDE


2.3 DRIVERS
As a convenience, your Distribution Software contains Drivers for PASCAL, Turbo PASCAL, C,
FORTRAN, BASIC, and QuickBASIC. You must link the appropriate Driver with your Application
Code; choose the Driver that matches the language used for your Application Code. Available
Drivers are as follows:

BASDASGLIB: Oriver for Compiled BASIC.
DA!X.LIB: Driver for Pascal,C, FORTRAN, and stand-alone QuickBASIC programs.
DASCBIN: Driver for BASICfAl.
DASCQLB: Driver for the QuickBASIC Integrated Development Environment Wer.
4.0-4.S).
DA!XX.QLB: Driver for the QuickBASIC Extended Enviromnent (ver. 7.01.
TURBOPAS.OBJ: Driver for TURBO Pascal.



2.4 MODE CALLS
This list briefly describes the Mode Calls supported by the DAS16/F/G and uCDASl6C driver
software. More detailed explanations of each Mode are available in the main text of the DAS-16/F/G
and uCDAS-16G User Guides.


MODE 0: Inttialize board, input BaseAddress, Interrupt Level, and DMA Level.
MODE 1: Set multiplexer low and high scan limits.

MODE 2: Reads the current channel setting and scan Bmit settings.

MODE 3: This MODE performs a single A/D conversion. Data from the
conversion is returned, the multiplexor is incremented, and the next
channel gain is selectedfrom the gain table set up in MODE 21.
This MODE is slow and runs in the foreground. If calibration
MODE 1 is selectedin MODE 0 then data will be offset corrected. If
calibration MODE 2 is selectedin MODE 0 then both gain and oft%
will be corrected.

MODE 4: This routine will perform N A/D conversions after receipt of an
external trigger. Scanrate can be set by the programmable timer
(set up by MODE 13, or by the external trigger. This MODE is
faster than MODE 3 but still runs in the foreground. MODE 21 sets
gain table. If calibration MODE 1 is selected in MODE 0 then data
will be oHset corrected. If calibration MODE 2 is selected in MODE
0 then both gain and offset will be corrected.

MODE 5: This MODE is similar to MODE 4 except that data transfer is driven
by interrupts. Scanrates are set by the programmable timer or the
external trigger. Speed is medium and runs in the background.
Data is transferred by an interrupt service routine. MODE 21 sets
gain table. MODE 9 is used to transfer the data from memory into a
BASIC Array (autocalibration is performed in MODE 91.


2-2
CHAPTER 2: DRIVER INFORMATION


MODE 6: This MODE is the fastest MODE of data transkx. An array of integers
is stored directly into memory by a DMA transfer. Since is no
interrupt service routine to selectthe next charmel's gain, all
channels are at the same gain. MODE 9 is used to transfar data
from memory into a BASIC array. Note that MODE 6 puts data into
mamory without parforming any autocalibration. For calibrated
results use MODE 9, which not only takes the data from memory,
but also performs that autocallbration operation.

MODE 7: Disable DMA and interrupt operations started in MODES $6.18, or
20.

MODE 8: Reports status of DMA and interrupt operations startad by MODEs
5,6,18or 20.

MODE 9: Block move of data ac$ired in MODES 5,6, and 20. If calibration
MODE 1 is selected in MODE 0 then data will be oftset corrected. If
calibration MODE 2 is selected in MODE 0 then both gain and offset
will be corrected.

MODE lo: SetCounter 0 configuration. This is the counter whose output is
available at the output connector.

MODE 11: Load Counter 0 data.

MODE 12:

MODE 13: Output to digital outputs OHI- OP7.
MODE 14: Read digital inputs IPtMP7.

MODE 15: Output data to a single DAC channel.

MODE 16: Outputs data to both DAC channels.

MODE 17:

MODE 1s: DAC waveform output and ADC input. (Note that no data correction
is perforowd by MODE 18.
MODE 19: Analog trigger function.

MODE 20: A/D block scan on interrupt. This MODE will do a complete scan of
channels using gains set by MODE 21. Runs in background at
medium speed. Use MODE 9 to transfer data from memory into a
BASIC array. Note that MODE 20 puts data into memory without
performing any autocalibration. For calibrated results use MODE 9,
which not only takes the data from memory, but also performs that
autocalibration operation.

MODE 21: Set channel gains. Use this MODE to set up gain table prior to calling
MODES 3,4,5, and 20.

MODE 22: Output a square wave frequency from Counter 0 out. Frequency
f+om 1.5Hz to 25KHz


2-3
PCF-16G USER GUIDE


MODE 23: Allocate memory Segment.

MODE 24: DaaEocateMemory Segment.

MODE 25: Initialize PI'1 chip.
MODE 26: I/O to l'l'l.




2.5 CALLING THE DRIVER
In your Application Code, you write a call the DAS-16/F/G or uCDAS-16G driver through a single
label that corresponds to the language used for your Code and to the memory model used for
compiling. These labels are the Call LubeIs. DAB16 Call Labels and their corresponding Drivers are
as folIows:



DASG.LIB:
mscs-dasg For Calls from Microsoft C, Small Model
-.A% For Calls from Microsoft C, Medium Model
msci-dasg For calls from Microsoft C, Large Model
tcs-dasg For calls from TURBO C, Small Model
tan-dasg For Calls from TURBO C, Medium Model
tci-dasg For Calls from TURBO C, Large Model

r-q-da% For Calls from Microsoft Pascal
msf-dasg For Calls from Microsoft FORTRAN
basdasg For calls from Microsoft QuickBASIC



TURBOPAS.OBJ:
tp-da% For Calls from TURBO Pascal


DASG.BIN:
dasg For Calls from BASIC(A)

Regardless of the Ianguage/model you are using, with each call to a label you must specify three
input parameters, as fallows:

MODE A l&bit integer containing the number of the mode to be executed by
the DAS16 driver.

PARAM An array of %-bit integers containing a variable number of mod-+
dependent arguments required for the successfulexecution of the
mode.
2.4
CHAPTER 2: DRIVER INFORMATION


FLAG A l&bit integer quantity that contains a number rep-ting any
error code reported by the DAS-16 driver. (SeeChapter 4 for error-
code definitions.)


The foIIowing is code fragment fin CI on how to declare and urn the call parameters.

int -;
int Flag:
int Params[16];
I&&:= 0;
Flag = 0;
Params[Ol = 0x300; /* card Base -as l/
Parama[lI = 7; I* selected Interrupt Level l/
Paeams[2] = 3; /* Selected D%aA Level l /
mSCl~daSg(udoda, Parma, &Flag) ;
if (Flag != 0)
pdntf ("**** Error %d deteoted in Ida 0". Flag);




Refer to Chapter 3 for additional details on how to decIare and use these variables in other languages.




2.6 CREATING NEW DRIVERS

General
while the Drivers available to you in the Distribution Sofhvare (seeSection 23) support all the CaII
Modes described in Section 2.4, they may not suit your particular application. You may remedy this
problem by creating a new version of the desired Driver. This section provides the information
necessary to create a new Driver for BASIC, QuickBASIC, PASCAL, Turbo PASCAL, C, and
FORTRAN.

Note that to create a new version of a Driver, your working directory (generally, the directory
containing the Distribution Software) must contain the Driver Source Modules (Section 2.2) and the
following development tools:

MASM.EKE Microsoft Assembler

LINKEXE Microsoft Linker

LIBEXE Microsoft Librarian


Other utilities will be specified as needed in the instructions of the subsections that follow.

Also, note that in the MASM compile commands you use to create a new Driver, you must define the
two symbols BIN and DA%. Thesedefinitions use the /D option for BASIC, QuickBASIC,
PASCAL, C, and FORTRAN. For Turbo PASCAL, onty the symbol DAS16A requires definition.
These symbol definitions are as follows:

2-5
PCF-16G USER GUIDE


BIN = 1: Compile for BASIC(A) Driver. Usage example: /DBIX=l .

BIN = 0: Compile for non-BASIC(A) Driver (PASCAL, C, FORTRAN, and
QuickBASICl. Usage example: /DBIX=O
DASC = 1: Support for DAS-16A. Usage -pie: /DDASG=I .

DASG 7 0: No support for DA!!&16A. Usage example: /DDASG=O

DAS16A = 1: Support for DAS-16A (Turbo PASCAL Driver only). Usage example:
/DDAS~~A=~.

DAS16A = 0: No support for DAS-16A (Turbo PASCAL Driver only). Usage
example: /DDASI62=0.


WARNING
The manufacturer does not provide teclmical support for user
medications of the driver source code.


The DASG.BIN Driver For BASIC(A)
To create a DASG.BlN Driver, you must have accessto the following utilities:

D(E2BlN.BXB A Microsoft BXB-to-COM file conversion utility (generally available in
DOS files).
MAKBBlN.EXB A .COM-to-.BlN file-conversion utility (supplied in the DAS16/F/G
and uCDAS-16 Distribution Softwarel.

Then, use the following conmumds:
N?&N /DBIN=l /DDAsG=l DA2G.A2M:
ms14 /DBIN=I ~aaso.~S~
mshs /DBIN=~ mso9ar.ma;
LINK DASPCP + DA2G + PCDASG, DA2G;
WZBIN DASG.NXE DASG.COn
NINNBIN DmG.CGU

All four steps must be successful. Note that the linking operation generates the warning:

LINK : Warning L4021 : no stack segment

Disregard this warning; it is irrelevent.



The TURBOPAS.OBJ Driver For Turbo PASCAL
To aeate a TURBOPASOBJ Driver, you must have accessto the following utility:

TASM.EXF TURBO Assembler




2-6
CHAPTER 2: DRlVER INFORMATION


Then, "se the command TASM TURBOPAS. AS&l.



The DASG.QLB Driver For The QuickBASIC Integrated ~Environment (V4.5)
To meate the DA!SG.QLBDriver, you must have accessto the utility BQL.B45LIB, which is the
QuickBASIC Integrated Environment Library. Then use the following commands:
MASU /DBIN=O /DDASG=l DASG.ASN;
NASM /DBIN=O PWG.ASN
ma4 /DBIN=~ rmscpw .~sn;
LINN /q LiASG+PCDASo+PCFDhSG, DASG, ,BQLe45;



The DASG.LIB Driver For A Stand-alone QuickBASIC (V4.5) Program
To create the DASG.LIB file, you must have accessto MASM (the Miaosoft Assembler) and LIB.EXJZ
(the Microsft Library Manager). Then, use the following commands:
NASH /DBIN=~ /~IasG=l ~hf3c.m;
tam4 /DBIN=~ ~cmsG.24su;
MUM /DBIN=O DhsoP~!~.Aslb;
LIB DASG-+DASG;
LIB DASG-+PCDASG;
LIB DASG-+DASGPCF:



The DASGX.QLB Driver For The QuickBASiC Extended Environment (V7.0)
To meate a QLB library compatible with QuickBA!SICVersion 7.0, follow the procedure d&bed for
QuickBASIC Version 45. However, link with QBXQLBUB , instead of BQLBCLIB , as follows:
LINK /q DASG+PCDASDIDASGPCF, DASGX, , QBXLB;

Note that the output file (from the linker) is renamed DASGXQLB to avoid incompatibilities with
QuickBASIC 4.5.



The DASG.LIB Driver For PASCAL, C, 81FORTRAN
When your Application Code is in PASCAL, C, or FORTRAN, use the DASGLIB Driver to compile
your Application hogram.

To create the DASGX.LIB file, you must have accessto MASM (the Miaosoft Assembler) and
LIB.EXE (the Microsft Library Manager). Use the following commands:

W&M /DBIN=O /DDASG=~ DASGASM;
m3m /DBIN=~ x~as~.~sta;
mm /DBIN=~ DAsGpm.xw:
LIB DASG-+DASG;
LIB DASG-+PCDASG;
LIB DUG-+DASGPCF:

888




2-7
CHAPTER 3

DRIVER USAGE


3.1 OVERVIEW
Although your DA!+16 (DAS-16 refers hereinafter to DAS-16/F/G and uCDAS-16G) drivers perform
similarly for all supported languages, there are differences from language-to-language in how they
pass paramatars and parameter values. The itams causing the most confusion are as follows:

l Memory allocation for DMA buffers.
l Sparating a FAR (32-bit) pointer into its !Segment O&et values (two l&bit values).
and

This chapter discussesthese items and any others of concern in the separate treatment of each
supported language. Refer to the appropriate section below for details on performing the Mode Calls
from the language you are using. The language sectionscontain brief code fragments for illustration.
More information is also available in the example programs Oistdbution Software).




3.2 MICROSOFT C/TURBO C
The C Language, with its large run-time libraries and full pointer-manipulation support, provides the
most flexible environment for writing Application Code that fully utilizes your DAS-16 product.



Function Prototypes
In your Application Code, declare one of the following timction prototypes, depending on the
Memory Model you will use:
maca-dasgfint *, int *, int *) ; /* MS c small Modal l/
nlacm_dasg(int l , int *, int *); /*Mscmdiumnodd*/
mscl-daagfint *, int *, int l ) ; /* MS C Large Model */
tcs-dasg(int l , int *, in+ l ) ; /* Turbo c small Model */
tom-dasg(int *, int *, int *); /* Turbo c Medium MO&l*/
tcl-dasg(int *, int *, int *); /* Turbo C Large Model */


You have the option of preceding these function prototypes with the C keyword extern Note that
each prototype contains a Call Label that corresponds to the Memory Model to be used during
compilation.



The Call Parameters
Declare the Mode Call parameters as follows:
int Mode;
int Params[l61;
int Flag;

3-1
PCF-1GG USER GUIDE


The Paramsfl array index values are 0 thru 15, inclusive.



An Example
To call MODE 0 of the DASG Driver from an MS C Medium Model program, your commands would
be

NO&O:
Flag=0 ;
Parama[O]=OX300;
Params[ll=7;
Params[21=3;
mscm-daag (4Nad0, Param, rElag) ;
if (Flag !=O)
r
printf ("Mode %d Error Flag = %d\n", W, Flag);
exit(l);
1



Note that qwifylng Parmns in the Call statmant is the same as bPar~~Ol.



Linking To The Driver
After compiling your C Application Code, link it to the DA!K.LIB Driver (for Call Label nwm&sg )
as follows:
LIWC yout-program, , , DABG . LIB :


If no error reports occur, you will obtain your Application Program your-program.EXE, ready to test.
If the Linker reports errors such as Unresolved ExtemalW, determine whether you linked to
DASG.LIB correctly.

NOlX Be sure to use the correct Call Label for the Memory Model you are using.


DMA Memory Butter Allocation
MODE 6 requires memory buffer represented by a special DMA buffer address in form of one X-bit
value (the segment; to complete the address, the Driver assumesan Offset of 0). This special DMA
address is available by calling MODE 23 (for detail, refer to the DAS-16/F/G and uCDAS-16G User
Guides).



Far Pointer Manipulation
MODE 4,s. 9,18, and 20 allows FAR pointers to be passed in the user Params[] integer array. The
Segment and Offset of all FAR pointers(32 bits) in C may be retrieved using C maao: FP-OFF and
Fp_SEG. Refer to your C Run-time library manual for more detail.



3-2
CHAPTER 3: DRIVER USAGE


For example,
int far * samp_bufgtr, l chan_bufgtr;
unsigned int &at-sag;
int MO&, Params[l6], Flag;




to unpack `I
Patm[lI = -1: I" use FAR pointer */
ParaIM(21 = 0; /* Stark with sample 0 ?!
Parama [31 = FP-OST(saq-bufgtr) ; /f Offset address Of data array "f
Params[Il = FP-SEG(saq-buf_ptr) ; /' ssgnren+ address of data array l/
Params CSI = FP-OrF (chan-bufgtr) ; /* Offset addsass Of l2hm azxay */
Parama [61 = FP-SEG(chan-bufgtr) : /* segmant address of channel atzfay l/
Parama[7] = 0; /* nemxy offset */
Params[sl = dest-seg; /* plamoey a'egmant */
mscl~dasg(6Mode, Pft2mma, &slag);
if (Flag !=O)
(
printf("Mode 9 Error Flag = %d\n",Flag);
ait (1) ;
1




3.3 MICROSOFT PASCAL
Function Prototypes
In your Application Code, declare the following function prototype:




The Call Parameters
Declare the Mode Call parameters as follows:
TYPE
PArray = array [l. ,161 of word :

VAN
Par- : PArray: (* MODE PARAH ARRAY *)
Mode,Flag : integer; (* MODE CALL VARIABLES *)


The Paramsll array index values are 1 thm 16 inclusive. Note that if P&ray TYPE is de&red as
[0..15], the index value starts at 0.




3-3
PCF-160 USER GUIDE


An Example
To caII MODE 0 of the DA.% Driver from MS PascalApplication Code,

Mode := 0;
Parama[l] := 766; (* BOARDmDRJ%S *I
Parama[2] := 7; (" 1-T LSVEL *)
Parama[3] := 3: (* DBGLLEVEL *)
MsP_oAsG (Mode, Parama, Flag);
if (Flag 0 0) then Report.Error;


where ReptError is a previously declared procedure that displays an error messageand terminates
the program. Refer to the Microsoft PASCAL example program (in the Distribution Software) for
more detail.



Linking To The Driver
After compiling your MS PASCAL Application Code, link it to the DASG.LIR Driver (for Call Label
msp-dusg ), as follows:

LINK your-program,,, DASG. LIB:


If no error reports occur, you will obtain your Application Program your-progrm.EXE , ready to test.
If the Linker reports errors such as Unresolved Externalfsl, determine whether you linked to
DA5G.LIR correctly.



DMA Memory Buffer Allocation
MODE 6 requires memory buffer represented by a special DMA buffer address in form of one &bit
value (the segment; to complete the address, the Driver assumesan Offset of 0). This special DMA
address is available by calling MODE 23 (for detail, refer to the DAS-16/F/G and uCDAS-16G User
Guides).



Far Pointer Manipulation
MODES 4,5,9,18, and 20 allow FAR pointers to be passed in the user Params[l integer array. The
Segment and Offset of all FAR pointers (32 bits1 in MS PASCAL may be retrieved using the built-in
operator ADS and the .S and .R sub-operators. Refer to your MS PascalRun-time library manual for
more detail.

For example,

rypa
D&ray = amay Il..50001 of integer:
vae
data, chan : DArray;




3-4
CHAPTER 3: DRIVER USAGE


l&da := 9 :
Flag := 0 :
rww;;; :=5000;
:=-I'
Parama[3] :=O:'
Paramatll :=ORD( (ADS data) .R);
Panama t5):=OPD( (ADS data) . S) ;
Parama[61 :=ORD( (ADS ohan) .R) ;
Paramat71 :=DPD((ADS chao) .s):
Parama[Sl :=O;
Param 191 : =deat_seq;
matit :' mSp daag(bLode,Params,Flag) ;
if (result <> a, than
Bssin
RnportError:
Raturn;
End;




3.4 BORLAND TURBO PASCAL
The Call Label
The Call Label tp-dasg is usable from any Turbo Pascalprogram; declare this label in your
Application Code as follows:




The Call Parameters
Declare the Mode Call parameters as follows:
TYPE
PArray = amay (1. .16) of word;
VAR
Paraam : PArLrray: (* MODE PARat ARPAY *)
Mode,Flag : integer: (' MODE CALL VAXABLES *)
RBau1t : integer; (* MODE CUL ReTUW K%LDE *)


The Params[] array index values are 1 thru 16, inclusive. Note that if PArray TYPE is declared as
[0..15], the index values start at 0.



An Example:
To call Mode 0 of the DASG Driver from Turbo Pascal Application Code:

Mode::= 0;
Params := 768; (* BOARD ADDRESS l )
Paraala[2] := 7; (* INTBRRUPT LEVEL *)
Parama[31 := 3; (* D= LEVEL *)
Result := TP-MSG Node, Pamma, Flag) ;
if (Result -3 0) then ReportError;



3-5
PCF-16G USER GUIDE


Where ReportError is a previously declared procxdure that displays an error messageand terminates
the Application Code. Refer to the Turbo Pascalexample program provided for more detail.



Linking To The Driver
The Turbo Pascal Driver is ~URBODASOBJ . This file is linked into your program using the $L
Compiler Directive. Include this command at the beginning of your progam as follows:

(QL mJRBoPAs)

Once included, you are ready to compile your program with the command
TPC your-program



DMA Memory Buffer Allocation
MODE 6 requires memory buffer represented by a special DMA buffer address in form of one N-bit
value (the segment; to complete the address, the Driver assumes an offset of 0). This special DMA
address is available by calling MODE 23 (for detail, refer to the DAS-16/F/G and KDAS-l&Z User
Guides).



Far Pointer Manipulation
MODES 4,5,9,18, and 20 allow FAR pointers to be passed in the user ParamsI] integer array. The
Segmentand Offset of all FAR pointers (32 bits) in Turbo Pascalmay be retrieved using built-in
function Ofs and Seg. Refer to your Turbo PascalRun-time library manual for more detail.




PArray= amay 11. .16lof integer :
DArray = array [l. .5000] of integer;
var
Params : PArray ;
data, chaa : DArray;
Mode,Flag : integer:




blade := 9 ;
Flag := 0 ;
Params[l] :=5000;
Params[2] :x-l;
:=afs(data);
Parama [S] :=aeg(data) ;
Paraw 161 :=ofs(chan);

Parama [ 91 : =&at-aeg:
Result := tp_daSgNode,Parama,Flag) :

3-6
CHAPTER 3: DRIVER USAGE


3.5 MICROSOFT FORTRAN
The Sottware Driver Call Label
The call Iabel msf_ansgis usable from any MS FORTRAN Application Code; no prototype declaration
of the label is required.



The Mode Call Parameters
Declare the Mode Call parameters as follows:
integer*2 i (16) !Paramatar Array
integer*2 moda !Mode number
integer*2 flag !Return error flag


Note that by default, FORTRAN array index values begin at 1. The latest versions of FORTRAN,
however, allow you override this default to start at Index Value 0. Refer to your FORTRAN Manuals
for more detail.



An Example
To caIl MODE 0 of the Driver from Microsoft FORTRAN Application Code,
mode=0
i(l)=768 ! Board Address
i(2)=7 ! Interrupt Level
i (3)=3 ! DMA Level
call msf~dasg(nbode, i(l), Flag)
if (flag .NE. 0) then
print l ,`Mcde = `,mode,' Error # `,flag
endif



Linking To The Driver
After compiling your FORTRAN Application Code, link it to the DASG.LIR Driver (for the Call Label
rrrsf-dasg1as follows:
LINK your-prcgnm,,,DASG.LIB;


If no error reports occur, you will obtain your Application Program your-program.EXE, ready to test.
If the Linker reports errors such as Unresolved Externalfsl, determine whether you linked to
DASG.LIB correctly.



DMA Memory Buffer Allocation
MODE 6 requires memory buffer represented by a special DMA buffer address in form of one l&bit
value (the segment; to complete the address, the Driver assumesan Offset of 01. This special DMA
address is available by calling MODE 23 (for detail, refer to the DAS-16/F/G and uCDAS-16G User
Guides).

3-7
PCF-1s USER GlJlDE




MODES 4,5,9,18, and 20 allow FAR pointers to be passed in the user Params integer array. The
Segment and Oftbet of all FAR pointers that are to represent a memory buffer in FORTRAN may be
retrieved using the FORTRAN intrinsic function LOCFARO and some simple calculation. Refer to
your FORTRAN Run-time library manual and our FORTRAN example programs for more detail.

For example,
integet*2 data(5000),p.ruM (lb)
integer*2 nKada,flag
integer*2 array-off,array_seg
integer*4 artay-addx




C Get segmeut and offset address Of data array
array~addrrLOCPAR(&ta (1) )
array_ssp--array~ad/#loooo
array~offsrray_addr-(~rray_ssg*%10000)

Inode=
flag=0
params (1)=5000
params(2)=-1
pa.eams(3)=0
params (I)=array-off
panms (5)=array_sag
parama(6)=0
parama(7)=0
parama(8)=0
par- (9) pdast-seg
call fdasg(mode, params( flag)




3.6 MICROSOFT QUICKBASIC

The Call Label
You must declare the Cal) Label in your Application Code. Make this declaration by inserting the
following command at the beginning of your Code:
DECLARE SUB BASDABG (MB%, BYVAL PABAMB%, FL&G%)


Note that all subroutine DECLARESin your program MUST be made before any $DYNAMIC arrays
are allocated. $DYNAMfC data is data that is allocated space in the FAR heap, outside the default
data segment. All arrays used for data acquisition must be declared as $DYT-JAMlC;QuickBasic
assumes$STATIC data (Default data segment) unless otherwise specified.




3-0
CHAPTER 3: DRIVER USAGE


The Call Parameters
Declare the Mode Call parameter array D%(151as follows:
DIM D%(15)
C- SBARD D%()


T'heterm COMMON SHARED allows the use other modules and subroutines in this array.



An Example
To initialize your DAS-16 board, use MODE 0 as follows:

120 &% = 0 `initialize mode
190 FLAG% = 0 `declare errors variable
200 D%(O) = SH300 'Card Base Address
210 D%(l) = 7 `Interrupt Level
220 D%(2) = 3 `mm Level
230 D%(3) = 0 `Auto-Calibration = Off
240 CAI& BASDASG (IO%, VARPl'R(D%(Ol) , FLAG%)
250 IF FIAG% <> 0 TBBN PRXNT "NGDE 0 Error t ": FLAG% : STOP



Linking To The Driver
The QuickBASIC interface consists three separate Drivers:

DASCQLB Use when you load the QuickBASIC Enviroment Version 45 and you
plan to run your program from within the Environment (no ME
envolved here). Use the /L switch to load this Quick Library into
QuickBASIC

QB /L DAGG
DASCX.QLB This is identical to DASCQLB except that it is designed for QuickBASIC
Extended Environment Version 7.0 (QBX). Use the /L switch to load this
Quick Library into QuickBASIC:

QBX /L DAGGX
DASG.LlB Link to this library when you want to make a stand-alone EXE program
from your QuickBASIC (all versions) source. To create such a program,
use BC and LlNK the QuickBASIC compiler and linker as follows:

BC .bas /o;
LINK ,,,DASG.LIB;


NOTE: All $DYNAMIC data declaration must occur after all COMMON and DECLARE
statementsin your program. If you get the QB error, COMMON and DECLARE must
precede all executable statements;double check the order of all DECLARE, COMMON,
and $DYNAMIC declarations.


3-9
PCF-16G USER GUIDE


To link your Application Code to a QuicBASIC Driver, you must specify the Driver in the command
line using the had switch /L , as follows

QB /L DASG.QLB



DMA Memory Buffer Allocation
MODE 6 rqutres memory buffer repmsented by a special DMA buffer address in form of one l&bit
value (the segment; to complete the address, the Driver assumesan Offset of 0). This special Dh4A
address is available by calling MODE 23 (for detail, refer to the DAS-16/F/G and uCDAS-16G User
Guides).



Far Pointer Manipulation
QuickBASIC provides the built-in functions VAEETE and VAESEG for obtaining the Offset and
Segment of a given variable. If the variable is declared in the $STATlC area (by default), VAFtSEG
returns the default data segment. If the variable is declared as $DYNAMIC, then it is placed in the
FAR heap and VAESEG for such a variable returns a unique Segment value outside the default data
segment.

For example,
DIM Dl'% (1000) ' Data artay used by ldoDE 9
DIM CH%(lOOOl ' Charmel array used by MDDE 9




MD% = 9 `mode9 - dal+ transfer
PARw%(O) = 1000 `mmber of worda to transfer
PARAM% = DMASEG% `Flag to look for SEG:OE'F pair8 below..
PARAM%(2) = 0 `atart transferring at 1st sample
P-%(3) = VARPTR(DT%(O)) `Offset of DT%(*) array
PARAN%(4) = vARPTB(cB%(O)) `Offaet of CR%(*) array
CALL BBSDASG(MD%, VARPTB(PARAbl%(O) ) , FL&G%) `make transfer
IF FLAG% e 0 THBN PRINT "Mode 9 data transfer emor t "; FIAG%: STOP




3-10
CHAPTER 4

SUMMARY OF ERROR CODES


In generaI, the Gror Flag is the parameter that returns any reports of error conditions. This flag is an
integer type (16 bits) and contains the Error Code number.


The following list contains &or Code definitions and suggested actions.


Envr 7: Ddver not Innlrrllzed.
Detail: This error may be issued from any mode; it indicates that the driver must
be reinitialized prior to this step.
Recommended Ation: call Mode 0 before calling the mode in which this error occurred.


Emw 2: MODE number out of range.
Detail: This error may be issued from any mode; it indicates the the specified
mode number is not allowed.
Recommended Action: Check the mode number; it should be within 0 to 25.


Enur 3: Base Address ow of range.
Detail: This error is generated by MODE 0 whenever the BaseAddress specified
is not allowed.
Recommended Action: Specify a BaseAddress within the range 256 WOh) and 100s (3Foh),
inclusive.


Error 4: /ntenupr Level out of mnge.
Detail: This error is generated by MODE 0 whenever the specified Interrupt
Level is not allowed. Use a level that does not conflict with other devices
in your system.
Recommended Action: Supply MODE 0 with an Interrupt Level in the range 2 thru 7, inclusive.


Error 5: DMA channel not 1 or 3.
Detail: This error is generated by MODE 0 whenever the specified DMA
Channel is not allowed. Note that, unlike the Interrupt Level selection,
the DMA Channel selected here must match the DMA Channel Switch
position on the board!
Recommended Action: Supply MODE 0 with DMA Channel 1 or 3.
PCF-16G USER GUIDE


Error 6: Dlfferentlai scan limits out of range.
Detail: This error is generated by MODE 1 whenever the differential input
channel scan limits are out of range.
Recommended Action: Check the channel numbers passed to MODE 1. They must be within 0
thru 7, inclusive.


Enor 7: Single En&d scan llmffs out of range.
Detail: This error is generated by MODE 1 whenever the Single Ended input
channel ran limits are out of range.
Recommended Action: Check the channel numbers passed to MODE 1. They must be within 0
thnr 15, inclusive.


Ermf 8:
Detail:
Recommended Action:


Ermr 9: No End-Of-Convemion (EOC) signs/ from A/D subsystem.
Detail: This error is generated by MODE 3 whenever an expected EOC signal
from the DA%16 is not recieved. This indicates a hardware failure.
Recommended Action: Check the boards Base Address.


Error 10: One or both counter values out of range.
Detail: This error is generated by MODE 17 whenever one or both counter
divisors are specified as 0 or 1.
Recommended Action: Check both counter divisors for values within the range 2 thru 65535,
inclusive.


Error 11: Number of ConversIons out of range.
Detail: This error is generated by MODES 4,5,6, or 20 whenever the number of
conversions specified is out of range. Note that the number of
conversions is limited to 0 thru 32767,inclusive; where, 0 is used to
specify the 32768 - the maximum number of conversions possible.
Recommended Action: Check the number of conversions.


Error 12: Counter 0 Conffgumtlon Number out of range.
Detail: This error is generated by MODE 10 whenever Counter 0 configuration
number is not within the allowed range of 0 thro 5 inclusive. Refer to
section ???for detail on the different configuration modes.
Recommended Action: Check the configuration number.
4-2
CHAPTER 4 SUMMARY OF ERROR CODES


Error 13: D/gfta/ output data out of range.
Detail: This error is generated by MODE 13 whenever the output data value is
not within 0 thru 15 inclusive. There are four (4) Digital Output lines
available on the DAS-16.
Recommended Action: Check the Digital output value.


Enor 14: Anabg output (D/A) data out of range.
Detail: This error is generated by MODES 15 and 16 whenever the D/A value
specified is out of the allowed range of 0 thru 4095, inclusive.
Recommended Action: Check the DAC value.


Emr 15: DAC channel number not 0 or 1.
Detail: This error is generated by MODES 15 and 18 whenever the DAC channel
number specified is not allowed. the DAS-16 family of boards supports
two DAC channels: 0 and 1.
Recommended Action: Check the DAC channel.


Error 16: Counter 0 Read opemtion number out of range.
Detail: This error is generated by MODE 12 whenever an illegal Counter Read
Operation is attempted. Two types of Reads are allowed: 0 = Normal
Read, and I= latched Read.
Recommended Action: Check Read operation number.


Error 17: Sfattlng sample number out of range.
Detail: This error is generated by MODE 9 whenever the starting sample
number is out of range. The number must within 0 thru 32767,inclusive.
Recommended Action: Check the starting sample number.


Error 18: Requested sample count out of range.
Detaik This error is generated by MODES 9 and 18 whenever the number of
samples is out of range. The sample count for these modes must within
1 thru 32767,inclusive.
Recommended Action: Check the sample count.


Emr 19: Trigger Mode must be 0 or 7.
Detail: This error is generated by a multiple of MODES whenever the A/D
Conversions Trigger source is not valid.
Recommended Action: 5pscify 0 for Internal Trigger or 1 for External Trigger.

4-3
PCF-16G USER GUIDE


Enur 20: htemtpt or DMA h&Me(s) almdy octlve.
Detail: This error is generated by MODES 5,6,18, or 20 whenever an Interrupt
or DMA Mode is attempted while another is already active. Interrupt
and DMA acquiistion modes share the - resources and can not be
used simultanuously.
Recommended Action: Use Mode 7 to terminate current acquisition operation.


Ertvr21: DMA Page Wrrp.
Detail: This error is generated by MODE 6 whenever the comblltion of the
DMA Segment fDIO%fI 11 the Number of Samples tDIO%fOll create
and
a Page Wrap condition in the PCs DMA Controller. The DMA operation
is never started.
Recommended Action: Use MODE 25 to determine a `good' DMA Segment to supply MODE 6.


Errvr 22: Board not present.
Detail: The Board PresenceTest perhmned in MODE 0 has failed. The Base
Address passed to MODE 0 must match the actual address selected on
the board.
Recommended Action: Check the boards BaseAddress.


Ertvr 23: Analog Trigger Channel out of range.
Detail: This error is generated by MODE 19 whenever the specified Analog
Input Channel is out of range. This channel number must between 0 and
7 (Differential) or 0 and 15 (Single Ended), inclusive.
Recommended Action: Check the channel number.


Emw 24: Analog trfgger data out of range.
Detail: This error is generated by MODE 19 whenever trigger value is out of
range.
Recommended Action: Specify a value between 0 and 4095 Klnipolar) or -2048 and 2047
(Bipolar), inclusive.


Ermr 25: Analog trigger slope not 0 or 1.
Detail: For MODE 19, the user is allowed to specify 0 to trigger on a Positive
slope or 1 for a Negative slope.
Recommended Action: Sepcify 0 or 1 for the Trigger Slope.




4-4
CHAPTER 4 SUMMARY OF ERROR CODES


Emr 26: Gatn Cods out of range.
Detail: This error is generated by MODES 6,19, and 21 whenever the spedfied
Gain Code is out of range. The allowed Gain Codes are 0 thru 3,
inclusive. Note that an Analog Input Gain Code is relevant only to the
DAS-16GI and G2 boards. This value is ignored when spscified for
other boards.
Recommended Action: Specify a valid Gain Code.


Enor 27: Old BASIC pmgrsm compattbflty problem.
Detail: You wiI1 get this error when you use the new DAS-16 drlver/llbrary
feature (Rev 4.10 or newer) from a BASIC program written for a previous
revision of the driver.
Recommended Action: Replaceall: CALL DA.516 with CALL DASG , and increase your
parameter array D%(4) dimention to D%f15).


Ermr 28:
Detail:
Recommended Action:


Error 29: Posstble memory Index overflow.
Detail: This is a rare error that is generated by MODES 4 or 5. If you are
unlucky enough to seeit, reduce your number of samples by 16!
Recommended Action: Reduce your number of samples by 16, and retry.


Envr 30: Msmory allocatlon/deellocation envr.
Detail: This error is generated by MODE 23 or MODE 24 whenever memory can
not be allocated or deallocated through DOS
Recommended Action: If error is generated from Mode 23, reduces the size of allocating
memory. If error is generated from Mode 24, make sure the right
memory segment to be deallocated is passed to the driver correctly.


Error 31: 825SA PPI control word out of range (Mode 25 for DASlGA only!).
Detail: This error is generated by MODE 25 whenever the control word for PPI
8255A is out of range.
Recommended Action: Check the control word passed to MODE 25. It must be within 0 -255.




4-5
PCF-160 USER GUIDE


Ermr 32: Data pmsent flag out of range (Mode 25 for DAS-16A only!).
Detail: This error is generated by MODE 25 whenever the Data Present flag is
neither 0 (data is presented) nor 1 (data is not presented).
Recommended Action: Make sure the flag passed to MODE 25 is either a 0 or I


Ermr 32: 8255A PPI modi out of range (Mode 25 for DAC16A only!).
D&lI: `Ihis error is generated by MODE 25 whenever the 8255A IT1 mode is
out of range.
Recommended Action: Make sure the mode number passed to MODE 25 is either a 0, 1, or a 2.


Ermr 34: PoR A dinxtlon out of range (Mode 25 for DAS-16A only!).
Detail: This error is generated by MODE 25 whenever the Port A direction is
invalid.
Recommended Action: Make sure the port direction is OOh,
Olh, lOh, or Ilh.


Ermr 35: Port S dlnwtlon out of mnge (Mode 25 for DAS-16A onlyf).
Detail: This error is generated by MODE 25 whenever the Port B direction is
invalid.
Recommended Action: Make sure the port direction is OOh,
Olh, lOh, or llh.


Ermr 36: Port C (HI) dhctlon Out of mnge (Mode 25 for DAS-16A Only!).
Detail: This error is generated by MODE 25 whenever the Port C (Hi) direction
is invaIid.
Recommended Action: Make sure the port direction is either OOh,
Olh, lOh, or llh.


Ermr 37: Fort C (Lo) dlmction out of range (Mode 25 for DA.9WA onlyl).
Detail: This error is generated by MODE 25 whenever the Port C (Lo) direction
is invalid.
Recommended Action: Make sure the port direction is either 004 Olh, 1Oh.or llh.


EI?W 38: lncormct Port S (UO) mode (for 8255A PPI h4ode 2 onlyf; h&Me 25 for DAS-16A only!).
Detail: This emor is generated by MODE 25 whenever the Port B U/O) mode is
invalid.
Recommended Action: Make sure the mode is either 0,l.




4-6
CHAPTER 4 SUMMARY OF ERROR CODES


Emr 26: 6256A PPI chip Is not lnffiallzed (Mode 26 for DAS-16A only!).
Lktaik This error is generated by MODE 26 whenever this MODE is called
before calling MODE 25.
Recommended Action: calls MODE 25 fiat.


Emr 46: PotI k output dafa out of fimge (Mode 26 tar DA646A ontyl).
Detalk This error is generated by MODE 26 whenever the output data to Port A
is out of range.
Recommended Action: Make sure the output data is between 0 and 255.


Emr 41: Port B oufpuf data out of range (Mode 26 for DAB-16A onlyf).
Detail: This emor is generated by MODE 26 whenever the output data to Port A
is out of range.
Recommended Action: Make sure the output data is between 0 and 255.


Error 42: Pan C oufpuf dafa out of fange (Mode 26 for DAB-16A only!).
Detalk This error is generated by MODE 26 whenever the output data to Port A
is out of range.
Recommended Action: Make sure the output data is between 0 and 255.




4-7