XEROX Lisp Users Packages 2 4 1 1 PCDAC 1 4 4 4 By: Michael Herring The Data Translation DT2801-series IBM-PC-compatible analog & digital i/o boards provide an inexpensive analog i/o capacity for the Xerox 1108 with Extended Processor Option (CPE) and BusMaster interface option. These boards provide for analog-to-digital output (A/D), digital-to-analog input (D/A), and digital input/output. DT2801 boards can be mounted in an IBM PC expansion chassis attached to the 1108's BusMaster interface. If the direct memory access capacities of the DT2801 board are to be used, a PC-compatible memory board must also be mounted in the expansion chassis. The PCDAC user package provides a convenient interface between Interlisp-D and one or more DT2801-series boards. The PCDAC package provides a functional-level interface, so that the user need not be concerned with details of the board's command sequences such as command register formats, handshaking, and error diagnosis. The user may instead concentrate on the design of the application, and on data manipulation. The PCDAC package also includes system diagnostic aids. The PCDAC user package uses the BUSMASTER library packages. THE DT2801 SERIES ANALOG AND DIGITAL I/O BOARDS This sketch is intended to be helpful to the casual reader of this document, and to establish context within this document. It is not guaranteed in any way. For details on the DT2801 series boards please consult a current Data Translation DT2801 Series User Manual. The DT2801 series boards are identical except in the resolution of their on-board sampling clock and in details of their A/D subsystems. The A/D subsystems vary in resolution, maximum throughput, choice of gains, whether single-ended inputs are possible, whether unipolar inputs are directly supported, and whether bipolar inputs are encoded as offset or twos-complement. I will sketch the capabilities of the A/D, D/A, and digital i/o subsystems separately. Where the capabilities vary between boards of the series, I give the lower capacity first and the higher capacity or additional alternative in square brackets. A/D There are 8 double-ended input channels [or unipolar, or as 16 single-ended], 10V full-scale, with 12[16]-bit resolution, 4 programmable gain settings from 1 to 8[500]. and maximum throughput of 100Hz [27.5KHz]. Sampling can be triggered by software or by an externally-supplied trigger signal, or clocked either by an externally-supplied clock pulse or by an on-board clock with 2.5[1.25] usec resolution and sampling rate from 3[6]Hz to maximum throughput rate. Input from multiple channels cannot be sampled truly simultaneously. Input is either done one point at a time under direct control of the program, or in block conversions under the control of the sampling clock. In block conversions any consecutive range of input channels can be sampled, but they are sampled round-robin, one per clock. During block input conversions, the board cannot do anything else; in particular it cannot change the output levels on the D/A channels or digital output ports, nor read the digital input ports. Block input conversions can deposit their data directly into RAM memory on the expansion chassis, by direct memory access (dma). A dma buffer must reside entirely within one 64KB memory page. It can be arranged that data be deposited continuously into a circular buffer. Data in the expansion-chassis memory can be transferred to or from the 1108's memory while the block conversion is taking place. See the documentation for the BUSMASTER library package for a details on expansion-chassis dma and on 1108 access to expansion-chassis memory. D/A There are two 12-bit output channels, which can be used separately or with their outputs latched simultaneously. The output ranges of the two channels can be set separately (by jumpers) as up to 10 volts, unipolar or bipolar. Triggering and clock rates are as for the A/D subsystem. As with A/D input, D/A output is done either one point at a time under direct control of the program, or in block conversions under the control of the sampling clock. However, in either case, either one channel is output or both channels are output, latching simultaneously. During block input conversions, the board cannot do anything else; in particular it cannot change the output levels on the digital output ports, nor read the digital input ports or the A/D channels. Dma is handled similar to the A/D subsystem. Digital I/O There are two 8-bit digital i/o ports, each of which can be programmed (independently) to serve as an input port or as an output port. They can be used together as one 16-bit port. Digital i/o, and the setting of the directions of the ports, can be synchronized to an externally-supplied trigger signal. The base i/o addresses for the board's control registers, and the dma channel to be used by the board, are fully jumper-selectable. A screw-terminal i/o panel is available from Data Translation. USER FUNCTIONS As documented in the DT2801 series User Manual, certain commands can be requested to delay their action until the board receives an externally-supplied trigger signal. Those PCDAC worker functions which encapsulate such commands have an optional EXTTRIGGER? argument which, if specified non-NIL, requests this feature. This EXTTRIGGER? argument is not described separately under each function. Miscellaneous Functions (PCDAC.SETCLOCK NTICKS ) Sets the rate of the board's internal clock for subsequent PCDAC.STARTREADA/D and PCDAC.STARTWRITED/A function calls. This function encapsulates the DT2801 series boards' command sequence Set Internal Clock Period. NTICKS is the length of the desired clock period in 2.5 microsecond ticks (1.25 microseconds on a DT2801-A). (PCDAC.SETUPDMA PAGE ADDRESS NPOINTS WRITETOMEM? AUTOINIT?) Sets up a single direct memory access operation in the usual way: one would typically call it once before each call to PCDAC.STARTREADA/D or PCDAC.STARTWRITED/A with DMA? non-NIL. PCDAC.SETUPDMA masks the dma channel PCDAC.DMACHANNEL, loads that channel's mode, address, and transfer-count registers, and finally unmasks it. PCDAC.SETUPDMA presumes that BUSDMA.INIT has been called. PAGE is the high 4 bits and address the low 16 bits of the 20-bit base address of the dma buffer in the external-bus memory. NPOINTS is the number of 16-bit data points to be transferred (minimum 1, maximum = default = 32768). WRITETOMEM? specifies the direction of the transfer: NIL for PCDAC.STARTWRITED/A, non-NIL for PCDAC.STARTREADA/D. AUTOINIT? is NIL if the dma controller is to stop honoring dma requests when NPOINTS data points have been transferred; it is non-NIL if the dma buffer is to be used as a circular buffer, with address and transfer-count registers automatically reinitialized every NPOINTS data points; in this latter case the dma controller does not of itself stop honoring dma requests. See the documentation for the BUSMASTER library package for more details. PCDAC.IOADDRESS A global variable which determines the i/o addresses the PCDAC functions will use for the DT2801 series board. Initially 2EC(hex). Must be SETQed equal to the data register i/o address set by jumpers on the DT2801 series board, if different. PCDAC.DMACHANNEL A global variable which determines the dma channel number that PCDAC.SETUPDMA will use. Initially 1. Must be SETQed equal to that set by jumpers on the DT2801 series board, if different. A/D Functions The argument GAINCODE in the following functions encodes the analog input gain: GAINCODE gain on DT2801xxx board gain on DT2805xxx board 0 1 1 1 2 10 2 4 100 3 8 500 (PCDAC.READA/DIMMEDIATE GAINCODE CHANNEL EXTTRIGGER?) Performs a single A/D conversion on the channel at the analog input gain encoded by GAINCODE (described above), returning the result as a positive integer. This function encapsulates the DT2801 series boards' command sequence Read A/D Immediate. (PCDAC.SETA/DPARAMETERS GAINCODE STARTCHANNEL ENDCHANNEL NPOINTS) Determines several parameters for subsequent PCDAC.STARTREADA/D function calls. GAINCODE encodes the analog input gain settting, as described above. The channels from STARTCHANNEL to ENDCHANNEL inclusive are scanned cyclically, one channel being sampled at each clock. (ENDCHANNEL defaults to STARTCHANNEL.) NPOINTS is significant only if the PCDAC.STARTREADA/D function is called with CONTINUOUS?=NIL; then it is the number of A/D conversions (one channel each) to take place during that Read A/D command (minimum = 3, maximum = default = 65535). This function encapsulates the DT2801 series boards' command sequence Set A/D Parameters. (PCDAC.STARTREADA/D DMA? CONTINUOUS? EXTCLOCK? EXTTRIGGER?) Initiates a scan of clocked A/D conversions on the channels and at the input gain specified in the last PCDAC.SETA/DPARAMETERS function call. If DMA? is specified non-NIL then the 16-bit data values will be deposited in external-bus memory by direct memory access according to the last PCDAC.SETUPDMA's NPOINTS; otherwise the data must be input a point at a time with PCDAC.READA/DDATUM. If CONTINUOUS? is specified non-NIL then A/D conversions will take place until a Stop command is issued to the DT2801 series board; otherwise the number of conversions that takes place is governed by the last PCDAC.SETA/DPARAMETERS call. If EXTCLOCK? is specified non-NIL then conversions are clocked by an external signal supplied to the board; otherwise the board's internal clock is used, at the clock rate specified in the last PCDAC.SETCLOCK call. This function encapsulates the DT2801 series boards' command sequence Read A/D With DMA and, with PCDAC.READA/DDATUM, the command sequence Read A/D. Note that, when PCDAC.STARTREADA/D is called with DMA? specified non-NIL, both the Read A/D command and the dma operation can have had word counts specified, or either or both can have been specified to have no effective word count. The hardware treats the two counters completely separately. The simplest thing is to specify both word counts the same and to call PCDAC.SETUPDMA before each PCDAC.STARTREADA/D call. However exotic results, some of them quite useful, can be got with other combinations. Again, see the documentation for the BUSMASTER library package. (PCDAC.READA/DDATUM) Inputs individual data points during a Read A/D command started by PCDAC.STARTREADA/D with DMA?=NIL. The datum is returned as a positive integer. Coordination with PCDAC.SETA/DPARAMETERS' NPOINTS and with the clock may be required; the functions PCDAC.READYFORCOMMAND? and PCDAC.READYFORREAD? may be of use in this. Note that the "Read A/D" command sequence described in the DT2801 series User Manual actually corresponds to PCDAC.STARTREADA/D plus one PCDAC.READA/DDATUM. D/A Functions (PCDAC.WRITED/AIMMEDIATE DACSELECT DATUM SECONDDATUM EXTTRIGGER?) Performs a single D/A conversion on DAC channels 0, 1, or both simultaneously (as DACSELECT is 0, 1, or 2). If only one channel is selected, then the less significant bits of the integer DATUM goes to that channel, and SECONDDATUM is ignored if present; if both channels are selected, then DATUM goes to channel 0 and SECONDDATUM to channel 1. This function encapsulates the DT2801 series boards' command sequence Write D/A Immediate. (PCDAC.SETD/APARAMETERS DACSELECT NPOINTS) Determines two parameters for subsequent PCDAC.STARTWRITED/A calls. DACSELECT determines whether output is to channel 0 only, channel 1 only, or both channels simultaneously (as DACSELECT is 0, 1, or 2). If DACSELECT is 2, then data are output in pairs, the first datum of each pair going to channel 0 and the second to channel 1. NPOINTS is significant only if PCDAC.STARTWRITED/A is called with CONTINUOUS?=NIL; then it is the number of D/A conversions (one or both channels) to take place during that Write D/A command (minimum = 3, maximum = default = 65535). This function encapsulates the DT2801 series boards' command sequence Set D/A Parameters. (PCDAC.STARTWRITED/A DMA? CONTINUOUS? EXTCLOCK? EXTTRIGGER?) Initiates a scan of clocked D/A conversions on the DAC or DACs specified in the last PCDAC.SETD/APARAMETERS call. If DMA? is specified non-NIL then the 16-bit data values will be read from external-bus memory by direct memory access according to the last PCDAC.SETUPDMA call; otherwise the data must be output a point at a time with PCDAC.WRITED/ADATUM. If CONTINUOUS? is specified non-NIL then D/A conversions will take place until a Stop command is issued to the DT2801 series board; otherwise the number of conversions that takes place is governed by the last PCDAC.SETD/APARAMETERS' NPOINTS. If EXTCLOCK? is specified non-NIL then conversions are clocked by an external signal supplied to the board; otherwise the board's internal clock is used, at the clock rate specified in the last PCDAC.SETCLOCK call. This function encapsulates the DT2801 series boards' command sequence Write D/A With DMA and, with one or two PCDAC.WRITED/ADATUM calls, the command sequence Write D/A. Note that, when PCDAC.STARTWRITED/A is called with DMA? specified non-NIL, both the Write D/A command and the dma operation can have had word counts specified, or either or both can have been specified to have no effective word count. The hardware treats the two counters completely separately. The simplest thing is to specify both word counts the same and to call PCDAC.SETUPDMA before each PCDAC.STARTWRITED/A call. However exotic results, some of them quite useful, can be got with other combinations. Again, see the documentation for the BUSMASTER library package. (PCDAC.WRITED/ADATUM DATUM) Outputs individual data points during a Write D/A command started by PCDAC.STARTWRITED/A with DMA?=NIL. The less significant bits of the integer DATUM are output. If both DACs are being written to, then pairs of data points must be output, with the first point of each pair going to DAC 0. Coordination with PCDAC.SETD/APARAMETERS' NPOINTS and with the clock may be required; the functions PCDAC.READYFORCOMMAND? and PCDAC.READYFORWRITE? may be of use in this. Note that the "Write D/A" command sequence described in the DT2801 series User Manual actually corresponds to PCDAC.STARTWRITED/A plus one or two PCDAC.WRITED/ADATUM calls. Digital I/O Functions (PCDAC.SETDIGITALINPUT PORTSELECT EXTTRIGGER?) Configures digital i/o ports 0, 1, or both (as PORTSELECT is 0, 1, or 2) to accept digital inputs. This function encapsulates the DT2801 series boards' command sequence Set Digital Port For Input. (PCDAC.SETDIGITALOUTPUT PORTSELECT EXTTRIGGER?) Configures digital i/o ports 0, 1, or both (as PORTSELECT is 0, 1, or 2) to provide digital outputs. This function encapsulates the DT2801 series boards' command sequence Set Digital Port For Output. (PCDAC.READDIGITALIMMEDIATE PORTSELECT EXTTRIGGER?) Reads digital input from digital i/o ports 0, 1, or both. If PORTSELECT is 0 or 1 then one byte of data is read (from port 0 or 1) and returned as a small positive integer. If PORTSELECT is 2, then two bytes of data are read simultaneously (one from each port) and returned as a 16-bit positive integer, with the port 1 data as the more significant byte. The ports selected must of course currently be set for input. This function encapsulates the DT2801 series boards' command sequence Read Digital Input Immediate. (PCDAC.WRITEDIGITALIMMEDIATE PORTSELECT DATUM EXTTRIGGER?) Writes digital output to digital i/o ports 0, 1, or both. If PORTSELECT is 0 or 1 then one byte of data is written (to port 0 or 1), namely the least significant 8 bits of the integer DATUM. If PORTSELECT is 2, then two bytes of data are written simultaneously: the least significant 8 bits of the integer DATUM are written to port 0 and the next less significant 8 bits are written to port 1. The ports selected must of course currently be set for output. This function encapsulates the DT2801 series boards' command sequence Write Digital Input Immediate. (LIST ((PAGE NIL NIL (0 0 612 792) ((FOLIO NIL (PARALOOKS (QUAD CENTERED) CHARLOOKS (SUPERSCRIPT 0 SIZE 10 FAMILY HELVETICA OVERLINE OFF STRIKEOUT OFF UNDERLINE OFF SLOPE REGULAR WEIGHT MEDIUM)) (282 42 72 36) NIL) (HEADING NIL (HEADINGTYPE BOO) (84 744 444 36) NIL) (TEXT NIL NIL (84 96 456 600) NIL))) (PAGE NIL NIL (0 0 612 792) ((FOLIO NIL (PARALOOKS (QUAD CENTERED) CHARLOOKS (SUPERSCRIPT 0 SIZE 10 FAMILY HELVETICA OVERLINE OFF STRIKEOUT OFF UNDERLINE OFF SLOPE REGULAR WEIGHT MEDIUM)) (282 42 72 36) NIL) (HEADING NIL (HEADINGTYPE BOO) (84 744 444 36) NIL) (TEXT NIL NIL (84 96 456 600) NIL))) (PAGE NIL NIL (0 0 612 792) ((FOLIO NIL (PARALOOKS (QUAD CENTERED) CHARLOOKS (SUPERSCRIPT 0 SIZE 10 FAMILY HELVETICA OVERLINE OFF STRIKEOUT OFF UNDERLINE OFF SLOPE REGULAR WEIGHT MEDIUM)) (282 42 72 36) NIL) (HEADING NIL (HEADINGTYPE BOO) (84 744 444 36) NIL) (TEXT NIL NIL (84 96 456 600) NIL))))) È TÈ È $l È ŠŠ8ŠŠ8 4ŠŠ8ŠŠ8ÈÈÈ PAGEHEADINGBOOHÔ HELVETICA  HELVETICALOGO HELVETICA HELVETICA  TIMESROMAN    HRULE.GETFN HELVETICA HRULE.GETFN HELVETICA HRULE.GETFN HRULE.GETFN HELVETICA HRULE.GETFN HELVETICA HRULE.GETFN HRULE.GETFN HRULE.GETFN HELVETICAGÛ<0 uøÑ%Ü- 2„?ŒFAµÌô½ P9  9øFƒ@P•;Ü F¶-’A2©>1Æ2É6 >2  >dzz¹