Tektronix The PCF-20 Guide to Driver Software for the DAS-20 24893A (UNSUPPORTED) User manual

PCF-20
Keithley MetraByte Corporation
*****
The
Guide to Using
PASCAL, C, & FORTRAN
Callable Driver Software
for the
DAS-20
Revision A, - 1987 Copyright @ Kelthley MetraByte Corp. 1987 Part Number: 24893
KEITHLEY METRABYTE CORPORATION
440 MYLES STANDISH BLVD., Taunton, MA 02780 TEL. f&8/880-3000. FAX 5W880-0179
. . .
- 111 -
Warranty Information
All products manufactured by Keithley MetraByte are warranted against defective materials
and worksmanship for a period of one year from the date of delivery to the original purchaser, Any product that is found to be defective within the warranty period will. at the option of Keithley MetraByte. be repaired or replaced. This warranty does not apply to products damaged by improper use.
Warning
Keithley MetraByte assumes no liability for damages
consequent to the use of this product. This product is not
designed with components of a level of reliability suitable
for use in life support or critical applications.
Disclaimer
Information furnished by Keithley MetraByte is believed to be accurate and reliable. However, the Keithley MetraByte Corporation assumes no responsibility for the use of such information nor for any infringements of patents or other rights of third parties that may result from its use. No license is granted by implication or otherwise under any patent rights of Keithley MetraByte Corporation.
Notes
Keithley MetraByte/Asyst/DAC is also referred to here-in as Keithley MefraByte. BasicTM is a trademark of Dartmouth College. IBM@ is a registered trademark of International Business Machines Corporation. PC, XT, AT, PS/2, and Micro Channel Architecture@ (MCA) are trademarks of
International Business Machines Corporation.
Microsoft@ is a registered trademark of Microsoft Corporation. Turbo C@ is a registered trademark of Borland International.
- iv -
Table of Contents
Section 1 INTRODUCTION 2
1.1 General Description:
1.2 Using the PCF-20
1.3 DAS-20Modes
1.3.1 Listing of Available Modes ..............................
1.3.2 Mode Parameter Descriptions .............................
1.3.2.1 Mode 0: Initialize the DAS-20
1.3.2.2 MODE 1: Load the A/D control Queue
1.3.2.3 MODE 2: View the current queue
1.3.2.4 MODE 3: Perform a Single A/D Conversion
1.3.2.5 MODE 4: Perform N conversions (program control)
1.3.2.6 MODE 5: Multiple A/D conversions-- Interrupt driven
1.3.2.7 MODE 6: Multiple A/D samples with DMA data transfer.
1.3.2.8 MODE 7: Command a Single D/A conversion
1.3.2.9 MODE 8: Load Memory Segment for D/A conversion.
1.3.2.10 MODE 9: Multiple Interrupt D/A conversions
1.3.2.11 MODE 10: DMA driven D/A conversions
1.3.2.12 MODE 11: Cancel DMA or Interrupt
1.3.2.13 MODE 12: Determine Status of interrupt/DMA
1.3.2.14 MODE 13: Transfer data from memory to array
1.3.2.15 MODE 14: Read the Digital inputs
1.3.2.16 MODE 15: Write to the Digital outputs.
1.3.2.17 MODE 16: Analog trigger
1.3.2.18 MODE 17: Initialize Timer - Reset timer.
1.3.2.19 MODE 18: Set Timer Master Mode Register
1.3.2.20 MODE 19: Set Counter ‘N’ Mode Register
1.3.2.21 MODE 20: Set Multiple Counter Control Registers
1.3.2.22 MODE 21: Set Counter ‘N’ Load Register
1.3.2.23 MODE 22: Read Counter ‘N’ Hold Register
1.3.2.24 MODE 23: Measure Frequency
1.3.2.25 MODE 24: Set A/D pacer clock
1.3.2.26 MODE 25: SET D/A pacer clock
1.3.2.27 MODE 26: Stop A/D and D/A pacer clocks
1.3.2.28 MODE 27: Perform “N” scans of a block of channels
1.3.2.29 MODE 28: Using the EXP-20
1.3.2.30 MODE 29: Set SSH-4 Flag
1.3.3 SUMMARY OF ERROR CODES . .,. . . . . . . . . . . . . . . . . . . . . . 36
........................................
...........................................
............................................
11 13 16 16
:;: 19
20
2
;i 25 25 26 28 28 29
i;
;‘: 31 33 36
2 2 2 2’ 4 4
7” 7 9
Section 2 DAS-20 PASCAL INTERFACE
2.1 Example Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Section 3 DAS-20 C LANGUAGE INTERFACE
3.1 Example Program. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
39
42
Section 4 DAS-20 FORTRAN INTERFACE
4.1 Example Program.. . . . . . . . . . . . . . . . . . . . . . , . . . . . . . . . . . . . . . . . . 46
45
Section 1
INTRODUCTION
1 .I General Description:
The PCF-20 software package has been developed for Pascal, C, and Fortran programmers wishing to write data acquisition and control software for MetraByte DAS-20, EXP-20 and SSH-4 boards. The PCF-20 is supplied on three disks (one for each language). In addition to the assembly level driver, each disk contains a number of example programs, and a
simple graphics package that may prove helpful in writing display routines.
1.2 Using the PCF-20
Each of the three software drivers supplied in the PCF package are virtually identical to the standard BASIC driver rouitines provided with the DAS-20. The only difference is in the way data and computer control are passed back and forth between the user program and the
assembly driver. Currently there are 30 modes (numbered 0 to 29), and each performs a specific function. Rather than write four redundant descriptions of each mode for each language, this manual refers to the
DAS-20 manual, and specifically Chapter four on programming to describe the funcion of each of the modes. This manual simply describes the syntax and conventions required to excecute one of the 30 modes from Pascal, C, and Fortran. However, as a quick reference guied the modes,
and a brief description of the applicable excecution parameters are listed in the next section.
Different functions of the assembly driver are selected by selecting a Mode.
1.3 DAS-20 Modes
1.3.1 Listing of Available Modes
The following DAS-20 functions are supported by the DAS20.BIN driver:
MODE DESCRIPTION~OF~FUNCTION
0
1
2
Initialize the DAS-20, (Base Address, Interrupt level, and DMA level).
Load the Channel/Gain queuing RAM
View the current Channel/Gain Queuing RAM
-2-
3
Perform a single A/D conversion and load the data into a BASICA variable
4
5
6
7
8
9
10
Perform an “N” conversion scan and store the data in a BASICA array, Sample rate is set by pacer clock or external trigger. and maximum sample rate is about 4000 samples per second.
Perform an “N” conversion scan, and store the data in memory under interrupt control. Maximum conversion rate = 4000 samples/set.
Perform an “N” conversion scan under DMA control. Conversion rate is set by on board pacer clock or by external trigger, Maximum conversion rate = 100,000 Khz
Command a single D/A conversion
: Load memory with D/A conversion data for Modes 9
and 10.
Perform “N” D/A conversions under interrupt control.
Perform “N” D/A conversions, DMA data transfers. Conversion timing from pacer clock or external trigger. Up to 260,000 Conversions per second.
11
12
13
14
15
16
17
18
19
Cancel DMA or interrupt driven operations. Return control completely to program software.
Return current status of DMA or Interrupt driven data transfers.
Transfer data from memory into BASICA arrays. This mode is necessary since interrupt and DMA driven conversions write and read directly from
memory locations without regard variables.
Read the 8 digital input Bits
Write to the 8 digital output bits.
Set Analog trigger mode. This mode can cause any other mode to wait until a certain specified input condition is met before proceeding.
Initialize the Counter/Timer chip
Set the 95 13 counter’s master mode register
Set counter “N” mode register
to BASICA
-3-
20
Set Multiple counter control register
21
22
23
24
25
26
27
28
29
Set Counter “N” load register
Read counter “N” hold register
Measure Frequency with counter timer
Set D/A pacer clock
Set A/D pacer clock
Stop A/D & D/A pacer clocks
Perform “N” scans of a block of analog input channels
Sample Data from EXP-20 board
Set Flag for using SSH-4 accesory board
1.3.2 Mode Parameter Descriptions
The following section provides a much more detailed description of the functions and uses of each of these modes. Arguments marked with marked with ‘<-’ are return values. Any arguments which are not specified, or are marked with the value ‘X’ are don’t care arguments.
‘->’ are values passed to the driver. Those
1.3.2.1 Mode 0: Initialize the DAS-20
Mode 0 sets the DAS-20’s Base Address, DMA channel, and interrupt level. Mode 0 also resets the A/D and sample control queue, sets the input gain to 1X, Bipolar, selects input channel
0, and resets the timer (see initialize timer function). performed before any other “calls” are made to the DAS-20 driver. Trying to execute any other call before executing a Mode 0 call will generate FLAG% =l, Driver not initialized error. example of using Mode 0 is shown in example program EXO.BAS which has been included on the DAS-20 software disk.
On entry the following parameters should be assigned:
MD% -> 0
DIO%(O) -> BASE ADDRESS
DIO%( 1) -> Interrupt Level
DI0%(2) -> DMA channel
FLAG% <-
Error checking flag, the value before the call does not matter
‘Mode 0
‘usually &H300
‘2 through 7
‘1 or3
A mode 0 initialization call must be
An
-4-
The following error codes apply to mode O:-
FLAG% = 0
Error #l will occur if you have specified an I/O address that is less than 512 (Hex 200) or greater than 1008 (Hex 3FO). I/O addresses below Hex 200 are used internally by devices
on the IBM P.C. system board and would always cause an address conflict and I/O addresses
above Hex 3FF are not decoded on the IBM P.C. Error #2 will occur if you have specified a non-valid interrupt level.
correspond to 2 thru 7. Certain of these levels may be in use by other peripheral devices
(especially level 6 used by floppy disk drive). A,list of the standard IBM interrupt assignments is:-
Level 2 ­Level 3 ­Level 4 ­Level 5 ­Level 6 ­Level 7 -
If you do not have a particular device installed, it is safe to assume that that level is available for use by DAS-20. The lower the level number, the higher the interrupt priority. Note that the interrupt will not be enabled unless you enter a mode which requires interrupts for operation. If you are not going to make use of interrupts any level can be chosen e.g. DIO%( 1)
= 2.
=-
1 (mode number out of range, <O or >29)
= =:.
=3 =
-3 (Board not present, I/O address wrong)
Reserved (but not used) by Color Graphics adapter Serial I/O - used if COM2: installed.
Serial I/O - used if COMl: installed.
Printer - may be used by LPT2: if installed.
Always in use by disk drives
Printer - may be used by LPTl: if installed.
(no error, o.k.)
(base address out of range 412 or >1008) (interrupt level <2 or >7) (DMA level not 1 or 3)
The available levels on the P.C. expansion bus
Error #3 is obtained if you specify a DMA level other than 1 or 3. There are 4 DMA levels available on the IBM P.C. (see Appendix E of the DAS-20 Manual), the highest priority is internally used for dynamic memory refresh and is not accessible to the user. The other levels 1 thru 3 are available on the expansion bus, but level 2 is always used by the floppy disk drive(s) and cannot be shared. In hard disk (XT) computers, level 3 may be used by the hard disk, but depending on the design of the disk controller hardware and fixed disk BIOS, may in some cases be available. To determine whether your computer’s hard disk uses level 3, run LEV3.EXE from DOS. In any case level 1 is usually available so if level 3 is used by the hard disk set DI0%(2) = 1. In floppy disk only machines DI0%(2) can be 1 or 3. Also, note that DMA requests and the 8237 controller are not enabled until you enter modes 6 or 10. If you are not using modes 6 or 10, it is irrelevant whether you set DI0%(2) = 1 or 3.
Mode 0 performs several other initializing functions. The Queing RAM sequncer is cleared. The DAS-20 control and timer counter enable registers are cleared, disabling all interrupt,DMA and external trigger functions. as a check on the function and presence of the DAS-20 hardware. If you obtain error -2, it is either indicative of a hardware fault in the DAS-20 or more commonly a discrepancy between the base address specified in DIO%(O) and the actual switch setting on the board.
Mode 0 also performs a simple read/write test
-5-
1.3.2.2 MODE 1: Load the A/D control Queue
Mode 1 allows the channel/gain queue to be loaded one step at a time. All Analog input modes except for Mode 3will get the channel number and input range information from the AfD queue.
The Queue is a 2048 Byte RAM that is used to control the analog input multiplexor (which
selects the input channel sampled) and the input instrumentation amplifier (which selects the input range).
The Queue is loaded using the standard DAS-20 Call in the following format:
MD%-> 1
DIO%(O) -> Channel number (0 to 7 differential
or 0 to 15 single ended.
DIO%( 1) -7 Gain/input range
DI0%(2) -7 Command #
FLAG% c- Error codes
DIO%( 1) Instrument Amplifier Gains and Ranges
Input Range Gain
0 to
+lOV +/- 1ov 0
to +lOV +/- 5v 0 to
+lV +/- .5v 0
to +lOOmV
+/- 50mV
DI0%(2): Command #
Where Command # is 0, 1 or 2. commands are described below:
0 = normal queue entry
1 = last entry, add EOQ flag
2 = first entry, initialize the counters
FLAG%
FLAG% = 0
=-
1 = 11 = 12
Xl x.5 Xl Xl x10 x10 Xl00 x100
Urn/Bipolar DIO%( 1)
Unipolar Bipolar Unipolar Bipolar Unipolar Bipolar Unipolar Bipolar
The available
(no error, o.k.) (mode number out of range, <O or 729) (Gain/Input range out of range) (Command # out of range)
-6-
The first entry (when DI0%(2) is 2) automatically re-initializes the DAS-20 counters, The second and subsequent (DI0%(2) entry (DI0%(2) and reading the sampling
= 1) automatically inserts an EOQ (End Of Queue) bit. An example of loading
Queue has been provided on the DAS-20 software disk.
= 0) entries simply load the queuing RAM, while the final
1.3.2.3 MODE 2: View the current queue
Mode 2 allows the current RAM Queue to be read. When DIO%(2) is 0, the Queue pointer is automatically incremented after the read so that the next read will be of the next Queue location. To reset the Queue pointer to 0, issue the same call with DI0%(2) = 1. An exampleof loading and reading the Queue has been provided in the EXl.BAS program included on the DAS-20 disk.
Arguments:
MD% -7 2
DIO%(O) <- channel number
DIO%(l) c- Gain
DI0%(2) -7 Command # DI0%(2) <- EOQ condition
Where “Command #” operates as follows:
0 = get next queue command 2 = reset and return to first command in the
queue
On Return, DI0%(2) will be:
,O -- End of Queue bit not set
--
1
End of Queue bit set
FLAG% <- Errors
0 = (No Error)
-1 = (Mode # out of Range) 1 = (Gain out of range)
2 = (Command # out of range)
1.3.2.4 MODE 3: Perform a Single A/D Conversion
Initialize the A/D converter, set the channel and input range desired, wait for completion, and return data. Note that this is the only mode that does not perform conversions based on the Queuing RAM.
- 7 -
Arguments:
MD%-7 3
DIO%(O) <-
DIO%(O) -7 Gain/range selection
DIO%( 1) c-7 A/D channel
FLAG% <- Errors
A/D data (0 - 4095 if unipolar)
(-2048 to 2047 if bipolar)
010%(l) ChanneI select data byte
CHANNEL Number
Single Ended
0
1
;
Differential
0
4
5 6 7
t
10
DIO%(O)
0
1
i
4
z
7
8 9
10
::. 13 14 15
DIO%(O) Instrument Amplifier Gains and Ranges
Input Range
0 to +lOV
+/- 1ov
0 to +lOV
+/- 5v
0 to +lV
+/- .5v
0 to +lOOmV +/- 50mV
Gain
Xl
x.5
Xl
EO x10 x100
x100
Uni/Bipolar DIO%( 1)
Unipolar 0 Bipolar Unipolar Bipolar Unipolar
Bipolar Unipolar Bipolar
-8-
1
2 3 4 5 6 7
FLAG% <- Errors (if any)
=
=
-! Hardware error
=­,311
= 32
No Errors
Mode # out of range Gain/input range out of range
Chnnel # out of range (note that if a channel
# between 8 and 15 is entered, and the board
is set to 8 channel Diff operation this error will result
1.3.2.5 MODE 4: Perform N conversions (program control)
Mode 4 performs N A/D conversions and transfers data directly into an array. Since the CPU
is performing the A/D polling and data transfers as a “foreground” operation, exit from the CALL will not occur until all conversions have been completed. However, hitting any key on the keyboard while data is being gathered in mode 4 will abandon futher conversions and produce an immediate return to your program. If you do not want to wait for data to be collected, both modes 5 or 6 can be used to gather the data as a “background” operation so that your program is able to process data and collect it at the same time.
The A/D will perform conversions on channels in accordance with the scan Queue conditions
set in mode 1. When the number of conversions “N” is larger than the number of items held in the Scan Queue, the Queue resets after sampling it’s final entry and begins sampling from Queue address 0 again. If mode 1 has not been entered prior to mode 4, a Flag% error will be returned.
The A/D may be triggered from 2 sources, the programmable interval timer or an external trigger pulse according to DI0%(2). If the programmable interval timer is used, then EXT TRIG acts as a start gate to the operation.
If an external trigger is used, trigger pulses are
applied to EXT TRIG and positive edges start conversions.
On entry the following parameters should be initialized:-
MD% -> 4 (mode number)
DIO%(O) -7 Number of conversions required (Word count).
Range 1 to N where N-l c= array dimension
DIO%( 1) -7 --array pointer
Conversions may be loaded starting at the M’th. position in an array or at the start if M = 0.
DI0%(2) - Trigger source. There are 3 possible:-
-9-
DI0%(2) = 0 : External
Conversions positive transitions on the EXT TRIG input and continue until reached. from the routine cannot take place until pulses equal word count supplied.
DI0%(2) = 1 : Programmable interval timer
with external gating:
sample rate is set via Mode
24. low until you want to conversions. Conversions will begin as soon as EXT TRIG
goes high and continue until EXT TRIG is brought again, or the word count is
reached.
DI0%(2) = 2 : Programmable interval timer
without external gating. The sampling mode is set via Mode
24. on Mode 24 sampling rate) immediately upon excecuting
the Mode 4 call.
EXT TRIG should be held
Sampling begins (based
trigger
take place on
the word count *
!WARNING! - ex?
have
input.
be:
The
start
low
DI0%(3) :
DI0%(3) = 0 : Unipolar data
DI0%(3) = 1 : Bipolar data
Since unipolar (o-4095) and Bipolar (-2048 to +2047) data is in different formats it is necessary to tell the transfer routine which type of data is being used.
scans Bipolar either format can be selected then scaled to the correct form.
conventions are listed below:
Subtract 4096 from Bipolar data transferred in Unipolar mode when Value 7 2047.
Add 4096 to Unipolar data transferred in Bipolar Mode when value < 0.
Data from UNIpolar or Bipolar inputs.
For channel
which include both unipolar
The scaling
and
- lo-
The following error codes apply to mode 4:-
FLAG% = 0 (no error, o.k.)
=
-2 (driver not initialized)
=
-1 (mode number out of range, <O or 729)
= 41
= 43 (trigger mode not 0 or 1)
(number of conversions 0 or negative)
1.3.2.6 MODE 5: Multiple A/D conversions-- Interrupt driven
Mode 5 performs N A/D conversions triggered either externally or by the programmable timer. At the end of each conversion, an interrupt is generated that invokes an interrupt handler
routine installed by this mode. This routine transfers the data from each conversion to a
specified segment of memory and keeps track of the total number of conversions performed. When the number reaches N, as specified by DIO%(O), interrupts are disabled if in the non­recycle mode (DI0%(3)=0), or the process is repeated continuously to the same segment of
memory if DI0%(3) specifies the recycle mode. Note that once mode 5 has enabled interrupts,
conversions continue regardless of what other programs the user may be running (although
they should not interfere either with the location of the DAS20.BIN driver or the A/D data
area). For this reason it is termed a background operation and in most respects is
functionally similar to mode 6 (D.M.A.) although much slower. About 3000 samples/set. are
possible in mode 5.
The A/D will perform conversions on channels in accordance with the scan Queue that must
be set by mode
1. When the number of conversions “N” is larger than the number of items held in the Scan Queue, the Queue resets after sampling it’s final entry and begins sampling from Queue address 0 again.
The A/D may be triggered from 2 sources, the programmable interval timer or an external trigger pulse according to DI0%(2). If the programmable interval timer is used, then EXT TRIG acts as a start gate to the operation. If an external trigger is used, trigger pulses are applied to EXT TRIG, positive edges start conversions.
On entry the following parameters should be initialized:-
MD% -7 5 (mode number)
DIO%(O) = Number of conversions required (Word count).
Range 1 to N, where N can range from 1 to
32766. items in the sample Queue, automatically resets the Queue pointer, and continues sampling.
DIO%( 1) = Segment of
When N is larger than the number of
the program
memory to
receive
data.
- ll-
Loading...
+ 35 hidden pages