Introduction
General Features
Timing Features
Analog Input Features
Analog Output Features
Digital Input Features
Digital Output Features
System Requirements

LabPac is a software support system designed for use with Scientific Solutions' DAS series interfaces, Lab Master DMA, Lab Master, Lab Tender, DADIO, and Base Board. LabPac software provides solutions for multiple needs, such as event counting, precision timing, digital input, digital output, analog input, or analog output. Repeatable functions, such as multiple sampling of analog inputs can be done using a hardware interrupt.

LabPac offers access to, input from, and control over laboratory/industrial instruments using high level languages. Because LabPac installs as a software interrupt, application programs can be developed in languages such as Advanced BASIC, FORTRAN, C, Pascal, APL, or Assembler. It replaces customized machine language programming with a library of powerful routines. The following is a brief description of many LabPac features.

General Features

Timing Features

Analog Input Features

Analog Output Features

Digital Input Features

Digital Output Features

SYSTEM REQUIREMENTS

1.) One or more of the following Scientific Solutions Boards

2.) DOS*or DOS session of Win31, Win95/98 *

3.) Minimum of 96 KB free system memory
 

*LabPac for DOS (this version) is for true DOS or compatilbe DOS session of Win31, Win95/98

*LabPac for Windows is for Win95/98 and WinNT operating as a 32-bit application (requires Scientific Solutions 32-bit driver for your hardware)

*LabPac for Linux is available for native Linux applications (requires Scientific Solutions Linux driver for your hardware)
 

return to top of Introduction


Installation

HARDWARE REQUIREMENTS
  Hardware Interrupt Handler
  9513A Timer/Counter
  External Signal
  External Triggers
  Digital I/O Handshaking
  Timer Sources
  DMA
SOFTWARE INSTALLATION
  Organization of the Diskette
  Copying Files
INSTALLING LABPAC IN MEMORY

 


LabPac is a software driver for Scientific Solutions hardware. Its function is to provide streamlined BIOS routines which facilitate the data acquisition and process control features on a McDAS, Lab Master DMA, Lab Master, Lab Tender, DADIO or Base Board. Information in this section explains features of LabPac. This is critical background information and should be read carefully before doing any programming.

LabPac is essentially a library of subroutines. It is, however, loaded and accessed differently than traditional libraries. For most compilers, libraries are set up as specialized files from which modular subroutines are loaded into a main program using the compiler's LINK utility. The main portion of LabPac, however, is a program that loads into the background and becomes memory resident in the computer. Once LabPac is loaded or run, it will be actively available to any application software until the computer is turned off or reset.

LabPac is structured to become an extension of DOS. Because it is a BIOS extension, it can be accessed by any language that runs under DOS. As a software driver, LabPac contains numerous subroutines that are divided into eight groups:

return to top of Installation


HARDWARE REQUIREMENTS

LabPac can maximize the normal data acquisition or process control functions on a Scientific Solutions Data Acquisition and Control interface. To use the default features on the hardware products effectively, follow the installation instructions in the manual provided with each product. Once one of the Scientific Solutions products is installed, LabPac will not require a board to be reconfigured unless a new application is designed using hardware features left uninstalled.

Scientific Solutions laboratory/industria1 products have many options. LabPac will require the use some of these options and support the use of others. Before installing any hardware, look over the following options to see if they will be useful in the application.


Hardware Interrupt Handler

Operating systems other than DOS have the ability to do multiple tasks in a shared environment. This means that two or more programs can be running simultaneously. DOS does not have this capability. It does allow for the program that is currently running to be interrupted so another program can run. Some LabPac features use this capability. This means that data collection or process control functions can be done at regulated intervals while the main program is involved with other tasks.

In order to use this capability, a hardware interrupt (IRQ) must be installed. Hardware interrupts used by LabPac can be generated from several sources. Normally timer/counter channel 1 is the IRQ source.

Since the interrupt handler is driven by a hardware IRQ, the designated timer/counter output must be connected to the proper IRQ line on the PC bus. Make sure that the chosen IRQ either has nothing else on it or that the other peripheral is tri-stated on the IRQ line. For example, most LabPac users will select IRQ7 for this feature. IRQ7 is also attached to the printer ports in the PC. Original IBM equipment and many other computers or printer port peripherals tri-state IRQ7 so peripherals such as Lab Master DMA can also use the line. However, if the printer port is not tri-stated, then no other equipment can share the line. If there are problems with sweep routines after installing LabPac, try using another IRQ line.


9513A Timer/Counter

When using a Lab Master DMA, Lab Master or Lab Tender the 9513A counter 1 is the usual interrupt source. Install the following features on your board to implement this source.


External Signal

To control the interrupt from outside the computer (e.g., a function generator) connect your signal to a 9513 source line and connect the timer to one of the interrupts. When running SWINIT, identify the IRQ line and timer channel used. You will need to start the timer using TIST or TIHDW with the proper source indicated. The external signal must have a minimum pulse width of 70 nS.


External Triggers

Analog to digital conversions on the DAS series, Lab Master DMA, Lab Master, and Lab Tender can be triggered using a hardware generated TTL signal instead of the default software generated signal. LabPac offers subroutines (AIHDW and AIDMA) which require this hardware signal.


Digital I/O Handshaking

LabPac contains several subroutines where the 8255A Mode 1 can be used. Mode 1 is designed for handshaking, i.e. external devices that send an independent signal to inform the receiver that the eight bits of data are coming. These devices usually require a return signal to let them know more data can be sent. Conversely, when sending data, these devices require an independent signal to know when data has arrived and return an acknowledgement signal when they have cleared their input buffer.

Mode 1 requires that handshaking fines be installed between the board and the external equipment. Thoroughly read the requirements for using Mode 1 in the hardware installation manual. If a strobed input mode is used, it is likely that the Input Buffer Full signal (a busy or acknowledge line) should be inverted. Each Scientific Solutions product has a jumper block set aside to invert the lines used for the Input Buffer Full signal. The technical discussion of the DINIT call in the Technical Reference chapter indicates which handshaking lines between the external device and the Scientific Solutions product must be installed.


Timer Sources

LabPac offers timing subroutines where an external source can be used to drive the 9513A counters. This feature can be used to count external events. It can also be used where timing periods not available from the onboard oscillator must be used. Additionally, the LabPac timer/counter features allow the use of gating on external sources. If these feature are used, carefully read the instructions for installing inputs to the external connectors of each board.

NOTE: The outputs from each 9513A counter can also be used to send information to external devices.


DMA

The McDAS series and the Lab Master DMA feature Direct Memory Access (DMA transfer) for the transfer of analog to digital information directly into RAM. One LabPac routine (AIDMA) uses the DMA feature to move the data into a memory buffer in a true background operation.

return to top of Installation



SOFTWARE INSTALLATION

The LabPac software package contains the software needed to develop application programs in any supported target language.
 

Organization of the Diskette

The LabPac distribution software contains the files necessary to support several high levels languages. In order to limit the number of files to take a look at, the LabPac software contains separate subdirectories for each language supported. The only files you need to look at are those in the root directory and those in the particular subdirectory that supports the desired programming language. Some directories may be compressed into a single file. You will have to uncompress the directory to use the files.

LABPAC Organization (typical)

APL <DIR>
ASSEMBLE <DIR>
BASIC <DIR>
C <DIR>
FORTRAN <DIR>
PASCAL <DIR>
TOOLS <DIR>
README  
LABMENU.EXE  
LABPAC.COM  

The file named LABPAC.COM is the most important file on the diskette. It is the device driver containing the subroutines to be used in the application.

Before the programs will work, this memory resident program must be loaded.

This is done very simply by typing in the command shown below or by placing the command line in an AUTOEXEC.BAT file.

LABPAC

The file named LABMENU.BAS is a menu driven demonstration and test program. It is written in Interpreted BASIC. The Tools chapter discusses how the program operates.

The file named README will contain up-to-date information on LabPac that supplements or extends the information in this manual.

The names with the <DIR> after them are subdirectories. The subdirectories contain interface modules and example programs for different languages.

In each of the language subdirectories there is one or more header files, such as LABHEAD.???, where the ??? extension refers to the application language. These files contain code to be used at the start of a program. Four types of variables are defined in each header file.

Files with .OBJ extensions are used by some compiled languages to access assembler subroutines or memory resident programs. These are used by languages such as FORTRAN, Compiled BASIC, or C. These object modules are designed so that an application program can pass information correctly to and from LABPAC.COM.

NOTE: The assembler listings for all the object modules are contained in the ASSEMBLE subdirectory. They are provided as references if an object module needs modification for a language not directly supported on the LabPac diskette.

The two files labeled LABPAC are special library interface modules which work the same as the files with the .OBJ extension.

The other files in the subdirectory are demonstration programs. They provide examples of how to use LabPac subroutines with associated language.


Copying Files

Copy the files from the LabPac diskette to your working directory. You may need to decompress some of the files.

return to top of Installation



INSTALLING LABPAC IN MEMORY

Before any application programs make calls to LabPac, it must be made memory resident. To install LabPac in memory type LabPac at the DOS prompt. This will look something like the following:

C> labpac

LabPac Version x.xx Copyright 1981-2020 by Scientific Solutions

C>
 

It is recommended that you put LabPac as a line in your AUTOEXEC.BAT file. For use under operating systems that have a DOS session, such as Win95/98, if you put the LabPac line in the AUTOEXEC.BAT file, then it should be available under all DOS sessions.

Several command line options are available to change characteristics of LabPac. These options are:


Parameter values are considered to be entered in decimal unless preceded by zero in which case they will be considered in hexadecimal.

For example, for 256 analog input channels and a Basic vector of 0F2H use the following:

C> labpac /ai256 /b0f2

return to top of Installation


Interface Conventions
DRIVER ACCESS
  Call Format
  Interrupt Format
INITIALIZATION
VARIABLES
DATA ARRAYS
DATA FILES

DRIVER ACCESS

Each subroutine will be referred to as a "Function" or "Call." These terms reflect that LabPac subroutines can be accessed in two ways depending on the language used. Assembler programmers and others who use software or BIOS interrupts, will recognize the term "Function" to indicate a specific subroutine contained in the interrupt service routine. BASIC, FORTRAN and C programmers will recognize the term "Call" to indicate an external program or subroutine written in languages such as assembler or C to be used by their main program.


Call Format

While the format of a call (i.e., where variables or parameters are placed in the command line) varies in the different languages supported by LabPac, they all have four things in common. These are the label "labpac", a variable to return error codes or data, variables to pass parameters, and a name for each call.

Each language uses the reserved label "labpac" within every call. In Interpreted BASIC, the label is the value of a memory location within the resident portion of LabPac. At this location is a subroutine to recover the information BASIC saved while executing the call statement. This information is passed to the LabPac function being called. In FORTRAN, Compiled BASIC, or C the label refers to a subroutine found in the interface (OBJ) module. This module is incorporated into the application by the LINK utility. The function of the external call is to take the parameters from the C, Compiled BASIC or FORTRAN statement and save them on the stack. The interface module finds the saved information and places it in the registers required by the memory resident portion of LabPac. The module then calls LabPac using the intermpt format. On return from LabPac, an error code or data is placed in the proper variable and control is returned to the main program.

The variables, constants, or parameters used within the call format contain information for LabPac. The required variables are listed and explained under each function in the Technical Reference chapter.

LabPac returns information on every call. LabPac structure requires the inclusion of a variable to return error codes or sampled data. In this manual, the name "RESULT' is used for this variable. All error codes return as two-byte integers with the most significant bit set high. All data returns as two-byte integers with eight to sixteen bits of accuracy.

Every function has a name. While each function can have a different name, it is best to use the pre-assigned names to avoid confusion. In all references to calls in this manual, the function name is constant across languages. The assigned name is paired with a constant value (function number) which LabPac uses to identify the correct subroutine. The Technical Reference chapter contains a complete list of LabPac commands with a brief description of their function. For example, AISWST (Analog Input Sweep Starts) starts a timed hardware interrupt routine to collect samples from a set of analog inputs.


Interrupt Format

Certain languages do not allow linkable object modules. For these languages, use the software interrupt capability that the language provides. Software interrupt functioning includes filling a set of special registers, calling the interrupt, and checking the return value. First, the registers are filled with the proper parameters. Each function in the Technical Reference chapter documents which registers go with which variables. Second, the interrupt is called using the INT command or its equivalent. Finally, the AX register will return with the error codes or valid data. Check this value to insure the success of a call.

return to top of Interface Conventions



INITIALIZATION

LabPac contains several internal variables and tables which must be initialized before data acquisition and process control features can be used. Initialization is handled by the RESET, AIINIT, AOINIT, DINIT, TIINIT, and SWINIT routines. LabPac is modularly constructed so only those features you intend to use need to be initialized. This allows for a simpler internal structure and enhanced operation of the device driver. Initialization of resources must occur before they can be used.

The initialization process installs internal tables, and when necessary configures hardware. The default internal table sizes are as follows:

Table Name

Default Channels

Analog Input Channel Table

16 

Analog Output Channel Table

Digital Input Channel Table

Digital Output Channel Table

Timer/Counter Channel Table

On PS/2 Micro Channel computers, initialization occurs automatically when LabPac is installed.

return to top of Interface Conventions



VARIABLES

Most variables used within LabPac are two-byte integers. All analog or digital data that is either sampled from or written to the hardware are two byte integers in two's complement form. The form and range for data found in variables or cells of data arrays is shown in the table below.

Resolution

Range

16 bit 

-32,768 to +32,767 

12 bit 

-2048 to +2047 

8 bit 

-128 to +127 

Use the factory default jumpering on Scientific Solutions hardware as LabPac takes care of any offsets or justifications based on these defaults. On the Lab Master DMA or Lab Master the analog inputs can be jumpered for a unipolar input range. The best A/D converter output format to use is binary. The range of the analog input data on return from LabPac will be 0 to 4095.

LabPac has two functions requiring a filename. Each uses one string variable to pass that file name. These are the only exceptions to the use of integer variables. All variables are discussed in the Technical Reference chapter under each function.

return to top of Interface Conventions



DATA ARRAYS

Two types of data arrays are used by LabPac. The first type, used to store information such as a set of channel numbers or maximum rate data, are one-dimensional, 2-byte, integer arrays. These are simple to use because all the cells are contiguous in memory and can be found by identifying the correct cell.

The second type of array is a two-dimensional, two-byte, integer array, used to store data. Normally it is dimensioned as the number of sweeps by the number of channels. However, many languages transpose this order. Check the array dimension information for your language in the Using BASIC chapter through the Languages with Software Interrupts chapter.

In memory, the data would be arranged contiguously so that the data for all the channels on any one sweep were together. An example of nine sweeps by six channels, the samples for the six channels for sweep number one would be in the first six locations in memory. They would be followed by the six samples for sweep number two. The last six samples would be for sweep number nine.

For languages such as C or assembler, the data arrays are dimensioned as they appear in memory. However, care must be taken with Interpreted BASIC or FORTRAN. These languages dimension their arrays different from C. Instead of sweeps by channels, BASIC and FORTRAN use channels by sweeps. Make sure these are in the correct order or some very interesting data will appear.

return to top of Interface Converntions



DATA FILES

LabPac can save data into ASCII or binary files. ASCII files are in a standard format recognized by major database software or statistical/graphics packages. Binary files provide for efficient use of disk storage space and are recognized by most statistical packages.

Up to 20 files can be opened at one time from within LabPac. If more than eight files are to be open at one time, modify the DOS internal FILES parameter to recognize the number of files to be used. Shown below is an example of using the FILES command in the CONFIG.SYS file. This file is found on the diskette or the hard drive used to reset the system (see the DOS manual).

FILES = 20

Files in LabPac can be opened for either read or write operations. These two operations, however, cannot be done simultaneously on the same file. If a file is open for saving data (writing), then the same data cannot be read back from that file until it has been closed and then reopened for reading. The same holds for files opened for reading. They also must be closed before new data can be overwritten to them.

When a LabPac file is opened for saving data, more than one data buffer can be saved even though the data is collected at different times. The additional data is appended to the end of the file. This includes the channel and sweep header information. Once a file is closed, no new data can be added to it via LabPac. When that closed file is re-opened for writing it will be cleared of its contents.

Each binary file contains the data from the channel array entered as two byte integers followed by the values from the data array as two byte integers.
 

return to top of Interface Conventions


Developing an Application
INSTALLING LabPac IN MEMORY
GENERAL CONSIDERATIONS
  Program Structure
  Control Parameter Setup
  Initialization
  Main Program
  Subroutines or Procedures
  Exit Routine

As a software driver, LabPac provides streamlined BIOS routines which facilitate the data acquisition and process control features on various Scientific Solutions products including the MC-DAS series, Lab Master series, Lab Tender series, DADIO, and Base Board products. Information in this chapter concerns the installation of LabPac and putting together an application to access the memory resident driver.
 

INSTALLING LabPac IN MEMORY

The main portion of LabPac is a program that becomes memory resident in the computer. LabPac is accessed directly through a BIOS level software interrupt. LabPac has command information and data pointers passed to its internal functions without passing through DOS. Data is sent to the driver a block at a time, thus lowering the overhead and increasing speed.

Once LabPac is installed, it will be actively available to any application program running under DOS until the computer is turned off or reset. The difference between LabPac and a library is that a program only needs to link in the interface module and not the entire body of LabPac code. This cuts down on the size of the code within the application program. Each function of LabPac is accessed through the same subroutine within the interface module. A command parameter within the Call to the interface determines which function is executed.

The driver program, LABPAC.COM, is installed by entering the program name at a DOS prompt, or by adding the line in the AUTOEXEC.BAT file (see the Installation chapter for details).

When LabPac installs, it becomes memory resident with an address pointer placed in the reserved location for software interrupt 66 hexadecimal (INT66H vector). INT66H is an interrupt vector set aside for user supplied applications. More than one application may use this vector. See the Interrupt Service Structure chapter for additional technical information on how LabPac works.

There is a utility program in the TOOLS subdirectory that provides feedback on Calls made to the LabPac driver. The program, CATCH, is useful during the development stage of an application. CATCH will intercept the software interrupt, report on the LabPac function being called, and return status information on the success of the Call. This information is written to the display for convenience during debugging. See the Tools chapter for details on using CATCH.

return to top of Developing an Application



GENERAL CONSIDERATIONS

Developing Data Acquisition & Control applications using LabPac is relatively straight forward. Using the Call or software interrupt methods from different languages is documented in their user manuals. The Using BASIC, Languages with Interface Modules, and the Languages with Software Interrupts chapters of this manual provide LabPac specific details for different supported languages.

Often the most perplexing aspect of Data Acquisition & Control applications is interpreting the design requirements into a software controlled interface. It is useful to map out the different stages of the application in a flow chart before developing the software. This will clarify the needs for acquiring data, data storage, statistics, data transformations, and graphics. Once these needs are blocked out, the different modules of the application software can be developed. The information contained in the rest of this chapter is general, oriented to developing the overall application.


Program Structure

While every application is different, each program will have the same general structure. When developing the application, use the following procedure as a guideline:


Control Parameter Setup

In some languages variables or labeled constants are required as Call parameters, while other languages make the definition of variables/constants optional. Start the program by defining the LabPac command constants and error code labels. This information is contained on the LabPac software in header files named LabPac.???. There is a header file for each supported language. Most languages have an easy method for including header files in the program. Instructions are included for each language in the Using BASIC, Languages with Interface Modules chapters, to the Languages with Software Interrupts chapter.

Define, dimension, or equate all constants, variables, string variables, and data arrays before executing any calls to LabPac. Some languages, such as Interpreted BASIC, have dynamic workspace allocation. When background programming is used while new variables, etc, are being defined, data will probably end up in the wrong location. By setting up all constructs at the start of the program, the required workspace is defined and becomes constant.

Many LabPac functions require data arrays or channel arrays. From the data requirements for the application the size of the arrays can be determined. The space to be used for the arrays should be allocated at this point in the program. If it can be determined, make sure data arrays used in DMA Calls are on segment boundaries.

If data files are going to be used with LabPac functions, the string space used for the file names should be allocated at this point in the program.


Initialization

LabPac contains several internal tables which must be initialized before data acquisition and process control features can be used. LabPac is modularly constructed so only those features you intend to use need to be initialized. This allows for a simpler internal structure and enhanced operation of the device driver.

The initialization process installs internal tables and configures some hardware features. The initialization functions identify key dimensions of Scientific Solutions hardware features used to construct the internal tables. To clear the memory resident driver of previously installed hardware information, use the RESET command as the first initialization routine.

Follow this with installation of the analog I/O, digital I/O and timer/counter features (AIINIT, AOINIT, DTNIT, TIINIT). The initialization routines can be called several times for multiple boards. On the first Call, the first channel will be assigned the value zero and the rest of the channels assigned consecutive numbers. After the first Call, subsequent channels will be assigned numbers starting from the last channel number assigned. For example using AIINIT, assume two Lab Masters and one Lab Tender are in the same system. If the first Call is for the Lab Master with eight differential channels, its eight channels will be assigned to channels zero through seven. If the second Call is for the Lab Tender with 32 single-ended channels, they will be assigned channels eight through 39. Finally the third Call is for the Lab Master with 64 single-ended channels. The channels will be assigned numbers 40 through 103.

If background interrupt-driven processes will be used, place the TIST and SWINIT functions in the next subroutine. See the LABMENU.BAS example program provided with the LabPac software.


Main Program

The main body of application code follows. This section will take many forms. For short programs, it will contain the code in the order it will be executed. For long programs it will more likely take the form of a series of calls to subroutines or proceedures with logical decision code between calls. Each subroutine may be used multiple times.


Subroutines or Procedures

Commonly used subroutines can include data collection, output control, trigger detection, interactive screen displays, error messages, graphics routines, statistics routines, or data transformations. The common thread of these routines is that they are used more than once in the application. Placing them in a subroutine saves workspace and simplifies the overall code used in the program.

Many applications can have some form of error detection and processing procedure. When an error is detected, a subroutine should be available to process the message and execute some qualifying procedure.


Exit Routine

The exit routine should close all files opened or created by LabPac. If EMS memory was used, the buffers allocated to LabPac should be returned to the Memory Manager using the FREE function. It is a good idea to end the program with a RESET Call.
 

return to top of Developing an Application


 Techniques
FOREGROUND PROCESSES
  RAW Calls
  Setting Up Arrays
  Sampling Sets of Channels
  Using EMS Memory
  Software Triggers
  Digital Trigger
  Timed Trigger
  Analog Trigger
  Peak Detection
  Controlling Hardware Interrupts
  Saving Time of Day
HARDWARE PROCESSES
  Counting/Timing Events
  Simple Hardware Triggered ADC
  Burst Mode ADC
  Simultaneous Analog I/O
  Tracking DMA Transfers
BACKGROUND PROCESSES
  Background Sweeps
  Calculating Interrupt Timing
  Use of STATUS Calls
  Pre/Post Sampling

 

The intent of this section is to discuss with examples several techniques for using LabPac routines to develop complete applications. The section is divided into three parts. The first part deals with processes that occur completely in the foreground. These routines proceed in a stepwise fashion with the main program stopping to finish each task before proceeding. The second part deals with hardware triggered processes, These routines have specific hardware requirements that must be in place for the functions to work. The final part deals with background/foreground processing. These techniques coordinate hardware triggered functions with regular foreground tasks.

FOREGROUND PROCESSES

Foreground processes are any subroutines that start and complete a task before returning control to the main program.


RAW Calls

The most elementary function that is performed is to set a channel to a value or to read a single value from a channel. These are known collectively as RAW Calls. Each routine simply transmits a given value or returns the current data value on the channel. AIRAW, DIlIAW, and TIRAW will return the current value on the specified input channel. These Calls are useful when one sample from one channel is required. For example, a calibration routine for the analog input could use the AIRAW Call to sample current data and then report the value to the display while adjustments are being made to the ADC. This might look something like the following:

600 CHAN = 0

610 CALL LABPAC(CHAN, IVAL, AIRAW)

620 RVAL = IVAL / 204.8

630 LOCATE 10,20: PRINT "RAW DATA = "; IVAL; "VOLTAGE = ";RVAL

640 A$ = INKEY$

650 IF A$ = "" GOTO 610

AORAW and DORAW will send one sample to the analog or digital output channel without preserving the current status of the channel. This is useful when a change is dictated by the software with pre-set values. DOSET, DOCLR, and SCRAW will read the current status of the digital output channel, modify that value with a masking value, and return the new value to the digital output channel. These operations are very useful when only certain lines or bits are to be toggled while preserving the current value of the remaining bits. For example, the following will set lines 1 and 5 to TTL high while not changing the remaining six lines in the 8-bit port.

600 OMASK = 34

610 CHAN = 0

620 CALL LABPAC(CHA, OMASK, RESULT, DOSET)


Setting Up Arrays

Often a set of channels needs to be monitored. This process requires a list of channels which will be sampled, a time interval between each burst of samples, and a data array to store the data. Conversely, when driving a set of channels the data array supplies the information to be provided to the set of channels at the timed interval.

In the data set Calls, the list of analog or digital channels to be sampled is placed in a Channel Array. The cells in the array are filled with the channel numbers in the order they are to be sampled. If the element in the array is a negative channel number, the corresponding timer/counter channel is sampled or re-loaded. For example, if a sweep of data consists of a read from channel 3 and a read from channel 5, the first element of the array named CHANNEL is set to 3 and the second element is set to 5.

500 CHANNEL(0) = 3: CHANNEL(1) =5

In the data set Calls the information to be sent is taken from the data array or conversely the information from sampled channels is stored in the data array. Information is stored in a sweep major manner: the first element contains data for/from the first sweep, first channel; the second element contains data for/from the first sweep, second channel, etc. Graphically this appears:

Sweep 1

Channel 1 

Sweep 1

Channel 2 

Sweep 1

Channel 3 

Sweep 2

Channel 1 

Sweep 2

Channel 2 

Since this is how two-dimension arrays are stored in memory it is often easiest to dimension the array as # of Sweeps by # of Channels for row major languages such as C. Column major languages such as FORTRAN or BASIC should be dimensioned as # of Channels by # of Sweeps. This means that an individual sample can be addressed in C as:

IBUF[SWEEP_N][CHANNEL_N]

or in FORTRAN or BASIC as:

IBUF(CHANNEL_N,SWEEP_N)

When a new sample is specified using the same data array, the new samples will replace the current contents of the data array. The data array cells do not have to be zeroed out between calls.

The maximum number of cells in the data array is 32,767. To calculate the number of cells use:

NCELLS = NSWEEPS * NCHANS

Pay close attention to whether the application language has zero-based indices or one-based indices. In C the first sweep, second channel data would be in array [0,1]; in FORTRAN the data would be accessed as array (2,1); or in Interpreted BASIC the same data is ARRAY(1,0).


Sampling Sets of Channels

When medium to high speed data set sampling is required, the MAXimum Rate functions are recommended. These routines use a Timer/Counter Channel to clock the time between sweeps. The interval timer must be established with the TIST Call for the time period between the start of each sweep of channels.

AIMAX and DIMAX will sample a set of channels into an array. In the following example three analog input channels are sampled fifty times each with sweeps at ten millisecond intervals.

600 CHAN(0) = 3:CHAN(1) = 6:CHAN(2) = 8

610 TCHAN = 3:SRC = 1 4:PERIOD = 10

620 NSWEEPS = 50:NCHANS = 3

630 CALL LABPAC(TCHAN,SRC,PERIOD,RESULT,TIST)

640 CALL LABPAC(TCHAN,NSWEEPS,NCHANS,CHAN(0),IDATA(0,0),RESULT,AIMAX)

AOMAX and DOMAX will output samples from an array to a set of channels. For example the following will output five ascending voltage levels on channel 0 and five descending levels on channel 1 at one second intervals.

590 DIM IDATA(1,4)

600 CHAN(0) = 0:CHAN(1) = 1

610 TCHAN = 3:SRC = 1 5:PERIOD = 100

620 NSWEEPS = 5:NCHANS = 2

630 IDATA(0,0) = 0: I DATA(1,0) = 2047

640 IDATA(0,1) = 500:IDATA(1,1) = 1500

650 IDATA(0,2) = 1 000:IDATA(1,2) = 1000

660 IDATA(0,3) = 1500:IDATA(1,3) = 500

670 IDATA(0,4) = 2047:IDATA(1 ,4) = 0

680 CALL LABPAC(TCHAN,SRC,PERIOD,RESULT,TIST)

690 CALL LAB PAC(TCHAN,NSWEEPS,NCHANS,CHAN(0),IDATA(0,0),RESULT,AIMAX)


Using EMS Memory

Expanded Memory, often referred to as the LIM EMS standard (Lotus, Intel, Microsoft Expanded Memory Specification), refers to computer memory beyond the 640KB DOS limit using techniques called paging and bank switching. LabPac requires an EMS memory manager or a 386 Virtual Memory Manager. To use expanded memory, three Calls are available (ALLOC, ACCESS, & FREE).

ALLOC allocates a block of EMS memory and returns a two-word handle or buffer number. This handle is used in place of any data array pointers when using the large or compact memory model programs. The handle consists of two parts: the segment address of the EMS memory and a block number assigned by the EMS Memory Manager. ALLOC can be used as follows:

handle = (unsigned long)labpac(ALLOC, nelements);

All LabPac routines using data arrays automatically map the EMS memory. The following code segment indicates how the EMS buffer handle can be used to indicate the data array location.

labpac(AIMAX, timer, nsweeps, nchans, chans, handle);

labpac(WRITE, filehandle, nsweeps, nchans, chans, handle);

If the application program needs to access any expanded memory, Call the ACCESS function with the proper handle. At this time the block of memory can be read from or written to the EMS memory segment starting at offset zero.

To release a block of memory after it is no longer needed, use the FREE function as follows:

labpac(FREE, handle);


Software Triggers

When the need arises to sample data after a certain event has happened, external triggers are used. If the triggering event is an analog input, the AISC function can be used. If the triggering event is a set of one or more digital inputs, the DISC function can be used. If the triggering event is time or count related, the TISTAT function can be used.


Digital Trigger

The DISC function detects a bit combination on a particular digital input channel. The routine requires the Digital Input Channel Number, a mask of the bits to look at, and a value to describe the on/off pattern for the masked bits.

The DISC function has two modes of operation depending on the mask. If the mask is non-zero the function returns as soon as the input lines corresponding to the set bits identified in mask equal value bits. If the mask is zero than the function returns as soon as any of the input lines corresponding to set bits in value change state. Note that in either mode it is possible to set up the DISC parameters so that the function will not return (i.e., the digital channel mask never meets the trigger condition). The following program fragment waits for a falling edge on digital input channel 0, bit 1.

labpac(0,2,2); //Make sure line is high

labpac(0,2,0); //Wait for the falling edge


Timed Trigger

In some applications a pause or delay is needed before the next section of code executes. For other applications a set of functions need to be done at set intervals. For these applications timer/counter channels can be utilized to provide accurate timing.

When the application requires a pause or delay, start a timer channel with a mode which will give you the range of delay desired. Use 11 for microseconds, 14 for milliseconds, or 15 for hundreths of seconds. Use the value of zero for the period. After starting the counter with the TIST function, use the TISTAT function to create a delay in the program. For example to delay one second, use 15 for the mode, zero for the period, and 100 for the value in TISTAT.

600 TCHAN = 3:SRC =15:PERIOD = 0

610 STATVAL = 100

620 CALL LABPAC(TCHAN, SRC, PERIOD, RESULT, TIST)

630 CALL LABPAC(TCHAN, STATVAL, RESULT, TISTAT)

The use of a counter trigger is similar, replace the timer source with an external source. The successive TISTAT Calls will then wait until the desired number of external counts is recorded.

Occasionally applications need to execute a task or set of tasks at the start of given time intervals. Repetitive functions in the application are executed at equal intervals. One technique to track the time interval is to monitor the output state of a timer/counter channel. The TISTAT routine can wait for the output of a timer/counter to go high as shown in the following fragment. After the task is complete, use the TISTAT routine to wait for the end of the next interval.

mask = 0x0808 //Waitfor channel 3 to go high

labpac(TISTAT, 3, mask);

There are two problems with the preceeding algorithm. First, if the task is complete before the timer/counter output goes back low, the next task could start before the given time interval is completed. To guard against this, add a TISTAT Call that waits for the timer/counter output to be low.

labpac(TISTAT, 3, 0x0008);

The second problem is that the high interval may be too short. If the timer/counter source is less then 100seconds, the TISTAT routine may not see every high pulse from a timer/counter started with TIST. To remedy this problem, start a timer channel with the TILH routine. Set the low and high output values about equal and such that their sum equals the desired time interval. The complete procedure might appear as follows:

700 TCHAN=3:SRC = 11:LOW = 500:HIGH = 500 '1 mS

710 LOWVAL = &H0008:HIGHVAL = &H0808

720 CALL LABPAC(TCHAN,SRC,LOW,HIGH,RESULT,TILH)

730 CALL LABPAC(TCHAN, HIGHVAL, RESULT, TISTAT)

740 'PLACE DESIRED TASK HERE

910 CALL LABPAC(TCHAN, LOWVAL, RESULT, TISTAT)

920 GOTO 730


Analog Trigger

The AISC function detects rising or falling analog signal edges. The routine requires an analog input channel, the pre-trigger level, and the post-trigger level. Tnis allows the specification of a level and a noise band for the trigger signal. The AISC function returns after the dual conditions have been met. In the following example analog input channel 5 is used to detect an analog trigger at aproximately 4 Volts.

600 CHAN = 5: PRE = 800: POST = 816

610 CALL LABPAC(CHAN, PRE, POST, RESULT, AISC)


Peak Detection

The AISC function also provides for threshhold detection. There may, however, be a need for a peak detector or localized maxima/minima detector. One way to detect extrema would be to collect a series of data and analyze the data after the fact. If the extrema is a trigger for other events we need to detect peaks in real time.

The following example looks for a local maxima. When a sample with a higher value than the previous maximum is identified, it is saved as the new maximum and the count reset. After a predetermined number of counts without a new maximum being found, the saved value is declared to be the peak value. The method provides some noise rejection although it does suffer in that there is a lag between reading the peak value and realizing that it is the peak value. This code can also be used to detect a minima by replacing max with min and checking if sample is less than min.

** Look for localized peak **

max= -32766

count= 0

while count < NSAM PLES

sample= labpac(AIRAW, 0)

if(sample > max)

max= sample

count= 0

else

increment count

endif

endwhile


If we are just counting peaks and they are of a known height, we can use the theshold detector routine to count crossings as follows:

** Count crossings **

while time<maxtime

peek= labpac(AISC, channel, LOW, HIGH)

increment count

endwhile


Controlling Hardware Interrupts

While the Scientific Solutions hardware is capable of fast data acquisition and process control, sometimes the computer interrupt traffic may make it difficult for the computer to acquire data at the maximum rate. One major limiting factor is that the CPU is constantly being interrupted by processes other than LabPac. If you are not able to acquire data at the full rate and you suspect this is due to other tasks interrupting the CPU, you can turn off the interrupt process. To turn off or mask the interrupts, follow these steps.

Use the ITCLR call to disable the desired interrupts. The discussion of the INTCLR function in the Technical Reference chapter identifies the common functions used with each IRQ line. When OFFFFh is in the register, all IRQs are masked off or disabled. Use this value to disable all IRQs as in the following example:

oldint = labpac(lNTCLR, Oxffffh)

Note that OLDINT is set equal the mask of interrupts that were turned on previous to this call so that the status of the IRQ Control Register can later be restored.The sixteen bits in this register correspond with the sixteen IRQ lines. Each bit number matches its IRQ number (i.e., bit zero is for IRQO). When a bit in this register is enabled (set to one), then the corresponding IRQ is disabled. When a bit in the register is set to zero, the corresponding IRQ is left alone.

If one of the IRQs that was already enabled (i.e., LabPac background process server) is to be left alone, be sure not to add the value that sets the corresponding bit to zero. See the example below for disabling all TRQs except number seven.

oldint = labpac(lNTCLR, Oxff7fh)

After finishing data collection at a maximum rate, always restore the IRQ Control Register to its previous status. If the previous value was saved as illustrated in the above examples, simply call INTSET using the value in OLDINT.

labpac(lNTSET, oldint)

NOTE: While the IRQ vectors are disabled in this fashion, the PC systemboard clock will stop keeping time and the disk drive motors will not stop.


Saving Time of Day

When the DOS clock is turned off for high speed or uninterrupted data collection, the system clock is stopped and will lose time. To reset the DOS clock from the computer's real-time clock use BIOS interrupt function 2 to read the clock, translate the time values from BCD to binary, and use DOS function 2DH to set the clock. Date and Time software supplied with the computer can also be used.

The Lab Master series, Lab Tender, and McDAS series boards can preserve the time of day on the Timer/Counter Channels 1 & 2. This is done through the SETTIME and GETTIME functions. SETTIME would be used before the clock interrupt is cleared with the TNTCLR function. After the time intensive task or before exiting the LabPac application, use GETTIME to reset the DOS clock. GETTIME can also be used during the application to retrieve the time-of-day for time stamping purposes.

return to top of Techniques



HARDWARE PROCESSES

Hardware processes are those routines that rely on some aspect of the hardware interface to start or cause some action.

Counting/Timing Events

External events can be counted or tracked by tying the signals to the source or gate pins of the 9513A timer/counter IC on the Lab Tender, Lab Master series, or McDAS series interfaces. The events can be tracked by starting a counter channel with the TIST routine. The current count of events can be identified at any time using the TIRAW routine. The following example starts timer/counter channel 3 to count events arriving at source pin 5.

600 TCHAN = 3: SRC = 5: PERIOD = 0

610 CALL LABPAC(TCHAN,SRC,PERIOD, RESULT,TIST)

1050 CALL LAB PAC(TCHAN,EVCOUNT,TIRAW)

1060 LOCATE 5,70:PRINT HEX$(EVCOUNT)

NOTE: In BASIC all counts above 32767 will be presented as negative numbers. The HEX$ conversion can be used to preserve the counts as a positive value.

Timer/counter channels can be read as part of input sweep routines. A negative channel number is interpreted by the SWST and MAX routines as a timer/counter channel. The read integer data is placed in the data array the same as for the analog or digital input channels. On output sweeps the data is output to the timer/counter channel's Load Register.

Some applications call for counting events within a precise interval of time. One way of handling this is to have one counter gated by another. The following example determines how many pulses occur on SRC3 during one second. Externally connect OUT2 to GATE4.

labpac(TILH,2,15,1 ,100); //10Msec. low - one sec.high

labpac(TIST,4,3+256,0); //count pulses on SRC3

labpac(TISTAT,0,0x404); //wait for high gate

labpac(TISTAT,0,0x400); //wait for low gate

count = labpac(TIRAW,2); //read number of counts


Simple Hardware Triggered ADC

A necessary condition to accurate high speed A/D sampling is a consistent equally spaced signal to start conversions. This is important because at higher speeds the reliability of data depends on equal sampling intervals. Using the external start feature on the Lab Master DMA, Lab Master and Lab Tender is the surest way to generate equal intervals.

One method for generating an external start is to bring an external signal from a source that sends rising edge pulses at accurate intervals. Use the LabPac AIHDW or AIDMA calls to collect the data.

The other method for generating an external start is to use one of the 9513A counters. To physically install one of these counters, run a line from one of the OUT pins on a board's 9513A connector to the external start pin. Some boards may already have a counter connected in this fashion. Refer to the manual on your particular Scientific Solutions' board. Use the LabPac timer routines to set the rate for the output signal from the counter. The following example provides a 40KHz sampling rate (based upon a 1Mhz 9513A clock).

labpac(TIST,S,11 ,25);

labpac(AIDMA,0,500,5,data);

The previous AIDMA Call may have returned the DMAERR error code. This is because the data buffer crossed a DMA page boundary. To prevent this from happening, start with two data buffers, allocated contiguously. Determine which buffer does not cross a boundary as follows.

int dma1[50001[4], dma2[5000][4];

p_addr = fp.seg(dma1) * 16 + fp.off(dma1);

if(p_addr >> 8 = = p_addr + 4000) >> 8)

{

buffer = dma1;

}

else

{

buffer = dma2;

}


Burst Mode ADC

Some applications call for a set of analog inputs to be sampled as a group at regular intervals instead of continuously at equal intervals between any two conversions. The routines AIMAX and AISWST/AIRSWST will sample their sweep of channels in this fashion. To minimize the time interval between any two conversions within the burst of channels, the AMDW and AIDMA routines can be used with a gated timer as the trigger. The timer/counter can be started with the TIST function as discussed earlier. To bunch the samples together, a gated pulse train is required. This is accomplished by cascading a timer started with a TILH function into the gated trigger timer. For example, to create a timer signal for a four channel sweep with 10 microseconds between samples and 100 microseconds between sweeps, connect OUT4 to GATES and use the following code:

labpac(TILH, 4, 11, 60, 40); //60 secs. low - 40 secs. high

labpac(TIST, 5, 11+ 0x20, 10); //10 secs. gated by above


Simultaneous Analog I/O

Some applications call for a set of analog inputs to be sampled while simultaneously stimulating with an analog output waveform. Usually the sequence of events is to output the stimulus, wait for the reaction to settle, then sample the data.

In the following example, timer/counter channel 3 determines the rate of stimulus change. Timer/counter channel 4's low output time determines the delay between the stimulus and the start of sampling. Timer/counter channel 4's high output time enables the conversions and should be equal to the number of samples times the conversion rate. Timer/counter channel 5 determines the conversion rate. To create a timer signal for a four channel sweep with 25 microseconds between samples triggered 20 microseconds after an analog output, connect OUT4 to GATES and OUT3 to GATE4. Use the following code:

//20 S before first sample - 100 S for 4 channels

labpac(TILH, 4, 11 + 0xe0, 20, 100)

labpac(TIST, 5, 11+ 0x20, 25) //25 S per conversion

labpac(AIDMA, 0, nsweeps, 4, databuf);

labpac(TIST, 3, 11, 1000); //1000 S between outputs

labpac(AOMAX, 3, nsweeps, 1, chan, outdata);


Tracking DMA Transfers

Real-time applications may require the identification of when a burst of samples has been transferred to the data buffer. To identify when a set of samples is in the data buffer, start a counter channel with the end-of-conversion status signal as the source. On the Lab Master DMA, connect the DONE jumper and use source 3. On the McDAS series use A/D DONE as the source. Use TISTAT to determine when the set of samples is available as follows:

labpac(TIST,3,3,0); //count DMA transfers

labpac(TIST,5,1 2,25); //high speed conversion

labpac(AIDMA,0,500,1,data);

labpac(TISTAT,3,250); //wait for buffer half full

return to top of Techniques



BACKGROUND PROCESSES

Background processes are those routines that start a task and return control to the main program before completing the task. The task will be completed by hardware interrupt processes.


Background Sweeps

When both a stimulus is to be provided and a response measured, and the sampling frequency is low to medium speed, the Sweep Start functions are recommended. These functions use the interrupt handler installed by the SWINIT routine. The time between sweeps is clocked by the Timer/Counter Channel installed using a TIST routine. These Calls take the user parameters and set up a background procedure which performs the actual work.

This background action allows two or more processes to proceed at the same time. An application program can write data to the screen as it is being collected or a stimulus can be provided at the same time as monitoring a subject's response.

The LabPac interrupt handler monitors a service cycle for timed interval processes. The service cycle consists of four parts. Each part is responsible for monitoring the status of timed interval sampling or sending of data for a set of one or more channels (referred to as a sweep of channels). The four types of sweeps are: analog input, digital input, analog output and digital output. The status of each type of sweep is monitored by its own "process context". This is a subroutine that checks to see a) if any sweep is in progress or b) if it is time to conduct a sweep. There are four process contexts, one for each sweep.

When the LabPac interrupt handler is called by the CPU, the main routine to monitor the service cycle is run. The routine acknowledges to the CPU and the Scientific Solutions hardware that the interrupt was received. The status of the service cycle is then checked and one of the process contexts is called. One process context is serviced on each hardware interrupt. The full service cycle consists of the running of all four process contexts. Thus it takes four hardware interrupts to complete one full service cycle. See the Interrupt Service Structure chapter for more details.


Calculating Interrupt Timing

With analog inputs in particular, there is always the danger for an overrun to occur in the service cycle. An overrun is when the process context calculates it is time to begin a sweep and the previous sweep of the same type is still in progress. The possibility of an overrun increases if too many channels need to be processed and not enough time has been allowed in the service cycle. This is also more likely to happen if another type of sweep is started with not enough time allowed to do both sweeps. See the Interrupt Service Structure chapter for a discussion of factors to consider in determining interrupt timing.

The minimum recommended time interval for one complete service cycle is 800 microseconds. This equates to 1250 complete service cycles per second. When calculating parameters for the time interval on the interrupt source, divide the service cycle interval to be used by four to get the time interval between each hardware interrupt.

Interrupt timing can be calculated as either a time interval or a frequency (i.e., times per second). The terms used in the following calculations are: Interrupt (hardware interrupt); Source (9513A counter's input source); Count (i.e., number of times to count the signal at the Source) and Skip (the number of complete service cycles between sweeps). Three formulas are needed as shown below for calculating time intervals. See the Interrupt Service Structure chapter for the corresponding frequency calculations.

Interrupt Interval = Source Interval * Count
Service Cycle Interval = 4 * lnterrupt Interval
Sweep Interval = Service Cycle Interval * Skip
As an example using a 100 microsecond Source interval, let the Count for the source interval equal 75 and the Skip between sweeps equal 20. The following calculations apply.
Interrupt Interval = .1 mS * 75 = 7.5 mS
Service Cycle Interval = 7.5 mS * 4 = 30 mS
Sweep Interval = 30 mS * 20 = 600 mS
For this example, these values mean that a hardware interrupt will occur every 7.5 milliseconds. It will take 30 milliseconds to complete one of LabPac's service cycles. There will be a sweep every 600 milliseconds or 1.67 sweeps per second.


Use of STATUS Calls

When the sweep start function returns, the sweep data is not necessarily present in the data array. Each of the background processes has a status routine which will return the current value in the sweep counter. The AISTAT, AOSTAT, DISTAT and DOSTAT Calls are useful in identifying how many sweeps have occurred in a background process. For example, the application starts a background process and proceeds to some other operation(s). After finishing with those routines it needs to wait until the background process is finished. The end of the background process can be determined as follows:

labpac(AOSTAT,0)

In slow moving real-time applications, the background process stat Calls can be used to identify when a set of samples are available for use by graphics, statistical, or transforming processes. In the following example a loop is set up to identify when each set of samples has arrived in the data array so their position on a strip chart display can be calculated and the screen updated.

labpac(AISWST, 1, nsweeps, nchans, chan, data);

for (s=0; s<nsweeps; ++s);

{

labpac(AISTAT, nsweeps-l-s);

for (c=0; c<nchans; ++c)

{

graph (s, c, data[s][c];

}

}

The timer/counter channels have a status routine, TISTAT. This routine was discussed earlier under Software Triggers. The ATDMA routine has a status function, DMASTAT. This function identifies when the DMA process has been completed. This function will not return until all DMA transfers are completed.


Pre/Post Sampling

Sometimes samples of input data are required prior to the trigger condition. These samples are known as pre-trigger samples. To acquire pre-trigger samples we use repeating input sweeps. These are similar to regular input sweeps with the addition that after acquiring a complete set of samples for the required sweeps, the repeating sweep function will restart the process, overwriting the data buffer. This allows a continuous sampling of the input channels. In order to detect the trigger condition, the STAT Call is used to identify which sweep is currently sampled. With this information examine the contents of the corresponding cell in the data array containing the current sample for the scrutinized input channel.

After determining that the trigger has occurred, stop the process with the SWAB routine. If post-tsigger samples are required, use a STAT function to wait for the post-trigger samples to be acquired and then abort the sweep process. An example of this overall process can be found in the Example Applications chapter.


Double Buffering - PingPong

A specific input repeating sweep technique which allows continuous sampling of data sets larger than 64K is called double buffering or pingpong buffering. This algorithm has a repeating analog input sweep to collect samples into a large data buffer. The foreground process monitors the progress of the repeating sweep and then starts writing the input data to a file after the sweep reaches the half full mark. After the file writing routine, the foreground routine waits until the input sweep process is finished with the second half of the data buffer. The second half is then written into the file. The process is repeated until some end condition is met.

file = labfile(CREATE, "data")
labpac(AIRSWST, 1, 3200, 10, channels, data)
repeat
  labpac(AISTAT, 1600)
  labpac(WRBIN, file, 1600, 10, channels, data)
  labpac(AISTAT, 0)
  labpac(WRBIN, file, 1600, 10, channels, data[600] )
until done
labpac(AISWAB)
labpac(CLOSE, file)
return to top of Techniques


Tools

CATCH
SCRIPT
LABMENU
  Initialization
  Analog Input
  Input From One Channel
  Multi-Channel Input
  Multi-Channel Data Display
Saving Multi-Channel Data Sets
  Digital Input
  Analog Output
  Digital Output
  Timing/Counting
In the TOOLS sub-directory you will find two programs to help you design LabPac programs. The SCRIPT program allows you to enter LabPac commands and parameters from the keyboard. The commands will be executed and the return value and data displayed on the monitor. CATCH is a memory resident program which will report all calls made to LabPac.

In the root directory of the LabPac disk is the program LABMENU, which can also be of assistance in designing programs. It is an Interpreted BASIC program. All three utility programs are described in this chapter.

CATCH

The utility program CATCH.COM, found in the TOOLS sub-directory, is a memory resident program. After installation, CATCH can report on all Calls made to LabPac. CATCH can write to the monitor the name of the Call, the values of the parameters used in the Call, and the result or return value from the Call. Having this information available during development of an application is extremely useful to identify problems in the main program and to troubleshoot system problems when unexpected results occur.

Since CATCH will intercept only Calls to LabPac, LabPac must be installed before installing CATCH. To make CATCH memory resident, type CATCH at the DOS prompt as follows:

C> CATCH

After capturing a Call to LabPac, CATCH will report the function name, parameter values and return value on the display in the following format:

[functionname parameterlist -- RESULT]

In the default installation, CATCH will report all information to the monitor and allow execution of the Call by LabPac. Writing of the function name, parameter list or return value to the monitor can be suppressed using a set of toggles with the CATCH command. Execution of the Call by LabPac can be suppressed, allowing the Call to return to the application without being executed. The following options are available:

/a - do not print result from LabPac

/c - do not allow LabPac to receive the Call

/f - do not print function name before calling LabPac

/p - do not print parameters before calling LabPac

To use one of the parameters, place it after the CATCH command as follows:

C> CATCH /C

If CATCH is already memory resident, running CATCH with an option(s) will toggle the current setting of that option(s). The options that can be used after CATCH is installed are:

/a - print result from LabPac

/c - allow LabPac to function

/f - print function name before calling LabPac

/p - print parameters before calling LabPac

/r - remove CATCH from memory

return to top of Techniques



SCRIPT

The SCRIPT program, found in the TOOLS sub-directory, allows you to enter LabPac commands and parameters from the keyboard. The commands will be executed and the return value and data displayed on the monitor. To run SCRIPT, type SCRIPT at the DOS prompt as follows:

C> SCRIPT

LabPac>

The program will respond, as shown, with a LabPac prompt. At this point any LabPac command can be entered at the keyboard with its parameter list. First type in the function name. Follow the name with a space and the parameters. Separate each parameter with a space. For example:

LabPac> reset

787

LabPac>

In the example, the return value of 787 decimal from the RESET function indicates the installed LabPac is Version 3.13. that is, 787 decimal is 313 hex. In the following example, the TIST command starts timer/counter channel 3.

LabPac> tist 3 13 1500

0

LabPac>

Parameters used in SCRIPT are decimal by default. To enter hexadecimal numbers, start the number with a "0x". To enter octal numbers, start the number with a "0". See the SET command below for an example of hexadecimal usage.

All LabPac functions are implemented in SCRIPT. There are some additional commands available to provide necessary auxilliary functions. One of these additional commands is HELP. To get a list of all commands type HELP. To get help on a specific command, type HELP commandname as in the following example:

LABPAC>help aiinit

To create a channel array or data array use the SET command. NOTE that input data arrays do not have to be created prior to an input command. The arrays can be given any name. In the following example, the arrays "aochans" and "aodata " are created. After each SET command a prompt will appear to fill the cells in the array with the desired decimal values.

LabPac> set aochans 4

Channels> 01 2 3

LabPac> set aodata 3 4

Sweep0> 0x0 0x10 0x20 0x30

Sweep l> 0xl 0x11 0x21 0x31

Sweep2> 0x2 0x12 0x22 0x32

LabPac> aoswst 1 3 4 aochans aodata

0

To exit SCRIPT, use the 'QUIT' command.

return to top of Techniques



LABMENU

The LabPac software includes a menu-driven program, LABMENU.EXE. Menu selections provide access to and control over the LabPac/hardware interface system. Use them to test the functionality of the system and to determine which routines to use in dedicated applications. For some applications this menu program may be sufficient to meet all programming needs. It can also be a convenient starting point for developing BASIC applications. Use of the menu program is explained in this chapter.


Initialization

Make sure you have loaded LABPAC.COM prior to running the LABMENU.EXE program.

To enter the menu program, type LABMENU at a command prompt, like this;

C:\ LABMENU


If LABPAC.COM was not loaded into memory, the error message "Divide Overflow" may display or the software will not display the LabPac version number and stop.

As LABMENU starts running it displays a Scientific Solutions copyright notice and then goes to the initializing routines. The program may prompt you for the particular Scientific Solutions' board you are using.

LabMenu Version 3.02

Copyright 1981-2000 by

Scientific Solutions
 
 

A menu program to test drive

LabPac Version x.xx
 
 

F1 Initialize LabMaster

F2 Initialize LabTender

After initialization, the following "Main Menu" will appear on the monitor

LABMENU
 
 

[Esc] Exit to Dos

F1 Analog Input

F2 Digital Input

F3 Analog Output

F4 Digital Output

F5 Timing/Counting

To enter one of the submenus, depress the function key (F1 to F4) listed in front of the option. For example, depress F2 to select the Digital Input submenu. A new menu will appear.

Depress the Esc key while in the Main Menu to exit the program, returning to DOS.

Depress the Esc key while in a submenu to return to the Main Menu.


Analog Input

The transfer of data from the analog to digital converter to LABMENU is handled by the Analog Input routines. The submenu is as follows:

ANALOG INPUT
 
 

[Esc] Return To Main Menu

F1 Read Analog Channel

F2 Start Analog Input Sweep

F3 Display Analog Data

F4 Stop Analog Input Sweep

F5 Start Maximum Rate Sweep

F6 Save Data to File

The choices allow data to be collected either one channel at a time or as sets of channels and samples. Data can be displayed in an oscilloscope format or saved as ASCII data files.


Input From One Channel

Option Fl will take one sample from one channel and display the result on the screen. Without clearing the Analog Input Menu from the screen, the following prompt will appear to identify the input channel.

Channel?

Type in the number between 0 and 256 that corresponds to the analog input channel to be sampled followed by a carriage return. An A/D conversion will be performed and the returned decimal value displayed on the screen under the above prompt as follows.

Result = 357


Multi-Channel Input

Options F2 and F5 allow for samples to be collected on up to 16 channels for 500 samples/channel. After selecting either option, the screen will clear. A prompt will appear requesting the time interval to use between the sampling of a set of one or more channels. For option F2 the base rate is in microseconds. For option F5 the base rate is in milliseconds. After typing in a value followed by a carriage return, a prompt will appear for the number of sweeps or bursts of channels to collect. Type in a number between 1 and 500 followed by a carriage return. A third prompt will appear to identify the number of channels to include. Type in a number between 1 and 16 followed by a carriage return. At this point the display will appear as follows where the parameters will be listed followed by a set of choices.

SWEEP PARAMETERS
 
 

Sweep timing (base rate): 200

Number of sweeps: 500

Number of channels: 8
 
 

[Esc] Return without Sweep

F1 Start Sweep

F2 Enter Channels

F3 Edit Channels

When multiple channels are selected, the Channel Array used by the sweep and maximum rate routines must be filled to identify which channels are to be used and the order that the channels will be sampled. Option F2 will present a set of prompts for the channelnumbers, Tn the example eight prompts will appear. The channels can be used in any order. Option F3 allows the order of the channels to be changed.


Multi-Channel Data Display

In the Analog Input Menu, option F3 will display the contents of the data array in an oscilloscope format. The last values entered for the number of channels and number of samples will be used to index the data array.


Saving Multi-Channel Data Sets

Option F6 creates a file to save the contents of the data array. The following prompt will appear for the name of the file:

File Name?

Type in the name of the file complete with DOS path. The file will be created at that location. The data array will be transferred to this location in ASCII format. The last values entered for the number of channels and the number of samples will be used to index the data array. After the data is transferred the file will be closed.


Digital Input

The transfer of data from the digital input ports to LABMENU is handled by the Digital Input routines. The submenu is as follows:

DIGITAL INPUT
 
 

[Esc] Return To Main Menu 

F1 Read Digital Channel 

F2 Start Digital Input Sweep 

F3 Display Digital Data 

F4 Stop Digital Input Sweep

F5 Start Maximum Rate Sweep

F6 Save Data to File

The options in the Digital Input Menu operate the same as the corresponding options in the Analog Input Menu.


Analog Output

The transfer of data from LABMENU to digital to analog converters is handled by the Analog Output routines. The submenu is as follows:

ANALOG OUTPUT
 
 

[Esc] Return To Main Menu 

F1 Write Analog Channel 

F2 Start Analog Output Sweep 

F3 Start Repeating Sweep 

F4 Stop Analog Input Sweep

F5 Start Maximum Rate Sweep

The choices allow data to be output from one channel at a time or from sets of one or more channels. The data can be entered at the keyboard or recalled from data files.

Options F2, F3 and F5 allow for samples to be output on up to 16 channels for 500 samples/channel. After selecting any of these options, the screen will clear. A prompt will appear requesting the time interval to use between the sending of a set of one or more channels. For options F2 and F3 the base rate is in microseconds. For option F5 the base rate is in milliseconds. After typing in a value followed by a carriage return, a prompt will appear for the number of sweeps or bursts of samples/channel to send, Type in a number between 1 and 500 followed by a carriage return. A third prompt will appear to identify the number of channels to include. Type in a number between 1 and 16 followed by a carriage return. At this point the display will appear as follows where the parameters will be listed followed by a set of choices.

SWEEP PARAMETERS
 
 

Sweep timing (base rate): 4

Number of sweeps: 20

Number of channels: 2
 
 

[Esc] Return without Sweep

F1 Start Sweep

F2 Enter Channels

F3 Edit Channels

F4 Enter Data

F5 Edit Data

F6 Read Data File

When multiple channels are selected, the Channel Array used by the sweep and maximum rate routines must be filled to identify which channels are to be used and the order that the channels will be sampled. Option F2 will present a set of prompts for the channel numbers. In the example eight prompts will appear. The channels can be used in any order. Option F3 allows the order of the channels to be changed.

Option F4 allows the data array to be filled from the keyboard. A series of prompts will appear for the number of cells determined by the number of channels times the number of sweeps.

Option F5 allows the editing of the data array. Prompts will appear to identify which cells to change and what new values to enter.

Option F6 allows the data array to be filled from a pre-existing ASCII data file. The following prompt will appear for the name of the file:

File Name?

Type in the name of the file complete with DOS path. LABMENU will look for the file at that location. The data will be transferred from this location. The last values entered for the number of channels and the number of samples will be used to index the data array. After the data is transferred the file will be closed.


Digital Output

The transfer of data from LABMENU to digital output ports is handled by the Digital Output routines. The submenu is as follows:

DIGITAL OUTPUT
 
 

[Esc] Return To Main Menu

F1 Write Digital Channel

F2 Start Digital Output Sweep

F3 Start Repeating Sweep

F4 Stop Digital Output Sweep

F5 Start Maximum Rate Sweep

The options in the Digital Output Menu operate the same as the corresponding options in the Analog Output Menu.


Timing/Counting

The Timing/Counting Menu presents options to start, stop, and read the contents of 9513 cdunters. The submenu is as follows:

Timing
 
 

[Esc] Return To Main Menu

F1 Start Timer

F2 Stop Timer

F3 Read Timer

F4 Set Clock Mode

F5 Read Clock

Option F1 will start one of the five timer/counter channels. Without clearing the screen a prompt will appear to identify the timer/counter channel. Enter a number between 1 and 5 followed by a carriage return. A second prompt will appear to identify the source of pulses to count. Enter a number between 0 and 15 followed by a carriage return. A third prompt will appear to identify the number of pulses to count. Enter a zero for counting up as an accumulator. Enter a number between 2 and 32,767 for counting down as a timer.

Option F2 will stop one of the five timer channels.

Option F3 will read the contents of one of the five timer channels and display the decimal value on the screen.

Option F4 will read the current time-of-day from the computer's system clock and install it on timer channels 1 and 2.

Option F5 will continuously read the contents of timer channels 1 and 2 and display the values as the time-of-day.
 

return to top of Techniques


Using BASIC
INTERPRETED BASIC
  The Header File
  Call Format
  Defining Terms
  Getting Started
  Error Checking
DEMONSTRATION PROGRAMS
  Aidemo.bas
  Aodemo.bas
  Didemo.bas
  Dodemo.bas
  Tidemo.bas
  Labmenu.bas
COMIPILED BASIC
  IBM Compilers
QuickBASIC Versions 2.0 & 3.0
  QuickBASIC Version 4.0
  The Header File
  Defining Terms
  Call Format
  Interface Modules
TURBO BASIC
  The Header File
  Call Format
  Interface Modules

This chapter discusses issues when programming in Interpreted BASIC or one of its compiled versions. The first part of the chapter explores elements needed to develop an application in Interpreted BASIC. The second part of the chapter indicates programming differences between Interpreted BASIC and its compiled forms.
 

INTERPRETED BASIC

Application programs can easily be written in Interpreted BASIC. Issues such as starting the application, error checking and string management are discussed in the paragraphs below. The LABMENU.EXE application program supplied with LabPac is written in QuickBasic 4 and contains many programming examples.


The Header File

Essential information for accessing LabPac functions from an application is contained in a header file in the BASIC section of the LabPac software. Every Interpreted BASIC application program should contain the LABHEAD.BAS file as the first section of the program. This file contains definitions of the function labels used by Calls, default I/O address variables, and an error checking routine. Additionally LABHEAD.BAS identifies where LABPAC.COM is loaded into memory.

LABHEAD.BAS is a text file and can be printed out using the DOS PRINT command. List it on the monitor using the following command:

TYPE LABHEAD.BAS

The different features of LABHEAD.BAS are described below.

Line DEFINT indicates that all variables are defined as integers unless otherwise specified through special symbols (i.e., $, %).

From all other languages, the memory resident portion of LabPac is accessed directly through software interrupt 66 hexadecimal. Interpreted BASIC, however, has structural features which do not allow direct access to LabPac through software interrupts. Instead, interrupt vector Fl hexadecimal is used to store a memory pointer to an entry subroutine for Interpreted BASIC in LabPac.

DEF SEG, LABSEG etc.. look at the Fl hexadecimal interrupt vector to identify the segment and offset of the address where LABPAC.COM was loaded into memory. The segment portion of the address is placed in the variable LABSEG. The offset portion of the address is placed in the variable LABPAC.

The application is then enabled to use Calls through that address to LabPac with the DEF SEG = LABSEG command. If the BASIC PEEK, POKE, BSAVE, BLOAD, or CALL (to user defined routines other than LabPac) statements are used in the application, return to the default segment address for the BASIC workspace using the statement shown below:

DEF SEG

After the execution of those commands return to the memory address for LabPac using the following statement:

DEF SEG = LABSEG

If the default segment is not reset to the LabPac segment, then Calls to LabPac may cause the computer to crash.

These DEF SEG, LABSEG=, DEG SEG Lines must be in all Interpreted BASIC applications.

Next group of statements identify which function numbers go with which Calls.

The 'MAXxx =' statements identifies the maximum values that the different channels can take.

Next statements identifie which hardware IRQ line is to be used.

Next group of statements define the default address parameters for each of the five Scientific Solutions boards. Lab Master and Lab Master DMA use the same address. If one or more of these boards are installed at a default address place one or more of the following statements on the appropriate line number in your application program. Delete lines that will not be used.

5 TENDER% = 1

6 MASTER% = 1

7 DADIO% = 1

8 BB% = 1

The purpose of these lines is to identify which of the default address variables are activated in the application. LabPac automatically initializes features on an Mc-DAS 16xx MicroChannel product, so its address parameters are not contained in LABHEAD.BAS. The address variable names and their default values used in LABHEAD.BAS are shown in the following table. If the boards are used at an address other than the default address, then these numbers would need to be changed to reflect the new base address.

Variable

Usage

ATOD A/D Control Register
  Lab Master Series = 0714h
  Lab Tender = 0330h
DTOA D/A Control Register
  Lab Master Series = 0710h
  Lab Tender = 0334h
LTIMER 9513A Data Port
  Lab Master Series = 0718h
  Lab Tender = 0338h
PIO Digital I/O Control Port
  Lab Master Series = 071Fh
  Lab Tender = 033Fh
DA DADIO D/A Ctrl = 0730h
DIO DADIO DI/O Ctrl = 073Bh
Base Board 8255A CTRL Ports
  BB0 = 0210h
  BB1 = 0214h
  BB2 = 0218h
  BB3 = 021Ch

Note that Lab Master and Lab Tender variable names are shared. If multiple boards are in the system, rename variables in the header file. For example, with one Lab Master at its default address and another Lab Master at a second address, use the appropriate defaults and then define another set of variables for the alternate addresses.


Call Format

In Interpreted BASIC the Call statement is used to access assembly language routines. The Call statement must contain a label (i.e., LABPAC) that is set to the offset in memory where the assembly routine resides. The Call statement must always contain at least one parameter or variable. This variable is for the return of information from the assembly routine. The term RESULT is used in this manual for that purpose. If information is to be passed to the assembly routine, it is placed in variables listed in the Call statement. The number of variables can vary, but they must always be listed in the correct order. The following is an example of the format all LabPac Calls will have:

CALL LABPAC(TIME, NSWEEPS, NCHANS, CHAN(START), BUFFER(CHN,SWP), RESULT, DOSWST) 

In this format the word "CALL" is of course the BASIC statement.

The word "LABPAC" is a variable that contains the offset memory pointer into the resident portion of LABPAC.COM.

The words "TIME", "NSWEEPS", and "NCHANS" are variables that contain information to be passed to LabPac via the call.

"CHAN(START)" and "BUFFER(CHN,SWP)" are variables that designate cells in the channel and data buffer arrays. Used here, they act as pointers passed to LabPac to identify the memory locations of the two cells.

The word "RESULT" is also a variable. When control is passed back to the BASIC program from LabPac it will contain status information about the call.

Finally "DOSWST" is the variable which defines which LabPac function is being called.

Defining Terms

With BASIC it is good practice to define all variables, strings, and arrays before any LabPac command is called. Only then will BASIC assign static locations in its workspace for each variable, string, or array. Otherwise BASIC will move array variable locations when new string or integer variables are defined, leading to possible loss of data or a system crash. Starting with line 500, insert lines that define and initialize all terms. See the demonstration programs and LABMENU.BAS for examples.

The descriptions of the Calls in the Technical Reference chapter use descriptive terms for variables, arrays, and strings. Use any legal BASIC label for variables, arrays and strings. Be sure to check that you are not using labels reserved by BASIC for other functions (i.e., ERR,DATA, etc.).

Variables or scalars are defined when they are equated with a value. For example:

VAR1 = 25

String variables are defined by equating a string label with a set of ASCII characters or a null string. The following example sets a string label to equal a string containing the name of a data file.

DFILENAM$ = "C:\DATA\DSET1.PRN"

Interpreted BASIC restricts string variables to a maximum length of 255 bytes. LabPac checks the string length descriptor used by Interpreted BASIC to determine the number of bytes in the string.

Arrays are defined when they are dimensioned. For example:

DIM DATARRAY(25)

creates a one-dimensional integer array with 26 cells.

It is especially important to remember that Advanced BASIC defines the data arrays as number of channels by number of sweeps. When defining data arrays use the following format:

BUFFER(CHANNELS, SWEEPS)

If data seems to be incorrect or out of place, double check data array definitions and any place the data array is used as a cell designator. Also check to see if a new variable has been defined or created that was not initialized at the top of the program.

Remember that Interpreted BASIC only uses 64K bytes of workspace. The total amount of space that can be used for an application and for storing all variables cannot exceed 64K bytes without problems. When determining array sizes, remember to include the space used by program statements, integer variables, and string variables. Note that all integer variables use two bytes of space. Use the following formulas for calculating array sizes:

one-dimensional = (2 * Number of cells) + 4

two-dimensional = (2 * Number of Channels ' Number of Sweeps) + 4

Getting Started

LABHEAD.BAS can be incorporated into the application in one of two ways. The first method is to enter BASIC and load the file with the following command:

LOAD"LABHEAD

Proceed to enter program statements with application specific variable/array/string definitions at line 500.

The second method would be to use the Interpreted BASIC merge function. Put the following statement on line 10 in the program.

10 CHAIN MERGE "LABHEAD.BAS",ALL

Since the statements contained in LABHEAD.BAS use line numbers through 490, start entering statements at line 500. When the application is RUN, LABHEAD.BAS is merged into the main program. Line 10 of LABHEAD.BAS will replace the original line 10 in the main program. Any statements in the application with the same line numbers as in LABHEAD.BAS will be overwritten by the MERGE function.

After all the variables, strings, and arrays have been defined, the first Call that should be made is RESET. This will clear the LabPac driver of information programmed by previous applications. The RESET function is called as follows:

550 CALL LABPAC(RESULT, LRESET)

Before data collection or process control functions can be used, the hardware functions to be used by LabPac must be initialized. For example, to use 16 analog inputs without programmable gain on a Lab Master DMA at its default address, use the following:

600 NCHANS = 16

610 DMA = 1

620 FOR 1 = 0 TO 15

630 GAIN(1)= 0

640 NEXT

650 CALL LABPAC(ATOD, NCHANS, DMA, GAIN(0), RESULT, AIINIT)

Error Checking

LABHEAD.BAS contains an error checking subroutine in lines 200 - 320. One way to use this subroutine is to check the value of the RESULT variable on return from any call. This variable will return status information about the execution of the subroutine. For most functions, only error codes are returned. When there are no errors in this situation, the value zero is returned. Place a line such as the following after these Calls.

660 IF RESULT <> 0 THEN GOSUB 200:PRINT "LINE 660":STOP

If the Call can contain either data or error codes, the above line must be modified. In an error code, the Most Significant Bit (bit 15) is always set to one. Unless otherwise noted in Chapter 10 (Technical Reference), the two bytes of data will have the Most Significant Bit set to zero. For situations where 12-bit, Two's Complement data is returned, place a line such as the following after the Call statement.

660 IF RESULT < -2048 THEN GOSUB 200:PRINT "LINE 660":STOP

For routines where the Most Significant Bit can be set to one to return data (i.e., TIRAW) no error checking is possible. However, if these Calls consistently return values in the error code range a problem may be indicated.

return to top of Using BASIC


DEMONSTRATION PROGRAMS

There are demonstration programs in the BASIC subdirectory. These demonstration programs spotlight hardware features of Scientific Solutions' products and the LabPac routines related to that area.

All the demonstration programs are set up for use on a Lab Master.

The following is a brief description of each program. Refer to LABMENU.BAS for examples of the utility and file I/O Calls.
 

Aidemo.bas

The analog input demonstration program uses Calls for A/D conversions. The Calls that are included are AIINIT for initialization, AIRAW for converting one sample, SWINIT for initializing sweeps, and AISWST, AISTAT and AISWAB for interrupt driven sweeps.
 

Aodemo.bas

The analog output demonstration program uses Calls for D/A conversions. The Calls that are included are AOINIT for initialization, AORAW for outputing one sample, SWINIT for initializing sweeps, AOSWST, AORSWST, AOSTAT and AOSWAB for doing output sweeps.
 

Didemo.bas

The digital input demonstration program uses Calls for reading digital input channels. The Calls that are included are DINIT for initialization, DIRAW for reading one channel, SWINIT for initializing sweeps, DISWST, DISTAT and DISWAB for interrupt driven sweeps.
 

Dodemo.bas

The digital output demonstration program uses Calls for sending digital outputs. The Calls that are included are DINIT for initialization, DORAW for sending one channel of information, SWINIT for initializing sweeps, DOSWST, DORSWST, DOSTAT and DOSWAB for doing interrupt driven sweeps.
 

Tidemo.bas

The timer/counter demonstration program uses Calls for the timer/counter channels. The Calls that are included are TIINIT for initialization, TIST for starting a timer/counter, TIRAW for reading the values on a timer/counter channel, TIAB for stopping a timer/counter channel, TISTAT for stopping the program for set time periods, and TILH for waveform output.
 

LabMenu

The root directory of the LabPac software contains the program LABMENU.EXE. This menu program contains examples of many LabPac Calls. The purpose of this program is for instructional value and to help test software and hardware. Do not expect it to meet all data collection or process control needs as it is not intended to be a full service shell. The best use of the program is to list it out and use it for programming ideas. The source code for this program is QB4MENU.BAS.

return to top of Using BASIC


COMIPILING BASIC PROGRAMS

Interpreted BASIC programs using Calls to LabPac can be compiled with minor modifications using the IBM BASIC, QuickBASIC, or TurboBASIC compilers. Use the information in the first part of this chapter to set up Calls to LabPac and define variables, strings, and arrays. Specific instructions for the three compilers follow.

Creating a compiled BASIC executable program is usually a two step process. The first part of the process is to take the BASIC code for the application contained in a file with the .BAS extension and compiling it into a file with the .OBJ extension.

This is what the compiler will do. Consult the compiler manual for specifics on creating application programs.

The second step in the process is to link the application .OBJ file with a compiler specific .OBJ file from the LabPac diskette. This is done using a "Linker" provided with the compiler. Consult the compiler manual for specifics on using its linking facilities.

BASIC compilers do not use the CHAIN MERGE statement. When developing an application, load the appropriate header file (i.e.,LABHEAD.BAS) as indicated earlier. Eliminate the DEF SEG, LABSEG, DEF SEG lines from LABHEAD.BAS. These are the lines that located the memory address used only for Interpreted BASIC and are not needed. Instead BASIC compilers use the labeling method for Calls.

IBM Compilers

In the BASIC subdirectory of the LabPac software is an interface module called BASIC.OBJ, which must be used to Call LabPac. This interface module contains the glue between the BASIC CALL statement and the memory resident portion of LabPac. Refer to the BASIC Compiler manual for information on using the interface module with the application program.

QuickBASIC Version 2.0 & 3.0

In the BASIC subdirectory of the LabPac software is an interface module called QBASIC.OBJ, which must be used to Call LabPac. This interface module contains the glue between the BASIC CALL function and the memory resident portion of LabPac. Refer to the QuickBASIC manual for information on using the interface module with an application program.

The QBASIC.OBJ interface module needs an array descriptor rather than an array element in the Call to LabPac. This means that all Calls containing data or channel array parameters do not include the cell descriptor as shown in the following example:

CALL LABPAC(SKIP, NSWEEPS, NCHANS, CHAN( ), INBUF( ), RESULT, DOSWST)

Arrays can be either dynamic or static. Dynamic arrays allow a workspace larger than 64K bytes. An example of a QuickBASIC 3.0 application is QB3MENU.BAS.

QuickBASIC Version 4.0 (QB4)

QuickBASIC Version 4.0 is very different from other BASIC compilers/interpreters . The format of its Call statement is the same as for the Microsoft C compiler. This requires a different technique for accessing LabPac.
 

QB4 - The Header File

A header file called LABHEAD.QB is in the BASIC subdirectory on the LabPac diskette. This file contains important information for defining constants such as LabPac Functions or error coding. Every QuickBASIC 4.0 application program should start with this header file as the first section of the program.
 

QB4 - Defining Terms

Filename strings must be null terminated. This can be done with the code shown below:

FILENAME$="C :\DATA\DSET1.PRN"+CHR$(0)

QB4 - Call Format

Microsoft QuickBASIC Version 4.0 uses the C Call format. An example in the C Call format is shown with every function documented in the Technical Reference chapter. Functions can be called as in the following example:

result=labpac5%(DOSWST,SKIP,NSWEEPS,NCHANS,CHAN(0),INBUF(0))

All Calls to LabPac must reference one of the seven variants. Each variant is keyed to the number of parameters in the call. The rule is to count the parameters within the parentheses and subtract one. Use the variant name based on the number of parameters to the call. For example:

result = labpacl%(AIRAW,0)

result = labpac2%(DORAW,1,8)

Microsoft QuickBASIC 4.0 interface modules have a separate subroutine to properly Call the LabPac OPEN and CREATE functions. The subroutine name is "labfile". It is called as in the following example (SADD and VARSEG are QuickBASIC functions):

result=labfile%(CREATE,SADD(FILENAME$),VARSEG(FILENAME$))

The BASIC subdirectory on the LabPac diskette contains the source code for LABMEU.BAS modified for use with QuickBASIC Version 4.0. The file is called QB4MENU.BAS. Use it as an example program.
 

Interface Modules

Two Libraries are included on the LabPac diskette in the BASIC subdirectory (LABPAC.QLB and LABPAC.LIB). When working within the QuickBASIC window environment, use LABPAC.QLB. See the QuickBASIC manual for use of its /L option. When using the external compilation method, use LABPAC.LIB .

return to top of Using BASIC


TURBO BASIC

TurboBasic - The Header File

There is header file on the LabPac diskette called LABHEAD.BTB. When developing the application, substitute this file in place of the LABHEAD.BAS. This file is complete and does not need to be modified. It contains all the necessary declarations to Call LabPac from Turbo Basic.
 

TurboBasic - Call Format

All Calls to LabPac will be formed exactly as they appear in the Technical Reference section. No changes need to be made.
 

TurboBasic - Interface Modules

In the BASIC subdirectory on the LabPac diskette is an interface module called TBASIC.BIN, which is used to Call LabPac. This interface module includes assembler subroutine code to Call the resident portion of LabPac. Refer to the Turbo BASIC manual for more information on the $INLINE function.

return to top of Using BASIC



 

Languages with Interface Modules
FORTRAN
  The Header File
  Defining Terms
  Call Format
  Interface Modules
  Getting Started
C
  The Header File
  Defining Terms
  Call Format
  Interface Modules
  Getting Started
PASCAL
  The Header File
  Defining Terms
  Call Format
  Interface Modules
  Getting Started
APL
  The Header File
  Call Format
  Interface Modules
  Getting Started
 

For many compilers, the most efficient method for accessing the functions of LabPac is through an interface module. The application program uses the Call format discussed in the Interface Conventions chapter. The compiler processes the Call, saving information in a predetermined format. The Call refers to a subroutine declared in a separate program called an interface module (.OBJ). This module is linked into the application during the link phase. It is the subroutine within the interface module that communicates with LabPac through interrupt 66 hexadecimal.

This chapter contains information for calling LabPac functions from FORTRAN, C, Pascal, and STSC APL. Specific hints or cautions on using LabPac are included with each language.
 

FORTRAN

There are two different approaches to calling LabPac routines from FORTRAN applications depending on the compiler being used. Both approaches will use the header files and have the same structure for their scalars, arrays, and strings.

Fortran - The Header File

Two header files can be found in the FORTRAN subdirectory on the LabPac diskette. These files contain important information for defining constants such as LabPac Functions or error coding. Every FORTRAN application program should contain one of these header files as the first section of the program.

The different features contained in the header files are described below.

Since FORTRAN does not allow conditional definitions, eight additional header files are included in the FORTRAN subdirectory. The eight header files define the default I/O address constants for the features on five Scientific Solutions data acquisition products. The files are:

MASTER.MSF or MASTER.RMF

TENDER.MSF or TENDER.RMF

DADIO.MSF or DADIO.RMF

BB.MSF or BB.RMF 

The header files were written for Microsoft FORTRAN Version 4.0. Before using the files, check the compiler manual for possible differences in format or structure of header files.

Fortran - Defining Terms

In FORTRAN all variables, string variables and arrays are declared prior to use. It is best to do this at the beginning of a LabPac application. FORTRAN also allows the use of numbers within the parameter list in a Call statement. This is convenient for LabPac Calls where a parameter is fixed.

Unless otherwise specified, all defined scalars, arrays and strings will be placed in the "no name" common block. Remember that FORTRAN only uses 64K bytes of workspace in each common block. The total amount of space available to use for storing all scalars, arrays, and strings cannot exceed 64K bytes without problems.

When defining and declaring variables, strings and arrays, keep the following points in mind.

FILENAME = 'D:\SUBDIR\DSET1.PRN'C

INBUF(CHANNELS, SWEEPS)

Fortran - Call Format

IBM Professional FORTRAN, Lahey FORTRAN77, Microsoft FORTRAN Version 4.x, and Ryan McFarland FORTRAN use the C calling sequence. Each function documented in Chapter 10 has an example of the C Call format. The following is an example of this sequence.

result = labpac(DOSWST,SKIP,NSWEEPS,NCHANS,CHAN,INBUF)

IBM FORTRAN and Microsoft FORTRAN through Version 3.x use a modified form of the C Call format. For these compilers the function number (DOSWST) is the last parameter in the list as in the following example.

result = labpac(SKIP,NSWEEPS,NCHANS,CHAN, NBUF,DOSWST)

Microsoft FORTRAN interface modules have a seperate subroutine to properly Call the LabPac OPEN and CREATE functions. The subroutine name is "labfile". It is called as in the following example:

result = labfile(CREATE,FILENAME)

Fortran - Interface Modules

When linking programs that have Calls to external subroutines, the LINK program requires the name of the interface module which contains the subroutine. LabPac applications in FORTRAN will Call a specialized interface module that meets the requirements of the compiler and transfers parameters to the correct LabPac Function. The FORTRAN subdirectory contains three OBJ modules.

Microsoft FORTRAN Version 4.x uses interface modules found in the "C" subdirectory of the LabPac software.

Depending on the compiler, use one of these modules when the application is LINKed together. If using a version of FORTRAN not included in the above list and none of the previous modules work, modify one of the source listings in the ASSEMBLE subdirectory according to instructions in the compiler's manual.

Fortran - (using 'calls') Getting Started

The header file can be incorporated into the FORTRAN application using the "include" function of the compiler. Place one of the following sets of statements at the beginning of the application.

$include:'labpac. msf'

$include:'master.msf'

or

include 'labhead.rmf'

include 'master.mf'

After these lines, place the application specific scalar, array, or string definitions and initializations before proceeding with the main section of the program.


C

LabPac subroutines can be called from many different C compilers. The easiest method is to use an interface module linked into the program at compilation time. Standard C calling conventions would then be used to pass LabPac Calls through the module. Several modules are provided in the C subdirectory on the LabPac diskette.

An alternate method is to use the System Call or software interrupt function in the compiler's library. No interface module is required with this method. See the Languages with Software Interrupts chapter for information about this method.

C - (using 'calls') The Header File

In the C subdirectory on the LabPac diskette are two header files. These files contain important information for defining constants such as LabPac Functions or error coding. Every C application program should contain one of these header files as the first section of the program.

The different features contained in the header files are described below.

C - (using 'calls') Defining Terms

When using a small or medium model compiler there will only be 64K bytes of workspace. Calculate how much space is taken up by the scalars, arrays and strings. When using the compact or large models, large arrays can be utilized. Remember that LabPac is restricted to 64K byte strings or data arrays. For maximum performance, always locate large arrays on a segment boundary.

It is especially important to remember that C defines the data arrays as number of sweeps by number of channels. When defining data arrays, use the following format:

INBUF[SWEEPS][CHANNELS]

If data seems to be incorrect or out of place, double check the data array definitions or any place where the data array definitions or any place where the data array was used as a cell designator.

C - (using 'calls') Call Format

The following is an example of the format all LabPac Calls will have.

result = labpac(DOSWST,SKIP,NSWEEPS,NCHANS,CHAN,INBUF);

The word "labpac" is used here as a subroutine name that will be found in the interface module at link time.

C - (using 'calls') Interface Modules

When linking programs that have Calls to external subroutines, the LINK program requires the name of the interface module which contains the external subroutine. The LabPac diskette or work space contains 10 interface modules. Four named DLC.OBJ, PLC.OBJ, LLC.OBJ, and SLC.OBJ are for use with Lattice C. Two named SMWC.OBJ and LMWC.OBJ are for use with the Mark Williams C compiler. Four modules named LARGE.OBJ, MEDIUM.OBJ, COMPACT.OBJ, and SMALL.OBJ are for use with Turbo-C, Microsoft C, and Zortech C or C++.

Depending on the compiler and memory model, use one of these modules when the application is LINKed together. If using a C compiler not included in the above list and none of these modules work, modify one of the source listings in the ASSEMBLE subdirectory according to instructions in the compiler's manual.

C - (using 'calls') Getting Started

The header file should be incorporated into the application programs. Depending on the compiler in use, place one of the following lines at the top of each program.

#include <labpac.h>

or

#include <labpac.btc>

After these lines, add any additional variable or string definitions and initializations before proceeding with the main section of the program.

return to top of Languages with Interface Modules


PASCAL (using 'calls')

Using LabPac with Microsoft Pascal Version 3.3 is the same approach as with Microsoft FORTRAN Version 4.0. The following information will assist in developing applications.

Pascal - (using 'calls') The Header File

In the PASCAL subdirectory on the LabPac diskette is a header file called LABHEAD.MSP. This file contains important information for defining constants such as LabPac Functions or error coding. Every Pascal application program should start with this header file as the first section of the program.

The different features contained in the header file are described below.

Pascal - (using 'calls') Defining Terms

The total amount of space available to use for storing all scalars, arrays, and strings cannot exceed 64K bytes in the small model.

FILENAME:= 'C.\DATA\DSET1.PRN'*CHR(0);

Pascal - (using 'calls') Call Format

Microsoft Pascal Version 3.3 uses the C Call format. An example in the C Call format is shown with every function documented in Chapter 8. Functions can be called as in the following example:

result = labpac(DOSWST,SKIP,NSWEEPS,NCHANS,CHAN,INBUF)

Microsoft Pascal interface modules have a seperate subroutine to properly Call the LabPac OPEN and CREATE functions. The subroutine name is "labfile". It is called as in the following example:

result = labfile(CREATE, FILENAME);

Pascal - (using 'calls') Interface Modules

When linking programs that have Calls to external subroutines, the LINK program requires the name of the interface module which contains the subroutine. LabPac applications in Microsoft Pascal Version 3.3 uses two interface modules found in the "C" subdirectory on the LabPac diskette. Use the LARGE.OBJ or MEDIUM.OBJ interface modules.

Pascal - Getting Started

The header file can be incorporated into the Pascal application using the "include" function of the compiler. Place the following line after the program statement.

$include:'labhead.msp'

After this line, place the application specific scalar, array, or string definitions and initializations before proceeding with the main section of the program.

return to top of Languages with Interface Modules


APL

Using LabPac with STSC APL is different from other languages discussed in this manual. The following information will assist in developing applications.

APL - The Header File

In the APL subdirectory on the LabPac diskette is a workspace called LABHEAD.AWS. This file contains an APL function that initializes the LabPac function numbers and the binary interface module used to Call the LabPac functions.

APL - Call Format

STSC APL uses a unique Call format. An example of the format using the DOSET Function is shown below.

(DOSET,CHANNEL,MASK) CALL LABPAC

APL - Interface Modules

The CALL function requires a variable containing code to execute. This code to initialize 'LABPAC' can be found in the INIT function.

APL - Getting Started

The most convient way to start developing applications in STSC APL is to load the header file (LABHEAD.AWS) and use/edit its functions. The file is loaded using the following command:

)LOAD LABHEAD

The first function to Call is INIT. It does not have any parameters. After the INIT function, define the functions to be used in the application.

return to top of Languages with Interface Modules



 

Languages with Software Interrupts

ASSEMBLER
  The Header File
  Defining Terms
  Interrupt Format
  Getting Started
TURBO PASCAL
  The Header File
  Defining Terms
  Getting Started
  Passing Arrays
C
  Getting Started

Since LabPac installs as a memory resident, BIOS level driver in the INT66H vector, it can be accessed directly by any language with a software interrupt function. For languages such as assembler or Turbo Pascal, this is the only way to call LabPac functions.

When a LabPac function is activated, it looks at the x86 registers to find its parameters and addresses for strings and arrays. Upon completion of its task, it restores values to critical registers, places a status code in the AX register and returns to the calling application. In the technical reference information for each LabPac function, the register assignments appear in parenthesis following the parameter names used in the examples.

When calling LabPac at interrupt 66 hexadecimal, the x86 registers will contain the following type of information.

Register

Function

AH 

Must contain 37 decimal (25 hex)

AL 

Contains the LabPac function number

BX 

The first parameter or offset of a file name string

CX 

Second parameter

DX 

Third parameter

DS 

The segment of a channel array or file name string

SI 

The offset of a channel array

ES 

The segment of a data array

DI 

The offset of a data array

While executing a call, LabPac uses the following guidelines:

When returning from a call, LabPac will use the following guidelines:


ASSEMBLER (using 'interrupts')

When applications are developed in assembler, LabPac Functions are called directly through a software interrupt instruction (INT) without calling intermediate code. All rules and cautions apply for using INT instructions.

Assembler - (using 'interrupts') The Header File

In the ASSEMBLE subdirectory of the LabPac software is a header file (LABHEAD.ASM). This file contains important information for defining constants such as LabPac Functions and error codes. Every assembler application should have this information at the beginning of the program. The different features contained in LABHEAD.ASM are described below.

Assembler - (using 'interrupts') Defining Terms

All integers, channel arrays, and data arrays passed or used by LabPac must be defined as two-byte, full word integers. All filename strings must be ASCII strings. The end of the string must be a null byte.

Assembler - (using 'interrupts') Interrupt Format

To identify the required registers to load before the INT call, refer to the description of the function in the Technical Reference chapter. Paired with each parameter name is the register that must be loaded to pass information to that function. The following is an example of the format all LabPac calls will have.

MOV BX,SKIP
MOV CS,NSWEEPS
MOV DX,NCHANS
MOV AX,SEG INBUF
MOV ES,AX
MOV DI,OFFSET INFUF
MOV AX,SEF CHAN
MOV DS,AX
MOV SI,OFFSET CHAN
MOV AH,37
MOV AL,DOSWST
INT 66H
CALL ERROR_CHECK

Assembler - (using 'interrupts') Getting Started

The header file can be incorporated into application programs very easily. Place the following line after the board equates at the beginning of the program.

INCLUDE LABHEAD.ASM

After the include statement, define all constants, variables, strings and arrays.

return to top of Languages with Software Interrupts



TURBO PASCAL (using 'interrupts')

Turbo Pascal compilers have a function for calling software or BIOS interrupts. This is the INTR function. This function is used to call LabPac routines. Read the Turbo Pascal manual for information on this function.


Turbo Pascal - (using 'interrupts') The Header File

In the PASCAL subdirectory of the LabPac software is a header file (LABHEAD.BTP). This file contains important information for defining constants such as LabPac Functions and error codes. Every Turbo Pascal application should have this information at the beginning of the program.

The different features contained in LABHEAD.BTP are described below.

Turbo Pascal - (using 'interrupts') Defining Terms

Programs written in Turbo Pascal Version 3.0 are restricted to 64K bytes of workspace. Make sure all of the variable scalars do not exceed the 64K byte limit. When using Turbo Pascal Version 4.0, refer to the manual for restrictions in using data arrays beyond the default 64K byte workspace.

Turbo Pascal uses 255 byte strings. The byte directly in front of the first character in the string is a string length indicator. When Turbo Pascal passes the offset of the string to the program, it gives the offset to the string-length indicator. Add one to that offset to point to the first byte in the string.

Turbo Pascal - (using 'interrupts') Getting Started

The header file can be incorporated into application programs very easily. Place the following line as the first line in each program.

{$i labpac.btb}

After this line add any additional variable, array, or string definitions before proceeding with the main section of the program. The following steps must be followed to properly call LabPac from Turbo Pascal.

type

Registers = record

case integer of

0: (AX, BX,CX, DX,SI, DI, DS, ES, Flags :word);

1: (AL,AH,BL,BH,CL,CH,DL,DH :byte);

end;

var

Regs : Registers;

Regs.AX: = AIRAW

intr(lNT66H,Regs);

value: = Regs.AX;

If there are a number of assignments to be made, the Pascal WITH command may be useful:

with Pegs do

begin

AX: = DOSWST;

BX: = SKIP;

CX: = NSWEEPS;

DX: = NCHANS;

DS: = segment(CHAN);

SI: = offset(CHAN);

ES: = segment(lNBUF);

DI: = offset(lNBUF);

intr(lNT66H,Regs);

error: = AX;

end;

Turbo Pascal - (using 'interrupts') Passing Arrays

When passing arrays to subroutines in Pascal, it is very important to declare them as VAR parameters. Without the VAR keyword, the array is copied onto the stack and the subroutine uses a copy of the array. This will not work with background sweep routines. The data on the stack is disturbed as soon as the subroutine returns to the main menu. On any input routine, the copy of the array will be affected, but the array itself will not be updated. Also, writing to a location on the stack may cause the computer to unpredictably crash.

return to top of Languages with Software Interrupts


C (using 'interrupts')

Most C languages have a software interrupt or system call function to use when calling BIOS routines. Using this function to call LabPac routines simplifies the compiler's task as it can jump directly to LabPac. The interface module is not required.

Read carefully, however, the information in the Languages with Interface Modules chapter on the header file and use of strings, scalars, and arrays.

C - Getting Started

The sample calling routine shown below is written for Microsoft C and uses the DOSWST call.

struct XREG

{

short ax,bx,cx,dx,ds,es,si,di;

};

struct HREG

{

char al,ah,bl,bh,cl,ch,dl,dh;

};

union REGS

{

struct XREG x;

struct HREG h;

};

doswst(int skip, int nsweeps, int nchans,

int far*chan, int far*inbuf)

{

union REGS inregs,outregs;

inregs.h.ah = 37 /*AH always = 37*/

inregs.h.al = DOSWST

inregs.x.bx = skip;

inregs.x.cx = nsweeps;

inregs.x.dx = nchans;

inregs.x.si = FP_OFF(chan);

inregs.x.ds = FP_SEG(chan);

inregs.x.di = FP_OFF(inbuf);

inregs.x.es = FP_SEG(inbuf);

int86x(0x66,&inregs,&outregs);

if (outregs.x.ax ! = nbytes) error( );

/* call error func */

return(outregs.x.ax);

};

return to top of Languages with Software Interrupts


Technical Reference

This section contains the technical information for the functions in LabPac. When reading the technical information, keep the following points in mind.

Following are two tables:

(1). Functions are first listed by category (i.e., analong in, analog out, etc).

(2). Functions are listed in alphabetical order.

General Funtion's for each Routine

INITIALIZATION
ANALOG INPUT
ANALOG OUTPUT
DIGITAL INPUT
DIGITAL OUTPUT
TIMING/COUNTING
TIMED INTERVAL PROCESSES
SWEEP START ROUTINES
SWEEP STATUS ROUTINES
SWEEP STOP ROUTINES
FILE I/O HANDLING
UTILITY ROUTINES

Alphabetical Listing of Function's

ACCESS Put EMS buffer in EMs memory segment
AIDMA DMA Direct memory access
AIGAIN Set gain level for one channel
AIHDW Externally triggered conversions
AIINIT Analog input initialization
AIMAX Fast rate conversions
AIRAW Sample a single input line
AIRSWST Repeating analog input sweep
AISC Wait until a threshhold is crossed
AISTAT Analog input
AISWAB Analog input
AISWST Analog input sweep
ALLOC Establish an EMS data buffer
AOINIT Analog output initialization
AOMAX Maximum rate output
AORAW Output a single channel
AORSWST Repeating analog output sweep
AOSTAT Analog output
AOSWAB Analog output
AOSWST Analog output sweep
BCD Converts binary to BCD
BIN Converts BCD to binary
BINRD Read data from a binary file
BINWR Write data to a binary file
CLOSE Close a file
CREATE Open a file for saving data
DIHDW Maximum rate with handshaking
DIMAX Maximum rate inputs
DINIT Digital I/O initialization
DIRAW Read a single channel
DIRSWST Repeating digital input sweep
DISC Wait until a value is equaled
DISTAT Digital input
DISWAB Digital input
DISWST Digital input sweep
DMASTAT Determine end of DMA transfer
DOCLR Clear and output a masked value
DOHDW Maximum rate with handshaking
DOMAX Maximum rate output on a single channel
DORAW Output a single sample
DORSWST Repeating digital output sweep
DOSET Set and output a masked value
DOSTAT Digital output
DOSWAB Digital output
DOSWST Digital output sweep
FREE Return EMS buffer to general use
GETTIME Get time-of-day from timer channel
INTCLR Enable interrupt lines
INTSET Disable interrupt lines
OPEN Open a file for reading data
READ Read data from an ASCII file
RESET Master reset
SCRAW Output a Set/Clear mask
SETALARM Set the Alarm Register on counter 1 or 2
SETTIME Set the time-of-day on a timer channel
SWINIT Sweep initialization
TIAB Stop a timer/counter channel
TIHDW Independent timer/counter programming
TIINIT Timer/Counter initialization
TILH Waveform output
TIRAW Read the timer/counter channel
TIST Start a timer/counter channel
TISTAT Wait for a value of a timer/counter
WRITE Save data in an ASCII file

INITIALIZATION

As noted in the Installation chapter, LabPac contains several internal tables. The initialization subroutines fill the internal tables with information such as I/O addresses, hardware configuration, level of gain, or physical I/O line numbers. There are five functions that initialize different LabPac features and one function to reset or clear the internal tables. Initialization functions are:

AIINIT Analog input initialization
AOINIT Analog output initialization
DINIT Digital I/O initialization
RESET Master reset
SWINIT Sweep initialization
TIINIT Timer/Counter initialization

return to top of Technical Reference



ANALOG INPUT

The LabPac analog input routines handle the function of Analog-to-Digital Conversion. The available non-interrupt driven routines are:

AIDMA Direct memory access
AIGAIN Set gain level for one channel
AIHDW Externally triggered conversions
AIMAX Fast rate conversions
AIRAW Sample a single input line
AISC Wait until a threshhold is crossed
DMASTAT Determine end of DMA transfer

return to top of Technical Reference




ANALOG OUTPUT

The LabPac analog output routines handle the function of Digital-to-Analog conversion. The available non-interrupt driven routines are:

AOMAX Maximum rate output
AORAW Output a single channel

return to top of Technical Reference




DIGITAL INPUT

The LabPac digital input routines handle the function of Digital Input using the 8255A compatible register on the Scientific Solutions' board. The McDAS interfaces handle two lines of digital input. The available non-interrupt driven routines are:

DIHDW Maximum rate with handshaking
DIMAX Maximum rate inputs
DIRAW Read a single channel
DISC Wait until a value is equaled

return to top of Technical Reference



DIGITAL OUTPUT

The LabPac digital output routines handle the function of Digital Output using the 8255A compatible register on the Scientific Solutions' board. The McDAS interfaces handle two lines of digital input. The available non-interrupt driven routines are:

DOCLR Clear and output a masked value
DOHDW Maximum rate with handshaking
DOMAX Maximum rate output on a single channel
DORAW Output a single sample
DOSET Set and output a masked value
SCRAW Output a Set/Clear mask

return to top of Technical Reference



TIMING/COUNTING

The LabPac timing/counting routines handle the ability to count or time events using the 9513A Timer/Counter device on the Scientific Solutions' boards. The available non-interrupt driven routines are:

GETTIME Get time-of-day from timer channel
SETALARM Set the Alarm Register on counter 1 or 2
SETTIME Set the time-of-day on a timer channel
TIAB Stop a timer/counter channel
TIHDW Independent timer/counter programming
TILH Waveform output
TIRAW Read the timer/counter channel
TIST Start a timer/counter channel
TISTAT Wait for a value of a timer/counter
return to top of Technical Reference



TIMED INTERVAL PROCESSES

Analog I/O and digital I/O channels can be sampled or written to in groups at specified intervals using the LabPac hardware interrupt driven routines. There are three subroutines associated with every interrupt driven sweep. These are the start routine, the status routine and the stop routine. Each sweep is made over a specified number of channels. The number of sweeps is specified by the user and must be dimensioned in the data array. All four processes can be set up to repeat the sweeps without additional Calls. There are 16 function Calls associated with sweeps.

Each of the three types of subroutines for sweeps serves the same function and requires the same information. A brief description of the three types of subroutine follows.

Sweep Start Routines

These routines initialize indexes in the interrupt handler and start the first sweep before returning from the Call. Several parameters need to be supplied in the Call. One parameter is the time interval (the number of interrupts that are to occur between each sweep). Two additional parameters are the number of times to sweep all the channels and the number of channels to be sampled or sent. Another parameter is the data array. The final parameter is the array that contains the channel numbers to be used in the order in which they are to be accessed during the sweep. Once started, sweeps will continue until the specified number of sweeps has occured or a sweep abort has been called. Aborted sweeps can be restarted by these Calls.

AISWST Analog input sweep
AOSWST Analog output sweep
DISWST Digital input sweep
DOSWST Digital output sweep
AIRSWST Repeating analog input sweep
AORSWST Repeating analog output sweep
DIRSWST Repeating digital input sweep
DORSWST Repeating digital output sweep

return to top of Technical Reference



Sweep Status Routines

These routines check to see which sweep will occur on the next interrupt. This is done by checking an internal counter which keeps track of how many sweeps are left counting from the last sweep start Call: These routines require that a value be passed to compare against the internal counter. Control will not be returned to the main program until the number of sweeps left to go is equal to or less than the specified number. On return from the Call, the number of sweeps left to go is contained in the error variable.

AISTAT Analog input
AOSTAT Analog output
DISTAT Digital input
DOSTAT Digital output
return to top of Technical Reference



Sweep Stop Routines

These routines stop the specified type of sweep by setting the Status index to zero. The number of sweeps that were left to execute is returned in the error variable.

AISWAB Analog input
AOSWAB Analog output
DISWAB Digital input
DOSWAB Digital output
return to top of Technical Reference



FILE I/O HANDLING

In the Interface Conventions chapter the external file handling characteristics of LabPac were discussed. There are seven subroutines associated with the opening and closing of files and the reading from or writing to files. The function Calls are:

BINRD Read data from a binary file
BINWR Write data to a binary file
CLOSE Close a file
CREATE Open a file for saving data
OPEN Open a file for reading data
READ Read data from an ASCII file
WRITE Save data in an ASCII file

return to top of Technical Reference



UTILITY ROUTINES

LabPac contains seven utility functions. These functions maximize data acquisition, establish EMS data buffers, or perform BCD/Binary transformations. The seven functions are:

ACCESS Put EMS buffer in EMs memory segment
ALLOC Establish an EMS data buffer
BCD Converts binary to BCD
BIN Converts BCD to binary
FREE Return EMS buffer to general use
INTCLR Enable interrupt lines
INTSET Disable interrupt lines
return to top of Technical Reference


ACCESS Map EMS Buffer to Memory

PURPOSE:

This routine moves an EMS data buffer allocated to LabPac into the EMS memory segment where it can be accessed by application routines other than LabPac.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(HNDL, RESULT, ACCESS)

C:

result = labpac(ACCESS, HNDL);

PARAMETERS:

Access (al):

The function number = 55

Hndl (bx):

The handle of the EMS buffer returned by the ALLOC function.

Result (ax):

On return from the Call, the variable RESULT (ax) contains the error code from the subroutine. A zero indicates that the Call was successful. The error message EMMERR indicates that an illegal EMS buffer handle was used.

REMARKS:

An EMS driver or virtual memory manager must be installed for this Call to work. The ACCESS function allows for directly reading from or writing to an EMS buffer without using Calls to LabPac. After ACCESS has returned, the data buffer will be available in the EMS memory segment. LabPac functions, including background sweep accesses, use EMS memory transparently.

return to top of Technical Reference



AIDMA DMA Analog Input Sweeps

PURPOSE:

This routine provides for collecting samples on one or more analog input channels. An external trigger is required to start the A/D conversions. The data is transferred in the background to a memory buffer using DMA. Between one and 256 channels can be sampled as long as they are consecutively located on one Scientific Solutions' interface. All channels will be converted for the level of gain of the first channel. This routine can maximize data collection. Key information to supply is the number of the first channel, the number of channels to sample, the number of samples per channel, and the data array.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(FRST,NSWPS,NCHNS,IBUF(0,0),RESULT,AIDMA)

C:

result = labpac(AIDMA, FRST, NSWPS, NCHNS,IBUF);

PARAMETERS:

Aidma (al):

The function number = 49

Frst (bx):

Contains the channel number of the first analog input to be converted on the Lab Master DMA or DAS series interface. This number is from the Analog Input Channel Table.

Nswps (cx):

Contains the number of times a set of analog input channels are to be converted and the results stored in the data buffer.

Nchns (dx):

Contains the number of channels that are to be converted for each set.

Ibuf, Ibuf(Chn,Swp), (ds:si):

This variable is the pointer to the starting address in memory for an input data array. See the discussion in the Techniques chapter.

Result (ax):

On return from the Call, the variable RESULT (ax) contains the error code from the subroutine. A zero indicates that the Call was successful. The error message RANGE indicates that a channel number was too large. The error message DMAERR indicates the data buffer crossed a 64K boundary.

REMARKS:

The DMA channel to be used is selected in the AIINIT Call.

All channels must be on the same board. If the board has a software programmable gain option, the gain corresponding to the first channel converted is used.

A hardware trigger must be installed on the Lab Master DMA. This is a positive going, +5 volt TTL edge usually externally generated, that connects to pin 45 on J8 on the Lab Master DMA. If the 9513A counter 5 is used, connect the ESOC jumper. There are also usable sources on each board for the signal. See the installation manual.

The DAS series interface uses the output of counter 5 to start the A/D conversions. Be sure to start timer/counter channel 5 before executing AIDMA.

If NCHNS is not equal to one, the Auto-Increment feature is utilized. With the Lab Master DMA, make sure the daughter board switches are set for the last channel to be converted. Since there is no channel array to show which channels to convert as in the interrupt driven sweep functions, hardware channels are consecutively sampled starting with a channel number from the Analog Input Channel Table. LabPac will calculate and properly program the DAS series interface for the first and last channels in auto-increment mode.

To know when the the DMA transfer is finished or to check its current status, install the DONE jumper on the Lab Master DMA. Start one of the timer/counter channels using SRC3 as the source. With the DAS series interface use the FIFO transfer source option. Start the timer/counter before the AIDMA Call. To find out how many samples have been taken, use TIRAW to read the current count. To have the program pause until a specified number of samples has occurred, use TISTAT.

Use DMASTAT to determine when the requested DMA transfer is completed. This is useful when consecutive Calls to AIDMA will be used with minimal time between Calls.

When using a data buffer assigned to the EMS memory segment, do not use any procedures that will operate simultaneously with AIDMA and also use EMS memory. If DMASTAT is used to identify when the DMA transfer is completed, it will replace the buffer in the EMS memory segment with the buffer in use prior to the AIDMA Call.

return to top of Technical Reference



AIGAIN Set Programmable Gain

PURPOSE:

This routine provides a way of modifying the gain setting for one channel previously initialized in the Analog Input Gain Table. Key information is the channel number and the new gain value.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(CHN, GAIN, RESULT, AIGAIN)

C:

result = labpac(AIGAIN, CHN, GAIN);

PARAMETERS:

Aigain (al):

The function number = 65

Chn (bx):

The number of the analog input channel to be used (from the Analog Input Channel Table).

Gain (cx):

This variable is equal to a gain value for use with programmable gain options on Lab Master DMA, Lab Master and DAS series products. Use the following table for the gain values.

Value

PGH

PGL

McDAS

10 

100 

10 

500 

100 

Result (ax):

On return from the Call, RESULT (ax) contains the error code from the subroutine. A zero indicates the Call was successful. The error message of RANGE indicates the analog input channel was out of range. The error message of PARAM indicates that the gain value was out of range or the analog input channel was associated with a Lab Tender.

REMARKS:

When analog input channels are initialized, the gain values are established for all channels. AIGAIN will reset the value in the gain table to a new value.

When MC-DAS series products are in use, AIGAIN is required to set channels for gains other than unity (gain value = 0).

return to top of Technical Reference



AIHDW Triggered Analog Input Sweeps

PURPOSE:

This routine provides for collecting samples on one or more analog input channels using an external trigger to start the A/D conversions. Between one and 256 channels can be sampled as long as they are consecutively located on one Scientific Solutions' interface. This routine can be used to maximize data collection. Key information to supply is the number of the first channel, the number of channels to sample, the number of samples, and the data array.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(FIRST,NSWPS,NCHNS,IBUF(0,0) RESULT,AIHDW)

C:

result = labpac(AIHDW, FIRST, NSWPS, NCHNS, IBUF);

PARAMETERS:

Aihdw (al):

The function number = 40

First (bx):

Contains the channel number from the Analog Input Channel Table for the first channel in the sequence to be converted.

Nswps (cx):

Contains the number of times a set of analog input channels are to be converted and the results stored in the data buffer.

Nchns (dx):

Contains the number of channels that are to be converted in each set.

Ibuf, Ibuf(Chn,Swp), (ds:si):

This variable is the pointer to the starting address in memory for an input data array. See the discussion in the Techniques chapter.

Result (ax):

On return from the Call, the variable RESULT (ax) contains the error code from the subroutine. A zero indicates that the Call was successful. The error message RANGE indicates that a channel number was too large. The error message PARAM indicates that the number of channels (NCHNS) times the number of sweeps (NSWPS) is 0 or greater than 32,767.

REMARKS:

All channels must be on the same board. A hardware trigger must be installed. This is a positive going, +5 volt TTL edge that connects to pin 45 on J8 on the Lab Master DMA, pin 3 of J2 on the Lab Master, or pin 1 on 54 on the Lab Tender. If counter 5 is used on a Lab Master DMA, connect the ESOC jumper. See the installation manual.

On an DAS series interface series product, counter 5 is used to start A/D conversions. Timer/counter channel 5 must be started.

For hardware with a software programmable gain feature, the gain corresponding to the first channel is used.

If NCHNS is not equal to one and a Lab Master DMA or Lab Master is used, the Auto-Increment feature is utilized. Make sure the daughter board switches are set for the last channel to be converted. Since there is no channel array to show which channels to convert as in the interrupt driven sweep functions, hardware channels are consecutively sampled starting with the channel number in FIRST. On a DAS series interface, the first and last channels are programmed.

On a Lab Tender the input lines will be sampled consecutively starting with the input specified in CHN (bx).

For maximum speed (faster than 20 KHz) the PC system interrupts should be turned off. See the discussion in the Techniques chapter.

return to top of Technical Reference



AIINIT Analog Input Initialization

PURPOSE:

This routine fills the Analog Input Channel Table. The table contains room for the number of channels installed by the /AI command line option (Default is 16). Key information to supply is the address of the A/D Control Register on the Scientific Solutions data acquisition board, and the number of analog inputs that will be used at that address, any optional gain and DMA parameters. AIINIT can be called several times to install multiple channels across several boards. (Not required in PS/2 MicroChannel systems).

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(ADRS, NCHNS, DMA, GAIN(0), RESULT, AIINIT)

C:

result = labpac(AIINIT, ADRS, NCHNS, DMA, GAIN);

PARAMETERS:

Aiinit (al):

The function number = 5

Adrs (bx):

The I/O address of the A/D Control Register.

 
Lab Master DMA

Base + 4 

Lab Master

Base + 4 

Lab Tender

Base + 0 

ISA DAS series

Base + 8 

Nchns (cx):

The number of A/D input channels to be used at the given address.

Dma (dx):

The DMA channel to use with AIDMA. Use a zero for non-DMA products or if DMA will not be used.

Gain, Gain(0) (ds:si):

This variable is the pointer to the starting address in memory for an array of gain values. The array must exist even when the hardware has no programmable gain option. The Gain array equals the number of channels initialized at the base I/O address in the order the channels appear on the board.

If the gain values are always unity, GAIN can be set equal to the NULL pointer. (i.e. si = 0) Use the table shown below for gains.

Value

PGH

PGL

McDAS

10 

100 

10 

500 

100 

Result (ax):

On return from the Call, RESULT (ax) contains the total number of initialized analog input channels or the error code from the subroutine. The error message of PARAM indicates an illegal DMA value. The error message of TABLE indicates an attempt was made to initialize too many channels.

REMARKS:

The maximum number of A/D channels that LabPac can process is specified by the /AI command line option. The default maximum is 16.

This Call has no function in PS/2 MicroChannel computers. If it is included in a program, the request will be ignored.

return to top of Technical Reference



AIMAX Maximum Rate A/D Sweeps

PURPOSE:

This routine causes analog to digital conversions on a set of channels as fast as possible. A timer/counter channel is used to determine the time interval between the start of the conversions of the first channel in each set. This routine can do at least 10,000 conversions per second.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(TMR, NSWPS, NCHNS, CHN(0), IBUF(0,0), RESULT, AIMAX)

C:

result = labpac(AIMAX, TMR, NSWPS, NCHNS, CHN, IBUF);

PARAMETERS:

Aimax (al):

The function number = 15
 

Tmr (bx):

The variable TMR (bx) is the channel number from the Timer/Counter Channel Table. The output signal for this timer/counter is monitored to determine the time interval between the start of consecutive sets of samples. The timer/counter channel cannot be an FOUT signal. Each time the 9513A counter reaches terminal count, a set of channels is processed.

Nswps (cx):

This variable contains the number of samples to be conducted for each channel. This number should be greater than zero and equal to or less than the value used to dimension the number of samples in the data array. The maximum number of samples is 32,767.

Nchns (dx):

This variable contains the number of A/D channels in each set to be converted during each interval. The range is one to 32,767. The channels must occupy consecutive cells in the channel array.

Chn, Chn(0), (ds:si):

This variable is the pointer to the starting address in memory for an array containing the A/D channel numbers in any order.

Ibuf, Ibuf(Chn,Swp), (es:di):

This variable is the pointer to the starting address in memory for an input data array. See the discussion in the Techniques chapter.

Result (ax):

On return from the Call, RESULT (ax) contains the error code from the subroutine. A zero indicates that the Call was successful. The error message PARAM indicates that the number of channels (NCHNS) times the number of sweeps (NSWPS) is 0 or greater than 32,767. The error message RANGE indicates a channel number was too large. The error message TIMERR indicates the timer/counter channel was not started or an FOUT signal was selected.

REMARKS:

This routine runs in the foreground and will not return until all the samples are completed. It is recommended that background analog input sweeps are not active during the period when AIMAX is active to avoid conflicts and A/D data overruns.

return to top of Technical Reference



AIRAW Analog Input Read

PURPOSE:

This routine causes an analog to digital conversion on a single channel and returns the sample. Key information to supply is the channel number from the Analog Input Channel Table.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(CHN, RESULT, AIRAW)

C:

result = labpac(AIRAW, CHN);

PARAMETERS:

Airaw (al):

The function number = 10

Chn (bx):

This variable contains the channel number from the Analog Input Channel Table.

Result (ax):

On return from the Call, the variable RESULT (ax) contains the value of the sample. The error message RANGE indicates an illegal channel number.

return to top of Technical Reference



AIRSWST Repeating Analog Input

PURPOSE:

Initialize the analog input process to repeatedly sample a specified number of sets of analog channels at specified intervals between sets.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(SKP, NSWPS, NCHNS, CHN(0), IBUF(0,0), RESULT, AIRSWST)

C:

result = labpac(AIRSWST,SKP,NSWPS,NCHNS,CHN,IBUF);

PARAMETERS:

Airswst (al):

The function number = 60
 

Skp (bx):

The variable SKP (bx) is the number of service cycles (one service cycle equals four interrupt intervals) to skip between sweeps. If an A/D sweep is required every service cycle, use the value one. The maximum number of service cycles that can be skipped is 65,535. The value zero will restart the A/D sweeps where the process was turned off by an AISWAB Call.
 

Nswps (cx):

This variable contains the number of sweeps to be conducted. This number should be greater than zero and equal to or less than the value used to dimension sweeps in the data array. The maximum number of sweeps is 32,767.

Nchns (dx):

This variable contains the number of A/D channels to be converted during each sweep. The range is one to 32,767. The channels must occupy consecutive cells in the channel array.

Chn, Chn(0), (ds:si):

This variable is the pointer to the starting address in memory for an array containing the A/D channel numbers in any order.

Ibuf, Ibuf(Chn,Swp), (es:di):

This variable is the pointer to the starting address in memory for an input data array. See the discussion in the Techniques chapter.

Result (ax):

On return from the Call, RESULT (ax) contains the error code from the subroutine. A zero indicates that the Call was successful. The error message PARAM indicates that the number of channels (NCHNS) times the number of sweeps (NSWPS) is 0 or greater than 32,767. The error message RANGE indicates a channel number was too large.

If zero was the parameter used in SKP (bx), then RESULT (ax) will contain the number of sweeps that were left to be done when the sweeps are restarted.

REMARKS:

This function starts a repeating analog input sweep. After Nsweeps of data are collected, the buffer is reused starting at the beginning. Immediately prior to return, AIRSWST sets the interrupt handler to begin the sweeps at the next interrupt.

return to top of Technical Reference



AISC Analog Input Monitor

PURPOSE:

This routine continuously converts a fixed analog input channel. The sampled value is then compared to a pair of values supplied in the Call to see if the specified values have been reached or crossed in a positive or negative direction. The direction of the crossing depends on the way the two values are entered into the Call. This routine is referred to as zero-cross or threshhold detection. The routine can have some value in peak detection if a threshhold value can be selected above signal noise.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(CHN, START, FINISH, RESULT, AISC)

C:

result = labpac(AISC, CHN, START, FINISH);

PARAMETERS:

Aisc (al):

The function number = 45

Chn (bx):

Contains the channel number from the Analog Input Channel Table.

Start (cx):

Contains the value which is compared to the value sampled with each A/D conversion. This is referred to as the threshhold. Ranges are:

Bipolar -128 to 127 (8-bit resolution)
  -2048 to 2047 (12-bit)
  -32,768 to 32,767 (16-bit)
 
Unipolar 0 to 255 (8-bit resolution)
  0 to 4095 (12-bit)
  0 to 65,535 (16-bit)

Finish (dx):

Contains the value used to determine the direction that the threshhold was crossed. If FINISH (dr) is less than START (cx), then a negative direction is indicated. If FINISH is greater than START, then a positive direction is indicated. If FINISH equals 0 a positive direction is assumed. Ranges are the same as shown above for the parameter START.

Result (ax):

On return from the Call, the variable RESULT (ax) contains the error code from the subroutine. The error message RANGE indicates that a channel number was too large. Otherwise, the Call returns with the last analog value read.

REMARKS:

This Call detects one positive or negative transition on an analog input channel. The value START indicates the threshhold to look for while the value FINISH indicates the direction of crossing. For example, if START equals zero and FINISH equals one then LabPac will wait for a positive zero-crossing (i.e., the channel must go below zero and then go above one) before returning control to the main program. If START equals 273 and FINISH equals 260 then LabPac will wait for the channel to go above 273 and then wait for the channel to go below 260. If START and FINISH are equal to each other, LabPac will assume a positive direction.

return to top of Technical Reference



AISTAT Analog Input Sweep Status

PURPOSE:

Check the current status of the A/D conversion sweep process and return control to the main program when the number of sweeps that are left to be done is less than a specified value.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(NSWEEP, RESULT, AISTAT)

C:

result = labpac(AISTAT, NSWEEP);

PARAMETERS:

Aistat (al):

The function number = 25

Nsweep(bx):

This variable contains the value which is compared to the value in the A/D sweep counter in the LabPac interrupt handler. Assigning the value of zero means that the main program will not continue until completion of all A/D conversion sweeps.

Result (ax):

On return from the Call, the variable RESULT (ax) contains the value of the A/D Sweeps Left index from the LabPac interrupt handler. If the length of time programmed into the Service Cycle interval is too short to complete the A/D sweeps, RESULT will return with an OVERRUN error.

REMARKS:

NOTE that this Call will HALT the main program until the number of sweeps that remain to be done is less than or equal to the value specified in NSWEEP (bx). To find out the number of sweeps remaining without halting the main program, specify either a value greater than the number of sweeps requested in AIRSWST or AISWST for NSWEEP (bx).

return to top of Technical Reference



AISWAB Analog Input Sweep Abort

PURPOSE:

Stop the background interrupt handler from processing further A/D sweeps.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(RESULT, AISWAB)

C:

result = labpac(AISWAB);

PARAMETERS:

Aiswab (al):

The function number = 30

Result (ax):

On return from the Call, the variable RESULT (ax) contains the number of sweeps that were left to be done when the sweep subroutine was halted.

return to top of Technical Reference



AISWST Analog Input Sweeps

PURPOSE:

Initialize the background interrupt handler to sample a specified number of sets of A/D channels at specified intervals between sets.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(SKP, NSWPS, NCHNS, CHN(0), IBUF(0,0), RESULT, AISWST)

C:

result = labpac(AISWST, SKP, NSWPS, NCHNS, CHN, IBUF);

PARAMETERS:

Aiswst (al):

The function number = 30
 

Skp (bx):

The variable SKP (bx) is the number of service cycles (one service cycle equals four interrupt intervals) to skip between sweeps. If an A/D sweep is required every service cycle, use the value one. The maximum number of service cycles that can be skipped is 65,535. The value zero will restart the A/D sweeps where they left off after being turned off by a AISWAB Call.
 

Nswps (cx):

This variable contains the number of sweeps to be conducted. This number should be greater than zero and equal to or less than the value used to dimension sweeps in the data array. The maximum number of sweeps is 32,767.

Nchns (dx):

This variable contains the number of A/D channels to be converted during each sweep. The range is one to 32,767. All the channels to be used must occupy consecutive cells in the channel array.

Chn, Chn(0), (ds:si):

This variable is the pointer to the starting address in memory for an array containing the A/D channel numbers in any order.

Ibuf, Ibuf(Chn,Swp), (es:di):

This variable is the pointer to the starting address in memory for an input data array. See the discussion in the Techniques chapter.

Result (ax):

On return from the Call, RESULT (ax) contains the error code from the subroutine. A zero indicates that the Call was successful. The error message PARAM indicates that the number of channels (NCHNS) times the number of sweeps (NSWPS) is 0 or greater than 32,767. The error message RANGE indicates a channel number was too large.

If zero was the parameter used in SKP (bx), then RESULT (ax) will contain the number of sweeps that were left to be done when the sweeps are restarted.

REMARKS:

Immediately prior to return, AISWST sets the interrupt handler to begin the sweeps at the next interrupt.

return to top of Technical Reference



ALLOC Establish EMS Buffer

Purpose:

This routine requests that an EMS data buffer be allocated to LabPac for use by its data acquisition or control functions. The EMS memory management driver will allocate up to 64K bytes of EMS memory for this purpose. This Call can be repeated until the EMS hardware is out of memory.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(NBYTES, RESULT, ALLOC)

C:

result = labpac(ALLOC, NBYTES);

PARAMETERS:

Alloc (al):

The function number = 54

Nbytes (bx):

This variable identifies the number of bytes to be allocated by the EMS driver for the data buffer. The EMS driver will assign memory space in 16 Kbyte increments. Multiple buffers can be allocated up to the amount of memory on the EMS hardware.

Result (ax):

On return from the Call, the variable RESULT (ax) contains either an error message or a number assigned by the EMS driver to identify the allocated data buffer. The number is referred to as the EMS buffer handle. The error message EMMERR indicates there is not enough EMS memory to cover the requested data buffer.

High Word Result (dx):

On return from the Call, the DX register contains the memory segment where the EMS buffers can be directly accessed from a program.

REMARKS:

An EMS driver program must be installed for this Call to work.

The information (dx:ax) returned by the ALLOC function is the segment:offset pair required by any LabPac Call using a data buffer. For example, in the AIMAX routine the input data buffer is identified by the values in the ES:DI registers. The value returned by ALLOC in the DX register should be placed in the ES register. The value returned by ALLOC in the AX register should be placed in the DI register.

For languages where access to the DX register on return from a Call is not allowed, the address of the EMS memory segment must be previously identified.

Some languages, particularly those that use "Call by Address" conventions, are unable to use EMS buffers. Advanced BASIC, IBM Compiled BASIC, and Microsoft FORTRAN before Version 4.0 are in this group.

In order to directly access the data in an EMS buffer by routines other than those contained in LabPac, issue the ACCESS Call.

return to top of Technical Reference



AOINIT Analog Output Initialization

PURPOSE:

This routine fills the Analog Output Channel Table. The table can contain as many channels as indicated by the /AO command line option (Default is 4). Key information to supply is the address of the first D/A Control Register on the Scientific Solutions data acquisition board, and the number of D/A channels on each board (1, 2, 4 or 16). AOINIT can be called several times to install channels on several boards. (Not required in PS/2 MicroChannel systems).

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(ADRS, NCHNS, MODE, RESULT, AOINIT)

C:

result = labpac(AOINIT, ADRS, NCHNS, MODE);

PARAMETERS:

Aoinit (al):

The function number = 7

Adrs (bx):

The I/O address of the first D/A Control Register. Use the following table to calculate the value of ADRS (bx):

 
Lab Master DMA

Base + 0 

Lab Master

Base + 0 

Lab Tender

Base + 4 

DADIO

Base + 0 

ISA DAS

Base + 6 

Nchns (cx):

The number of D/A output channels to use at this address. Since each board has a different number of analog outputs, NCHNS MUST have one of the following values:

 
DAS series

Base + 1 

Lab Master DMA

Base + 2 

Lab Master

Base + 2 

Lab Tender

Base + 16 

DADIO

Base + 4 

Mode (dx):

Bit mask of the D/A converter mode. If a bit is "1" the corresponding analog output channel is Unipolar. If the bit is "0", the channel is Bipolar.

Result (ax):

On return from the Call, RESULT (ax) contains the total number of analog output channels that have been initialized or the error code from the subroutine. The error message TABLE indicates an attempt was made to initialize too many channels. The error message PARAM indicates an illegal address was used or the variable NCHNS (cx) was not equal to 1, 2, 4, or 16.

REMARKS:

This Call has no function in PS/2 MicroChannel computers. If included in a program, the request will be ignored.

The maximum number of D/A channels that LabPac can process is deterSmined by the /AO command line option. The default is four.

Remember that the Lab Tender D/A outputs should be refreshed at 150 millisecond intervals to hold their signal. The best method is to use the repeating sweeps routine, AORSWST

return to top of Technical Reference



AOMAX Maximum Rate D/A Sweeps

PURPOSE:

This routine outputs data on a set of channels as fast as possible. A timer/counter channel is used to determine the time interval between the start of the outputs on the first channel in each set. This feature can output at least 10,000 channels per second.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(TMR, NSWPS, NCHNS, CHN(0), OBUF(0,0), RESULT, AOMAX)

C:

result = labpac(AOMAX,TMR,NSWPS,NCHNS,CHN,OBUF);

PARAMETERS:

(al):

The function number = 17
 

Tmr (bx):

The variable TMR (bx) is the channel number from the Timer/Counter Channel Table. The output signal for this timer/counter is monitored to determine the time interval between the start of consecutive sets of outputs. The timer/counter channel cannot be an FOUT signal. Each time the 9513A counter reaches Terminal Count, a set of channels is processed.

Nswps (cx):

This variable contains the number of samples to be output for each channel. This number should be greater than zero and equal to or less than the value used to dimension samples in the data array. The maximum number of samples is 32,767.

Nchns (dx):

This variable contains the number of D/A channels to be output during each set. This number must be greater than zero and less than 32,767. All the channels to be used must occupy consecutive cells in the channel array.

Chn, Chn(0), (ds:si):

This variable is the pointer to the starting address in memory for an array containing the A/D channel numbers in any order.

Obuf, Obuf(Chn,Swp), (es:di):

This variable is the pointer to the starting address in memory for an output data array. See the discussion in the Techniques chapter.

Result (ax):

On return from the Call, RESULT (ax) contains the error code from the subroutine. A zero indicates that the Call was successful. The error message PARAM indicates that the number of channels (NCHNS) times the number of sweeps (NSWPS) is 0 or greater than 32,767. The error message RANGE indicates a channel number was too large. The error message TIMERR indicates the timer/counter channel was not started or an FOUT signal was selected.

REMARKS:

For each time interval, values will be consecutively drawn from the data array and output to the channels identified in the channel array. This routine runs in the foreground and will not return until all the samples are output. It is recommended that background analog output sweeps are not conducted during the time this Call is active.

return to top of Technical Reference



AORAW Analog Output Write

PURPOSE:

The purpose of this function is to take a value, convert it into the correct analog signal and send it out over the output channel.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(CHN, OUTPUT, RESULT, AORAW)

C:

result = labpac(AORAW, CHN, OUTPUT);

PARAMETERS:

Aoraw (al):

The function number = 12

Chn (bx):

This variable contains the channel number from the Analog Output Channel Table.

Output (cx):

This variable contains the value to be sent to the analog output channel.

Result (ax):

On return from the Call, the variable RESULT (ax) contains the error code from the subroutine. A zero indicates that the Call was successful. The error message RANGE indicates that a channel number was too large.

REMARKS:

Remember that Lab Tender D/A outputs need to be refreshed at least every 150 milliseconds in order to prevent drooping. The best Call to use is AORSWST.

return to top of Technical Reference



AORSWST Repeating Analog Output

PURPOSE:

Initialize analog output process to repeatedly send a set of data to analog output channels at specified intervals between sets.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(SKP, NSWPS, NCHNS, CHN(0), OBUF(0,0), RESULT, AORSWST)

C:

result = labpac(AORSWST,SKP,NSWPS,NCHNS,CHN,OBUF);

PARAMETERS:

Aorswst (al):

The function number = 47

Skp (bx):

The variable SKP is the number of service cycles (one service cycle equals four interrupt intervals) to skip between sweeps. If a D/A sweep is required every service cycle, use the value one. The maximum number of service cycles that can be skipped is 65,535. The value zero will restart the D/A sweeps where the process was turned off by a AOSWAB Call.

Nswps (cx):

This variable contains the number of different sweeps to be conducted. This number should be greater than zero and equal to or less than the value used to dimension sweeps in the data array. The maximum number of sweeps is 32,767. After Nswps have been completed, AORSWST restarts its output from the beginning of the data buffer.

Nchns (dx):

This variable contains the number of D/A channels to be output during each sweep. This number must be greater than ten, and less than 32,767. All the channels to be used must occupy consecutive cells in the channel array.

Chn, Chn(0), (ds:si):

This variable is the pointer to the starting address in memory for an array containing the A/D channel numbers in any order.

Obuf, Obuf(Chn,Swp), (es:di):

This variable is the pointer to the starting address in memory for an output data array. See the discussion in the Techniques chapter.

Result (ax):

On return from the Call, RESULT (ax) contains the error code from the subroutine. A zero indicates that the Call was successful. The error message PARAM indicates that the number of channels (NCHNS) times the number of sweeps (NSWPS) is 0 or greater than 32,767. The error message RANGE indicates a channel number was too large. If zero was the parameter used in SKP (bx), than RESULT (ax) will contain the number of sweeps that were left to be done when the sweeps are restarted.

REMARKS:

On every sweep, values will be consecutively drawn from the data array and output to the channels identified in the channel array. Immediately prior to return, AORSWST sets the interrupt handler to begin the sweeps at the next interrupt.

return to top of Technical Reference



AOSTAT Analog Output Sweep Status

PURPOSE:

Checks the current status of the analog output process and returns control to the main program when the number of sweeps that are left to be done is less than a specified value.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(NSWEEP, RESULT, AOSTAT)

C:

result = labpac(AOSTAT, NSWEEP);

PARAMETERS:

Aostat (al):

The function number = 27

Nsweep (bx):

This variable contains the value which is compared to the value in the D/A sweep counter in the interrupt handler. Assigning the value of zero assures that the main program will not continue until completion of all D/A output sweeps.

Result (ax):

On return from the Call, the variable RESULT (ax) contains the value of the D/A Sweeps Left index from the interrupt handler. If the length of time programmed into the Service Cycle interval is too short to complete the D/A sweeps, RESULT will return with an OVERRUN error.

REMARKS:

NOTE that this Call will HALT the main program until the number of sweeps that remain to be done is less than or equal to the value specified in NSWEEP (bx). To find out the number of sweeps remaining without halting the main program, specify a value for NSWEEP (bx) greater than 32,767 or greater than or equal to the number of sweeps requested by AORSWST or AOSWST.

return to top of Technical Reference



AOSWAB Analog Output Sweep Abort

PURPOSE:

Stop the background analog output process.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(RESULT, AOSWAB)

C:

result = labpac(AOSWAB);

PARAMETERS:

Aoswab (al):

The function number = 32

Result (ax):

On return from the Call, the variable RESULT (ax) contains the number of sweeps that were left to be done when the subroutine was halted.

return to top of Technical Reference



AOSWST Analog Output Sweeps

PURPOSE:

Initialize the analog output process to output specified sets of data to analog output channels at specified intervals between sets.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(SKP, NSWPS, NCHNS, CHN(0), OBUF(0,0), RESULT, AOSWST)

C:

result= labpac(AOSWST,SKP,NSWPS,NCHNS,CHN,OBUF);

PARAMETERS:

Aoswst (al):

The function number = 22
 

Skp (bx):

The variable SKP (bx) is the number of service cycles (one service cycle equals four interrupt intervals) to skip between sweeps. If a D/A sweep is required every service cycle, use the value one. The maximum number of service cycles that can be skipped is 65,535. The value zero will restart the A/D sweeps where the process was turned off by a AOSWAB Call.

Nswps (cx):

This variable contains the number of sweeps to be conducted. This number should be greater than zero and equal to or less than the value used to dimension sweeps in the data array. The maximum number of sweeps is 32,767.

Nchns (dx):

This variable contains the number of D/A channels to be output during each sweep. This number must be greater than zero and less than 32,767. All the channels to be used must occupy consecutive cells in the channel array.

Chn, Chn(0), (ds:si):

This variable is the pointer to the starting address in memory for an array containing the A/D channel numbers in any order.

Obuf, Obuf(Chn,Swp), (es:di):

This variable is the pointer to the starting address in memory for an output data array. See the discussion in the Techniques chapter.

Result (ax):

On return from the Call, RESULT (ax) contains the error code from the subroutine. A zero indicates that the Call was successful. The error message PARAM indicates that the number of channels (NCHNS) times the number of sweeps (NSWPS) is 0 or greater than 32,767. The error message RANGE indicates a channel number was too large.

If zero was the parameter used in SKP (bx), than RESULT (ax) will contain the number of sweeps that were left to be done when the sweeps are restarted.

REMARKS:

On every sweep, values will be consecutively drawn from the data array and output to the channels identified in the channel array. Immediately prior to return, AOSWST sets the interrupt handler to begin the sweeps at the next interrupt.

return to top of Technical Reference



BCD BINARY to BCD Conversion

PURPOSE:

This routine converts 16-bit binary numbers into four-digit BCD numbers. Key information to supply is a two-byte integer value.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(NUMBER, RESULT, BCD)

C:

result = labpac(BCD, NUMBER);

PARAMETERS:

Bcd (al):

The function number = 3

Number (bx):

Contains an integer value that is to be converted to BCD.

Result (ax):

On return from the Call, this variable contains the four-digit BCD number.

REMARKS:

Use a hexadecimal conversion function to generate the BCD number. For example in Advanced BASIC set a string variable equal to HEX$(RESULT). The string value will be the BCD number.

return to top of Technical Reference



BIN BCD to BINARY Conversion

PURPOSE:

This routine converts 4-digit BCD numbers into binary numbers. Most languages do not have this conversion feature. Key information to supply is a four-digit BCD number. A binary value will be returned.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(BCD, RESULT, LBIN)


C:

result = labpac(LBIN, BCD);

PARAMETERS:

Lbin, Bin (al):

The function number = 4

Bcd (bx):

Contains a four digit BCD number. Range is from 0000 to 9999 BCD.

Result (ax):

On return from the Call, this variable contains the binary number converted from the 6digit BCD number.

REMARKS:

When using hexadecimal notation for the numbers, the BCD value equals the hexadecimal value. When using decimal numbers, use a hexadecimal to decimal conversion (i.e., 99 BCD equals 153 decimal).

return to top of Technical Reference



BINRD Read From a Binary File

PURPOSE:

This routine restores data from an external binary file to an array. The file must be in two-byte binary format. Key information to supply is the file's handle number, the number of sweeps, the number of channels, the channel array and the data array.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(HNDL, NSWPS, NCHNS, CHN(0), IBUF(0,0), RESULT, BINRD)

C:

result = labpac(BINRD,HNDL,NSWPS,NCHNS,CHN,IBUF);

PARAMETERS:

Binrd (al):

The function number = 52

Hndl (bx):

Contains the File Handle assigned by the OPEN Call. Range is zero to 19.

Nswps (cx):

Contains the number of samples per channel that will be stored in the data array.

Nchns (dx):

Contains the number of channels that will be stored in the data array.

Chn, Chn(0), (ds:si):

This variable is the pointer to the starting address in memory for a one-dimensional array to recieve the channel numbers read from the file.

Ibuf, Ibuf(Chn,Swp), (es:di):

This variable is the pointer to the starting address in memory for an input data array. See the discussion in the Techniques chapter.

Result (ax):

On return from the Call, this variable contains the error code from the subroutine. A zero indicates the Call was successful. The error message PARAM indicates that the NSWPS or NCHNS parameters did not match the ones stored in the data file. The error message FILERR indicates either a bad File Handle or an EOF mark was encountered.

REMARKS:

The data is read in binary format from the file. The channel array is read in first and restored to the integer array location two bytes at a time. Next the data buffer is restored to its integer array location. The data is read in two bytes at a time. The array is filled a sweep at a time until NSWPS * NCHNS elements are read.

return to top of Technical Reference



BINWR Write To a Binary File

PURPOSE:

This routine will save a data array into an external binary file. The data is stored in two-byte binary format. Key information to supply is the file handle number assigned when the file was opened, the number of sweeps, the number of channels for the data array dimensions, the channel array and the data array.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(HNDL, NSWPS, NCHNS, CHN(0), OBUF(0,0), RESULT, BINWR)

C:

result = labpac(BINWR, HNDL, NSWPS, NCHNS, CHN, OBUF);

PARAMETERS:

Binwr (al):

The function number = 53

Hndl (bx):

Contains the File Handle assigned by the CREATE Call. Range is zero to 19.

Nswps (cx):

Contains the number of times that values for a set of channels were stored in the data array.

Nchns (dx):

Contains the number of channels that are stored in the data array.

Chn, Chn(0), (ds:si):

This variable is the pointer to the starting address in memory for a one-dimensional array containing the channel numbers to be written to the file.

Obuf, Obuf(Chn,Swp), (es:di):

This variable is the pointer to the starting address in memory for an output data array. See the discussion in the Techniques chapter.

Result (ax):

On return from the Call, this variable contains the error code from the subroutine. A zero indicates the Call was successful. The error message PARAM indicates that the NSWPS or NCHNS parameters did not match the ones stored in the data file. The error message FILERR indicates either a bad File Handle or out of space on the disk to add the data to the file.

REMARKS:

The data is written in binary format to the file. Two bytes are written to the file for each element inthe channel array. Next two bytes are written for each element in the data array. The data is read from the data array a sweep at a time (a set of samples).

return to top of Technical Reference



CLOSE Close an Open File

PURPOSE:

This routine closes an external file. Key information to supply is the DOS file handle number assigned when the file was opened.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(HNDL, RESULT, LCLOSE)

C:

result = labpac(CLOSE, HNDL);

PARAMETERS:

Close, Lclose, (al):

The function number = 39

Hndl (bx):

Contains the file number or File Handle assigned by the OPEN or CREATE functions. The range is zero to 19.

Result (ax):

On return from the Call, this variable contains the error code from the subroutine. A zero indicates the Call was successful. If an error has occurred, RESULT (ax) will return the error code FILERR which indicates LabPac was unable to close the file. A possible problem is a bad file handle.

return to top of Technical Reference



CREATE Open Data Files For Writing

PURPOSE:

This routine allows external files to be "opened" from within an application to take data from a data array and save it in a data file. Files "opened" in this manner cannot have data read from them while they are open. Key information to supply is a legal DOS filename. On return from the Call, a value which is the file number called the "handle" for the "opened" empty file is contained in the return variable.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(FILENAME$, RESULT, LCREATE)

C:

result = labfile(CREATE, FILENAME);

PARAMETERS:

Create, Lcreate, (al):

The function number = 35

Filename, Filename$, (ds:bx):

This character variable contains the name of the file to be opened. File names follow MS-DOS rules. The maximum number of characters in the filename and its path is 45.

Result (ax):

On return from the Call, this variable contains a number between zero and 19 referred to as the File Handle, which is to be used in future Calls to identify this opened file. If an error has occurred, RESULT (ax) will return the error code FILERR to indicate problems in opening the file. Potential problems are too many files opened in the system, or a bad filename.

REMARKS:

LabPac can use up to 20 files at one time.

File handles returned by LabPac are DOS file handles.

Files will remain open until closed, the system is reset or the power turned off.

If more than 8 files (MS-DOS default) will be opened/created, use the FILES command within the MS-DOS CONLlG.SYS File. See the MS-DOS manual.

LabFile is an alternate entry point for compiled languages that check type. This function is defined to use a string as the second parameter.

A file can be written to multiple times after opening it with the CREATE Call. Each additional write will append data to the already saved data. Before using the file to read data back into an array, the file must be closed with the CLOSE Call.

return to top of Technical Reference



DIHDW Triggered Digital Input

PURPOSE:

This routine reads multiple samples of digital input from a single 8255A channel in Mode 1. Data is sampled as quickly as the handshaking allows. Key information to supply is first channel to sample, number of channels to sample, and the number of sweeps to perform.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(FIRST, NSWPS, NCHNS IBUF(0,0), RESULT, DIHDW)

C:

result = labpac(DIHDW, FIRST, NSWPS, NCHNS, IBUF);

PARAMETERS:

Dihdw (al):

The function number = 41

First (bx):

Contains the channel number from the Digital Input Channel Table of the first digital channel to read.

Nswps (cx):

Contains the number of samples to be taken from each channel before returning to the main program.

Nchns (dx):

This variable contains the number of consecutive digital input channels in the set to be sampled. This number must be greater than zero and less than or equal to the number of initialized digital input channels.

Ibuf, Ibuf(Chn,Swp), (es:di):

This variable is the pointer to the starting address in memory for an input data array. See the discussion in the Techniques chapter.

Result (ax):

On return from the Call, the variable RESULT (ax) contains the error code from the subroutine. A zero indicates that the Call was successful. The error message RANGE indicates that a channel number was too large.

REMARKS:

A hardware strobe must be installed if the channel is initialized in a strobed mode. See the DINIT Call in Chapter 10 for instructions on installing the IBF handshaking line for the channel to be used. For maximum speed the PC's system interrupts should be turned off. The IBF line for the digital input channel is monitored to identi& when data is available. The channel is sampled and the next channel's handshake line is then is monitored. If the digital channel is not set up in a strobed mode, is will be sampled immediately.

return to top of Technical Reference



DIMAX Maximum Rate Digital Input

PURPOSE:

This routine inputs information from a set of channels as fast as possible. A timer/counter channel is used to determine the time interval between the start of the inputs from the first channel in each set. This feature can input up to 10,000 channels per second.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(TMR, NSWPS, NCHNS, CHN(0), IBUF(0,0), RESULT, DIMAX)

C:

result = labpac(DIMAX, TMR, NSWPS, NCHNS, CHN, IBUF);

PARAMETERS:

Dimax (al):

The function number = 16

Tmr (bx):

The variable TMR (bx) is the channel number from the Timer/Counter Channel Table. The output signal for this timer/counter is monitored to determine the time interval between the start of consecutive sets of samples. The timer/counter channel cannot be an FOUT signal. Each time the 9513A counter reaches terminal count, a set of channels is processed.

Nswps (cx):

This variable contains the number of samples to be taken for each channel in the set. This number should be equal to or less than the value used to dimension samples in the data array. The maximum number of samples is 32,767.

Nchns (dx):

This variable contains the number of digital input channels in the set to be sampled during each time interval. This number must be greater than zero and less than 32,767. All the channels to be used must occupy consecutive cells in the channel array.

Chn, Chn(0), (ds:si):

This variable is the pointer to the starting address in memory for an array containing the A/D channel numbers in any order.

Ibuf, Ibuf(Chn,Swp), (es:di):

This variable is the pointer to the starting address in memory for an input data array. See the discussion in the Techniques chapter.

Result (ax):

On return from the Call, RESULT (ax) contains the error code from the subroutine. A zero indicates that the Call was successful. The error message PARAM indicates that the number of channels (NCHNS) times the number of sweeps (NSWPS) is 0 or greater than 32,767. The error message RANGE indicates a channel number was too large. The error message TIMERR indicates the timer/counter channel was not started or an FOUT signal was selected.

REMARKS:

During each time interval set on the timer/counter channel, the identified channels in the channel array will be sampled once and the samples consecutively placed in the data array. This routine runs in the foreground and will not return until all the samples are taken. It is recommended that background digital input sweeps are not conducted while DIMAX is active.

return to top of Technical Reference



DINIT Digital I/O Initialization

PURPOSE:

This routine fills the Digital Input Channel Table and the Digital Output Channel Table. Each table can contain as many I/O ports as indicated by the /DI and /DO command line options (Default is 3 each). Key information to supply is the address of an 8255A Control Port on the Scientific Solutions data acquisition board. Additional information includes whether each port will be configured in an input or output state and in Mode 0 or Mode 1. DINIT can be called several times until the maximum number of input and/or output channels have been defined. (Not required on a PS/2 MicroChannel system).

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(ADRS, CONFIG, RESULT, DINIT)

C:

result = labpac(DINIT, ADRS, CONFIG);

PARAMETERS:

Dinit (al):

The function number = 6

Adrs (bx):

The I/O address of the 8255A Control Port or the digital I/O register.

Use the following table to determine the correct address to use.

 
Lab Master DMA

Base + 15 
Lab Master

Base + 15 
Lab Tender

Base + 15 
DADIO

Base + 11 
ISA DAS

Base + 1 
Base Board (Port 1) = Base + 0 
Base Board (Port 2) = Base + 4 
Base Board (Port 3) = Base + 8 
Base Board (Port 4) = Base + 12 

Config (cx):

Configures the three ports of an 8255A (A, B, and C) to be either an input port or an output port and in either a Basic or Strobed Mode. To determine the value of CONFIG (cx) use the following table. First select the input/output and Mode configuration for the three ports. Then add together the five choices from the ADD column. Finally use that value for CONFIG (cx). Note that on ISA DAS series interfaces CONFIG (cx) is ignored.

BIT

FUNCTION

ADD

0 = Port A set for OUTPUT

 

1 = Port A set for input

0 = Port B set for OUTPUT

 

1 = Port B set for INPUT

0 = Port C set for OUTPUT

 

1 = Port C set for INPUT

0 = Port A set for Basic Mode

 

1 = Port A set for Strobed Mode

0 = Port B set for Basic Mode

 

1 = Port B set for Strobed Mode

16 

Result (ax):

On return from the Call, RESULT (ax) contains the error code from the subroutine. The error message TABLE indicates an attempt to initialize too many channels. Otherwise, the high byte of RESULT contains the total number of initialized digital output channels and the lower byte of RESULT contains the total number of initialized digital input channels.

REMARKS:

The maximum number of ports that LabPac can process is determined by the /DI and /DO command line options. The default is three output and three input ports.

DINIT can be called several times for several boards. LabPac establishes two separate internal channel tables to distinguish between input and output channels. While one 8255A can have mixed input and output ports, LabPac will assign the ports their channel numbers in the order they are initialized into the two tables. Channels can be assigned until the tables are full.

For example, if the first 8255A is set for Ports A and C as input ports and Port B as an output port, LabPac will assign input channel number zero to Port A, input channel number one to Port C and output channel number zero to Port B. If a second 8255A is set for Port C as an input port and Ports A and B as output ports, LabPac will assign input channel number two to Port C, output channel number one to Port A and output channel number two to Port B.

When using Strobed (Mode 1) input or output, several bits on Port C are dedicated to handshaking with external equipment. Other bits are used for internal interrupts (LabPac enables but does not use these interrupts). Consult hardware installation manual for the pinouts of these bits on the 8255A connector. The following table indicates which bits in Port C are used for the handshaking signals required when Port A or Port B are in Strobed Mode.

Port A:

Input Mode:

 

Bit 3 

INTeRrupt

Bit 4 

Strobed input To Buffer

Bit 5 

Input Buffer Full

Bit 6 

Mode 0 Input

Bit 7 

Mode 0 Input

Output Mode

 

Bit 3 

INTeRrupt

Bit 4 

Mode 0 Input

Bit 5 

Mode 0 Input

Bit 6 

ACKnowledge

Bit 7 

Output Buffer Full

Port B:

Input Mode:

 

Bit 0 

INTeRrupt

Bit 1 

Input Buffer Full

Bit 2 

Strobed input To Buffer

Output Mode:

 

Bit 0 

INTeRrupt

Bit 1 

Output Buffer Full

Bit 2 

ACKnowledge

In the Strobed Mode the interrupts are enabled. LabPac does not install any interrupt handlers for the 8255A. If hardware interrupts from the 8255A will be used in conjunction with LabPac, a dedicated interrupt handler is required and the proper connection to an IRQ line must be installed (see the installation manual).

This Call has no functionality on PS/2 MicroChannel systems. If it is included in a program, the request will be ignored.

return to top of Technical Reference



DIRAW Digital Input Read

PURPOSE:

This routine reads one sample of digital input from a single channel. Key information to supply is a channel number.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(CHN, RESULT, DIRAW)

C:

result = labpac(DIRAW, CHN);

PARAMETERS:

Diraw (al):

The function number = 11

Chn (bx):

This variable contains the channel number from the Digital Input Channel Table.

Result (ax):

On return from the Call, the variable RESULT (ax) contains the value of the sample. The error message RANGE indicates that an illegal channel number was used.

REMARKS

A DAS series interface has only two bits of digital input. The upper 14 bits will be zero upon return from the Call.

return to top of Technical Reference



DIRSWST Repeating Digital Input

PURPOSE:

Initialize the background digital input process to repeatedly sample a set of digital input channels at discrete intervals between sets.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(SKP, NSWPS, NCHNS, CHN(0), IBUF(0,0), RESULT, DIRSWST)

C:

result = labpac(DIRSWST, SKP, NSWPS, NCHNS, CHN, IBUF);

PARAMETERS:

Dirswst (al):

The function number = 61

Skp (bx):

The variable SKP (bx) is the number of service cycles (one service cycle equals four interrupt intervals) to skip between sweeps. If a digital input sweep is required every service cycle, use the value one. The maximum number of service cycles that can be skipped is 65,535. The value zero will restart the digital input sweeps where the process was turned off by a DISWAB Call.

Nswps (cx):

This variable contains the number of sweeps to be conducted. This number should be equal to or less than the value used to dimension sweeps in the data array. The maximum number of sweeps is 32,767.

Nchns (dx):

This variable contains the number of digital input channels to be sampled during each sweep. This number must be greater than zero and less than 32,767. All the channels to be used must occupy consecutive cells in the channel array.

Chn, Chn(0), (ds:si):

This variable is the pointer to the starting address in memory for an array containing the A/D channel numbers in any order.

Ibuf, Ibuf(Chn,Swp), (es:di):

This variable is the pointer to the starting address in memory for an input data array. See the discussion in the Techniques chapter.

Result (ax):

On return from the Call, RESULT (ax) contains the error code from the subroutine. A zero indicates that the Call was successful. The error message PARAM indicates that the number of channels (NCHNS) times the number of sweeps (NSWPS) is 0 or greater than 32,767. The error message RANGE indicates a channel number was too large.

If zero was the parameter used in SKP (bx), than RESULT (ax) will contain the number of sweeps that were left to be done when the sweeps are restarted.

REMARKS:

This starts a repeating digital input sweep. After Nsweeps of data are collected, the buffer is reused starting at the beginning. Immediately prior to return, DIRSWST sets the interrupt handler to begin the sweeps at the next interrupt.

return to top of Technical Reference



DISC Digital Input Wait

PURPOSE:

This routine continuously samples one channel of digital input. The samples are compared to a value supplied in the Call. When the input value meets the mask criteria, the function discontinues sampling the channel and returns to the main program. Alternatively, the function can wait for a change in state of one or more of the input channel's bits. Key information to supply is a channel number and the values to be used for comparison.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(CHN, MASK, SENSE, RESULT, DISC)

C:

result = labpac(DISC, CHN, MASK, SENSE);

PARAMETERS:

Dise (al):

The function number = 46

Chn (bx):

Contains the channel number from the Digital Input Channel Table.

Mask (cx):

Contains a value that acts as a mask to select the digital input bits that are to be monitored. The range is zero through 255. To determine the MASK (cx) value, set the bits in an eight-digit binary number to one using the table shown under SENSE (dx) to calculate the mask value.

Sense (dx):

Contains a value that indicates whether the masked bits should be high or low. The range is zero through 255. To determine the SENSE (dr) value, set the masked bits to one (for high) or zero (for low) and calculate the decimal value using the table below. The range is between zero and 255.

Bit

Add

16 

32 

64 

128 

Result (ax):

On return from the Call, the variable RESULT (ax) contains the error code from the subroutine. The error message RANGE indicates that a channel number was too large. Otherwise, RESULT contains the last value read.

REMARKS:

Samples are continuously taken from the specified digital input channel. Each sample is XORed with the value in SENSE and then ANDed with the value in MASK. If the resultant value equals zero then control is returned to the main program, otherwise the next sample is taken. There are certain combinations of MASK and SENSE which will never return. Be sure not to Call DISC with this condition else the computer will lock up.

If MASK is zero, the port bits corresponding to bits in SENSE that are set to one are monitored for any change. When a change occurs, control is returned to the main program.

On the DAS series interface only two bits of digital input are available. Use bits 0 and 1 for this Call.

return to top of Technical Reference



DISTAT Digital Input Sweep Status

PURPOSE:

Check the current status of the background digital input process and return control to the main program when the number of sweeps remaining to be done is less than a specified value.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(NSWEEP, RESULT, DISTAT)

C:

result = labpac(DISTAT, NSWEEP);

PARAMETERS:

Distat (al):

The function number = 26

Nsweep (bx):

This variable contains the value which is compared to the value in the Digital Input Sweep counter in the LabPac interrupt handler. Assigning the value of zero means that the main program will not continue until completion of all digital input sweeps.

Result (ax):

On return from the Call, the variable RESULT (ax) contains the value of the digital input Sweeps Left index from the LabPac interrupt handler. If the length of time programmed into the Service Cycle interval is too short to complete the digital input sweeps, RESULT will return with an OVERRUN error.

REMARKS:

NOTE that this Call will HALT the main program until the number of sweeps that remain to be done is less than or equal to the value specified in NSWEEP (bx). To find out the number of sweeps remaining without halting the main program, specify a value for NSWEEP (bx) greater than 32,767 or greater than or equal to the value used to set the number of sweeps in DISWST or DIRSWST.

return to top of Technical Reference



DISWAB Digital Input Sweep Abort

PURPOSE:

Stops the background digital input process from running sweeps.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(RESULT, DISWAB)

C:

result = labpac(DISWAB)

PARAMETERS:

Diswab (al):

The function number = 31

Result (ax):

On return from the Call, the variable RESULT (ax) contains the number of sweeps that were left to be done when the subroutine was halted.

return to top of Technical Reference



DISWST Digital Input Sweeps

PURPOSE:

Initialize the background digital input process to sample a specified set of digital input channels at discrete intervals between sets.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(SKP, NSWPS, NCHNS, CHN(0), IBUF(0,0), RESULT, DISWST)

C:

result = labpac(DISWST, SKP, NSWPS, NCHNS, CHN, IBUF);

PARAMETERS:

Diswst (al):

The function number = 21

Skp (bx):

The variable SKP (bx) is the number of service cycles (one service cycle equals four interrupt intervals) to skip between sweeps. If a digital input sweep is required every service cycle, use the value one. The maximum number of service cycles that can be skipped is 65,535. The value zero will restart the digital input sweeps where the process was turned off by a DISWAB Call.

Nswps (cx):

This variable contains the number of sweeps to be conducted. This number should be equal to or less than the value used to dimension sweeps in the data array. The maximum number of sweeps is 32,767.

DISWST

Nchns (dx):

This variable contains the number of digital input channels to be sampled during each sweep. This number must be greater than zero and less than 32,767. All the channels to be used must occupy consecutive cells in the channel array.

Chn, Chn(0), (ds:si):

This variable is the pointer to the starting address in memory for an array containing the A/D channel numbers in any order.

Ibuf, Ibuf(Chn,Swp), (es:di):

This variable is the pointer to the starting address in memory for an input data array. See the discussion in the Techniques chapter.

Result (ax):

On return from the Call, RESULT (ax) contains the error code from the subroutine. A zero indicates that the Call was successful. The error message PARAM indicates that the number of channels (NCHNS) times the number of sweeps (NSWPS) is 0 or greater than 32,767. The error message RANGE indicates a channel number was too large.

If zero was the parameter used in SKP (bx), than RESULT (ax) will contain the number of sweeps that were left to be done when the sweeps are restarted.

REMARKS:

On every sweep, the identified channels in the channel array will be sampled and the samples consecutively placed in the data array. Immediately prior to return, DISWST sets the interrupt handler to begin the sweeps at the next interrupt.

return to top of Technical Reference



DMASTAT DMA Transfer Status

PURPOSE:

This routine provides a way of determining when the DMA process initialized under AIDMA has has finished. Key information is the starting channel used in the AIDMA function.
 

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(CHN, RESULT, DMASTAT)


C:

result = labpac(DMASTAT,CHN);

PARAMETERS:

Dmastat (al):

The function number = 50

Chn (bx):

The channel number of the first channel sampled by the AIDMA Call prior to executing this routine.

Result (ax):

On return from the Call, the variable RESULT (ax) contains the error code from the subroutine. A ten, indicates the Call was successful and that the DMA transfer is completed. The error message ERRDMA indicates that the channel number in CHN (bx) is not defined to exist on a DMA capable product. The error message RANGE is returned if the channel number is out of range.

REMARKS:

If the DMA task being handled by AIDMA is a background task, start a timer/counter using Source3 on a Lab Master DMA or FIFO Transfer on an DAS series interface. Install the DONE jumper on the Lab Master DMA. The timer will keep track of how many conversions have taken place from which the number left to do can be calculated.

If EMS memory was used by DMA, the block of memory present in the window before the AIDMA Call will be mapped.

return to top of Technical Reference



DOCLR Digital Mask Output Clear

PURPOSE:

The output of this routine will turn off bits (i.e., set lines to TTL low) in a digital output channel as specified by a mask. The mask contains one's in the bit positions to be turned off. The remaining bits with zeros in the mask will be left unchanged. DOCLR reads the current value of the bits (lines on the channel) and ANDs it with the complement of the mask value. The new value is output on the channel. Key information to supply is a channel number and a value to be entered in the mask. The new value on the channel is returned.


CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(CHN, MASK, RESULT, DOCLR)

C:

result = labpac(DOCLR, CHN, MASK);

PARAMETERS:

Doclr (al):

The function number = 43

Chn (bx):

This variable contains the channel number from the Digital Output Channel Table.

Mask (cx):

The bits identified in this variable will be "turned off' on the specified digital output channel. All other bits will be left alone. To turn off a bit, place a one in the bit position in the eight-digit binary representation for the channel. The value for the mask variable can be calculated from the table below.

Bit

Add

16 

32 

64 

128 

Result (ax):

On return from the Call, the variable RESULT (ax) contains the new value of the digital output channel after the mask has been output. If the Call was unsuccessful an error code will be returned. The error message RANGE indicates that a channel number was too large.

REMARKS:

The DAS series interface has only two bits of digital output. The upper bits in an output request are ignored.

return to top of Technicl Reference



DOHDW Triggered Digital Output

PURPOSE:

This routine takes a set of values and sends them out over digital output channels using the 8255A Mode 1. Key information to supply is the first channel sent, the number of output channels, the values to output, and the number of values to output.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(FIRST, NSWPS, NCHNS, OBUF(0,0), RESULT, DOHDW)

C:

result = labpac(DOHDW, FIRST, NSWPS, NCHNS, OBUF);

PARAMETERS:

Dohdw (al):

The function number = 42

First (bx):

Contains the channel number from the Digital Output Channel Table of the first digital output channel to use.

Nswps (cx):

Contains the number of sets of samples to be output before returning to the main program.

Nchns (dx):

This variable contains the number of digital output channels to be processed during each set. All the digital outputs must be consecutive after the first channel. This number must be greater than zero and less than or equal to the number of initialized output channels.

Obuf, Obuf(Chn,Swp), (ds:si):

This variable is the pointer to the starting address in memory for an output data array.

Result (ax):

On return from the Call, the variable RESULT (ax) contains the error code from the subroutine. A zero indicates that the Call was successful. The error message RANGE indicates that a channel number was too large.

REMARKS:

A hardware strobe must be installed if the channel is initialized to be in strobed mode. See the DINIT Call in Chapter 10 for instructions on installing the Acknowledge handshaking line for the channel(s) to be used.

The Acknowledge line for the digital output channel is monitored to identify when data can be sent. As soon as the handshake line is ready the data is output and the next channel is monitored. If the channel is not in strobed mode, the data is output as fast as possible.

For maximum speed the PC's system interrupts should be turned off. See the discussion in the Techniques chapter about maximizing data collection.

return to top of Technical Reference


DOMAX Maximum Rate Digital Output

PURPOSE:

This routine outputs information on a set of channels as fast as possible. A timer/counter channel is used to determine the time interval between the start of the outputs on the first channel in each set. This feature outputs up to 10,000 channels per second.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(LTMR, NSWPS, NCHNS, CHN(0), OBUF(0,0), RESULT, DOMAX)

C:

result = labpac(DOMAX, TMR, NSWPS, NCHNS, CHN, OBUF);

PARAMETERS:

Domax (al):

The function number = 18

Tmr (bx):

The variable TMR (bx) is the channel number from the Timer/Counter Channel Table. The output signal for this timer/counter is monitored to determine the time interval between the start of consecutive sets of samples. The timer/counter channel cannot be an FOUT signal. Each time the 9513A counter reaches terminal count, a set of channels is processed.

Nswps (cx):

This variable contains the number of samples to be output for each channel in the set. This number should be greater than zero and equal to or less than the value used to dimension samples in the data array. The maximum number of samples is 32,767.

Nchns (dx):

This variable contains the number of digital output channels to be processed in each set. This number must be greater than zero and less than 32,767. All the channels to be used must occupy consecutive cells in the channel array.

Chn, Chn(0), (ds:si):

This variable is the pointer to the starting address in memory for an array containing the A/D channel numbers in any order.

Obuf, Obuf(Chn,Swp), (es:di):

This variable is the pointer to the starting address in memory for an output data array. See the discussion in Chapter 5 (Techniques).

Result (ax):

On return from the Call, RESULT (ax) contains the error code from the subroutine. A zero indicates that the Call was successful. The error message PARAM indicates that the number of channels (NCHNS) times the number of sweeps (NSWPS) is 0 or greater than 32,767. The error message RANGE indicates a channel number was too large. The error message TIMERR indicates the timer/counter channel was not started or an FOUT signal was selected.

REMARKS:

During each time interval, values will be consecutively drawn from the data array and output to the channels identified in the channel array.

This routine runs in the foreground and will not return until all the samples are output. It is recommended that background digital output sweeps are not conducted while DOMAX is active.

return to top of Technical Referenc



DORAW Digital Output Write

PURPOSE:

This routine takes a value and sends it out over one channel. Key information to supply is a channel number and a value to output.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(CHN, OUTPUT, RESULT, DORAW)

C:

result = labpac(DORAW, CHN, OUTPUT);

PARAMETERS:

Doraw (al):

The function number = 13

Chn (bx):

This variable contains the channel number from the Digital Output Channel Table.

Output (cx):

This variable contains the value to be sent to the digital output channel.

Result (ax):

On return from the Call, the variable RESULT (ax) contains the error code from the subroutine. A zero indicates that the Call was successful. The error message RANGE indicates that a channel number was too large.

REMARKS:

The DAS series interface has only two bits of digital output. The upper 14 bits in an output request are ignored.

return to top of Technical Reference



DORSWST Repeating Digital Output

PURPOSE:

Initialize the background digital output process to send data to a set of digital output channels at specified intervals.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(SKP, NSWPS, NCHNS, CHN(0), OBUF(0,0), RESULT, DORSWST)

C:

result = labpac(DORSWST,SKP,NSWPS,NCHNS,CHN,OBUF)

PARAMETERS:

Dorswst (al):

The function number = 48

Skp (bx):

The variable SKP (bx) is the number of service cycles (one service cycle equals four interrupt intervals) to skip between sweeps. If a digital output sweep is required every service cycle, use the value one. The maximum number of service cycles that can be skipped is 65,535. The value zero will restart the digital output sweeps where the process was turned off by a DOSWAB Call.

Nswps (cx):

This variable contains the number of different sweeps to be conducted. This number should be greater than zero and equal to or less than the value used to dimension sweeps in the data array. The maximum number of sweeps is 32,767. After Nswps have been output, DORSWST restarts its output from the beginning of the data buffer.

Nchns (dx):

This variable contains the number of digital output channels to be processed during each sweep. This number must be greater than zero and less than 32,767. All the channels to be used must occupy consecutive cells in the channel array.

Chn, Chn(0), (ds:si):

This variable is the pointer to the starting address in memory for an array containing the A/D channel numbers in any order.

Obuf, Obuf(Chn,Swp), (es:di):

This variable is the pointer to the starting address in memory for an output data array. See the discussion in the Techniques chapter.

Result (ax):

On return from the Call, RESULT (ax) contains the error code from the subroutine. A zero indicates that the Call was successful. The error message PARAM indicates that the number of channels (NCHNS) times the number of sweeps (NSWPS) is 0 or greater than 32,767. The error message RANGE indicates a channel number was too large.

If zero was the parameter used in SKP (bx), than RESULT (ax) will contain the number of sweeps that were left to be done when the sweeps are restarted.

REMARKS:

On every sweep, values will be consecutively drawn from the data array and output to the channels identified in the channel array. Immediately prior to return, DORSWST sets the interrupt handler to begin the sweeps at the next interrupt.

return to top of Technical Reference



DOSET Digital Mask Output Write

PURPOSE:

The output of this routine will turn on bits (i.e., set lines to TTL positive) in a digital output channel as specified by a mask. The mask contains ones in the bit positions to be turned on. The remaining bits with zeros in the mask will be left unchanged. DOSET reads the current value of the bits (lines in the channel) and ORs it with the mask value. The new value is output on the channel. Key information to supply is a channel number and a value to be entered in the mask. The new value is returned.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(CHN, MASK, RESULT, DOSET)

C:

result = labpac(DOSET, CHN, MASK);

PARAMETERS:

Doset (al):

The function number = 44
 

Chn (bx):

This variable contains the channel number from the Digital Output Channel Table.
 

Mask (cx):
 

The bits identified in this variable will be "turned on" in the specified digital output channel. All other bits will be left alone. To turn on a bit, place a one in the bit position in the eight-digit binary representation for the channel. Use the following table to calculate the mask value.

 

Bit

Add

16 

32 

64 

128 

Result (ax):
 

On return from the Call, the variable RESULT (ax) contains the new value of the digital output channel after the mask has been output. If the Call was unsuccessful an error code will be returned. The error message RANGE indicates that a channel number was too large.
 

REMARKS:

The DAS series interface has only two bits of digital output. The upper 14 bits in an output request are ignored.

return to top of Technical Reference



DOSTAT Digital Output Sweep Status

PURPOSE:

Check the current status of the background digital output process and return control to the main program when the number of remaining sweeps are less than a specified value.
 

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(NSWEEP, RESULT, DOSTAT)

C:

result = labpac(DOSTAT, NSWEEP);

PARAMETERS:

Dostat (al):

The function number - 28

Nsweep(bx):

This variable contains the value which is compared to the value in the digital output sweep counter in the LabPac interrupt handler. Assigning the value of zero means that the main program will not continue until completion of all digital output sweeps.

Result (ax):

On return from the Call, the variable RESULT (ax) contains the value of the digital output Sweeps Left index from the LabPac interrupt handler. If the length of time programmed into the Service Cycle interval is too short to complete the digital output sweeps, RESULT will return with an OVERRUN error.

REMARKS:

NOTE that this Call will HALT the main program until the number of sweeps that remain to be done is less than or equal to the value specified in NSWEEP (bx). To find out the number of sweeps remaining without halting the main program, specify a value greater than 32,767 for NSWEEP (bx).

return to top of Technical Reference



DOSWAB Digital Output Sweep Abort

PURPOSE:

Stop the processing of sweeps by the background digital output process.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(RESULT, DOSWAB)

C:

result = labpac(DOSWAB);

PARAMETERS:

Doswab (al):

The function number = 32

Result (ax):

On return from the Call, the variable RESULT (ax) contains the number of sweeps that were left to be done when the subroutine was halted.

return to top of Technical Reference



DOSWST Digital Output Sweeps

PURPOSE:

Initialize the background digital output process to send data to a set of digital output channels at specified intervals between sets.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(SKP, NSWPS, NCHNS, CHN(0), OBUF(0,0), RESULT, DOSWST)

C:

result = labpac(DOSWST, SKP, NSWPS, NCHNS, CHN, OBUF);

PARAMETERS:

Doswst (al):

The function number = 23

Skp (bx):

The variable SKP (bx) is the number of service cycles (one service cycle equals four interrupt intervals) to skip between sweeps. If a digital output sweep is required every service cycle, use the value one. The maximum number of service cycles that can be skipped is 65,535. The value zero will restart the digital output sweeps where the process was turned off by a DOSWAB Call.

Nswps (cx):

This variable contains the number of sweeps to be conducted. This number should be equal to or less than the value used to dimension sweeps in the data array. The maximum number of sweeps is 32,767.

Nchns (dx):

This variable contains the number of digital output channels to be processed during each sweep. This number must be greater than zero and less than 32,767. All the channels to be used must occupy consecutive cells in the channel array.

Chn, Chn(0), (ds:si):

This variable is the pointer to the starting address in memory for an array containing the A/D channel numbers in any order.

Obuf, Obuf(Chn,Swp), (es:di):

This variable is the pointer to the starting address in memory for an output data array. See the discussion in the Techniques chapter.

Result (ax):

On return from the Call, RESULT (ax) contains the error code from the subroutine. A zero indicates that the Call was successful. The error message PARAM indicates that the number of channels (NCHNS) times the number of sweeps (NSWPS) is 0 or greater than 32,767. The error message RANGE indicates a channel number was too large.

If zero was the parameter used in SKP (bx), than RESULT (ax) will contain the number of sweeps that were left to be done when the sweeps are restarted.

REMARKS:

On eveIy sweep values will be consecutively drawn from the data array and output to the channels identified in the channel array. Immediately prior to return, DOSWST sets the interrupt handler to begin the sweeps at the next interrupt.

return to top of Technical Reference



FREE Free EMS Buffer

PURPOSE:

This routine returns an EMS data buffer allocated to LabPac to the use of other software.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(HNDL, RESULT, FREE)

C:

result = labpac(FREE, HNDL);

PARAMETERS:

Free (al):

The function number = 56

Hndl (bx):

The value of the EMS buffer handle for the data buffer to be freed.

Result (ax):

On return from the Call, this variable contains the error code from the subroutine. A zero indicates the Call was successful. The error message EMMERR indicates the EMS buffer handle was illegal.

REMARKS:

An EMS driver or virtual memory manager must be installed for this Call to work. EMS buffers are allocated to LabPac by the EMS driver through ALLOC. The memory will remain allocated to LabPac, even after its application program is finished. For other programs to use the EMS memory, a request must go to the EMS driver to return the used buffer to general use. FREE must be run to deallocate each EMS buffer used by LabPac. If the buffers are not returned, there will eventually be an out-of-memory error and the system must be restarted.

return to top of Technical Reference



GETTIME Get Time-of-Day

PURPOSE:

This routine reads timer/counter channels 1 and 2, returning the time-of-day value currently in the counters. Key information to supply is a channel number.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(CHN, SETDOS, RESULT, GETTIME)

C:

result = labpac(GETTIME, CHN, SETDOS);

PARAMETERS:

Gettime (al):

The function number = 63

Chn (bx):

The number of the timer/counter channel from which to read the time of day. This channel must correspond to a 9513A counter 1 or 2.

Setdos (cx):

If SETDOS (ex) is non-zero, MS-DOS will be set with the time-of-day value retrieved from the timer/counters.

Result (ax):

On return from the Call, RESULT (ax) contains the current time-of-day value for seconds. If an error has occurred, RESULT (ax) returns the error code from the subroutine. The error message TMR indicates the timer/counter channel is illegal. The error message RANGE indicates the timer/counter channel is out of range.

Result (dx):

Returns the current time-of-day value for hours and minutes in the high and low bytes.

REMARKS:

Basic programs must use TIRAW to get the hours:minutes value. The seconds and minutes values will be in bcd format. In order to set the timer/counter to the current MS-DOS time-of-day, use SETTIME.

return to top of Technical Reference



INTCLR Clear Interrupt Mask

PURPOSE:

This routine is designed to give control over the processes that interrupt the CPU. By providing the proper value to the Call, an application can mask off or deactivate other IRQ lines so that LabPac functions can operate at maximum speed.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(MASK, RESULT, INTCLR)

C:

result = labpac(lNTCLR, MASK);

PARAMETERS:

Intclr (al):

The function number = 1

Mask (bx):

Hardware interrupts corresponding to the bits set in MASK will be disabled. For example a mask value of four will disable IRQ2. interrupts corresponding to MASK bits which are cleared will be left alone. Use the following table to calculate the MASK value.

IRQ

Add

16 

32 

64 

128 

256 

512 

10 

1,024 

11 

2,048 

12 

4,096 

13 

8,192 

14 

16,384 

15 

32,768 

Result (ax):

On return from the Call, this variable identifies the IRQ lines that were active prior to the Call.

REMARKS:

When using this Call with the LabPac interrupt handler, leave the bit turned on for the IRQ line it uses. Otherwise LabPac interrupts will be discontinued.

When resetting the IRQ Control Register after the LabPac tasks are completed, always restore it to its former value with INTSET.

return to top of Technical Reference



INTSET Set Interrupt Mask

PURPOSE:

This routine restores the interrupts which were turned off by INTCLR.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(MASK, RESULT, INTSET)

C:

result = labpac(lNTSET, MASK);

PARAMETERS:

Intset (al):

The function number = 2

Mask (bx):

Hardware interrupts corresponding to the bits set in MASK will be enabled. interrupts corresponding to cleared bits in MASK will be left alone. For example a mask value of four will enable IRQ2. Use the following table to calculate the MASK value.

IRQ

Add

16 

32 

64 

128 

256 

512 

10 

1,024 

11 

2,048 

12 

4,096 

13 

8,192 

14 

16,384 

15 

32,768 

Result (ax):

On return from the Call, this variable identifies the IRQ lines that were active prior to the Call.

REMARKS:

Use INTSET to re-enable interrupts turned off by INTCLR. The recommended procedure is to use the return value of INTCLR as the MASK value for INTSET. This way no extra hardware interrupts are accidentally enabled.

return to top of Technical Reference



OPEN Open Data Files For Reading

PURPOSE:

This routine allows external files to be "opened" from within an application program so that previously saved data can be restored to a data array. Files "opened" in this manner cannot have data saved to them while they are open. Key information to supply is a legal DOS filename of an existing data file. On return from the Call, a value which is the file number called the "handle" for the "opened" file is contained in the return variable.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(FILENAME$, RESULT, LOPEN)

C:

result = labfile(OPEN, FILENAME);

PARAMETERS:

LopenOpen, Lopen (al):

The function number = 36

Filename, Filename$, (ds:bx):

This character variable contains the name of the file to be opened. File names follow MS-DOS rules. The maximum number of characters in the filename plus the path is 45.

Result (ax):

On return from the Call, this variable contains a number between zero and 19 referred to as the File Handle. The handle is used by DOS to identify this opened file. If an error has occurred, RESULT (ax) will return the error code FILERR to indicate problems in opening the file.

Potential problems are too many files opened in the system or a bad file na me.

REMARKS:

LabPac can use up to 20 files at one time. The file handles that are returned in RESULT (ax) are DOS file handles.

Files will remain open until closed, the system is reset, or the power turned off.

If more than 8 files (MS-DOS default) will be opened/created, use the FILES command within the CONFIG.SYS File. See the DOS manual.

To be opened, files must previously exist. Once opened with the OPEN Call, the files can only be read. See the CREATE command for writing data out to a file.

LabFile is an alternate entry point into LabPac for compiled languages that type check. This function is defined to use a string as the second parameter.

A file can be read multiple times until the end-of-file (EOF) marker after opening with the OPEN Call. Before reusing the file to write new data, the file must be closed with the CLOSE Call. When a file is reused, the old data is destroyed.

return to top of Technical Reference



READ Read Data From File

PURPOSE:

This routine accesses an external file to restore data to an array. While the data may have been saved from LabPac, it is not required. The file does have to be in ASCII format. Key information to supply is the file handle number assigned when the file was opened, the number of sweeps, the number of channels , the channel array and the data array.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(HNDL, NSWPS, NCHNS, CHN(0), IBUF(0,0), RESULT, LREAD)

C:

result = labpac(READ, HNDL, NSWPS, NCHNS, CHN, IBUF);

PARAMETERS:

Read, Lread (al):

The function number = 37

Hndl (bx):

Contains the File Handle assigned by the OPEN Call. Range is zero to 19.

Nswps (cx):

Contains the number of times values for a set of channels that will be stored in the data array.

Nchns (dx):

Contains the number of channels that will be stored in the data array.

Chn, Chn(0), (ds:si):

This variable is the pointer to the starting address in memory for a one-dimensional array to receive the channel numbers read from the file.

Ibuf, Ibuf(Chn,Swp), (es:di):

This variable is the pointer to the starting address in memory for an input data array. See the discussion in the Techniques chapter.

Result (ax):

On return from the Call, this variable contains the error code from the subroutine. A zero indicates the Call was successful. The error message PARAM indicates that the NSWPS or NCHNS parameters did not match the ones stored in the data file. The error message FILERR indicates either a bad File Handle or an EOF encountered.

return to top of Technical Reference



RESET Master Reset

PURPOSE:

This routine clears internal LabPac tables and resets other internal structures to initial values.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(RESULT, LRESET)

C:

result = labpac(RESET);

PARAMETERS:

Reset, Lreset (al):

The function number = 0

Result (ax):

On return from the Call, RESULT (ax) contains the version number (in BCD format) of the installed LABPAC.COM. The high byte contains the version number and the low byte contains the revision number. For example Version 3.20 will return 3 in the high byte, 2 in the high nibble of the low byte, and 0 in the low nibble ofthe low byte. This will be 800 in decimal.
 

REMARKS:

All device initializations are cleared. Digital I/O on the 8255A is reset to input state. The 9513A Master Reset command is issued to timer/counter channels. The RESET function does not affect device initialization parameters on a PS/2 MicroChannel system. RESET removes all interrupt vectors and dis-engages all sweeps.

return to top of Technical Reference



SCRAW Set/Clear One Digital Output

PURPOSE:

The output of this routine will turn on and off bits (i.e., set lines to TTL high or low) in a digital output channel as specified by a set mask and a clear mask. The set mask contains ones in the bit positions to be turned on. The remaining bits with zeros in the set mask will be left unchanged. SCRAW reads the current value of the bits (lines in the channel) and ORs it with the set mask value. The clear mask contains ones in the bit positions to be turned off. The remaining bits with zeros in the clear mask will be left unchanged. SCRAW uses the product of the set mask and ANDs it with the complement of the clear mask value. The new value is output on the channel. Key information to supply is a channel number and a value to be entered in the set/clear mask. The new value on the channel is returned.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(CHN, MASK, RESULT, SCRAW)

C:

result = labpac(SCRAW, CHN, MASK);

PARAMETERS:

Scraw (al):

The function number = 59

Chn (bx):

This variable contains the channel number from the Digital Output Channel Table

Mask (cx):

This variable contains the two bytes of the set/clear value. The high byte contains the bits to be set to a high state. The low byte contains the bits that are to be cleared to a low state.

Result (ax):

On return from the Call, RESULT (ax) contains the error code from the subroutine. The error message RANGE indicates the digital output channel is out of range. Otherwise, RESULT returns with the current output value.

REMARKS:

The present output value of the channel is ORed with the high byte of the set/clear value, ANDed with the complement of the low byte of the set/clear value, then output to the channel.

return to top of Technical Reference



SETALARM Set 9513A Alarm Register

PURPOSE:

This routine turns on the Alarm Register on timer/counter channels 1 or 2. Key information to supply is a channel number and the value to program into the Alarm Register.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(CHN, VALUE, RESULT, SETALARM)

C:

result = labpac(SETALARM, CHN, VALUE);

PARAMETERS:

Setalarm (al):

The function number = 64

Chn (bx):

The timer/counter channel from the Timer/Counter Channel Table. This channel must correspond to a 9513A counter 1 or 2.

Value (cx):

This is the value programmed to the Alarm Register which when matching the value in the counter drives its output latch.

Result (ax):

On return from the Call, RESULT (ax) returns the error code from the subroutine. A zero indicates the Call was successful. The error message TMR indicates the timer/counter channel is illegal. The error message RANGE indicates the timer/counter channel number is out of range.

REMARKS:

This Call changes the timer/counter channel output control to comparator output. If the counter value matches the alarm value, the channel output will be on, otherwise it will be off. All other functions of the timer/counter remain the same. The mode, load, and hold values in the counter will not be affected. To turn the alarm mode off, use TIAB on the timer channel.

If both timer/counter channels 1 and 2, are set to alarm output, and they are set to time-of-day mode, then Out2 will only be set if Outl is also set. This allows Out2 to be a full time-of-day alarm.

return to top of Technical Reference



SETTIME Set Time-of-Day

PURPOSE:

This routine starts the time-of-day process on timer/counter channels 1 and 2. The channels are loaded and armed. Key information to supply is a channel number and the time-of-day to install on the counters.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(CHN, SECONDS, MINUTES, RESULT, SETTIME)

C:

result = labpac(SETTIME, CHN, SECONDS, MINUTES);

PARAMETERS:

Settime (al):

The function number = 62

Chn (bx):

The timer/counter channel from the Timer/Counter Channel Table. This channel must correspond to a 9513A counter 1 or 2.

Seconds (cx):

The upper byte of SECONDS (cx) contains the number of seconds in BCD format, while the lower byte contains hundreths of seconds in BCD format.

If SECONDS (cx) equals minus one, the time-of-day is read from the DOS Clock.

Minutes (dx):

The upper byte of MINUTES (dx) contains the number of hours in BCD format, while the lower byte contains the number of minutes in BCD format.

Result (ax):

On return from the Call, RESULT (ax) contains the error code from the subroutine. A zero indicates the Call was successful. The error message TMR indicates the timer/counter channel is illegal. The error message RANGE indicates the timer/counter channel number is out of range.

REMARKS:

The seconds and minutes values must be in BCD format. In order to read the current time from the channels, use GETTIME. To turn the time-of-day mode off, use TIAB on the timer/counter channel.

return to top of Technical Reference



SWINIT Sweep Initialization

PURPOSE:

This routine installs an interrupt handler for interval processing of A/D, D/A or digital I/O channels. The function installs a user selected source for the interrupts to the CPU. Key information to supply is the interrupt source and the hardware interrupt (IRQ) number. SWINIT can disengage the interrupt handler.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(TMR, INTERRUPT, RESULT, SWINIT)

C:

result = labpac(SWINIT, TMR, INTERRUPT);

PARAMETERS:

Swinit (al):

The function number = 8

Tmr (bx):

This variable is the timer/counter channel used as the interrupt source. This timer/counter must have been initialized by TIINIT.

If CX (described below) is zero, then EX is the divisor for the systemboard timer. The interrupt frequency will be 1.19MHzlBX. The sweep frequency will be 297.5KHz/BX.

Interrupt (cx):

This variable is the IRQ channel number (2 - 15). If INTERRUPT (cx) is zero, the systemboard timer is used. If INTERRUPT (cx) is one, the interrupt service routine is disengaged.

Result (ax):

On return from the Call, RESULT (ax) contains the error code from the subroutine. A zero indicates the Call was successful. The error message PARAM indicates an IRQ line greater than 15. The error message RANGE indicates the specified timer/counter channel was not initialized. The error message TIMERR indicates that a FOUT timer/counter channel was selected.

REMARKS:

IRQs 2 through 7 can be installed on the Lab Master DMA, Lab Master, or Lab Tender using the interrupt header. IRQ7 is reccomended. Do not attach different boards to the same IRQ line. See the Installation chapter for information on installing the necessary hardware modifications to generate the hardware interrupt.

IRQ 3, 5, 11, or 15 may be used by the DAS series interface. For the MC-DAS the correct interrupt is automatically selected if INTERRUPT (c) is between two and fifteen.

Carefully read the sections in Techniques regarding the structure of the interrupt handler. Note especially that the LabPac interrupt handler is divided into four service routines and requires four hardware interrupts for a complete service cycle. Use the equations in Techniques chapter to calculate the values you use in PERIOD (dx) in TIST and SKP (bx) in any sweep start Call.

When SWINIT is run with INTERRUPT equal to one, the LabPac interrupt handler disengages from the IRQ vector restoring the previous contents of the vector. All current contents of index variables are preserved. The interrupt handler can be re-enabled and sweeps restarted from where they left off by re-calling SWINIT with the initial values used for parameters. Sweeps can also be restarted using a new interrupt period or a different IRQ line.

return to top of Technical Reference



TIAB Stop a Timer/Counter

PURPOSE:

This routine stops the counting process on a timer/counter channel. The channel is disarmed. Key information to supply is a channel number.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(CHN, RESULT, TIAB)

C:

result = labpac(TIAB, CHN);

PARAMETERS:

Tiab (al):

The function number = 34

Chn (bx):

This variable contains the channel number from the Timer/Counter Channel Table.

Result (ax):

On return from the Call, the variable RESULT (ax) contains the error code from the subroutine. A zero indicates that the Call was successful. The error message of RANGE indicates that too large of a channel number was used.

REMARKS:

On channel 0, turns off FOUT.

return to top of Technical Reference



TIHDW Special Timer Modes

PURPOSE:

This routine starts the counting process on a timer/counter channel with user supplied initialization information. Key information to supply is a channel number, a counter mode value, and value(s) to load into the counter.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(CHN, MODE, LOAD, HOLD, RESULT, TIHDW)

C:

result = labpac(TIHDW, CHN, MODE, LOAD, HOLD);

PARAMETERS:

Tihdw (al):

The function number = 51

Chn (bx):

The timer/counter channel from the TimerlCounter Channel Table.

Mode (cx):

The value to be programmed into the 9513A Counter Mode Register.

Load (dx):

The value to be programmed into the 9513A Load Register.

Hold (si):

The value to be programmed into the 9513A Hold Register.

Result (ax):

On return from the Call, RESULT (ax) contains the error code from the subroutine. A zero indicates the Call was successful. The error message PARAM indicates the mode request is for an illegal mode. The error message TMR indicates the timer/counter channel is an FOUT channel. The error message RANGE indicates the timer/counter channel number is out of range.

REMARKS:

All legal 9513A modes can be used. See the hardware manual for information. All modes can later be read back with TIRAW.

return to top of Technical Reference



TIINIT Timer Initialization

PURPOSE:

This routine fills the Timer/Counter Channel Table. The table can contain as many channels as indicated by the /T command line option (Default is 6). Key information to supply is the address of the 9513A Data Register on the Scientific Solutions data acquisition board. (Not required in PS/2 MicroChannel systems).

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(ADRS, RESULT, TIINIT)

C:

result = labpac(TIINIT, ADRS);

PARAMETERS:

Tiinit (al):

The function number = 9

Adrs (bx):

The 9513A Data Port I/O address on a Lab Master DMA, Lab Master, or Lab Tender (Base + 8) or the ISA DAS series (Base + 4).

Result (ax):

On return from the Call, RESULT (ax) contains the error code from the subroutine. The error message of TABLE indicates an attempt was made to initialize too many channels. Otherwise, RESULT contains the total number of timer channels initialized.

REMARKS:

The maximum number of timer/counter channels that LabPac can process is set by the /T command line option. The default is six channels. TIINIT can be called multiple times to initialize six channels per Call.

TIST and TIAB when called for a 9513 channel 0 will start and stop the FOUT signal. TISTAT when called for a 9513 channel 0 will return the current output status of the other five counters.

This Call has no functionality on the PS/2 MicroChannel system. If it is included in a program, the requested initializations will be ignored.

return to top of Technical Reference



TILH Waveform Output

PURPOSE:

This routine sets up a variable duty cycle waveform. Key information to supply is the channel number, the number of counts the output is to be low, the number of counts the output is to be high, and the counter's source.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(CHN, SOURCE, LOW, HIGH, RESULT, TILH)

C:

result = labpac(TILH, CHN, SOURCE, LOW, HIGH);

PARAMETERS:

Result (ax):

On return from the Call, the variable RESULT (ax) contains the error code from the subroutine or zero if the Call was successful. The error message RANGE indicates that a channel number was too large and TIMERR indicates an attempt to start an FOUT channel.

Tilh (al):

The function number = 19
 

Chn (bx):

This variable contains the channel number from the Timer/Counter Channel Table.
 

Source (cx):

This variable determines the source of the pulses that are counted by the 9513A counter. Use the following table to determine the value of SOURCE.

Value

Lab Master/Tender

DAS series

Terminal Count Output Terminal Count Output

Source 1 Source 1

Source 2 Source 2

Source 3 Source 3

Source 4 FIFO Transfer

Source 5 Converter Ready

GATE1 GATE1

GATE2 GATE2

GATE3 FIFO Input Ready

GATE4 DMA Terminal Count

10 

GATE5 GATE5

11 

1 MHz 1 MHz

12 

100 KHz 100 KHz

13 

10 KHz 10 KHz

14 

1 KHz 1 KHz

15 

100 Hz 100 Hz

To Gate a source, add the values below to SOURCE:

Value

Gating Behavior

16 

Count on Falling Edge

32 

High Gate of TC-1

64 

High GATE N + 1

96 

High GATE N-1

128 

High GATE N

160 

Low GATE N

192 

Rising Edge GATE N

224 

Falling Edge GATE N
Low (dx):

This variable contains the number of counts at the source that the output will be low.

High (si):

This variable contains the number of counts at the source that the output will be high.

return to top of Technical Reference



TIRAW Timer/Counter Input Read

PURPOSE:

This routine reads the timer/counter channel. Key information to supply is a channel number.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(CHN, RESULT, TIRAW)

C:

result = labpac(TIRAW, CHN);

PARAMETERS:

Tiraw (al):

The function number = 14

Chn (bx):

This variable contains the channel number from the Timer/Counter Channel Table.

Result (ax):

On return from the Call, the variable RESULT (ax) contains the value in the timer/counter channel.

The result from reading timer/counter channels 0 or 6 (FOUT) is the 9513A Status Register. Bits one to five reflect the current output status ofthe five counters.

The error message of RANGE indicates that too large a channel number was encountered.

REMARKS:

The return value is the value currently in the Hold Register. If the timer/counter channel was started with TIST or TTHDW (with the Load/Hold mode bit equal to zero) then a transfer of the current counter value to the Hold Register is performed before the read of the Hold Register.

return to top of Technical Reference



TIST Start Timer/Counter
 

PURPOSE:

This routine starts the counting process on a timer/counter channel. The channel is loaded and armed. Key information to supply is a channel number, the counter's source and the number of times to count source pulses.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(CHN, SOURCE, PERIOD, RESULT, TIST)

C:

result = labpac(TIST, CHN, SOURCE, PERIOD);

PARAMETERS:

Tist (al):

The function number = 24

Chn (bx):

This variable contains the channel number from the Timer/Counter Channel Table.

Source (cx):

This variable determines the source of the pulses that are counted by the 9513A counter. Use the following table to determine the value of SOURCE.

Value

Lab Master/Tender

DAS series

Terminal Count Output Terminal Count Output

Source 1 Source 1

Source 2 Source 2

Source 3 Source 3

Source 4 FIFO Transfer

Source 5 Converter Ready

GATE1 GATE1

GATE2 GATE2

GATE3 FIFO Input Ready

GATE4 DMA Terminal Count

10 

GATE5 GATE5

11 

1 MHz 1 MHz

12 

100 KHz 100 KHz

13 

10 KHz 10 KHz

14 

1 KHz 1 KHz

15 

100 Hz 100 Hz

To Gate a source, add the values below to SOURCE:

Value

Gating Behavior

16 

Count on Falling Edge

32 

High Gate of TC-1

64 

High GATE N + 1

96 

High GATE N-1

128 

High GATE N

160 

Low GATE N

192 

Rising Edge GATE N

224 

Falling Edge GATE N
Period (dx):

This variable contains the number of counts that occur at the counter's source before a pulse appears at the counter's output.

If the period is zero, the timer/counter channel will be acting as a counter and the value returned by TIRAW (Timer/Counter Read) will be the number of counts at the source since the Call of TIST.

If the period is non-zero, the timer/counter is acting as a divider and the value returned by TIRAW will start at the period value and decrement for each count at the source.

For timer/counter channel 0, period must be equal to or less than 16. See instructions for the 9513A Master Mode Register in the hardware manual.

Result (ax):

On return from the Call, the variable RESULT (ax) contains the error code from the subroutine. A zero indicates that the Call was successful. The error message PARAM indicates that an illegal value is in PERIOD (dx) or SOURCE (cx). The error message of RANGE indicates too large of a channel number.

REMARKS:

Timer/counter channel 0 starts the FOUT signal's output. Most of the sources for the FOUT counter are the same as for the five 16-bit counters. Value 0 is a 1 MHz source instead of the Terminal Count of a counter.

return to top of Technical Reference



TISTAT Wait Until Count N

PURPOSE:

When called, this routine stops the main program until a specified value is reached on the timer/counter channel. Key information to supply is a channel number and the value to wait for. Channel 0 waits until one of the timer/counters indicated has a high output.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(CHN, COUNT, RESULT, TISTAT)

C:

result = labpac(TISTAT, CHN, COUNT);

PARAMETERS:

Tistat (al):

The function number = 29

Chn (bx):

This variable contains the channel number from the Timer/Counter Channel Table.

Count (cx):

This variable contains the value that the subroutine will wait for on the specified timer/counter channel before returning to the main program.

Result (ax):

On return from the Call, the variable RESULT (ax) contains the current count on the timer/counter channel. The error message RANGE indicates that a channel number was too large. The error message TIMERR indicates attempt to read timer/counter not started or not started in the proper mode.

REMARKS:

If the selected timer/counter channel is counting up, TISTAT will wait until the value in the counter is greater than or equal to the COUNT value before returning. For example if COUNT equals 14 and the value on the timer/counter channel is 23, then TISTAT will return immediately.

If the selected timer/counter channel is counting down, TISTAT will wait until the value on the counter is less than or equal to the COUNT value before returning. For example if COUNT equals 789 and the value on the timer/counter channel is 783, then TISTAT will return immediately.

If timer/counter channel 0 is used, TISTAT will wait until the low byte of COUNT value ANDed with the 9513A Status Register is equal to the high byte of COUNT. Use the low byte of COUNT as a mask to select the counter outputs to monitor and the high byte to select the sense of the monitored bits.

return to top of Technical Reference



WRITE Write Data To a File

PURPOSE:

This routine will save a data array into an external file. The data will be stored in ASCII format. Key information to supply is the file handle number assigned when the file was opened, the number of sweeps, the number of channels for the data array dimensions, the channel array and the data array.

CALLING FORMATS:

Advanced BASIC:

CALL LABPAC(HNDL, NSWPS, NCHNS, CHN(0), OBUF(0,0), RESULT, LWRITE)

C:

result = labpac(WRITE, HNDL, NSWPS, NCHNS, CHN, OBUF);

PARAMETERS:

LwriteWrite, Lwrite (al): The function number = 38

Hndl (bx):

Contains the File Handle assigned by the CREATE Call. Range is zero to 19.

Nswps (cx):

Contains the number of times values for a set of channels were stored in the data array.

Nchns (dx):

Contains the number of channels that are stored in the data array.

Chn, Chn(0), (ds:si):

This variable is the pointer to the starting address in memory for a one-dimensional array containing the channel numbers to be written to the file.

Obuf, Obuf(Chn,Swp), (es:di):

This variable is the pointer to the starting address in memory for an output data array. See the discussion in the Techniques chapter.

Result (ax):

On return from the Call, this variable contains the error code from the subroutine. A zero indicates the Call was successful. The error message PARAM indicates that the NSWPS or NCHNS parameters did not match the ones stored in the data file. The error message FILERR indicates either a bad File Handle or out of space on the disk to add the data to the file.
 

return to top of Technical Reference


Example Applications

STIMULUS & RESPONSE
PRE-TRIGGER DATA COLLECTION
ANALOG OUTPUT WAVEFORM
TACHOMETER
BACKGROUND PROGRAMMING
The purpose of this appendix is to present a variety of notes on using LabPac in applications. The intent of these notes is to present either ideas on optimizing an application or alternate ways to set up equipment and software. The notes are in no particular order or priority.
 

STIMULUS & RESPONSE

This section sets up a stimulus-response type of experiment. We are measuring the response of a human eye to light stimulus. We wish to find out how fast an eye can track a moving light in a darkened room. The moving light will be simulated using twenty-four LEDs driven by the three digital ports of a LabMaster DMA. We track the eyes' positions with three axial sensors each. A test lasts ten seconds and is started with a switched pulse into timer source 1. We need to initialize the timer, digital ports, and analog channels as follows:

** Initialize the ports **
labpac(RESET)
labpac(TIINIT, TIMER)
labpac(AIINIT, ATOD, 6, 0)
labpac(DINIT, PIO, 0)
The lights need to change with tenths of a second accuracy, and we wish to concurrently track the eyes every hundreth of a second. These two requirements indicate the need for background sweeps operating at millisecond intervals. Assuming the standard LabMaster setup, using IRQ7 and timer 1 for the sweeps, the following code enables background sweeps:
labpac(SWINIT, 1,7)
We do not turn on the sweep timer until both sweeps are set up in order to keep them syncronized. The channel arrays and the digital output data array need to be set up at this time. We will sample the channels in regular order and the digital output will be off for the first 4/10 of a second and then scan across the LEDs four times.
** Fill analog input channel array **
for channel = 0 to 5
  aichan[channel] = channel
 
** Fill digital output channel array **
for channel = 0 to 2
  dochan[channel] = channel
 
** Zero digital output data array **
for time = 0 to 99
  for channel = 0 to 2
    dodata[time][channel] = 0;
 
** Fill in the scanning light **
for time= 0 to 95
  LEDn= time div 24
  dodata[time+4][LEDn div 8] = 1 shl (LEDn rnod 8)
Once the data is ready, we need to wait for the trigger on timer source one. Since our trigger source is a simple mechanical switch toggling between ground and +5V, we can expect some chatter or switch bounce. We will set up a timer to count up from zero, and if we get at least one contact pulse, continue with the program.
** Wait for trigger **
labpac(TIST, 2, 1, 0)
labpac(TISTAT, 1, 1)
Now we will set up the sweeps. We need a sweep frequency of 100Hz for the analog inputs. This means an interrupt frequency of 400Hz. We will use source 14 (1 KHz) and a period of twenty-five. The analog input sweeps will execute every service cycle so its skip will be one. It will collect a total of 1,000 sweeps. The digital output sweep will need a skip of 10 and will have 100 sweeps of data.
** Start the sweeps **
labpac(AISWST, 1, 1000, 6, aichan, aidata)
labpac(DISWST, 10, 100, 6, dochan, dodata)
labpac(TIST, 1, 14, 25)
 
** Wait for end of data collection **
labpac(AISTAT, 0)
After the data is collected, we can either immediately process the data or we can save it for later analysis. We will save our data for work with a spreadsheet.
** Save the data **
file= labpac(CREATE, "test.prn")
labpac(WRITE, file, 1000, 6, aichan, aidata)
labpac(CLOSE, file)
return to top of Example Applications


PRE-TRIGGER DATA COLLECTION

For the following experiment we will to track five different chemical concentrations in a solution as well as temperature and pressure data. After the chemical concentration on channel 2 reaches the set point, we would like to monitor the chemical data in finer detail for half of a second. We would also like to have two seconds of data leading up to the trigger point. The pre-trigger data rate will be 1KHz, the post-trigger data rate will be 10KHz. We will be using an MC-DAS 1612 for our experiment.
 

Since microchannel boards are automatically initialized, we do not need to do initializing calls except for the sweep, enabling, and timing. Timer 4 will be set up to generate the 4KHz interrupt rate corresponding to the 1KHz background sweep rate. Timer 3 will be set up as the 10KHz pace clock for the faster foreground input sweeps. Also, we need to increase the gain on the temperature and pressure channels to 100 and 500 respectively.

** Enable and set sweep time **
labpac(SWINIT, 3, 2)
 
** Timer 3 foreground pace clock **
labpac(TIST, 3, 13, 1)
 
** Timer 4 background sweep clock **
labpac(TIST, 4, 13, 25)
 
** Set Pressure to gain of 500 **
labpac(AIGAIN, 5, 3)
 
** Set Temperature to gain of 100 **
labpac(AIGAIN, 6, 2)
Since our data must be time accurate we need to turn off the periodic motherboard interrupt. However, we would like the DOS timeclock to not be affected, so we will set up our timers to keep track of the time while IRQ0 is disabled.
** Disable int and read time **
saveint = labpac(lNTCLR, 1)
labpac(SETTIME, 1, -1, 0)
Now we start the background sweeps and in the foreground, monitor the trigger channel for our ending condition. (In this example, all arrays are zero based.)
** Start background sweep **
for channel = 0 to 6
  aichan[channel] = channel
labpac(AIRSWST, 4, 2000, 7, aichan, airdata)
 
** Wait for trigger **
sweep = 2000
do
  decrement sweep
  sweep = labpac(AISTAT, sweep)
until airdata[l 999-sweep][2] > setpoint
After encountering the trigger, we stop the background sweeps and start the fast foreground sweeps. The fastest way of turning off the background sweeps and stopping the interrupt overhead is by turning the interrupt off.
** Stop background **
labpac(lNTCLR, 1 shl intlevel)
 
** start foreground **
labpac(AIMAX, 3, 5000, 5, aichan, maxdata)
 
** Enable int **
labpac(lNTSET, saveint)
After data collection has occured, we will shift the data in the pre-trigger array so that the first sweep is in the first "row" of the array. (We are working in an application language that uses "row-major" indexing.) First we need to find out what sweep was last filled, then we can copy the data in the proper order.
** Normalize in time the circular buffer**
lastsweep = labpac(AISWAB)
for time = 0 to 1999
  if time > lastsweep
    normal[time][] = airdata[time-lastsweep][]
  else  
    normal[time][] =airdata[l999+time-lastsweep][]
Now we will reset the DOS time and save the data in binary format for later use.
** Reset time and save the data **
labpac(GE'ITlME, 1, 1)
file = labpac(CREATE, "test.prn")
labpac(BINWR, file, 2000, 5, aichan, normal)
labpac(BINWR, file, 5000, 7, aichan, maxdata)
labpac(CLOSE, file)
return to top of Example Applications


ANALOG OUTPUT WAVEFORM

Occasionally there is a need for an analog output waveform. If this is slow enough we can use the AORSWST routine to constantly update the D/A converter in the background while the foreground program is attending to other tasks. In this example we will set up two waveforms, the first a triangle and the second a sine. The period will be 50 hertz. In order to get a reasonable approximation of the sine wave we will output 200 sample points per cycle giving us a sample frequency of 1 KHz and a interrupt frequency of 4 KHz. First we initilize the timer and analog channels as follows:

** Initialize labpac and d/a **
labpac(RESET)
labpac(TIINIT, TIMER)
labpac(AOINIT, DTOA, 2)
Filling the data array is accomplished by indexing the data array by time and channel and assigning each element with its proper function. Depending on which application language you use, the array subscripts may need to be transposed.
** Channel 0 function **
function triangle(time)
  if(time < 100)
    return(20*time-l 000)
  else  
    return(3000- 20*time)
  endif
endfunction
 
** Channel 1 function **
function sine(time)
  return(int(1000*sin(time/200*3.14)) )
endfunction
 
** Assign arrays **
for time = 0 to 199
  aodata[time][0] = triangle(time)
  aodata[time][t] = sine(time)
chan[0] = 0
chan[l] = l
Assuming a LabMaster using IRQ7 and timer 1 for the sweeps, the following code starts the interrupt timer (source 100KHz / period 25 yields 4KHz), enables background sweeps and starts the background repeating analog output sweeps:
labpac(TIST, 1, 11,25)
labpac(SWINIT, 1, 7)
labpac(AORSWST, 1, 200, 2, chans, aodata)
We can now continue the precede with other tasks that the program handles in the foreground. When the sweeps are no longer needed, turn them off with the abort sweep command:
labpac(AOSWAB)
return to top of Example Applications


TACHOMETER

Often when counting events, we would like to know the number of events over certain amount of time. An example of this would be a flow meter, where the output is a pulse every time a certain volume of liquid has passed, and we would like to read a flow rate as gallons per minute. This is often referred to as a tachometer.

A simple way of making a tachometer is with two 9513 counters. Set up one of the counters to count up with special gating on a gate edge, Set up another counter to create a pulse train for the first counter's timebase. Connect the second counter's output to the gate that the first counter is using. To read the instaneous rate, read the HOLD register of the first counter.

As an example, we have a flowmeter that causes a pulse for every 5 milliliters of water and we wish to update the flow rate figure every tenth of a second. (This assumes we will be getting enough pulses per second to be updating this fast.) The following code sets up Counter 2 in the special gating mode and sets up Counter 0 (Fout) to pulse every tenth of a second.

** Timer 0 rate clock **
labpac(TIST, 0, 15, 10)
 
** Counter 2 src pulses/gate pulse **
labpac(TIHDW, 2, 1100001011101000b, 0, 0)
We need to connect the flowmeter output to Src 2 and externally connect Fout to Gate 2. In order to read the counts per tenth of a second we use the outport and inport statements. This will be different depending on which board we are using. For the LabMaster or LabTender we need two byte wide reads of the timer.
** Read LabMaster/LabTender **
 
** Point to Hold Register 2 **
outportb(BASE+9, 12h)
 
** Read back register **
low = inportb(BASE+8)
hi = inportb(BASE+8)
result = hi * 256 + low
For the MC-DAS series boards, a single word wide read of the counter is required.
** Read MC-DAS 16xx **
 
** Point to Hold Register 2 **
outportb(BASE+2, 12h)
 
** Read back register **
result = inport(BASE+4)
Once we have the value read back, we can scale it to the proper value. For our example, dividing the result by two will give us milliliters per second. (5 m1/0.1 second divide by 2 yields 1 ml/second)

return to top of Example Applications



BACKGROUND PROGRAMMING

If we need to sample a process over a long period of time (a day or a week), and the sample rate is slow (once a minute or hour), we can set up a background sampling routine which does not interfere with using the computer for word-processing or number-crunching applications.

In this example we will set up sampling of A/D channels 5, 6, 8, and 10 every second for one hour. The program will save a pointer to the data buffer and then exit to MS-DOS and stay resident in memory. First we initialize the timer and analog channels as follows:

** Initialize **
labpac(RESET)
labpac(TIINIT, TIMER)
labpac(AIINIT, ATOD, 16, 0)
 
** Fill Channel Array **
chan[0]= 5
chan[0]= 6
chan[0]= 8
chan[0] = l0
Assuming a LabMaster using IRQ7 and timer 1 for the sweeps, the following code starts the interrupt timer (source 100Hz / period 25 yields 4Hz), enables background sweeps and starts the background analog input sweep:
labpac(TIST, 1, 15, 25)
labpac(SWINIT, 1,7)
labpac(AISWST, 1,3600, 4, chan, aidata)
We now save a pointer to the data buffer in an unsed software vector and exit to dos:
** Use Dos Function 25 to set vector **
bdosptr(0x25, addr(aidata), 0xf3)
 
** Use Dos Function 31 to exit and stay resident **
bdos(0x31, sizeofprogram, 0)
After the hour is up, use another program to find the data and save it to disk. The computer must not be turned off or reset between starting the sweeps and writing the data to file! However, the computer is available for use with other programs.
** Use Dos Function 35 to get vector **
aidata = bdos(0x35, 0, 0xF3)
file = labpac(CREATE, "test.prn")
labpac(WRITE, file, 3600, 4, chan, aidata)
labpac(CLOSE, file)
return to top of Example Applications


Interrupt Service Structure

INITIALIZATION
HARDWARE INTERRUPT HANDLER
  IRQ Installation
  The Service Cycle
  Calculating Interrupt Timing
LabPac chains on software interrupt 66 hexadecimal. This means that when LabPac is loaded it becomes memory resident with an address pointer placed in the INT66H vector. If another program also occupies INT66H and has placed a pointer in the vector, LabPac can distinguish its calls from the other program's by inspecting the contents of the AH register. If the call is not to LabPac, it will pass the call on to the next program. When it loads, LabPac saves the pointer that was in the INT66H vector. The last program loaded receives the information first. Since LabPac chains, it will transfer the address pointer correctly. If problems occur with LabPac and another memory resident program installed after LabPac by loading the other program before loading LabPac. Issuing a Call to LabPac consists of three steps:

INITIALIZATION

Table Name

Default Maximum Channels

Analog Input Channel Table

16 

Analog Output Channel Table

Digital Input Channel Table

Digital Output Channel Table

Timer/Counter Channel Table

Each internal channel table stores the I/O address(es) for the control register(s) and data port(s) for the hardware features. The analog channel tables also store the numbering for the input/output lines in the hardware. The analog input table additionally stores the gain level for each analog input line.

return to top of Interrupt Service Structure


HARDWARE INTERRUPT HANDLER

Some LabPac features use the interrupt capability of Scientific Solutions products. This means that data collection or process control functions can be done at regulated intervals while the main program is involved with other tasks.

At user determined intervals, a hardware interrupt (IRQ) is generated that stops whatever program is currently running. The 8259 hardware interrupt handler in the computer receives the interrupt, notifies the CPU, and saves information for the program that was interrupted. The location in memory of the program waiting for the interrupt is pulled from a table and control of the computer is transferred to that location. This program is referred to as the interrupt service routine. LabPac installs an interrupt handler or service routine to allow timed interval data collection or process control functions to occur without requiring unnecessary programming steps.

IRQ Installation

One of the LabPac functions, SWINIT, installs the interrupt handler and initializes several state variables. When the interrupt handler is installed, a memory location pointer is placed in the interrupt vector for the specified IRQ line. The previous vector is saved by the installation subroutine. If the LabPac option to disengage the interrupt handler is used, the installation subroutine restores the previous address pointer to the interrupt vector and turns off hardware interrupts.

Because of its emphasis on flexibility, hardware interrupts used by LabPac can be generated from several sources. Normally timer/counter channel 1 is the IRQ source. Another source is the PC Systemboard Timer. It can interrupt the system up to 1.19 million times per second. To use external interrupt sources, the TTL compatible signal must be routed to a timer input and the timer/counter channel programmed to count that source.

Since the interrupt handler is driven by a hardware IRQ, the designated source must be connected to the proper IRQ line on the PC bus. Make sure that the chosen IRQ either has nothing else on it or that the other peripheral is tri-stated on the IRQ line. For example, most LabPac users will select IRQ7 for this feature. IRQ7 is also attached to the printer ports in the PC. Original IBM equipment and many other computers or printer port peripherals do tri-state IRQ7 so other peripherals such as a Lab Master can use the line also. However, if the printer port is not tri-stated, then no other equipment can share the line. If there are problems with sweep routines after installing LabPac, try another IRQ line.

When using a Lab Master DMA, Lab Master or Lab Tender the 9513A counter 1 is the usual interrupt source. Install the following features on your board to implement this source.

The Service Cycle

The LabPac interrupt handler monitors a service cycle for timed interval processes. The service cycle consists of four parts. Each part is responsible for monitoring the status of timed interval sampling or sending of data for a set of one or more channels (referred to as a sweep of channels). The four types of sweeps are: analog input, digital input, analog output and digital output. The status of each type of sweep is monitored by its own "process context". This is a subroutine that checks to see if any sweep is in progress, or if it is time to conduct a sweep. There are four process contexts, one for each sweep.

When the LabPac interrupt handler is called by the CPU, the main routine to monitor the service cycle is run. The routine acknowledges to the CPU and the Scientific Solutions hardware that the interrupt was received. The status of the service cycle is then checked and one of the process contexts is called. One process context is serviced on each hardware interrupt. The full service cycle consists of the running of all four process contexts. Thus it takes four hardware interrupts to complete one full service cycle.

Each process context tracks six state variables. The values of all the state variables are set by a sweep start call. Theses variables are:

Status Is this context active
N of Sweeps How many sweeps to run
Sweeps Left How many sweeps are left
Count Number of service cycles to skip between each sweep
Counts Left Number of service cycles left before the next sweep is to start
Restart Should sweeps be automatically restarted

When called, a process context checks to see if its sweep processing subroutine is already operating. If its sweep routine is in process the overrun flag is set and sweeps are halted. If a sweep is not in process, Counts Left is decremented. When the Counts Left reaches zero, the Sweeps Left is decremented and the sweep processing subroutine is called. When the Sweeps Left reaches zero, the Restart variable is checked. If the sweeps are to be automatically restarted, the other variables are reset to initial values and the cycle restarted.

The sweep processing subroutine tracks six state variables. The values of these state variables are set by the sweep start call. The state variables are:

N of Channels How many channels to sweep
Channels Left How many channels are left to process
Channel Array Address Where is the next channel located in memory
Channel Array Start Address What is the starting memory address of the channel array
Data Array Address Where are the next two bytes of the data array located in memory
Data Array Start Address What is the starting memory address of the data array

The first time a sweep is conducted, the Channel Array Address and the Data Array Address indices are set equal to zero. As each sample is processed, the Channels Left is decremented and the Channel Array Address and Data Array Address indices are incremented. When the Channels Left reaches zero, it is reset to the N of Channels. The Channel Array Address is reset to the

Channel Array Start Address. The Data Array Address is left alone so that the next time a sweep is conducted, it will be pointing to the correct location to find or place data. After each sweep, control is returned to the main program.

7

With analog inputs in particular, there is always the danger for an overrun to occur in the service cycle. An overrun is when the process context calculates it is time to begin a sweep and the previous sweep of the same type is still in progress. The possibility of an overrun increases if too many channels need to be processed and not enough time has been allowed in the service cycle. This is also more likely to happen if another type of sweep is started with not enough time allowed to do both sweeps.

Interrupt timing is a critical area. Each part of the interrupt process takes valuable microseconds which must be considered when calculating parameters for initializing and starting sweeps. The list below discusses timing considerations.

SWEEP TYPE

MICROSECONDS

Analog Input

50 

Digital Input

20 

Analog Output

20 

Digital Output

20 

The LabPac interrupt handler is designed as a general purpose interface to do timed interval sweeps. As such, it has to contain more overhead then interrupt handlers designed to service one fixed purpose. Looking at the timing presented above, it takes approximately 90 microseconds to service one hardware interrupt by the combined efforts of the CPU (50 microseconds), the main LabPac service routine (30 microseconds) and one process context (10 microseconds). This does not count the actual time spent processing a sweep or the time needed by the program that was interrupted.

Another factor to consider, which is reflected somewhat in the estimates, is the other system processes that interrupt the CPU. These processes can also interrupt the LabPac interrupt handler or force the interrupt handler to wait for service from the CPU. In general these other interrupting processes increase the timing requirements of the LabPac interrupt handler or LabPac functions in general. The Example Applications chapter has a discussion of how to turn some of these processes off.

The most important factor is how fast of computer you are working with. If you are working with an 8MHz AT class machine, the recommendations in the following paragrpah apply. Otherwise, try your application and see if the computer is fast enough.

The minimum recomended time interval for one complete service cycle be 800 microseconds. This equates to 1250 complete service cycles per second. When calculating parameters for the time interval on the interrupt source, divide the service cycle interval to be used by four to get the time interval between each hardware interrupt. Details on calculating the key variables dealing with interrupt timing are given below.

Interrupt timing can be calculated as either a time interval or a frequency (i.e., times per second). Both types of calculation are demonstrated below. When using these formulas note that the following terms are used: Interrupt (hardware interrupt); Source (9513A counter's input source); Count (i.e., number of times to count the signal at the Source); and Skip (the number of complete service cycles between sweeps). Three formulas are needed as shown below for calculating time intervals.

Interrupt Interval

Source Interval * Count
Service Cycle Interval

4* Interrupt Interval
Sweep Interval

Service Cycle Interval * Skip
As an example using a 100 microsecond Source interval, let the Count for the source interval equal 75 and the Skip between sweeps equal 20. The following calculations apply.
Interrupt Interval .1 mS * 75 = 7.5 mS
Service Cycle Interval 7.5mS*4 =30mS
Sweep Interval 30 mS * 20 skips = 600mS
For this example, these values mean that a hardware interrupt will occur every 7.5 milliseconds. It will take 30 milliseconds to complete one of LabPac's service cycles. There will be a sweep every 600 milliseconds or 1.67 sweeps per second.

The simple way to calculate frequencies is to invert the time interval calculations. For convenience the frequency formulas are given below.

Interrupt Frequency

Source Frequency / Count
Service Cycle Frequency

Interrupt Frequency / 4
Sweep Frequency

Service Cycle Frequency / Skip
Using the numbers from the example above provides the following calculations:
Interrupt Frequency

10,000 Hz / 75 

133.33 Hz
Service Cycle Frequency

133.33 Hz / 4 

33.33 Hz
Sweep Frequency

33.33 Hz / 20 

1.67 Hz
This again equates to 1.67 sweeps per second.
 

return to top of Interrupt Service Structure


Error Codes

PARAM (8001)
RANGE (8002)
OVERRUN (8003)
TABLE (8004)
FILERR (8005)
DMAERR (8006)
TIMERR (8007)
EMMERR (8008)
The following is a list of error codes that are returned from LabPac calls. Along with the error mnemonics is the corresponding hex value and possible causes for the error.

PARAM (8001)

One of the scalar parameters supplied was unacceptable.

return to top of Error Codes


RANGE (8002)

A channel number exceded the maximum number of initialized channels.

return to top of Error Codes


OVERRUN (8003)

There was not enough time to do all processing required during the background sweep or external triggerring is occuring faster than the processor could handle.

return to top of Error Codes


TABLE (8004)

An attempt was made to initialize more channels than there was space for in the channel tables. Try rerunning LabPac with command line parameters to increase the appropiate table size.

return to top of Error Codes


FILERR (8005)

A dos file error occured.

return to top of Error Codes


DMAERR (8006)

A dma error occured. For the PC/XT/AT, the buffer specified may have crossed a 64K page boundary.

return to top of Error Codes


TIMERR (8007)

An operation was attempted on a timer channel incapable of performing that function. For example, using timer 0 in an AIMAX call.

return to top of Error Codes


EMMERR (8008)

The extended memory manager detected an error.

return to top of Error Codes