MASTER LINK SOFTWARE LIBRARIES (PCI
Transcrição
MASTER LINK SOFTWARE LIBRARIES (PCI
INNOVATIVE PC Data Acquisition Solutions MASTER LINK SOFTWARE LIBRARIES (PCI-20369S and PCI-20485S) FOR DOS, Windows 3.x and Win32 855M466 3.0 Copyright 1992-97 by Intelligent Instrumentation Inc., Tucson, Arizona, USA All rights reserved. Warranty and Repair Policy Statement General Seller warrants that its products furnished hereunder will, at the time of delivery, be free from defects in material and workmanship and will conform to Seller's published specifications applicable at the time of sale. Seller's obligation or liability to Buyer for products which do not conform to above stated warranty shall be limited to Seller, at Seller's sole discretion, either repairing the product, replacing the product with a like or similar product, or refunding the purchase price of the nonconforming product, provided that written notice of said nonconformance is received by Seller within the time periods set forth below: a) for all software products, including licensed programs, ninety (90) days from date of initial delivery to Buyer; b) for all hardware products, including complete systems, one year from date of initial delivery to Buyer, subject to the additional conditions of paragraphs c) and d) below; c) all PCI-20000, PCI-600, PCI-700 series circuit card assemblies shall be warranted for the "lifetime" of the product, subject to the limitations of paragraph d) below. For the purposes of this warranty, "lifetime" is defined to mean: FROM THE DATE OF PURCHASE UNTIL FIVE YEARS AFTER THE DATE THAT INTELLIGENT INSTRUMENTATION DISCONTINUES MANUFACTURING SAID PRODUCT AND LISTS THE PRODUCT IN ITS PUBLISHED LIST OF DISCONTINUED PRODUCTS. Electro-mechanical items such as, but not limited to, batteries, relays and switches, which are purchased separately or included as part of the above products, are warranted for a period of one year. d) In the event that Buyer's returned product is a Discontinued product and is unrepairable for any reason, Seller may elect to replace it with like or similar product that is, in Seller's sole judgment, the closest equivalent to the returned product. Seller does not warrant that such replacement product will be an exact functional replacement of the returned product. Further, all products warranted hereunder for which Seller has received timely notice of nonconformance must be returned FOB Seller's plant no later than thirty (30) days after the expiration of the warranty periods set forth above. These warranties provided herein shall not apply to any products which Seller determines have been subjected, by Buyer or others, to operating and/or environmental conditions in excess of the limits established in Seller's published specifications or otherwise have been the subject of mishandling, misuse, neglect, improper testing, repair, alteration or damage. THESE WARRANTIES EXTEND TO BUYER ONLY AND NOT TO BUYER'S CUSTOMERS OR USERS OF BUYER'S PRODUCT AND ARE IN LIEU OF ALL OTHER WARRANTIES WHETHER EXPRESS, IMPLIED OR STATUTORY INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SELLER BE LIABLE FOR INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES. Seller's liability for any claim of any kind shall in no case exceed the obligation or liability specified in this Warranty clause. Technical Assistance and Service Seller's warranty as herein set forth shall not be enlarged, diminished or affected by, and no obligation or liability shall arise or grow out of, Seller's rendering of technical advice, facilities or service in connection with Buyer's order of the goods furnished hereunder. Products returned for warranty service, but which are found to be fully functional and in conformance with specifications may be subject to a nominal service charge and return freight charges. Periodic re-calibration of products, if required, is the responsibility of Buyer and is not provided under this Warranty. Static Sensitivity Seller ships all static-susceptible products in anti-static packages. Seller's Warranty as herein set forth shall not cover warranty repair or replacement for products damaged by static due to Buyer's failure to use proper protective procedures when handling, storing, or installing products. IBM PC, XT, AT are registered trademarks of International Business Machines Corporation. Microsoft Windows, Windows 95 and Windows NT are registered trademarks of Microsoft Corporation. Master Link Software Libraries MASTER LINK SOFTWARE LIBRARIES MANUAL REVISION HISTORY Version Date Revision 1.0 2.0 2.1 920508 920928 921130 3.0 970926 Original Release Version 2.00 release of drivers for Microsoft Windows support. Version 2.1 added installation program and support for the PCI-20377W Low Power Multifunction Board. Also changed product name to Master Link Software Libraries. Version 3.0 added Win32 32-bit support. Updated manual for PCI-20378W Digital I/O Boards and PCI-20428W Multifunction Boards. i Master Link Software Libraries This page intentionally blank ii Table of Contents Table of Contents Chapter 1: Introduction 1.1 About this Manual .................................................................................................... 1-1 1.2 The Master Link Software Libraries......................................................................... 1-1 1.3 System Configuration Requirements....................................................................... 1-2 1.3.1 DOS Environment - Programming Language Support ............................ 1-2 1.3.2 Microsoft Windows 3.x Environment Programming Language Support ............................................................ 1-2 1.3.3 Win32 Environment - Programming Language Support ......................... 1-2 1.4 The Software License Agreement ........................................................................... 1-3 Chapter 2: Getting Started 2.1 Introduction .............................................................................................................. 2-1 2.2 Installing the DOS Based Libraries.......................................................................... 2-1 2.3 DOS Based Library Files ......................................................................................... 2-2 2.3.1 C Language Software Library Files ......................................................... 2-2 2.3.2 Turbo Pascal Language Software Library Files....................................... 2-3 2.3.3 Microsoft QuickBASIC Language Software Library Files ...................... 2-4 2.4 Using the DOS Based Software Interface Library ................................................... 2-5 2.4.1 Interface Files and Your Program............................................................ 2-5 C and QuickBASIC ............................................................................... 2-5 Turbo Pascal ........................................................................................ 2-5 2.4.2 Summary of Steps for Using The DOS Based Interface Files ................ 2-7 2.5 Installing the Microsoft Windows 3.x Based Software Libraries .......................... 2-8 2.6 The Microsoft Windows 3.x Based Software Interface Files ............................... 2-10 2.6.1 Microsoft Visual Basic Language Files .................................................. 2-10 2.6.2 C Language Software Files ..................................................................... 2-11 2.6.3 Pascal Language Software Files ............................................................. 2-12 2.7 Using the Microsoft Windows 3.x Based Software Interface Files ...................... 2-13 2.7.1 The Master Link Dynamic Link Library .................................................... 2-13 2.7.2 Other Interface Files and Your Program ................................................. 2-13 2.7.3 Programming Language Notes ............................................................... 2-13 Visual Basic .......................................................................................... 2-13 C ........................................................................................................... 2-14 Turbo Pascal for Windows ................................................................... 2-14 2.8 Installing the Win32 Based Software Libraries ........................................................ 2-15 2.9 The Win32 Based Software Interface Files ............................................................. 2-18 2.9.1 C Language Software Files ..................................................................... 2-19 2.9.2 Microsoft Visual Basic Language Files .................................................. 2-20 2.10 Using the Win32 Based Software Interface Files .................................................. 2-21 2.10.1 The Master Link Win32 Dynamic Link Library....................................... 2-21 2.10.2 Other Interface Files and Your Program ............................................... 2-21 2.10.3 Programming Language Notes ............................................................. 2-21 C ........................................................................................................... 2-21 Visual Basic .......................................................................................... 2-22 2.11 Communicating With the Libraries ........................................................................ 2-22 Chapter 3: General Programming Procedures 3.1 Function Categories and General Call Structure..................................................... 3-1 3.1.1 Function Call Groups............................................................................... 3-1 3.1.2 Call Structure........................................................................................... 3-3 3.2 Initialization .............................................................................................................. 3-4 iii Table of Contents 3.3 3.4 3.5 3.6 3.7 3.8 iv 3.2.1 Hardware and Software Initialization Functions .......................................3-4 3.2.2 Hardware and Software Support Functions .............................................3-4 3.2.3 Slot Assignment and Inquiry Functions....................................................3-5 3.2.4 Initialization Function Call Sequence .......................................................3-7 Analog Input .............................................................................................................3-8 3.3.1 Single Channel Acquisition ......................................................................3-8 Common Analog Data Format ..............................................................3-8 Using the PCI-20364M-1 High-Accuracy Analog Input Module. ...........3-9 3.3.2 Single Channel Analog Input Acquisition Programming Procedures .......3-9 Analog Input Single Channel Read .......................................................3-9 Reading All Channels on a PCI-20363M-1 SSH Module ......................3-10 Reading a Channel on a PCI-20364M-1 Module ..................................3-10 3.3.3 Multiple Channel Acquisition ....................................................................3-10 Pacing Signals ......................................................................................3-11 Trigger Signals ......................................................................................3-11 Start and Stop Modes ...........................................................................3-11 Buffers...................................................................................................3-12 3.3.4 Multiple Channel Analog Input DMA Programming Procedures ..............3-13 3.3.5 Analog Input DMA Overrun Errors ...........................................................3-15 Analog Output ..........................................................................................................3-16 3.4.1 Non-DMA Analog Output .........................................................................3-16 3.4.2 Analog Output Programming Procedures ................................................3-16 Burst Generator........................................................................................................3-18 3.5.1 Modes ......................................................................................................3-18 Figure 3.1 Burst Generator Waveform.................................................3-18 3.5.2 Using a Burst Generator as a DMA Pacer or Trigger ..............................3-18 3.5.3 Burst Generator Programming Procedures .............................................3-19 Counters...................................................................................................................3-20 3.6.1 Signal Measurement - Period and Pulsewidth .........................................3-20 Period Measurement.............................................................................3-21 Pulsewidth Measurement......................................................................3-21 3.6.2 Event Counting Mode...............................................................................3-21 3.6.3 Programmable Divider Mode (divide-by-N)..............................................3-22 Continuous Mode ..................................................................................3-22 Latched Mode .......................................................................................3-22 3.6.4 Variable Duty-Cycle Generator (VDCG) Mode ........................................3-22 Figure 3.2 VDCG Waveform................................................................3-23 3.6.5 Using a Counter as a DMA Pacer or Trigger ...........................................3-23 3.6.6 Counter Programming Procedures ..........................................................3-23 Counters, 8254-Based .............................................................................................3-25 3.7.1 Operational Modes...................................................................................3-25 Mode 0: Interrupt on Terminal Count ...................................................3-25 Mode 1: Hardware Retriggerable One-Shot.........................................3-25 Mode 2: Rate Generator ......................................................................3-26 Mode 3: Square Wave Generator ........................................................3-26 Mode 4: Software Triggered Strobe.....................................................3-26 Mode 5: Hardware Triggered Strobe ...................................................3-26 Mode Summary Table...........................................................................3-26 3.7.2 Configuration............................................................................................3-27 3.7.3 Counter Reading and Status....................................................................3-27 3.7.4 Frequency Measurement .........................................................................3-27 3.7.5 Using a Counter Channel as a DMA Pacer and/or Trigger......................3-28 3.7.6 8254-Based Counter Programming Procedures......................................3-28 Programming/Reading a Single Counter ..............................................3-28 Programming/Reading All Counters on a Module.................................3-29 Digital Input/Output ..................................................................................................3-30 3.8.1 Digital I/O Operations...............................................................................3-30 Table of Contents 3.8.2 Basic Digital I/O ....................................................................................... 3-30 3.8.4 Handshake Mode .................................................................................... 3-30 3.8.5 Digital I/O Programming Procedures....................................................... 3-31 Reading a Digital Input Port.................................................................. 3-31 Writing to a Digital Output Port............................................................. 3-31 3.9 Direct Memory Access (DMA) Functions................................................................. 3-32 3.9.1 Basic DMA Information............................................................................ 3-32 Hardware Specific Notes ...................................................................... 3-32 3.9.2 Planning a DMA Process......................................................................... 3-33 The DMA Transfer List: I/O Channels and Types ................................ 3-33 Valid I/O Channels/Types ..................................................................... 3-33 Pacers, Start/Stop Modes and Triggers ............................................... 3-34 Analog Input ......................................................................................... 3-35 Mixed I/O Types ................................................................................... 3-36 Start/Stop Modes and Triggers............................................................. 3-36 Start on Command - Stop on Trigger after delay (also known as Trigger Mode) ...................................................... 3-37 Figure 3.3 Trigger Mode ...................................................................... 3-38 Figure 3.4 Operation of a Circular Buffer ............................................ 3-39 Start on Command, Stop on Terminal Count ....................................... 3-40 Start on Trigger after delay, Stop on Command................................... 3-40 Start on Trigger (no delay), Stop on Terminal Count............................ 3-40 Start on Trigger (no delay), Stop on Command .................................. 3-40 Start on Command, Stop on Command ............................................... 3-40 Determining the Amount of Data, and Creating a Buffer...................... 3-41 Allocating the Buffer ............................................................................. 3-42 Storing and Retrieving Data ................................................................. 3-42 3.9.3 General DMA Programming Procedures................................................. 3-44 3.10 Interrupts ............................................................................................................... 3-47 3.10.1 Software Interrupt Programming Procedures......................................... 3-47 3.11 Rate Generator ...................................................................................................... 3-48 3.11.1 Rate Generator Modes and Operation ................................................... 3-48 Figure 3.5 Pulse and Square Wave Output Waveforms ..................... 3-49 3.11.2 PCI-20377W and PCI-20428W 16-Bit Rate Generator Mode............... 3-50 Figure 3.6 16-Bit Mode Pulse and Square Wave Output Waveforms 3-51 3.11.3 Routing the Generator's Output............................................................. 3-51 3.11.4 Rate Generator Programming Procedures............................................ 3-52 3.12 Synchronization Bus .............................................................................................. 3-53 3.12.1 Connection Pairs .................................................................................... 3-53 3.12.2 Notes on Specifying SYNCConfigure's slot and module Parameters ... 3-53 3.12.3 Source/Target Types ............................................................................. 3-54 3.12.4 Source Types ........................................................................................ 3-54 3.12.5 Target Types ......................................................................................... 3-55 3.12.6 SYNC Bus Programming Procedures ................................................... 3-57 3.13 Thermocouple Measurement ................................................................................ 3-58 3.13.1 Standard Thermocouple Inputs ............................................................. 3-58 TCLinearize .......................................................................................... 3-58 TCMeasure........................................................................................... 3-58 3.13.3 Using PCI-5B37 Thermocouple Signal-Conditioning Blocks ................. 3-59 TCLinearize .......................................................................................... 3-59 TCMeasure........................................................................................... 3-59 3.13.4 Thermocouple Measurement Programming Procedures ...................... 3-59 Thermocouple Data Conversion With TCLinearize.............................. 3-59 Thermocouple Measurement Using TCMeasure ................................. 3-60 3.14 Trigger Operations................................................................................................. 3-61 3.14.1 Operational Information ......................................................................... 3-61 3.14.2 Analog Trigger Programming Procedures............................................. 3-61 v Table of Contents Chapter 4: Master Link Software Libraries Function Call Reference 4.1 General Information ..................................................................................................4-1 4.2 General Description and Preliminary Notes .............................................................4-2 4.2.1 Call Format...............................................................................................4-2 4.2.2 Common Call Parameters and Data Types .............................................4-2 The Slot Parameter...............................................................................4-3 The Module Parameter .........................................................................4-3 The Channel/Port Parameters ..............................................................4-3 Data Types............................................................................................4-4 Analog Input/Output Data Format .........................................................4-4 4.3 System Configuration Summary ..............................................................................4-6 4.4 Function Call Summary............................................................................................4-7 4.5 Function Call Specifications .....................................................................................4-10 4.5.1 Analog Input Function Calls .....................................................................4-13 AICalibrate ............................................................................................4-14 AICalibrate364 ......................................................................................4-15 AICalibrationStatus ...............................................................................4-16 AIConfigureList......................................................................................4-17 AIRead ..................................................................................................4-20 AIReadExtended ...................................................................................4-22 AISetTime .............................................................................................4-23 SSHReadGroup ....................................................................................4-24 4.5.2 Analog Output Function Calls ..................................................................4-27 AOConfigure .........................................................................................4-27 AOWrite ................................................................................................4-28 AOWriteGroup ......................................................................................4-29 4.5.3 Buffer Management Function Calls..........................................................4-31 BUFAllocate ..........................................................................................4-32 BUFAttachProcess................................................................................4-34 BUFDeallocate ......................................................................................4-36 BUFDecode...........................................................................................4-37 BUFEncode...........................................................................................4-38 BUFMoveIn ...........................................................................................4-40 BUFMoveOut ........................................................................................4-41 BUFSeek...............................................................................................4-42 4.5.4 Burst Generator Function Calls................................................................4-43 BGConfigure .........................................................................................4-43 BGDisable .............................................................................................4-45 BGEnable..............................................................................................4-45 BGSetOptions .......................................................................................4-45 4.5.5 Counters...................................................................................................4-47 CTRConfigure .......................................................................................4-48 CTRDisable...........................................................................................4-50 CTREnable............................................................................................4-50 CTRMeasure.........................................................................................4-51 CTRRead ..............................................................................................4-52 CTRReadGroup ....................................................................................4-52 CTRSetOptions .....................................................................................4-53 4.5.6 Counters, 8254-Based .............................................................................4-56 CTR8254Configure ...............................................................................4-57 CTR8254Disable...................................................................................4-59 CTR8254Enable....................................................................................4-60 CTR8254Measure.................................................................................4-60 CTR8254Read ......................................................................................4-62 vi Table of Contents CTR8254ReadGroup............................................................................ 4-63 4.5.7 Digital Input/Output .................................................................................. 4-64 DIOConfigure........................................................................................ 4-65 DIORead............................................................................................... 4-66 DIOReadBit .......................................................................................... 4-67 DIOStatus ............................................................................................. 4-67 DIOWrite............................................................................................... 4-68 DIOWriteBit .......................................................................................... 4-68 4.5.8 Direct Memory Access (DMA) Calls ........................................................ 4-70 DMAConfigureList ................................................................................ 4-71 DMAFreeHandle................................................................................... 4-77 DMAGetHandle .................................................................................... 4-78 DMAHugeGetHandle............................................................................ 4-78 DMASetOptions.................................................................................... 4-78 DMASetPacer....................................................................................... 4-79 DMASetTrigger..................................................................................... 4-80 DMAStart .............................................................................................. 4-81 DMAStatus ........................................................................................... 4-82 DMAStop .............................................................................................. 4-83 DMASwap............................................................................................. 4-83 4.5.9 Initialization Calls ..................................................................................... 4-85 HWInit................................................................................................... 4-87 RegisterClient ....................................................................................... 4-87 SWInit................................................................................................... 4-88 SWReset .............................................................................................. 4-88 SlotAssign............................................................................................. 4-88 SlotAssignIO......................................................................................... 4-89 SlotInquire ............................................................................................ 4-89 SlotSearchEISA.................................................................................... 4-92 SlotSearchISA ...................................................................................... 4-92 SlotSearchIO ........................................................................................ 4-93 UnregisterClient.................................................................................... 4-93 IncludeXXXX ........................................................................................ 4-94 4.5.10 Interrupt Function Calls ......................................................................... 4-99 SoftInt ................................................................................................... 4-99 4.5.11 Rate Generator Function Calls .............................................................. 4-100 RGConfigure......................................................................................... 4-100 RGDisable ............................................................................................ 4-103 RGEnable ............................................................................................. 4-103 4.5.12 Synchronization Bus .............................................................................. 4-104 SYNCConfigure .................................................................................... 4-104 4.5.13 Thermocouple Measurement ................................................................ 4-109 TCLinearize .......................................................................................... 4-109 TCMeasure........................................................................................... 4-110 4.5.14 Trigger/Alarm Calls................................................................................ 4-113 TRIGConfigure ..................................................................................... 4-113 TRIGDisable ......................................................................................... 4-114 TRIGEnable.......................................................................................... 4-115 TRIGStatus........................................................................................... 4-115 4.5.15 Other Functions ..................................................................................... 4-117 SetOptions98........................................................................................ 4-117 SetOptions364...................................................................................... 4-118 SetOptions377...................................................................................... 4-119 4.5.16 Utility Functions ..................................................................................... 4-120 CountsToVolts ...................................................................................... 4-120 ExtendedCountsToVolts....................................................................... 4-121 FrequencyToRGCounts........................................................................ 4-122 vii Table of Contents VoltsToCounts ......................................................................................4-122 Appendix A: Sample Program Descriptions A.1 DOS Based Sample Programs................................................................................A-1 A.1.1 Analog Input.............................................................................................A-1 A.1.2 Analog Output..........................................................................................A-2 A.1.3 Burst Generator .......................................................................................A-3 A.1.4 Counters, 8254-Based.............................................................................A-4 A.1.5 Counters ...................................................................................................A-4 A.1.6 Digital Input/Output ...................................................................................A-5 A.1.7 General Purpose DMA..............................................................................A-6 A.1.8 Rate Generator .........................................................................................A-6 A.1.9 Simultaneous Sample/Hold .....................................................................A-7 A.1.10 Thermocouple Measurement.................................................................A-7 A.1.11 Analog Trigger .......................................................................................A-8 A.2 Microsoft Windows 3.x Based Sample Programs................................................A-9 A.2.1 Analog Input.............................................................................................A-9 A.2.2 Analog Output..........................................................................................A-10 A.2.3 Digital Input/Output ..................................................................................A-11 A.2.4 Signal Measurement................................................................................A-11 A.3 Win32 Based Sample Programs .............................................................................A-12 A.3.1 Analog Input.............................................................................................A-12 A.2.2 Analog Output..........................................................................................A-13 A.2.3 Digital Input/Output ..................................................................................A-14 A.2.4 Signal Measurement................................................................................A-14 Appendix B: Memory Manager, DMA Device Driver, Initialization Options and Interrupt Notes B.1 Memory Manager Notes for DOS and Windows 3.x................................................B-1 B.1.1 386MAX................................................................................................B-1 B.1.2 EMM386 ..................................................................................................B-1 B.1.3 QEMM ..................................................................................................B-2 B.1.4 EMMExclude Notes .................................................................................B-2 B.2 Notes or Performing DMA in Windows ....................................................................B-3 B.2.1 Windows 3.x and DMA ............................................................................B-3 B.2.2 Windows 95 and DMA ...........................................................................B-3 16-bit DMA Applications........................................................................B-3 32-bit DMA Applications........................................................................B-4 B.2.3 Windows NT and DMA.........................................................................B-4 B.3 Initialization Options.................................................................................................B-4 B.4 Interrupts and Segment Locking (Windows 3.x only) ..............................................B-5 Index viii Chapter 1: Introduction Chapter 1: Introduction 1.1 About this Manual This manual is a guide to using your PCI-20369S and PCI-20485S Master Link Software Libraries. PCI-20369S provides software support for the DOS and Microsoft Windows 3.x environments. PCI-20485S provides software support for Win32 operating systems (i.e. Windows 95, Windows NT, etc). Chapter 1 contains an introduction and overview of the products. Chapter 2 will get you started with installation instructions, brief descriptions of the Master Link files, and general instructions for compiling and linking a program. Chapter 3 discusses how the various function call groups are organized, and what general programming sequences should be followed to implement a particular function. Chapter 4 is a reference guide to the software instructions, or calls, providing all the details you might need for using the software calls most effectively. Appendix A describes and lists the sample programs we have provided for maximum use of your software; we have tried to include most common needs in these programs. Appendix B contains important notes on DMA operations, memory manager usage and software initialization options. Note: A list of all error codes, in numerical order, that may be reported by the software is provided in the ERRORS.TXT file which is copied onto your hard drive when you install any of the software packages. 1.2 The Master Link Software Libraries The Master Link Software Libraries provide an uncomplicated, consistent, and useful interface between the highlevel language programmer and the PCI-20000 Instrumentation System. They provide high-level language support of the most useful hardware-level functions, while buffering the programmer from the details of running the hardware. In addition, the function call interfaces are identical for DOS, Windows 3.x and Win32 versions of the Software. So you only need to learn one set of calls to write programs in each environment. We believe you will find the Master Link Software Libraries to be a flexible, powerful and useful interface between you and the PCI-20000 Instrumentation System. As an illustration of the simplicity of using Master Link, consider the following example, in C: . . AIRead (slot, module, channel, AZchannel, gain, range, input_config, (int far *) &counts); CountsToVolts (counts, gain, range, &volts); . . The top program line shows a driver function call which configures and reads an analog input channel, returning the data value in "counts" (an integer). The second line calls another driver function that converts the returned counts value to a voltage value. Procedures such as these allow you to interface with the hardware in a straightforward and painless way. The parameter variable names we use in our function calls (Chapter 4) are chosen to illustrate the parameter semantics. You may use any variable names which do not conflict with constant or other names defined by the Master Link Software, or with the requirements of your programming language. Chapter 4 covers complete call specifications for the functions provided by the library. All valid function call parameters for supported PCI hardware devices are covered in detail. 1-1 Chapter 1: Introduction 1.3 System Configuration Requirements For DOS based applications your personal computer system can be an XT/AT/286/386/486/Pentium/... or compatible, or an EISA Bus computer, and use IBM-DOS or MS-DOS version 3.1 or higher. If you are programming Windows 3.x based applications, you will also need Microsoft Windows 3.x (version 3.1 or 3.11 is recommended). For Win32 based applications using the Master Link Software Libraries you need to be running a 32-bit operating system (such as Windows 95 or Windows NT 4.0 etc). In addition you will need one or more PCI-20000 Series Carriers, Multifunction Boards, or Single Board products and appropriate I/O Modules for your application. If you wish to use extended memory (above 1 Mbyte) with DOS and Windows 3.x applications with the Master Link Software Libraries, you will also need HIMEM.SYS, QEMMTM, 386MAXTM, 386EMM or a similar extended memory driver. See Appendix B for details on properly configuring your memory manager. 1.3.1 DOS Environment - Programming Language Support To write programs using the Master Link DOS based Software Libraries, you will need one of the supported language compilers listed below: • • • • • Borland C++, 4.5 or higher Microsoft C++, 7.0 or higher Borland Turbo Pascal, 6.0 Borland Pascal, 7.0 Microsoft QuickBASIC, 4.5 Using the Software Libraries with your chosen compiler is discussed in Chapter 2: Getting Started, and the README.TXT file. 1.3.2 Microsoft Windows 3.x Environment - Programming Language Support To write programs using the Master Link Microsoft Windows 3.x based Software Libraries, you will need one of the supported language compilers listed below: • • • • • Borland C++, 4.5 or higher Microsoft C++, 7.0 or higher Microsoft Visual Basic, 4.0 or higher Borland Pascal, 7.0 Borland Turbo Pascal for Windows, 1.5 Using the Software Libraries with your chosen compiler is discussed in Chapter 2: Getting Started, and the READMEW.TXT file. 1.3.3 Win32 Environment - Programming Language Support To write programs using the Master Link Win32 based Software Libraries, you will need one of the supported language compilers listed below: • • • Borland C++, 4.5 or higher Microsoft Visual C++, 4.0 or higher Microsoft Visual Basic, 4.0 or higher Using the Software Libraries with your chosen compiler is discussed in Chapter 2: Getting Started, and the README32.TXT file. 1-2 Chapter 1: Introduction 1.4 The Software License Agreement Read the PROGRAM LICENSE AGREEMENT, printed on the envelope containing the Master Link Software Libraries diskettes, and make sure you fully understand it. If you have any questions, contact your sales representative before continuing. 1-3 Chapter 1: Introduction This page intentionally left blank 1-4 Chapter 2: Getting Started Chapter 2: Getting Started 2.1 Introduction All the Software Libraries and interface files for communicating with the various compilers supported, as well as a variety of sample programs are contained on the supplied Master Link disks in compressed form. Use of the Libraries consists of installing the libraries and interface files for your compiler, and making the necessary connections between the interface files and your application program. The remainder of Chapter 2 is divided into the following topics. Section 2.2 provides information on installing the PCI-20369S DOS based Software Library files. Section 2.3 lists and briefly describes the PCI-20369S DOS based Software Libraries. Section 2.4 summarizes how the Libraries are used. Sections 2.5, 2.6 and 2.7 cover the same topics for the Microsoft Windows 3.x compatible PCI-20369S Libraries. Sections 2.8, 2.9 and 2.10 cover the same topics for the Win32 PCI-20485S Master Link Libraries. 2.2 Installing the DOS Based Libraries First, make back-up copies of the distribution diskettes - and store the originals in a safe place. Never use the original masters for everyday purposes. The DOS based Software Libraries are compressed onto the PCI-20369S DOS support diskettes. To install the software onto a hard disk, or other drive, you need to run the SETUP.EXE program. Note: If you are running Windows of any type you must first exit Windows to DOS before installing the DOS support Libraries. To run SETUP, follow these steps: [1] Place the first PCI-20369S Master Link Software Libraries DOS version diskette in an available 3.25” floppy drive on your system. [2] If you placed the diskette in drive A: (for example), run SETUP, from the DOS prompt by typing: A:\SETUP<ENTER> Note, if your current drive is the drive holding the installation disk, you can start the SETUP program, just by typing: SETUP<ENTER> After you have pressed <ENTER>, the SETUP program will open with a welcome message, press a key to start the installation process. (You may exit the SETUP program by pressing the CTRL and X keys at the same time.) [3] The SETUP program will first ask you what supported language versions of the Libraries you want to install. Use the <Space Bar> and arrow keys to select the language(s) support you wish to install (C/C++, BASIC, Pascal), then press <ENTER>. [4] Next, SETUP asks onto which of your available drives would you like the Library files to be transferred. Press the letter of the drive or use the arrow keys to select the drive. After you select a drive, and press <ENTER>, you will have the option to specify a "Base Directory" under which various subdirectories will be created, and filled with appropriate files (depending on the language support you have chosen). Unless you specify otherwise, the default "Base Directory" is located on the selected drive and given the name PCIMASTR. After deciding on a directory, press <ENTER> to start the extraction and transfer process. Note: Installation of all supported language files requires about 4.7 Mbytes of disk space. 2-1 Chapter 2: Getting Started [5] When all files have been transferred, you will be asked if you want to examine the README document. Please read this file by responding "Y". The README file contains important information on the version of Master Link software you have just installed. When you examine the contents of the extracted Master Link DOS based Software Libraries, you will find that compiler specific files are located in separate subdirectories. These and all other files are described in Section 2.3. 2.3 DOS Based Library Files Support for all specified compilers, along with sample programs in each language are supplied with the software package. This section lists and briefly describes the files provided with the software package. Use of the Library functions is discussed in the following chapters. First, in the "Base Directory" (i.e. \PCIMASTR) there are at least two text files; README.TXT and ERRORS.TXT. Additional text files, if present, contain information that is too recent to appear in this manual. Any of these files may be read by typing TYPE filename at the DOS prompt, or through any ASCII text editing program. The README.TXT file contains important information for using the Master Link Software Libraries with all supported DOS compilers. Always be sure be examine the README file for the latest information before compiling and linking any program. The ERRORS.TXT file contains a listing, in numerical order, of all reported error and warning codes. Names and descriptions of each error or warning code are also provided. This file is useful as a quick disk-based reference source for error information, or you may want to incorporate portions of this text data into your programs for more descriptive error reporting. Whenever you install any DOS based support library, the Base Directory is created, and loaded with the following files: Base Directory README.TXT ERRORS.TXT TYPEJ.TC TYPEK.TC TYPET.TC TYPEJ5B.TC TYPEK5B.TC TYPET5B.TC See above for a description of this file. See above for a description of this file. Type J thermocouple conversion table used by thermocouple support functions. Type K thermocouple conversion table used by thermocouple support functions. Type T thermocouple conversion table used by thermocouple support functions. Type J thermocouple conversion table for non-linearized 5B thermocouple block support. Type K thermocouple conversion table for non-linearized 5B thermocouple block support. Type T thermocouple conversion table for non-linearized 5B thermocouple block support. The following sections briefly describe the files provided in the Base Subdirectories created when PCI-20369S support for each language is installed. 2.3.1 C Language Software Library Files When the DOS Master Link Software Libraries for C are installed, the following file structure is created: C\INCLUDE PCI.H 2-2 Contains the software function declarations. All program source files that use the constants, type definitions, and functions must include this header file if you are using C. Note: PCI.H includes PCICONS.H and PCTYPE.H. Chapter 2: Getting Started PCICONS.H PCIDATA.H PCIDECL.H PCIDEF.H PCIMEM.H PCITYPE.H Contains the software library constants definitions. Software initialization functions and local data block size header file. PCI-20369S uses its own local data block in the common data segment of the application program. Although you will probably never need to alter this data block size, the size of the data block can be modified if required. The associated source code file, PCIDATA.C, for the local data block size and initialization functions is located in the C\SAMPLE subdirectory. C/C++ compiler support file. C/C++ compiler support file. C/C++ memory allocation support file. Contains the software library variable type definitions. C\LIB PCI_BC.LIB PCI_MC.LIB Library file for Borland C++. Library file for Microsoft C++. C\SAMPLE ?????_C.C ?????.C PCIDATA.C ?????.H Sample program main source code filenames end with _C.C. Utility function source code filenames have no underscore character. Software Initialization Support source code file. PCIDATA.C must be compiled and linked with the application program. Utility function header files. 2.3.2 Turbo Pascal Language Software Library Files When the DOS Master Link Software Libraries for Turbo Pascal are installed, the following file structure is created: PASCAL\INCLUDE PCI.P PCICONS.P PCIDATA.P PCITYPE.P Contains software library function declarations. This file is for reference only; it does not need to be textually included in any source file. Note, PCI.P includes PCICONS.P and PCITYPE.P. Contains software library constants definitions. This file is for reference only; it does not need to be textually included in any source file. Internal software initialization function and local data block size header file. PCI-20369S uses its own local data block in the common data segment of the application program. Although you will probably never need to alter the local data block size, the size of the data block can be modified if required. The associated source code file, PCIDATA.PAS, for the local data block size and initialization functions is located in the PASCAL\SAMPLE subdirectory. Contains the software library variable type definitions. This file is for reference only; it does not need to be textually included in any source file. Note: In Turbo Pascal, the "uses" statement is used to include function support. All *.P files (except PCIDATA.P) are provided in this directory for your reference only. They do not need to be included in any program source files. PASCAL\SAMPLE ?????_P.PAS ?????.PAS PCIDATA.PAS ?????.P Sample program main source code filenames end with _P.PAS Utility function source code filenames have no underscore character. Software Initialization Support source code file. PCIDATA.PAS must be compiled with the application program as well as listed in its “uses” statement.. Utility function interface files. PASCAL\TPU 2-3 Chapter 2: Getting Started I???????.TPU PCI.TPU Turbo Pascal Unit files. Note: These files do not need to be listed in the "uses" statement of the program - they are internally used by PCI.TPU. Main Turbo Pascal Unit file. Add the data unit name (PCIDATA) and main library unit name (PCI) to the "uses" statement in the main program module. Add PCI to the "uses" statement of any other module that uses the library functions, constants, or type definitions. See Section 2.4.1 for a listing of library unit files (.TPU). PASCAL\TPU70 I???????.TPU PCI.TPU Borland Pascal 7.0 Unit files. Note: These files do not need to be listed in the "uses" statement of the program - they are internally used by PCI.TPU. Main Borland Pascal 7.0 Unit file. Add the data unit name (PCIDATA) and main library unit name (PCI) to the "uses" statement in the main program module. Add PCI to the "uses" statement of any other module that uses the library functions, constants, or type definitions. See Section 2.4.1 for a listing of library unit files (.TPU). 2.3.3 Microsoft QuickBASIC Language Software Library Files When the DOS Master Link Software Libraries for QuickBASIC are installed, the following file structure is created: BASIC\INCLUDE PCI.B PCICONS.B PCIDATA.B PCIMEM.B PCITYPE.B Contains function declarations for each function call supported by the Software Library. All QuickBASIC program source files that use the functions must include this header file. Defines the various I/O type codes, gain, range and other constants used by various Software Library function calls. All QuickBASIC program source files that use the constants and functions must include this header file. Internal software initialization function and local data block size header file. PCI-20369S uses its own local data block in the common data segment of the application program. Although you will probably never need to alter the local data block size, the size of the data block can be modified if required. The associated source code file, PCIDATA.BAS, for the local data block size and initialization functions is located in the BASIC\SAMPLE subdirectory. Memory allocation support file. Contains the software library variable type definitions. All QuickBASIC program source files that use the type definitions and functions must include this header file. BASIC\LIB PCI_QB.LIB I?????.LIB Library file for Microsoft QuickBASIC. This library contains all hardware and other function support. Individual hardware and other function support libraries. These libraries can be used to build a custom library with only the functions required by your application. BASIC\SAMPLE ?????_B.BAS ?????.BAS PCIDATA.BAS ?????.B Sample program main source code filenames end with _B.BAS. Utility function source code filenames have no underscore character. Software Initialization Support source code file. PCIDATA.BAS must be compiled and linked with the application program. Utility function header or declaration files. 2.4 Using the DOS Based Software Interface Library 2-4 Chapter 2: Getting Started Each set of interface files; those for C, Turbo Pascal, and QuickBASIC, contains all of the necessary files for the supported compiler(s) for that language. The interface files provide type and constant definitions and function declarations (or interfaces), which allow you to make high-level language calls to the libraries, using your programming language. 2.4.1 Interface Files and Your Program The libraries can be linked with Microsoft C programs compiled for the medium, large, or huge memory model or Borland C programs compiled for all memory models except tiny. Additionally, the libraries can be linked with QuickBASIC and Turbo Pascal programs. C and QuickBASIC For use with C or QuickBASIC, simply link your application program with the compiled code from the Software Initialization Support file (PCIDATA.C or PCIDATA.BAS) and the main library file (PCI_MC.LIB for Microsoft, PCI_BC.LIB for Borland, PCI_QB.LIB for QuickBASIC). The appropriate header file (PCI.H or PCI.B) must be included textually in your application source code. Turbo Pascal For use with Turbo Pascal, add the data unit name (PCIDATA - supplied as a source file) and main library unit name (PCI). For example, the sample program AI_P.PAS (Analog Input) contains the following items in its "uses" statement: . . program AI_P; {$N+,E+} uses CRT, PCI, PCIdata, Config, Name, Err, Find; . . CRT is a unit supplied with Turbo Pascal. The units; Config, Name, Err and Find are utility functions supplied with the Master Link sample programs. PCI and PCIdata are the PCI-20369S main and data units. The following is a list of all supplied Turbo Pascal library units (.TPU files) and when they should be used. Main and Data Units All programs must include these two unit names in the "uses" statement. PCI PCIDATA Main unit. It must be included in all source files that use the software library functions. Software Initialization Support unit. This unit is supplied as a source file, it must be compiled with the application source file(s). This file should only be included ("used") by the main source file. 2-5 Chapter 2: Getting Started PCI-20000 Series I/O Module Support Units These TPU files (units) are used internally by PCI.TPU - you need not reference the unit name(s) in the program's "uses" statement to obtain function support for the particular I/O Module(s). I17M I19M I20M I21M I23M I2M I31M I341M I363M I364M I368M I3M I4M I5M I6M I7M PCI-20017M Simultaneous Sample/Hold Module support unit (this I/O Module is no longer available and has been replaced by the PCI-20363M SSH Module). PCI-20019M High-Speed Analog Input Module support unit. PCI-20020M Trigger/Alarm Module support unit. PCI-20021M 8-Channel Analog Output Module support unit. PCI-20023M High-Speed Analog Input Module support unit. PCI-20002M Analog Input Module support unit. PCI-20031M Analog Input Expander/Sequencer Module support unit. PCI-20341M High-Resolution Analog Input Module support unit. PCI-20363M 8-Channel Simultaneous Sample/Hold Module support unit. PCI-20364M High-Accuracy Analog Input Module support unit. PCI-20368M High-Speed Analog Input Expansion Module support unit. PCI-20003M Analog Output Module support unit. PCI-20004M 32 Channel Digital I/O Module support unit. PCI-20005M Analog Input Expansion Module support unit (this I/O Module is no longer available and has been replaced by the PCI-20031M and PCI-20368M Expansion Modules). PCI-20006M 16-bit Analog Output Module support unit. PCI-20007M Counter/Timer/Rate Generator with Quadrature Decoder support unit. PCI-20000 Series Single Board Product Support Units These TPU files (units) are used internally by PCI.TPU - you need not reference the unit name(s) in the program's "uses" statement to obtain function support for the particular PCI I/O Module(s). I87W I89W I91W I93W I377W I378W I428W PCI-20087W PCI-20089W PCI-20091W PCI-20093W PCI-20377W PCI-20378W PCI-20428W Digital Input/Output Board support unit. Analog Input Board support unit. High-Speed Analog Input Board support unit. Analog Output Board support unit. Low Power Multifunction Board support unit. Series High-Density Digital I/O Boards support unit. Series Multifunction Boards support unit. PCI-20000 Series Boards Supporting PCI I/O Plug-In Function Modules. These TPU files (units) are used internally by PCI.TPU - you need not reference the unit name(s) in the program's "uses" statement to obtain function support for the particular PCI I/O Module(s). I1C I41C I98C I501C PCI-20001C General-Purpose Carrier support unit. PCI-20041C Series High-Performance Carriers support unit. PCI-20098C Series Multifunction Boards support unit. PCI-20501C Series High-Performance EISA Boards support unit. Special Functions Software Support These TPU files (units) are used internally by PCI.TPU - you need not reference the unit name(s) in the program's "uses" statement to obtain special function support. IBUF IDMA ITC Data buffer support unit. Direct Memory Access (DMA) function support unit. Thermocouple function call support unit. Other Pascal Units All other Pascal units not already mentioned are found in the PASCAL\TPU subdirectory. These units are used by the function calls themselves, be sure to include these files in your unit directory. 2-6 Chapter 2: Getting Started Utility Functions Every program using the utility functions supplied with the software must have the corresponding unit name(s) in the program's "uses" statement. These functions are not supplied as library (.TPU) units, however, the source code and headers are provided. You will find the following unit names mentioned throughout in sample program "uses" statements. CONFIG ERR FIND HEX NAME Print hardware configuration utility. General purpose error handing utility. Hardware search utility. Hexadecimal number format utility. Report Intelligent Instrumentation hardware component name utility. 2.4.2 Summary of Steps for Using The DOS Based Interface Files In summary, using the interface files consists of three basic steps: [1] First you must copy the appropriate interface files for your compiler into the location where your compiler will look for these files. This may vary somewhat from compiler to compiler. Consult your compiler documentation for specifics. [2] In the declaration section of your C or QuickBASIC applications program, you must add the appropriate header file to your application. If you are using Turbo Pascal, add the PCIdata unit name and PCI main library unit name to the "uses" statement in the program module (see 2.4.1 under "Turbo Pascal"). [3] For C or QuickBASIC, compile your application program and the PCIDATA file, then link your application program with the interface library. For Turbo Pascal, compile your application source files and the PCIDATA file. Specific information on the various language compilers, including environment notes and command line instructions are provided in the README file. 2-7 Chapter 2: Getting Started 2.5 Installing the Microsoft Windows 3.x Based Software Libraries First, make back-up copies of the distribution diskettes - and store the originals in a safe place. Never use the original masters for every day purposes. The Windows 3.x based Software Libraries are compressed onto the PCI-20369S Microsoft Windows 3.x support diskette. To install the software onto a hard disk, or other drive, you need to run the SETUP.EXE program. To do this, follow these steps: [1] Place the PCI-20369S Master Link Software Libraries for Microsoft Windows 3.x diskette in an available floppy drive on your system. [2] If you placed the diskette in drive A: (for example), run SETUP, by typing the following in the Program Manager File/Run command box: A:\SETUP Click on the “OK” push-button to start the SETUP program. (You may exit the SETUP program by pressing the ESC Key.) The SETUP program will open with a welcome message, click on “OK” to start the installation process. 2-8 [3] As shown below, the SETUP program will first ask you what supported language versions of the Libraries you want to install. To select the language(s) support you wish to install (C/C++, Visual Basic, Pascal), click on the item(s). Click on “OK” when you are done selecting. [4] Next, SETUP asks onto which of your available drives you wish the Library files to be installed. To select a drive, click on the desired drive item, then click on “OK”. Chapter 2: Getting Started [5] Next, you will have the option to specify a "Base Directory" under which various subdirectories will be created, and filled with appropriate files (depending on the language support you have chosen). Unless you specify otherwise, the default "Base Directory" is located on the selected drive and given the name PCIMASTR. After deciding on a directory, click on "OK" or press <ENTER> to start the extraction and transfer process. A status box will appear to inform you of the installation activity. Note: Installation of all supported language files requires about 2 Mbytes of disk space. When all files have been transferred, you will be asked if you want to examine the README document. Please read this file by clicking on "OK" or pressing <ENTER>, as it contains important information on the version of Master Link you have just installed. When you examine the contents of the extracted Software Libraries, you will find that compiler specific files are located in separate subdirectories. These and all other files are described in Section 2.6. 2-9 Chapter 2: Getting Started 2.6 The Microsoft Windows 3.x Based Software Interface Files Support for all compilers, along with sample programs in each language are supplied with the software package. This section lists and briefly describes these files. Use of the Software Libraries functions in application programs is discussed in the following chapters. First, in the "Base Directory" directory (i.e. \PCIMASTR) there are at least two text files; READMEW.TXT and ERRORS.TXT. Additional text files, if present, contain information that is too recent to appear in this manual. Any of these files may be read through any ASCII text editing program. The READMEW.TXT file contains important information for using the Windows 3.x Master Link Software Libraries with all supported compilers. Always be sure be examine the READMEW.TXT file for the latest information before compiling and linking any program. The ERRORS.TXT file contains a listing, in numerical order, of all reported error and warning codes. Names and descriptions of each error or warning code are also provided. This file is useful as a quick disk-based reference source for error information, or you may want to incorporate portions of this text data into your programs for more descriptive error reporting. Whenever you install any Microsoft Windows 3.x based language support library set, the Base Directory is created, and loaded with the following files: Base Directory READMEW.TXT ERRORS.TXT PCIVDMAD.386 See above for a description of this file. See above for a description of this file. Virtual DMA Driver for DMA operations with the Libraries in Windows 3.x. See Appendix B for more information. PCI_WIN.DLL PCI-20369S Windows Based Dynamic Link Library (DLL). TYPEJ.TC Type J thermocouple conversion table used by thermocouple support functions. TYPEK.TC Type K thermocouple conversion table used by thermocouple support functions. TYPET.TC Type T thermocouple conversion table used by thermocouple support functions. TYPEJ5B.TC Type J thermocouple conversion table for non-linearized 5B thermocouple block support. TYPEK5B.TC Type K thermocouple conversion table for non-linearized 5B thermocouple block support. TYPET5B.TC Type T thermocouple conversion table for non-linearized 5B thermocouple block support. MASTRLNK.VXD Hardware Driver support for operations with the Libraries under Windows 95. See Appendix B for more information. This and the VDMAD.VXD file, instead of PCIVDMAD.386, are required for DMA operations if you installed the Libraries on a Windows 95 machine. VDMAD.VXD Virtual DMA Driver support for DMA operations with the Libraries under Windows 95. See Appendix B for more information. The following sections briefly describe the files provided for each language supported by the software package. 2.6.1 Microsoft Visual Basic Language Files VB\INCLUDE PCICONSW.B PCIDATAW.B 2-10 Defines constants used by various Software function calls. All Visual Basic application programs must merge this file into the main global module. Internal software initialization function and local data block size header file. Master Link uses its own local data block in the common data segment of the application program. Although you will probably never need to alter the local data block size, the size of the data block can be modified if required. All Visual Basic application programs must merge this file into the main global module. The associated source code file, PCIDATAW.BAS, for the local data block size and initialization functions is located in the VB\SAMPLE subdirectory. Chapter 2: Getting Started PCITYPEW.B PCIW.B Visual Basic Software Library type definitions. All Visual Basic application programs must merge this file into the main global module. Contains function declarations for each function call supported by the Software Library. All Visual Basic application programs must merge this file into the main global module. VB\SAMPLE ?????G.BAS ?????W.BAS PCIDATAW.BAS Sample program global modules. Sample program utility modules. Visual Basic Software Initialization Support source code file. PCIDATAW.BAS must be linked in the application make file. ?????_BW.FRM Sample program forms. ?????_BW.MAK Sample program make files. 2.6.2 C Language Software Files CW\INCLUDE PCICONSW.H PCIDATAW.H PCIDECLW.H PCIDEFW.H PCITYPEW.H PCIW.H Contains the software library constants definitions. Software initialization functions and local data block size header file. Master Link uses its own local data block in the common data segment of the application program. Although you will probably never need to alter this data block size, the size of the data block can be modified if required. The associated source code file, PCIDATAW.C, for initialization functions is located in the CW\SAMPLE subdirectory. C/C++ compiler support file. C/C++ compiler support file. Contains the software library variable type definitions. Contains the software function declarations. All program source files that use the constants, type definitions, and functions must include this header file. Note, PCIW.H includes PCICONSW.H and PCITYPEW.H. CW\LIB IPCI_WIN.LIB Import library file. This library file must be linked with the application program. CW\SAMPLE ?????_CW.C ?????W.C PCIDATAW.C ?????_CW.DEF ?????_CW.H ?????W.H ?????.ICO ?????_CW.RC C Sample program main source code files. C Sample utility function source code files. Software Initialization Support source code file. PCIDATAW.C must be compiled and linked with the application program. C Sample program module definition files. C Sample program header files. Contains control IDs for the resource and main program files. C Sample utility function header files. C Sample program icon files. C Sample resource files. 2-11 Chapter 2: Getting Started 2.6.3 Pascal Language Software Files PASCALW\INCLUDE PCICONSW.P PCIDATA.P PCITYPEW.P PCIW.P Contains software library constants definitions. This file is for reference only; it does not need to be textually included in any source file. Internal software initialization function and local data block size header file. Master Link uses its own local data block in the common data segment of the application program. Although you will probably never need to alter the local data block size, the size of the data block can be modified if required. The associated source code file, PCIDATAW.PAS, for the local data block size and initialization functions is located in the PASCALW\SAMPLE subdirectory. Contains the software library variable type definitions. This file is for reference only; it does not need to be textually included in any source file. Contains software function declarations. This file is for reference only; it does not need to be textually included in any source file. Note, PCIW.P includes PCICONSW.P and PCITYPEW.P. Note: In Turbo Pascal, the "uses" statement is used to include function support. All *.P files (except PCIDATA.P) are provided in this directory for your reference only. They do not need to be included in any program source files. PASCALW\SAMPLE ????_PW.H ?????.ICO ???????.P ?????_PW.PAS ????W.PAS PCIDATAW.PAS ?????_PW.RC ?????_PW.RES These files contain the control IDs for the resource files. Pascal Sample program icon files. Pascal Sample utility function header files. Pascal Sample program main source code files. Pascal Sample utility function source code files. Software Initialization Support source code file. PCIDATAW.PAS must be compiled with the application program as well as listed in its “uses” statement.. Pascal Sample program resource files. Pascal Sample compiled resource files. PASCALW\TPU PCIW.TPU Pascal Run Time Library unit file. Every main source code file (????_PW.PAS) must use PCIW. Every utility function source code file that uses the library functions, constants or type definitions must use PCIW. PASCALW\TPU70 PCIW.TPW 2-12 Pascal 7.0 Run Time Library unit file. Every main source code file (????_PW.PAS) must use PCIW. Every utility function source code file that uses the library functions, constants or type definitions must use PCIW. Chapter 2: Getting Started 2.7 Using the Microsoft Windows 3.x Based Software Interface Files Along with the Dynamic Link Library (PCI_WIN.DLL) and other files in the "Base Directory", each set of files; those for C, Turbo Pascal, and Visual Basic, contains all of the necessary files for the supported compiler(s) for that language. The interface files provide type and constant definitions and function declarations which allow you to make highlevel language calls to the libraries, using your programming language. 2.7.1 The Master Link Dynamic Link Library The Dynamic Link Library (PCI_WIN.DLL) must be made available to Microsoft Windows and your application program, by installing it in the working directory of your application program, or by specifying its location in the "PATH" environment variable, or in the WINDOWS directory. The DLL is not "compiled" with the application, rather it is accessed by the application program during execution. In general, this interface is achieved in one of several ways depending on the programming language: For C applications, the C Import Library file IPCI_WIN.LIB must be linked with the application program. For Pascal applications, the Pascal Run Time Library unit file, PCIW.TPU, must be included in the "uses" statement of the application program. For Visual Basic, linkage to the PCI_WIN.DLL is achieved through the PCIW.B function declarations “Lib” statement. All Visual Basic application programs must merge this file into the main global module. 2.7.2 Other Interface Files and Your Program Master Link uses its own local data block in the common data segment of the application program. The default size of the local data block is 4 kbytes. The source code for this module is provided (in the language specific SAMPLE subdirectories) so that the size of the data block can be modified, if needed. The source file names are PCIDATAW.C for C, PCIDATAW.PAS for Turbo Pascal, and PCIDATAW.BAS for Visual Basic. This module must be compiled and linked with the application program. Compiler specific environment notes, command lines (when applicable) and programming notes are provided in the READMEW file. 2.7.3 Programming Language Notes Visual Basic There are three important steps to creating and running programs in the Visual Basic environment when using the Master Link Software Libraries for Windows 3.x: First, you must install the dynamic link library, PCI_WIN.DLL, either in the PATH or in the directory which will be current when your Visual Basic program runs, or in the WINDOWS directory. The second step is merging the global PCI constants into the global module of your Visual Basic program. Note, this step has already been performed for the sample programs. The third step is ensuring that the software is initialized before any I/O calls are attempted. The sample programs assure that this is the case by calling a separate subroutine called InitRoutine. 2-13 Chapter 2: Getting Started Additional details on the above procedures are provided in the READMEW file. C The C Import Library, IPCI_WIN.LIB, must be linked with Microsoft C++ and Borland C++ for Windows programs compiled for the small, compact, medium, or large memory models. Creating C executable programs entails: Adding the CW\INCLUDE directory to the Include Search Path of your compiler. Making a project file with the following items: All application source files (*.C files) The PCIDATAW.C source code file The IPCI_WIN.LIB import library Your application's definition file (.DEF file). Your application's resource definition file (.RC file). Compiling and linking the files. Additional details on the above procedures are provided in the READMEW file. Turbo Pascal for Windows The basic steps for creating Pascal executables are: Add the PASCALW\INCLUDE directory to the Include directories of your compiler. Add the Pascal unit (PASCALW\TPU or PASCALW\TPU70) and PASCALW\SAMPLE directories to the Unit and Include directories of your compiler. Compile the application source files. Additional details on the above procedures are provided in the READMEW file. 2-14 Chapter 2: Getting Started 2.8 Installing the Win32 Based Software Libraries First, make back-up copies of the distribution diskettes - and store the originals in a safe place. Never use the original masters for every day purposes. The Win32 based Software Libraries are compressed onto the PCI-20485S Master Link Win32 support diskette. To install the software onto a hard disk, you need to run the SETUP.EXE program. To do this, follow these steps: [1] Place the Master Link for Win32 diskette in an available floppy drive on your system. [2] If you placed the diskette in drive A: (for example), run SETUP, by typing the following after clicking on the “Start” button and selecting Run… A:\SETUP.EXE Click on the “OK” push-button to start the SETUP program. (You may exit the SETUP program by clicking the “Cancel” button or pressing the <ESC> Key.) The SETUP program will open with a welcome message, recommending that you exit all Windows programs before running setup. If you have other programs running, click “Cancel” to quit SETUP and close any other programs. When you are ready, click on “Next” to continue. [3] After selecting “Next”, you will be asked if you want to examine the README32 document now. Please read this file as it contains important information on the version of Master Link software you are about to install. When you are ready, click “Next” to continue. [4] Next, enter your name and organization name in the entry boxes provided. When you are done typing this information, click “Next” to continue. [5] As shown below, the SETUP program will ask you what type of setup you prefer. Select “Typical”. The other options are for replacing damaged files or for installing a particular configuration. You will also be able select the destination directory for your installation files or accept the default destination directory “Master Link 3.0”. When you are ready, click “Next” to continue. 2-15 Chapter 2: Getting Started [6] 2-16 Now select the program folder for the Master Link drivers. Select “Next” to accept the default “Master Link” folder. To select an existing folder click on the folder’s name in the “Exiting Folders” selection box. When you are ready, click “Next” to continue. Chapter 2: Getting Started [7] The next installation option allows to select the driver support you want installed. If you will be using Windows 95 and creating applications that require DMA data transfer to and from data acquisition hardware and memory, click on “Select All”. Note: For Windows NT systems the “Virtual DMA Device Driver” is not required for DMA applications and does not need to be installed. If you will not require DMA, you may only select the “Master Link Device Driver”- installation of this driver is required in order to access hardware. If you later require DMA under Windows 95 and did not install the “Virtual DMA Device Driver” option, you will need to run SETUP again and install the option. (Note: Appendix B of this manual has additional information on the DMA driver.) When you are ready, click “Next” to continue. [8] Before file installation is started, you will be given a chance to review the current settings. Use the “Back” then “Next” buttons to locate the appropriate entry dialog if you need to change any settings. Click the “Next” button in this dialog to begin installation. A status box will appear to inform you of the installation activity. Note: Installation of all supported language files requires about 1.2 Mbytes of disk space. [9] When installation is complete, you must restart your computer before using Master Link. Select the an option (restart or restart computer later) and click the “Finish” button. This completes installation of the Master Link 3.0 for Win32 Software Libraries. 2-17 Chapter 2: Getting Started When you examine the contents of the extracted Software Libraries, you will find that compiler specific files are located in separate subdirectories. These and all other files are described in Section 2.9. 2.9 The Win32 Based Software Interface Files Support for all compilers, along with sample programs in each language, is supplied with the Master Link for Win32 Software Libraries. This section lists and briefly describes these files. Use of the Software Libraries functions in application programs is discussed in the following chapters. First, in the "Base Directory" directory (i.e. \Master Link 3.0) there are at least two text files; README32.TXT and ERRORS.TXT. Additional text files, if present, contain information that is too recent to appear in this manual. Any of these files may be read through any ASCII text editing program. The README32.TXT file contains important information for using the Master Link Win32 Based Software Libraries. Always be sure be examine the README32.TXT file for the latest information before compiling and linking any program. The ERRORS.TXT file contains a listing, in numerical order, of all reported error and warning codes. Names and descriptions of each error or warning code are also provided. This file is useful as a quick disk-based reference source for error information, or you may want to incorporate portions of this text data into your programs for more descriptive error reporting. 2-18 Chapter 2: Getting Started Whenever you install Master Link Win32 based language support, the Base Directory is created, and loaded with the following files: Base Directory README32.TXT ERRORS.TXT PCI_W32.DLL TYPEJ.TC TYPEK.TC TYPET.TC TYPEJ5B.TC TYPEK5B.TC TYPET5B.TC See above for a description of this file. See above for a description of this file. PCI-20485S Win32 Based Dynamic Link Library (DLL). Type J thermocouple conversion table used by thermocouple support functions. Type K thermocouple conversion table used by thermocouple support functions. Type T thermocouple conversion table used by thermocouple support functions. Type J thermocouple conversion table for non-linearized 5B thermocouple block support. Type K thermocouple conversion table for non-linearized 5B thermocouple block support. Type T thermocouple conversion table for non-linearized 5B thermocouple block support. If selected at installation time, the following driver files are installed in the directories indicated below. For Windows 95 Systems: WINDOWS\SYSTEM MASTRLNK.VXD Hardware Driver support for operations with the Libraries under Windows 95. See Appendix B for more information. This and the VDMAD.VXD file are required for DMA operations if you installed the Libraries on a Windows 95 machine. WINDOWS\SYSTEM\VMM32 VDMAD.VXD Virtual DMA Driver support for DMA operations with the Libraries under Windows 95. See Appendix B for more information. For Windows NT Systems: WINNT\SYSTEM32\DRIVERS MASTER_NT.SYS Master Link Windows NT hardware driver with DMA support. The following sections briefly describe the files provided for each language supported by the software package. 2.9.1 C Language Software Files CW32\INCLUDE PCICONSW.H PCIDATAW.H PCIDECLW.H PCIDEFW.H PCITYPEW.H PCIW.H Contains the software library constants definitions. Software initialization functions and local data block size header file. Master Link uses its own local data block in the common data segment of the application program. Although you will probably never need to alter this data block size, the size of the data block can be modified if required. The associated source code file, PCIDATAW.C, for initialization functions is located in the CW32\SAMPLE subdirectory. C/C++ compiler support file. C/C++ compiler support file. Contains the software library variable type definitions. Contains the software function declarations. All program source files that use the constants, type definitions, and functions must include this header file. Note, PCIW.H includes PCICONSW.H and PCITYPEW.H. CW32\LIB IPCI_W32.LIB Import library file for Borland C++. This library file must be linked with the application program. 2-19 Chapter 2: Getting Started IPCI_W3V.LIB Import library file for Microsoft Visual C++. This library file must be linked with the application program. CW32\SAMPLE ?????_CW.C ?????W.C PCIDATAW.C ?????_CW.DEF ?????_CW.H ?????W.H ?????.ICO ?????_CW.RC C Sample program main source code files. C Sample utility function source code files. Software Initialization Support source code file. PCIDATAW.C must be compiled and linked with the application program. C Sample program module definition files. C Sample program header files. Contains control IDs for the resource and main program files. C Sample utility function header files. C Sample program icon files. C Sample resource files. 2.9.2 Microsoft Visual Basic Language Files VB32\INCLUDE PCICONSW.B PCIDATAW.B PCITYPEW.B PCIW.B Defines constants used by various Software function calls. All Visual Basic application programs must merge this file into the main global module. Software initialization function and local data block size header file. Master Link uses its own local data block in the common data segment of the application program. Although you will probably never need to alter the local data block size, the size of the data block can be modified if required. All Visual Basic application programs must merge this file into the main global module. The associated source code file, PCIDATAW.BAS, for the local data block size and initialization functions is located in the VB32\SAMPLE subdirectory. Visual Basic Software Library type definitions. All Visual Basic application programs must merge this file into the main global module. Contains function declarations for each function call supported by the Software Library. All Visual Basic application programs must merge this file into the main global module. VB32\SAMPLE ?????G.BAS ?????W.BAS PCIDATAW.BAS Sample program global modules. Sample program utility modules. Visual Basic Software Initialization Support source code file. PCIDATAW.BAS must be linked in the application make file. ?????_BW.FRM Sample program forms. ?????_BW.MAK Sample program make files. 2-20 Chapter 2: Getting Started 2.10 Using the Win32 Based Software Interface Files Along with the Dynamic Link Library (PCI_W32.DLL) and other files in the "Base Directory", each set of files contains all of the necessary files for the supported compiler(s). The interface files provide type and constant definitions and function declarations which allow you to make high-level language calls to the libraries, using your programming language. 2.10.1 The Master Link Win32 Dynamic Link Library The Win32 Dynamic Link Library (PCI_W32.DLL) must be made available to Windows 95 or Windows NT and your application program, by installing it in the working directory of your application program, or by specifying its location in the "PATH" environment variable, or in the WINDOWS directory. The DLL is not "compiled" with the application, rather it is accessed by the application program during execution. In general, this interface is achieved in one of several ways depending on the programming language: For C applications, the C Import Library file IPCI_W32.LIB or IPCI_W3V.DLL must be linked with the application program. For Visual Basic, linkage to the PCI_W32.DLL is achieved through the PCIW.B function declarations “Lib” statement. All Visual Basic application programs must merge this file into the main global module. 2.10.2 Other Interface Files and Your Program Master Link uses its own local data block in the common data segment of the application program. The default size of the local data block is 4 kbytes. The source code for this module is provided in the SAMPLE subdirectories so that the size of the data block can be modified, if needed. The source file names are PCIDATAW.C for C and PCIDATAW.BAS for Visual Basic. This module must be compiled and linked with the application program. 2.10.3 Programming Language Notes C The IPCI_WV.LIB import library must be linked with Microsoft Visual C++ programs, while the IPCI_W32.LIB import library must be linked with Borland C++ programs. Creating C executable programs entails: Adding the CW32\INCLUDE directory to the Include Search Path of your compiler. Making a project file with the following items: All application source files (*.C files) The PCIDATAW.C source code file The IPCI_W32.LIB or IPCI_W3V.LIB import library Your application's definition file (.DEF file). Your application's resource definition file (.RC file). Compiling and linking the files. Visual Basic 2-21 Chapter 2: Getting Started There are two steps to creating and running programs in the Microsoft Visual Basic environment when using the Master Link Software Libraries for Win32: First, you must install the dynamic link library, PCI_W32.DLL, either in the PATH or in the directory which will be current when your Visual Basic program runs, or in the WINDOWS directory. The next step is ensuring that the software is initialized before any I/O calls are attempted. The sample programs assure that this is the case by calling a separate subroutine called InitRoutine. 2.11 Communicating With the Libraries For DOS, Microsoft Windows 3.x or Win32 applications, communication with the Software Libraries is accomplished by making simple function calls to the interface library as demonstrated in Section 1.2, Chapter 1. Before you begin to work on your own application programs in any of the supported languages, you may wish to try out some of the Sample Programs to familiarize yourself with the system, and the operation of the Software Libraries. A complete description of each of the referenced calls, including, syntax, and information on valid parameter values, is provided in Chapter 4, Section 4.5. A complete listing of all software error codes is provided in the ERRORS.TXT file. Note: For the purpose of consistency, the syntax for all software call specifications is presented in a generic C function prototype format. Type differences and differences in record structures may exist between C and your chosen programming language. Language-specific information is provided at the beginning of each function call group in Chapter 4 in order for you to translate parameters into formats appropriate to your application program and the compiler you are using. Chapter 3 describes, in general, how the calls in the various functional call groups should be sequenced in an application program to perform a specific task. 2-22 Chapter 3: General Programming Procedures Chapter 3: General Programming Procedures This chapter covers general programming procedures, starting with an overview of the Software's functional call groups and fundamental call structure. Subsequent chapter sections discuss basic programming procedures for each function area. Step by step guidelines and relevant function calls are listed for each programming topic. 3.1 Function Categories and General Call Structure The information in this section introduces you to the Master Link Software Library's functional groups, and common function call features. 3.1.1 Function Call Groups The Master Link Software Libraries are organized into functional groups directly related to specific hardware control and data acquisition tasks. Therefore, there is relatively little interdependence between functional call groups - in many cases a single function call is all that is required to perform the desired operation. Each of the functional categories supported by Master Link is summarized below in alphabetical order. ANALOG INPUT This group supports acquisition of single channel analog input data, A/D calibration, reading of Simultaneous Sample/Hold channels, and configuration of multiple channel analog input DMA data transfer. ANALOG OUTPUT This call group allows you to output analog voltage levels using Intelligent Instrumentation Analog Output Modules and Boards. Calls are provided to configure output ranges, create a desired level on a single analog output channel, or simultaneously output different levels on a group of output channels. BUFFER Data buffer support functions are provided for allocating memory areas for DMA transfer processes, formatting input and output data, and locating specific data blocks within data buffers. Both conventional and extended memory data buffers are supported (see Section 1.3 System Configuration Requirements, Chapter 1 for required extended memory drivers). BURST GENERATOR Burst Generator calls enable you to set operating parameters for Burst Generator devices and enable or disable burst generator outputs. Burst Generator circuits produce groups (bursts) of pulses which are typically used to control successive A/D conversions on Intelligent Instrumentation Analog Input devices. COUNTERS This call group is used to configure and control counter channels on Multifunction Boards such as the PCI20098C Multifunction Board or PCI-20501C Series High-Performance EISA Boards. COUNTERS, Intel 8254-Based This call group is used to configure and control counter channels based on the Intel 8254 interval timer chip. The PCI-20007M Counter/Timer/Rate Generator Module, PCI-20089W Analog Input Board, PCI-20091W High-Speed Analog Input Board, PCI-20377W Low Power Multifunction Board and PCI-20428W Series Multifunction Boards use these integrated circuits for timing and pulse generation functions. 3-1 Chapter 3: General Programming Procedures DIGITAL INPUT/OUTPUT These calls are used for configuring digital I/O ports, and reading or writing port values. Ports can be configured for input or output directions, and for basic or handshaking modes. DIRECT MEMORY ACCESS (DMA) The DMA call group supports configuration and hardware control functions to perform DMA transfer processes. This call group is used in conjunction with other function call groups to completely specify and execute a DMA transfer. INITIALIZATION These calls are used at the beginning of every program. Initialization calls assign certain operating parameters for the software libraries, define hardware and software support, and set the hardware to a known state. In addition, several functions are provided for performing system configuration inquiries. INTERRUPT One call is currently provided in this group for generating a software interrupt signal (pulse) on a specified hardware Synchronization Bus line. OTHER FUNCTIONS Additional functions are supplied with the Software Libraries to control specialized options on the PCI-20098C Multifunction Board, the PCI-20364M-1 High-Accuracy (12/16/18-bit) Analog Input Module, and the PCI20377W Low Power Multifunction Board. RATE GENERATOR Rate Generator function calls are used to configure, enable, and disable Rate Generator channels. Like Burst Generators, Rate Generators are typically used to regulate A/D conversions through controlled pulse generation. SYNCHRONIZATION BUS One function call provides the means to specify routing of synchronization signals within Modules, between Modules, or between Modules and a Board/Carrier via the device's "SYNC Bus". A SYNC Bus is a software programmable set of connections, provided by switches and/or multiplexers on some data acquisition devices. THERMOCOUPLE MEASUREMENT Two function calls are provided in this category. One to convert voltage data from a thermocouple channel to a temperature, and another to perform a temperature measurement from analog input channels connected to a thermocouple, cold-junction reference and zero reference. TRIGGER/ALARM These calls are used to configure a PCI-20020M Analog Trigger/Alarm Module for specific high and low thresholds, a triggering mode, and provide the ability to enable or disable a trigger channel. 3-2 Chapter 3: General Programming Procedures 3.1.2 Call Structure Master Link Software Libraries function calls have several common features you need to become familiar with. 1. For verification purposes, ALL functions return an integer value which represents an error code. If the operation performed by the function was completely successful, the returned value will be 0 (zero). If an error occurred, a positive (>0) error code value will be returned. If a function informs you of some possible, but not definite error condition, it may return a negative (<0) warning code value. For your reference, all error and warning codes and their meanings are listed in ERRORS.TXT file installed with the software.. 2. Several common parameters appear in most function calls. These are the slot, module position number, and channel or port (in the case of digital I/O) to which the call is directed. Slot refers to the expansion slot number at which the call is directed. Module refers to the module position at which the call is directed. The channel parameter refers to the I/O channel at which the call is directed. For digital I/O hardware this is the port parameter. Rules for determining valid slot, module, and channel/port parameters values are detailed in Section 4.2.2, Chapter 4. In the following chapter sections, general programming procedures and function call sequences are discussed starting with a detailed look at initialization. 3-3 Chapter 3: General Programming Procedures 3.2 Initialization Software and hardware initialization routines are the first components of an application program. The Master Link Software initialization functions are used to initialize the software library, define hardware support, define function support (DMA, Thermocouple, etc.), and detect and initialize your data acquisition components (Boards/Carriers and I/O Modules). Note: For Windows 3.x and Win32 applications, the functions RegisterClient and UnregisterClient are provided in the Initialization group for the purpose “registering” and “unregistering” program instances with the Master Link Dynamic Link Library (.DLL) driver. These function calls are the first and last required calls for Windows applications, but are not discussed in this section. Please refer to Chapter 4 and the Windows based sample programs for information on using these functions. A brief description of the initialization functions provided with the libraries are presented in the following sections. The calls you use to initialize your system are categorized into hardware and software initialization functions, hardware and software support functions, and expansion slot assignment and inquiry functions. 3.2.1 Hardware and Software Initialization Functions The Software Libraries provide three function calls in this category: HWInit SWInit SWReset hardware initialization software initialization, and a function call to reset or cancel the configuration established by the other two calls. HWInit is the final system function that should be called in the initialization Section of program. It establishes the software configuration, performs system timer calibration, and initializes the Intelligent Instrumentation hardware components. Descriptions of the initialized states of all Intelligent Instrumentation Data Acquisition Devices after a HWInit call are given at the end of the Initialization Call group section in Chapter 4, Section 4.5.9. SWInit initializes the software library. This call should precede all other Master Link function calls in your program. You can alter the SWInit call to customize driver initialization. You do this by replacing the last parameter of the InitSW function call (found in the SWInit function in the PCIDATA source file in the SAMPLE directory) with the desired flag(s). For more information on this topic please consult the “Initialization Enhancements” section of the README.TXT or READMEW.TXT file and Appendix B. These initialization enhancements apply to all Master Link language versions. SWReset resets the Software Library. This function, which can be called any time after SWInit, cancels the software and hardware initialization. 3.2.2 Hardware and Software Support Functions IncludeXXXX calls comprise the hardware and software support function call group. IncludeXXXX function calls are provided to link software support for the hardware used by the application. They cause support for the PCI-20XXXX Board/Carrier, or Module, support for special software functions to be included in your program, and create necessary internal structures for the software library functions. There is a unique IncludeXXXX call for each Board, Carrier and I/O Module product. Additionally, there are IncludeXXXX calls for buffer, DMA, and thermocouple temperature measurement software support. Some example hardware support calls are: Include98C - hardware support function for the PCI-20098C Series Multifunction Boards. 3-4 Chapter 3: General Programming Procedures Include368M - hardware support function for the PCI-20368M-1 High-Speed Analog Expander Module. All IncludeXXXX calls are listed in Chapter 4. Two example software function support calls are: IncludeBUF - buffer support IncludeDMA - Direct Memory Access (DMA) support To load support for a PCI-20098C Series High-Performance EISA Board, the beginning of a C language initialization routine would look something like this: int InitRoutine (void) { int err; if (err = SWInit ()) return err; if (err = Include98C ()) return err; . . . 3.2.3 Slot Assignment and Inquiry Functions SLOT ASSIGNMENT functions are used to identify the Intelligent Instrumentation hardware configuration installed in your computer to the software. All addressing by function calls is related to the "slot number" of the Board/Carrier. For the libraries to properly identify a hardware element, it must have a designated "slot" number. These functions, SlotAssign, SlotAssignIO, and SlotSearchEISA are used to find and/or assign slot numbers. SlotAssign assigns a slot number to an installed memory-mapped ISA Bus Board or Carrier. SlotAssignIO assigns a slot number to an installed I/O-mapped ISA Bus Board (e.g. a PCI-20377W or PCI-20428W Board). SlotSearchEISA finds the slot numbers of installed PCI-20501C EISA Boards. Note: The Win32 Libraries do not support EISA Data acquisition hardware (i.e. the PCI-20501C EISA Series Boards). SlotAssign assigns a slot number to an installed ISA Board or Carrier. You must specify the segment address of the Board/Carrier and the slot number you wish to assign. The assigned slot number, along with the module position and channel number, is used for all subsequent I/O function calls. The SlotAssign call must be made for each ISA Board or Carrier in the system, and must be made between the SWInit and HWInit calls. IMPORTANT NOTE: When you assign slot numbers for ISA devices (such as the PCI-20098C Series Multifunction Boards) installed in an EISA Bus computer, we recommend that you assign slot numbers 16 to 31. This will avoid any possible conflict between installed EISA and ISA Boards in the system. SlotAssignIO assigns a slot number to an installed I/O-mapped ISA Board (i.e. PCI-20377W or PCI-20428W). You must specify the base I/O address of the Board and the slot number you wish to assign in this function. The assigned slot number, along with the module position and channel number, is used for all subsequent I/O function calls. The SlotAssignIO call must be made for each Intelligent Instrumentation Data Acquisition I/O-mapped ISA Board in the system, and must be made between the SWInit and HWInit calls. 3-5 Chapter 3: General Programming Procedures SlotSearchEISA searches the EISA expansion backplane for PCI-20501C EISA Boards and identifies them to the software. This call is required in every program using PCI-20501C Series Boards to inform the software system of PCI-20501C Board slot assignments and memory map locations. Each PCI-20501C Board found, will automatically be initialized when HWInit is called. IMPORTANT NOTE: The Win32 Libraries do not support EISA Data acquisition hardware (i.e. the PCI-20501C EISA Series Boards). SLOT INQUIRY functions are used to return information about the hardware configuration installed in your computer. These functions are: SlotSearchIO searches the I/O-map for installed Intelligent Instrumentation I/O mapped ISA devices and returns configuration information. SlotSearchISA searches the memory-map for installed Intelligent Instrumentation memory-mapped ISA devices and returns configuration information. SlotInquire returns configuration information about a specific "slot". SlotSearchIO searches the I/O space for I/O-mapped Boards (i.e the PCI-20377W and PCI-20428W) and returns the number of boards found along with information about each board. Note, only those boards with software support already loaded (using the IncludeXXXX function call) will be detected. For each device found, the ID code and base I/O address are returned. This information may be used to generate SlotAssignIO calls for those boards which are found. SlotSearchISA searches memory for memory-mapped Boards or Carriers and returns the number of boards found along with information about each board. Note, only those Boards/Carriers with software support already loaded (using the IncludeXXXX function call) will be detected. For each device found, the ID code and segment address are returned. This information may be used to generate SlotAssign calls for those boards which are found. An example slot search and assignment routine, in Pascal, follows: err := SlotSearchISA(count, boards); For i := 0 To count-1 Do Begin Writeln ('board #', i:1, ': segment = ', boards[i].segment, ' id = ', boards[i].id); err := SlotAssign (i+16, boards[i].segment) if (err <> 0) then begin FunctionName := err; exit (FunctionName); end; End; SlotInquire can be used to obtain information about the Intelligent Instrumentation Hardware configuration installed in a specific slot of the host computer. (SlotInquire should only be called after HWInit has been called.) A four member list array of data corresponding to module positions 0 to 3 of the installed Board or Carrier is returned. Data for each module position includes a module present flag, a module ID code, and the Board/Carrier/Module's segment address. The first member, corresponding to module 0, contains the ID and segment address of the Board/Carrier itself. Note: All hardware ID codes are listed in the SlotInquire function call description in Chapter 4. 3-6 Chapter 3: General Programming Procedures 3.2.4 Initialization Function Call Sequence The order in which you should organize initialization function calls in your programs is summarized below, and demonstrated in the sample programs supplied with Master Link. An example initialization sequence is listed at the end of the initialization call group in Chpater 4. [1] SWInit must be the first library function call. Note: The SWReset function can be called any time after SWInit to cancel all software and hardware initializations. [2] All of the necessary IncludeXXXX calls should be made next. [3] Optionally call SlotSearchISA and/or SlotSerachIO to automatically detect ISA boards. [4] If you are using memory-mapped or I/O mapped ISA boards, you should assign them slot numbers now with the SlotAssign and/or SlotAssignIO functions (see above for an example). [5] If you are using PCI-20501C Series High-Performance EISA Board(s), the SlotSearchEISA call must be made immediately after all of the necessary IncludeXXXX and SlotAssign calls. Note: The Win32 Libraries do not support EISA Data acquisition hardware (i.e. the PCI-20501C EISA Series Boards). [6] HWInit should be the last required initialization function called. All installed ISA Boards/Carriers which have been assigned slot numbers by the SlotAssign and SlotAssignIO calls will be initialized. If you are using an EISA computer, all installed EISA Boards found by the SlotSearchEISA function call will be initialized as well. Note: SlotInquire can be called any time after HWInit to obtain configuration information about a specific slot. 3-7 Chapter 3: General Programming Procedures 3.3 Analog Input The following Analog Input Modules and Boards are supported by the Master Link Software Libraries: PCI-20501C Series High-Performance EISA Boards PCI-20098C Series Multifunction Boards PCI-20002M 25kHz Analog Input Module PCI-20019M 89kHz Analog Input Module PCI-20020M Trigger/Alarm Module PCI-20023M 200 kHz Analog Input Module PCI-20031M Analog Expander/Sequencer Module PCI-20341M 16-bit High-Resolution Analog Input Module PCI-20363M Simultaneous Sample/Hold Module PCI-20364M 12/16/18 High-Accuracy Analog Input Module PCI-20368M High-Speed Analog Expander/Sequencer Module PCI-20089W Analog Input Board PCI-20091W Analog Input Board PCI-20377W Low Power Multifunction Board PCI-20428W Series Low Cost Multifunction Boards IMPORTANT NOTE: The Win32 Master Link drivers do not support the PCI-20501C Series EISA Boards. There are two different approaches for reading analog input data; single channel acquisitions, and multiple channel acquisitions. The mode of operation you require depends on your analog data gathering needs, and the capabilities of your hardware system. Single channel acquisitions are sufficient if you need to know input values on an occasional basis, without respect to precise moments in time or to some rapidly changing external event. Temperature monitoring and control is a typical application where single channel read operations are appropriate. Single channel reads are also useful for verifying correct connections to external signals. On the other hand, multiple channel acquisitions are appropriate if you must repeatedly sample a single input (or group of inputs), or when the data you are looking for starts or stops based on some external "triggering" event. Waveform capture and analysis is an example application requiring multiple channel acquisition. Different library function calls support these two different types of data acquisition tasks. Because of the additional timing factors and hardware functions involved with multiple channel acquisition, several function calls are provided to support this mode of operation. 3.3.1 Single Channel Acquisition A read of a single analog input channel on any PCI-20000 Series Analog Input device can be performed using the AIRead call. If the analog input device has programmable operating features (range, gain, and input mode), the AIRead call configures these features of the device then returns the A/D conversion data. After the proper initialization calls have been made (see Section 3.2), only one call (AIRead) is required to perform a single read operation. A special call, SSHReadGroup, is also provided which allows you to simultaneously read all channels on a PCI20363M-1 8-Channel Simultaneous Sample/Hold Module. The data from each input channel (0-7) is placed sequentially in an array. Common Analog Data Format For the AIRead and SSHReadGroup calls, analog conversion data is returned in "common analog data format": 16-bit 2's complement format (-32768 to 32767) for Bipolar input ranges, or 16-bit straight binary (0 to 65535) for Unipolar ranges. 3-8 Chapter 3: General Programming Procedures A count-to-voltage conversion function, CountsToVolts, is provided for converting the values returned from the above function calls to floating point voltage values. Using the PCI-20364M-1 High-Accuracy Analog Input Module. A special set of function calls are provided to support analog data acquisition using the PCI-20364M-1 HighAccuracy Analog Input Module. These function calls enable you to take advantage of the Module's advanced features, such as auto-calibration, extended mode 18-bit A/D conversion, and variable span and zero offset options. Single channel analog acquisitions from the PCI-20364M-1 Module can be performed using the AIRead call or the AIReadExtended call. AIReadExtended can execute a 12, 16, or 18-bit resolution A/D conversion on the PCI-20364M-1 Module and return 32-bit signed result data. The resolution, mode and result format (extended or common) of the PCI-20364M-1 are controlled by the SetOptions364 call. Optionally you may call AICalibrate (and AICalibrationStatus) to perform an auto-calibration of the Module's A/D prior to a read operation. Another call, AICalibrate364, can be employed to make more accurate, and/or custom calibrations using an external voltage reference. The AIReadExtended call can also be used to read A/D (or Expander) channels, other than the PCI-20364M-1's. In these cases, results will be in 32-bit length "common format" - sign extended to 32-bits An extended count-to-voltage conversion function, ExtendedCountsToVolts, is provided for converting the values returned from the AIReadExtended function call to floating point voltage values. 3.3.2 Single Channel Analog Input Acquisition Programming Procedures NOTE: Not all Analog input devices have software programmable gains, input ranges or input types. Some require hardware jumpers for setting these parameters, operate at a fixed gain, or support one type of input configuration only. If a device is configured through jumpers, the AIRead function's parameters should match the jumpered values. The AIRead function call description, in Chapter 4, provides a list of all supported Analog Input hardware features. Please refer to that list for all available gains, ranges, input types and software configurable hardware features. Information on each of the software calls, including syntax, a description, a list of parameters and possible values is provided in Chapter 4. Analog Input Single Channel Read Using the AIRead call, single channel reads can be performed on any analog input channel. [1] As with any program, you must initialize your system with the SWInit call, the proper IncludeXXXX calls, SlotAssign, SlotSearchEISA, and the HWInit call (see Section 3.2 on Initialization for more information on initialization functions). [2] Call AIRead with the desired settings for gain, range, and input type (single-ended or differential). The data is returned in common analog data format. (Please see the NOTE at the beginning of this section for Analog Input parameter considerations.) [3] Optionally call CountsToVolts to convert the common format values returned from AIRead to floating point voltage values. 3-9 Chapter 3: General Programming Procedures Reading All Channels on a PCI-20363M-1 SSH Module Data acquisition on the PCI-20363M-1 8-Channel Simultaneous Sample/Hold Module can be performed using the SSHReadGroup call. All 8 channels on the PCI-20363M-1 Module may be read using a single SSHReadGroup call. [1] Initialize your system (see Section 3.2 on Initialization for more information on these functions). [2] Call SSHReadGroup with the desired settings for gain, range, and single-ended or differential operation. (NOTE: The gain, range, and input signal-endedness in this case specifies the A/D Module's configuration. All PCI-20363M inputs are single-ended, however, its output can accomodate singleended or differential input A/D Modules. Set the SSHReadGroup differential parameter to the A/D's configuration) The data array is returned in common analog data format. (Please see the NOTE at the beginning of this section for Analog Input parameter considerations.) [3] Optionally call CountsToVolts to convert the common format values returned from SSHReadGroup to floating point voltage values. Reading a Channel on a PCI-20364M-1 Module Using the AIRead call, single channel reads can be performed on any analog input channel on the PCI-20364M-1 Analog Input Module configured for any resolution (12/16/18-bit). Note, if the Module is configured for 18-bit resolution, the 2 Least Significant Bits (LSBs) of the conversion will be lost since AIRead must return a 16-bit number. If the AIReadExtended call is used, a full 18-bit resolution read can be performed (as well as 12-bit and 16-bit reads). In either case, an optional auto-calibration of the Module can be done using the AICalibrate and AICalibrationStatus calls prior to a read. Zero and span calibrations (referenced to on-module calibation sources) are all accomplished as a result of the AICalibrate call. The Module's resolution, result format (common or extended) and other programmable options can be configured by using the SetOptions364 call. [1] Initialize your system (see Section 3.2 on Initialization for more information on these functions). [2] If desired, call SetOptions364 to configure the mode, resolution, and result format of the Module's A/D. [3] If desired, call AICalibrate to calibrate the A/D. Poll the status of the calibration with AICalibrationStatus until the calibration is complete. [4] Call AIRead or AIReadExtended with the desired settings for gain, range, and input type (singleended or differential). The data is returned in common analog data format, or extended result format depending on the settings specified to SetOptions364. [5] Optionally call CountsToVolts or ExtendedCountsToVolts to convert the common format or extended format values returned from AIRead or AIReadExtended to floating point voltage values. 3.3.3 Multiple Channel Acquisition Multiple channel analog input data acquisition is accomplished using Direct Memory Access (DMA) techniques. DMA is a fast and efficient way to get large quantities of data into a personal computer. 3-10 Chapter 3: General Programming Procedures To perform Analog Input DMA transfers you must be using a PCI-20501C-1 High-Performance Multifunction EISA Board, a PCI-20501C-2 High-Performance EISA Board with an installed Analog Input Module, a PCI20098C Series Multifunction Board, a PCI-20041C High-Performance Carrier with an installed Analog Input Module, a PCI-20377W Board, a PCI-20428W Series Multifunction Board or a PCI-20091W High-Speed Analog Input Board. NOTE: All Analog Input Modules are supported by the Master Link Software Libraries for DMA transfer except the PCI-20002M Analog Input Module. Note: Win32 Based Master Link drivers do not support the PCI-20501C Series Boards. These boards are supported by the Master Link for DOS or Windows 3.x versions, however. The two primary Software Library function calls used in analog input DMA operations are the AIConfigureList and DMAConfigureList calls. The AIConfigureList call is used to specify a list of analog input channels you want to acquire data from, and at what gain, range, and input configuration to perform the acquisition. Note, only data from one A/D device may be used in a single DMA analog input process. In any case, multiple DMA processes can be used in a program to acquire data from several A/Ds. Analog Input Expansion Modules may be used to increase the number of available channels feeding a single A/D. The DMAConfigureList call is used to specify the majority of DMA input or output configuration parameters. The call specification for DMAConfigureList (Chapter 4, Section 4.5.8) discusses valid parameters and the various conditions allowed for analog input DMA transfer. Pacing Signals Multiple channel data acquisition is managed by the use of pacing signals. Pacing signals are pulses used to initiate A/D conversions and time the DMA transfer. Conversions are started with a pacer signal source on the Board, one of its Modules, or on a remote Board (connected via an inter-board/carrier cable) or one of its Modules, or an external source. The A/D's channel scanner will automatically increment to the next channel list element immediately after the start of each conversion. A pacer signal can come from a number of possible sources, and is usually connected to the A/D's Start Convert input via a Board's Synchronization Bus (Sync Bus) using the SYNCConfigure call. In turn, the A/D's Busy line (or End Of Convert) is usually connected to the DMA Controller's pacer input (also using the SYNCConfigure call) to inform the Board's DMA controller when to make a transfer. Trigger Signals Unlike pacing signals, triggers are not absolutely required for DMA processes, however, they are very useful for applications requiring event driven data acquisition. Triggers are commonly used to start or stop an acquisition based on some external condition, such as an analog input voltage crossing a threshold level, a contact closure, a software command, etc. For example, the PCI20020M Trigger/Alarm Module can generate a trigger signal from an analog threshold detection or window comparison. Trigger's may come from an external input, or they can be chosen from any valid Sync Bus source. Start and Stop Modes DMA start and stop modes are specified using the DMAConfigureList call. Available start and stop modes, and hardware specific restrictions, are listed in the DMAConfigureList call's start and stop parameter descriptions. 3-11 Chapter 3: General Programming Procedures Analog input DMA transfers are enabled using a software command (DMAStart). The termination mode you choose helps determine when, and how many transfers will take place before the process stops. When an acquisition is programmed to stop on an external event, such as an analog trigger signal, we say that a "Trigger Mode" acquisition is being performed. In this case a specified number of transfers (set in the stopdelay parameter of the DMAConfigureList call) are made after the detection of a trigger signal. If you choose a "Stop on Terminal Count" mode, the the "Terminal Count" value is set in the clustercount parameter of the DMAConfigureList call. The terminal count value specifies the number of transfers that will be made before the DMA process stops. How to assign the various DMA start and stop modes is shown in the function call reference section under the DMAConfigureList call entry. Buffers You will need to know how much data will be involved in the transfer so a section of memory can be set aside for storing the data. Whenever you set up a DMA operation, you must allocate buffer memory for this purpose. Once you know how much memory you need, you can use the BUFAllocate call to set up a buffer. The start address of the data buffer is returned from this call. On 80286 machines (or better) with extended memory (also called XMS memory), BUFAllocate can create a buffer in extended memory. Note, you can allocate your own buffer, or array, for data storage if you prefer. The amount of buffer memory required depends on the number of analog input channels you want to read and the number of samples you want to take from each channel. The DMAConfigureList call returns a value, called the clustersize, that you can use to determine the required buffer size. See the BUFAllocate and DMAConfigureList call descriptions for further details on the clustersize parameter and determining the buffer size. After the acquisition run, you will want to translate the analog input data into common analog data format (see 3.3.1) using the BUFDecode call. Prior to calling BUFDecode you may wish to use the BUFSeek function to locate specific data clusters within the buffer. A buffer information structure (info) is passed to both BUFDecode and BUFSeek. This structure is also passed to DMAStatus and DMAStop calls where it is filled with information about the acquisition. The information is used when decoding data and is updated to reflect changes in the current location in the buffer, and other buffer information (see Chapter 4, Section 4.5.3 for details on buffer info). Note, the buffer must be associated with the DMA process, using the BUFAttachProcess call, before "seeking" and "decoding" can be done. 3-12 Chapter 3: General Programming Procedures 3.3.4 Multiple Channel Analog Input DMA Programming Procedures Information on each of the software calls, including syntax, a description, a list of parameters and possible values is provided in Chapter 4. IMPORTANT NOTE for Windows Users: If you didn’t do so at installation time, you will need to install one of the following platform-dependent driver files as described in Chapter 2 and in Appendix B: 1. Windows NT : Master Link NT Driver with DMA support, MASTER_NT.SYS. 2. Windows 95: Virtual DMA Device Driver, VDMAD.VXD. 3. Windows 3.x: Virtual DMA Device Driver, PCIVDMAD.386. The essential function calls for performing a DMA analog input acquisition have been briefly presented in the preceding sections. To program an acquisition, you will need to: [1] Initialize your system (see Section 3.2 on Initialization for more information on these functions). [2] Call DMAGetHandle or DMAHugeGetHandle to assign a "processhandle" to the DMA process. The handle is a number returned by the call, you must use this handle when referencing this process in subsequent DMA operations. Use DMAHugeGetHandle for any Windows applications that require greater than 64 kbytes of acquisition data. [3] Call DMASetOptions to choose a host computer DMA channel for the transfer (see the DMASetOptions call description in Chapter 4 for DMA channel options). [4] Configure your pacer source. The pacer signal can come from any number of sources, such as an onboard Burst Generator, an on-board Rate Generator, an on-board Counter channel, a signal generated by an I/O Module, a signal from the inter-board or inter-carrier connector, or an external signal. NOTE: Pacer and trigger connection calls are grouped in step [6]. [5] If you are using a trigger signal, configure your trigger source. As with pacer signals (see [4]), trigger signals can come from a variety of sources. For example, the PCI-20020M Trigger/Alarm Module can generate a trigger signal from an analog threshold detection, or a window comparison. NOTE: Pacer and trigger connection calls are grouped in step [6]. [6] Connect your pacer source to the appropriate input(s), or target(s), using the SYNCConfigure call. For example, to connect a Burst Generator output to an on-board A/D Start Convert input, specify the source as SYNC_BG_OUT and the target as SYNC_AD_START in SYNCConfigure. See the Synchronization Bus section in Chapter 4 for more details on sync signals and the SYNConfigure call. If you have Expander/SSH Modules, you will need to connect a pacer to these devices as well (see the appropriate Module's manual for information on selecting a pacer). If you are using a trigger signal, connect your trigger source to the appropriate input, or target, using the SYNCConfigure call. For example, to connect the trigger output of a PCI-20020M Module (installed in position 2 of a PCI-20501C-1 or a PCI-20098C) to an on-board A/D trigger input, specify the source as SYNC_MOD_2 and the target as SYNC_AD_TRIG for a PCI-20501C or SYNC_DMA_TRIG for a PCI-20098C in the SYNCConfigure call. See the Synchronization Bus section of Chapter 4 for more details on sync signals and the SYNCConfigure call. 3-13 Chapter 3: General Programming Procedures [7] Call DMASetPacer to identify your selected A/D pacer source to the Software Libraries. NOTE: The software will automatically enable the selected I/O device (if it is a Burst Generator, Counter channel, Rate Generator, or a Trigger/Alarm Module) specified to DMASetPacer when you call DMAStart (step [12]). For no pacer, specify NO_TYPE in DMASetPacer. [8] Call DMASetTrigger to identify the trigger source to the Software Libraries (see note in step [5]). For no trigger, specify NO_TYPE in DMASetTrigger. [9] Call AIConfigureList to: A. Program the analog channel scan list. The list passed to this call contains the following data: slot number of the Board, module number of A/D or Analog Input expander, channel number, input range, gain, and differential or single-ended operation. B. Choose burst mode or single-shot mode (if supported by your hardware, see the AIConfigureList call description in Chapter 4). C. Specify the number of list elements in the count parameter. Note: The triggermode and triggerdelay parameters in this call are reserved for future use and are not related to DMA - always set these to "0" (for "FALSE", and 0 delay respectively). [10] Call DMAConfigureList to: A. Identify the DMA channel list. The list should contain; slot number of the Board, module number of A/D or Analog Input expander, channel number, and the I/O type=AI_TYPE. B. Specify the number of channel list elements in count. C. Set the clustercount (number of samples from each channel to be stored in the buffer). D. Select a start and stop mode, and set the number of trigger stopdelay clusters (depending on the start and stop modes you want to use). If you choose stop on terminal count mode, set stopdelay to 0. Set trigger startdelay clusters to 0 (this applies only to DMA output processes when using a PCI-20041C Carrier). NOTE: You must always set DMAConfigureList's groupAI parameter to 1 (TRUE) when using a PCI-20501C Board for analog input DMA acquisition. Set groupAI to 0 (FALSE) for a PCI-20041C, PCI-20098C, PCI-20377W, PCI-20428W or a PCI-20091W. [11] From the clustersize value returned in the DMAConfigureList call, determine the buffer size you will need (in bytes) from the following: Buffer size (bytes) = clustersize x clustercount where clustercount is the number of channel list passes you want to acquire (as specified through the DMAConfigureList call in step [10]). Call BUFAllocate to allocate a data buffer for receiving your analog input data. Set the buffersize parameter to the value determined above. Also specify the general buffer location. The buffer start location (address) is returned in the extended memory bufferhandle and conventional memory buffer pointer parameters. Alternatively, you may allocate your own buffer or array through other means. After allocating the buffer, call BUFAttachProcess to associate your buffer with the DMA process you are performing. You do this by specifying the DMA processhandle, obtained from DMAGetHandle or DMAHugeGetHandle, to BUFAttachProcess's processhandle parameter. You must also identify the buffer's XMS bufferhandle, and conventional memory buffer pointer to the call. 3-14 Chapter 3: General Programming Procedures [12] To start your analog input DMA acquisition call DMAStart. This will enable your pacer source and trigger source (if specified to DMASetPacer or DMASetTrigger), the Intelligent Instrumentation device's and the PC's DMA controller. [13] The DMAStatus call can be used to check if the DMA process has finished. Optionally the DMA process can be stopped at any point through the DMAStop call. DMA status and buffer information is also returned after a call to DMAStop. [14] When the process has terminated you can locate specific data in the data buffer with BUFSeek, then transfer and decode (format) that data to a specified destination array or buffer using the BUFDecode call. [15] Before exiting your program, you must deallocate any buffers by using the BUFDeallocate call, and "free" any DMA processhandles using the DMAFreeHandle call. 3.3.5 Analog Input DMA Overrun Errors There are several types of overrun errors which can occur in the course of an analog DMA data acquisition, each indicating that conversion results may have been lost. Overrun errors, as well as many other non-A/D related errors, can be detected by checking the status of the acquisition using the DMAStatus call. These errors do not stop the DMA process; the next pacing signal after the error will be acted upon. However, the data as a whole may have gaps. DMA_AD_READ_OVERRUN = Analog input overrun. A conversion completed before data from the previous analog input conversion was read. This error is often returned when using a continuously running pacer (such as a Burst Generator) because the A/D will continue to perform conversions after the DMA process has stopped. DMA_AD_RATE_OVERRUN = Analog input overrun. The analog input sample rate was too high, resulting in skipped cycles. DMA_FIFO_OVERRUN = DMA FIFO overrun. This error applies to a hardware which contain FIFO buffers. A DMA write to a full First In First Out (FIFO) register or DMA read from an empty FIFO was detected. DMA_HUGE_OVERRUN = Huge DMA process overrun. An overrun was detected during a huge DMA process that resulted in missing, or lost, data. 3-15 Chapter 3: General Programming Procedures 3.4 Analog Output The following Analog Output Modules and Boards are supported by the Master Link Software Libraries: PCI-20003M-2,4 12-bit Analog Output Module (2 channel Voltage/Current) PCI-20006M-2 16-bit Analog Output Module (2 channel Voltage) PCI-20021M-1B 12-bit 8 Channel Analog Output Module (Voltage) PCI-20093W-1 12-bit 8-Channel Analog Output Board (Voltage/Current) PCI-20428W-1,-2 Series Multifunction Boards (2, 12-bit analog output voltage channels) Analog output levels can be generated through general purpose DMA techniques, or on a single channel and/or channel group basis. Section 3.9 on DMA explains how to perform DMA output procedures, this section discusses the function calls supporting non-DMA Analog Output modes. Three function calls are provided in the library to control analog output devices - AOConfigure, AOWrite and AOWriteGroup. 3.4.1 Non-DMA Analog Output The AOConfigure call allows you to configure an Analog Output channel for a specified output range. The output range is specified through the AOConfigure call's range parameter. Output ranges for all supported hardware are listed in the call’s description in Chapter 4. Note: For devices which use hardware jumpers to select a range, the parameter value should match the jumpered value. Two calls are provided for writing output data, the AOWrite and AOWriteGroup calls. AOWrite is used to output a data value to a single channel on an Analog Output Module. You specify the desired output value(s) in each call's data parameter in common analog data format; -32768 to 32767 for Bipolar output ranges, or 0 to 65535 for Unipolar ranges. AOWriteGroup simultaneously writes a group of data values to all the channels on an Analog Output Module. The data you wish to output must be stored in an array. Elements of the array (0 to N) correspond to the channel numbers of the Module on which you desire to generate the analog output levels. The data must be in common analog data format. A voltage-to-counts conversion function, VoltsToCounts, is provided for converting floating point voltage values to common analog data format counts values for use by the above function calls. 3.4.2 Analog Output Programming Procedures A description, syntax information, and a parameter list for each of the calls is provided in Chapter 4. To create an analog output level on a single channel, use the AOConfigure and AOWrite calls. 3-16 [1] Initialize your system (see Section 3.2 on Initialization for more information on these functions). [2] Call AOConfigure to specify the analog output range.* [3] Optionally call VoltsToCounts to convert floating point voltage values to common analog data format for use by the AOWrite call in the next step. [4] Write output data to the desired channel using the AOWrite call. Chapter 3: General Programming Procedures For multiple channel analog output, use the AOConfigure and AOWriteGroup calls. [1] Initialize your system (see Section 3.2 on Initialization for more information on these functions). [2] Call AOConfigure to specify the analog output ranges.* [3] Optionally call VoltsToCounts to convert floating point voltage values to common analog data format for use by the AOWriteGroup call in the next step. [4] Call AOWriteGroup with an array of the desired output data values. *Note: When using a PCI-20021M Module, or a PCI-20093W Board, you must configure all channels for the same range before using AOWrite or AOWriteGroup. 3-17 Chapter 3: General Programming Procedures 3.5 Burst Generator The following Boards with programmable Burst Generator functionality are supported by the Master Link Software Libraries: PCI-20501C Series High-Performance EISA Boards PCI-20098C Series Multifunction Boards A Burst Generator produces a series of bursts of pulses or a stream of pulses at a continuous rate. The burst period (time between bursts), pulse period (time between pulses in a burst) and the number of pulses per burst are all programmable. A Burst Generator output waveform is shown in Figure 3.1. 3.5.1 Modes Three operational modes can be programmed. These modes are termed Continuous, Single-Shot, and Sync Start and Stop modes. In addition, the polarity (e.g. inverted, non-inverted) of the Burst Generator output signal is software selectable. Burst Generator output pulses are primarily used for pacing analog input data acquisitions, but can be used for a variety of applications. Use of the Burst Generator as a pacing signal can facilitate accurate data acquisition by approximating "simultaneous" reading of multiple channels. For details on the operation of the various Burst Generator modes please see Chapter 4 (Section 4.5.4) and the manuals for the PCI-20501C Series or PCI-20098C Series Boards. Pulsewidth (250 nsec) Burst Period Pulse Period Number of pulses per burst (=4 in this example) Figure 3.1 Burst Generator Waveform The Master Link Software Libraries supply four function calls for the purpose of controlling a Burst Generator circuit - BGConfigure, BGSetOptions, BGDisable, and BGEnable. 3.5.2 Using a Burst Generator as a DMA Pacer or Trigger The calls DMASetPacer and DMASetTrigger allow you to specify a Burst Generator channel as a pacer or trigger for DMA data acquisition. DMASetPacer and DMASetTrigger specify the pacer and trigger sources for a DMA data acquisition (Section 3.3 and Section 3.9 offer general information on the use of pacers, triggers and DMA processes). For example, to designate a PCI-20501C Burst Generator output as a pacer or a trigger signal source, specify "BG_TYPE" in the i/otype parameters of the above calls. The Burst Generator output signal must be routed to the DMA pacer or trigger input destination using the SYNCConfigure call. 3-18 Chapter 3: General Programming Procedures 3.5.3 Burst Generator Programming Procedures The procedure for programming a Burst Generator to output a stream of pulses is listed below. Information on each of the function calls, including a description, format information, and a list of parameters, is provided in Chapter 4. [1] Initialize your system (see Section 3.2 on Initialization for more information on these functions). [2] First, decide on a Burst Generator mode - Continuous mode, Single-Shot mode, or Sync Start and Stop mode. If you select Single-Shot mode, or Sync Start and Stop mode, you must call SYNCConfigure to connect start and stop signal sources to the Burst Generator start and stop inputs. Single-Shot mode only requires a start signal. The mode is set in step [4]. [3] Call BGSetOptions to select inverted or non-inverted Burst Generator output pulses. [4] Call BGConfigure to set the burst and pulse periods, the number of pulses per burst, and the Burst Generator mode. [5] Call BGEnable to start the generator in Continuous mode or to enable the Burst Generator start and stop inputs for Sync Start and Stop and/or Single-Shot modes. 3-19 Chapter 3: General Programming Procedures 3.6 Counters The counter function calls apply to the counter circuits on the following hardware: PCI-20501C Series High-Performance EISA Boards PCI-20098C Series Multifunction Boards These counter circuits provide two 16-bit counter channels that can operate independently or can be configured to operate as a single 32-bit counter. IMPORTANT NOTE: The Win32 Master Link drivers do not support the PCI-20501C Series EISA Boards. Each of the counters is capable of performing a variety of counting functions, these include: Signal Measurement (for period or pulsewidth) Event Counting Programmable Dividing When configured for 32-bit operation, an additional mode is available - Variable Duty-Cycle Generator (VDCG). When operated as a single 32-bit counter, the counter pair is referred to as Counter 0. Thus, only Counter 0 may be configured as either a 32-bit counter or a 16-bit counter. Counter 1 can be configured as a 16-bit counter, and is operable only when Counter 0 has also been configured as a 16-bit counter. Counter outputs may be routed to various Synchronization Bus destinations, such as Module SYNC inputs. The polarity (inverted, non-inverted) of these signals is software selectable. Counter modes are chosen using the CTRConfigure call. (A table of counter modes and parameters is given in the CTRConfigure call description in Chapter 4, Section 4.5.5.) The various programmable counter modes are examined in the following Sections. 3.6.1 Signal Measurement - Period and Pulsewidth For all signal measurement modes, the signal to be measured is connected to the counter's external clock input line at the Board's digital signal connector. The external clock input signal may be inverted through the CTRSetOptions call. Setting the measurement mode is a two step operation, using the CTRConfigure and the CTRMeasure calls. First, 16-bit or 32-bit measurement mode is selected in the CTRConfigure mode parameter. Next, period or pulsewidth measurement is specified in the type parameter of CTRMeasure. "LONG" or "SHORT" period measurement options may be specified in the type parameter, or, "HIGH-GOING" or "LOW-GOING" pulsewidth measurements may be selected. When performing period measurements, "LONG" or "SHORT" period measurement should be chosen based on the length of the signal period (as explained in the next topic.) "HIGH-GOING" or "LOW-GOING" pulsewidth modes measure the duration of the high-level portion or low-level portion of a TTL type signal (0 to 5 V). Signal measurements are performed using the CTRMeasure call. In all modes, the results are in units of seconds (a floating point double precision result is returned by the call in its period parameter). For period measurements, this is the period of the input signal. For pulsewidth mode, this is the width of the input pulse in seconds. 3-20 Chapter 3: General Programming Procedures NOTE: If the value of the measured signal exceeds the capacity of the counter, an overflow error will be returned. That is, if a counter has exceeded its maximum count, an overflow indication will be returned in the counter status word. An underflow error condition (no counts) can also occur. Bit masks are provided with the Master Link Software for decoding the status word. Period Measurement Two period measurement modes can be specified in the CTRMeasure call - LONG and SHORT. These modes are provided so you may select the best measurement resolution for signals with "LONG" periods (low frequency) or "SHORT" periods (high frequency). For signal measurement with 0.1% resolution or better, SHORT period measurement mode should be used for measuring signals with frequencies above 10 kHz (less than a 100 µsec period), while LONG period mode should be used for measuring signal frequencies below 10 kHz (greater than a 100 µsec period). SHORT period measurement mode is accomplished by summing the number of signal pulses (TTL level) of the input signal over a "gating time" which is automatically selected by the software for optimum measurement resolution. The period value is returned in seconds - frequency can be obtained by inverting the period. If the input frequency is constantly changing over a significant range, SHORT mode is not recommended. In LONG period measurement mode, a counter accumulates the number of pulses from the device's on-board 8 MHz clock which occur during one period of the input signal. Thus, the input signal's period will be measured to the nearest 125 nsec increment. Pulsewidth Measurement The pulsewidth measurement capability is used to measure the pulsewidths of both periodic and non-periodic signals. For pulsewidth measurement, the pulsewidth of the input signal will be measured to the nearest 125 nsec, based on the 8 MHz on-board clock. The counter accumulates the number of 8 MHz clock pulses which occur during one pulsewidth of the input signal. Pulsewidths of up to 8.19 msec can be measured with a 16-bit configuration and pulsewidths of up to 536 sec can be measured with a 32-bit configuration. High-Going or Low-Going pulsewidth measurement is specified in the CTRMeasure call's type parameter. 3.6.2 Event Counting Mode Event counting mode is specified by setting the mode parameter of CTRConfigure to SCTR_MODE (16-bit counter) or LCTR_MODE (32-bit counter). An event counter can be used to count external events by counting transitions on a counter's external clock input line. The counter's external gate input must be active for event counting to take place. The polarities of the external counter clock input, external counter gate input, and counter output signals are programmed with the CTRSetOptions call. When the external counter clock input is programmed to be non-inverted, the counter will count the low-to-high transitions of this signal; when the external counter clock input is programmed to be inverted, the counter will count the high-to-low transitions of the input signal. Gate inputs may also be inverted. Whenever the counter overflows, its output becomes active for one period of the external clock input signal. 3-21 Chapter 3: General Programming Procedures You read a single count value (from Counter 0 or Counter 1) using the CTRRead call, or you can read both counter values at the same time using the CTRReadGroup call. At the completion of a read, a 32-bit count value is returned (counter results are always returned as 32-bit values by the software, whether configured in 16-bit or 32-bit modes). If the counter has exceeded its maximum count, an overflow indication can be detected by checking the status information (status information is returned in the status parameter of a CTRRead or a CTRReadGroup call.) 3.6.3 Programmable Divider Mode (divide-by-N) In divide-by-N mode, the counter divides the signal on a counter's external clock input by a divisor, N, while the counter's external gate is active. The divisor is specified in the data parameter of the CTRConfigure call. The range of data is either 16 or 32 bits, although a 32-bit number must always be passed in this parameter. The polarities of the counter's external clock input, external gate input and the counter's output signals are set in the CTRSetOptions call. Counter size (SDIV_MODE and LDIV_MODE) is chosen via the mode parameter of the CTRConfigure call. There are two divider start and stop modes that may be selected: continuous and latched mode. The mode is specified in the dividerLatch parameter of the CTRSetOptions call. Continuous Mode In continuous mode, (dividerLatch = FALSE) the divider will output one pulse for every N pulses of the external clock input, where N is the programmed divisor. The counter's gate input must be active for the divider to operate. Latched Mode In latched mode, (dividerLatch = TRUE) the divider will not start counting until a "trigger" pulse has been received. Then, after the Nth external clock transition, the output will become active and will remain active until the counter is reset by calling CTREnable. The counter's gate input must be active for the divider to operate. After being reset, the divider will wait for the next trigger before beginning another division. The trigger signal is selected from one of several sources and is connected to the Divider 0 Trigger input (SYNC_DIV0_TRIG) or Divider 1 Trigger input (SYNC_DIV1_TRIG) via the SYNCConfigure call. 3.6.4 Variable Duty-Cycle Generator (VDCG) Mode The variable duty-cycle generator uses the 32-bit counter configuration to produce an output waveform with individually programmable high and low going durations. VDCG mode is programmed for Counter 0 in 32-bit mode in the CTRConfigure call. VDCG mode is chosen by specifying VDCG_MODE in the call's mode parameter. The positive pulsewidth of the output waveform is defined as the time period from the low-to-high transition of the signal to the high-to-low transition of the signal. The negative pulsewidth of the output waveform is defined as the time period from the high-to-low transition of the signal to the low-to-high transition of the signal. The default clock source is the on-board 8 MHz clock. If Counter 0's external clock input is used, the range of the pulsewidths will be from (2 * the external clock period) to (65536 * the external clock period). The external clock is selected by specifying TRUE in the vdcgxclock parameter of the CTRSetOptions call. The low and high pulsewidths of the VDCG are programmed in the CTRConfigure call by specifying a 2 element array of 32-bit integers in the call's data parameter. In the diagram below these integers are given the designations N1 and N2. 3-22 Chapter 3: General Programming Procedures Positive Pulsewidth is (N1*125 nsec) If internal 8 MHz clock is used or (N1*CLK Period) If the external clock input is used Negative Pulsewidth is (N2*125 nsec) If internal 8 MHz clock is used or (N2*CLK Period) If the external clock input is used Where N1 and N2 must be between 2 and 65536 Figure 3.2 VDCG Waveform 3.6.5 Using a Counter as a DMA Pacer or Trigger The calls DMASetPacer and DMASetTrigger allow you to specify a counter channel as a pacer or trigger for DMA data acquisition. DMASetPacer and DMASetTrigger specify the pacer and trigger sources for a DMA data acquisition (Section 3.3 and Section 3.9 offer general information on the use of pacers, triggers and DMA processes). For example, to designate a PCI-20098C counter output as a pacer or a trigger signal source, specify "CTR_TYPE" in the i/otype parameters of the above calls. The counter's output signal must be routed to the DMA pacer or trigger input destination using the SYNCConfigure call. 3.6.6 Counter Programming Procedures Steps for programming the counters in one of the signal measurement modes, or for event counting, division, or generation of a variable duty-cycle waveform, are provided below. Information on each of the calls, including a description, syntax, and a parameter list is provided in Chapter 4. Note, CTRConfigure automatically disables the counter, thus, you need not call CTRDisable prior to configuring the channel. Program for period or pulsewidth measurement on either counter using the CTRSetOptions, CTRConfigure, and CTRMeasure calls as follows: [1] Initialize your system (see Section 3.2 on Initialization for more information on these functions). [2] Call CTRSetOptions to select clock inversion state (or you may use the default state - no inversion). [3] Call CTRConfigure to select the signal measurement channels and 16-bit or 32-bit signal measurement mode. [4] Call CTRMeasure to select a long or short period measurement type, or a high or low pulsewidth measurement type and perform the signal measurement. A period value, in seconds is returned. Also examine the status word returned by CTRMeasure to check for any measurement errors. 3-23 Chapter 3: General Programming Procedures To program event counting, division, or variable duty-cycle generator modes, use the CTRSetOptions, SYNCConfigure, CTRConfigure, CTREnable, CTRRead, and CTRReadGroup calls. 3-24 [1] Initialize your system (see Section 3.2 on Initialization for more information on these functions). [2] Call CTRSetOptions to select clock, gate, and output inversion states (if desired), and whether or not to use divider latch or continuous mode if you are going to configure for divide-by-n operation. If you are going to use divider latch mode, also call SYNCConfigure to choose the trigger source for the divider. If you are going to use VDCG mode, you may select the external clock input through the CTRSetOptions vdcgxclock parameter. [3] Call CTRConfigure to select event counting, division, or variable duty-cycle waveform (VDCG) modes. If divider mode is selected, you must also pass the divisor, N. If VDCG mode is selected, you must also pass the high and low pulse periods. [4] Call CTREnable to start the event counter, divider, or VDCG. If you are using event counter mode, you may use the CTRRead or the CTRReadGroup call to read the count value(s) and get counter status information. Always check the status word for counter Overflow errors in event counter mode. Chapter 3: General Programming Procedures 3.7 Counters, 8254-Based The Master Link Software Libraries supports the IntelR 8254-based general purpose counter channels available on the following hardware: PCI-20007M-1A Counter/Timer/Rate Generator Module PCI-20089W Analog Input Board PCI-20377W Low Power Multifunction Board PCI-20428W Series Multifunction Boards.. The PCI-20007M-1A Module includes four general purpose counter/timer channels. The PCI-20089W Analog Input Board has one 8254-based general purpose counter. The PCI-20377W has two 8254-based general purpose counter channels. Each channel can be programmed for a variety of counting, pulse and periodic output functions. Most of these counter channels are also supported for use as pacers or triggers for DMA processes. PCI-20428W Low Cost Multifunction Boards have one general purpose 8254 based counter channel (Counter channel 0). Two other 8254 counter circuits are used for the Analog Input and Analog Output Rate Generators on these boards. The general purpose counter channel has a clock input, a gate input, and an output line. All three of these TTL-Level compatible lines are available at the I/O signal connector of the board. Each general purpose channel has a clock input, a gate input, and an output line. All three signals for each channel are available at the external signal connectors of the devices. Each counter channel consists of a 16-bit presettable down counter, whose contents can be loaded and read back via Software Library function calls. As described in section 3.7.1, a variety of counting, pulse and periodic output functions can be performed by these counters. Please consult the manuals for the boards and module mentioned in the above paragraphs for more specific information on the operation of the counter circuits in each device. The counter gate inputs on the PCI-20007M-1A Module or PCI-20089W Board must be internally jumpered for software gate control in order for the calls CTR8254Disable and CTR8254Enable to work. Software gate control is the factory default jumper configuration for these units. The PCI-20377W or PCI-20428W does not employ software gate control. In these cases, the proper external logic levels must be applied to the board's counter gate inputs for the CTR8254Disable and CTR8254Enable calls to work. (A summary table is provided at end of the next section describing gate functions, counting and output actions for each mode). 3.7.1 Operational Modes Counter channels can be configured to operate in 6 different modes by using the CTR8254Configure call (operational modes are described in detail in each hardware device's manual). Each counter can provide a pulse, a pulse train, a square wave, or an indication of a terminal count. The various counter modes are briefly described below: Mode 0 Interrupt on Terminal Count The counter is loaded with an initial count, and its output line is set low. When the counter is enabled, the counter counts down for each input clock pulse. When the count value reaches 0, the output line goes high. Mode 1 Hardware Retriggerable One-Shot After the counter is configured with an initial count N, its output line is set high. A rising edge on its gate input triggers the one-shot and the output goes low for N input pulses then returns high. If another trigger edge occurs before the output returns high, the output will remain low for an addition N input pulses. Note: In this mode the channel's gate control jumper (on a PCI-20007M-1A Module or a PCI-200089W Board) for the channel must be in the hardware control position. In this case, the calls CTR8254Disable and CTR8254Enable will have no effect. 3-25 Chapter 3: General Programming Procedures Mode 2 Rate Generator Rate generator mode essentially configures the counter channel as a divide-by-N counter. When the initial count N is loaded, and the counter is enabled, the output goes high for N input clock cycles - then goes low for one clock cycle. This sequence is repeated every N counts. The initial count cannot be 1. Mode 3 Square Wave Generator In this mode, when the initial count N is loaded and the counter is enabled, the output goes high and stays high for N/2 input clock cycles - then goes low for N/2 input cycles. As long as the counter is enabled this sequence repeats to produce a square wave output signal. Note: If the initial count is an odd number, the output stays high for (N+1)/2 counts and low for (N-1)/2 counts. The initial count cannot be 1. Mode 4 Software Triggered Strobe In this mode, loading the initial count N "triggers" the counting sequence. Initially the output is set high. The output goes low for one input clock cycle every N+1 clock pulses. This sequence repeats every time a count N is written to the counter. Disabling the counter stops counting but has no effect on the output level. Mode 5 Hardware Triggered Strobe This mode works like mode 4, except the trigger signal must be provided at the counter channel's gate input. When the initial count "N" is loaded the output is set high. A low-to-high transition at the gate input will trigger the counter to begin decrementing on the next clock input cycle. After N+1 clock pulses, the output will go low for one clock cycle and return high. If another trigger is received before the counter has been decremented to zero, the counter is reloaded and another sequence begins. The gate input in this mode is used as a trigger and does not effect counting or the output level. Note: In this mode the gate control jumper (on a PCI-20007M-1A Module or a PCI-20089W Board) for the channel must be set for hardware control. As a result, the calls CTR8254Disable and CTR8254Enable will have no effect. The following table summarizes each Mode's, gate, counting, and output actions. Mode Summary Table Mode 3-26 GATE Initial Count Counter OUT LOW L to H HIGH Min. Max. 0 Disable counting X Enable counting 1 0 Continue counting down LOW initially HIGH after count 0 1 X Restart counting Reset OUT X 1 0 Continue counting down HIGH initially LOW HIGH after count 0 2 Disable counting OUT HIGH Restart counting Enable counting 2 0 Reload initial count HIGH initially LOW on count 1 HIGH after reload 3 Disable counting OUT HIGH Restart counting Enable counting by twos 2 0 Reload initial count Toggle OUT HIGH initially HIGH first half LOW second half 4 Disable counting X Enable counting 1 0 Continue counting down HIGH initially LOW on count 0 5 X Restart counting X 1 0 Continue counting down HIGH initially LOW on count 0 Chapter 3: General Programming Procedures 3.7.2 Configuration With the CTR8254Configure call, you can easily program the initial count and counter mode of any counter channel. Details on the CTR8254Configure call, as well as all other calls, are provided in Chapter 4. When you are programming counter channels on a PCI-20377W Board, you should be aware that the Board's Rate Generator uses general purpose counter channel 0 when 32-bit Rate Generator operation has been selected through the SetOptions377 call. The default power-on configuration of the PCI-20377W's Rate Generator is for 16-bit operation, so both on-board counter channels will be available (see the Rate Generator section of this chapter for more information on SetOptions377). 3.7.3 Counter Reading and Status The count value, and counter status information of an individual counter can be read using the CTR8254Read call. A 32-bit count value is returned in the call's data parameter. Status information is also returned. The status word is a 16-bit number in which various bits may indicate the existence of a particular condition on the counter channel. Named masks for the status word are provided. The most significant of these is CTR8254_NULL_CNT. When this condition is reported, the count value returned is not valid. This indicates that the counter did not receive a clock pulse after the counter was configured. The first pulse, whether the counter is enabled or not, is used by the 8254 chip to load the initial count value into the counter channel. All counters on a PCI-20007M-1A Module, or a PCI-20377W Board can be read by using the CTR8254ReadGroup call. When reading a PCI-20007M-1A Module, this instruction latches the first three counter channels (0, 1, and 2) simultaneously, while counter channel 3 is latched as soon as possible after the others. When reading PCI-20377W counters, this instruction latches both counter channels (0, and 1) simultaneously. An array of returned count values is given in the call's data parameter. An array of status values is also returned. The first array element in each case will contain counter channel 0 information, the second array element will contain counter channel 1 information, and so on. Both 8254 counter read calls have reset-on-read flags that allow you to reset the counter values, if desired, after the read operation. Other 8254-based Software calls include the CTR8254Disable call, the CTR8254Enable call, and the CTR8254Measure call. The enable call enables the specified 8254-based counter channel for its configured mode. The counter is reset during the enable process. The disable call disables the counting process for the specified counter channel, the counter in this case is not reset. These two calls essentially act as the gate input control for the counter channel you indicate. 3.7.4 Frequency Measurement The CTR8254Measure call allows you to read the frequency of an input signal to a specified precision, using an 8254 general purpose counter channel and a Rate Generator channel in combination. A Rate Generator channel is used as the time base for the measurement. The output of the selected Rate Generator must be connected to the gate input of the selected counter, and the input signal to be measured must be connected to the clock input of the selected counter. The gatetime parameter of the CTR8254Measure call is used to specify the gate period, in msec, to be used for the frequency measurement. Allowed values are 1, 10, 100, 1000, and 10000 msec. The result of the floating point frequency measurement is returned in the frequency parameter. The data value is returned in units of Hz. A status word is also returned, indicating whether a counter overflow condition has occurred. 3-27 Chapter 3: General Programming Procedures The practical limits of the measurement on an 8254 counter are from about 1 Hz to about 8 MHz. The counter channel and Rate Generator channel are automatically configured and enabled appropriately by the software. Any previous configuration information is lost. The counter channel must also be hardware configured for an externally controlled gate (see the Module's manual for jumper details). The instruction requires a specific set up of the hardware as follows: [1] Using a connection at a termination panel, connect the Rate Generator output to the GATE input of the counter channel selected to make the measurement. [2] The signal whose frequency is to be measured must be connected to the CLOCK input of the counter channel selected. [3] The counter channel must be jumpered for hardware-gated operation (see the appropriate hardware manual for the proper jumper selections). [4] The signal to be measured must be conditioned to be TTL compatible, or damage to the hardware may occur. The rise and fall times of the signal should not exceed 25 nsec. 3.7.5 Using a Counter Channel as a DMA Pacer and/or Trigger The calls DMASetPacer and DMASetTrigger allow you to specify a counter channel as a pacer for DMA data acquisition, or as a trigger source. DMASetPacer and DMASetTrigger specify the pacer and trigger sources for a DMA data acquisition (Section 3.3 and Section 3.9 offer general information on the use of pacers, triggers and DMA processes). For example, to designate a PCI-20007M-1 counter output as a pacer or a trigger signal source, specify "CTR8254_TYPE" in the i/otype parameters of the above calls (see Chapter 4 for more information on these and other call parameters). The pacer or trigger signal (from the counter output) must be properly routed to its destination. If the signal can be directed to its destination via the Board's or Carrier's Synchronization Bus, the SYNCConfigure call may be used to route the signal to its final destination. 3.7.6 8254-Based Counter Programming Procedures Steps for programming counters and reading count values are provided below. Information on each of the calls, including a description, the syntax, and a parameter list is provided in Chapter 4. Note, CTR8254Configure automatically disables the counter, thus, you need not call CTR8254Disable prior to configuring the channel. Programming/Reading a Single Counter For single channel counter programming and reading, use the CTR8254Configure, CTR8254Enable, and CTR8254Read calls. 3-28 [1] Initialize your system (see Section 3.2 on Initialization for more information on these functions). [2] Call CTR8254Configure to select the counter channel, mode, and initial count value. [3] Call CTR8254Enable to start the selected counter for its programmed mode. [4] If you want to read a count value, call CTR8254Read to read the counter value and the counter status to check for valid counter data. Chapter 3: General Programming Procedures Programming/Reading All Counters on a Module For programming and reading all 8254-based counters on a device, the calls CTR8254Configure, CTR8254Enable, and CTR8254ReadGroup are used. [1] Initialize your system (see Section 3.2 on Initialization for more information on these functions). [2] Call CTR8254Configure for each counter channel to select the counter modes, and initial count values. [3] Call CTR8254Enable for each counter to start each counter for its programmed mode. [4] Call CTR8254ReadGroup to read all counter values and statuses. Check the status array for valid counter data. 3-29 Chapter 3: General Programming Procedures 3.8 Digital Input/Output The Master Link Software Libraries support all PCI-20000 Series devices with digital I/O capability. These devices are: PCI-20501C Series High-Performance EISA Boards PCI-20098C Series Multifunction Boards PCI-20041C Series High-Performance Carriers PCI-20001C-2 General Purpose Carrier with Digital I/O PCI-20087W-1 Digital Input/Output Board PCI-20377W-1 Low Power Multifunction Board PCI-20378W Series High-Density Digital I/O Boards PCI-20428W Series Multifunction Boards PCI-20004M-1 Digital Input/Output Module. IMPORTANT NOTE: The Win32 Master Link drivers do not support the PCI-20501C Series EISA Boards. 3.8.1 Digital I/O Operations Several library functions are provided for digital I/O operations. Configuration, reading input data, writing output data, and checking the status of a digital I/O port that has been configured for handshake mode can be performed. Through the DIOConfigure call, a specified 8-bit digital I/O port can be configured as an input or an output. In addition, ports on a PCI-20501C, PCI-20098C or a PCI-20087W can be set for digital I/O handshake mode. Direction for digital I/O ports is set in the input parameter of the DIOConfigure call. If input is set to TRUE, the 8-bits of the specified port are configured as inputs, FALSE configures all bits on a port as outputs. The mode for each of the digital I/O ports is set in the handshake parameter of the DIOConfigure call. On initialization, all ports are set up as inputs in basic I/O mode. Note for PCI-20377W and PCI-20428W Board users: Since these boards have one port dedicated for input and one dedicated for output, these digital I/O ports do not need to be explicitly configured using the DIOConfigure call. The PCI-20378W-1 has 30 8-bit digital I/O ports which can be individually configured for input or output operation. The PCI-20378W-3 has 15 8-bit digital I/O ports which can be individually configured for input or output operation. 3.8.2 Basic Digital I/O Basic I/O transfer mode provides simple data input and output operation for each port. No handshaking is used in basic I/O mode; data is simply written to or read from a specific port. Digital I/O reads and writes are performed using the DIORead, DIOReadBit, DIOWrite and DIOWriteBit functions. DIORead and DIOWrite read or write an 8-bit byte from/to an 8-bit digital I/O port. DIOReadBit and DIOWriteBit read or write a single bit from/to a specified digital bit on a digital I/O port. 3.8.4 Handshake Mode Handshake mode is useful for data transfer based on events occurring at different points in time, and uses handshake signals to coordinate the flow of data between the host computer, the digital I/O port, and an external device. 3-30 Chapter 3: General Programming Procedures If the port being read or written is configured for handshake mode, the DIORead and DIOWrite calls wait for the port to be ready to receive or transmit new data before completing the action. In handshake mode, you should be aware that if the port never shows a status of ready, the call will be caught in an infinite loop. When operating in handshake mode, you can call DIOStatus before a DIORead or DIOWrite call to determine that the port is ready (input port full, or output port empty). Please refer to the appropriate hardware manual(s) for input/output timing details and signal connections for digital I/O handshake modes. 3.8.5 Digital I/O Programming Procedures Digital input and output operations can be programmed by following the steps below. Information on each of the digital I/O calls, including a description, format information, and a parameter list, is provided in Chapter 4. Reading a Digital Input Port The procedure for reading a digital I/O port, on any of the supported hardware using the DIOConfigure and DIORead calls (and the DIOStatus call for ports supporting handshake mode) is as follows: [1] Initialize your system (see Section 3.2 on Initialization for more information on these functions). [2] Call DIOConfigure to set the direction of the desired port for input and to configure for basic or handshake mode. If handshake mode is chosen, call DIOStatus as many times as necessary to check for port readiness before proceeding to the next step. (Note: You may want to set up a time-out test condition to avoid an infinite loop if the port never becomes ready.) [3] Call DIORead to read the data from the port. Writing to a Digital Output Port The procedure for writing to a digital I/O port, on any of the supported digital I/O hardware using the DIOConfigure and DIOWrite calls (and the DIOStatus call for ports, supporting handshake mode) is as follows: [1] Initialize your system (see Section 3.2 on Initialization for more information on these functions). [2] Call DIOConfigure to set the direction of the desired port for output and to configure for basic or handshake mode. If handshake mode is chosen, call DIOStatus as many times as necessary to check for port readiness before proceeding to the next step. (Note: You may want to set up a time-out test condition to avoid an infinite loop if the port never becomes ready.) [3] Call DIOWrite to write data to the port. 3-31 Chapter 3: General Programming Procedures 3.9 Direct Memory Access (DMA) Functions Direct Memory Access (DMA) is a hardware controlled data transfer technique that operates in the background. The Master Link Software Libraries functions are used to set up the hardware system (PCI-20000 hardware devices and the host computer). Once the DMA process is started, data is passed between the host computer and Intelligent Instrumentation I/O hardware without software intervention. While the DMA process is running in the background, control may be returned to an unrelated task and other processing may occur in the foreground. This chapter section discusses general purpose input and output DMA operations. PCI-20000 System hardware devices capable of DMA operations include: PCI-20501C Series High-Performance EISA Boards PCI-20098C Series Multifunction Boards PCI-20041C-3A High-Performance Carrier PCI-20377W-1 Low Power Multifunction Board PCI-20428W Series Low Cost Multifunction Boards PCI-20091W-1 High-Speed Analog Input Board IMPORTANT NOTE: The Win32 Master Link drivers do not support the PCI-20501C Series EISA Boards. If you are not familiar with DMA, the following topic (3.9.1) provides background information on the DMA process. For a full introduction to DMA concepts and terms, also read Section 3.9.2. If you want to get right to DMA programming procedures using the Software Library functions go to Section 3.9.3. 3.9.1 Basic DMA Information DMA data transfer is accomplished using the host computer's DMA controller in conjunction with a Board's DMA controller. Upon a DMA transfer request (from the Board) the host's DMA controller needs to know where in memory the data is to go, or come from, (called the "buffer address") and how much data is to be transferred (called the "byte count"). When the host controller processes a DMA request, it "steals" a bus cycle from the processor, issues the current buffer address to memory, and sends an acknowledge signal to the requesting device so that it can transfer data to/from memory. The host DMA controller then increments the buffer address and decrements the byte count for the next request. Hardware Specific Notes Each PCI-20501C Series High-Performance EISA Board (DOS and Windows 3.x applications only) provides a general purpose DMA channel for transferring mixed data types to and from host computer memory. The PCI20501C-1 High-Performance Multifunction Board provides an additional DMA channel for transferring analog input data from its on-board A/D to the host. The PCI-20501C-1 can concurrently transfer both analog input data and general purpose output data under DMA control. DMA processes on each Board can be configured to stop after a specified number of transfers (called a "terminal count") or after a post-trigger delay (after a trigger is detected, a specified number of transfers are made before the process stops). Each PCI-20098C Series Multifunction Board, the PCI-20091W High-Speed Analog Input Board, the PCI20377W Low Power Multifunction Board and the PCI-20428W Series Low Cost Multifunction Board provides a DMA channel for transferring analog input data from its on-board A/D circuit to the host computer. The PCI-20041C-3A supports general purpose DMA input and output processes. The following sections tell you how to acquire input data or transfer output data under DMA control, using the Master Link Software Libraries. 3-32 Chapter 3: General Programming Procedures 3.9.2 Planning a DMA Process Before programming any DMA process you will need to consider several general questions: 1. 2. 3. 4. What input devices and channels (or output ports/channels for an output transfer) can I access? How will transfers be regulated (i.e. at what rate), and how will the process be started and stopped? Where in memory will transfer data be located, and how much memory will be needed? How will the data be retrieved after an input process, or stored prior to an output process? Once you have made determinations on the above questions, it is a relatively simple matter to program and execute a DMA process using the Software Libraries. The following sections detail steps you can follow to answer the above questions, and the options available to you in each category. The DMA Transfer List I/O Channels and Types To set up a "DMA transfer list", you specify the expansion slot, module position, I/O type, and channel number of where data is to be input or output to the DMAConfigureList function call. If you are going to perform analog input DMA list, you must also specify the analog input channels in the AIConfigureList call. AIConfigureList is also used to set gain, range and other parameters for analog input channels. Up to 128 elements may entered in the list. Note: If you need to mix analog input and other input data types (digital I/O or counter) for a single DMA process you must use a PCI-20501C Series Board or a PCI-20041C-3A Carrier. Valid I/O Channels/Types This section discusses the I/O channels and types that may be involved in a DMA transfer. There are several reasons for specifying different I/O types in a general purpose DMA list. First, the length of the data varies with the I/O device used - I/O type information is needed to inform the DMA controller of the size of particular I/O transfer. In addition, this information is used by the Master Link Software to help you determine the amount of storage required for setting-up a DMA buffer. Lastly, the I/O type (input or output) determines the direction of the DMA transfer. All entries on a list must be of the same directional type for a single DMA process. Available input/output channels and types, and ways you can use them are given below. They are listed using the Software Libraries constant names used for specifying I/O types in the DMAConfigureList call's list parameter. AI_TYPE = Analog Input Analog Input data can come from a PCI-20501C-1's on-board A/D, a PCI-20098C's A/D, or any Analog Input Module (except the PCI-20002M) installed on a PCI-20041C-3A Carrier or a PCI-20501C Series Board. A/D data from the PCI-20377W, PCI-20428W and the PCI20091W is also supported. Data from only one A/D device may be gathered in a single DMA process - channels associated to only one A/D may be entered in the list. These channels may be on an expander device (i.e. a PCI-20031M Expander Module) connected to the A/D device. When using a PCI-20501C Series Board for analog input DMA, DMAConfigureList's groupAI flag must be set to "1" (TRUE). For the PCI-20098C, PCI-20041C-3A, PCI20377W, PCI-20428W and the PCI-20091W, DMAConfigureList's groupAI flag must be set to "0" (FALSE). For the PCI-20377W, channels must be listed in consecutive order from the first desired channel in the list to the last channel in the list. For the PCI-20428W, channels must be listed in consecutive order from channel 0 to the last desired channel in the list. For an input transfer involving mixed types, (PCI-20501C Series Boards and PCI-20041C-3A Carrier) all analog input list elements must be grouped together and should be the first items in the list. 3-33 Chapter 3: General Programming Procedures AO_TYPE = Analog Output Data can be sent to any of the Analog Output Module's channels listed in Section 3.4 "Analog Output". Analog waveform generation is possible with analog output DMA. PCI-20428W-1 and -2 models each have 2 independent analog output channels supporting DMA. To perform analog output DMA using a PCI-20501C Series Board or a PCI-20041C-3A Carrier requires that an Analog Output Module be installed on the Board/Carrier. CTR8254_TYPE = 8254-Based Counter count data This is an Input type only. Count data from a PCI-20007M-1A Counter/Timer/Rate Generator Module may be gathered by DMA (see Section 3.7 "Counters, 8254-Based"). To perform DMA operations, the Counter Module must be used on a PCI-20501C Series Board or PCI20041C-3A Carrier. CTR_TYPE = Counter count data This is an Input type only. For DMA purposes, this type only refers to count data from any of a PCI-20501C's on-board counter channels (see Section 3.6). Note: The Win32 Master Link drivers do not support the PCI-20501C Series EISA Boards. DIO_TYPE = Digital Input or Output Input or Output sense depends on the direction for which the specified digital port has been configured. Digital I/O DMA requires a PCI-20501C Series Board or PCI-20041C-3A Carrier. The Digital I/O port must not be configured for handshake mode (see Section 3.8). Pacers, Start/Stop Modes and Triggers DMA transfers are regulated by pacing signals. For every occurrence of the pacer signal (i.e. a pulse) one or more DMA transfers take place. For example, if a pacing source is a steady stream of evenly spaced pulses, the sampling rate of an analog input data acquisition is determined by the pacer's pulse frequency. Similarly, the frequency of a digitally generated analog output waveform can be determined by a pacer's pulse rate in a DMA analog output application. DMA Pacing signals can come from a variety of sources. In most cases, you will use a signal available from an on-board signal generator function, or one from an installed I/O Module. In any case, a DMA pacer signal of some kind will need to be connected through the Board's or Carrier's Synchronization Bus to the Board's DMA pacer input. In most instances the interconnection can be established by software - using the SYNCConfigure function call. (Note, the DMA Pacer Input is designated SYNC_DMA_PACER in the SYNCConfigure call's target list). Some possible pacer sources you may select via the SYNCConfigure call are: BURST GENERATOR OUTPUT - from a PCI-20501C or a PCI-20098C on-board Burst Generator COUNTER 1 OUTPUT or COUNTER 0 OUTPUT - from the on-board counter outputs on a PCI-20501C or a PCI-20098C EXTERNAL INTERRUPT - from the digital signal connector on a PCI-20501C, a PCI-20098C, a PCI-20377W, a PCI-20428W or from the External Interrupt connector on a PCI-20041C-3A. EXTERNAL SYNC OUT - from an inter-board input bus on a PCI-20501C Board, or an inter-carrier connector on a PCI-20041C-3A Carrier MODULE 1 SYNC OUT - from module position 1 SYNC OUT line MODULE 2 SYNC OUT - from module position 2 SYNC OUT line MODULE 3 SYNC OUT - from module position 3 SYNC OUT line A/D BUSY - from the on-board A/D converter of a PCI-20501C-1 RATE GENERATOR OUTPUT - from the Rate Generator on-board a PCI-20377W Board, a PCI20428W Board or a PCI-20041C-3A Carrier. SOFTWARE INTERRUPT - generated from a software command (SoftInt) 3-34 Chapter 3: General Programming Procedures These sources, as well as all signal sources that may be selected, are described in more detail in the Synchronization Bus section (3.12) and under the SYNCConfigure call description in Chapter 4. Analog Input In general, the DMA pacer source you choose from the above list will depend on the transfer application. Some examples: When using a PCI-20501C-1 in data acquisitions involving analog input data, you will need to connect the A/D Busy signal from the A/D device to the DMA pacer input, SYNC_DMA_PACER (using SYNCConfigure). For a PCI-20098C Board or a PCI-20377W Board, you will need to connect your pacer source to the on-board A/D Start Convert input (a PCI-20098C's or a PCI-20377W's A/D "data ready" line is internally connected to the unit's DMA pacer input). If data from an Analog Input Module's A/D is required, you need to connect it's SYNC OUT line (which is the A/D Module's A/D Busy) to the DMA pacer input, SYNC_DMA_PACER (using SYNCConfigure), on a PCI-20501C Series Board or a PCI-20041C-3A Carrier. Note that the data from an A/D Module installed on a PCI-20098C cannot transferred via DMA. For the PCI-20428W, the DMASetPacer function must be used to identify the pacer source (the SYNCConfigure call is not used in this case). The PCI-20428W allows one of two pacer signal sources; the on-board Analog Input Rate Generator, or the External Input. The Analog Input Rate Generator must be disabled if the External Input is used as the pacer. Also, if the DMA Start on Trigger mode is selected (see topic “Start/Stop Modes and Triggers” given later in this section), the External Input acts as a trigger input for starting the DMA process, and cannot be used as a pacer. NOTE: Remember that only data from a single A/D may be transferred in a single DMA process. You can, however, gather data from multiple A/Ds through multiple DMA processes. In most cases (except mixed I/O transfers), data from one analog input channel is acquired for each pacer pulse. Thus, if a steady pulse stream is chosen to drive an A/D's Start Convert input, the sampling rate of the analog DMA acquisition is determined by the pulse rate of that source (up to the throughput capacity of the A/D device and/or your computer's hardware/software configuration). For analog input transfers, the DMA pacer input is connected to the A/D Busy line or data ready line. Thus, you should identify the signal source driving the A/D's Start Convert input (usually a Rate Generator or Burst Generator channel) as the DMA pacer in the DMASetPacer call. If the pacer source defined in the DMASetPacer call is one of those listed on the previous page, DMA transfer will begin upon the first occurrence of the specified pacer signal following the issuance of a DMAStart call. Analog Input (only) DMA procedures are discussed in detail in Section 3.3. 3-35 Chapter 3: General Programming Procedures Mixed I/O Types Mixed I/O type (analog input, digital input, or analog output, digital output, etc.) DMA data transfers are supported by the PCI-20501C Series High-Performance EISA Boards and the PCI-20041C-3A High-Performance Carrier. Note: The Win32 Master Link drivers do not support the PCI-20501C Series EISA Boards. When a DMA transfer is performed using mixed I/O types, the data transferred per DMA pacer pulse depends on whether or not analog input channels are present in the DMA transfer list. The three possible mixed I/O cases are: 1. An input transfer with analog input types and other input types on the list. 2. An input transfer with no analog input types on the list. 3. An output transfer. Data transfer is different when multiple analog inputs are involved because analog input channels are multiplexed to a central A/D input. Since only one A/D is used, data from only one channel may be converted per pacer pulse. For most Analog Input devices, on-board analog multiplexers are advanced to the next channel on the analog input list (specified in the AIConfigureList call) shortly after each A/D Start Convert pulse. So to acquire analog data from every analog input channel in the list, at least one pacer pulse per analog channel is needed. Other I/O types do not operate under this requirement - data transfer is assumed to be valid at any time. This means that data from contiguous non-analog input channels on the DMA list can be transferred as the result of a single DMA pacer pulse. Start/Stop Modes and Triggers You will have to decide by what means you are going to initiate and terminate the transfer. The start and stop method may involve a trigger signal. When a trigger signal is used, the transfer is termed a "Trigger Mode" DMA process. Trigger Mode uses a "circular data buffer" construct as described later. Start and stop modes are defined by the start and stop, and startdelay and stopdelay parameters of the DMAConfigureList call. The valid start/stop combinations for each hardware device supporting DMA transfer processes are tabulated below. PCI-20501C Series High-Performance EISA Boards (Input and Output Modes) START MODE STOP MODE Start on Command Start on Command Stop on Trigger (after delay) Stop on Terminal Count PCI-20098C Series Multifunction Boards (Analog Input DMA only) 3-36 START MODE STOP MODE Start on Command Start on Command Start on Command Stop on Trigger (after delay) Stop on Command Stop on Terminal Count Chapter 3: General Programming Procedures PCI-20041C-3A High-Performance Carriers (Input and Output Modes) START MODE STOP MODE Start on Trigger (after delay) Start on Command Start on Command Start on Command Stop on Command (DMA output processes only) Stop on Command Stop on Trigger (after delay) Stop on Terminal Count PCI-20377W-1 Low Power Multifunction Board (Analog Input DMA only) START MODE STOP MODE Start on Command Start on Command Stop on Command Stop on Terminal Count PCI-20428W Low Cost Multifunction Board (Analog Input DMA Modes) START MODE STOP MODE Start on Command Start on Command Start on Trigger (no delay) Start on Trigger (no delay) Stop on Terminal Count Stop on Command Stop on Terminal Count Stop on Command PCI-20428W Low Cost Multifunction Board (Analog Output DMA Modes) START MODE STOP MODE Start on Command Start on Command Stop on Terminal Count Stop on Command PCI-20091W-1 High-Speed Analog Input Board (Analog Input DMA only) START MODE STOP MODE Start on Command Stop on Command Start on Command Stop on Trigger (after delay) Start on Command Stop on Terminal Count Note: In all cases, the command to enable the DMA process is DMAStart. For Stop on Command modes, the command to stop the DMA process is DMAStop. Each of the supported start/stop mode combinations are explained in the following paragraphs. Start on Command - Stop on Trigger (after delay) - also known as “Trigger Mode” This mode is particularly useful in analog input data acquisitions. However the concept may be extended to mixed I/O types. The analog input case is examined in the following paragraphs. In some cases, it may be useful to continuously collect data until the occurrence of some event, and possibly some number of samples beyond that event. An example of this application would be the monitoring of an alarm. When the alarm occurs, data both up to the point of the alarm and after the point of the alarm would be required for analysis. An excellent way to handle this type of acquisition is to use a "Trigger Mode" acquisition, and a "circular buffer". The triggering function provides the capability of terminating the acquisition in process after the receipt of some external trigger signal. After receipt of the external trigger signal, a specified number of additional transfers will be made before the acquisition stops. 3-37 Chapter 3: General Programming Procedures The number of post-trigger transfers is specified in the stopdelay parameter of the DMAConfigureList call. When the acquisition is complete, both pre-trigger and post-trigger data will be available in the acquisition buffer for processing. The timing diagram below (Figure 3.3) illustrates the triggering function. For the purposes of the diagram, assume that 1) there is only one A/D conversion per Pacer tick, 2) there is one channel in the channel list 3) the A/D circuit is configured for single-shot repetition mode (see Section 3.3), and 4) stopdelay in the associated DMAConfigureList call was set to 4. Pacer Trigger A/D Conversions 1 pre-trigger conversions 2 3 4 post-trigger conversions Figure 3.3 Trigger Mode Trigger mode uses a circular buffer, a section of memory conceptually arranged as a "ring". The operation of a circular buffer is diagrammed in Figure 3.4. Associated with this section of memory are two pointers which indicate the oldest and the newest data in the buffer. Data is entered into the buffer, beginning at Oldest Data Pointer, and the Newest Data Pointer advances around the ring, until eventually it reaches the Oldest Data Pointer. Thereafter, the Oldest Data Pointer and the Newest Data Pointer advance together around the buffer "ring", overwriting the oldest data in the buffer, and keeping only the newest data. If Start on Command, Stop on Trigger mode is specified, the Software Libraries will automatically treat the buffer space as a "ring" configuration. (Buffer instructions are discussed in more detail in following sections.) Connecting a Trigger Source. If a PCI-20501C-1's or a PCI-20098C's on-board A/D circuit is used to capture analog input data only, the trigger source should be connected to the on-board A/D trigger input (SYNC_AD_TRIG for PCI-20501C-1, or SYNC_DMA_TRIG for a PCI-20098C) using the SYNCConfigure call. If the acquisition is a mixed I/O type (on a PCI-20501C-1,-2 Board or a PCI-20041C-3A Carrier with Analog Input Module) the trigger source needs to be connected to the DMA controller's trigger input (SYNC_DMA_TRIG) using SYNCConfigure. NOTE: The PCI-20341M-1 Analog Input Module has an External trigger input similar to trigger inputs on the circuits already mentioned. If this Module is used in a DMA trigger mode analog input acquisition, the Module must be installed on a PCI-20501C Series Board or a PCI-20041C-3A Carrier. You should connect the trigger source to the Board's or Carrier's DMA controller trigger input rather than the PCI-20341M's trigger input. After selecting a trigger source, call the DMASetTrigger function. The trigger source you specify to DMASetTrigger will be enabled during a call to DMAStart. 3-38 Chapter 3: General Programming Procedures ACQUISITION DATA OLDEST DATA PTR OLDEST DATA PTR NEWEST DATA PTR UNDEFINED UNDEFINED DATA BUFFER BEFORE ACQUISITION START DATA BUFFER AFTER ACQUISITION START a) b) ACQUISITION DATA ACQUISITION DATA NEWEST DATA PRE-TRIGGER DATA OLDEST DATA PTR OLDEST DATA OLDEST DATA PTR TRIGGER POINT (CALCULATED) N SAMPLES POST-TRIGGER DATA (TRIGGER DELAY) DATA BUFFER AFTER WRAP AROUND DATA BUFFER DECODING c) d) PCI-20098C 855M2611.UMI Figure 3.4 Operation of a Circular Buffer 3-39 Chapter 3: General Programming Procedures Start on Command, Stop on Terminal Count - also known as"Terminal Count Mode". This start and stop mode uses a linear memory buffer - data does not wrap back to the start of the buffer as in a circular arrangement. After the DMA process is started by a call to DMAStart, data is transferred to/from a buffer until a specified number of transfers (terminal count) have been performed. The terminal count value is specified in the clustercount parameter of the DMAConfigureList call. The terminal count value indicates the number of times each channel on the list will be sampled, or for an output process - the number of times data will be sent to each output channel in the list. The number of elements in the channel list must be specified in the count parameter of the DMAConfigureList call. The startdelay and stopdelay parameters of the DMAConfigureList call do not apply in this mode - set them to 0. Start on Trigger (after delay), Stop on Command This start and stop mode is available for the PCI-20041C-3A High-Performance Carrier only, for output transfers only. After the occurrence of a DMA trigger signal, and a specified number of DMA pacer pulses (delay), data will be transferred by each successive DMA pacer pulse until a DMAStop command is issued. This mode also utilizes a "circular buffer" arrangement (as does Start on Command, Stop on Trigger after delay mode). The number of post-trigger DMA pacer pulses that will be ignored prior to transfer is specified in the startdelay parameter of the DMAConfigureList call. Data from the buffer is transferred out (for each DMA pacer pulse) until the stop command (DMAStop) is issued. Please refer to the discussion on Start on Command - Stop on Trigger after delay for more information on circular buffer operation and selecting trigger signals. Start on Trigger (no delay), Stop on Terminal Count This mode applies to the PCI-20428W Series. In this case, the startdelay parameter of the DMAConfigureList call does not apply since the Board does not support the start delay function. When this mode combination is programmed, the DMA process will start after the DMAStart call is issued and when a trigger signal (TTL-level Low-to-High transition) at the PCI-20428W’s External Input occurs. When "Start on Trigger mode" is used, the PCI-20428W’s Analog Input Rate Generator is the only allowed pacer source. Prior to issuing DMAStart, the DMASetPacer function must be used to identify the Analog Input Rate Generator as the pacer source to enable. The process is stopped in the same manner discussed under the "Start on Command - Stop on Terminal Count" description given earlier. Start on Trigger (no delay), Stop on Command This mode applies to the PCI-20428W Series. In this case, the startdelay parameter of the DMAConfigureList call does not apply since the Board does not support the start delay function. When this mode combination is programmed, the DMA process will start after the DMAStart call is issued and when a trigger signal (TTL-level Low-to-High transition) at the External Input occurs as described in the previous paragraph. The process is stopped using the DMAStop call. A circular buffer, described earlier, is also employed to store acquisition data. Start on Command, Stop on Command After a start command (DMAStart) is given, a transfer will be made upon each occurrence of a DMA pacer pulse until a stop command (DMAStop) is issued. 3-40 Chapter 3: General Programming Procedures Like stop on trigger modes, this mode also utilizes a "circular buffer" arrangement. If the transfer was an input acquisition, the data buffer contains the most recently acquired data (up to the size of the data buffer) after the DMA transfer stops. If an output transfer is programmed, data from the buffer is transferred out (for each DMA pacer pulse) until the stop command (DMAStop) is issued. Please refer to the discussion on Start on Command - Stop on Trigger after delay for more information on circular buffer operation. Determining the Amount of Data, and Creating a Buffer You will need to know how much data will be involved in the transfer so a section of memory can be set aside for storing the input or output data. Whenever you prepare a DMA operation, you must allocate buffer memory for this purpose. For example, in an analog input application, the amount of buffer memory required depends on the number of analog input channels you want to read and the number of samples you want to take from each channel. Once you know how much memory you need, you can use the BUFAllocate call to set up a buffer. Alternatively you can allocate your own buffer, or array, for data storage if you prefer. The data involved in one complete "pass" through the DMA channel list is defined as a "cluster". In the DMAConfigureList call, you specify the number of data "clusters" in the clustercount parameter. The clustercount is the same as the number of samples per channel for an input process, or the number of output transfers per channel in an output process. The amount of buffer space you need to allocate is found from the returned value of DMAConfigureList's clustersize parameter multiplied by the clustercount value: Buffer size (bytes) = clustersize x clustercount This value should be entered in the buffersize parameter of the BUFAllocate call. If you are using a PCI-20041C-3A Carrier, you will find that the clustersize value returned by DMAConfigureList for mixed I/O DMA transfer processes will be much larger than you might initially expect. To explain why this is, the transfer methods employed by the PCI-20041C-3A High-Performance Carrier and the PCI-20501C Series High-Performance EISA Boards (which also support mixed I/O DMA) are contrasted below: The PCI-20041C-3A performs DMA in what we term "Frame Mode”. PCI-20501C Boards support what is termed "Group Mode” transfer. Group Mode transfer is significantly more efficient than the earlier-developed Frame Mode technique. What distinguishes the two techniques is the amount of buffer memory required for mixed I/O DMA data transfer. The difference centers around how channel lists containing analog input data are handled. Frame Mode: The following explanation assumes a mixed I/O channel list including analog inputs. In Frame Mode, for each DMA pacer pulse, one analog input reading (AI_TYPE) is transferred along with readings from all non-analog input types on the list. On the next pacer pulse the data from the next analog input channel in the list is transferred - again with all non-analog input data types on the list. The data transferred for each DMA pulse in this mode is termed a "data frame". A cluster in this case is the sum of all data frames that make up a complete transfer of all analog input channels in the list. For example, if 3 analog input channels are on the list and 3 non-analog input channels are on the list, the number of bytes required for a data cluster is the number of bytes required for 3 analog input readings plus the number of bytes required for 9 (i.e. 3 x 3) of the non-analog input readings. Group Mode: The following explanation also assumes a mixed I/O channel list including analog inputs. In Group Mode, the non-analog input data on the list is transferred only when the last analog input channel on the list is read. In this case, a data cluster is equal to the sum of the data represented by the list elements. Group mode only applies to PCI-20501C Series Boards, and is specified by setting DMAConfigureList's groupAI parameter to "1" (TRUE). When programming Group Mode, all of the analog input channels must be listed first in the DMAConfigureList call’s channel list. 3-41 Chapter 3: General Programming Procedures Allocating the Buffer Using the BUFAllocate call you can specify the size of a buffer (in bytes) in conventional or extended memory. As described earlier, the buffer size is specified in the buffersize parameter. For DOS applications, a buffer can be created in conventional or extended memory by setting the XMSflag to "0" (conventional) or to "1" (extended). Note: XMSflag should always be set to "1" for any Windows (3.x, 95, NT) application. The BUFAllocate location parameter allows you to specify where the buffer starts. The options you may specify are: ALLOC_ANYWHERE ALLOC_IN_64K ALLOC_ON_64K ALLOC_NO_LOCK Allocate buffer anywhere Entire buffer inside a 64 kbyte memory page Starting at the boundary of a 64 kbyte memory page For huge (greater than 64 kbyte) DMA processes in Windows applications The second and third choices in the list are for compatibility with IBM PC/XT/AT type machines (which have limitations on where and how large a DMA buffer can be). For EISA Bus machines, these limitations do not apply - even when used with Intelligent Instrumentation ISA type Boards. Specifying ALLOC_ANYWHERE in conventional or extended memory areas will suffice for an EISA application. Please see the BUFAllocate function call description in Chapter 4 for more information on choosing the proper buffer location for ISA applications. Note: The location parameter does apply for Windows NT applications and should be set to ALLOC_NO_LOCK. For DOS based applications, you can locate the buffer in either conventional or extended memory. If you allocate a buffer in conventional memory (0 to 640 kbyte area), the BUFAllocate call returns a pointer to the start of the buffer in the buffer parameter and sets bufferhandle to 0. If you allocate a buffer in extended memory (above 1 Mbyte area), by setting the BUFAllocate XMSflag parameter, the call returns an XMS 2.0-compatible handle in the bufferhandle parameter and sets buffer to 0. In order to allocate a data buffer in extended memory you will need HIMEM.SYS, QEMM, 386Max or a similar extended memory driver (see Appendix B). Whenever you allocate a buffer, you should always deallocate it (with the BUFDeallocate call) before you exit your program. Failing to do so may cause problems with other applications that use these memory areas. Storing and Retrieving Data Several functions are supplied with the Software Libraries to help you locate and decode the input data you have acquired, or encode the data you will output. These are the BUFDecode, BUFEncode and BUFSeek calls. Before using any of these functions, you will need to call the function BUFAttachProcess to associate the buffer with your DMA process. The functions provided by these buffer management calls are explained below. When input data is transferred in a DMA process, you will usually want to decode it since the information is stored without any translation. For analog input DMA acquisitions, the stored data will be in the output format of the particular A/D converter used. For general purpose DMA transfers, the data can be a mix of I/O types (counter, digital I/O, etc.), with their own particular formats. The BUFDecode call is used to translate this data to the form you normally use to specify data in other Software functions. For example, the decoding process will translate analog input data to common analog data format (as returned by the AIRead call), regardless of the A/D's output format. A listing of all data formats for decoded data types are shown in the Software Libraries Function Call Reference (Chapter 4). This decoded data is transferred to a specified destination buffer, or array. 3-42 Chapter 3: General Programming Procedures When decoding data, you may want to use the BUFSeek function to locate specific data clusters within the source buffer for decoding. If you don't "seek", data is returned from the oldest to the newest in successive calls to BUFDecode. A buffer information structure (the info parameter) is passed to BUFSeek and BUFDecode. The buffer information structure is defined in the header file(s) supplied with the software. (See the BUFDecode function call description in Chapter 4 for a complete list and description of reported buffer information.) BUFSeek works by changing the Next Cluster location pointer in the buffer information structure (info). The Next Cluster location is the cluster where the BUFDecode call will begin decoding data. To locate specific clusters of data, you specify a starting reference point in the buffer (in BUFSeek's origin parameter) and the number of clusters (in the count parameter) from that origin you want to move the Next Cluster location pointer. Using origin and count you may locate the Next Cluster pointer to the start of any data cluster. In the BUFSeek call, three options are available to set the "seek" origin; the CURRENT pointer location, the BEGINNING of the buffer, and the END of the buffer. The pointer will be moved by the number of clusters specified in count. CURRENT points to the Next Cluster (which is changed after a call to BUFSeek). END points to the last cluster (newest) in the buffer. BEGINNING points to the first cluster (oldest) in the buffer. To decode data, you specify the source buffer, the destination buffer, and the number of data clusters from the source you want decoded using the BUFDecode call. The call returns the number of data clusters it decoded and updates the Next Cluster pointer (in the buffer information structure). To decode data into your local array, pass a pointer to your structure in destination. NOTE: If DMA is in progress and at least one cluster has been acquired, you may use the BUFDecode call to retrieve this data. If no complete data clusters have been transferred, the BUFDecode parameter xcount returns a value of 0 and an error code. The BUFEncode call performs the inverse function of BUFDecode. It allows you to set up an array of output data in the form used by the Software Library's write functions (such as AOWrite). BUFEncode translates this data to the form actually used by Intelligent Instrument Output hardware devices, and transfers it to a destination buffer. Thus, you need not know hardware specific details to perform an output transfer. Chapter 4 presents more information on the type and forms of data you may encode. As with BUFDecode, you may use the BUFSeek call to locate specific areas within the destination buffer to transfer data via BUFEncode. Note, BUFEncode also uses the same buffer information list as do BUFDecode and BUFSeek. Note: The Master Link Software Libraries also provide the function calls BUFMoveIn and BUFMoveOut. These calls behave in the same way as the BUFEncode and BUFDecode calls do, except no translation from native-format, or vice-versa, is performed. 3-43 Chapter 3: General Programming Procedures 3.9.3 General DMA Programming Procedures This section provides a sequence of instructions showing how to program a general purpose DMA process using the Master Link Software Libraries. Information on each of the software calls, including syntax, a description, a list of parameters and possible values is provided in Chapter 4. IMPORTANT NOTE for Windows Users: If you didn’t do so at installation time, you will need to install one of the following platform-dependent driver files as described in Chapter 2 and in Appendix B: 1. Windows NT : Master Link NT Driver with DMA support, MASTER_NT.SYS. 2. Windows 95: Virtual DMA Device Driver, VDMAD.VXD. 3. Windows 3.x: Virtual DMA Device Driver, PCIVDMAD.386. The essential elements and Software Library calls for performing a general purpose DMA transfer have been presented in the preceding sections. To program a DMA transfer process, you will need to: [1] Initialize your system (see Section 3.2 on Initialization for more information on these functions). [2] Call DMAGetHandle or DMAHugeGetHandle to assign a "processhandle" to the DMA process. The handle is a number returned by the call, you must use this process handle in all subsequent DMA operations. Use DMAHugeGetHandle for Windows applications that require more than 64 kbytes of DMA data. [3] Call DMASetOptions to choose a host computer DMA channel for the transfer. For PCI-20501C Series High-Performance EISA Board applications, specify "automatic channel selection" (DMA_CHANNEL_AUTO). For PCI-20098C Series Multifunction Board applications, specify channel "1". DMA channel “3” is also available for PCI-20098C “F” version models, and later. For PCI-20041C-3A High-Performance Carrier and PCI-20091W-1 Analog Input Board applications, channel "1" is recommended, however, channels 2 or 3 may be alternatively specified. Consult your hardware manual if more information is required. In any case, the value passed must match the jumper setting or the process will not run. For PCI-20377W Boards, you may specify channel "1" or "3". For PCI-20428W Boards, you may specify channel “1” or “3”. The specified DMA channel must match the DMA channel selected through board jumper settings. NOTE: For Windows NT applications, only DMA channels “1” and “3” are supported by Master Link. [4] 3-44 Configure your pacer source. The pacer signal can come from any number of sources, such as an onboard Burst Generator, an on-board Counter channel, a signal generated by an I/O Module, a signal from an inter-board or inter-carrier connector, or an external signal. If needed, please see the appropriate section of this manual and your hardware manual(s) for configuring your chosen pacer signal source. NOTE: Pacer and trigger connection calls are grouped in step [8]. Chapter 3: General Programming Procedures [5] Call DMASetPacer to identify your selected pacer source to the Software. NOTE: If the pacer is a Burst Generator, Counter channel, Rate Generator, Digital I/O port, or a Trigger/Alarm Module, the software will automatically enable the device specified to DMASetPacer when you call DMAStart (step [12]). For no pacer, specify NO_TYPE in DMASetPacer. [6] If you are using a trigger signal, configure your trigger source. As with pacer signals (see [4]), trigger signals can come from a variety of sources. For example, the PCI-20020M Trigger/Alarm Module can generate a trigger signal from an analog threshold detection, or a window comparison. NOTE: Pacer and trigger connection calls are grouped in step [8]. [7] Call DMASetTrigger to identify the trigger source to the Software (see note in step [5]). For no trigger, specify NO_TYPE in DMASetTrigger. [8] Connect your pacer source to the appropriate input(s), or target(s), using the SYNCConfigure call. For example, to connect a Burst Generator output on a PCI-20501C to an Analog Input Module's A/D start convert input, specify the source as SYNC_BG_OUT and the target as SYNC_MOD_X (where X is the module number of the A/D) in SYNCConfigure. In this case you also need to connect the SYNC OUT line of the A/D Module to the Board's DMA controller's pacer input. To do this, specify the source as SYNC_MOD_X (where X is the module number of the A/D) and the target as SYNC_DMA_PACER using the SYNCConfigure call. See the Synchronization Bus section (3.12) and Chapter 4 for more details on sync signals and the SYNConfigure call. If you are using Analog Input Expander or Simultaneous Sample/Hold Modules, you will need to connect a pacer to these devices as well (see the appropriate Module's manual for information on selecting a pacer). If you are using a trigger signal, connect your trigger source to the appropriate input, or target, using the SYNCConfigure call. For example, to connect module position 2's SYNC OUT to the DMA controller's trigger input on a PCI-20501C-1 specify the source as SYNC_MOD_2 and the target as SYNC_AD_TRIG in the SYNCConfigure call. To connect module position 2's SYNC OUT to the DMA controller's trigger input on a PCI-20098C specify the source as SYNC_MOD_2 and the target as SYNC_DMA_TRIG in the SYNCConfigure call. See the Synchronization Bus section (3.12) and Chapter 4 for more details on sync signals and the SYNCConfigure call. [9] If you want to acquire analog input data, call AIConfigureList to: A. Program the analog channel list. The list contains the following data; slot number of the Board, module position number where the channel is located, channel number, input range, gain, and differential or single-ended operation. B. If you are using a PCI-20501C Board or a PCI-20341M Analog Input Module you may select burstmode or single-shot mode (see Section 3.3). For other devices set this parameter to "0". C. Specify the number of list elements in the count parameter. Note: The triggermode and triggerdelay parameters in this call are not used - always set these to "0" (for "FALSE", and 0 delay respectively). Trigger mode and delay are specified through DMAConfigureList for all DMA processes. 3-45 Chapter 3: General Programming Procedures [10] Call DMAConfigureList to: A. Identify the DMA channel list. The list should contain; slot number of the Board, module numbers the I/O devices used (0 specifies on-board function), channel numbers, and the I/O types (see Section 3.9.2). B. Specify the number of channel list elements in count. C. Set the clustercount (number of transfers per channel - see Section 3.9.2). D. Select a start and stop mode, and set the number of trigger stopdelay or startdelay clusters (depending on the start and stop mode you want to use and if the hardware supports start and/or stop delays - PCI-20501C, PCI-20041C, PCI-20098C (stop delay only) ). If you choose stop on terminal count mode, set startdelay and stopdelay to zero. If analog input channels are on the list, you must always set DMAConfigureList's groupAI parameter to 1 ("TRUE") when using a PCI-20501C Board. The groupAI parameter must be 0 ("FALSE") for all other Boards. [11] From the clustersize value returned in the DMAConfigureList call, determine the buffer size you will need (in bytes) from the following: Buffer size (bytes) = clustersize x clustercount Where clustercount is the number of samples per channel you want to acquire (see step [10] ). Call BUFAllocate to allocate a data buffer for receiving your input data or setting up your output buffer. Set the buffersize parameter to the value determined above. You can allocate the buffer in conventional or extended memory (see the BUFAllocate call description, Chapter 4, for more information concerning EISA and ISA restrictions on buffer allocation). The buffer location is returned in the extended memory bufferhandle, and conventional memory buffer pointer parameters. Alternatively, you may allocate your own buffer or array through other means. After allocating the buffer, call BUFAttachProcess to associate your buffer with the DMA process you are performing. You do this by specifying the DMA processhandle, obtained from DMAGetHandle or DMAHugeGetHandle, to BUFAttachProcess's processhandle parameter. You must also identify the buffer's XMS bufferhandle, and conventional memory buffer pointer to the call. If you are performing an output process you may now encode and transfer your source data to the DMA output buffer with the BUFEncode function. 3-46 [12] To start your DMA process call DMAStart. This will enable your pacer source and trigger source (if specified to DMASetPacer or DMASetTrigger). [13] The DMAStatus call can be used to check if the DMA process has finished. Optionally the DMA process can be stopped at any point via the DMAStop call. DMA status and buffer information is also returned after a call to DMAStop. See the DMAStatus call description in Chapter 4 for a list of DMA status conditions, and error information. [14] If you are performing an input process, you may use BUFSeek and BUFDecode to locate, decode and transfer acquired data to a specified destination buffer or array. [15] Before exiting your program, you should deallocate any buffers using the BUFDeallocate call, and "free" any DMA processhandles using the DMAFreeHandle call. Chapter 3: General Programming Procedures 3.10 Interrupts One function call is provided by the Master Link Software Libraries for generating a "software interrupt" (SoftInt). SoftInt may be used to generate interrupts on PCI-20501C Series High-Performance EISA Boards and PCI-20098C Multifunction Boards only. Note: The Win32 Master Link drivers do not support the PCI-20501C Series EISA Boards. A software interrupt signal is generated to the hardware at the specified slot and module positions. This function provides a means of sending a pulse to a specified input line without having to explicitly configure and connect a hardware pulse generating device. The specific input you want to send a pulse to must first be connected to the SYNC_SW_INT source (software interrupt source) using the SYNCConfigure call. The SYNCConfigure call description has a list of all available inputs (targets) you may select from. Note: This function is useful for test and debug purposes, and as an interactive user controlled hardware interface. 3.10.1 Software Interrupt Programming Procedures [1] Call SYNCConfigure to establish a connection between the source SYNC_SW_INT and the desired input (or target). [2] Call SoftInt to generate the interrupt signal. 3-47 Chapter 3: General Programming Procedures 3.11 Rate Generator A Rate Generator provides a source of evenly spaced pulses that can be used in a variety of data acquisition tasks - A/D pacing, DMA pacing, a source of clock pulses for counting and frequency measuring purposes, etc. The Software Libraries support the Rate Generator channels on the following hardware products: PCI-20007M-1A Counter/Timer/Rate Generator PCI-20089W-1 Analog Input Board PCI-20091W-1 High-Speed Analog Input Board PCI-20377W-1 Low Power Multifunction Board (see Section 3.11.2) PCI-20428W Series Low Cost Multifunction Boards(see Section 3.11.2) PCI-20041C High-Performance Carriers* * The Rate Generator circuit on the PCI-20041C Carrier is referred to as a pacer in its hardware manual. 3.11.1 Rate Generator Modes and Operation A Rate Generator channel may be operated in pulse mode or square wave mode to produce a periodic output signal. The time base for the Rate Generator channel is the device's (Module, Board or Carrier) on-board 8 MHz crystal oscillator. In both modes, the Rate Generator's output frequency is the result of dividing the time base frequency by a pair of integers. These integers are specified in the RGConfigure call under the parameters labeled count1 and count2. The output frequency can be computed by the formula: Fout = 8 MHz / (count1*count2) where count1 and count2 are both 16-bit integers greater than or equal to 2, and less than or equal to 65535. From the above formula, the output frequency can range from a maximum of 2 MHz to a minimum of 0.002 Hz. The operating mode of the Rate Generator is determined by the mode parameter of the RGConfigure call. When mode = 2, the Rate Generator is configured for pulse operation. When mode = 3, the Rate Generator is configured for square wave output. In pulse mode, the width of each low portion of the waveform, Tlow, is determined by: Tlow = count1*125 nsec Since the total period is equal to 1/Fout, or (count1*count2)*125 nsec, the width of the high portion of the waveform is the total period minus Tlow: Thigh = (count1*count2)*125 nsec - count1*125 nsec = count1*(count2-1)*125 nsec The following diagram shows pulse and square wave output waveforms. 3-48 Chapter 3: General Programming Procedures PULSE OUTPUT count1*(count2-1)*125 ns count1*125 ns Period = count1*count2*125 ns SQUARE-WAVE OUTPUT Period/2 Period/2 Period = count1*count2*125 ns Figure 3.5 Pulse and Square Wave Output Waveforms 3-49 Chapter 3: General Programming Procedures 3.11.2 PCI-20377W and PCI-20428W 16-Bit Rate Generator Mode The PCI-20377W Low Power Multifunction Board's Rate Generator can be operated in two modes (16-bit or 32bit). A PCI-20428W Series Low Cost Multifunction Board's Analog Input or Analog Output Rate Generator operates in 16-bit mode only. 32-bit Rate Generator mode operates exactly as described in the previous section. In 16-bit mode, the Rate Generator's output frequency is the result of dividing the time base frequency by a single integer (as opposed to two integers). The default mode of the PCI-20377W Board's Rate Generator is 16-bit operation. To select 32-bit operation you must call the SetOptions377 function. For 16-bit operation the integer is specified in the RGConfigure call under the parameter count1 (the count2 parameter is ignored in 16-bit mode). The output frequency can be computed by the formula: Fout = 8 MHz / (count1) where count1 is a 16-bit integer greater than or equal to 2, and less than or equal to 65536. From the above formula, the output frequency can range from a maximum of 4 MHz to a minimum of 122 Hz. The operating mode of the Rate Generator is determined by the mode parameter of the RGConfigure call. When mode = 2, the Rate Generator is configured for pulse operation. When mode = 3, the Rate Generator is configured for square wave output. In pulse mode, the width of the low portion of the waveform, Tlow, is a constant 125 nsec: Tlow = 125 nsec Since the total period is equal to 1/Fout, or count1*125 nsec, the width of the high portion of the waveform is the total period minus Tlow: Thigh = (count1*125 nsec) - 125 nsec For applications in which the Rate Generator is used to pace the PCI-20377W's or the PCI-20428W’s A/D circuit, you will want to configure the 16-bit Rate Generator for pulse (mode = 2) output. The following diagram (Figure 3.6) shows pulse and square wave output waveforms for the 16-bit Rate Generator configuration. 3-50 Chapter 3: General Programming Procedures PULSE OUTPUT (count1*125 ns) -125 ns 125 ns Period = count1*125 ns SQUARE-WAVE OUTPUT Period/2 Period/2 Period = count1*125 ns Figure 3.6 16-Bit Mode Pulse and Square Wave Output Waveforms 3.11.3 Routing the Generator's Output The calls DMASetPacer and DMASetTrigger allow you to specify a Rate Generator channel as a pacer or a trigger source for DMA processes. DMASetPacer and DMASetTrigger specify the pacer and trigger sources that will be enabled during a DMAStart call. The iotype parameters in the above calls allow you to select I/O type "RG_TYPE", Rate Generator, as a signal source. Note: A PCI-20007M's SYNC OUT signal is internally connected to the Module's Rate Generator output. In this case, the SYNCConfigure call may be used to connect the Rate Generator's output to an input available through a PCI-20501C's or a PCI-20098C's Synchronization Bus. Note: The source parameter of the SYNCConfigure call should be SYNC_MOD_X (where X depends on the PCI-20007M's module position) in this case. The SYNCConfigure call can also be used to connect a PCI-20041C-3A or a PCI-20377W Rate Generator output to the DMA pacer input or A/D Start Convert input respectively. The PCI-20089W-1's and PCI-20091W's Rate Generator outputs are routed via hardware jumpers. Rate Generator's are disabled/enabled by means of the RGDisable and RGEnable calls. In order for the RGEnable and RGDisable calls to operate (except the PCI-20377W's or PCI-20428W’s Rate Generator), the device's gate control jumpers must be set for software gate control. This is the factory default configuration. Please consult the appropriate hardware manual for additional jumper information if you have any doubts on these settings. Not that the PCI-20377W Board does not employ software gate control, gate inputs must be externally connected to the proper level(s). 3-51 Chapter 3: General Programming Procedures A utility function, FrequencyToRGCounts, is provided with Master Link which performs conversions between frequencies and counts (passed to rate generators). An iterative process is used to compute the best values for count1 and count2. 3.11.4 Rate Generator Programming Procedures Rate Generator operations can be programmed using the Software Libraries by following the steps outlined below. Detailed information on each of the Rate Generator calls, including a description, call format, and a parameter list is provided in Chapter 4. The procedure for setting up and enabling a Rate Generator channel comprises configuring the Rate Generator mode, frequency and pulsewidth (using RGConfigure), followed by enabling the channel with the RGEnable call. 3-52 [1] Initialize your system (see Section 3.2 on Initialization for more information on these functions). [2] Optionally call FrequencyToRGCounts to obtain count1 and/or count2 value(s) from a frequency value to pass to the RGConfigure call. [3] Call RGConfigure to select the Rate Generator channel, mode, and frequency or pulsewidth duration. [4] Call RGEnable to enable the Rate Generator. [5] To turn off the selected Rate Generator, you can call the RGDisable function. Chapter 3: General Programming Procedures 3.12 Synchronization Bus The Master Link Software Libraries provide a call (SYNCConfigure) which supports Synchronization Bus connections on various PCI-20000 Series devices. This call controls the routing of various signals between onboard function circuits between Boards connected by inter-board/carrier cables, between a Board and it's installed I/O Modules, or between two installed I/O Modules. The purpose of this programmable feature is to provide a software controllable means of interconnecting signals to control data acquisition events. Examples include: starting and stopping a Burst Generator, pacing an A/D converter, "triggering" an acquisition based on an external condition, etc. Connections are programmed in pairs. Each connection pair consists of a source and destination. The "Synchronization Bus" (or just Sync Bus), refers to a group of sources and targets you may interconnect. The SYNCConfigure call supports the following programmable connections: Sync Bus connections on PCI-20501C High-Performance EISA Boards. PCI-20098C Series Multifunction Boards, and the PCI-20377W Low Power Multifunction Board. The PCI-20041C-3A Carrier's DMA controller trigger and pacer (other SYNC Bus connections on this unit use hardware jumpers). Programmable connections internal to PCI-20341M-1 and PCI-20364M-1 Analog Input Modules, and the PCI-20363M-1 Simultaneous Sample/Hold Module. The interrupt connection circuitry on PCI-20378W Series High-Density Digital I/O Boards. 3.12.1 Connection Pairs SYNCConfigure establishes a connection from the specified "SYNC" source to the specified "SYNC" target. Several connection pairs can be made by calling this function for each desired connection pair. A target can be connected to only one source. However, a source can be connected to more than one target. For example, a PCI-20098C Burst Generator output could be connected to the A/D pacer and to a Module's SYNC IN. When a connection is made to a given target, any previously connected source is disconnected from the target prior to connection of the new source. All sources and targets available on supported hardware are listed in the SYNCConfigure call description in Chapter 4, Section 4.5.12. Please refer to that chapter section for details regarding information in the following sections. 3.12.2 Notes on Specifying SYNCConfigure's slot and module Parameters The SYNCConfigure call addresses a particular device by slot and module numbers. Only connection pairs available to the specified device can be referenced in source or target. A Board's or Carrier's Sync Bus is referenced by specifying 0 (zero) in module, an I/O Module in module position 1 is referenced by a specifying a 1 in module, and so on. For example, a PCI-20501C's or PCI-20098C's Sync Bus accesses all on-board function inputs and outputs, and each installed I/O Module's SYNC IN/OUT lines on the I3 Bus (designated SYNC_MOD_1, SYNC_MOD_2, etc.). To control these connections, module must be 0. An I/O Module, on the other hand, can access only its on-board inputs and outputs. Thus, the sources/targets SYNC_MOD_1, SYNC_MOD_2 and SYNC_MOD_3 have no meaning when module is 1, 2, or 3. You can use the following sources or targets when addressing module positions 1, 2, and 3: 3-53 Chapter 3: General Programming Procedures SYNC_MODULE = Module SYNC IN (source) - an I/O Module's own SYNC IN line. SYNC_EXTERNAL = External SYNC IN/OUT (source) - a software selectable external connection on an I/O Module, such as the external pacer input on a PCI-20364M-1 Analog Input Module. SYNC_NONE = None (source) - used to disconnect a previously connected pair. SYNC_MUX_PACER = A/D Expander Pacer (target) - the internal pacer, or channel advance line within a PCI-20363M-1 Simultaneous Sample/Hold Module. SYNC_AD_START = A/D start convert (target) - an Analog Input Module's internal A/D start convert line, such as within a PCI-20341M-1 Analog Input Module. (Note: if module is 0 (zero) this can be a PCI-20501C-1's, a PCI-20098C's on-board, or a PCI-20377W's A/D Start convert input.) 3.12.3 Source/Target Types The following paragraphs provide short descriptions of each Sync Bus type that can specify a source or a target depending on the specific hardware device. SYNC_MODULE. This source/target is used when you want to connect the SYNC IN/OUT line on an I/O Module to something else on the I/O Module. The Module number (1, 2, or 3) is specified in SYNCConfigure's module parameter, so the Module position number associated with the SYNC line is not specified in the constant name. Note, SYNC_MODULE is supported only as a source at this time. (No I/O Modules currently have programmable targets for SYNC IN). SYNC_EXTERNAL. This references an external input or output available only on the device specified by the SYNCConfigure slot and module parameter. This can be a PCI-20501C's SYNC IN/SYNC OUT line (available on the device's inter-board connectors) or an external input on an I/O Module. SYNC_MOD_1, 2 or 3. The I3 Bus Module 1, 2 and 3 SYNC IN/OUT signals on I/O Modules installed in the corresponding module positions. (Please refer to the individual I/O Module's manual for a description of the Module's SYNC IN/OUT signals.) To properly use this source/target, the parameter module must be 0 (zero). SYNC_IRQ_1, 2 or 3. The I3 Bus Module 1, 2 and 3 IRQ IN/OUT signals from I/O Modules installed in the corresponding module positions. (Please refer to the individual I/O Module's manual for a description of the Module's IRQ IN/OUT signals.) To properly use this source/target, the parameter module must be 0 (zero). 3.12.4 Source Types The following paragraphs provide short descriptions of each Sync Bus type that can specify a source only. SYNC_BG_OUT. The Burst Generator output on a PCI-20501C or PCI-20098C Board. This signal is synchronous with the device's 8 MHz clock. See Section 3.5 for information on generating an output from a Burst Generator. The Burst Generator is typically used to pace A/D conversions. SYNC_CTR0_OUT and SYNC_CTR1_OUT. The Counter 1 and Counter 0 Outputs are the output signals from the respective PCI-20501C or PCI-20098C on-board counters when configured for any one of the nonmeasurement modes: event counter, divider, or variable duty-cycle waveform generation. In divider mode, the output will be synchronous with the external clock signal to be divided and will either be continuous or latched. The VDC Generator output will be synchronous either with the Board's 8 MHz clock or the VDC Generator's external clock. (See Section 3.6 for instructions on how to generate an output from these counter channels.) A Counter output may be used to pace A/D conversions. 3-54 Chapter 3: General Programming Procedures SYNC_EXT_INT. The External Interrupt input available on the PCI-20501C's, PCI-20098C's, or the PCI20377W's digital signal connector, or the External Interrupt input on a PCI-20041C's External Interrupt Connector. This input can come from any number of external sources and will most likely be asynchronous with the Board's 8 MHz clock. NOTE: This signal should be active-high with a pulsewidth of at least 250 nsec. SYNC_SW_INT. The Software Interrupt source is synchronous with the host computer's bus clock and will be at least 250 nsec wide. A Software Interrupt can be generated by a call to SoftInt when using a PCI-20501C or PCI20098C Board (see Section 3.10). SYNC_AD_BUSY. The PCI-20501C-1's on-board A/D Busy line. This source is typically connected to the SYNC_DMA_PACER target in mixed-type DMA acquisitions. This connection insures A/D conversion data is available for DMA transfer. SYNC_NONE. No source. Specify this as the source when you want to disconnect a previously established pair. SYNC_RG_OUT. The Rate Generator output on a PCI-20377W Board or a PCI-20041C Carrier. This signal is synchronous with the device's 8 MHz clock. See Section 3.11 for information on generating an output from a Rate Generator. The Rate Generator is typically used to pace A/D conversions. SYNC_AD_DAV. The A/D available flag on a PCI-20377W Board. When this source goes high, it indicates that A/D conversion data is ready. When the source is low, it indicates that the A/D's 16 word FIFO result buffer is empty. This source can be connected to one of the Board's PC Interrupt output lines (SYNC_PC_IRQ2, 3, or 5). This information can be used to notify the PC that analog conversion data is available for use an interruptdriven data acquisition application. SYNC_DMA_TC. The DMA Terminal Count status flag on a PCI-20377W Board. The Terminal Count status is set high during a DMA process when the Terminal Count line on the PC's bus goes active and the selected Device Acknowledge line (DACK) is true. This source can be connected to one of the Board's PC Interrupt output lines (SYNC_PC_IRQ2, 3, or 5). This status is latched when it occurs and is cleared by a write to Offset 01 of the PCI-20377W. When DMA "Stop on Terminal Count" mode is selected (see Section 3.9), the hardware pacing source is disabled when a Terminal Count interrupt occurs and is enabled when the Terminal Count interrupt is cleared. SYNC_EXT_INT_0. This is the external interrupt input available on the auxiliary connector of a PCI-20378W1, or PCI-20378W-3 High-Density Digital I/O Board. SYNC_EXT_INT_1, SYNC_EXT_INT_2 and SYNC_EXT_INT_3. These external interrupt sources refer to connectors P2, P3 and P4 respectively on PCI-20378W-1, -3 Boards. The digital I/O port associated with the interrupt input line must be configured for input operation to function as an interrupt source (see the appropriate board’s manual for connection details). SYNC_EXT_INT_4 and SYNC_EXT_INT_5. These external interrupt sources apply to connectors P5 and P6 respectively on a PCI-20378W-1 Board only. The port associated with the interrupt input line must be configured for input operation to function as an interrupt source (see the appropriate board’s manual for connection details). 3.12.5 Target Types The following paragraphs provide short descriptions of each Sync Bus type that can specify a target only. SYNC_MUX_PACER. The internal pacer input (HOLD line) of a PCI-20363M-1 Simultaneous Sample/Hold Module. This is used as a target when selecting SYNC IN HOLD control or external external input HOLD control for a PCI-20363M-1. 3-55 Chapter 3: General Programming Procedures SYNC_AD_START. The A/D start convert input of a PCI-20501C-1's, a PCI-20098C's, or a PCI-20377W's onboard A/D, or that of a PCI-20341M-1 or PCI-20364M-1 Analog Input Module. SYNC_AD_TRIG. A PCI-20501C-1's on-board A/D trigger input. Probable sources for this target include the External Interrupt input, or a PCI-20020M Trigger/Alarm Module's output. This is used as a target when performing analog input only DMA operations on a PCI-20501C-1 Board. SYNC_DMA_PACER. This is the DMA pacer input on a PCI-20501C Series Board, or a PCI-20041C-3A Carrier. Probable sources for this target include an External Interrupt input, Burst Generator output, or a PCI20007M Rate Generator channel. SYNC_DMA_TRIG. This is the DMA trigger input for a DMA controller on a PCI-20501C Series Board, a PCI-20041C-3A Carrier, or a PCI-20098C Series Board. Probable sources for this target include an External Interrupt input, or a PCI-20020M Trigger/Alarm Module's output. SYNC_BG_START and SYNC_BG_STOP. These targets only apply to PCI-20501C or PCI-20098C Boards. A signal connected to a Burst Generator Start or Burst Generator Stop can be used to start or stop the Burst Generator. A Burst Generator Start signal is used when the Burst Generator has been configured for either sync start and stop or single-shot mode in the BGConfigure call. A Burst Generator Stop signal is used only when the Burst Generator has been configured for Sync start and stop mode. Refer to Chapter 4 for more detailed descriptions of Burst Generator modes. SYNC_DIV0_TRIG and SYNC_DIV1_TRIG. These are the on-board Counter 1 or Counter 0 divider trigger inputs on a PCI-20501C or PCI-20098C Board. The counter(s) in this case must be configured for divider latch mode. The source for the Counter 1 or Counter 0 Divider trigger input triggers (starts) that counter's divider when latched mode has been set in the CTRSetOptions call. SYNC_PC_IRQ0 and SYNC_PC_IRQ1. PC Bus Interrupt Request lines 0 and 1. These are not currently supported by Hardware. SYNC_PC_IRQ2. PC Bus Interrupt Request line 2. This target is available on PCI-20377W and PCI-20378W Boards. For PCI-20377W Boards, this target may be connected to SYNC_AD_DAV, SYNC_DMA_TC, or SYNC_NONE. For the PCI-20378W Series, one of these targets may be paired at a time with the following sources: SYNC_EXT_INT_0 through SYNC_EXT_INT_5, or SYNC_NONE (see the source descriptions given earlier). The priority of the PC interrupt is related to the IRQ Line. IRQ2 is the highest priority interrupt and IRQ5 has the lowest priority. Only one priority of interrupt can be enabled at a time and all of the disabled interrupt lines are tri-stated. SYNC_PC_IRQ3. PC Bus Interrupt Request line 3. This target is available on PCI-20377W and PCI-20378W Boards. For PCI-20377W Boards, this target may be connected to SYNC_AD_DAV, SYNC_DMA_TC, or SYNC_NONE. For the PCI-20378W Series, one of these targets may be paired at a time with the following sources: SYNC_EXT_INT_0 through SYNC_EXT_INT_5, or SYNC_NONE (see the source descriptions given earlier). The priority of the PC interrupt is related to the IRQ Line. IRQ2 is the highest priority interrupt and IRQ5 has the lowest priority. Only one priority of interrupt can be enabled at a time and all of the disabled interrupt lines are tri-stated. SYNC_PC_IRQ4. PC Bus Interrupt Request line 4. This target is available on PCI-20378W Boards only. One of these targets may be paired at a time with the following PCI-20378W sources: SYNC_EXT_INT_0 through SYNC_EXT_INT_5, or SYNC_NONE (see the source descriptions given earlier). The priority of the PC interrupt is related to the IRQ Line. IRQ2 is the highest priority interrupt and IRQ5 has the lowest priority. Only one priority of interrupt can be enabled at a time and all of the disabled interrupt lines are tri-stated. This IRQ is not currently supported by Hardware. 3-56 Chapter 3: General Programming Procedures SYNC_PC_IRQ5. PC Bus Interrupt Request line 5. This target is available on PCI-20377W and PCI-20378W Boards. For PCI-20377W Boards, this target may be connected to SYNC_AD_DAV, SYNC_DMA_TC, or SYNC_NONE. For the PCI-20378W Series, one of these targets may be paired at a time with the following sources: SYNC_EXT_INT_0 through SYNC_EXT_INT_5, or SYNC_NONE (see the source descriptions given earlier). The priority of the PC interrupt is related to the IRQ Line. IRQ2 is the highest priority interrupt and IRQ5 has the lowest priority. Only one priority of interrupt can be enabled at a time and all of the disabled interrupt lines are tri-stated. SYNC_PC_IRQ6 and SYNC_PC_IRQ7. PC Bus Interrupt Request lines 6 and 7. These targets are available on PCI-20378W Boards only. One of these targets may be paired at a time with the following PCI-20378W sources: SYNC_EXT_INT_0 through SYNC_EXT_INT_5, or SYNC_NONE (see the source descriptions given earlier). The priority of the PC interrupt is related to the IRQ Line. IRQ2 is the highest priority interrupt and IRQ5 has the lowest priority. Only one priority of interrupt can be enabled at a time and all of the disabled interrupt lines are tri-stated. 3.12.6 SYNC Bus Programming Procedures Refer to the function call specifications in Chapter 4 for complete parameter, and syntax information. The SYNCConfigure call is shown in various programming procedures throughout this chapter. For example uses of SYNCConfigure, see the programming procedures in Sections 3.3. and 3.9. 3-57 Chapter 3: General Programming Procedures 3.13 Thermocouple Measurement The Master Link Software Libraries support temperature measurement operations with standard J, K, and T type thermocouples, and PCI-5B37 Series J, K, and T type Non-Linearized Thermocouple Signal-Conditioning Blocks. Two functions are provided in the driver library for simplifying thermocouple measurements: TCLinearize and TCMeasure. TCLinearize is a voltage to temperature conversion utility which takes previously acquired thermocouple input data, and Cold-Junction Compensation (CJC) data to produce a linearized and compensated temperature value (in °C). TCMeasure ,on the other hand, incorporates both the analog data acquisition and voltage to temperature conversion functions in one call. The following information discusses function call parameters for making thermocouple measurements. Standard thermocouple measurements, and measurements using PCI-5B37 Signal-Conditioning Blocks are separately addressed. 3.13.1 Standard Thermocouple Inputs TCLinearize If you are using the TCLinearize function to convert analog input data to temperature, analog values are first read in using an analog read function such as AIRead. Thermocouple data must be passed to TCLinearize as a floating point value scaled in units of volts. CJC data must be in units of °C. For example, to properly scale the analog input data, use the CountsToVolts utility function which requires the gain and input range values used in the AIRead operation to convert the returned common analog data format value to voltage (see Chapter 4). According to the thermocouple specified in the type parameter, TCLinearize uses this data to return the correct thermocouple junction temperature in °C. TCMeasure When using the TCMeasure function, analog data is read in from specified thermocouple and CJC channels, and an optional zero-reference channel on the same Analog Input device. The zero-reference channel is used to compensate for input offset errors on the A/D. The input data is converted by TCMeasure into a °C temperature value and returned in the temperature parameter according to the thermocouple type you specify in type. The preferred input range is ±5 V. Specify the range code BIPOLAR_10 in the range parameter of TCMeasure. The CJC channel should be connected to a device which reports reference-junction temperature at 1 mV per degree Kelvin. For example, the PCI-20303T-2 Thermocouple Termination Panel has a built-in CJC sensing channel that supplies a 1 mV/°K output characteristic on channel 0. If an auto-zero reference channel is specified, it will be used to correct the thermocouple input prior to the linearization and compensation. Specify AI_NO_ZERO in the zchannel parameter for no auto-zero correction, otherwise specify the zero channel number (the inputs of this channel should be grounded). Note, the PCI20098C Series and PCI-20377W Multifunction Boards have built-in zero-reference functions that do not require the use of an analog input channel. To use this feature, specify AI_HW_ZERO in the call's zchannel parameter. Certain gain requirements and range jumper settings may also apply to your hardware configuration as mentioned in Chapter 4, Section 4.5.13. 3-58 Chapter 3: General Programming Procedures 3.13.3 Using PCI-5B37 Thermocouple Signal-Conditioning Blocks TCLinearize To use PCI-5B37 Series Non-Linearized Thermocouple Signal-Conditioning Blocks with TCLinearize, simply invoke the TCLinearize function to "post-process" the data acquired through an analog read function. When reading data from the PCI-5B37 Block, the analog input function (A/D) should be configured for a gain of 1, and an input range of 0 to +5 V or ±5 V and single-ended operation. PCI-5B37 Blocks have built-in CJC. To process the acquired data, you must set the cjctemp parameter to 0.0 (°C) in the TClinearize call and set the call’s type parameter to the correct 5B37 type. PCI-5B37J, K and T Non-Linearized Thermocouple Signal Conditioning Blocks output 0 to 5 V for their specified temperature ranges (see the type parameter below). After reading the Block’s voltage with an AIRead call, use the CountsToVolts utility function to convert the returned common analog counts value to voltage The equations to scale the voltage (Vout) from each Block to obtain the actual thermocouple voltage for the volts parameter of TCLinearize are given below: PCI-5B37J: volts = 5.00*(Vout/105.14) - 4.632 mV PCI-5B37K: volts = 5.00*(Vout/86.69) - 3.553 mV PCI-5B37T: volts = 5.00*(Vout/206.21) - 3.378 mV According to voltage value and the thermocouple specified in the type parameter, TCLinearize returns the correct thermocouple junction temperature in °C. TCMeasure When using the TCMeasure function to read PCI-5B37 Series Non-Linearized Thermocouple SignalConditioning Blocks, set the call’s type parameter to the correct 5B37 type and set the cjcchannel parameter to TC_NO_CJC for no CJC. The input hardware must be configured for single-ended input operation, an input range of ±5 V and a gain of 1. The call will automatically configure the hardware accordingly, unless the hardware requires jumper settings for configuration. The analog input data is converted by TCMeasure into a °C temperature value and returned in the temperature parameter according to the thermocouple type you specify in type. 3.13.4 Thermocouple Measurement Programming Procedures Programming procedures for thermocouple measurement operations are given below. Information on all referenced calls can be found in Chapter 4. Thermocouple Data Conversion with TCLinearize Data is acquired in the same manner as with standard single channel analog data acquisition (see Section 3.3.1). After proper scaling, the TCLinearize call is used to convert the voltage and CJC values to a temperature. [1] Initialize your system (see Section 3.2 on Initialization for more information on these functions). [2] Call AIRead with the desired settings for gain, input range, and the choice of single-ended or differential operation for the thermocouple and CJC channels. [3] Perform any necessary scaling of the analog input data to get the thermocouple's voltage value and the CJC temerature value in °C. 3-59 Chapter 3: General Programming Procedures [4] Call TCLinearize - pass the thermocouple voltage value in volts, the CJC temperature in cjctemp and the thermocouple type in type. The temperature of the thermocouple tip in °C is returned in temperature. Thermocouple Measurement Using TCMeasure TCMeasure incorporates both the analog data acquisition and voltage to temperature conversion functions in one call. Only one function call is required. 3-60 [1] Initialize your system (see Section 3.2 on Initialization for more information on these functions). [2] Call TCMeasure with the proper settings for input range and thermocouple type. (The CJC and thermocouple channels must have external signal-conditioning if the A/D's gain is not software programmable.) The temperature in °C is returned in temperature. Chapter 3: General Programming Procedures 3.14 Trigger Operations The Master Link Software Libraries contain four function calls for programming the PCI-20020M-1 Trigger/Alarm Module. The PCI-20020M-1 Trigger/Alarm Module can monitor an analog channel, and will generate a digital output when pre-programmed conditions are satisfied. Thresholds in the range of ±10V can be programmed with 8-bit resolution. A trigger output level can be set when the analog input is inside, or outside, of the specified low-level and high-level thresholds. 3.14.1 Operational Information The PCI-20020M-1 Trigger/Alarm Module can be configured to respond to various analog input conditions. The TRIGConfigure function is used to configure the PCI-20020M Trigger/Alarm Module as window comparator to detect when the analog input is inside or outside of the specified low and high voltage thresholds. The triggering mode (inside or outside a threshold window) is set in the mode parameter. Note, both of the Module's analog inputs must be jumpered together to act as single input for a voltage window comparison. Once the trigger threshold has been crossed, the trigger output stays latched until a TRIGDisable call is made. To detect another threshold crossing the trigger channel can be re-enabled by a TRIGEnable call. The TRIGStatus call is used to return the status of the given trigger channel's input comparators. The analog input range of the PCI-20020M Trigger/Alarm Module module is ±10V. With 8-Bit (78mV) resolution, the module can compare the analog input to programmable values ranging from -10.0 V to +9.92 V. Please see the Module's instruction manual for selecting trigger output jumper options. The data values corresponding to the high or low ends of the trigger channel's voltage window are specified in the format shown below. The data value (decimal) for a high or low alarm limit is specified using Bipolar analog common data format. You can calculate the data value by the following: data value =(threshold/10.0)*32768.0 Where the threshold value is in volts. The resulting value should be rounded to an integer. The low and high limit comparators have 8-bit resolution. Each Bit corresponds to approximately 78 mV. This is the smallest voltage increment that may actually be detected. Alternatively, Master Link provides a utility function (VoltsToCounts) which converts voltage data to count data suitable for input to the TRIGConfigure function. The call determines the correct count value for a specified voltage value based on the voltage range you specify. 3.14.2 Analog Trigger Programming Procedures The programming procedure for setting up a trigger/alarm channel to generate a trigger signal is shown below. The description, syntax information, and parameter list for each of the calls is provided in Chapter 4. To program a PCI-20020M-1 Module to generate a trigger signal, use the TRIGConfigure, TRIGEnable, TRIGDisable, and TRIGStatus calls. [1] Initialize your system (see Section 3.2 on Initialization for more information on these functions). [2] Optionally, call VoltsToCounts to obtain count data from specified voltage values for input to the TRIGConfigure call’s window thresholds. 3-61 Chapter 3: General Programming Procedures 3-62 [3] Call TRIGConfigure to specify the trigger window thresholds and mode. [4] Call TRIGEnable to enable detection of the trigger condition. [5] Call TRIGStatus to determine if any channels are in the alarm state. [6] To reset a trigger channel that has detected an alarm condition (and is thus latched), first disable the channel with TRIGDisable then re-enable it with TRIGEnable. Chapter 4: Software Libraries Function Call Reference Chapter 4: Master Link Software Libraries Function Call Reference 4.1 General Information The PCI-20369S and PCI-20485S Master Link Software Libraries and associated language interface files provide high-level language support for most all Intelligent Instrumentation hardware devices. This includes Data Acquisition Boards/Carriers and plug-in I/O Modules. The library functions allow you to write data acquisition applications programs in the programming language of your choice. PCI-20369S: DOS Language Support • • • • • Borland C++, 4.5 or higher Microsoft C++, 7.0 or higher Borland Turbo Pascal, 6.0 Borland Pascal, 7.0 Microsoft QuickBASIC, 4.5 PCI-20369S: Windows 3.x Language Support • • • • • Borland C++, 4.5 or higher Microsoft C++, 7.0 or higher Microsoft Visual Basic, 4.0 or higher Borland Pascal, 7.0 Borland Turbo Pascal for Windows, 1.5 PCI-20485S: Win32 Language Support • • • Borland C++, 4.5 or higher Microsoft Visual C++, 4.0 or higher Microsoft Visual Basic, 4.0 or higher Chapter 4 covers complete call specifications for the functions provided by the software libraries. All valid function call parameters for supported Intelligent Instrumentation hardware devices are covered in detail. Chapter 4 is organized into the following sections: Section 4.2 Section 4.3 Section 4.4 Section 4.5 A general description of the function call format and some important preliminary notes. Required system configuration summary. A tabular listing of all function calls, organized by function type. Complete function call specifications, organized by functional category. A complete listing of all error and warning codes returned by the function calls are tabulated in the ERRORS.TXT files found in the base directories of the installed driver libraries. 4-1 Chapter 4: Software Libraries Function Call Reference 4.2 General Description and Preliminary Notes This chapter details all function calls available through the PCI-20369S and PCI-20485S Master Link Software Libraries. Calls are listed in functional categories such as initialization, analog input, analog output, digital I/O, etc. The header files supplied with the library files contain information which makes possible the interface between your application program and the functions contained in the libraries. The following sections discuss general features of the function calls such as format, common parameters, and common data types. 4.2.1 Call Format The library routines are accessed through simple function calls from all supported languages. For the purpose of consistency, all function call specifications are presented using a C function as follows: int FunctionName (parameter, parameter, ...) For verification purposes, all functions return an integer value which represents an error code. (For your reference, all error codes and their meanings are listed in the ERRORS.TXT files.) If the operation performed by the function was completely successful, the returned value will be 0 (zero). If an error occurred, a positive error code value will be returned. If a function call wishes to inform you of some possible, but not definite error condition, it may return a negative warning code value. A listing of the function calls, showing call formats for all supported languages, is given at the beginning of each functional category in section 4.5. Function names should be entered into your application program exactly as indicated in the above example. All parameters are shown in the order in which they should be passed. As explained in the next section, each parameter is assigned a data type that identifies its input or output format and/or structure. 4.2.2 Common Call Parameters and Data Types Several common parameters appear in most function calls. These are the slot, module position number, and channel or port (in the case of digital I/O) to which the call is directed. Some examples: 1. An AIRead(..) call is to be used to read an analog input value from channel 7 of an Analog Input Module installed in module position 3 of a Board in expansion slot number 2. The AIRead(..) call's slot parameter should be 2, the module parameter should be 3, and the channel parameter should be 7. 2. If digital input port 0 on a Digital I/O Module installed in position 2 of a Board in slot 3 is to be read the slot parameter should be 3, module should be 2, and port should be 0 in a DIORead(..) call. Rules for determining valid slot, module, and channel/port parameters values follow. 4-2 Chapter 4: Software Libraries Function Call Reference The Slot Parameter Slot refers to the expansion slot number at which the call is directed. The range of legal slot numbers that can be passed in the slot parameter is 1 to 31. For Extended Industry Standard Architecture (EISA) Boards, legal values for the slot parameter are 1 to 15. Slot 0 is reserved for the host computer's motherboard. NOTE: EISA Bus boards, such as the PCI-20501C Series, are not supported under Win32 environments. For Industry Standard Architecture (ISA) Boards, such as the PCI-20098C Series, we recommend that you use slot numbers 16 to 31. This will avoid any possible conflict between installed EISA and ISA Boards in your system. If you use Intelligent Instrumentation ISA Boards in your system, the slot number of the device must be assigned through the SlotAssign or SlotAssignIO function call depending on whether the device is designed to be addressed through the memory-map or the I/O-map. EISA Bus computers address expansion cards by the geographical position of the expansion slot. Expansion slot numbers are clearly marked on the EISA backplane. Note, ISA Bus computers do not specifically address devices by expansion slot position as EISA Bus computers do. So the slot to which an ISA Board is assigned may be chosen arbitrarily (within the guidelines specified above). The Module Parameter Module refers to the module position at which the call is directed: Module position 0 always refers to a built-in function (such as a counter) on a Carrier or Board. Module positions 1, 2, or 3 always refer to I/O Modules (such as Analog Input or Analog Output Modules) installed in a Board or Carrier. Legal values for module always follow the above rules for Intelligent Instrumentation hardware supported by the Software Libraries. It should be noted that certain restrictions on I/O Module positioning may apply depending on the hardware functions you require. Please refer the appropriate hardware manual(s) for information on which board connectors I/O Modules should be inserted. The Channel/Port Parameters For analog input/output, burst generator, counter, and rate generator calls, the channel parameter refers to the channel on the Carrier, Board or Module at which the function call is directed. For digital I/O calls, this is the port parameter. Legal values in most cases are simply determined by the number of channels/ports available on the device. Some examples: 1. The PCI-20023M High-Speed Analog Input Module has 8 available single-ended input channels. The legal values for channel in this instance are 0 to 7 (channel numbering always starts at 0 (zero)). 2. If an Analog Input Module can be configured for single-ended or differential input operation, valid channel values for the differential configuration are half that of its single-ended mode. For example, the PCI-20002M Analog Input Module can be configured for 16 single-ended, or 8 differential input channels. In single-ended mode, legal values for channel are 0 to 15. When in differential mode, only values 0 to 7 are legal. There are only a few minor exceptions to the above legal channel value rules depending on the hardware used. These exceptions are noted in individual function call specifications as appropriate. 4-3 Chapter 4: Software Libraries Function Call Reference Data Types In each call specification, every parameter is assigned a data type which indicates the required data format for the parameter, or the format of returned data. Some of these parameters are given common data types, and some require specially defined formats or list structures suited for the data acquisition function at hand. NOTE: One purpose of the interface files provided with the software is to predefine these data types for you when you compile your program. For demonstration purposes, some of the C language data types used in the function call parameter specifications of this chapter are listed below. Most of the call parameters use standard data types like integers, and long integers. Other call parameters use type definitions and structures found in the various interface files supplied with the software package. Detailed explanations of these special types are covered in the applicable call specifications. You may wish to review the definition syntax and rules of use for structured types in your chosen compiler's reference manual. Standard Data Types Used by the Function Calls Name Description int long * indicates a 16-bit integer value (Integer in Turbo Pascal, % in BASIC) indicates a 32-bit integer value (LongInt in Turbo Pascal, & in BASIC) indicates parameter is the address of a data value (var for Turbo Pascal, SEG for QuickBASIC) double precision (Double in Turbo Pascal, # in BASIC) character pointer type* (Pointer in Turbo Pascal, & in BASIC) double char far * *Note for QuickBASIC users: 'char far *' parameter types are replaced by 'long' parameter types, as char *'s do not exist in BASIC. Example Special Data Types Used by the Function Calls Name Description AIListType Configuration data list for automatic channel list sequencing in the AIConfigureList call. Calibration constants and values for a PCI-20364M-1 Module external calibration procedure (in AICalibrate364 call). Format for returned data from a SlotInquire system configuration inquiry call. Cal364Type ModInfoType Analog Input/Output Data Format This section describes how the data values returned by analog input function calls can be converted into the original input voltages which were presented to analog input hardware. It also describes how the data values passed to analog output function calls, and analog trigger functions are translated into voltage. Master Link provides three utility functions CountsToVolts, VoltsToCounts and ExtendedCountsToVolts which you can use to convert A/D counts values returned from analog input functions to floating point voltage values, and to convert floating point voltage values to counts data for use by analog output functions. Therefore, you need not write your own code to implement the conversion equations described below. Except for extended format results from the PCI-20364M-1 High-Accuracy (12/16/18-bit) Analog Input Module, all analog data values are represented by 16-bit numbers. For extended mode, PCI-20364M-1 data is returned as a 32-bit signed integer. 4-4 Chapter 4: Software Libraries Function Call Reference For analog input and output devices configured for BIPOLAR ranges (for example, ±10 V or ±5 V), voltages are represented in 16-bit left-justified two's complement format. The maximum decimal value which can be represented by a 16-bit two's complement number is 32767; the minimum value which can be represented is -32768. The integer data value representing an analog input or output voltage (configured for a bipolar range) is related to the voltage as follows: voltage = (integer data value/(gain * 32768.0)) * full_scale_voltage where full_scale_voltage is the maximum voltage possible given the input or output range. For a ±10 V range, full_scale_voltage is 10 V, for a ±5 V range, full_scale_voltage is 5 V. For analog input and output devices configured for UNIPOLAR ranges (for example, 0-10 V), the voltage is represented by a 16-bit straight binary number (0 - 65535). The voltage in this case is related to the integer data value as follows: voltage = ((integer data value)/(gain * 65535.0))*full_scale_voltage where full_scale_voltage is the maximum voltage possible given the input or output range. For a 0-10 V range, full_scale_voltage is 10 V. For the PCI-20364M-1 (12/16/18-bit) High-Accuracy Analog Input Module configured for extended mode results, the voltage is related to the returned integer data as follows: voltage = (integer data value * 10 V)/(gain * 218) for all input ranges and resolutions (12/16/18-bit). 4-5 Chapter 4: Software Libraries Function Call Reference 4.3 System Configuration Summary Use of the Master Link Software Libraries for DOS and Windows 3.x requires the following: 1. An IBM Compatible PC or EISA Bus computer (for EISA board applications). 2. IBM DOS or MS-DOS version 3.1, or higher, and Microsoft Windows 3.x (version 3.1 or 3.11) if you are programming Windows based applications. If you have extended memory, you will also need HIMEM.SYS, QEMMTM, 386EMM, 386MAXTM or a similar extended memory driver to allocate XMS buffers. 3. One or more PCI-20000 Series Carriers or Multifunction Boards, and appropriate I/O Modules for your application. 4. You will also need the appropriate version of a supported compiler listed at the beginning of this chapter. Use of the Master Link Software Libraries for Win32 requires the following: 1. An IBM Compatible PC (486 or better). 2. Microsoft Windows 95 or Windows NT (version 4.0 or higher). 3. One or more PCI-20000 Series Carriers or Multifunction Boards, and appropriate I/O Modules for your application. 4. You will also need the appropriate version of a supported compiler listed at the beginning of this chapter. 4-6 Chapter 4: Software Libraries Function Call Reference 4.4 Function Call Summary For your reference, a list of all function calls is provided below and on the next two pages. Each functional call group (e.g. Analog Input) is listed alphabetically. COMMAND DEFINITION ANALOG INPUT AICalibrate(..) Initiate an automatic calibration of a specific A/D AICalibrate364(..) Perform an external calibration of a PCI-20364M-1 Analog Input Module AICalibrationStatus(..) Get status of an A/D calibration AIConfigureList(..) Configure the analog input channel list for a specified DMA process AIRead(..) Configure and read a specified analog input channel and return one sample AIReadExtended(..) Read a specified analog input channel configured for extended result format AISetTime(..) Optionally program the settling time used by a PCI-20363M or PCI-20341M in an analog input DMA process SSHReadGroup(..) Read all the channels on the indicated Simultaneous Sample/Hold Module ANALOG OUTPUT AOConfigure(..) Configure an analog output channel for a specified range AOWrite(..) Write a given value to a specified analog output channel AOWriteGroup(..) Write values to each channel in a group of analog outputs simultaneously BUFFER BUFAllocate(..) Allocate a data buffer in conventional or extended memory BUFAttachProcess(..) Attaches a data buffer to a specific DMA process BUFDeallocate(..) De-allocate a previously allocated data buffer BUFDecode(..) Translate and transfer data from a source buffer to a destination buffer or local array BUFEncode(..) Encode and transfer data to a DMA buffer for a DMA output process BUFMoveIn(..) Transfer data from a source buffer to a destination buffer or local array BUFMoveOut(..) Transfer data to a DMA buffer for a DMA output process BUFSeek(..) Locate the current cluster pointer to a specific location in a DMA buffer for subsequent encode or decode or move operations BURST GENERATOR BGConfigure(..) Set operating parameters for a burst generator channel BGDisable(..) Disable the specified burst generator channel BGEnable(..) Enable the specified burst generator channel BGSetOptions(..) Set the output inversion option of a burst generator channel COUNTERS CTRConfigure(..) Set operating parameters and mode for a counter channel CTRDisable(..) Disable a counter channel CTREnable(..) Enable a counter channel CTRMeasure(..) Perform a period or pulsewidth measurement using a counter channel CTRRead(..) Read the count value and status from a counter channel CTRReadGroup(..) Reads the count value and status from each counter channel on a Board or Carrier. CTRSetOptions(..) Set operating options for a counter channel COUNTERS, Intel 8254-Based CTR8254Configure(..) Configure the given 8254 counter channel with an initial count and a mode CTR8254Disable(..) Disable the specified 8254 counter channel CTR8254Enable(..) Enable the specified 8254 counter channel CTR8254Measure(..) Measure a frequency with an 8254 counter channel using a rate generator channel as the time base CTR8254Read(..) Return count value and status of specified 8254 counter channel CTR8254ReadGroup(..) Return count values and statuses of the specified 8254 counter group 4-7 Chapter 4: Software Libraries Function Call Reference DIGITAL INPUT/OUTPUT DIOConfigure(..) Configure a digital I/O port for input or output and for basic or handshake mode DIORead(..) Read a specified digital I/O port DIOReadBit(..) Read a specified bit in a digital I/O port DIOStatus(..) Return handshake status of specified digital I/O port DIOWrite(..) Write a value to a digital I/O port DIOWriteBit(..) Write a value to specified bit in a digital I/O port DIRECT MEMORY ACCESS (DMA) DMAConfigureList(..) Configure the channel list for a specified DMA process DMAFreeHandle(..) Free the specified DMA process handle DMAGetHandle(..) Allocate a handle to a DMA process DMAHugeGetHandle(..) Allocate a handle to a huge (>64K) DMA process DMASetOptions(..) Set the options for the specified DMA process DMASetPacer(..) Identify the pacer source for a specified DMA process DMASetTrigger(..) Identify the trigger source for a specified DMA process DMAStart(..) Start a specified DMA process DMAStatus(..) Get the status and buffer information of the specified DMA process DMAStop(..) Stop the specified DMA process and get the status and buffer information DMASwap(..) Switch to a new data buffer when terminal count is reachedfor a DMA process INITIALIZATION HWInit(..) Initialize the data acquisition hardware RegisterClient(..) Windows 16-bit and 32-bit applications only. Registers an application instance with the drivers. SWInit(..) Initialize the Software Libraries SWReset(..) Reset the Software Libraries initialization (cancels SWInit and HWInit) SlotAssign(..) Assign a slot number to a memory-mapped ISA data acquisition Board or Carrier SlotAssignIO(..) Assign a slot number to an I/O-mapped ISA data acquisition Board or Carrier SlotInquire(..) Return information about the hardware configuration of a specified slot SlotSearchEISA(..) Search for EISA Boards and identify them to the software SlotSearchISA(..) Search for memory-mapped ISA Boards and return the number of boards found and information about each board SlotSearchIO(..) Search for I/O-mapped Boards and return the number of boards found and information about each board UnregisterClient(..) Windows 16-bit and 32-bit applications only. Unregisters an application instance with the drivers. IncludeXXXX(..) Include support for the specified Hardware and specical software functions in program INTERRUPT SoftInt(..) Generate a software interrupt signal on the specified Board RATE GENERATOR RGConfigure(..) Configure the given rate generator channel with rate parameters and a mode RGDisable(..) Disable specified rate generator channel RGEnable(..) Enable specified rate generator channel SYNCHRONIZATION BUS SYNCConfigure(..) Specify routing of synchronization signals within Modules, between Modules, or between Modules and a Board or Carrier via the SYNC Bus THERMOCOUPLE MEASUREMENT TCLinearize(..) Convert voltage data from a thermocouple channel to a temperature TCMeasure(..) Perform a temperature measurement from analog input channels connected to a thermocouple, cold-junction reference and zero reference. TRIGGER/ALARM TRIGConfigure(..) Configure the given analog trigger channel for specific high and low thresholds and a triggering mode TRIGDisable(..) Disable the specified analog trigger channel 4-8 Chapter 4: Software Libraries Function Call Reference TRIGEnable(..) Enable the specified analog trigger channel TRIGStatus(..) Return status of the specified analog trigger channel OTHER FUNCTIONS SetOptions98(..) Optionally invert the External Interrupt input signal on a PCI-20098C Multifunction Board SetOptions364(..) Set resolution, integration mode, and result format for a PCI-20364M-1 High-Accuracy (12/16/18-bit) Analog Input Module SetOptions377(..) Optionally select 16-bit or 32-bit Rate Generator configuration for a PCI-20377W Low Power Multifunction Board UTILITY FUNCTIONS CountsToVolts(..) Convert a count value returned by AIRead to a floating point voltage value ExtendedCountsToVolts(..) Convert a count value returned by AIReadExtended to a floating point voltage value FrequencyToRGCounts(..) Computes the count1 and count2 parameters used in RGConfigure to obtain a desired rate generator output frequency VoltsToCounts(..) Convert from a voltage value to count value suitable as parameter for AOWrite, AOWriteGroup, or TRIGConfigure 4-9 Chapter 4: Software Libraries Function Call Reference 4.5 Function Call Specifications When examining these function calls, please refer to section 4.2 for general parameter definitions and valid ranges. Be sure to read the following notes on this section. Notes on the Organization of Section 4.5: In this section function call groups (Analog Input Function Calls, Analog Output Function Calls, Counters, etc.) are listed in alphabetical order. In general, the calls as a whole are listed in alphabetical sequence as well. There are a few exceptions however. These are the Initialization Function Call Group, the "Other" Functions Call Group, and the SSHReadGroup Analog Input Function call. An alphabetic table of contents, by actual function call name, is provided on the next page for your reference. At the start of each category is a listing of the function calls described in that particular call group. Function call specifications and descriptions are represented in C function format. The corresponding parameter names and meanings in other language formats may be quickly translated by referring to and comparing the specific format(s) listed in the beginning section of each call group. Note for MicrosoftR Visual Basic users: The parameter descriptor "SEG", used in many BASIC language function calls listed at the start of each section is not valid in Visual Basic. To obtain the Visual Basic representation of a call from the BASIC one listed, simply take out the "SEG" portion of the specific parameter name. Example code segments are given at the end of various call specifications and function call sections showing how the calls can be used in a program. Also, be sure to examine the sample programs for more detailed examples. Notes on Specification Structure and Notational Conventions: Call specifications start with a C function listing, followed by a general description of the call. References to any other calls that may be interrelated or interdependent with the call being described are also made. Sub-topics are also elaborated upon where appropriate in the call description section. The call description is followed by a listing of the parameter descriptions. All call parameters are italicized, and parameter constant names appear in all CAPITAL letters (just as they are declared in the language header files). Note for MicrosoftR QuickBASIC users: In QuickBASIC only, "_" (underscores) in constant names are replaced by "." (period or dot), as the underscore is not allowed by QuickBASIC in symbolic names. Note for MicrosoftR Visual Basic users: The names of function calls for Visual Basic have a "%" character added to them for Windows 16-bit calls and a “&” for Win32 calls. This character informs Visual Basic that the calls each return an integer error code. Also, this character indicates that a parameter is an integer type (“%” for 16-bit integers and “&” for 32-bit integers). Note that Win32 call parameters use “&” for integers. Remember to include this extra character when entering function names. Failure to do so may cause Visual Basic to generate a redefinition error. This error indicates that Visual Basic already has a function of the name that you have used (AIRead%, for example and is flagging an attempt to call another function with the same name but a different type (if you type AIRead with no %, for example). In addition, any information structure formats are shown in small type, and appear exactly as they do in the C language header file (PCITYPE.H for DOS, or PCITYPEW.H for Windows). Information structures are not presented in this reference section for all languages. To find the exact representations of these structures for function declarations can be found in PCICONS.H for C (DOS), PCICONSW.H for C (Windows), PCICONS.P for Pascal (DOS), PCICONSW.P for Pascal (Windows), PCI.B for QuickBASIC, and PCIW.B for Visual Basic. 4-10 Chapter 4: Software Libraries Function Call Reference Function Call................................................................................................................. Page AICalibrate ...................................................................................................................... 4-14 AICalibrate364 ................................................................................................................ 4-15 AICalibrationStatus ......................................................................................................... 4-16 AIConfigureList ............................................................................................................... 4-17 AIRead............................................................................................................................ 4-20 AIReadExtended............................................................................................................. 4-22 AISetTime....................................................................................................................... 4-23 AOConfigure................................................................................................................... 4-27 AOWrite .......................................................................................................................... 4-28 AOWriteGroup................................................................................................................ 4-29 BGConfigure................................................................................................................... 4-43 BGDisable....................................................................................................................... 4-45 BGEnable ....................................................................................................................... 4-45 BGSetOptions................................................................................................................. 4-45 BUFAllocate.................................................................................................................... 4-32 BUFAttachProcess ......................................................................................................... 4-34 BUFDeallocate................................................................................................................ 4-36 BUFDecode .................................................................................................................... 4-37 BUFEncode .................................................................................................................... 4-38 BUFMoveIn..................................................................................................................... 4-40 BUFMoveOut .................................................................................................................. 4-41 BUFSeek ........................................................................................................................ 4-42 CountsToVolts ................................................................................................................ 4-120 CTR8254Configure......................................................................................................... 4-57 CTR8254Disable ............................................................................................................ 4-59 CTR8254Enable ............................................................................................................. 4-60 CTR8254Measure .......................................................................................................... 4-60 CTR8254Read................................................................................................................ 4-62 CTR8254ReadGroup...................................................................................................... 4-63 CTRConfigure................................................................................................................. 4-48 CTRDisable .................................................................................................................... 4-50 CTREnable ..................................................................................................................... 4-50 CTRMeasure .................................................................................................................. 4-51 CTRRead........................................................................................................................ 4-52 CTRReadGroup.............................................................................................................. 4-52 CTRSetOptions .............................................................................................................. 4-53 DIOConfigure.................................................................................................................. 4-65 DIORead......................................................................................................................... 4-66 DIOReadBit..................................................................................................................... 4-67 DIOStatus ....................................................................................................................... 4-67 DIOWrite......................................................................................................................... 4-68 DIOWriteBit..................................................................................................................... 4-68 DMAConfigureList .......................................................................................................... 4-71 DMAFreeHandle ............................................................................................................. 4-77 DMAGetHandle............................................................................................................... 4-78 DMAHugeGetHandle ...................................................................................................... 4-78 DMASetOptions .............................................................................................................. 4-78 DMASetPacer ................................................................................................................. 4-79 DMASetTrigger ............................................................................................................... 4-80 DMAStart ........................................................................................................................ 4-81 DMAStatus...................................................................................................................... 4-82 DMAStop ........................................................................................................................ 4-83 4-11 Chapter 4: Software Libraries Function Call Reference Function Call .................................................................................................................Page DMASwap .......................................................................................................................4-83 ExtendedCountsToVolts .................................................................................................4-121 FrequencyToRGCounts ..................................................................................................4-122 HWInit .............................................................................................................................4-87 IncludeXXXX ...................................................................................................................4-94 RegisterClient..................................................................................................................4-87 RGConfigure ...................................................................................................................4-100 RGDisable.......................................................................................................................4-103 RGEnable........................................................................................................................4-103 SetOptions364 ................................................................................................................4-118 SetOptions377 ................................................................................................................4-119 SetOptions98 ..................................................................................................................4-117 SlotAssign .......................................................................................................................4-88 SlotAssignIO ...................................................................................................................4-89 SlotInquire .......................................................................................................................4-89 SlotSearchEISA ..............................................................................................................4-92 SlotSearchIO...................................................................................................................4-93 SlotSearchISA.................................................................................................................4-92 SoftInt..............................................................................................................................4-99 SSHReadGroup ..............................................................................................................4-24 SWInit .............................................................................................................................4-88 SWReset.........................................................................................................................4-88 SYNCConfigure...............................................................................................................4-104 TCLinearize.....................................................................................................................4-109 TCMeasure .....................................................................................................................4-110 TRIGConfigure ................................................................................................................4-113 TRIGDisable....................................................................................................................4-114 TRIGEnable ....................................................................................................................4-115 TRIGStatus .....................................................................................................................4-115 UnregisterClient ..............................................................................................................4-93 VoltsToCounts.................................................................................................................4-122 4-12 Chapter 4: Software Libraries Function Call Reference 4.5.1 Analog Input Function Calls AICalibrate Initiate an automatic calibration of a specific A/D C Pascal BASIC int AICalibrate (int slot, int module); function AICalibrate (slot, module: Integer): Integer; FUNCTION AICalibrate% (BYVAL slot%, BYVAL mdl%) AICalibrate364 Perform an external calibration of a PCI-20364M-1 Analog Input Module C Pascal BASIC int AICalibrate364 (int slot, int module, int channel, int gain, int range, int differential, Cal364Type far *data, int func); function AICalibrate364 (slot, module, channel, gain, range, differential: Integer; var data: Cal364Type; func: Integer): Integer; FUNCTION AICalibrate364% (BYVAL slot%, BYVAL mdl%, BYVAL chn%, BYVAL gain%, BYVAL range%, BYVAL diff%, SEG caldata AS Cal364Type, BYVAL func%) AICalibrationStatus Get the status of an A/D calibration C Pascal BASIC int AICalibrationStatus (int slot, int module, unsigned far *status); function AICalibrationStatus (slot, module: Integer; var status: Word): Integer; FUNCTION AICalibrationStatus% (BYVAL slot%, BYVAL mdl%, SEG stat%) AIConfigureList Configure the analog input channel list for a specified DMA process C Pascal BASIC int AIConfigureList (int handle, int burstmode, int triggermode, unsigned long triggerdelay, int count, AIListType far *list, int far *clustersize); function AIConfigureList (handle, burstmode, triggermode: Integer; triggerdelay: Longint; count: Integer; var list: AIListType; var clustersize: Integer): Integer; FUNCTION AIConfigureList% (BYVAL hnd%, BYVAL burstmode%, BYVAL trigmode%, BYVAL trigdly&, BYVAL cnt%, SEG ailist AS AIListType, SEG clustsiz%) AIRead Configure and read a specified analog input channel and return one sample C Pascal BASIC int AIRead (int slot, int module, int channel, int zchannel, int gain, int range, int differential, int far *data); function AIRead (slot, module, channel, zchannel, gain, range, differential: Integer; var data: Integer): Integer; FUNCTION AIRead% (BYVAL slot%, BYVAL mdl%, BYVAL chn%, BYVAL zchn%, BYVAL gain%, BYVAL range%, BYVAL diff%, SEG aidata%) AIReadExtended Read a specified analog input channel and return a 32-bit result (extended format) C Pascal BASIC int AIReadExtended (int slot, int module, int channel, int zchannel, int gain, int range, int differential, long far *data); function AIReadExtended (slot, module, channel, zchannel, gain, range, differential: Integer; var data: Longint): Integer; FUNCTION AIReadExtended% (BYVAL slot%, BYVAL mdl%, BYVAL chn%, BYVAL zchn%, BYVAL gain%, BYVAL range%, BYVAL diff%, SEG aidata&) 4-13 Chapter 4: Software Libraries Function Call Reference AISetTime Optionally program the settling time used by a PCI-20363M or PCI-20341M in an analog input DMA process C Pascal BASIC int AISetTime (int slot, int module, unsigned long time) function AISetTime (slot, module: Integer; time: Longint): Integer; FUNCTION AISetTime% (BYVAL slot%, BYVAL mdl%, BYVAL settletime&) SSHReadGroup Read all the channels on the indicated Simultaneous Sample/Hold Module C Pascal BASIC int SSHReadGroup (int slot, int module, int zchannel, int gain, int range, int differential, int far *data); function SSHReadGroup (slot, module, zchannel, gain, range, differential: Integer; var data: Integer): Integer; FUNCTION SSHReadGroup% (BYVAL slot%, BYVAL mdl%, BYVAL chn%, BYVAL zchn%, BYVAL gain%, BYVAL range%, BYVAL diff%, SEG dptr%) AICalibrate int AICalibrate (int slot, int module) Call Description Initiate an automatic calibration of the specified Analog Input Function (A/D). Currently this call supports the PCI-20364M-1 High-Accuracy (12/16/18-bit) Analog Input Module only. Future products with auto-calibration functions will be supported by this call when they are available. The PCI-20364M-1 auto-calibration feature takes about 0.5 seconds to perform. It performs an internal autocalibration for all the gains and ranges of the PCI-20364M-1 Module and compensates for internal offsets. The AICalibrate364 call can be used to compensate for externally caused gain and offset errors. AICalibrationStatus should be used to monitor the progress of the calibration. If an error occurs during calibration an error code will be returned from the AICalibrationStatus call. Parameter Descriptions slot slot number of the hardware device with the A/D you wish to calibrate. module module position number on the Board or Carrier in the specified slot in which the A/D is located. Example An example calibration procedure using the AICalibrate and AICalibrationStatus calls is shown below: err := AICalibrate(slot, module); repeat err := AICalibrationStatus(slot, module); until (status and AI_CAL_COMPLETE) <> 0; 4-14 Chapter 4: Software Libraries Function Call Reference AICalibrate364 int AICalibrate364 (int slot, int module, int channel, int gain, int range, int differential, Cal364Type far *data, int function) Call Description This call performs the specified PCI-20364M-1 High-Accuracy Analog Input Module "external calibration" function. A calibration compensating for all gain and offset errors throughout the signal path is performed. In addition, the calibration information can be stored (using the CAL364_READ function mode) and re-loaded later (using the CAL364_WRITE function mode), so external calibration can be performed at reduced intervals. An external calibration procedure requires that span or zero reference voltages be provided through the signal path you want to calibrate, to one of the Module's input channels (specified in channel). To execute a calibration, first call AICalibrate364 to perform a zero calibration (by selecting CAL364_ZERO, in the call's function parameter). Next, call AICalibrate364 again to perform the span calibration (by selecting CAL364_SPAN, in the call's function parameter). The Module's controller uses an equation of the form y=mx + b, where m is a span constant, b is a zero constant, and y is the conversion result. The AICalibrate364 call also lets you customize these zero and span constants in a two step process. Details on this procedure, and other features of the calibration function are elaborated in the parameter descriptions. Parameter Descriptions slot slot number of the Board or Carrier holding the PCI-20364M-1 Module you wish to calibrate. module module position number on the Board or Carrier in the specified slot in which the PCI-20364M-1 is located. channel the channel number of the input connected to the external calibration voltage(s). gain gain value (1, 10, 100, 200) range one of the following input range codes: UNIPOLAR_10 = 0 - 10 V BIPOLAR_10 = ±5 V differential differential input flag, "1" = differential mode, "0" = single-ended data the calibration data. The calibration data structure is defined below: /* * PCI-20364M calibration data structure */ 4-15 Chapter 4: Software Libraries Function Call Reference typedef struct Cal364Type { long zeroVal; long spanVal; long zeroK; long spanK; } Cal364Type; /* /* /* /* Zero Span Zero Span calibration calibration calibration calibration value. value. constant. constant. */ */ */ */ The Zero calibration value and Span calibration value are data you define to create custom zero and full scale points. This data must be in the (decimal) range of -1048576 to +1048575 (or -220 to 220-1). The Zero calibration constant and Span calibration constant are values that the Module's controller determines after a calibration procedure to apply in the transfer equation; y=mx + b. See the function parameter below for more information. function the calibration function to perform: CAL364_ZERO = Initiate external zero calibration CAL364_SPAN = Initiate external span calibration CAL364_READ = Read calibration data CAL364_WRITE = Write calibration data Only one of the above functions may be specified per call to AICalibrate364. Two calls to AICalibrate364 are required to calibrate both zero and full scale points. When you specify CAL364_ZERO, a zero calibration is performed using the external zero reference voltage on the channel specified in channel and the Zero calibration value specified in data. A CAL364_ZERO operation should be followed by a CAL364_SPAN operation. In this case, a span calibration is performed using the external full scale reference voltage you supply at the input channel specified in channel and the Span calibration value specified in data. The values you specified in the Zero calibration value and Span calibration value will become the result codes for zero and full scale voltage readings. To store the current calibration data for later use, perform a CAL364_READ operation. A CAL364_WRITE operation will load the current data values specfied in the calibration data list. AICalibrationStatus int AICalibrationStatus (int slot, int module, unsigned far *status) Call Description This call is used to check the status of an A/D calibration procedure. Also see the AICalibrate and AICalibrate364 calls. Parameter Descriptions slot slot number of the Board or Carrier containing the A/D under calibration. module module position number on the Board or Carrier in the specified slot in which the A/D is located. 4-16 Chapter 4: Software Libraries Function Call Reference status the calibration status information. The following bit mask is provided to help you detect the completion of the calibartion procedure. If a bit mask compare is FALSE, then the calibration is still in progress. AI_CAL_COMPLETE = Calibration complete bit mask. Example An example usage of the AICalibrationStatus call is shown in the AICalibrate call description. AIConfigureList int AIConfigureList (int processhandle, int burstmode, int triggermode, unsigned long triggerdelay, int count, AIListType far *list, int far *clustersize) Call Description This call is used to configure the analog input channel list for the DMA process identified by the processhandle parameter. Burst mode or single-shot acquisition modes may be specified. Note: Data from only one A/D may be involved in a specified DMA transfer process. Analog input channels in the channel list must use a single A/D. These channels must be A/D channels or be expansion channels on an Analog Input Expander chained to the A/D through the Analog Daisy Chain. The AIConfigureList call is always used in conjunction with the DMAConfigureList call. Parameter Descriptions processhandle the DMA process handle obtained from a DMAGetHandle or DMAHugeGetHandle call. Each DMA process must have an assigned handle. burstmode burstmode flag. If this parameter is set to a value of "1" (TRUE), then the on-board burstmode feature of a PCI20501C-1, or PCI-20341M-1 A/D circuit will be enabled. If the parameter is "0" (FALSE) then single-shot mode is specified. triggermode triggermode flag. This function is not currently supported - always specify "0" (FALSE) for this parameter. triggerdelay triggerdelay value. This function is not currently supported - always specify 0 (zero) in this parameter. count number of list elements in the channel list. Up to 128 channels may be specified in a channel list. You must pass the actual number of items in your list in this parameter. list the analog input channel list array. The analog input channel list is an array of elements where each element has the following format: /* * Analog input channel list structure */ typedef struct AIListType { int slot; int module; /*Slot /*Module */ */ 4-17 Chapter 4: Software Libraries Function Call Reference int channel; int gain; int range; int differential; } AIListType; /*Channel /*Gain /*Range code /*Differential flag */ */ */ */ The meanings of each channel list element specification are given below. Slot slot number of the Board or Carrier where the analog input channel in this list element is located. Module module position number (0, 1, 2, 3) on the Board or Carrier in the specified Slot. Module number 0 (zero) specifies a Board's or Carrier's on-board analog input channels. Channel the number of the analog input channel you want to sample from the above module position. Gain gain at which to read the channel. Valid gain parameters depend on the analog input function (A/D) used to convert the analog input signal. See the following page for allowed gain values. Range code analog input range at which to read the channel. The available ranges depend on the A/D converter being used (see the following page for supported ranges). The input range code must be the same for all channels in the list, unless a PCI-20364M-1 Module is used (in this case channels on the list can have different range codes for PCI-20364M-1 channels or Analog Expanders attached to it). Range codes are: UNIPOLAR_5 = 0 - 5 V UNIPOLAR_10 = 0 - 10 V BIPOLAR_5 = ±2.5 V BIPOLAR_10 = ±5 V BIPOLAR_20 = ±10 V Differential flag differential input flag, "1" = differential mode, "0" = single-ended See the following table for supported input configurations for all analog input hardware. Valid gains, ranges, and input configurations (differential/single-ended) for all supported Analog Input (A/D) hardware are listed in the following table: 4-18 Chapter 4: Software Libraries Function Call Reference A/D HARDWARE AVAILABLE GAINS PCI-20501C-1 PCI-20098C-1A, 1 1, 10, 100 PCI-20098C-1B,-2 1, 10, 100, 200 PCI-20002M-1 1, 10, 100, 1000 *PCI-20019M-1A 1 *PCI-20023M-1 1 PCI-20341M-1 PCI-20364M-1** PCI-20089W-1A 1, 10, 100, 200 1, 10, 100, 200 1, 10, 100 *PCI-20091W-1 1 PCI-20377W-1 PCI-20428W-1* PCI-20428W-2* PCI-20428W-3* 1, 10, 100, 200 1, 10, 100 1, 2, 4, 8 1 RANGE(S) ±5 V, 0-10 V ±5 V, ±10 V, 0-10 V ±5 V, ±10 V, 0-10 V ±5 V, ±10 V, 0-10 V ±2.5 V, ±5 V, ±10 V, 0-5 V, 0-10 V ±5 V, ±10 V, 0-10 V ±5 V ±5 V, 0-10 V ±5 V, ±10 V 0-10 V ±2.5 V, ±5 V, ±10 V, 0-5 V, 0-10 V ±5 V, 0-10 V, ±5 V, ±10 V, 0-10 V, 0-5 V ±5 V, ±10 V, 0-10 V, 0-5 V ±5 V, ±10 V, 0-10 V, 0-5 V DIFF/SE SE only DIFF or SE DIFF or SE DIFF or SE* SE only SE only DIFF only DIFF or SE DIFF or SE* SE only DIFF or SE DIFF or SE DIFF or SE SE Only * The ranges or input configurations on these boards/modules are selected with hardware jumpers. The parameter values should match the jumpered values. ** The PCI-20364M-1 Analog Input Module cannot be used with the PCI-20363M-1 SSH Module in a DMA process. When specifying channels from an Analog Input Expansion Module (or Modules), the corresponding list elements should contain the following items: slot - number of Board containing the Expansion Module module - position of the Expansion Module channel - number of the desired Expansion Module channel gain - of the A/D hardware (see above table) connected to the Expansion Module input range - of the A/D hardware (see above table) connected to the Expansion Module differential - input configuration flag (differential or single-ended) as required: 1. For a PCI-20363M Simultaneous Sample/Hold (SSH) Module the differential list item parameter specifies the output configuration of the SSH Module, or the input configuration of the A/D it is attached to (can be single-ended or differential). 2. For a PCI-20031M-1 Expander/Sequencer Module the differential parameter specifies the input configuration of the PCI-20031M (differential or single-ended), the input configuration of its associated A/D must match. 3. PCI-20368M-1 Expanders and PCI-20017M SSH Modules only work with A/Ds configured for single-ended input, so always set the differential flag of the list item to 0. clustersize number of "bytes per cluster" returned by the call. This value is equal to the number of data bytes that will be generated as a result of sampling all analog channels on the channel list once. 4-19 Chapter 4: Software Libraries Function Call Reference Example An example code segment from sample program AIDMA_C.C, showing the AIConfigureList call in context is listed below. . . * Create channel lists for the AIConfigureList call (which sets up the A/D and * analog expanders for a list of analog input channels) and for the * DMAConfigureList call (which initializes the DMA controller on the board). */ for (channel = 0; channel < kAINumChannels; channel++) { AIlist[channel].slot = slot; AIlist[channel].module = module; AIlist[channel].channel = channel; AIlist[channel].gain = kAIGain; AIlist[channel].range = kAIRange; AIlist[channel].differential = kAISingleEnded; DMAlist[channel].slot = slot; DMAlist[channel].module = module; DMAlist[channel].channel = channel; DMAlist[channel].iotype = AI_TYPE; } /* * Configure the analog input channel list for the on-board A/D and any expander * modules to which it is chained. */ printf ("Configuring analog input channel list..."); error_code = AIConfigureList (dma_handle, kAISingleShotMode, kAINonTriggerMode, 0, kAINumChannels, AIlist, &ai_cluster_size); ErrorRoutine ("Error in AIConfigureList", error_code); printf ("\n"); /* . . AIRead int AIRead (int slot, int module, int channel, int zchannel, int gain, int range, int differential, int far *data) Call Description Reads the specified analog input channel with the specified gain and range, and using an optional auto-zero reference channel. The appropriate A/D is determined by the call according to whether the channel to be read is on an Analog Input Module, Analog Input Expansion Module, or an analog input channel on a Board or Carrier. On Analog Input hardware with software controllable input configurations, the call configures the analog input for differential mode if the differential flag is "1" (TRUE) or single-ended mode if the differential flag is "0" (FALSE). The result is returned in the data parameter. Parameter Descriptions slot slot number in which the analog input channel to be read is located. Note, reading a channel on an analog input expansion module (such as a PCI-20031M Expander/Sequencer Module) whose associated A/D function is located on another Board (i.e. signals are connected via an inter-board cable), requires that the Board or Carrier with the A/D be located in a lower numbered expansion slot. 4-20 Chapter 4: Software Libraries Function Call Reference module module position number on the Board or Carrier in the specified slot in which the A/D or expander channel to be read is located. module should be set to 0 (zero) to read any of a Board's or Carrier's on-board analog input channels. channel channel number on the Module or Board or Carrier, specified in module, to be read. zchannel auto-zero channel number or AI_NO_ZERO for none. PCI-20098C Series and PCI-20377W Multifunction Boards have built-in zero-reference functions. To use this feature, specify AI_HW_ZERO in zchannel. gain gain at which to read the channel. Valid gain parameters depend on the analog input function (A/D) used. See the previous table for allowed gain values. range analog input range at which to perform the read. The range depends on the A/D converter being used (see the table below for A/D hardware ranges). One of the following codes may be specified: UNIPOLAR_5 = 0 - 5 V UNIPOLAR_10 = 0 - 10 V BIPOLAR_5 = ±2.5 V BIPOLAR_10 = ±5 V BIPOLAR_20 = ±10 V differential flag indicating whether or not to read the channel using differential input configuration. Note that differential is the output configuration of a PCI-20363M-1 SSH or PCI-20017M SSH Modules. Valid gains, ranges, and input configurations (differential/single-ended) for all supported Analog Input (A/D) hardware are listed in the A/D Hardware table found in the AIConfigureList call description. When specifying channels from an Analog Input Expansion Module (or Modules), the slot, module, channel, gain, range and differential parameters should specify the following: slot - number of Board containing the Expansion Module module - module position of the Expansion Module channel - channel number of the desired Expansion Module channel gain - gain of the A/D hardware (see above table) connected to the Expansion Module range - input range of the A/D hardware (see above table) connected to the Expansion Module differential - input configuration flag (differential or single-ended) as required: 1. For a PCI-20363M Simultaneous Sample/Hold (SSH) Module the differential parameter specifies the output configuration of the SSH Module, or the input configuration of the A/D it is attached to (can be single-ended or differential). 2. For a PCI-20031M-1 Expander/Sequencer Module the differential parameter specifies the input configuration of the PCI-20031M (differential or single-ended), the input configuration of its associated A/D must match. 3. PCI-20368M-1 Expanders and PCI-20017M SSH Modules only work with A/Ds configured for single-ended input, so always set the differential parameter to 0. data the data value read from the channel. The format of the data is dependent upon the range for which the channel was configured. See the heading "Analog Input/Output Data format" in section 4.2.2 for data formats. 4-21 Chapter 4: Software Libraries Function Call Reference Example An example code segment, showing the AIRead call in context is listed below. error_code = AIRead (slot, module, channel, kAZChannel, gain, range, input_config, &counts); ErrorRoutine ("Error in AIRead", error_code); CountsToVolts (counts, gain, range, &volts); printf ("AI %2d: counts = %8d volts = %8.4f\n", channel, counts, volts); AIReadExtended int AIReadExtended (int slot, int module, int channel, int zchannel, int gain, int range, int differential, long far *data) Call Description AIReadExtended can be used to read analog input data from a PCI-20364M-1 High-Accuracy Analog Input Module configured for extended mode results (see the SetOptions364 call in "Other Function" calls, section 4.5.15). Extended result format provides a 32-bit signed integer value for any of the PCI-20364M's programmable A/D resolutions (12, 16, or 18-bit). AIReadExtended can also be used to read any analog input channel. The data returned for analog input channels other than PCI-20364M-1 channels configured for extended mode is 32-bit length common analog data format. See section 4.2.2, "Analog Input/Output Data Format" for common and extended format descriptions. Optionally you may call AICalibrate or AICalibrate364 to perform an auto-calibration of the PCI-20364M Module's A/D prior to a read operation. See the SetOptions364 function call for information on configuring the PCI-20364M-1 Module for its various operating modes. Parameter Descriptions slot slot number in which the analog input channel to be read is located. Note: Also see slot information in the AIRead call description for information on using Analog Expander Module channels. module module position number on the Board or Carrier in the specified slot in which the channel to be read is located. channel channel number on the Module to be read. zchannel auto-zero channel number or AI_NO_ZERO for none. PCI-20098C Series and PCI-20377W Multifunction Boards have built-in zero-reference functions. To use this feature, specify AI_HW_ZERO in zchannel. gain gain at which to read the channel. range analog input range at which to perform the read. One of the following codes may be specified: UNIPOLAR_5 = 0 - 5 V UNIPOLAR_10 = 0 - 10 V BIPOLAR_5 = ±2.5 V BIPOLAR_10 = ±5 V BIPOLAR_20 = ±10 V 4-22 Chapter 4: Software Libraries Function Call Reference Note: The PCI-20364M-1 Analog Input Module supports UNIPOLAR_10 and BIPOLAR_10 ranges. When the Module operates in extended mode (see SetOptions364), valid results are returned for an additional 2 volts beyond the configured input range (i.e. ±7 V, or -2 V to 12 V). differential flag indicating whether or not to read the channel using differential input configuration. data the data value read from the channel. The data is returned in 32-bit signed integer format when reading a PCI20364M Module configured for extended mode. Otherwise data is returned in 32-bit common analog format for any analog input channel read. Note: For extended mode PCI-20364M results, the input voltage is related to the result data by: Vin = data * 10V/(gain* 218) Note: For 32-bit common format results, the input voltage is related to the result data by: Vin = (data * range)/(gain* 216) For information on valid gains, ranges, and input configurations (differential/single-ended) for all supported Analog Input hardware please see the AIConfigureList call. The ExtendedCountsToVolts function can be used to convert extended result counts to voltage values (see example below). Example An example code segment, showing the AIReadExtended call in context is listed below. /* Reading a PCI-20364M configured for extended mode results */ error_code = AIReadExtended (slot, module, kChannel, kAZChannel, kAIGain, kAIRange, kSingleEnded, (long far *) &extended_counts); ErrorRoutine ("Error in AIReadExtended", error_code); ExtendedCountsToVolts (extended_counts, kAIGain, kAIRange, &volts); printf ("AI %2d: extended counts = %8ld volts = %10.6f\n", kChannel, extended_counts, volts); AISetTime int AISetTime (int slot, int module, unsigned long time) Call Description IMPORTANT: Only use this function under the direction of the factory. Contact the factory for assistance if your application requires an adjustment of the settling time for a PCI-20363M Module or a PCI-20341M Module. This function can be used to program the settling time used by a PCI-20363M Module or a PCI-20341M Module in an analog input DMA process. The settling time for these boards is automatically programmed by the drivers during the AIConfigureList function to allow for maximum sampling throughput in the data acquisition process. In some cases, the programmed settling time may not be adequate for the hardware being used. In other cases, the programmed settling time may be reduced to achieve a higher sampling rate. In any case, the AISetTime function can be used to overwrite the settling time programmed by the drivers. Simply call the AISetTime function after AIConfigureList but before DMAStart. Specify the channel-to-channel settling time in nanoseconds. 4-23 Chapter 4: Software Libraries Function Call Reference Parameter Descriptions slot slot number of the Board or Carrier in which the PCI-20363M Module or PCI-20341M Module is located. module module position number on the Board or Carrier in which the PCI-20363M Module or PCI-20341M Module is located. time channel-to-channel settling time in nanoseconds (up to to 255 nsec) for the PCI-20363M Module or PCI20341M Module. SSHReadGroup int SSHReadGroup (int slot, int module, int zchannel, int gain, int range, int differential, int far *data) Call Description Reads all of the channels on a Simultaneous Sample/Hold (SSH) Module using the Simultaneous Hold capability of the Module. This call supports the 20363M-1 8-Channel Simultaneous Sample/Hold Module. (Note: The PCI20017M SSH Module is also supported. This Module is no longer available, use the PCI-20363M for new designs.) The call determines the SSH Module's associated A/D function according the Module's position on the Board or Carrier and the location of the A/D. Reading channels on an SSH Module whose associated A/D function is located on another board (i.e. signals connected via an inter-board cable), requires that the Board or Carrier with the A/D be located in a lower numbered expansion slot. This function call first puts the SSH Module into the HOLD mode. Next the analog channels are converted to digital, using the associated A/D, and the data is returned in order in an array of integers. After reading all the channels, the SSH Module is put back into the SAMPLE mode. If SSHReadGroup is attempted with a PCI-20363M-1 SSH Module used with a PCI-20364M-1 Analog Input Module an error is returned. Parameter Descriptions slot slot number in which the Board or Carrier with the SSH Module is located. module module position number on the Board or Carrier in the specified slot in which the SSH Module to be read is located. zchannel auto-zero channel number or AI_NO_ZERO for none. gain gain for the Analog Input function (A/D) at which to read the SSH channels. 4-24 Chapter 4: Software Libraries Function Call Reference range analog input range for which to configure the A/D. UNIPOLAR_5 = 0 - 5 V UNIPOLAR_10 = 0 - 10 V BIPOLAR_5 = ±2.5 V BIPOLAR_10 = ±5 V BIPOLAR_20 = ±10 V differential flag indicating whether or not to configure the A/D for differential input configuration. "1" (TRUE) = differential configuration "0" (FALSE) = single-ended configuration can be TRUE or FALSE for: PCI-20363M SSH Module when used with a PCI-20098C, or a PCI-20002M* configured for the same input type. must be FALSE for: PCI-20363M SSH Module when used with a PCI-20501C-1, PCI-20019M, or a PCI-20023M. must be TRUE for: PCI-20363M when used with a PCI-20341M Analog Input Module. * The input configuration on the PCI-20002M Module is selected with hardware jumpers, the parameter value should match the jumpered value. data returned data array. Note that the array must be dimensioned based on the number of channels on the SSH Module (8 for the PCI-20363M-1). The format of the data is dependent upon the range for which the channel was configured. See the heading "Analog Input/Output Data format" in section 4.2.2 for data formats. NOTE: For information on valid gains, ranges, and input configurations (differential/single-ended) for all Analog Input (A/D) hardware please see the AIConfigureList call. Example An example code segment, showing the SSHReadGroup call in context is listed below. procedure testSSH (slot, module: Integer); var error_code: done: channel: counts: volts: c: dummy: Integer; Integer; Integer; array[0..kNumChannels-1] of Integer; Double; Char; Integer; begin done := 0; Writeln; Writeln ('All of the SSH channels will be read continuously.'); Writeln ('To stop the readings, press <q>. Press any other key to acquire'); Writeln ('another group of SSH readings.'); while done = 0 do begin error_code := SSHReadGroup (slot, module, kAZChannel, kAIGain, kAIRange, kSingleEnded, counts[0]); ErrorRoutine ('Error in SSHReadGroup', error_code); Writeln; 4-25 Chapter 4: Software Libraries Function Call Reference for channel := 0 to kNumChannels-1 do begin dummy := CountsToVolts (counts[channel], kAIGain, kAIRange, volts); Writeln ('AI ', channel:2, ': counts = ', counts[channel]:8, 'volts = ', volts:8:4); end; c := Readkey; case c of 'q', 'Q': done := 1; end; end; end; 4-26 Chapter 4: Software Libraries Function Call Reference 4.5.2 Analog Output Function Calls AOConfigure Configure an analog output channel for a specified range C Pascal BASIC int AOConfigure (int slot, int module, int channel, int range); function AOConfigure (slot, module, channel, range: Integer): Integer; FUNCTION AOConfigure% (BYVAL slot%, BYVAL mdl%, BYVAL chn%, BYVAL range%) AOWrite Write a given value to a specified analog output channel C Pascal BASIC int AOWrite (int slot, int module, int channel, int data); function AOWrite (slot, module, channel, data: Integer): Integer; FUNCTION AOWrite% (BYVAL slot%, BYVAL mdl%, BYVAL chn%, BYVAL aodata%) AOWriteGroup Write values to each channel in a group of analog outputs simultaneously C Pascal BASIC int AOWriteGroup (int slot, int module, int far *data); function AOWriteGroup (slot, module: Integer; var data: Integer): Integer; FUNCTION AOWriteGroup% (BYVAL slot%, BYVAL mdl%, SEG aodata%) AOConfigure int AOConfigure (int slot, int module, int channel, int range) Call Description This call configures the given analog output channel for the specified range. Supported analog output devices are the PCI-20003M-2 and -4, 12-bit 2 Channel Voltage/Current Output Module, PCI-20006M-1,-2 16-bit 2 Channel Voltage Output Modules, PCI-20021M-1B 12-bit 8 Channel Voltage Output Module, the PCI-20093W-1 Analog Output Board and the PCI-20428W-1, -2 Multifunction Boards. Note, even though all the above analog output devices use hardware jumpers to set their output ranges, the AOConfigure call is required to inform the AOWrite calls of the proper data formats. Parameter Descriptions slot slot number in which the given Analog Output Module is located. module module position number on the Board or Carrier in the specified slot in which the Analog Output Module is located (module should be 0 for a PCI-20093W-1 Board or a PCI-20428W Board.) channel channel to configure. Valid channel numbers are 0 and 1 for the PCI-20003M-2, PCI-20003M-4, or the PCI20006M-2 Analog Output Modules (channel 0 for the PCI-20006M-1 Module). Channel numbers 0 to 7 are valid when using the PCI-20021M-1B 12-bit 8 Channel Analog Output Module and PCI-20093W-1 Analog Output Board. Valid channel numbers are 0 and 1 for a PCI-20428W-1,-2 Board. range range for which to configure the channel. 4-27 Chapter 4: Software Libraries Function Call Reference UNIPOLAR_5 = 0 - 5 V UNIPOLAR_10 = 0 - 10 V BIPOLAR_5 = ±2.5 V BIPOLAR_10 = ±5 V BIPOLAR_20 = ±10 V If the PCI-20003M is jumpered for current output, specify the UNIPOLAR_10 range. If the PCI-20093W is jumpered for current output (0-20 mA), specify the UNIPOLAR_5 range. Note: When using a PCI-20021M 8-Channel Analog Output Module or a PCI-20093W Analog Output Board, all analog output channels on the Module or Board must configured for the same range. Ranges supported by each device are listed in the following table: HARDWARE PCI-20003M-2,-4 PCI-20006M-1,-2 PCI-20021M PCI-20093W-1 PCI-20428W-1,-2 RANGE CODE OUTPUT RANGE BIPOLAR_20 ±10 V BIPOLAR_10 ±5 V UNIPOLAR_10 BIPOLAR_20 BIPOLAR_10 UNIPOLAR_10 BIPOLAR_20 BIPOLAR_10 BIPOLAR_5 BIPOLAR_10 UNIPOLAR_5 BIPOLAR_10 BIPOLAR_20 UNIPOLAR_10 0-10 V ±10 V ±5 V 0-10 V ±10 V ±5 V ±2.5 V ±5 V 0-5 V ±5 V ±10 V 0-10 V The ranges on all the above Analog Output devices are selected with hardware jumpers, the parameter value should match the jumpered value. Example For an example, see the end of this function call group. AOWrite int AOWrite (int slot, int module, int channel, int data) Call Description Write the value given in data to the specified analog output channel. Parameter Descriptions slot slot number in which the given Analog Output Module is located. module module position number on the Board or Carrier in the specified slot in which the Analog Output Module is located (module should be 0 for a PCI-20093W-1 Board or a PCI-20428W Board.) 4-28 Chapter 4: Software Libraries Function Call Reference channel channel to write. Valid channel numbers are 0 and 1 for the PCI-20003M-2, PCI-20003M-4, or the PCI20006M-2 Analog Output Modules (channel 0 for the PCI-20006M-1 Module). Channel numbers 0 to 7 are valid when using the PCI-20021M-1B 12-bit 8 Channel Analog Output Module and PCI-20093W-1 Analog Output Board. Valid channel numbers are 0 and 1 for a PCI-20428W-1,-2 Board. data data value to write to the channel. The data must be specified in common analog data format, and is dependent upon the range for which the channel was configured in AOConfigure. (See Section 4.2.2 "Analog Input/Output Data Format".) Example For an example, see the end of this function call group. AOWriteGroup int AOWriteGroup (int slot, int module, int far *data) Call Description Writes analog output values to each channel in the specified Analog Output Module simultaneously. Channel number 0 is written to when using a PCI-20006M-1 Module. Channel numbers 0 and 1 are written to when using the PCI-20003M-2, PCI-20003M-4, or the PCI-20006M-2 Analog Output Modules or a PCI-20428W-1,-2 Board. Channel numbers 0 to 7 are written to when using the PCI-20021M-1B 12-bit 8 Channel Analog Output Module and the PCI-20093W-1 Analog Output Board. Parameter Descriptions slot slot number in which the given Analog Output Module is located. module module position number on the Carrier/Board in the specified slot in which the Analog Output Module is located (module should be 0 for a PCI-20093W-1 Board or a PCI-20428W Board.) data array of data to write to the channels in the group. Adjust the size of the output data array according to the number of available channels on the Module you are writing to. The data must be specified in common analog data format, and is dependent upon the range for which the device was configured in AOConfigure. (See Section 4.2.2 "Analog Input/Output Data Format".) The VoltsToCounts utility function can be used to convert voltage values to common format count data. 4-29 Chapter 4: Software Libraries Function Call Reference Example An example code segment, showing the AOConfigure, AOWrite and VoltsToCounts calls in context is listed below. void testAnalogOutput { int int int double char (int slot, int module) error_code; done; counts; volts; c; done = 0; printf ("Configuring analog output channel %d...", kChannel); error_code = AOConfigure (slot, module, kChannel, kAORange); ErrorRoutine ("Error in AOConfigure", error_code); printf ("\n"); while (!done) { printf ("Press <q> to quit or any other key to output voltage:"); c = (char) getch (); printf ("\n"); switch (c) { case 'q': case 'Q': done = 1; break; default: printf ("Enter output voltage: "); scanf ("%lf", &volts); VoltsToCounts (volts, kAORange, &counts); error_code = AOWrite (slot, module, kChannel, counts); ErrorRoutine ("Error in AOWrite", error_code); break; } } } 4-30 Chapter 4: Software Libraries Function Call Reference 4.5.3 Buffer Management Function Calls BUFAllocate Allocate a data buffer in conventional or extended memory C Pascal BASIC int BUFAllocate (int location, int XMSflag, unsigned long buffersize, unsigned long far *bufferhandle, char far * far *buffer); function BUFAllocate (location, XMSflag: Integer; buffersize: Longint; var bufferhandle: Longint; var buffer: POINTER): Integer; FUNCTION BUFAllocate% (BYVAL location%, BYVAL XMSflag%, BYVAL bufsiz&, SEG bufhnd&, SEG buffer&) BUFAttachProcess Attach a data buffer to a specific DMA process C Pascal BASIC int BUFAttachProcess (int processhandle, unsigned long bufferhandle, char far *buffer, BufInfoType far *info); function BUFAttachProcess (processhandle: Integer; bufferhandle: Longint; buffer: POINTER; var info: BufInfoType): Integer; FUNCTION BUFAttachProcess% (BYVAL prchnd%, BYVAL bufhnd&, BYVAL buffer&, SEG info AS BufInfoType) BUFDeallocate Deallocate a previously allocated data buffer C Pascal BASIC int BUFDeallocate (unsigned long bufferhandle, char far *buffer, unsigned long buffersize); function BUFDeallocate (bufferhandle: Longint; buffer: POINTER; buffersize: Longint): Integer; FUNCTION BUFDeallocate% (BYVAL bufhnd&, BYVAL buffer&, BYVAL bufsiz&) BUFDecode Translate and transfer data in a DMA buffer to a destination buffer C Pascal BASIC int BUFDecode (unsigned long sourcehandle, char far *source, unsigned long destinationhandle, char far *destination, BufInfoType far *info, unsigned long count, unsigned long far *xcount); function BUFDecode (sourcehandle: Longint; source: POINTER; destinationhandle: Longint; destination: POINTER; var info: BufInfoType; count: Longint; var xcount: Longint): Integer; FUNCTION BUFDecode% (BYVAL srchnd&, BYVAL src&, BYVAL dsthnd&, SEG dst%, SEG info AS BufInfoType, BYVAL count&, SEG xcount&) BUFEncode Encode and transfer data to a DMA buffer for a DMA output process C Pascal BASIC int BUFEncode (unsigned long sourcehandle, char far *source, unsigned long destinationhandle, char far *destination, BufInfoType far *info, unsigned long count, unsigned long far *xcount); function BUFEncode (sourcehandle: Longint; source: POINTER; destinationhandle: Longint; destination: POINTER; var info: BufInfoType; count: Longint; var xcount: Longint): Integer; FUNCTION BUFEncode% (BYVAL srchnd&, SEG src%, BYVAL dsthnd&, BYVAL dst&, SEG info AS BufInfoType, BYVAL count&, SEG xcount&) BUFMoveIn Same as BUFEncode except no translation of data from common-format to native-format C Pascal BASIC int BUFMoveIn (unsigned long sourcehandle, char FAR *source, unsigned long destinationhandle, char FAR *destination, BufInfoType FAR *info, unsigned long count, unsigned long FAR *xcount); function BUFMoveIn (sourcehandle: Longint; source: Pointer; destinationhandle: Longint; destination: Pointer; var info: BufInfoType; count: Longint; var xcount: Longint): Integer; FUNCTION BUFMoveIn% (BYVAL srchnd&, SEG src%, BYVAL dsthnd&, BYVAL dst&, SEG info AS BufInfoType, BYVAL count&, SEG xcount&) 4-31 Chapter 4: Software Libraries Function Call Reference BUFMoveOut Same as BUFDecode except no translation of data from native-format to common-format C int BUFMoveOut (unsigned long sourcehandle, char FAR *source, unsigned long destinationhandle, char FAR *destination, BufInfoType FAR *info, unsigned long count, unsigned long FAR *xcount); function BUFMoveOut (sourcehandle: Longint; source: Pointer; destinationhandle: Longint; destination: Pointer; var info: BufInfoType; count: Longint; var xcount: Longint): Integer; FUNCTION BUFMoveOut% (BYVAL srchnd&, BYVAL src&, BYVAL dsthnd&, SEG dst%, SEG info AS BufInfoType, BYVAL count&, SEG xcount&) Pascal BASIC BUFSeek Locate the cluster pointer to a specifc location in a DMA buffer C int BUFSeek (int origin, BufInfoType far *info, long count, unsigned long bufferhandle, char far *buffer); function BUFSeek (origin: Integer; var info: BufInfoType; count, bufferhandle: Longint; buffer: POINTER): Integer; FUNCTION BUFSeek% (BYVAL origin%, SEG info AS BufInfoType, BYVAL count&, BYVAL bufhnd&, BYVAL buffer&) Pascal BASIC BUFAllocate int BUFAllocate (int location, int XMSflag, unsigned long buffersize, unsigned long far *bufferhandle, char far *far *buffer) Call Description Whenever you prepare a DMA process for a DMA analog input acquisition or a general purpose DMA input/output transfer, you must allocate buffer memory. Buffers are required to receive DMA input data, or to store data prior to a DMA output transfer. Once you know how much memory you need, you can use the BUFAllocate call to reserve a buffer. The BUFAllocate call can be used to allocate a data buffer in the location and with the specified buffersize in either conventional or extended memory. If the data buffer is placed in conventional memory a pointer to the data buffer is returned in the buffer parameter. If the buffer is placed in extended memory, by setting the XMSflag to "1" (TRUE), an extended memory bufferhandle is returned. For most applications on machines with extended memory, you will want to use the XMSflag to allocate buffers above 1 Mbyte (set XMSflag to 1). Note: Always set XMSflag to "1" for any Windows (3.x, 95, NT) applications. In your program, the BUFAllocate call should be made after a DMAConfigureList call. This sequence is recommended since DMAConfigureList returns a value, called "clustersize", that will help you determine the minimum buffersize required for your DMA transfer. Parameter Descriptions location buffer location. The following buffer flags are defined: ALLOC_ANYWHERE = Locate buffer anywhere in conventional or extended memory. Use this option for EISA Bus computer DOS or Windows 16-bit applications. ALLOC_IN_64K = Locate a buffer inside a 64 kbyte page block. Use this option for ISA Bus computer DOS applications, or Windows 16-bit DMA applications which require less than 64 kbytes of buffer space. 4-32 Chapter 4: Software Libraries Function Call Reference ALLOC_ON_64K = Locate a buffer starting on a 64 kbyte page boundary. This option should be used for DMA "Swap" buffers in DOS applications only, see the DMASwap call description. ALLOC_NO_LOCK = Allocate buffer anywhere but don't lock the buffer in physically contiguous memory. This flag should be used for any Windows (3.x, 95, NT) DMA processes that require greater than 64 kbytes of data. Such a process is termed a Huge DMA process, and requires that you acquire a DMA process handle using the DMAHugeGetHandle function. Also, use this option all of the time for Windows NT computers. Specifying "ALLOC_ANYWHERE" in conventional or extended memory areas will suffice for your EISA based applications. The second and third buffer location flags, ALLOC_IN_64K and ALLOC_ON_64K, are for Software Library compatibility with IBM PC/XT/AT (e.g. ISA Bus) machines, which have limitations on where and how large a DMA buffer can be. For EISA Bus machines, these limitations do not apply. If you are writing a DOS application for ISA based data acquisition hardware (e.g. a PCI-20098C Multifunction Board) that must operate on both ISA and EISA platforms, you must use the "ALLOC_IN_64K" buffer location flag. Because of the internal design of ISA computers, a DMA process cannot automatically transfer data into or out of a buffer which crosses a 64 kbyte page boundary. "ALLOC_ON_64K" should be used for ISA "offsetaligned" buffers required by the DMASwap call. The "ALLOC_IN_64K" option is used to allocate within a 64 kbyte page. You may use this option to locate a buffer (less than 64 kbytes long) for ISA DOS or Windows applications. Notes for Windows Users: 1. If BUFAllocate is called and error 15300 is returned, 65520 (bytes) is the maximum possible buffer size for "ALLOC_IN_64K". "ALLOC_ON_64K" will not work in this case! 2. Always use "ALLOC_NO_LOCK" if the DMA process uses more than 64 kbytes of data (a huge DMA process). Always use this flag for Windows NT applications. Also see the DMAHugeGetHandle call. XMSflag extended memory flag. This parameter applies to DOS based applications. Always set XMSflag to "1" for any Windows based applications. Setting this parameter to "0" (FALSE), indicates you want to allocate a buffer in conventional memory (0 to 640 Kbyte area). Setting this parameter to "1" (TRUE) will allow you to allocate a buffer in extended memory, if you have an 80286 (or higher) system and extended memory. You need an XMS 2.0 compliant memory driver for the Master Link Software Libraries to allocate extended memory. HIMEM.SYS. QEMM.SYS, and 386MAX.SYS all manage XMS memory in a compatible manner (see Appendix B). For DOS based applications, if you allocate a buffer in extended memory (above 1 Mbyte area), BUFAllocate returns the XMS memory handle allocated through the XMS driver in bufferhandle (see below). In this case, the return value in the parameter buffer (see below) is 0. If you allocate a buffer in conventional memory (0 to 640 kbyte area), the BUFAllocate call returns (in the buffer parameter) the buffer start address (and sets bufferhandle to 0). Windows note: bufferhandle is always "0" for Windows applications. buffersize buffer size in bytes. Set the buffersize parameter to the value determined from the clustersize and clustercount values as explained below. 4-33 Chapter 4: Software Libraries Function Call Reference From the clustersize value obtained from the DMAConfigureList call, determine the buffersize you will need (in bytes) from the following: buffersize (bytes) = clustersize x clustercount Where clustercount is the number of passes through the DMA channel list you want to acquire or output (as specified to the DMAConfigureList call). Remember that a cluster is defined as the amount of data transferred in one complete pass of the channel list. bufferhandle the returned extended memory handle (from the XMS driver). Also see the XMSflag description above. buffer the returned conventional memory buffer address. Also see XMSflag description above. Example An example code segment, showing the BUFAllocate call used to allocate a 10 kbyte buffer in conventional memory is listed below. { Allocate a 10k byte buffer for use with DMA. } bufferLocation := ALLOC_IN_64K; bufferInXMS := 0; { { { { { You may use ALLOC_ANYWHERE if your } computer is an EISA system! } FALSE: If you have a '286 or higher } system and extended memory, you } can set this flag to 1. } bufferSize := 10 * 1024; err := BUFAllocate(bufferLocation, bufferInXMS, bufferSize, bufferHandle, bufferPointer); { ... always check for errors ... } BUFAttachProcess int BUFAttachProcess (int processhandle, unsigned long bufferhandle, char far *buffer, BufInfoType far *info) Call Description This call attaches a buffer to a DMA process. The DMA process is identified by the processhandle (obtained through the DMAGetHandle call). The buffer is identified by a bufferhandle for a buffer located in extended memory, or by a buffer pointer for a buffer located in conventional memory. The extended memory bufferhandle, and conventional memory buffer pointer are obtained through the BUFAllocate call. The BUFAttachProcess function must be called before data can be decoded from a DMA Buffer (using BUFDecode), or encoded into a DMA data buffer (using BUFEncode). Parameter Descriptions processhandle DMA process handle (see the DMAGetHandle or DMAHugeGetHandle call). bufferhandle XMS buffer handle obtained from BUFAllocate, or 0 if you have allocated a conventional memory buffer for the DMA process or a buffer in a Windows application. 4-34 Chapter 4: Software Libraries Function Call Reference buffer the memory buffer pointer obtained from BUFAllocate. info buffer information. The buffer information structure has the following format: Buffer Information Structure /* * Buffer information structure */ typedef struct BufInfoType { short wrap; short running; short bytespercluster; short framespercluster; long size; long count; long currentcluster; long triggercluster; long nextcluster; unsigned long DMAword; unsigned long DMAaddr; void FAR *command; short unlatchedwrap; } BufInfoType; /* /* /* /* /* /* /* /* /* /* /* /* /* Latched buffer wrap flag. */ Process running flag. */ Number of bytes per cluster. */ Number of frames per cluster. */ Buffer size in clusters. */ Number of clusters available for decoding/encoding. */ Current cluster. */ Trigger cluster. */ Next decode/encode cluster. */ Current DMA word count. */ Current DMA address. */ Decode/encode command pointer. */ Unlatched buffer wrap flag. */ The info variable data structure is defined for you in the Master Link header files. The same info structure is passed with all calls using this variable in a program; BUFAttachProcess, BUFDecode, BUFEncode, BUFSeek, DMAStatus and DMAStop. All of the buffer information items are updated when the DMAStatus, or DMAStop functions are called. NOTE: Buffer information items are adjusted and maintained by the Software Library - DO NOT ALTER ANY OF THESE VALUES! wrap - Latched buffer wrap flag A "1" here indicates a circular buffer arrangement was used and that the buffer wrapped around (a full buffer of data was acquired). "0" indicates a that no "wrap" has taken place. Also, wrap is "1" at the termination of a DMA "stop on terminal count" mode. This is a “latched” wrap flag. running - Process running flag "1" = DMA process is active. "0" = DMA process inactive. bytespercluster - Number of bytes per cluster The number of bytes transferred in one pass of the DMA channel list for this process. framespercluster - Number of frames per cluster Number of data frames that make up a cluster for this DMA process. The number of frames per cluster is always 1 for a DMA transfer using a PCI-20501C-1 or PCI-20501C-2 High-Performance EISA Board. For other Boards this value may be different. (See the DMAConfigureList call.) size - Buffer size in clusters A cluster (in bytes) is the amount of data transferred in one complete pass of the DMA channel list (see the DMAConfigureList call). The size of the buffer in bytes is equal to: (bytespercluster * size). 4-35 Chapter 4: Software Libraries Function Call Reference count - Available decode/encode cluster count Indicates the number of complete clusters available for decoding or encoding (encoding applies to the BUFEncode call). This value indicates the number of complete clusters transferred, or the number which the buffer will hold (clustercount), whichever is smaller. currentcluster - Current cluster "Current cluster" points to the location in the buffer at which the next cluster will be transferred by DMA. triggercluster - Trigger cluster "Trigger cluster" points to the first complete cluster that was transferred after a trigger was detected when running in trigger mode. nextcluster - Next cluster "Next cluster" points to the next cluster for decoding or encoding, or it points to the cluster sought as the result of a BUFSeek call. Note: If the DMA process is running the Next cluster equals the Current cluster. DMAword - Current DMA word count The actual word transfer count in the host computer's DMA controller. At the start of the DMA process, this is equivalent to the buffer length in words. DMAaddr - Current DMA address The actual DMA address in the host computer's DMA controller. At the start of the DMA process, this address is the buffer start address. unlatchedwrap - Unlatched buffer wrap flag This is an unlatched version of the wrap flag above. Note, the info variable is user-allocated - the data structure is defined for you in the Master Link header files. The function calls just set or maintain info's field values. BUFDeallocate int BUFDeallocate (unsigned long bufferhandle, char far *buffer, unsigned long buffersize) Call Description This call frees a buffer previously allocated with the BUFAllocate function. Whenever you allocate a buffer, you should always deallocate it with the BUFDeallocate call before you exit your program. Failing to do so may cause problems with other applications that use the same memory areas. Parameter Descriptions bufferhandle extended memory handle or 0 for conventional buffer pointer or Windows buffer. Also see BUFAllocate call description. buffer conventional memory buffer pointer. Also see BUFAllocate call description. buffersize buffersize, in bytes, of the buffer to be deallocated. 4-36 Chapter 4: Software Libraries Function Call Reference BUFDecode int BUFDecode (unsigned long sourcehandle, char far *source, unsigned long destinationhandle, char far *destination, BufinfoType far *info, unsigned long count, unsigned long far *xcount) Call Description The purpose of the BUFDecode function is to convert input data acquired in a DMA input process into the form normally returned by the Software Library's data read functions. This function provides overall consistency when dealing with input data. The BUFDecode call decodes and transfers a specified number of data units (clusters) from a source buffer to a destination array or buffer you specify. Before you can decode a buffer, you must call BUFAttachProcess to associate the DMA process with the buffer. After a call to BUFDecode, the "next cluster location pointer" is updated to the end of the data decoded. (The next cluster location is available in the buffer info array.) To help you understand how to use BUFDecode, a little background information is now presented. Data Formats When input data is captured in a DMA process, you will usually want to decode it using BUFDecode. For example, in an analog input DMA acquisition, the stored data will be in the output format of the particular A/D converter used. Without using BUFDecode, to understand what this data means, you must know what the A/D output format is. If you apply the BUFDecode function, the data will be translated to common analog data format (as returned by the AIRead call), or extended data format (as returned by the AIReadExtended call) depending on the Analog Input device's configuration. For 12-bit or 16-bit resolution A/D results, common analog format reports data in the following ranges: -32768 to 32767 (decimal) for Bipolar input ranges, or 0 to 65535 (decimal) for Unipolar input ranges, Note, 12-bit analog data is left-justified and zero-filled in the translation process. For a PCI-20364M Analog Input Module operating in extended mode, 12-bit, 16-bit, or 18-bit resolution data is reported as a 32-bit signed integer. For general purpose DMA input transfers, the data can be a mix of input types (analog input, counter values, digital input, etc.). In the decode process, input data-widths are converted to the wordlength that is returned by the Read call associated with the input type. Examples: A transfer from a PCI-20004M-1 digital I/O port (configured for input), which is 8-bits wide, will be padded with zeros to form one 16-bit word (as is returned by the DIORead call). A count value transferred from a PCI-20501C on-board counter channel configured for 16-bit operation, will be converted to a 32-bit value (as is returned by the CTRRead call). A count value transferred from a 8254-based 16-bit counter channel, such as a PCI-20007M Counter/Timer/Rate Generator Module, will be converted to a 32-bit count value (as is returned by the CTR8254Read call). NOTE: Counter measurement modes and digital handshake modes are not supported (for DMA transfer) since an indeterminate number of transfers would be involved to acquire the desired result data. In these cases a warning code is reported by the DMAConfigureList call, but execution is not halted. Also, single bit Digital I/O read/writes are not supported for DMA transfer. 4-37 Chapter 4: Software Libraries Function Call Reference Using BUFDecode Before you call BUFDecode, you will typically use the BUFSeek function to first locate a specific data cluster in the original DMA Buffer. Note, a data cluster is the data transferred in a complete pass through the DMA channel list (see the DMAConfigureList call description for more information on clusters). BUFDecode is then called to format the data from the location and put it in the local destination array or buffer. Parameter Descriptions sourcehandle source buffer extended memory handle obtained from the BUFAllocate call. If you allocated a conventional memory buffer or a buffer under Windows, sourcehandle should be set to 0 (zero). source pointer to the memory buffer obtained from the BUFAllocate call. If you allocated an extended memory buffer, source should be set to 0 (zero). destinationhandle destination buffer handle for decoded data. Set destinationhandle to 0 (zero) if a local array is used or a conventional memory buffer is used as the destination. The local array elements should be 16-bit integers for common format analog data and 32-bit integers for extended format data. destination pointer to destination buffer or array for decoded data. The local array elements must be 16-bit integers. Set destination to 0 (zero) if an extended memory buffer is used as the destination. info buffer information. Buffer information structure and descriptions are listed under the BUFAttachProcess function call. The information will be updated to reflect a new next cluster location. count number of data clusters from the source buffer you want to decode. xcount number of data clusters actually decoded. If DMA is in progress and at least one cluster has been acquired, you may use the BUFDecode call to retrieve this data. If no complete data clusters have been transferred, the BUFDecode parameter xcount returns a value of 0 (an error code is returned as well). BUFEncode int BUFEncode (unsigned long sourcehandle, char far *source, unsigned long destinationhandle, char far *destination, BufinfoType far *info, unsigned long count, unsigned long far *xcount) Call Description The purpose of the BUFEncode call is to encode data in preparation for a DMA output process. This function allows you to set up output data in the format normally required by the Software Library's Write functions. The BUFEncode call is used to encode your data into the form actually used by the Intelligent Instrumentation output hardware, and transfer it to a buffer that will be used in the DMA output operation. This process facilitates consistency when dealing with output data. This call encodes count clusters from your source array or buffer, to the DMA destination buffer (in conventional or extended memory) starting at the next cluster location in the destination buffer. The data will be formatted to make it consistent with the AOWrite and DIOWrite function calls. The next cluster location pointer is updated to the end of the data encoded. (The next cluster location is available in the buffer info array.) 4-38 Chapter 4: Software Libraries Function Call Reference Before you can encode your source data into the destination buffer, you must call BUFAttachProcess to associate the DMA process with the destination buffer. In a DMA output process, Analog Output and Digital Output data types (AO_TYPE and DIO_TYPE) only may be transferred. The formats you need to set up the source data in are listed below. Source buffer data for an Analog Output transfer must be in common analog data format (see section 4.2.2 or the AOWrite call). BUFEncode will translate this data to the form actually used by the Analog Output hardware. A source data item (8-bit value) for transfer to a Digital Output port must be right justified and padded with zeros to form a 16-bit word. (I/O port(s) configured for handshake output mode are not supported for DMA). Parameter Descriptions sourcehandle source buffer extended memory handle. If you used BUFAllocate to allocate an extended memory buffer for your source data (data to be encoded), then sourcehandle should be assigned the value returned in the BUFAllocate bufferhandle parameter. If you allocated a conventional memory buffer or a local array for your source data, sourcehandle should be set to 0 (zero). For any Windows application this parameter should always be set to 0 (zero). source pointer to the memory source buffer obtained from the BUFAllocate call, or a pointer to the start of your data source array. (If you allocated an extended memory buffer for your source data, set source to 0 (zero).) destinationhandle extended memory destination handle. If you used BUFAllocate to allocate an extended memory buffer to hold your encoded output data, destinationhandle is the value returned in the BUFAllocate bufferhandle parameter. Set destinationhandle to 0 (zero) if you want to put the encoded data in a conventional memory buffer.) For any Windows application, this parameter should be set to 0 (zero). destination the start address of the memory destination buffer or array to hold your encoded output data. If you used BUFAllocate to allocated a conventional memory buffer to hold your encoded output data, destination is the pointer returned in the BUFAllocate buffer pointer. (Set destination to 0 (zero) if you are going to put the encoded data in an extended memory buffer.) info pointer to buffer information. The buffer information structure is the same as that described earlier in the BUFAttachProcess call description. count number of data clusters from the source buffer or array that you want to encode. xcount the number of data clusters actually encoded. 4-39 Chapter 4: Software Libraries Function Call Reference BUFMoveIn int BUFMoveIn (unsigned long sourcehandle, char FAR *source, unsigned long destinationhandle, char FAR *destination, BufInfoType FAR *info, unsigned long count, unsigned long FAR *xcount); Call Description The BUFMoveIn call works like the BUFEncode call except no translation or encoding of data is done. The purpose of the call is to transfer data which is already in the proper format for the intended output hardware from a source buffer to a DMA output buffer. The BUFMoveIn call encodes count clusters from your source array or buffer, to the DMA destination buffer (in conventional or extended memory) starting at the next cluster location in the destination buffer. The next cluster location pointer is updated to the end of the data moved. (The next cluster location is available in the buffer info array.) Before you can move your source data into the destination buffer, you must call BUFAttachProcess to associate the DMA process with the destination buffer. Parameter Descriptions sourcehandle source buffer extended memory handle. If you used BUFAllocate to allocate an extended memory buffer for your source data (data to be moved), then sourcehandle should be assigned the value returned in the BUFAllocate bufferhandle parameter. If you allocated a conventional memory buffer or a local array for your source data, sourcehandle should be set to 0 (zero). For any Windows application this parameter should always be set to 0 (zero). source pointer to the memory source buffer obtained from the BUFAllocate call, or a pointer to the start of your data source array. (If you allocated an extended memory buffer for your source data, set source to 0 (zero).) destinationhandle extended memory destination handle. If you used BUFAllocate to allocate an extended memory buffer to hold your output data, destinationhandle is the value returned in the BUFAllocate bufferhandle parameter. Set destinationhandle to 0 (zero) if you want to put the data in a conventional memory buffer. For any Windows application, this parameter should be set to 0 (zero). destination the start address of the memory destination buffer or array to hold your output data. If you used BUFAllocate to allocated a conventional memory buffer to hold your output data, destination is the pointer returned in the BUFAllocate buffer pointer. (Set destination to 0 (zero) if you are going to put the data in an extended memory buffer.) info pointer to buffer information. The buffer information structure is the same as that described earlier in the BUFAttachProcess call description. count number of data clusters from the source buffer or array that you want to move. xcount the number of data clusters actually moved. 4-40 Chapter 4: Software Libraries Function Call Reference BUFMoveOut int BUFMoveOut (unsigned long sourcehandle, char FAR *source, unsigned long destinationhandle, char FAR *destination, BufInfoType FAR *info, unsigned long count, unsigned long FAR *xcount); Call Description The BUFMoveOut call works much like the BUFDecode call except except no translation or deoding of data is done. The purpose of this function is to move input data acquired in a DMA input process into a destination buffer. The BUFMoveOut call transfers a specified number of data units (clusters) from a source buffer to a destination array or buffer you specify. Before you can move a buffer, you must call BUFAttachProcess to associate the DMA process with the buffer. After a call to BUFMoveOut, the "next cluster location pointer" is updated to the end of the data moved. (The next cluster location is available in the buffer info array.) Before you call BUFMoveOut, you will typically use the BUFSeek function to first locate a specific data cluster in the original DMA Buffer. Note, a data cluster is the data transferred in a complete pass through the DMA channel list (see the DMAConfigureList call description for more information on clusters). BUFMoveOut is then called to move the data from the location and put it in the local destination array or buffer. Parameter Descriptions sourcehandle source buffer extended memory handle obtained from the BUFAllocate call. If you allocated a conventional memory buffer, sourcehandle should be set to 0 (zero). For any Windows application this parameter should always be set to 0 (zero). source pointer to the memory buffer obtained from the BUFAllocate call. If you allocated an extended memory buffer, source should be set to 0 (zero). destinationhandle destination buffer handle for the data. Set destinationhandle to 0 (zero) if a local array is used or a conventional memory buffer is used as the destination. For any Windows application, this parameter should be set to 0 (zero). destination pointer to destination buffer or array for the data. Set destination to 0 (zero) if an extended memory buffer is used as the destination. info buffer information. The buffer information structure is the same as that described earlier in the BUFAttachProcess call description. count number of data clusters from the source buffer you want to move. xcount number of data clusters actually moved. If DMA is in progress and at least one cluster has been acquired, you may use the BUFMoveOut call to retrieve this data. If no complete data clusters have been transferred, the BUFMoveOut parameter xcount returns a value of 0 (an error code is returned as well). 4-41 Chapter 4: Software Libraries Function Call Reference BUFSeek int BUFSeek (int origin, BufinfoType far *info, long count, unsigned long bufferhandle, char far *buffer) Call Description The BUFSeek call changes the Next Cluster Location pointer in the buffer information list (info). To locate specific clusters of data, you specify a starting reference point in the buffer (in the call's origin parameter) and the number of clusters (in the count parameter) from that origin to move the Next Cluster Location pointer. Using these parameters you may locate the Next Cluster Location pointer to the start of any data cluster. Three options are available to set the seek origin; the CURRENT pointer location, the BEGINNING of the buffer, and the END of the buffer. The pointer will be moved by the number of clusters specified in count. If count is negative, the pointer is moved back through the buffer the specified number of clusters. After the BUFSeek call is made, the info list is updated with the new next cluster location. Parameter Descriptions origin seek origin. You may specify one of the following origins: BUF_SEEK_CURRENT = seek a cluster starting from the Current Cluster Location pointer. BUF_SEEK_BEGIN = seek a cluster starting from the beginning of the buffer. BUF_SEEK_END = seek a cluster starting from the end of the buffer. info buffer information. Buffer information structure is the same as that described under the BUFAttachProcess function call description. count number of clusters from the origin to which the Next Cluster Location pointer is moved. If the specified count would move past the beginning or end of the buffer, the location pointer wraps back to the end or beginning (respectively) of the buffer. Note, in any case, count must be less than the buffer size in clusters (e.g. if the buffer holds 10 clusters, they are numbered 0 - 9). Note that for "Stop on Command" or "Stop on Trigger" DMA modes, the cluster that marks the beginning of the buffer may not be 0 if the DMA process "wrapped" in the buffer bufferhandle extended memory handle of the buffer. Specify 0 in this parameter if a conventional memory buffer is being used. For any Windows application, this parameter should be set to 0 (zero). buffer pointer to the memory buffer. Specify 0 in this parameter if an extended memory buffer is being used. 4-42 Chapter 4: Software Libraries Function Call Reference 4.5.4 Burst Generator Function Calls BGConfigure Set operating parameters for a burst generator channel C Pascal BASIC int BGConfigure (int slot, int module, int channel, unsigned long burstperiod, unsigned pulseperiod, int pulsesperburst, int mode); function BGConfigure (slot, module, channel: Integer; burstperiod: Longint; pulseperiod: Word; pulsesperburst, mode: Integer): Integer; FUNCTION BGConfigure% (BYVAL slot%, BYVAL mdl%, BYVAL chn%, BYVAL burstp&, BYVAL pulsep%, BYVAL npulse%, BYVAL mode%) BGDisable Disable the specified burst generator channel C Pascal BASIC int BGDisable (int slot, int module, int channel); function BGDisable (slot, module, channel: Integer): Integer; FUNCTION BGDisable% (BYVAL slot%, BYVAL mdl%, BYVAL chn%) BGEnable Enable the specified burst generator channel C Pascal BASIC int BGEnable (int slot, int module, int channel); function BGEnable (slot, module, channel: Integer): Integer; FUNCTION BGEnable% (BYVAL slot%, BYVAL mdl%, BYVAL chn%) BGSetOptions Set the output inversion option of a burst generator channel C Pascal BASIC int BGSetOptions (int slot, int module, int channel, int invertoutput); function BGSetOptions (slot, module, channel, invertoutput: Integer): Integer; FUNCTION BGSetOptions% (BYVAL slot%, BYVAL mdl%, BYVAL chn%, BYVAL invertout%) BGConfigure int BGConfigure (int slot, int module, int channel, unsigned long burstperiod, unsigned pulseperiod, unsigned pulsesperburst, int mode) Call Description Configures the specified burst generator channel in the given slot/module position with a burst period, pulse period, number of pulses per burst, and a mode. The burst generator is disabled by the function call prior to being reconfigured. This call supports the Burst Generator circuits on the PCI-20501C-1,-2 High-Performance EISA Boards, and the PCI-20098C Series Multifunction Boards. Parameter Descriptions slot slot number in which the Board containing the channel is located. module module position number on the Board in the specified slot which contains the channel (module should be set to 0 (zero) for a burst generator on a Board). channel channel to configure (channel 0 (zero) is the only legal burst generator channel). 4-43 Chapter 4: Software Libraries Function Call Reference burstperiod burst period data value. The burst period is specified in multiples of 125 nsec. The burst period must be greater than or equal to the pulse period times the number of pulses per burst. The burst period data value must be an integer in the range of 3 to 4,294,967,295 (375 nsec to 536 sec). pulseperiod pulse period data value. The pulse period is specified in multiples of 125 nsec. The pulse period data value must be an integer in the range of 3 to 4095 (375 nsec to 512 µsec). pulsesperburst number of pulses per burst to generate. Valid range is 1 to 255. If single-shot repetition mode is selected then the number of pulses per burst must be greater than or equal to 2. mode specifies the repetition mode of the burst generator. Burst generator modes are: MODE NAME DESCRIPTION BG_CONT_MODE Continuous mode. The burst generator is started and stopped through software commands (BGEnable and BGDisable). BG_SINGLE_MODE Single-shot mode. The burst generator will output one burst of pulses at the programmed rate at each occurrence of the specified start signal. The start signal is selected in the SYNCConfigure call from sources available through the Board's SYNC Bus. BG_SYNC_MODE SYNC start-stop mode. The burst generator is started and stopped by SYNC signals selected from the Board's SYNC Bus. The start and stop signals are selected using the SYNCConfigure call Example An example code segment, showing the BGConfigure, BGSetOptions, and BGEnable calls in context is listed below. Procedure RunBG(slot, module, channel : Integer; rate : Real); Var burstper : LongInt; pulseper : Word; npulses : Integer; mode : Integer; invertOutput : Integer; err : Integer; Begin burstper := Trunc(8000000.0 / rate); pulseper := 3; npulses := 1; mode := BG_CONT_MODE; { Output generated immediately by BGEnable. } err := BGConfigure(slot, module, channel, burstper, pulseper, npulses, mode); { ... always check error codes returned from calls ... } invertOutput := 0; { FALSE: Use active high output. } err := BGSetOptions(slot, module, channel, invertOutput); { ... check error code ... } err := BGEnable(slot, module, channel); { ... check for error ... } End; 4-44 Chapter 4: Software Libraries Function Call Reference BGDisable int BGDisable (int slot, int module, int channel) Call Description Disable the given burst generator channel. Note, the burst generator is also disabled when a BGConfigure call is made. Parameter Descriptions slot slot number in which the Board containing the channel is located. module module position number on the Board in the specified slot which contains the channel (module should be set to 0 (zero) for a burst generator channel on a Board). channel channel to disable (channel should be set to 0 (zero)). BGEnable int BGEnable (int slot, int module, int channel) Call Description This call enables the given burst generator channel. Parameter Descriptions slot slot number in which the Board containing the channel is located. module module position number on the Board in the specified slot which contains the channel (module should be set to 0 (zero) for a burst generator channel on a Board). channel channel to enable (channel should be set to 0 (zero)) Example An example code segment, showing the BGConfigure, BGSetOptions, and BGEnable calls in shown at the end of the BGConfigure call description. BGSetOptions int BGSetOptions (int slot, int module, int channel, int invertoutput) Call Description This call can be used to set the output inversion option for the given burst generator channel. It is suggested, although not required, that the generator be disabled prior to changing its options. Changing the options "on-thefly" may cause unexpected results. 4-45 Chapter 4: Software Libraries Function Call Reference Parameter Descriptions slot slot number in which the Board containing the channel is located. module module position number on the Board in the specified slot which contains the channel (module should be set to 0 (zero) for a burst generator channel on a Board). channel channel for which option is to be set (channel should be set to 0 (zero)). invertoutput flag indicating whether or not to invert the output of the burst generator channel "1" (TRUE): Inverted Output "0" (FALSE): Noninverted Output (power-on default) Example An example code segment, showing the BGConfigure, BGSetOptions, and BGEnable calls shown at the end of the BGConfigure call description. 4-46 Chapter 4: Software Libraries Function Call Reference 4.5.5 Counters CTRConfigure Set operating parameters and mode for a counter channel C Pascal BASIC int CTRConfigure (int slot, int module, int channel, unsigned long far *data, int mode); function CTRConfigure (slot, module, channel: Integer; var data: Longint; mode: Integer): Integer; FUNCTION CTRConfigure% (BYVAL slot%, BYVAL mdl%, BYVAL chn%, SEG ctrdata&, BYVAL mode%) CTRDisable Disable a counter channel C Pascal BASIC int CTRDisable (int slot, int module, int channel); function CTRDisable (slot, module, channel: Integer): Integer; FUNCTION CTRDisable% (BYVAL slot%, BYVAL mdl%, BYVAL chn%) CTREnable Enable a counter channel C Pascal BASIC int CTREnable (int slot, int module, int channel); function CTREnable (slot, module, channel: Integer): Integer; FUNCTION CTREnable% (BYVAL slot%, BYVAL mdl%, BYVAL chn%) CTRMeasure Perform a period, or pulsewidth measurement using a counter C Pascal BASIC int CTRMeasure (int slot, int module, int channel, int type, double far *period, unsigned far *status); function CTRMeasure (slot, module, channel, msrtype: Integer; var period: Double; var status: Word): Integer; FUNCTION CTRMeasure% (BYVAL slot%, BYVAL mdl%, BYVAL chn%, BYVAL msrtype%, SEG period#, SEG stat%) CTRRead Read the count value and status from a counter channel C Pascal BASIC int CTRRead (int slot, int module, int channel, int reset, unsigned long far *data, unsigned far *status); function CTRRead (slot, module, channel, reset: Integer; var data: Longint; var status: Word): Integer; FUNCTION CTRRead% (BYVAL slot%, BYVAL mdl%, BYVAL chn%, BYVAL resetonrd%, SEG ctrdata&, SEG stat%) CTRReadGroup Read the count values and statuses from all counter channels on a Board or Carrier C Pascal BASIC int CTRReadGroup (int slot, int module, int reset, unsigned long far *data, unsigned far *status); function CTRReadGroup (slot, module, reset: Integer; var data: Longint; var status: Word): Integer; FUNCTION CTRReadGroup% (BYVAL slot%, BYVAL mdl%, BYVAL resetonrd%, SEG ctrdata&, SEG stat%) CTRSetOptions Sets operating options for a counter channel C Pascal int CTRSetOptions (int slot, int module, int channel, int invertoutput, int invertclock, int invertgate, int dividerlatch, int vdcgxclock); function CTRSetOptions (slot, module, channel, invertout, invertclock, invertgate, dividerlatch, vdcgxclock: Integer): Integer; 4-47 Chapter 4: Software Libraries Function Call Reference BASIC FUNCTION CTRSetOptions% (BYVAL slot%, BYVAL mdl%, BYVAL chn%, BYVAL invertout%, BYVAL invertclk%, BYVAL invertgat%, BYVAL divlatch%, BYVAL vdcgxclock%) CTRConfigure int CTRConfigure (int slot, int module, int channel, unsigned long far *data, int mode) Call Description CTRConfigure configures the given counter channel with data values and a mode. This function call supports the two 16-bit counter channels (Counter 0, Counter 1) on the PCI-20501C-1,-2 High-Performance EISA Boards, and the PCI-20098C Series Multifunction Boards. When calling CTRConfigure, the specified counter channel is disabled, and any previous configuration information is lost. Counter channels can be configured in a variety of modes including: Signal Measurement (measurement type is specified in CTRMeasure) Event Counter Divider Variable Duty-Cycle Generator (VDCG) Each 16-bit counter channel can be programmed separately for the above modes (except for VDCG), or they can operate together as a single 32-bit counter unit. When configured for VDCG mode, both counter channels are combined to produce a VDC waveform available at Counter 0's output line. One counter is used to generate the low-going portion of the cycle and the other counter is used to establish the high-going portion. To completely specify, and accomplish any of the above counter operations you will typically use several calls from the Counter function call group. For example: The counter will not begin running in event counter, divider, or variable duty-cycle generator modes until enabled (with a call to CTREnable). In these modes, the counter(s) value(s) may be read with a call to CTRRead or CTRReadGroup. After selecting the counter configuration (16-bit or 32-bit) for signal measurement mode using the CTRConfigure call, a complete measurement process is accomplished by calling CTRMeasure. Parameter Descriptions slot slot number in which the Board containing the channel is located. module module position number on the Board in the specified slot which contains the channel (module should be set to 0 (zero) since these counter channels are always on a Board). channel counter channel to configure (must be channel 0 or 1, must be 0 for a 32-bit counter mode) data an array of data for setting up the counter. These values are ignored in all modes except Divider and Variable Duty-Cycle Generator. For VDCG modes, this data should be an array of two 32-bit values, the low and high pulsewidths (respectively) of the desired output signal. For Divider modes, this should be a single 32-bit divisor value. In Divider modes a signal on the counter's clock input is divided by this value. Allowable data values (decimal) for Divider and VDCG modes are noted below. 4-48 Chapter 4: Software Libraries Function Call Reference Divider Modes 16-bit mode, SDIV_MODE: 2 to 65535 32-bit mode, LDIV_MODE: 2 to 4,294,967,295 VDCG Modes (32-bit modes only) VDCG_MODE using the on-board 8 MHz clock*: low or high pulsewidth: 2 to 65535 (250 nsec to 8.19 msec) low or high count value = (desired pulsewidth in nsec)/125 nsec VDCG_MODE using the external clock input*: low or high pulsewidth: 2 to 65535 (2 * external clock input period) to (65535 * external clock input period) low or high count value = (desired pulsewidth in nsec)/ (external clock period in nsec) * NOTE: The clock source, on-board or external, is specified in the CTRSetOptions call. mode mode for which to configure the counter channel. Counter modes and mode parameters are defined in the following tables. 16-BIT MODE NAME DESCRIPTION SCTR_MODE 16-bit event counter. Counter totals pulses at the clock input as long as counter is enabled. Count value is retrieved using the CTRRead call. SDIV_MODE 16-bit divider. See data parameter description above. Also see CTRSetOptions parameter dividerLatch for additional options. CTREnable call is used to start the counter. SMSR_MODE 16-bit signal measurement. Selects the 16-bit counter configuration for a period or a pulsewidth signal measurement. Period or pulsewidth measurement modes are selected in the type parameter of the CTRMeasure call. 32-BIT MODE NAME DESCRIPTION LCTR_MODE 32-bit event counter. Counter totals pulses at the clock input as long as counter is enabled. Count value is retrieved using the CTRRead call. LDIV_MODE 32-bit divider. See data parameter description above. Also see CTRSetOptions parameter dividerLatch for additional options. CTREnable call is used to start the counter. LMSR_MODE 32-bit signal measurement. Selects the 32-bit counter configuration for a period or a pulsewidth signal measurement. Period or pulsewidth measurement modes are selected in the type parameter of the CTRMeasure call. VDCG_MODE Variable Duty-Cycle Generator. See the data parameter description. CTREnable call is used to start signal generation. Example A programming example using the on-board Counter call group is provided at the end of section 4.5.5. 4-49 Chapter 4: Software Libraries Function Call Reference CTRDisable int CTRDisable (int slot, int module, int channel); Call Description Disable the specified counter channel. Parameter Descriptions slot slot number in which the Board containing the channel is located. module module position number on the Board in the specified slot which contains the channel (module should be set to 0 (zero) since these counter channels are always on a Board). channel channel to disable (must be channel 0 or 1, must be 0 for a 32-bit counter). Example A programming example using the on-board Counter call group is provided at the end of section 4.5.5. CTREnable int CTREnable (int slot, int module, int channel); Call Description Enables the specified counter channel. This call is used to enable counters configured for Event Counter, Divider, and Variable Duty-Cycle Generator (VDCG) modes. Parameter Descriptions slot slot number in which the Board containing the channel is located. module module position number on the Board in the specified slot which contains the channel (module should be set to 0 (zero) since these counter channels are always on a Board). channel counter channel to enable (must be channel 0 or 1, must be 0 for a 32-bit counter). Example A programming example using the on-board Counter call group is provided at the end of section 4.5.5. 4-50 Chapter 4: Software Libraries Function Call Reference CTRMeasure int CTRMeasure (int slot, int module, int channel, int type, double far *period, unsigned far *status) Call Description Performs a period or pulsewidth measurement of a TTL level signal using the indicated counter channel. The counter must be configured through the CTRConfigure call prior to calling CTRMeasure. The measurement result is returned in the period parameter. Parameter Descriptions slot slot number in which the Board containing the channel is located. module module position number on the Board in the specified slot which contains the channel (module should be set to (0) zero since the counter channels are on a Board). channel channel to use for measurement. Must be channel 0 or 1 for 16-bit modes. Must be channel 0 for 32-bit modes. type measurement type. After a 16-bit or 32-bit measurement mode has been selected using the CTRConfigure call, one of the following measurement types may be performed: type NAME DESCRIPTION MEAS_SHORT_PER Measure short period (high frequency signals). This measurement type is recommended for measuring periods shorter than 0.1 msec (frequencies above 10 KHz) with a minimum resolution of 0.1 %. Maximum input frequency is 16 MHz (62.5 nsec period). MEAS_LONG_PER Measure long period (low frequency signals). This measurement type is recommended for measuring periods longer than 0.1 msec (frequencies below 10 KHz) with a minimum resolution of 0.1 %. Lowest measurable input frequency is 0.0018 Hz (536.8 sec period) in 32-bit mode. Lowest measurable input frequency is 122 Hz (8.19 msec period) in 16-bit mode. MEAS_HIGH_PW Measure high-going pulsewidth. The input signal's high-going pulsewidth will be measured to the nearest 125 nsec increment based on the on-board 8 MHz clock. 16bit or 32-bit mode should be selected based on the signal's maximum duration (8.19 msec max for 16-bit mode, 536.8 sec for 32-bit mode). MEAS_LOW_PW Measure low-going pulsewidth. The input signal's low-going pulsewidth will be measured to the nearest 125 nsec increment based on the on-board 8 MHz clock. period the measured period value (expressed in sec). The returned value is a double precision floating point number. In period measurement modes, this is the period of the input signal. In pulsewidth measurement, this is the duration of the pulse. status the counter status information. Compare the status word with the following bit masks to determine if an error occurred during the measurement. CTR_OVERFLOW = Overflow bit mask. The counter overflowed; in short period mode, the signal frequency was too high; in long period mode the signal frequency was too low. 4-51 Chapter 4: Software Libraries Function Call Reference CTR_UNDERFLOW = Underflow bit mask. No signal transitions occurred during the short period measurement (the input signal frequency was too low for this mode). CTR_EOM = End Of Measurement bit mask. The measurement has completed. Example A programming example using the on-board Counter call group is provided at the end of section 4.5.5. CTRRead int CTRRead (int slot, int module, int channel, int reset, unsigned long far *data, unsigned far *status) Call Description Returns the specified counter's current count value (a 32-bit number) and counter status. Optionally, you may reset the counter on a read operation. This call is primarily intended to determine the count value when the counter is used in Event Counter mode. Parameter Descriptions slot slot number in which the Board containing the channel is located. module module position number on the Board in the specified slot which contains the channel (module should be set to 0 (zero) since these counter channels are on a Board). channel channel to read (must be channel 0 or 1, must be 0 for 32-bit modes). reset reset on read flag. Set this parameter to "1" (TRUE) to reset-on-read, or "0" (FALSE) to continue from current count. data 32-bit count value. status counter status information. Compare the status word with the following bit mask to determine if an overflow has occurred: CTR_OVERFLOW = Overflow bit mask. CTRReadGroup int CTRReadGroup (int slot, int module, int reset, unsigned long far *data, unsigned far *status) Call Description This call reads each of the counter channels in the counter group in the specified slot/module position simultaneously. In order of channel number, counter channel data is returned in the array pointed to by data. Optionally, you may reset the counter group when making this call. 4-52 Chapter 4: Software Libraries Function Call Reference Parameter Descriptions slot slot number in which the Board containing the channels are located. module module position number on the Board in the specified slot (module should be set to 0 (zero) since these counter channels are on a Board). reset reset on read flag. Set this parameter to "1" (TRUE) to reset-on-read, or "0" (FALSE) to continue from current count(s). data data read array. Two 32-bit count values are returned (Counter 0 and Counter 1). status counter status array. Compare the status words with the following bit mask to determine if overflows have occurred: CTR_OVERFLOW = overflow bit mask Example A programming example using the on-board Counter call group is provided at the end of section 4.5.5. CTRSetOptions int CTRSetOptions (int slot, int module, int channel, int invertoutput, int invertclock, int invertgate, int dividerlatch, int vdcgxclock) Call Description This call sets the state of options for a given counter channel. These options include: inversion of the counter output signal, inversion of the counter input clock and gate signals, select a divide-by-n operational mode, and determine the clock source for Variable Duty-Cycle Generator (VDCG) mode. The new options are programmed as soon as this call is executed. This call does not disable the counter channel while the options are being set, nor is it required that you disable the counter channel prior making this call (although it is recommended). Parameter Descriptions slot slot number in which the Board containing the channel is located. module module position number on the Board in the specified slot which contains the channel (module should be set to 0 (zero) since counter channels are on a Board). channel counter channel for which options are to be set (channel 0 or 1, must be 0 for 32-bit counter modes). 4-53 Chapter 4: Software Libraries Function Call Reference invertoutput flag indicating whether or not to invert the counter output signal. "1" (TRUE): Counter output signal inverted "0" (FALSE): Counter output signal not inverted The default is no inversion. invertclock flag indicating whether or not to invert the counter clock input signal. "1" (TRUE): Counter clock input signal inverted "0" (FALSE): Counter clock input signal not inverted The default is no inversion. invertgate flag indicating whether or not to invert the counter's gate input. "1" (TRUE): Counter gate input signal inverted "0" (FALSE): Counter gate clock input signal not inverted The default is no inversion. dividerlatch flag indicating whether to have the divider circuit on the counter work in continuous or latched mode. The value of this parameter is irrelevant in counter modes other than Divider (see the CTRConfigure call's mode parameter description). If the divider is not set for latched mode, it operates in "continuous" mode. "1" (TRUE): Divider circuit operates in latched mode "0" (FALSE): Divider circuit operates in continuous mode The default is continuous mode. In continuous mode, the divider works as a regular divide-by-N-counter, where one output pulse is produced for every N clock input pulses. The duration of the output pulse will be equal to one clock input period. In latched mode, the divider will not start counting until a "trigger" pulse has been received. After N clock input pulses the divider output will go active (and stay active) until the counter is reset by a CTREnable or a CTRRead call. Once reset, the divider will wait for another trigger before beginning another division cycle. The trigger source is selected from one of the SYNC Bus signals available on the SYNC Bus using the SYNCConfigure call. vdcgxclock flag indicating whether to use the external clock input for the VDCG clock source, or the on-board 8 MHz clock. (Also see the CTRConfigure call's mode parameter description.) "1" (TRUE): Use external clock input. "0" (FALSE): Use on-board 8 MHz clock. The default is the 8 MHz clock. 4-54 Chapter 4: Software Libraries Function Call Reference Example An example code segment, showing the CTRConfigure, CTRSetOptions, CTREnable, and CTRRead calls for event counter mode is listed below. Var dummyData : LongInt;{ The data parameter passed to } { CTRConfigure is not used in } { event counter mode. It is used only } { in divider and variable duty-cycle } { generator modes. } Begin { Program the counter for event counting. { of events reaches 1000. } mode := LCTR_MODE; { { { { Read it until the number } Since we are using 32-bit counter mode, } we must set channel to 0 and we cannot } use channel 1 again without reconfiguring } channel 0 for a 16-bit mode. } channel := 0; err := CTRConfigure(slot, module, channel, data, mode); { ... test for errors during the call ... } invertOutput := 0; { FALSE: Active high output. } invertClock := 0; { FALSE: Count low-to-high transitions. } invertGate := 0; { FALSE: Pull gate low to inhibit counting. } dividerLatchMode := 0; { Not used when configured for event counting. } VDCGExternalClock := 0; { Not used when configured for event counting. } err := CTRSetOptions(slot, module, channel, invertOutput, invertClock, invertGate, dividerLatchMode, VDCGExternalClock); { ... check for errors ... } err := CTREnable(slot, module, channel); { ... check for errors ... } Repeat resetOnRead := 0; { FALSE: Let the counter continue. } err := CTRRead(slot, module, channel, resetOnRead, data, status); { ... test for error conditions reported by the read call ... } Until (count >= 1000); 4-55 Chapter 4: Software Libraries Function Call Reference 4.5.6 Counters, 8254-Based CTR8254Configure Configure the given counter channel with an initial count and a mode C Pascal BASIC int CTR8254Configure (int slot, int module, int channel, unsigned count, int mode); function CTR8254Configure (slot, module, channel: Integer; count: Word; mode: Integer): Integer; FUNCTION CTR8254Configure% (BYVAL slot%, BYVAL mdl%, BYVAL chn%, BYVAL cnt%, BYVAL mode%) CTR8254Disable Disable the specified counter channel C Pascal BASIC int CTR8254Disable (int slot, int module, int channel); function CTR8254Disable (slot, module, channel: Integer): Integer; FUNCTION CTR8254Disable% (BYVAL slot%, BYVAL mdl%, BYVAL chn%) CTR8254Enable Enable the specified counter channel C Pascal BASIC int CTR8254Enable (int slot, int module, int channel); function CTR8254Enable (slot, module, channel: Integer): Integer; FUNCTION CTR8254Enable% (BYVAL slot%, BYVAL mdl%, BYVAL chn%) CTR8254Measure Measure a frequency with an 8254 counter channel using a 8254 rate generator channel as the time base C Pascal BASIC int CTR8254Measure (int slot, int module, int channel, int rgslot, int rgmodule, int rgchannel, int gatetime, double far *frequency, unsigned far *status); function CTR8254Measure (slot, module, channel, rgslot, rgmodule, rgchannel, gt: Integer; var frequency: Double; var status: Word): Integer; FUNCTION CTR8254Measure% (BYVAL slot%, BYVAL mdl%, BYVAL chn%, BYVAL rgslot%, BYVAL rgmdl%, BYVAL rgchn%, BYVAL gtim%, SEG frq#, SEG stat%) CTR8254Read Returns count value of specified counter channel and status information C Pascal BASIC int CTR8254Read (int slot, int module, int channel, int reset, unsigned long far *data, unsigned far *status); function CTR8254Read (slot, module, channel, reset: Integer; var data: Longint; var status: Word): Integer; FUNCTION CTR8254Read% (BYVAL slot%, BYVAL mdl%, BYVAL chn%, BYVAL resetonrd%, SEG ctrdata&, SEG stat%) CTR8254ReadGroup Returns count values of the specified counter group and status information C Pascal BASIC 4-56 int CTR8254ReadGroup (int slot, int module, int reset, unsigned long far *data, unsigned far *status); function CTR8254ReadGroup (slot, module, reset: Integer; var data: Longint; var status: Word): Integer; FUNCTION CTR8254ReadGroup% (BYVAL slot%, BYVAL mdl%, BYVAL resetonrd%, SEG ctrdata&, SEG stat%) Chapter 4: Software Libraries Function Call Reference CTR8254Configure int CTR8254Configure (int slot, int module, int channel, unsigned count, int mode) Call Description This call configures the given 8254-based counter channel on a PCI-20007M Counter/Timer/Rate Generator Module, or the 8254-based counters on a PCI-20089W Board, PCI-20377W-1 Low Power Multifunction Board or PCI-20428W Series Multifunction Board. If the device is jumpered for "software gate control" (see below), the counter will not begin running until enabled (with a call to CTR8254Enable). The counter may be read with a call to CTR8254Read or CTR8254ReadGroup. The counter channel is disabled when CTR8254Configure is called. Any previous configuration information is lost. The PCI-20007M-1A Module has four general purpose 8254-based counter timer channels. Each channel contains a 16-bit presettable down counter, whose contents can be loaded and read back with CTR8254 function calls. Individual channels can be programmed for a variety of counting, pulse and periodic output functions. In addition to these four general purpose channels, the PCI-20007M has a dedicated rate generator channel based on the 8254. See the section on rate generator calls for information on programming this feature. The PCI-20089W Analog Input Board has one 8254-based general purpose counter channel and one 8254-based rate generator channel. The section on rate generator calls covers information on programming the rate generator. The PCI-20377W Low Power Multifunction Board has one 8254-based general purpose counter channel and one 8254-based rate generator channel. The section on rate generator calls covers information on programming the rate generator. NOTE: If the Rate Generator section of the PCI-20377W Board has been configured for 32-bit operation, via the SetOptions377 function call, Counter 0 of this Board will not be available. PCI-20428W Low Cost Multifunction Boards have one general purpose 8254 based counter channel (Counter channel 0). Two other 8254 counter circuits are used for the Analog Input and Analog Output Rate Generators on these boards. The general purpose counter channel has a clock input, a gate input, and an output line. All three of these TTL-Level compatible lines are available at the I/O signal connector of the board. The 8254 counter circuits on all the above hardware are programmed the same way using the CTR8254 function calls. PCI-20007M and PCI-20089W Counter Gate Input Considerations On a PCI-20007M, each general purpose channel has a clock input, a gate input, and an output line. All three signals for each channel are available at the external signal connector of the Module. The gate inputs must be internally jumpered for "software gate control" in order for the calls CTR8254Disable and CTR8254Enable to work. When gate inputs are jumpered for "software gate control", they are no longer available at the Module's external signal connector. Note: Software gate control is the factory default jumper configuration for the PCI20007M Module. On a PCI-20089W-1A Analog Input Board, the general purpose channel has a clock input, a gate input, and an output line. All three signals for each channel are available at the external Digital I/O (P3) signal connector of the board. The gate input must be internally jumpered (jumper W19 IN, and jumper W18 OUT) for the calls CTR8254Disable and CTR8254Enable to work. When the gate input is jumpered for "software gate control", it is no longer available at the connector. Note: Software gate control is the factory default jumper configuration for the PCI-20089W-1A. 4-57 Chapter 4: Software Libraries Function Call Reference PCI-20377W and PCI-20428W Counter Gate Input Considerations The PCI-20377W and PCI-20428W do not employ software gate control. When using these boards, the proper external logic levels must be applied to the counter gate inputs for the CTR8254Disable and CTR8254Enable calls to work. Parameter Descriptions slot slot number in which the Board or Carrier or Module containing the 8254-based counter channel is located. module module position number on the Board or Carrier in the specified slot which contains the channel (module should be set to 0 (zero) for a channel on a Board). channel 8254-based counter channel to configure (can be channel 0, 1, 2 or 3 on a PCI-20007M Module, can be channel 0 or 1 on a PCI-20377W Board, must be channel 0 on a PCI-20089W Board or a PCI-20428W Board). count 16-bit initial count value for the counter channel. When enabled, the counter will count down beginning at this value. When the count value reaches 0, the counter will reset to count and begin counting again. See the mode parameter for restrictions on initial count values. mode mode value (0, 1, 2, 3, 4, or 5) for which to configure the specified counter channel. Counter channels can be configured to operate in 6 different modes. Each counter can provide a pulse, a pulse train, a square wave, or an indication of a terminal count. Please refer to the appropriate hardware manual(s) for detailed counter mode definitions. Briefly, the available modes are: Mode 0 Interrupt on Terminal Count The counter is loaded with an initial count, and its output line is set low. When the counter is enabled, the counter counts down for each input clock pulse. When the count value reaches 0, the output line goes high. The initial count must be 1 or greater. Mode 1 Hardware Retriggerable One-Shot After the counter is configured with an initial count N, its output line is set high. A rising edge on its gate input triggers the one-shot and the output goes low for N input pulses then returns high. If another trigger edge occurs before the output returns high, the output will remain low for an addition N input pulses. Note: In this mode the channel's gate control jumper for the channel must be in the hardware control position. In this case, the calls CTR8254Disable and CTR8254Enable will have no effect. The initial count must be 1 or greater. Mode 2 Rate Generator Rate generator mode essentially configures the counter channel as a divide-by-N counter. When the initial count N is loaded, and the counter is enabled, the output goes high for N input clock cycles - then goes low for one clock cycle. This sequence is repeated every N counts. The initial count must be greater than 1. 4-58 Chapter 4: Software Libraries Function Call Reference Mode 3 Square Wave Generator In this mode, when the initial count N is loaded and the counter is enabled, the output goes high and stays high for N/2 input clock cycles - then goes low for N/2 input cycles. As long as the counter is enabled this sequence repeats to produce a squarewave output signal. Note: If the initial count is an odd number, the output stays high for (N+1)/2 counts and low for (N-1)/2 counts. The initial count must be greater than 1. Mode 4 Software Triggered Strobe In this mode, loading the initial count N "triggers" the counting sequence. Initially the output is set high. The output goes low for one input clock cycle every N+1 clock pulses. This sequence repeats every time a count N is written to the counter. Disabling the counter stops counting but has no effect on the output level. The initial count must be 1 or greater. Mode 5 Hardware Retriggered Strobe The trigger signal must be provided at the counter channel's gate input. A rising edge at the channel's gate input initiates the process. Note: In this mode the gate control jumper for the channel must be set for hardware control. As a result, the calls CTR8254Disable and CTR8254Enable will have no effect. The initial count must be 1 or greater. Example An example code segment, showing the CTR8254Configure, CTR8254Enable, CTR8254Disable, and CTR8254Read calls in context is listed below. count := 1000; mode := 2; err := CTR8254Configure(slot, module, channel, count, mode); { ... test for errors after every call ... } err := CTR8254Enable(slot, module, channel); { ... check for errors ... } { Wait for the counter to count to 1000 (actually, it counts down from } { 1000 to 0. } Repeat resetOnRead := 0; { FALSE: Don't reset the count value } { to 0 after the read; we want it to } { continue. } err := CTR8254Read(slot, module, channel, resetOnRead, data, status); { ... test for error ... } Writeln ('Count value = ', data); Until (status And CTR8254_OVERFLOW) <> 0; err := CTR8254Disable(slot, module, channel); { ... check for error, even on a simple call like this ... } CTR8254Disable int CTR8254Disable (int slot, int module, int channel) Call Description Disable the specified 8254-based counter channel. Note: The counter gate input(s) of a PCI-20007M or a PCI-20089W-1A must be internally jumpered for "software gate control" in order for the calls CTR8254Disable and CTR8254Enable to work. 4-59 Chapter 4: Software Libraries Function Call Reference Parameter Descriptions slot slot number in which the Board or Carrier or Module containing the 8254-based counter channel is located. module module position number on the Board or Carrier in the specified slot which contains the channel (module should be set to 0 (zero) for a channel on a Board). channel 8254-based counter channel to disable (can be channel 0, 1, 2 or 3 on a PCI-20007M Module, can be channel 0 or 1 on a PCI-20377W Board, must be 0 for a channel on a PCI-20089W Board or a PCI-20428W Board). CTR8254Enable int CTR8254Enable (int slot, int module, int channel) Call Description Enables the given 8254-based counter channel for its configured mode. The counter is reset during the enable process. Note: The counter gate input(s) of a PCI-20007M or a PCI-20089W-1A must be internally jumpered for "software gate control" in order for the calls CTR8254Disable and CTR8254Enable to work. Parameter Descriptions slot slot number in which the Board or Carrier or Module containing the 8254-based counter channel is located. module module position number on the Board or Carrier in the specified slot which contains the channel (module should be set to 0 (zero) for a channel on a Board). channel 8254-based counter channel to enable (can be channel 0, 1, 2 or 3 on a PCI-20007M Module, can be channel 0 or 1 on a PCI-20377W Board, must be 0 for a channel on a PCI-20089W Board or a PCI-20428W Board). CTR8254Measure int CTR8254Measure (int slot, int module, int channel, int rgslot, int rgmodule, int rgchannel, int gatetime, double far *frequency, unsigned far *status) Call Description The CTR8254Measure call allows you to read a frequency to a specified precision, using an 8254 general purpose counter channel and a rate generator channel in combination. The rate generator channel is used as the time base for the measurement. The output of the selected rate generator must be connected to the gate input of the selected counter, and the input signal must be connected to the clock input of the selected counter. The counter channel must be configured for an externally controlled gate. Hardware interconnection instructions are given at the end of this call's parameter descriptions. 4-60 Chapter 4: Software Libraries Function Call Reference The gatetime parameter of the CTR8254Measure call is used to specify the gate period, in msec, to be used for the frequency measurement. Allowed values are 1, 10, 100, 1000, and 10000 msec. This allows you measure frequencies with various resolutions. The practical limits of the measurement are from about 1 Hz to about 8 MHz. The counter channel and rate generator channel are automatically configured and enabled appropriately by the this call. Any previous configuration information is lost. NOTE: If you are using the PCI-20377W's rate generator it must be configured for 32-bit operation. To configure the Rate Generator for this mode, you must call SetOptions377 with the parameter rgdouble equal to "1" (TRUE). NOTE: The PCI-20428W Board does not support the frequency measurement function. Parameter Descriptions slot slot number in which the Board or Carrier or Module containing the 8254-based counter channel is located. module module position number on the Board or Carrier in the specified slot which contains the channel (module should be set to zero for a channel on a Board). channel 8254-based counter channel to enable (can be channel 0, 1, 2 or 3 on a PCI-20007M Module, can be channel 0 or 1 on a PCI-20377W Board, must be 0 for a channel on a PCI-20089W Board). rgslot slot number in which the Board or Carrier or Module containing the 8254-based rate generator channel is located. rgmodule module position number on the Board or Carrier in the specified slot which contains 8254-based rate generator channel (module should be set to zero for a channel on a Board). rgchannel 8254-based rate generator channel. gatetime gate time in milliseconds: allowed values are 1, 10, 100, 1000, and 10000 msec. frequency the result of the floating point frequency measurement. The data value in returned in units of Hz. status status information. Compare the status word with the following bit mask to determine if an overflow has occurred: CTR8254_OVERFLOW = overflow bit mask 4-61 Chapter 4: Software Libraries Function Call Reference Hardware Set Up The instruction requires that the hardware be hooked-up as follows: [1] Using a connection at a termination panel, connect the selected rate generator output to the GATE input of the counter channel selected to make the measurement. [2] The signal whose frequency is to be measured must be connected to the CLOCK input of the counter channel selected. [3] The counter channel must be jumpered for hardware-gated operation (see the appropriate hardware Manual for the proper jumper selections). [4] The signal to be measured must be conditioned to be TTL compatible, or damage to the hardware may occur. The rise and fall times of the signal should not exceed 25 nsec. For other specification details refer to the Intel 8254 data sheet, and to the appropriate hardware Manual. CTR8254Read int CTR8254Read (int slot, int module, int channel, int reset, unsigned long far *data, unsigned far *status) Call Description Reads the specified 8254-based (e.g. PCI-20007M Counter/Timer Module) counter channel, optionally resetting it, returning the count value (a 32-bit number). A counter status word is also returned. Parameter Descriptions slot slot number in which the Board or Carrier or Module containing the 8254-based counter channel is located. module module position number on the Board or Carrier in the specified slot which contains the channel (module should be set to zero for a channel on a Board or Carrier). channel 8254-based counter channel to read (can be channel 0, 1, 2 or 3 on a PCI-20007M Module, can be channel 0 or 1 on a PCI-20377W Board, 0 for a channel on a PCI-20089W Board or a PCI-20428W Board). reset reset on read flag. Set this parameter to "1" (TRUE) to reset-on-read, or "0" (FALSE) to continue from current count. data data read. Remember that the 8254 is a down counter. status the counter status. Compare the status word with the following bit masks to determine if counter errors have occurred: CTR8254_NULL_CNT = Null count bit mask. A valid count has not been loaded into the counter. Since the initial count (specified in CTR8254Configure) is loaded upon the first input pulse, a null count indicates the counter's clock input had not received an input pulse at the time the counter was read. 4-62 Chapter 4: Software Libraries Function Call Reference CTR8254_OUT_PIN = Output pin state bit mask. This bit allows you to test the state (1 ,0) of the counter's output (pin). Example An example code segment, showing the CTR8254Read call is given with the CTR8254Configure call description. CTR8254ReadGroup int CTR8254ReadGroup (int slot, int module, int reset, unsigned long far *data, unsigned far *status) Call Description Reads all of the 8254-based counter channels on the specified device "simultaneously". The data is placed in an array of 32-bit numbers. On the PCI-20007M, the first three counter channels (0, 1, and 2) are latched simultaneously, while counter channel 3 is latched as soon as possible after the others. If the rgdouble option of the SetOptions377 call has not been set, CTR8254ReadGroup simultaneously reads Counter channels 0 and 1 on the PCI-20377W. The data is placed in a two element array of 32-bit numbers. If the rgdouble option has been set (to TRUE or 1), data and status are still placed in a two element array, but only the data for Counter channel 1 is valid and a warning error is set. Parameter Descriptions slot slot number in which the Board or Carrier or Module containing the 8254-based counter group is located. module module position number on the Board or Carrier in the specified slot which contains the group (module should be set to zero for a channel on a Board or Carrier). data data read array. Each counter's value is stored as a 32-bit number. The first array element will contain counter channel 0 data, the second element will contain channel 1 data, and so on. status counter status array. Compare the status words with the following bit masks to determine if counter errors have occurred: CTR8254_NULL_CNT = Null count bit mask. A valid count has not been loaded into the counter. Since the initial count is loaded upon the first input pulse, this means that the counter's clock input had not received an input at the time the counter was read. CTR8254_OUT_PIN = Output pin state bit mask. The state (1 ,0) of the counter's output (pin). 4-63 Chapter 4: Software Libraries Function Call Reference 4.5.7 Digital Input/Output DIOConfigure Configure a digital I/O port for input or output and basic or handshake mode C Pascal BASIC int DIOConfigure (int slot, int module, int port, int input, int handshake, unsigned data); function DIOConfigure (slot, module, port, dioinput, handshake, data: Word): Integer; FUNCTION DIOConfigure% (BYVAL slot%, BYVAL mdl%, BYVAL port%, BYVAL dioinput%, BYVAL handshake%, BYVAL diodata%) DIORead Read a specified digital I/O port C Pascal BASIC int DIORead (int slot, int module, int port, unsigned far *data); function DIORead (slot, module, port: Integer; var data: Word): Integer; FUNCTION DIORead% (BYVAL slot%, BYVAL mdl%, BYVAL port%, SEG diodata%) DIOReadBit Read a specified bit on a digital I/O port C Pascal BASIC int DIOReadBit (int slot, int module, int port, int portbit, unsigned far *data); function DIOReadBit (slot, module, port, portbit: Integer; var data: Word): Integer; FUNCTION DIOReadBit% (BYVAL slot%, BYVAL mdl%, BYVAL port%, BYVAL portbit%, SEG diodata%) DIOStatus Return handshake status of specified digital I/O port. C Pascal BASIC int DIOStatus (int slot, int module, int port, unsigned far *status); function DIOStatus (slot, module, port: Integer; var status: Word): Integer; FUNCTION DIOStatus% (BYVAL slot%, BYVAL mdl%, BYVAL port%, SEG stat%) DIOWrite Write a value to a digital I/O port C Pascal BASIC int DIOWrite (int slot, int module, int port, unsigned data); function DIOWrite (slot, module, port, data: Word): Integer; FUNCTION DIOWrite% (BYVAL slot%, BYVAL mdl%, BYVAL port%, BYVAL diodata%) DIOWriteBit Write a value to specified bit on a digital I/O port C Pascal BASIC 4-64 int DIOWriteBit (int slot, int module, int port, int portbit, unsigned data); function DIOWriteBit (slot, module, port, portbit, data: Word): Integer; FUNCTION DIOWriteBit% (BYVAL slot%, BYVAL mdl%, BYVAL port%, BYVAL portbit%, BYVAL diodata%) Chapter 4: Software Libraries Function Call Reference DIOConfigure int DIOConfigure (int slot, int module, int port, int input, int handshake, unsigned data) Call Description This call configures the specified 8-bit digital I/O port as an input or an output. This call can also be used to set the port for digital I/O handshake mode, or for basic digital I/O operation. Basic digital I/O operation support includes the Digital I/O functions on the PCI-20001C-2 General Purpose Carrier with DIO, PCI-20041C HighPerformance Carriers, PCI-20004M-1 Digital Input/Output Module, the PCI-20501C Series, PCI-20098C Series, PCI-20087W-1, PCI-20377W, PCI-20378W Series and the PCI-20428W Series. Digital I/O handshake mode is supported on the PCI-20501C-1, PCI-20501C-2, PCI-20098C and the PCI-20087W-1. Parameter Descriptions slot slot number in which the Board or Carrier or Module containing the digital I/O port is located. module module position number on the Board or Carrier in the specified slot which contains the I/O port (module should be set to zero for a channel on a Board or Carrier). port digital I/O port to configure (0, 1, 2, 3, …, 29 depending on the Board or Carrier/Module used). PCI-20087W Note: When port 2 or 3 is configured for handshake mode, port 4 of the PCI-20087W-1 is used for the handshake signals. input flag indicating whether the port is to be configured for digital input or output. Note: The digital I/O port configuration on PCI-20377W and PCI-20428W Boards are fixed. This parameter should match the direction of the fixed I/O port for these Boards. "1" (TRUE) for digital input "0" (FALSE) for digital output handshake flag indicating whether or not to configure the port for handshake mode. "1" (TRUE) for handshake mode* "0" (FALSE) for basic I/O mode, can be TRUE or FALSE for the PCI-20501C Series or PCI-20098C Series Boards or port 2 or 3 of a PCI-20087W-1 Board. must be FALSE for the PCI-20001C-2, PCI-20041C, PCI-20004M-1 Modules, and the PCI20377W, PCI-20378W and PCI-20428W Boards. * Please refer to appropriate chapter of the hardware device's manual for information on the operation and hookup of digital I/O handshake signals. data initial data written to a port configured for digital output (must be a right-justified 16-bit word). Example An example code segment, showing the DIOConfigure, DIOWrite, and DIORead calls in context is listed below. Var dummyData : Integer; { The data parameter to DIOConfigure } { is not used when the channel is } { being configured as an input. } 4-65 Chapter 4: Software Libraries Function Call Reference Begin outputPort := 0; input := 0; { FALSE: Configure port 0 as an output. } handshake := 0; { FALSE: Use standard, asynchronous, I/O. } outputData :=128 err := DIOConfigure(slot, module, outputPort, input, handshake, outputData); inputPort := 1; input := 1; { TRUE: Configure port 1 as an input. } handshake := 0; { FALSE: Use standard, asynchronous, I/O. } err := DIOConfigure(slot, module, inputPort, input, handshake, dummyData); For outputData := 0 To $ff Do Begin err := DIOWrite(slot, module, outputPort, outputData); { ... check for write errors ... } err := DIORead(slot, module, inputPort, inputData); { ... check for read errors ... } End; DIORead int DIORead (int slot, int module, int port, unsigned far *data) Call Description Reads the given 8-Bit digital I/O port and returns the value read. If the port being read is configured for handshake mode, the call waits for data to be ready on the port before doing the read. See DIOConfigure for supported hardware and modes. IMPORTANT: In handshake mode, you should be aware that if no data is ever received by the port, the call will be caught in an infinite loop. In handshake mode, you can call DIOStatus before a DIORead call to determine that the input port is ready (has data) and avoid this situation. Reading back a port configured as an output returns the last data value written with the DIOWrite call. Parameter Descriptions slot slot number in which the Board or Carrier or Module containing the digital I/O port is located. module module position number on the Board or Carrier in the specified slot which contains the I/O port (module should be set to zero for a channel on a Board or Carrier). port digital I/O port to read (0, 1, 2, 3,…, 29 depending on the Board or Carrier/Module used). Note: When port 2 or 3 is configured for handshake mode, port 4 of the PCI-20087W-1 is used for the handshake signals. data the digital input value read from the given port. The data is reported as a 16-bit word, the port's value is the least significant 8-bits (the upper 8-bits are set to 0). Example An example code segment, showing the DIOConfigure, DIOWrite, and DIORead calls is given in the DIOConfigure call description. 4-66 Chapter 4: Software Libraries Function Call Reference DIOReadBit int DIOReadBit (int slot, int module, int port, int portbit, unsigned far *data) Call Description Reads the state of a single digital I/O port bit. This call does not support a digital I/O port configured for handshake mode Parameter Descriptions slot slot number in which the Board or Carrier or Module containing the digital I/O port is located. module module position number on the Board or Carrier in the specified slot which contains the I/O port (module should be set to zero for a channel on a Board or Carrier). port digital I/O port to read (0, 1, 2, 3, …, 29 depending on the Board or Carrier/Module used). portbit digital I/O port bit (0 - 7 where bit 0 = LSB, bit 7 = MSB) data the digital data read from the given port bit. The state (1, 0) of the port bit is returned. DIOStatus int DIOStatus (int slot, int module, int port, unsigned far *status) Call Description This call returns the status of the indicated PCI-20501C-1, PCI-20501C-2, PCI-20087W-1, or PCI-20098C digital I/O port that has been configured for handshake mode (via the DIOConfigure call). This call can be used to avoid a potential infinite looping situation with the DIORead and DIOWrite calls when the ports are in handshake mode. Parameter Descriptions slot slot number in which the Board or Carrier or Module containing the digital I/O port is located. module module position number on the Board or Carrier in the specified slot which contains the I/O port (module should be set to zero for a channel on a Board or Carrier). port digital I/O port status to read (0, 1, 2, 3, or 4 depending on the Board or Carrier/Module used). Note: When port 2 or 3 is configured for handshake mode, port 4 of the PCI-20087W-1 is used for the handshake signals. status the port's status information. Compare the status word with the following bit mask to determine whether the channel is ready for a read or write operation. 4-67 Chapter 4: Software Libraries Function Call Reference DIO_READY = Data ready bit mask. For input ports: "1" means that data is available at the input port to be read. For output ports: "1" means that the output port is ready to receive another byte to output. DIOWrite int DIOWrite (int slot, int module, int port, unsigned data) Call Description This call writes the indicated value (in data) to the given digital I/O port. If the port being written is configured for handshake mode, the call waits for the port to be ready to receive new data before writing the value. (See DIOConfigure for supported hardware and modes.) Data should be right justified, 16-bit. NOTE: In handshake mode, you should be aware that if the port never shows a status of ready, the call will be caught in an infinite loop. When operating in handshake mode, you may want to call DIOStatus prior to calling DIOWrite to determine that the output port is ready to receive data. Please refer to appropriate chapter of the hardware device's manual for information on the operation of digital I/O handshake signals. Parameter Descriptions slot slot number in which the Board or Carrier or Module containing the digital I/O port is located. module module position number on the Board or Carrier in the specified slot which contains the I/O port (module should be set to zero for a channel on a Board or Carrier). port digital I/O port to write data to (0, 1, 2, 3,…, 29 depending on the Board or Carrier/Module used). Note: When port 2 or 3 is configured for handshake mode, port 4 of the PCI-20087W-1 is used for the handshake signals. data digital value to write to the given port. The port data value must be a 16-bit word with the least significant 8bits being the byte you wish to send. Example An example code segment, showing the DIOConfigure, DIOWrite, and DIORead is calls given in the DIOConfigure call description. DIOWriteBit int DIOWriteBit (int slot, int module, int port, int portbit, unsigned data) Call Description This call writes a single digital I/O port bit whose value is indicated in data. This call does not support a digital I/O port configured for handshake mode. 4-68 Chapter 4: Software Libraries Function Call Reference Parameter Descriptions slot slot number in which the Board or Carrier or Module containing the digital I/O port is located. module module position number on the Board or Carrier in the specified slot which contains the I/O port (module should be set to zero for a channel on a Board or Carrier). port digital I/O port to write data to (0, 1, 2, 3,…, 29 depending on the Board or Carrier/Module used). portbit digital I/O port bit (0 - 7, where 0=LSB, 7=MSB) data digital value (0, 1) to write to the given port bit. 4-69 Chapter 4: Software Libraries Function Call Reference 4.5.8 Direct Memory Access (DMA) Calls DMAConfigureList Configure the channel list for a specified DMA process C Pascal BASIC int DMAConfigureList (int processhandle, int start, int stop, unsigned long startdelay, unsigned long stopdelay, unsigned long clustercount, int count, DMAListType far *list, int groupAI, int far *clustersize); function DMAConfigureList (processhandle, start, stop: Integer; startdelay, stopdelay, clustercount: Longint; count: Integer; var list: DMAListType; groupAI: Integer; var clustersize: Integer): Integer; FUNCTION DMAConfigureList% (BYVAL prchnd%, BYVAL st%, BYVAL stp%, BYVAL std&, BYVAL stpd&, BYVAL cc&, BYVAL cnt%, SEG lst AS DMAListType, BYVAL grp%, SEG clustsiz%) DMAFreeHandle Free the specified DMA process handle C Pascal BASIC int DMAFreeHandle (int processhandle); function DMAFreeHandle (processhandle: Integer): Integer; FUNCTION DMAFreeHandle% (BYVAL prchnd%) DMAGetHandle Assign a handle to a DMA process C Pascal BASIC int DMAGetHandle (int far *processhandle); function DMAGetHandle (var processhandle: Integer): Integer; FUNCTION DMAGetHandle% (SEG prchnd%) DMAHugeGetHandle Assign a handle to a Huge DMA process (>64 kbyte buffer, Windows applications only) C Pascal BASIC int DMAHugeGetHandle (int far *processhandle); function DMAHugeGetHandle (var processhandle: Integer): Integer; FUNCTION DMAHugeGetHandle% (SEG prchnd%) DMASetOptions Set the options for the specified DMA process C Pascal BASIC int DMASetOptions (int processhandle, int channel, unsigned long reserved); function DMASetOptions (processhandle, channel: Integer; reserved: Longint): Integer; FUNCTION DMASetOptions% (BYVAL prchnd%, BYVAL chn%, BYVAL reserved&) DMASetPacer Identify the pacer source for a specified DMA process C Pascal BASIC int DMASetPacer (int processhandle, int slot, int module, int channel, int iotype); function DMASetPacer (processhandle, slot, module, channel, iotype: Integer): Integer; FUNCTION DMASetPacer% (BYVAL prchnd%, BYVAL slot%, BYVAL mdl%, BYVAL chn%, BYVAL iotype%) DMASetTrigger Identify the trigger source for a specified DMA process C Pascal BASIC 4-70 int DMASetTrigger (int processhandle, int slot, int module, int channel, int iotype); function DMASetTrigger (processhandle, slot, module, channel, iotype: Integer): Integer; FUNCTION DMASetTrigger% (BYVAL prchnd%, BYVAL slot%, BYVAL mdl%, BYVAL chn%, BYVAL iotype%) Chapter 4: Software Libraries Function Call Reference DMAStart Start a specified DMA process C int DMAStart (int processhandle, unsigned long bufferhandle, char far *buffer, unsigned long buffersize); function DMAStart (processhandle: Integer; bufferhandle: Longint; buffer: POINTER; buffersize: Longint): Integer; FUNCTION DMAStart% (BYVAL prchnd%, BYVAL bufhnd&, BYVAL buffer&, BYVAL bufsiz&) Pascal BASIC DMAStatus Get the status and buffer information of the specified DMA process C int DMAStatus (int processhandle, unsigned far *status, BufInfoType far *info); function DMAStatus (processhandle: Integer; var status: Word; var info: BufInfoType): Integer; FUNCTION DMAStatus% (BYVAL prchnd%, SEG stat%, SEG info AS BufInfoType) Pascal BASIC DMAStop Stop the specified DMA process and get the status and buffer information C Pascal int DMAStop (int processhandle, unsigned far *status, BufInfoType far *info); function DMAStop (processhandle: Integer; var status: Word; var info: BufInfoType): Integer; FUNCTION DMAStop% (BYVAL prchnd%, SEG stat%, SEG info AS BufInfoType) BASIC DMASwap Switch to a new data buffer when DMA terminal count is detected (DOS applications only) C int DMASwap (int processhandle, unsigned long bufferhandle, char far *buffer, unsigned far *status, BufInfoType far *info); function DMASwap (processhandle: Integer; bufferhandle: Longint; buffer: Pointer; var status: Word; var info: BufInfoType): Integer; FUNCTION DMASwap% (BYVAL prchnd%, BYVAL bufhnd&, BYVAL buffer&, SEG stat%, SEG info AS BufInfoType) Pascal BASIC DMAConfigureList int DMAConfigureList (int processhandle, int start, int stop, unsigned long startdelay, unsigned long stopdelay, unsigned long clustercount, int count, DMAListType far *list, int groupAI, int far *clustersize) Call Description The DMAConfigureList call is used in all DMA operations to define DMA hardware operating parameters, specify the I/O data you want transferred, and the order data will be sent or received. Specifically, for the DMA process identified by the processhandle parameter, this call is used to: Configure the DMA channel list Specify the DMA start/stop mode Set the number of channel list passes to acquire or output Specify the data transfer grouping (Group Analog Input or Frame mode) Get information for determining the data buffer size required for the transfer NOTE, THIS CALL IS CENTRAL TO ALL DMA OPERATIONS: If you haven't already done so, it is strongly advised that you familiarize yourself with DMA concepts and terminology before attempting to use this call in a program. For more information, please read the DMA programming, or the related sections, of your Intelligent Instrumentation hardware manual(s). 4-71 Chapter 4: Software Libraries Function Call Reference Supported Hardware This call (and other DMA function calls) supports DMA functions on PCI-20501C Series High-Performance EISA Boards, PCI-20098C Series Boards, the PCI-20041C-3A High-Performance Carrier, the PCI-20091W-1 High-Speed Analog Input Board, the PCI-20377W-1 Low Power Multifunction Board and the PCI-20428W Series Low Cost Multifunction Board. NOTE: The Win32 Based Master Link drivers do not support the PCI-20501C Series Boards. These boards are supported by the Master Link DOS or Windows 3.x versions, however. Programming Notes Please read the following programming notes for important information on using the DMAConfigureList call. DMA Transfer Direction The DMA transfer direction must be the same for the entire DMA process. The direction of the DMA transfer is determined by the I/O types specified in the DMA channel list elements of this call. For example, if you use AI_TYPE (Analog Input), an input process will be set-up. A complete list of allowed I/O types is given in the list parameter description. Allowed data types for Intelligent Instrumentation devices supporting DMA operations are listed below. PCI-20501C-1 and PCI-20501C-2: Note: These Boards are not supported by the Win32 Based Master Link drivers. Both the PCI-20501C-1 and PCI-20501C-2 Boards have general purpose DMA controller circuits. The PCI-20501C-1 High-Performance Multifunction EISA Board contains two independent DMA controllers. One is dedicated for analog input DMA transfers from its on-board A/D circuit, and the other is for general purpose DMA use. Having two controllers allows you to run two separate DMA processes concurrently, one for analog input and the other general purpose DMA output. Note, when the general purpose DMA controller is configured for DMA input, the PCI-20501C-1's analog input DMA controller is automatically disabled. The general purpose DMA controller on either PCI-20501C Board allows the transfer of mixed data types (AI_TYPE, DIO_TYPE, CTR8254_TYPE, etc.) to or from the host computer's memory and I/O hardware. PCI-20098C Series, PCI-20041C-3A, PCI-20091W-1, PCI-20377W-1 and PCI-20428W Series: The PCI-20098C Series Multifunction Boards support DMA for on-board A/D analog input transfers only. (Remember that analog channels can be from Analog Input Expanders daisy chained to the A/D as well.) Therefore, the only I/O type allowed on the DMA channel list for these devices is AI_TYPE. The same is true for PCI-20091W-1 and PCI-20377W Boards. The PCI-20041C-3A supports general purpose DMA transfers. This allows the transfer of mixed data types (AI_TYPE, DIO_TYPE, CTR8254_TYPE, etc.) to or from the host computer's memory and I/O hardware. The PCI-20428W-1, -2 Multifunction Boards support DMA for their on-board analog input and analog output circuits. Allowed I/O types on DMA channel lists for these devices is AI_TYPE or AO_TYPE. You cannot mix these types on the same list however. The PCI-20428W-3 Multifunction Board supports DMA for its onboard analog input circuit. The allowed I/O types for this Board is AI_TYPE. 4-72 Chapter 4: Software Libraries Function Call Reference Analog Input Two general RULES must be followed when acquiring analog data in a DMA input process. These rules apply to all of the Boards mentioned earlier. 1. For a given DMA process, analog input data from only one A/D device (and Analog Expanders daisy chained to the A/D) can be acquired. (A PCI-20501C-2 or a PCI-20041C-3A Board, requires an Analog Input Module (A/D) be installed to acquire analog input data.) 2. The analog input channels you reference in DMAConfigureList must also be specified in the AIConfigureList call's channel list. The relative order of the analog channels referenced in both lists must match. (AIConfigureList is used to specify gain, input range, and other parameters for analog input channels.) Only A/D devices with hardware pacing capabilities (a start convert line) are supported for DMA. This means only single channel read operations are supported for the PCI-20002M Analog Input Module (i.e. you must read analog data from this device using AIRead for example). The channel lists discussed in rule number 2 above must also conform to one of the following conditions depending on the Analog Input acquisition hardware used. Single Channel Operation: If you only want to acquire data from one channel on a PCI-20019M or PCI-20023M Analog Input Module, or a PCI-20091W Analog Input Board, these devices must be jumper configured with automatic channel advance disabled. Up to Eight Channels: Several Analog Input devices support a maximum channel list of up to eight different analog channels (the PCI-20019M, PCI-20023M and PCI-20091W). In these cases the channel lists must consist of channels resident on the PCI-20019M or PCI-20023M High-Speed Analog Input Module or PCI-20091W Analog Input Board, in order from channel n to channel 7, with each channel appearing exactly once. The channels in the DMA list must be channels n through 7 of one Module/Board - where n must be 0 for the PCI-20019M-1, and n can be 0 to 7 for the PCI-20019M-1A and PCI-20023M Modules, and the PCI-20091W Board. A PCI-20019M-1, PCI-20019M-1A, or PCI20023M Module must be jumper configured with automatic channel advance enabled. From Channel N to Channel M: This is the channel scanning convention used by the PCI-20377W-1 Low Power Multifunction Board. The channel list must consist of channels resident on the PCI20377W Board, in sequential increasing order from channel N to channel M, where N is the starting channel and M is the ending channel. You may not repeat channels on the list. The same gain, range and input type (single-ended or differential) must be used for all channels on the list. Up to eight differential input channels may be specified, or, up to sixteen single-ended input channels may be specified. From Channel 0 to Channel N: This is the channel scanning convention used by the PCI-20428W Series Low Cost Multifunction Boards. The channel list must consist of channels in sequential increasing order from channel 0 to channel N, where N is the ending channel. You may not repeat channels on the list. The same gain, range and input type (single-ended or differential) must be used for all channels on the list. Up to eight differential input channels may be specified, or, up to sixteen single-ended input channels may be specified. Up to 128 Channels: Many Analog Input devices support programmed channel list sequencing of up to 128 analog channels. These include; the PCI-20501C-1 and PCI-20098C Multifunction Boards, and the PCI-20341M and PCI-20364M Analog Input Modules. In addition, the PCI-20031M and PCI-20368M Analog Input Expansion Modules, and the PCI20363M Simultaneous Sample/Hold (SSH) Module fully support 128 channel programmed channel list sequencing. These Modules can be used with PCI-20019M or PCI-20023M Analog Input Modules to implement 128 element programmed lists. The PCI-20019M or PCI-20023M must be hardware 4-73 Chapter 4: Software Libraries Function Call Reference jumpered to accept analog input from the Expander or SSH Module(s) via the analog daisy chain. Any channels resident on the Analog Input Module will not be available, as a result. PCI-20368M and PCI-20031M Expander and PCI-20363M SSH Modules may also be used to increase the number of available input channels with PCI-20501C-1 and PCI-20098C Multifunction Boards, and the PCI-20341M Analog Input Module. Only PCI-20031M and PCI-20368M Expander Modules may be used to expand the number channels on a PCI-20364M Analog Input Module. Resident A/D channels on these A/D devices may be used along with Expander/SSH Modules on the list, since the A/D daisy chain connection is software controlled through the channel list. For 128 element programmed channel lists, the channels on the list may appear in any order, and each channel may appear any number of times. Channels from PCI-20031M, PCI-20368M Expander, or PCI-20363M SSH Modules and a PCI-20501C-1, PCI-20098C, PCI-20341M or PCI-20364M (see note below) may be intermixed in the list. NOTE: When using the PCI-20364M Analog Input Module, channels with different input voltage ranges can be intermixed in the list. Additionally, on-board PCI-20364M channels specified in the list can be a mixture of single-ended and differential input types. However, all off-board channels (e.g. from Expander Modules) must have the same input configuration. Also, please note that the PCI20364M Module cannot be used to convert PCI-20363M SSH channels in a DMA process (because the PCI-20363M's minimum scan rate is faster than the PCI-20364M's maximum conversion rate). Mixing Analog Input Channels With Other Input Data Types The PCI-20501C Series EISA Boards, and the PCI-20041C Series Carriers support mixed, or general purpose, DMA transfer operations. If you want to do a general purpose DMA input transfer that includes analog input data (AI_TYPE) along with other input data types, these additional rules must be followed: 1. The first element in the DMAConfigureList channel list should be an analog input channel. 2. Group all of the analog input channels together on the list, otherwise an error may be returned by the DMAConfigureList call. The channel order within the analog input channel group is not important (except for the "Up to Eight Channels" list condition mentioned in the previous section). A reminder: The analog input channels referenced on the DMAConfigureList and AIConfigureList channel lists must have the same relative order. The first list element in both lists must contain the first analog channel, the second element the second analog channel and so on. Transfer Modes Two transfer modes are available in this call; Group Analog Input mode or Frame mode. Group Analog Input mode is specified by setting the groupAI parameter to "1" (TRUE). Frame mode is specified by setting groupAI to "0" (FALSE). Briefly, Group Analog Input mode is a DMA channel scanning option that provides efficient transfer of analog input data in a mixed I/O type general purpose DMA input process. Group Analog Input mode or Frame mode must be specified depending on the Board or Carrier used. 4-74 Chapter 4: Software Libraries Function Call Reference PCI-20501C-1 and PCI-20501C-2: Note: These Boards are not supported by the Win32 Based Master Link drivers. Both of these Boards must be programmed for Group Analog Input mode. Whenever you need to perform a DMA input transfer that involves analog input data, always specify Group Analog Input mode (groupAI = "1") when using a PCI-20501C-1 or PCI-20501C-2 Board. PCI-20098C Series, PCI-20041C-3A, PCI-20091W-1, PCI-20377W-1 and PCI-20428W: You must always specify Frame mode (groupAI = "0") whenever you perform a DMA transfer with one of these devices. IMPORTANT NOTE for Windows Users: If you didn’t do so at installation time, you will need to install one of the following platform-dependent driver files as described in Chapter 2 and in Appendix B: 1. Windows NT : Master Link NT Driver with DMA support, MASTER_NT.SYS. 2. Windows 95: Virtual DMA Device Driver, VDMAD.VXD. 3. Windows 3.x: Virtual DMA Device Driver, PCIVDMAD.386. Parameter Descriptions processhandle the DMA process handle obtained from a DMAGetHandle or DMAHugeGetHandle call. You must assign a processhandle to each DMA process you wish to implement. IMPORTANT: To appropriately set up the following five parameters; start, stop, startdelay, stopdelay, and clustercount - you should be familiar with how DMA start/stop modes operate, the definition of a data "cluster" in a DMA transfer process, and the different types of data buffers used in the process. If you need additional information, please read the programming sections related to DMA in your Intelligent Instrumentation hardware manual(s). start DMA initiation mode. The following DMA initiation modes are available: DMA_START_COMMAND = start the DMA process on a software command - the DMAStart call. (Note, all DMA processes are enabled by the DMAStart call.) DMA_START_TRIGGER = when a trigger signal is detected, start the DMA process after a delay specified in the startdelay parameter. The start delay is specified in terms of data clusters. This start mode using a start delay value is only supported for DMA output processes with the PCI-20041C-3A Carrier. This start mode, with no start delay specified, is supported for analog input DMA with PCI20428W Boards. stop DMA termination mode. The following DMA termination modes are available: DMA_STOP_COMMAND = stop the DMA process via a command (the DMAStop call). This stop mode cannot be used with PCI-20501C Boards. DMA_STOP_TRIGGER = when a trigger signal is detected, stop the DMA process after a designated number of data transfers specified in the stopdelay parameter (not supported by PCI-20091W, PCI20377W and PCI-20428W Boards). The stop delay is specified in terms of data clusters. 4-75 Chapter 4: Software Libraries Function Call Reference DMA_STOP_TC = stop the DMA process on a Terminal Count. The Terminal Count, specified in the clustercount parameter, indicates the number of data clusters you want transferred in the DMA process. startdelay start trigger delay, specified in data clusters, for a DMA_START_TRIGGER initiation mode. startdelay must be 0 (zero) for DMA_START_COMMAND start mode. The startdelay parameter is only applicable to the PCI-20041C-3A Carrier. For other devices, set this parameter to 0 (zero) stopdelay stop trigger delay, specified in data clusters, for a DMA_STOP_TRIGGER termination mode. stopdelay must be 0 (zero) for DMA_STOP_TC stop mode. This function is not supported by PCI-20091W, PCI-20377W and PCI-20428W Boards. For these devices, set this parameter to 0 (zero) clustercount cluster count. This is a number indicating the number of data clusters you will transfer in the DMA input or output process. A data cluster is defined as the block of input or output data represented by a complete pass of all the channels on the channel list. (The size of a data cluster depends on the transfer mode specified in the groupAI parameter. Data cluster size in bytes, is reported by the clustersize parameter.) If you chose DMA_STOP_TC in the stop parameter, the value you specify in clustercount is the Terminal Count value. For any DMA transfer, clustercount is equivalent to the size of the DMA data buffer in terms of data clusters. count count is the number of list elements you program in the DMA channel list. list the DMA channel list array. The DMA channel list structure has the following format: /* * DMA channel list structure */ typedef struct DMAListType { int slot; / *Slot. int module; / *Module int channel; / *Channel int iotype; / *I/O type } DMAListType; */ */ */ */ The meanings of each DMA channel list element are given below. Slot slot number of the Board or Carrier where the channel in this list element is located. Module module position number (0, 1, 2, 3) on the Board or Carrier in the specified Slot. Module number 0 (zero) specifies a Board's or Carrier's on-board functions. Channel the channel number on the I/O device you want to acquire data from in an input process, or send data to in an output process. 4-76 Chapter 4: Software Libraries Function Call Reference I/O type the I/O type of the channel. This information is used by the software to determine the number of bytes that need to be transferred to or from the specified I/O channel. The direction of the transfer is defined by the I/O type list elements. Only Input types may be specified for an input process, and only Output types may be specified for an output process. The following I/O types are supported: AI_TYPE = Analog Input AO_TYPE = Analog Output CTR8254_TYPE = 8254-Based Counter count data - this is an Input type only. Always configure the counter before calling DMAConfigureList. Note: "8254" Frequency measurement data is not supported for DMA transfer. CTR_TYPE = An On-Board Counter count data - this is an Input type only. The data transferred depends on the currently selected counter mode. Always configure the counter before calling DMAConfigureList. Note: Period measurement data is not supported for DMA transfer. DIO_TYPE = Digital Input or Output, depending on the direction for which the specified digital port (channel) has been configured. Always configure the Digital I/O port before calling DMAConfigureList. Note: Handshake mode digital I/O data is not supported for DMA transfer. groupAI group analog input channel list elements flag. This parameter must always be set to "1" (TRUE) when using a PCI-20501C Series High-Performance EISA Board for any DMA input process involving analog input data. groupAI must always be set to "0" (FALSE) when using a PCI-20041C Carrier, a PCI-20098C Series Board, a PCI-20091W Board, a PCI-20377W Board or a PCI-20428W Board. NOTE: "Group" analog input mode is only supported by the DMA controller on PCI-20501C Series devices. clustersize the number of bytes per data cluster. Also see the description for the clustercount parameter. You use the returned "number of bytes per data cluster" value and the clustercount to determine the size of the buffer you will need to allocate for the DMA transfer. The required minimum buffer size, in bytes, is equal to the clustercount times the clustersize. Buffer size (in bytes) = clustersize * clustercount Also see the BUFAllocate call description. DMAFreeHandle int DMAFreeHandle (int processhandle) Call Description This call "frees" the specified DMA handle assigned through the DMAGetHandle or DMAHugeGetHandle call. You should always free any DMA handles that are no longer in use (and prior to exiting a program). Parameter Description processhandle DMA process handle you want to free. 4-77 Chapter 4: Software Libraries Function Call Reference DMAGetHandle int DMAGetHandle (int far *processhandle) Call Description This call assigns a processhandle (a number) to your DMA process. This is the first function call you should make, after hardware and software initialization calls, if you want to implement a DMA process in your program. The DMA processhandle must be referenced in all subsequent DMA function calls associated with that process. This call also allows you to easily set up more than one DMA process in a single application program, specifying the processhandle of each one at appropriate times to DMAConfigureList, DMAStart, DMAStatus, etc. Note to Windows Users: Use DMAHugeGethandle for processes requiring more than 64 kbytes of data. Parameter Description processhandle the assigned DMA process handle. DMAHugeGetHandle int DMAHugeGetHandle (int far *processhandle) Call Description This call is used in place of DMAGethandle for DMA processes requiring data buffers greater than 64 kbytes (a "huge" buffer) under Windows Only. DOS applications that need to transfer more than 65536 bytes (64k) of data need to make use of the DMASwap function. See the BUFAllocate call description for allocating a data buffer for a huge DMA process in a Windows application. Use DMAGethandle if less than 64 kbytes of data will be transferred. Parameter Description processhandle pointer to the assigned huge DMA process handle. DMASetOptions int DMASetOptions (int processhandle, int channel, unsigned long reserved) Call Description This call is used to assign a DMA channel for the process identified by processhandle. After you call DMAGetHandle or DMAHugeGethandle, you must assign a DMA channel for the transfer using DMASetOptions. Parameter Descriptions processhandle handle for the DMA process the call assigns a channel to. channel DMA channel options: DMA_CHANNEL_AUTO = Automatic DMA channel selection. 4-78 Chapter 4: Software Libraries Function Call Reference For all PCI-20501C applications, you must select DMA_CHANNEL_AUTO. Use one of the following DMA channel options for other Boards/Carriers which support DMA: For PCI-20098C Series Multifunction Board applications, specify channel "1". DMA channel “3” is also available for PCI-20098C “F” version models and later. For PCI-20041C-3A High-Performance Carrier and PCI-20091W-1 Analog Input Board applications, channel "1" is recommended, however, channels 2 or 3 may be alternatively specified. Consult your hardware manual if more information is required. In any case, the value passed must match the jumper setting or the process will not run. For PCI-20377W Boards, you may specify channel "1" or "3". For PCI-20428W Boards, you may specify channel “1” or “3”. The specified DMA channel must match the DMA channel selected through board jumper settings. Important Note: For Windows NT applications, only DMA channels “1” and “3” are supported by Master Link. reserved parameter reserved for future use - set it to 0 (zero). DMASetPacer int DMASetPacer (int processhandle, int slot, int module, int channel, int iotype) Call Description For the specified DMA process, DMASetPacer is used to identify the pacer source that will be enabled by the DMAStart call. The DMA pacing signal must be separately connected to the appropriate DMA pacer input using the SYNCConfigure call. The choice of a DMA pacing signal is dependent upon the type of data being transferred (analog input, analog output, digital I/O, counter or mixed I/O types.) or your particular application's needs. The pacer source should be configured before calling DMASetPacer. Note, the DMASetPacer call is not applicable when a DMA pacer source cannot be identified by a slot, module, and channel number, such as a signal connected via an external input. You may use any of these non-applicable sources as a DMA pacer, however, you still need to connect sources to inputs using SYNCConfigure. Parameter Descriptions processhandle DMA process handle. slot slot number in which the Board or Carrier or Module containing the pacer source you wish to use is located. module module position number on the Board or Carrier in the specified slot which contains the desired pacer source (module should be set to zero for a channel on a Board or Carrier). channel channel number of pacer source. 4-79 Chapter 4: Software Libraries Function Call Reference iotype the I/O type of the pacer source (burst generator, rate generator, counter, 8254-based counter, etc). One of the following I/O types may be specified: BG_TYPE = Burst Generator type (a PCI-20098C or a PCI-20501C on-board Burst generator). CTR8254_TYPE = 8254-based counter type (a PCI-20007M, a PCI-20377W or a PCI-20428W counter channel). CTR_TYPE = On-board Counter type (i.e. a PCI-20098C or a PCI-20501C on-board counter channel). RG_TYPE = Rate Generator type (i.e. a PCI-20007M, a PCI-20377W,a PCI-20428W, a PCI-20041C or a PCI-20091W rate generator channel). TRIG_TYPE = Trigger type (a PCI-20020M Trigger/Alarm Module). NO_TYPE = No type. Use this to cancel a previously selected pacer or use NO_TYPE if the pacer need not (or can not) be enabled directly by the software. (i.e. if the pacer source cannot be identified by slot, module and channel.) DMASetTrigger int DMASetTrigger (int processhandle, int slot, int module, int channel, int iotype) Call Description For the specified DMA process, DMASetTrigger is used to identify the trigger source that will be enabled by the DMAStart call. The DMA trigger signal is connected to the appropriate DMA trigger input using the SYNCConfigure call. A typically employed trigger source is a PCI-20020M Trigger/Alarm Module, which can provide a trigger signal based on an analog input threshold or window comparison. For example, use SYNCConfigure to connect the PCI-20020M trigger output (SYNC OUT line) to the desired trigger input, and specify I/O type TRIG_TYPE in DMASetTrigger. The trigger source should be configured before calling DMASetTrigger. Note, the DMASetTrigger call is not applicable when the trigger source cannot be identified by a slot, module, and channel number, such as a signal connected via an external input. You may use any of these non-applicable sources as a DMA trigger, however, you still need to connect sources to inputs using SYNCConfigure. Parameter Descriptions processhandle DMA process handle. slot slot number in which the Board or Carrier or Module containing the trigger source you wish to use. module module position number on the Board or Carrier in the specified slot which contains the desired trigger source (module should be set to 0 (zero) for a channel on a Board or Carrier). channel channel number of trigger source. 4-80 Chapter 4: Software Libraries Function Call Reference iotype the I/O type of the trigger source (Trigger/Alarm Module, burst generator, rate generator, counter, 8254-based counter, etc). One of the following I/O types may be specified: BG_TYPE = Burst Generator type ( a PCI-20098C or a PCI-20501C on-board Burst generator). CTR8254_TYPE = 8254-based counter type (a PCI-20007M, a PCI-20377W, or a PCI-20428W counter channel). CTR_TYPE = On-board Counter type (a PCI-20098C or a PCI-20501C on-board counter channel) RG_TYPE = Rate Generator type (a PCI-20007M, PCI-20377W, PCI-20428W, PCI-20091W, or a PCI-20041C rate generator channel). TRIG_TYPE = Trigger-alarm (a PCI-20020M Trigger/Alarm Module). NO_TYPE = No type. Use this to cancel a previously selected trigger or use NO_TYPE if the trigger need not (or can not) be enabled directly by the software. (i.e if the trigger source cannot be identified by slot, module and channel.) DMAStart int DMAStart (int processhandle, unsigned long bufferhandle, char far *buffer, unsigned long buffersize) Call Description This call starts the DMA process with the specified processhandle, data buffer and buffer size in bytes. DMAStart enables the pacer and trigger sources specified in the DMASetPacer and DMASetTrigger calls, the on-board DMA controller, and the host computer's DMA controller. Parameter Descriptions processhandle DMA process handle. bufferhandle extended memory buffer handle obtained from the BUFAllocate call, if an extended memory buffer was allocated. If a conventional memory data buffer was allocated, then bufferhandle must be set to 0 (zero). Always set this parameter to 0 (zero) for Windows applications. buffer pointer to the data buffer in memory or 0 (zero) if buffer is in extended memory (see the BUFAllocate call). buffersize size of the data buffer in bytes (see the BUFAllocate call). 4-81 Chapter 4: Software Libraries Function Call Reference DMAStatus int DMAStatus (int processhandle, unsigned far *status, BufInfoType far *info) Call Description This call returns the status of the specified DMA process and fills in the fields of the buffer information array. A host of DMA status bit masks are provided with the Software Libraries to detect a number of process conditions and hardware errors. The buffer information is the same array described in the Buffer Management Call group (section 4.5.3). Parameter Descriptions processhandle DMA process handle. status the DMA status word. Compare the following bit masks to the status word to test for a particular DMA status condition: DMA_PROCESS_RUNNING = The specified DMA process is still active. DMA_TRIGGER_OCCURRED = The specified DMA process trigger has occurred. DMA_PACER_OVERRUN = A DMA pacer occurred before the last frame was transferred. DMA_GROUP_OVERRUN = A DMA pacer occurred before the last group was transferred. DMA_FIFO_OVERRUN = A DMA write to a full FIFO or DMA read from an empty FIFO was detected. This means the data bus is heavily loaded (input or output process). DMA_CHAIN_PENDING = Reserved. DMA_AD_READ_OVERRUN = An A/D conversion completed before the previous analog input data was read. DMA_AD_RATE_OVERRUN = The analog input sample rate was too high, resulting in skipped cycles. DMA_AD_TIMEOUT = A timeout occurred during an analog input conversion. DMA_HUGE_OVERRUN = Huge DMA process overrun. An overrun was detected during a huge DMA process that resulted in missing, or lost, data. info the buffer information array. The buffer information structure and definitions for each buffer list element are provided in section 4.5.3 under the BUFAttachProcess call description. 4-82 Chapter 4: Software Libraries Function Call Reference DMAStop int DMAStop (int processhandle, unsigned far *status, BufInfoType far *info) Call Description This call terminates the specified DMA process. Status and buffer information are also returned. DMAStop halts the DMA process started in any mode. The pacer and trigger devices (if specified to DMASetPacer and DMASetTrigger) are disabled, the on-board DMA controller is disabled and the host computer's DMA controller is disabled. NOTE: Data in the input or output FIFO buffer of a PCI-20501C Series Board, when DMAStop is called, cannot be accessed (input data in the FIFO is lost, output data cannot be dumped). DMAStop call(s) should be made prior calling DMAFreeHandle to ensure that all DMA activity for the process is terminated. Parameter Descriptions processhandle DMA process handle. status the DMA status word. See the status parameter description in the DMAStatus call. info the buffer information array. The buffer information structure and definitions for each buffer list element are provided in section 4.5.3 under the BUFAttachProcess call description. DMASwap int DMASwap (int processhandle, unsigned long bufferhandle, char far *buffer, unsigned far *status BufInfoType far *info) Call Description This call, which is only applicable to DOS based applications, automatically repeats a "Stop on Terminal Count" DMA process (see the DMAConfigureList call's stop parameter description) using a new data buffer. Process status and information on the old buffer is returned. The DMASwap instruction will not return control to the application program (holds processing) until the DMA process is running in the new buffer. For an input process, when the the old buffer is full it can be read using the BUFDecode call. Thus, for DMA input operations, this call provides a means of acquiring more data while permitting the application program to access data already acquired. For an analog output operation, this call can be used to switch between alternate output waveforms. The first and second buffers must be the same length and be offset aligned (both buffers must start at the same relative memory page position). You can use the BUFAllocate "ALLOC_ON_64K" location flag when allocating buffers to satisfy the offset alignment condition. Parameter Descriptions processhandle DMA process handle. 4-83 Chapter 4: Software Libraries Function Call Reference bufferhandle the new extended memory (XMS) data bufferhandle. If BUFAllocate was used to allocate the data buffer, just use the bufferhandle returned in that call. buffer pointer to the new memory data buffer. If BUFAllocate was used to allocate the data buffer, just use the buffer pointer returned in that call. status the DMA status word. See the status parameter description in the DMAStatus call. info the old "swapped out" buffer information array. The buffer information structure and definitions for each buffer list element are provided in section 4.5.3 under the BUFAttachProcess call description. 4-84 Chapter 4: Software Libraries Function Call Reference 4.5.9 Initialization Calls HWInit Initialize the data acquisition hardware C Pascal BASIC int HWInit (void); function HWInit: Integer; FUNCTION HWInit% () RegisterClient Windows 16-bit and 32-bit applications only. Registers an application instance with the drivers. C Pascal Visual Basic int RegisterClient (void); function RegisterClient: Integer; Function RegisterClient%() Note: Windows 16-bit only for Pascal SWInit Initialize the Software Library C Pascal BASIC int SWInit (void); function SWInit: Integer; FUNCTION SWInit% () SWReset Reset the Software Library's initialization (cancels SWInit and HWInit) C Pascal BASIC int SWReset (void); function SWReset: Integer; FUNCTION SWReset% () SlotAssign Assign a slot number to a memory-mapped ISA data acquisition Board or Carrier C Pascal BASIC int SlotAssign (int slot, unsigned segment); function SlotAssign (slot: Integer; segment: Word): Integer; FUNCTION SlotAssign% (BYVAL slot%, BYVAL segment%) SlotAssignIO Assign a slot number to a I/O-mapped ISA data acquisition Board C Pascal BASIC int SlotAssignIO (int slot, unsigned base); function SlotAssignIO (slot: Integer; base: Word): Integer; FUNCTION SlotAssignIO% (BYVAL slot%, BYVAL base%) SlotInquire Return information about the hardware configuration in a specified slot C Pascal BASIC int SlotInquire (int slot, ModInfoTypeArray far *info); function SlotInquire (slot: Integer; var info: ModInfoTypeArray): Integer; FUNCTION SlotInquire% (BYVAL slot%, SEG info AS ModInfoType) SlotSearchEISA Search for PCI-20501C EISA Boards and identify them to the software (For Windows 16-bit and DOS applications only) C Pascal BASIC int SlotSearchEISA (void); function SlotSearchEISA: Integer; FUNCTION SlotSearchEISA% () 4-85 Chapter 4: Software Libraries Function Call Reference SlotSearchISA Search for PCI-20000 Series memory-mapped ISA Boards and return the number of boards found, thier ID codes, and segment addresses C Pascal int SlotSearchISA (int far *count, ISASearchBoardTypeArray far *info); function SlotSearchISA (var count: Integer; var info: ISASearchBoardTypeArray): Integer; FUNCTION SlotSearchISA% (SEG count%, SEG info AS ISASearchBoardType) BASIC SlotSearchIO Search for PCI-20000 Series I/O-mapped ISA Boards and return the number of boards found, thier ID codes, and segment addresses C Pascal int SlotSearchIO (int far *count, IOSearchBoardTypeArray far *info); function SlotSearchI0 (var count: Integer; var info: IOSearchBoardTypeArray): Integer; FUNCTION SlotSearchIO% (SEG count%, SEG info AS IOSearchBoardType) BASIC UnregisterClient Windows 16-bit and 32-bit applications only. Unregisters an application instance with the drivers. C Pascal Visual Basic int UnregisterClient (void); function UnregisterClient: Integer; Function UnregisterClient% () Note: Windows 16-bit only for Pascal IncludeXXXX Include support for the XXXX Carrier/Board, Module, and Buffer, DMA, and Thermocouple functions in program C IncludeXXXX Functions int int int int int int int int int int int int int int int int int int int int int int int int int int int int int int Include17M (void); FUNCTION Include17M% () Include19M (void); FUNCTION Include19M% () Include1C (void); FUNCTION Include1C% () Include20M (void); FUNCTION Include20M% () Include21M (void); FUNCTION Include21M% () Include23M (void); FUNCTION Include23M% () Include2M (void); FUNCTION Include2M% () Include31M (void); FUNCTION Include31M% () Include341M (void); FUNCTION Include341M% () Include363M (void); FUNCTION Include363M% () Include364M (void); FUNCTION Include364M% () Include368M (void); FUNCTION Include368M% () Include3M (void); FUNCTION Include3M% () Include41C (void); FUNCTION Include41C% () Include4M (void); FUNCTION Include4M% () Include501C (void); FUNCTION Include501C% () Note: Include501C is for Windows 16-bit and DOS applications only. Include5M (void); FUNCTION Include5M% () Include6M (void); FUNCTION Include6M% () Include7M (void); FUNCTION Include7M% () Include87W (void); FUNCTION Include87W% () Include89W (void); FUNCTION Include89W% () Include91W (void); FUNCTION Include91W% () Include93W (void); FUNCTION Include93W% () Include377W (void); FUNCTION Include377W% () Include378W (void); FUNCTION Include378W% () Include428W (void); FUNCTION Include428W% () Include98C (void); FUNCTION Include98C% () IncludeBUF (void); FUNCTION IncludeBUF% () IncludeDMA (void); FUNCTION IncludeDMA% () IncludeTC (void); FUNCTION IncludeTC% () Pascal IncludeXXXX Functions function function function function function function function 4-86 BASIC IncludeXXXX Functions Include17M: Integer; Include19M: Integer; Include1C: Integer; Include20M: Integer; Include21M: Integer; Include23M: Integer; Include2M: Integer; Chapter 4: Software Libraries Function Call Reference function Include31M: Integer; function Include341M: Integer; function Include363M: Integer; function Include364M: Integer; function Include368M: Integer; function Include3M: Integer; function Include41C: Integer; function Include4M: Integer; function Include501C: Integer; Note: Include501C is for Windows 16-bit and DOS applications only function Include5M: Integer; function Include6M: Integer; function Include7M: Integer; function Include87W: Integer; function Include89W: Integer; function Include91W: Integer; function Include93W: Integer; function Include377W: Integer; function Include378W: Integer; function Include428W: Integer; function Include98C: Integer; function IncludeBUF: Integer; function IncludeDMA: Integer; function IncludeTC: Integer; HWInit int HWInit (void) Call Description This call establishes the software configuration and initializes the hardware components. This function call must be made immediately after all of the necessary IncludeXXXX and SlotAssign calls. All installed EISA Boards found by the SlotSearchEISA function call, and all installed ISA Boards/Carriers which have been assigned slot numbers by the SlotAssign call will be initialized. Descriptions of the initialized states of all Intelligent Instrumentation Hardware Devices after a HWInit call are given at the end of the Initialization Call group section. RegisterClient int RegisterClient (void); Call Description This call applies to Windows 3.x and Win32 applications only. This call registers an application instance with the drivers and must be the first call in your Windows program. Example The following code segment is taken from the sample program AI_CW.C: . . /********************************************************** * Main program. **********************************************************/ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { int error_code; DLGPROC dp; /* * Register this application instance with the drivers. */ 4-87 Chapter 4: Software Libraries Function Call Reference error_code = RegisterClient (); ErrorRoutine (0, error_code, "Error in RegisterClient"); . . SWInit int SWInit (void) Call Description This call initializes the Software Library and performs system timer calibration. This function must be called prior to any other function call. You can alter the SWInit call to customize driver initialization. You do this by replacing the last parameter of the InitSW function call (found in the PCIDATA source file in the SAMPLE directory) with the desired flag(s). For more information on this topic please consult the “Initialization Enhancements” section of Appendix B. These initialization enhancements apply to all Master Link language versions. SWReset int SWReset (void) Call Description This call resets the Software Library's initialization. This function, which can be called any time after SWInit, cancels all software and hardware initialization. SlotAssign int SlotAssign (int slot, unsigned segment) Call Description This call assigns a slot number to an installed memory-mapped ISA Board or Carrier. The assigned slot number, along with the module position and channel number, is used for all subsequent I/O function calls. The SlotAssign call must be made for each ISA Board or Carrier in the system, and must be made between the SWInit and HWInit calls. Parameter Descriptions slot the host computer "slot" number you assign to the installed memory-mapped ISA Board or Carrier. For ISA memory-mapped boards, such as the PCI-20098C Series Multifunction Boards, we recommend that you use slot numbers 16 to 31. This will help avoid any possible conflict between installed EISA and ISA Boards in your system. segment the segment address of the Board or Carrier you wish to assign a slot number to. The segment address defines the Board or Carrier location in the memory map, and is usually set by DIP switches on the Board or Carrier. If you do not know the segment address of the ISA Board or Carrier, you have three available methods to determine its value: 4-88 Chapter 4: Software Libraries Function Call Reference Method 1. Use the SlotSearchISA function (see the SlotSearchISA call description). Method 2. For DOS and Windows 16-bit applications, use the SYSCHECK utility supplied with the Board or Carrier. SYSCHECK is an easy to use menu driven system check utility supplied with every Board or Carrier purchase. Method 3. You may visually inspect DIP switch settings (see the appropriate hardware manual for DIP switch locations). SlotAssignIO int SlotAssignIO (int slot, unsigned base) Call Description This call assigns a slot number to an installed I/O-mapped ISA Board (i.e. a PCI-20377W or PCI-20428W Board). The assigned slot number, is used for all subsequent I/O function calls. The SlotAssignIO call must be made for each I/O-mapped ISA Board in the system, and must be made between the SWInit and HWInit calls. Parameter Descriptions slot the host computer "slot" number you assign to the installed I/O-mapped ISA Board. For I/O-mapped ISA devices, (such as the PCI-20428W Board), we recommend that you use slot numbers 16 to 31. This will help avoid any possible conflict between installed EISA and ISA Boards if you are using an EISA system. base the base I/O address of the Board you wish to assign a slot number to. The base address defines the Board location in the I/O memory map, and is set by DIP switches on the Board. If you have changed the base address and no longer know what it is, you have three available methods to determine its value: Method 1. Use the SlotSearchIO function (see the SlotSearchIO call description). Method 2. For DOS and Windows 16-bit applications, use the SYSCHECK utility supplied with the Board. SYSCHECK is an easy to use menu driven system check utility supplied with every Board purchase. Method 3. You may visually inspect DIP switch settings. SlotInquire int SlotInquire (int slot, ModInfoTypeArray far *info) Call Description This call can be used to return information about the Intelligent Instrumentation Hardware configuration installed in a specific slot of the host computer. A four member list array of data corresponding to module positions 0 to 3 of the installed (and initialized by the drivers) Board or Carrier is returned. Data for each module position includes a module present flag, a module ID code, and the Board or Carrier's segment address. The first member, corresponding to module 0, contains information on the Board or Carrier itself. Parameter Descriptions slot the slot number of the Board or Carrier you wish to query. 4-89 Chapter 4: Software Libraries Function Call Reference info the module information array. The module information structure has the following format: /* * Module information structure */ #define MAXMODULE 4 typedef struct ModInfoType { int present; unsigned id; unsigned segment; unsigned long flags; /* /* /* /* hardware present flag. */ hardware ID. */ Board segment or I/O address. */ Module: (MODINFO_IO_BOARD = I/O Mapped Board) */ } ModInfoType; typedef ModInfoType ModInfoTypeArray [MAXMODULE]; Module present flag This flag indicates if an I/O Module or Board or Carrier is installed in the module position (0, 1, 2, 3). If a valid device is present the flag will contain 01 Hex; otherwise it will contain 00 Hex. Module ID This is the I/O Module’s or Board’s or Carrier’s ID code. Every Intelligent Instrumentation Board or Carrier or Module has a unique ID code. A listing of these codes is provided below. Board Segment or I/O address This is the base address of the Board or Carrier. The base address establishes the start address of the Board or Carrier's I/O map. For memory mapped ISA Boards/Carriers, address bits A10 to A19 are defined by their segment address DIP switches. For I/O-mapped ISA Boards, such as the PCI-20377W or PCI-20428W, address bits A4 to A9 are defined by their base I/O address DIP switches. Module flags This flag word indicates special information about the device. The following "module flags" bit mask is currently provided: MODINFO_IO_BOARD = An I/O-mapped Board is present (i.e. a PCI-20377W, or PCI-20428W). Carrier, Board and Module ID Codes Carriers, Multifunction Boards and Single Boards 4-90 Model Number/Description ID Code (Hexadecimal, Decimal) PCI-20001C-1A (Without Digital I/O) PCI-20001C-2A (With Digital I/O) PCI-20041C-2A (No DMA) PCI-20041C-3A (DMA slave) PCI-20041C-3A (DMA Master W/TC Int.)* PCI-20041C-3A (DMA Master No TC Int.)* PCI-20087W-1 PCI-20089W-1 PCI-20091W-1 (No TC Interrupt)* PCI-20091W-1 (W/TC Interrupt)* PCI-20091W-1 (No DMA) PCI-20093W-1 PCI-20377W-1 PCI-20378W-1 $1B, 27 $1D, 29 $13, 19 $15, 21 $11, 17 $17, 23 $0D, 13 $0B, 11 $04, 04 $05, 05 $D3, 211 $02, 02 $20, 32 $06, 06 Chapter 4: Software Libraries Function Call Reference continued Model Number/Description PCI-20378W-3 PCI-20428W-1 configured for SE operation PCI-20428W-1 configured for DIFF operation PCI-20428W-2 configured for SE operation PCI-20428W-2 configured for DIF operation PCI-20428W-3 always SE operation PCI-20098C-1, -2A PCI-20098C-1B, to -1F PCI-20098C-2, -2C to -2F PCI-20501C-1 PCI-20501C-2 ID Code (Hexadecimal, Decimal) $07, 07 $30, 48 $31, 49 $32, 50 $33, 51 $34, 52 $01, 01 AUX ID Bin: 0000, 0 dec. $01, 01 AUX ID Bin: 1000, 8 dec. $01, 01 AUX ID Bin: 0100, 4 dec. $E200, 57856 $E100, 57600 * TC = Terminal Count Analog Input Modules Model Number/Description PCI-20002M-1 12-Bit A/D Single-ended Differential PCI-20005M Expander PCI-20017M-1 4-Channel SSH PCI-20019M-1A High-Speed 12-Bit A/D 0-7 Scan N-7 Scan No Scan PCI-20023M-1 High-Speed 12-Bit A/D N-7 Scan No Scan PCI-20031M-1 Expander SYNC IN or software advance Software advance only PCI-20341M-1 High-Res 16-Bit A/D PCI-20363M 8-Channel SSH PCI-20364M High-Accuracy (12/16/18-Bit) A/D PCI-20368M 16-Channel Exapnder ID Code (Hexadecimal, Decimal) $FF, 255 $FE, 254 $EF, 239 $E9, 233 $E4, 224 $C4, 196 $E5, 229 $C0, 192 $C1, 193 $DF, 223 $DE, 222 $77, 119 $E1, 225 $DC, 220 $C2, 194 Analog Output Modules Model Number/Description ID Code (Hexadecimal, Decimal) PCI-20003M 12-bit Configuration -2 (Two voltage chns.) -4 (chn. 0 voltage/ chn. 1 current) -4 (chn. 0 current/ chn. 1 voltage) -4 (chn. 0 current/ chn. 1 current) PCI-20006M-1 16-bit 1-Channel PCI-20006M-2 16-bit 2-Channel PCI-20021M-1B 12-bit 8-Channel $F7, 247 $F3, 243 $F4, 244 $F5, 245 $E2, 226 $E3, 227 $DD, 221 4-91 Chapter 4: Software Libraries Function Call Reference Digital I/O Modules Model Number/Description PCI-20004M-1, 32 Channels ID Code (Hexadecimal, Decimal) $FB, 251 Special-Purpose Modules Model Number/Description ID Code (Hexadecimal, Decimal) PCI-20020M-1, Trigger/Alarm Module Configured as a: Single input window comparator Dual input level comparator $E7, 231 $E6, 230 SlotSearchEISA int SlotSearchEISA (void) Call Description This function, which is only available for DOS and Windows 16-bit applications (the Win32 drivers do not support the PCI-20501C Series), searches the EISA Bus for PCI-20501C-1's and PCI-20501C-2's using EISA extended BIOS functions. This call is required in every program (that uses PCI-20501Cs) to inform the Software Library of PCI-20501C Board slot assignments and memory map locations. Each PCI-20501C Board found will automatically be initialized when HWInit is called. A warning code will be returned if this function is called on an ISA-class machine. SlotSearchISA int SlotSearchISA (int far *count, ISASearchBoardTypeArray far *info) Call Description This function searches the memory map for Intelligent Instrumentation ISA Boards or Carriers and returns the number of boards found along with information about each board. Note, only those Boards/Carriers with software support already loaded (using the IncludeXXXX function call) will be detected. (Note, you must still call SlotAssign to assign slot numbers to ISA Boards.) Parameter Descriptions count the number of Boards/Carriers found. info the Board or Carrier information array. For each device found, the ID code and segment address are returned. (Note, ID codes are listed in the SlotInquire function call parameter descriptions.) The ISA search information structure is shown below: /* ISA board search type definition*/ #define MAXSLOT 32 typedef struct ISASearchBoardType { unsigned id; unsigned segment; } ISASearchBoardType; /* ID. */ /* segment. */ typedef ISASearchBoardType ISASearchBoardTypeArray [MAXSLOT]; 4-92 Chapter 4: Software Libraries Function Call Reference SlotSearchIO int SlotSearchIO (int far *count, IOSearchBoardTypeArray far *info) Call Description This function searches the I/O map for PCI-20377W and PCI-20428W Boards and returns the number of units found along with information about each board. Note that only those Boards with software support already loaded (using the IncludeXXXX function call) will be detected. (Note that you must still call SlotAssignIO to assign slot numbers to these Boards.) Parameter Descriptions count the number of Boards found. info the Board information array. For each device found, the ID code and base address are returned. (Note, ID codes are listed in the SlotInquire function call parameter descriptions.) The search information structure is shown below: /* * */ IO board search type definition #define MAXSLOT 32 typedef struct IOSearchBoardType { unsigned id; unsigned address; } IOSearchBoardType; /* ID. */ /* Base I/O addrress. */ typedef IOSearchBoardType IOSearchBoardTypeArray [MAXSLOT]; UnregisterClient int UnregisterClient (void); Call Description This call applies to Windows 3.x and Win32 applications only. This call unregisters an application instance with the drivers and must be the last call in your Windows program. Example The following code segment is taken from the sample program AI_CW.C: . . . /* * Unregister this application instance with the drivers. */ error_code = UnregisterClient (); ErrorRoutine (0, error_code, "Error in UnregisterClient"); return 0; } 4-93 Chapter 4: Software Libraries Function Call Reference IncludeXXXX int IncludeXXXX (void) Call Description IncludeXXXX function calls are provided to link software support for the hardware used by the application. There is a unique IncludeXXXX call for each Board, Carrier and I/O Module product. Additionally, there are IncludeXXXX calls for buffer, DMA, and thermocouple temperature measurement software support. The IncludeXXXX calls must be made between the SWInit and HWInit calls. You should call IncludeXXXX for your hardware components after calling SWInit. XXXX can take on values like 2M (for PCI-20002M support), 3M (for PCI-20003M), 341M (for PCI-20341M), and so on. The available IncludeXXXX calls are listed below. Hardware Support Include17M (void) Provides support for the PCI-20017M-1 Simultaneous Sample/Hold Module (no longer available - the PCI-20363M-1 SSH Module has replaced this unit.) Include19M (void) Provides support for all PCI-20019M High-Speed 12-Bit Analog Input Modules. Include1C (void) Provides support for all PCI-20001C General Purpose Carriers. Include20M (void) Provides support for the PCI-20020M-1 Trigger/Alarm Module. Include21M (void) Provides support for the PCI-20021M-1B 12-Bit 8-Channel Analog Output Module. Include23M (void) Provides support for the PCI-20023M-1 12-Bit Very High-Speed Analog Input Module. Include2M (void) Provides support for the PCI-20002M-1 12-Bit Analog Input Module. Include31M (void) Provides support for the PCI-20031M-1 Analog Expander/Sequencer Module. Include341M (void) Provides support for the PCI-20341M-1 High-Resolution Analog Input Module. Include363M (void) Provides support for the PCI-20363M-1 8-Channel Simultaneous Sample/Hold Module. Include364M (void) Provides support for the PCI-20364M-1 High-Accuracy (12/16/18-Bit) Analog Input Module. Include368M (void) Provides support for the PCI-20368M-1 High-Speed (1 MHz) Analog Expander Module. Include3M (void) Provides support for PCI-20003M Analog Output Modules. Include41C (void) Provides support for PCI-20041C High-Performance Carriers. Include4M (void) Provides support for the PCI-20004M-1 Digital I/O Module. Include501C (void) For DOS and Windows 16-bit applications only. Provides support for the PCI20501C-1 High-Performance Multifunction, and PCI-20501C-1 High-Performance EISA Boards. Include5M (void) Provides support for the PCI-20005M-1 Analog Expander Module (this product is no longer available, it has been replaced by the PCI-20031M.) Include6M (void) Provides support for the PCI-20006M-2 16-bit Analog Output Module. Include7M (void) Provides support for the PCI-20007M-1A Counter/Timer Module. Include87W (void) Provides support for the PCI-20087W-1 Digital I/O Board. Include89W (void) Provides support for the PCI-20089W-1 Analog Input Board. Include91W (void) Provides support for the PCI-20091W-1 High-Speed Analog Input Board. Include93W (void) Provides support for the PCI-20093W-1 Analog Output Board. Include377W (void) Provides support for the PCI-20377W-1 Multifunction Board. Include378W (void) Provides support for the PCI-20378W Series High-Density Digital I/O Boards. Include428W (void) Provides support for the PCI-20428W Series Multifunction Boards. Include98C (void) Provides support for all PCI-20098C Series Multifunction Boards. 4-94 Chapter 4: Software Libraries Function Call Reference Software Support IncludeBUF (void) Provides data buffer support for DMA operations. IncludeDMA (void) Provides support for DMA Input/Output operations. IncludeTC (void) Provides support for thermocouple temperature measurement. Initialization Examples The following program segments show how the various initialization function calls are used. This example illustrates the initialization procedure for an application which uses a PCI-20098C and the PCI20341M: int InitRoutine (void) { int err; if (err = SWInit ()) return err; if (err = Include98C ()) return err; if (err = Include341M ()) return err; if (err = SlotAssign( slot, segment)) return err; return HWinit (); } This example shows how you can use the SlotInquire function call to find a Board or Carrier by detecting a valid module present flag and a module ID code. Function findCarrierByID (ID : Integer; Var slot : Integer) : Boolean; Var err : Integer; found : Boolean; s : Integer; info : ModInfoTypeArray; Begin s := 1; found := FALSE; Repeat err := SlotInquire (s, info); { ... handle the error, if any ... } If (info[0].present <> 0) And (info[0].id = ID) Then Begin found := TRUE; slot := s; End; Inc(s); Until (s = MAXSLOT) Or found; findCarrierByID := found; End; This example shows how to use the SlotSearchISA function to find Intelligent Instrumentation ISA Boards in your system, and display their ID codes and segment addresses. err := SlotSearchISA(count, boards); { ... handle the error, if any ... } For i := 0 To count-1 Do Begin Writeln ('board #', i:1, ': segment = ', boards[i].segment, ' id = ', boards[i].id); End; 4-95 Chapter 4: Software Libraries Function Call Reference Hardware Initialization States The following tables describe the state of Data Acquisition Devices after initialization by HWInit. Unless otherwise stated, number references to specific products are to be taken to mean the entire line of that product. For example, when the PCI-20098C Multifunction Board is referred to, we mean all PCI-20098C Series Multifunction Boards. If a particular function operates on only one version of a product, we will make reference to that version only. Initialization Sequence After the appropriate IncludeXXXX calls have been made, the HWInit function performs the following initialization sequence: 1. If the Board or Carrier has on-board input/output (I/O) channels, each on-board function is initailized. 2. For Boards/Carriers with Module positions, starting with Module position 1, each of the Modules present are initialized 3. The Analog Daisy Chain is established (i.e. attaching or "chaining" Expander Modules to A/Ds). Below is a list of hardware initialization sequences for each of the PCI-20000 Series Modules. Note: All channelnumber designations are identical to the channel numbering found on the Board or Carrier or Module. That is, numbers begin with 0 as the first channel, 1 as the second channel, and so forth. PCI-20001C-2 CARRIER WITH DIGITAL I/O Four digital I/O ports are set up. All digital I/O ports are configured as inputs by the initialization procedure. PCI-20002M ANALOG INPUT MODULE The initialization procedure performs an analog conversion to verify hardware operation. If the hardware is faulty the system may "hang". PCI-20003M 12-BIT ANALOG OUTPUT MODULE Analog output channels are initially set to the middle of their range. A channel configured for bipolar range will be set to zero voltage; a channel configured for unipolar range will be set to half scale. PCI-20004M-1 DIGITAL I/O MODULE Four digital I/O ports are set up. All ports are configured as inputs by the initialization procedure. PCI-20006M 16-BIT ANALOG OUTPUT MODULE Analog output channels are initially set to the middle of their range. A channel configured for bipolar range will be set to zero voltage; a channel configured for unipolar range will be set to half scale. PCI-20017M SIMULTANEOUS SAMPLE/HOLD MODULE This unit is no longer available, it is replaced by the PCI-20363M SSH Module. The Module is put into HOLD then SAMPLE mode. If the Module fails to respond to a software HOLD or SAMPLE command during initialization, an error condition is set. NOTE: This Module can not be used with the PCI-20341M 16-bit Analog Input Module. 4-96 Chapter 4: Software Libraries Function Call Reference PCI-20020M TRIGGER/ALARM MODULE The trigger channel is disabled by the initialization procedure. The Analog output channels are set to mid-range (0 volts). PCI-20021M EIGHT-CHANNEL ANALOG OUTPUT MODULE All 8 analog output channels are initially set to zero volts. PCI-20023M HIGH-SPEED ANALOG INPUT MODULE The scanner base for this Module's scan list is set to 0 (zero). The initialization procedure performs an analog conversion to verify hardware operation. If the hardware is faulty the system may "hang". PCI-20031M ANALOG INPUT EXPANSION MODULE The initialization procedure resets the sequencer and writes a 0 (zero) into the first scan-list element, effectively disabling all the multiplexers and the channel advance. PCI-20041C HIGH PERFORMANCE CARRIER All digital I/O channels are configured as inputs by the initialization procedure. The rate generator, and delay counter are disabled. PCI-20098C MULTIFUNCTION BOARD All digital I/O ports are configured as inputs. The burst generator, and counters are disabled. (The burst generator, variable duty cycle generator, divider, and counter channels must be explicitly configured before being used.) The initialization procedure performs an analog conversion to verify hardware operation. If the hardware is faulty the system may "hang". PCI-20501C-1 HIGH-PERFORMANCE MULTIFUNCTION EISA BOARD All digital I/O ports are configured as inputs. The burst generator, and counters are disabled. (The burst generator, variable duty cycle generator, divider, counter channels must be explicitly configured before being used.) The initialization procedure performs an analog conversion to verify hardware operation. If the hardware is faulty the system may "hang". PCI-20501C-2 HIGH-PERFORMANCE EISA BOARD All digital I/O ports are configured as inputs. The burst generator, and counters are disabled. (The burst generator, variable duty cycle generator, divider, counter channels must be explicitly configured before being used.) PCI-20341M 16-BIT ANALOG INPUT MODULE Module options are initialized with trigger mode disabled, trigger and pacer normal polarity, and single-shot data mode. Settling time count is set to 0 µsec. Hardware start-convert is disabled. The module is reset. The initialization procedure performs an analog conversion to verify hardware operation. If the hardware is faulty the system may "hang". NOTE: This Module cannot be used with the PCI-20017M Simultaneous Sample/Hold Module or the PCI20368M Expander Module. PCI-20363M 8-CHANNEL SIMULTANEOUS SAMPLE/HOLD MODULE The Sample/Hold and Pacer Source status bits are checked. Next, the Module is reset. Settling time count is set to 0µsec. The scan list is initialized for all eight simultaneous sample/hold channels. 4-97 Chapter 4: Software Libraries Function Call Reference PCI-20364M-1 HIGH-ACCURACY (12/16/18-BIT) ANALOG INPUT MODULE The initialization procedure performs the following operations. The options are initialized with active high SYNC OUT polarity, SYNC IN hardware pacing, hardware pacing disabled, 16-bit resolution, normal sampling mode, and extended result format. Finally, the Module is reset and the self-test and calibration status are checked for errors. NOTE: This Module cannot use hardware pacing when used with the PCI-20363M Simultaneous Sample/Hold Module. PCI-20368M-1 16-CHANNEL HIGH-SPEED ANALOG EXPANDER MODULE The initialization procedure resets the Module's sequencer. PCI-20377W-1 LOW POWER MULTIFUNCTION BOARD The board is reset, and the rate generator and counters are disabled. The initialization procedure configures the rate generator for 16-bit operation. PCI-20378W SERIES HIGH-DENSITY DIGITAL I/O BOARDS The board is reset, all digital I/O ports are set for input operation and all interrupts are disabled. PCI-20428W SERIES LOW COST MULTIFUNCTION BOARDS The board is reset, and the rate generator and counters are disabled. Analog outputs (PCI-20428W-1, -2 models) are set to 0 V out. 4-98 Chapter 4: Software Libraries Function Call Reference 4.5.10 Interrupt Function Calls SoftInt Generate a software interrupt (generates a pulse on the software interrupt SYNC Bus line) C Pascal BASIC int SoftInt (int slot, int module); function SoftInt (slot, module: Integer): Integer; FUNCTION SoftInt% (BYVAL slot%, BYVAL mdl%) SoftInt int SoftInt (int slot, int module) Call Description This call generates a "Software Interrupt" to the hardware at the specified slot and module positions. This function provides a means of sending a pulse to a specified input line without having to explicitly configure and connect a hardware pulse generating device. The target (input) must be connected to the SYNC_SW_INT source (software interrupt source) using the SYNCConfigure call. The SYNCConfigure call has a list of all available targets. SoftInt may be used with the PCI-20501C-1,-2 and PCI-20098C Boards. Parameter Descriptions slot slot number of the Board or Carrier where the device to receive the interrupt is located. module module position of the device to receive the interrupt. 4-99 Chapter 4: Software Libraries Function Call Reference 4.5.11 Rate Generator Function Calls RGConfigure Configure the given rate generator channel with rate parameters and a mode C Pascal BASIC int RGConfigure (int slot, int module, int channel, unsigned count1, unsigned count2, int mode); function RGConfigure (slot, module, channel: Integer; count1, count2: Word; mode: Integer): Integer; FUNCTION RGConfigure% (BYVAL slot%, BYVAL mdl%, BYVAL chn%, BYVAL cnt1%, BYVAL cnt2%, BYVAL mode%) RGDisable Disable specified rate generator C Pascal BASIC int RGDisable (int slot, int module, int channel); function RGDisable (slot, module, channel: Integer): Integer; FUNCTION RGDisable% (BYVAL slot%, BYVAL mdl%, BYVAL chn%) RGEnable Enable specified rate generator C Pascal BASIC int RGEnable (int slot, int module, int channel); function RGEnable (slot, module, channel: Integer): Integer; FUNCTION RGEnable% (BYVAL slot%, BYVAL mdl%, BYVAL chn%) RGConfigure int RGConfigure (int slot, int module, int channel, unsigned count1, unsigned count2, int mode) Call Description Configures the specified rate generator on a PCI-20007M-1A Counter/Timer/Rate Generator Module, a PCI20091W or PCI-20089W-1 Analog Input Board, a PCI-20377W Low Power Multifunction Board or a PCI20428W Series Low Cost Multifunction Board. This call also applies to the pacer circuits on a PCI-20041C High-Performance Carrier. The rate generator in the given slot/module position is configured with a pair of count values, and a mode. The period, and frequency of the rate generator output signal will be: T = (count1*count2*125 nsec) F = 1/T = 8 MHz/(count1*count2) A utility function (FrequencyToRGCounts) is provided by the Master Link Libraries which returns count1 and count2 values based on a frequency value for use by the RGConfigure call. See the utilities section. NOTES: 1. For the PCI-20377W Board, the above equation only applies if the Board has been configured for 32-bit rate generator operation through the SetOptions377. If 16-bit mode is used (default), count2 is disregarded. See the SetOptions377 call description for further details. 2. For a PCI-20428W Series Board, count2 is disregarded since the board’s analog input rate generator (and analog output rate generator for -1 and -2 models) operate in 16-bit mode. Also see the SetOptions377 call description for more information on 16-bit rate generator operation. 4-100 Chapter 4: Software Libraries Function Call Reference The mode parameter specifies square wave or variable pulse width operation. If variable pulse width mode is chosen, the low going portion of the waveform is defined by: Tlow = count1*125 nsec The total period in pulse width mode is still equal to the value for T, given earlier. Important: The rate generators on the supported hardware devices can be disabled or enabled through software control (using the RGDisable and RGEnable calls). However, The PCI-20007M Module's rate generator channel, has an optional jumper setting for hardware controlled enabling/disabling through the Module's I3 Bus SYNC IN line. For the RGDisable and RGEnable calls to work with the PCI-20007M, jumpers W10 and W12 of the Module must be IN. Please see the instruction manuals for these devices if you require additional information. The rate generator is disabled by the RGConfigure call prior to configuration or reconfiguration. The RGDisable call may also be used if you wish to disable the rate generator. The output of a rate generator is typically used as a source of evenly spaced pulses (to an Analog Input Module or on-board A/D start convert line) in DMA data acquisition applications. Parameter Descriptions slot slot number of the Board or Carrier where the rate generator is located. module module position number on the Board or Carrier in the specified slot which contains the channel (module should be set to zero for a PCI-20041C's pacer, or a rate generator channel on a PCI-20089W-1, PCI-20091W, PCI20377W or a PCI-20428W Board). channel rate generator channel to configure count1, count2 count1 and count2 work together to describe the rate generator's output waveform. See the call description for details. Note, count2 is disregarded for the PCI-20428W and for the PCI-20377W if it is set for 16-bit rate generator operation (see SetOptions377). mode rate generator mode for the indicated channel. The value of mode (2, or 3) determines the type of output waveform from the rate generator: 2 = Variable pulse width output 3 = Square Wave output When the rate generator is programmed for mode 2, the low pulse width of the output signal is determined by the value of count1. When the generator is programmed in mode 3, the output signal will be a square wave with the frequency determined by count1 and count2, as described in the call description. Example The following code segment lists a function that programs a rate generator for a specific frequency. Use of the FrequencyToRGCounts function and provisions to detect PCI-20428W and PCI-20377W Boards are incorporated into the code segment. 4-101 Chapter 4: Software Libraries Function Call Reference /****************************************************************************** * testRateGenerator * * Configures a rate generator channel for a frequency entered by the user. ******************************************************************************/ void testRateGenerator (int slot, int module) { int error_code; double frequency; unsigned count1; unsigned count2; int rg_double; /* * Prompt the user for the frequency in hertz. */ printf ("Enter frequency in hertz: "); scanf ("%lf", &frequency); /* * Compute counts from frequency. Note that if a PCI-20428W is used, * it only has a single section rate generator. */ switch (BOARDID) { case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: rg_double = kRGSingle; break; default: rg_double = kRGDouble; break; } FrequencyToRGCounts (frequency, rg_double, &count1, &count2); /* * Configure the rate generator channel based on the user's inputs. Note * that if a PCI-20377W is used, the rate generator is configured for two * sections. */ printf ("Configuring rate generator channel %d...", kChannel); if ((BOARDID == 0x20) || (BOARDID == 0x21)) { error_code = SetOptions377 (slot, module, kRGDouble); ErrorRoutine ("Error in SetOptions377", error_code); } error_code = RGConfigure (slot, module, kChannel, count1, count2, kRGMode); ErrorRoutine ("Error in RGConfigure", error_code); printf ("\n"); /* * Prompt for a key before enabling the generator. */ printf ("Press a key to enable the generator:"); (void) getch (); error_code = RGEnable (slot, module, kChannel); ErrorRoutine ("Error in RGEnable", error_code); printf ("\n"); 4-102 Chapter 4: Software Libraries Function Call Reference /* * Prompt for a key press by the user before disabling the rate generator. */ printf ("Press a key to disable the generator:"); (void) getch (); error_code = RGDisable (slot, module, kChannel); ErrorRoutine ("Error in RGDisable", error_code); printf ("\n"); } RGDisable int RGDisable (int slot, int module, int channel) Call Description This call disables a specified rate generator channel on a PCI-20007M Counter/Timer module, PCI-20041C Carrier, PCI-20089W-1 Board, PCI-20091W Board, PCI-20377W Board or PCI-20428W Board. Important note: The PCI-20007M Module's rate generator has an optional jumper setting for hardware controlled enabling/disabling through the Module's I3 Bus SYNC IN line. For the RGDisable and RGEnable calls to work with the PCI-20007M, jumpers W10 and W12 must be IN. Please see the instruction manuals for these devices if you require additional information. Parameter Descriptions slot slot number in which the Board or Carrier or Module containing the rate generator channel is located. module module position number on the Board or Carrier in the specified slot which contains the channel. This parameter should be set to 0 (zero) for on-board rate generators. channel channel to disable RGEnable int RGEnable (int slot, int module, int channel) Call Description Enables the given rate generator channel for its programmed mode. Important note: The PCI-20007M Module's rate generator has an optional jumper setting for hardware controlled enabling/disabling through the Module's I3 Bus SYNC IN line. For the RGDisable and RGEnable calls to work with the PCI-20007M, jumpers W10 and W12 must be IN. Please see the instruction manuals for these devices if you require additional information. Parameter Descriptions slot slot number in which the Board or Carrier or Module containing the rate generator channel is located. module module position number on the Board or Carrier in the specified slot which contains the channel. This parameter should be set to 0 (zero) for on-board rate generators. channel channel to enable 4-103 Chapter 4: Software Libraries Function Call Reference 4.5.12 Synchronization Bus SYNCConfigure Specify routing of synchronization signals within Modules, between Modules, or between Modules and a Board or Carrier via the SYNC Bus C Pascal BASIC int SYNCConfigure (int slot, int module, int source, int target); function SYNCConfigure (slot, module, source, target: Integer): Integer; FUNCTION SYNCConfigure% (BYVAL slot%, BYVAL mdl%, BYVAL source%, BYVAL target%) SYNCConfigure int SYNCConfigure (int slot, int module, int source, int target) Call Description Various PCI-20000 devices feature programmable switches and multiplexers that allow the interconnection of various signal sources and circuit inputs. The SYNCConfigure call provides a means to program a desired connection pair. The "Synchronization Bus" (or just SYNC Bus), refers the group of sources and inputs you may interconnect. SYNCConfigure establishes a connection from the specified "SYNC" source to the specified "SYNC" target. Several connections can be made by calling this function for each desired connection pair. In Intelligent Instrumentation data acquisition systems, SYNC signal routing is usually accomplished for the purpose of synchronizing the operations of several devices. For example, a trigger source, used to terminate a DMA process, can be directed to a DMA controller's trigger input. Or, a pacer source (used to initiate A/D conversions), can be connected to an A/D start convert input and an Expansion Module's SYNC IN line. The SYNCConfigure call supports the following programmable connections: Sync Bus connections on PCI-20501C High-Performance EISA Boards, PCI-20098C Series Multifunction Boards, and PCI-20377W Low Power Multifunction Boards. The PCI-20041C-3A Carrier's DMA controller trigger and pacer (other SYNC Bus connections on this unit use hardware jumpers). Programmable connections internal to PCI-20341M-1 and PCI-20364M-1 Analog Input Modules, and the PCI-20363M-1 Simultaneous Sample/Hold Module. The interrupt connection circuitry on PCI-20378W Series High-Density Digital I/O Boards. A listing of valid SYNC sources and targets are given after the parameter descriptions below. Following the list, are notes on applying SYNCConfigure to establish a desired connection pair. Parameter Descriptions slot slot location of the Board or Module containing the SYNC circuit you wish to configure. module module position of the SYNC circuit you wish to configure. Specify 0, for connections on a Board's SYNC Bus. 4-104 Chapter 4: Software Libraries Function Call Reference source SYNC Bus source. To disconnect a pair, call SYNCConfigure with SYNC_NONE as the new source for the old target. target SYNC Bus target Sources and Targets The following is a list of the available sources and targets. Each item is denoted by an (s), (t) or (s,t), indicating whether it is a source, target or either depending on the associated device referenced by slot and module. SYNC Bus sources/targets. These sources/targets reference connections to/from I/O Module SYNC IN, SYNC OUT and IRQ lines, Modules with programmable internal connections, the PCI-20501C's or PCI-20041C-3A's "inter-board" SYNC IN/OUT connections, and other Sync bus connections on PCI-20501C and PCI-20098C Series devices. SYNC_MODULE = Module SYNC OUT/IN (s,t) (note 1) SYNC_EXTERNAL = External SYNC OUT/IN (s,t) (note 2) SYNC_MOD_1 = Module 1 SYNC OUT/IN (s,t) (note 3) SYNC_MOD_2 = Module 2 SYNC OUT/IN (s,t) SYNC_MOD_3 = Module 3 SYNC OUT/IN (s,t) SYNC_IRQ_1 = Module 1 IRQ OUT/IN (s,t) (note 3, note 4) SYNC_IRQ_2 = Module 2 IRQ OUT/IN (s,t) (note 4) SYNC_IRQ_3 = Module 3 IRQ OUT/IN (s,t) (note 4) NOTES: 1. SYNC_MODULE is supported only as a source at this time. Functionality as a target is reserved for future hardware products. 2. When used as a source, SYNC_EXTERNAL references the external pacer input on a PCI-20341M, a PCI-20363M, or a PCI-20364M. SYNC_EXTERNAL can be used as a source or a target when referencing a PCI-20501C's inter-board external SYNC IN or external SYNC OUT signals respectively, or as a source for the PCI-20041C-3A's inter-carrier SYNC IN (jumper W48 or W49 IN). 3. Module position 1 is available on the PCI-20501C-2 Board, PCI-20098C and the PCI-20041C-3A Carrier only. 4. Module IRQ signals are not available on the PCI-20501C Series or PCI-20098C Series Sync Bus. SYNC Bus sources. Unless otherwise noted, these items reference SYNC sources on PCI-20501C or PCI-20098C Boards. SYNC_BG_OUT = Burst generator output (s) SYNC_RG_OUT = Rate generator output (s) (note 1) SYNC_CTR0_OUT = Counter 0 output (s) SYNC_CTR1_OUT = Counter 1 output (s) SYNC_EXT_INT = External interrupt (s) (note 2) SYNC_SW_INT = Software interrupt (s) SYNC_AD_BUSY = A/D busy (s) (note 3) SYNC_AD_DAV = A/D Data Available flag (s) (note 4) SYNC_DMA_TC = DMA Terminal Count Status flag (s) (note 4) SYNC_EXT_INT_0 = External interrupt 0 (s) (note 5) SYNC_EXT_INT_1 = External interrupt 1 (s) (note 5) SYNC_EXT_INT_2 = External interrupt 2 (s) (note 5) SYNC_EXT_INT_3 = External interrupt 3 (s) (note 5) SYNC_EXT_INT_4 = External interrupt 4 (s) (note 5) 4-105 Chapter 4: Software Libraries Function Call Reference SYNC_EXT_INT_5 = External interrupt 5 (s) (note 5) SYNC_NONE = None (s) (note 6) NOTES: 1. RG_OUT refers to the Pacer Clock on the PCI-20041C-3A Carrier and the Rate Generator on the PCI20377W Board. 2. SYNC_EXT_INT can also refer to the External Interrupt Input on the PCI-20041C-3A Carrier or a PCI-20377W’s digital connector. 3. A/D Busy only applies to the PCI-20501C-1's on-board A/D circuit. 4. SYNC_AD_DAV and SYNC_DMA_TC only apply to the PCI-20377W-1 Board. 5. SYNC_EXT_INT_0 applies to the auxiliary connector on PCI-20378W-1, -3 Boards. SYNC_EXT_INT_1, SYNC_EXT_INT_2 and SYNC_EXT_INT_3 applies to connectors P2, P3 and P4 respectively on PCI-20378W-1, -3 Boards only. SYNC_EXT_INT_4 and SYNC_EXT_INT_5 applies to connectors P5 and P6 respectively on a PCI-20378W-1 Board only. The port associated with the interrupt input line must be configured for input operation to function as an interrupt source (see the appropriate board’s manual for connection details). 6. SYNC_NONE also applies to PCI-20378W Series Boards. SYNC Bus targets. Unless otherwise noted, these items reference SYNC targets on PCI-20501C Boards, PCI-20098C Boards, and PCI-20041C-3A Carriers. SYNC_MUX_PACER = A/D expander pacer (t) (note 1) SYNC_AD_START = A/D start convert (t) (note 2) SYNC_AD_TRIG = A/D trigger (t) (note 3) SYNC_DMA_PACER = DMA pacer (t) (note 4) SYNC_DMA_TRIG = DMA trigger (t) (note 4) SYNC_BG_START = Burst generator SYNC start (t) (note 5) SYNC_BG_STOP = Burst generator SYNC stop (t) (note 5) SYNC_DIV0_TRIG = Divider 0 latch trigger (t) (note 5) SYNC_DIV1_TRIG = Divider 1 latch trigger (t) (note 5) SYNC_PC_IRQ_0 = PC Bus Interrupt Request line 0 (t) (note 6) SYNC_PC_IRQ_1 = PC Bus Interrupt Request line 1 (t) (note 6) SYNC_PC_IRQ_2 = PC Bus Interrupt Request line 2 (t) (note 7) SYNC_PC_IRQ_3 = PC Bus Interrupt Request line 4 (t) (note 7) SYNC_PC_IRQ_5 = PC Bus Interrupt Request line 5 (t) (note 7) SYNC_PC_IRQ_6 = PC Bus Interrupt Request line 6 (t) (note 7) SYNC_PC_IRQ_7 = PC Bus Interrupt Request line 7 (t) (note 7) NOTES: 1. SYNC_MUX_PACER refers to the internal pacer input (or HOLD) on a PCI-20363M-1 Module. The Module's external pacer input pin (SYNC_EXTERNAL), or the Module's SYNC IN line (SYNC_MODULE) may be chosen as the source of pacer signals to the internal pacer. If the Module's SYNC IN line is selected as the Module pacer input, a source of pacing signals must in turn be connected to SYNC IN using a second SYNCConfigure call. 2. SYNC_AD_START applies to the A/D start convert input on a PCI-20501C-1 on-board A/D, a PCI20098C on-board A/D, a PCI-20341M A/D, a PCI-20364M A/D, or a PCI-20377W-1's A/D. 3. SYNC_AD_TRIG refers to the on-board A/D trigger input of a PCI-20501C-1 Board. 4. SYNC_DMA_PACER and SYNC_DMA_TRIG apply to the PCI-20501C-1, -2 Boards and the PCI20041C-3A Carrier. SYNC_DMA_TRIG also applies to the PCI-20098C. 5. These targets are available on the PCI-20501C and PCI-20098C Boards only. 6. These targets are reserved for future products. 7. These apply to PCI-20377W and PCI-20378W Boards. Except for SYNC_PC_IRQ_6 and SYNC_PC_IRQ_7 these targets are available on the PCI-20377W Board. Only one of these targets may be paired at a time with the PCI-20377W sources: SYNC_AD_DAV or SYNC_DMA_TC. SYNC_PC_IRQ_2 through SYNC_PC_IRQ_7 apply to all PCI-20378W Series Boards. Only one of 4-106 Chapter 4: Software Libraries Function Call Reference these targets may be paired at a time with the PCI-20378W sources: SYNC_EXT_INT_0 through SYNC_EXT_INT_5 (see the source descriptions given earlier). Notes On Selecting Sources and Targets The following notes will help you avoid potential problems when using the SYNCConfigure call. Illegal Pairs If you specify an illegal source and target pair, an error code will be returned by SYNCConfigure. Specifying a designated source as a target (or visa versa) is a readily apparent error. Two of the less obvious types of illegal pairings are discussed below. Attempting to connect nonexistent sources/targets. If you try to connect a source and target on a hardware device that does not possess the referenced source or target an error will occur. Either the device you want to make the specified connection on does not the support the connection referenced, or you may have simply specified an incorrect module, (or slot) number. Attempting to mix a Module's sources/targets with another Module's source/targets. The source/target constant names listed on the previous pages are "module specific". When module is 0, connections that can be established between a Board's on-board functions, between a Board's functions and installed I/O Modules, and between installed I/O Modules are allowed. When module is 1, 2, or 3 you may only establish connections available within the I/O Module installed in the referenced module position. Only the following sources/targets are allowed for module positions 1, 2, and 3: SYNC_MODULE = Module SYNC OUT/IN (s) SYNC_EXTERNAL = External SYNC OUT/IN (s) SYNC_MUX_PACER = A/D expander pacer (t) SYNC_AD_START = A/D start convert (t) Even though it may seem logical the following procedure is incorrect: Lets say you want to connect SYNC OUT of Module 1 to SYNC IN of Module 2, where both Modules are on a Board installed in slot 1. So you specify the following values for each parameter; slot=1, module=1, source=SYNC_MODULE, and target=SYNC_MOD_2. These parameters will produce an error; SYNC_MOD_2 cannot be used in this context because you have selected connections within Module 1 (module=1). The correct procedure is to specify module=0, source=SYNC_MOD_1, and target=SYNC_MOD_2. When you choose module=0, the Board's SYNC Bus is selected and connections between Modules are allowed. Two Step Connections In some cases, two calls to SYNCConfigure are needed to complete a connection. This is required when you want to select one of two available connections internal to an I/O Module, then want to connect the selected line to a source on the Board's Sync Bus. For example, to connect the A/D start convert input of a PCI-20341M Analog Input Module to the on-board burst generator output of the PCI-20098C on which it is installed: Use the first SYNCConfigure call to internally select the PCI-20341M's SYNC IN line as the A/D start convert source. Assuming the PCI-20341M is installed in module position 1 and the slot number is 1, the following parameters should be used; slot=1, module=1, source=SYNC_MODULE, and target=SYNC_AD_START. Use the second SYNCConfigure call to connect the PCI-20098C's burst generator output to the PCI-20341M's SYNC IN line. The following parameters should be used; slot=1, module=0, source=SYNC_BG_OUT, and target=SYNC_MOD_1. 4-107 Chapter 4: Software Libraries Function Call Reference Example The following code segment shows how to use SYNCConfigure to set up connections in preparation for an analog input DMA operation using a PCI-20098C Multifunction Board. Procedure Configure98CForDMA(slot : Integer); Const ON_BOARD = 0; { Module = 0 indicates the board. } Var source : Integer; target : Integer; err : Integer; Begin { Configure the SYNC bus on the 98C Board for DMA. For this } { example, we use the burst generator to start conversions and } { trigger on the occurrence of an external interrupt input. } { Connect the burst generator to the A/D start convert. } source := SYNC_BG_OUT; target := SYNC_AD_START; err := SYNCConfigure(slot, ON_BOARD, source, target); { ... always check for error ... } { Connect the external interrupt input to the DMA trigger. } source := SYNC_EXT_INT; target := SYNC_DMA_TRIG; err := SYNCConfigure(slot, ON_BOARD, source, target); { ... always check for error ... } End; 4-108 Chapter 4: Software Libraries Function Call Reference 4.5.13 Thermocouple Measurement TCLinearize Convert voltage data from a thermocouple reading to a temperature C int TCLinearize (double volts, double cjctemp, int type, double far *temperature); function TCLinearize (volts, cjctemp: Double; tctype: Integer; var temperature: Double): Integer; FUNCTION TCLinearize% (BYVAL volts#, BYVAL cjctemp#, BYVAL tctype%, SEG temperature#) Pascal BASIC TCMeasure Perform a temperature measurement from analog input channels connected to a thermocouple, cold-junction reference and zero reference C int TCMeasure (int slot, int module, int channel, int zchannel, int cjcchannel, int range, int type, double far *temperature); function TCMeasure (slot, module, channel, zchannel, cjcchannel, range, tctype: Integer; var temperature: Double): Integer; FUNCTION TCMeasure% (BYVAL slot%, BYVAL mdl%, BYVAL chn%, BYVAL zchn%, BYVAL cjcchn%, BYVAL range%, BYVAL tctype%, SEG temperature#) Pascal BASIC TCLinearize int TCLinearize (double volts, double cjctemp, int type, double far *temperature) Call Description This function converts a voltage value you supply to the volts parameter, to a temperature value based on the specified type (the thermocouple type) and a Cold-Junction Compensation (CJC) temperature (in °C) specified in cjctemp. The temperature value (in °C), is returned in the temperature parameter. Supported thermocouple types are J, K and T and PCI-5B37J, K and T Non-Linearized Thermocouple Signal Conditioning Blocks. The full temperature range of each thermocouple type is supported. Performing a thermocouple measurement usually requires two analog input channels (configured for differential operation), one to obtain the thermocouple's output voltage and the other to acquire CJC data. PCI-5B37 Blocks have built-in CJC and must be connected to singleended analog input channels. Parameter Descriptions volts analog input data in volts. This could be a voltage read on the thermocouple channel, acquired with an AIRead call. The common format counts data from AIRead must be converted to a floating point voltage value and correctly scaled to the actual thermocouple voltage. You can use the CountsToVolts utility function to perform the counts to volts conversion and scaling. To convert the analog input counts data to voltage with the utility, you must know the gain and input range used for the the reading. Note, for most thermocouple types the output voltages are between -50 mV and +50 mV, a gain of 100 is typically required. PCI-5B37J, K and T Non-Linearized Thermocouple Signal Conditioning Blocks output 0 to 5 V for their specified temperature ranges (see the type parameter below). When using PCI-5B37 Blocks, the analog input device (A/D) must be configured for single-ended operation, a gain of 1, and an input range of 0 to +5 V or ±5 V. The equations to scale the output voltage (Vout), after conversion from counts to volts (see above paragraph), from each Block to obtain the actual thermocouple voltage for the volts parameter are given below: PCI-5B37J: volts = 5.00*(Vout/105.14) - 4.632 mV 4-109 Chapter 4: Software Libraries Function Call Reference PCI-5B37K: volts = 5.00*(Vout/86.69) - 3.553 mV PCI-5B37T: volts = 5.00*(Vout/206.21) - 3.378 mV cjctemp the temperature at the junction between the thermocouple leads and the analog input channel on which it was read in °C. The compensation temperature is typically derived from a linear temperature sensor located at the thermocouple/input circuit terminal block. If a 1 mV/°K CJC sensor is used, a typical CJC voltage will be 298 mV which is equivalent to (298 - 273.15)°C = 25°C or 77°F. If a PCI-5B37J, K or T Non-Linearized Thermocouple Signal Conditioning Block is used, specify 0.0 for cjctemp. type the thermocouple type. Specify one of the following: TC_TYPE_J = Type J TC_TYPE_K = Type K TC_TYPE_T = Type T TC_TYPE_J_5B = PCI-5B37J (-100 °C to 760 °C) TC_TYPE_K_5B = PCI-5B37K (-100 °C to 1350 °C) TC_TYPE_T_5B = PCI-5B37T (-100 °C to 400 °C) temperature the temperature value of the thermocouple tip in °C. TCMeasure int TCMeasure (int slot, int module, int channel, int zchannel, int cjcchannel, int range, int type, double far *temperature) Call Description This call performs a temperature measurement using a thermocouple connected to an analog input channel, a Cold-Junction Compensation (CJC) channel, and an optional auto-zero channel. TCMeasure eliminates the need to make separate AIRead calls to obtain the thermocouple voltage and CJC data. J, K, and T and PCI-5B37J, K and T Non-Linearized Thermocouple Signal Conditioning Blocks are supported. The full temperature range of each thermocouple type is supported. The temperature data (in °C), is returned by the call in the temperature parameter. When measuring standard thermocouples (i.e., non-PC-5B37 types), the gain will automatically be configured for differential input operation, a thermocouple channel gain of 100, and a CJC channel gain of 10 (if the input hardware supports these gains and if these parameters do not require jumper settings). If the hardware does not support these gains, then a gain of 1 is used and external amplification of these signals is assumed. If the hardware support these gains but reqiures jumpers to be set, the call assumes you have set the proper jumpers. For standard thermocouple measurements, the input hardware should always be configured for differential input operation for common mode noise rejection. If a PCI-5B37 Block is used, the thermocouple channel gain is configured for 1, and a CJC channel is not used. The input hardware must be configured for single-ended input operation when PCI-5B37 Blocks are used. The hardware will automatically be configured for these settings when a 5B37 type is specified and the hardware is software programable (see the Parameter Descriptions for additional information). 4-110 Chapter 4: Software Libraries Function Call Reference Parameter Descriptions slot slot location of the Board or Carrier or Module containing the thermocouple, CJC, and auto-zero analog input channels. module module position of the Analog Input (A/D) function used to read the analog data. channel thermocouple channel number. zchannel auto-zero channel number or AI_NO_ZERO for none. If an auto-zero reference channel is specified, it will be used to correct the thermocouple input channel prior to the linearization and compensation. PCI-20098C Series and PCI-20377W Multifunction Boards have built-in zero-reference functions. To use this feature, specify AI_HW_ZERO in zchannel. cjcchannel CJC channel number or TC_NO_CJC for none. Specify TC_NO_CJC if a PCI-5B37 Block is used. The CJC channel, if used, should be connected to a device which reports reference-junction temperature at 1 mV per degree Kelvin. For example, the PCI-20304T-2 Thermocouple Termination Panel has a built-in CJC sensing channel that supplies a 1 mV/°K output characteristic. range analog input range for the Analog Input device. Input range should be set for ±5 V. Specify the range code BIPOLAR_10. Note: You can use what ever range is available but ±5 V covers most of the temperature range with good resolution. Certain gain requirements, input configuration requirements and range jumper settings may also apply to your hardware configuration. Please check the following hardware specific requirements: For Standard Thermocouple Types: 1. Analog Input devices with software-programmable gain will automatically be configured for a differential thermocouple channel gain of 100, and a CJC channel gain of 10. Devices supporting these requirements are the PCI-20098C and PCI-20377W Multifunction Boards, and the PCI-20002M-1, PCI-20341M-1 and PCI-20364M Analog Input Modules. 2. The PCI-20089W-1 and PCI-20428W-1 Boards have software-programmable gains of 100 and 10 and jumper setable ranges and input configuration. For these boards, you must set the range jumpers for ±5 Vin., and set the input configuration jumpers for differential operation. 3. If you are using a PCI-20428W-2, a PCI-20501C-1 Board, a PCI-20091W-1 Board, a PCI-20019M-1A, or a PCI-20023M-1 Analog Input Module, you must provide external signal conditioning to provide gains of 10 and 100 for the CJC and thermocouple channels respectively. The PCI-20428W-2 and PCI-20023M-1 must also be jumper configured for an input range of ±5 V, and set the input configuration jumpers for differential operation. 4-111 Chapter 4: Software Libraries Function Call Reference For 5B37 Thermocouple Types: 1. Analog Input devices with software-programmable gain and input configuration will automatically be configured for a thermocouple channel gain of 1 and single-ended operation. Devices supporting these requirements are the PCI-20501C, PCI-20098C and PCI-20377W Multifunction Boards, the PCI-20091W Board, and the PCI-20002M-1, PCI-20341M-1 and PCI-20364M Analog Input Modules. 2. The PCI-20089W-1 and PCI-20428W-1,-2,-3 Boards and the PCI-20023M-1 Module have softwareprogrammable gains of 1and jumper setable ranges and input configuration. For these devices, you must set the range jumpers for ±5 Vin., and set the input configuration jumpers for single-ended operation. type the thermocouple type. Specify one of the following: TC_TYPE_J = Type J TC_TYPE_K = Type K TC_TYPE_T = Type T TC_TYPE_J_5B = PCI-5B37J (-100 °C to 760 °C) TC_TYPE_K_5B = PCI-5B37K (-100 °C to 1350 °C) TC_TYPE_T_5B = PCI-5B37T (-100 °C to 400 °C) temperature the temperature value of the thermocouple tip returned in °C. 4-112 Chapter 4: Software Libraries Function Call Reference 4.5.14 Trigger/Alarm Calls TRIGConfigure Configure the given analog trigger channel for specific high and low thresholds and a triggering mode C Pascal BASIC int TRIGConfigure (int slot, int module, int channel, int low, int high, int mode); function TRIGConfigure (slot, module, channel, low, high, mode: Integer): Integer; FUNCTION TRIGConfigure% (BYVAL slot%, BYVAL mdl%, BYVAL chn%, BYVAL low%, BYVAL high%, BYVAL mode%) TRIGDisable Disable the specified analog trigger channel C Pascal BASIC int TRIGDisable (int slot, int module, int channel); function TRIGDisable (slot, module, channel: Integer): Integer; FUNCTION TRIGDisable% (BYVAL slot%, BYVAL mdl%, BYVAL chn%) TRIGEnable Enable the specified analog trigger channel C Pascal BASIC int TRIGEnable (int slot, int module, int channel); function TRIGEnable (slot, module, channel: Integer): Integer; DECLARE FUNCTION TRIGEnable% (BYVAL slot%, BYVAL mdl%, BYVAL chn%) TRIGStatus Return status of the specified analog trigger channel C Pascal BASIC int TRIGStatus (int slot, int module, int channel, unsigned far *comparator, unsigned far *alarm); function TRIGStatus (slot, module, channel: Integer; var comparator, alarm: Word): Integer; FUNCTION TRIGStatus% (BYVAL slot%, BYVAL mdl%, BYVAL chn%, SEG comparator%, SEG alarm%) TRIGConfigure int TRIGConfigure (int slot, int module, int channel, int low, int high, int mode) Call Description This call configures a Trigger/Alarm Module to respond to various analog input conditions. Specifically, this instruction configures the PCI-20020M Trigger/Alarm Module as a window comparator to detect when the analog input is inside, or outside, of the specified low and high voltage thresholds. The triggering mode (inside, or outside a threshold window) is set in the mode parameter. Note, the Module should be jumpered for single input configuration. The analog input range of the PCI-20020M Trigger/Alarm Module is ±10 V. With 8-bit (78 mV) resolution the module can compare the analog input to programmable values ranging from -10.0 V to +9.92 V. See the Module's instruction manual for selecting trigger output jumper options. Note: The trigger channel is disabled prior to reconfiguration and must be enabled again with TRIGEnable. Parameter Descriptions slot slot number in which the Carrier containing the Trigger/Alarm Module is located. 4-113 Chapter 4: Software Libraries Function Call Reference module module position number on the Carrier in the specified slot which contains the Trigger/Alarm Module. channel channel on the Trigger/Alarm Module to configure (must be 0). low data value corresponding to the low end of the trigger channel's voltage window. The data value must be entered in common analog data counts format for the ±10 V range as shown below. high data value corresponding to the high end of the trigger channel's voltage window. The data value must be entered in common analog data counts format for the ±10 V range as shown below. To convert voltage values to counts values suitable for the low and high parameters of the TRIGConfigure function, use the Master Link utility function called VoltsToCounts. The call determines the correct count value for a specified voltage value based on the voltage range you specify. Specify the BIPOLAR_20 output range (i.e. ±10 V range) to the VoltsToCounts utility call to obtain the proper counts values for the low and high TRIGConfigure parameters. mode triggering mode (inside the window, outside the window). The analog triggering modes are defined as follows: TRIG_IN_MODE = trigger when input is between high threshold and low threshold TRIG_OUT_MODE = trigger when signal is outside thresholds (above high threshold or below low threshold) TRIGDisable int TRIGDisable (int slot, int module, int channel) Call Description Disables the given trigger channel on a PCI-20020M Trigger/Alarm Module. To reset a trigger channel, first disable and then enable it. Parameter Descriptions slot slot number in which the or Carrier containing the Trigger/Alarm Module is located. module module position number on the Carrier in the specified slot which contains the Trigger/Alarm Module. channel channel on the Trigger/Alarm Module to disable (must be 0). 4-114 Chapter 4: Software Libraries Function Call Reference TRIGEnable int TRIGEnable (int slot, int module, int channel) Call Description Enables detection of the trigger condition specified in a TRIGConfigure call for a PCI-20020M Trigger/Alarm Module. Parameter Descriptions slot slot number in which the Carrier containing the Trigger/Alarm Module is located. module module position number on the Carrier in the specified slot which contains the Trigger/Alarm Module. channel channel on the Trigger/Alarm Module to enable (must be 0). TRIGStatus int TRIGStatus (int slot, int module, int channel, unsigned far *comparator, unsigned far *alarm) Call Description Returns the status of the given trigger channel on a PCI-20020M Trigger/Alarm Module. High and low threshold levels are set using the TRIGConfigure call. Parameter Descriptions slot slot number in which the Carrier containing the Trigger/Alarm Module is located. module module position number on the Carrier in the specified slot which contains the Trigger/Alarm Module. channel channel from which to read status information (must be channel 0) comparator the current statuses of the window comparators. Returned information indicates which region the input voltage currently falls - below the low threshold, between the thresholds, or above the high threshold. Apply the following bit masks to the comparator status to detect if the indicated condition is true or false. CMP0_LT_THRESH = low threshold limit has not been exceeded (if bit mask compare is TRUE) CMP1_LT_THRESH = high threshold limit has not been exceeded (if bit mask compare TRUE) alarm the alarm (trigger) status. That is, whether or not the trigger condition, specified in the mode parameter of the TRIGConfigure call, has been met since the module was last reset. The following bit is provided. ALARM_ACTIVE = the trigger condition has been met (if bit mask compare is TRUE) To reset the ALARM_ACTIVE status, call TRIGDisable (or TRIGConfigure) followed by TRIGEnable. 4-115 Chapter 4: Software Libraries Function Call Reference Example The following code segment shows a procedure for configuring a trigger/alarm channel in TRIG_OUT_MODE, and monitoring for the occurrence of the trigger/alarm condition. dummy := VoltsToCounts (low_volts, BIPOLAR_20, low); dummy := VoltsToCounts (high_volts, BIPOLAR_20, high); mode := TRIG_OUT_MODE; { Trigger when input voltage is greater than } { highVoltage or less than lowVoltage. } err := TRIGConfigure(slot, module, channel, low, high, mode); { ... always check for errors detected during calls ... } err := TRIGEnable(slot, module, channel); { ... check for error ... } { Wait for alarm to become TRUE. } Repeat err := TRIGStatus(slot, module, channel, comparator, alarm); { ... test error code return value ... } Until (alarm And ALARM_ACTIVE) <> 0; 4-116 Chapter 4: Software Libraries Function Call Reference 4.5.15 Other Functions SetOptions98 Optionally invert the External Interrupt input signal on a PCI-20098C Multifunction Board C Pascal BASIC int SetOptions98 (int slot, int module, int invertXIRQ); function SetOptions98 (slot, module, invertXIRQ: Integer): Integer; FUNCTION SetOptions98% (BYVAL slot%, BYVAL mdl%, BYVAL invertXIRQ%) SetOptions364 Set resolution, integration mode (noise-rejection for 50 Hz or 60 Hz), and result format for a PCI-20364M-1 HighAccuracy (12/16/18-bit) Analog Input Module C Pascal BASIC int SetOptions364 (int slot, int module, int resolution, int mode, int commonformat); function SetOptions364 (slot, module, resolution, mode, commonformat: Integer): Integer; FUNCTION SetOptions364% (BYVAL slot%, BYVAL mdl%, BYVAL resolution%, BYVAL mode%, BYVAL commonformat%) SetOptions377W Optionally select a one section (16-bit) or two section (32-bit) Rate Generator configuration C Pascal BASIC int SetOptions377 (int slot, int module, int rgdouble); function SetOptions377 (slot, module, rgdouble: Integer): Integer; FUNCTION SetOptions377% (BYVAL slot%, BYVAL mdl%, BYVAL rgdouble%) SetOptions98 int SetOptions98 (int slot, int module, int invertXIRQ) Call Description This call provides you with the option of inverting a PCI-20098C Multifunction Board's External Interrupt (EXINT) input signal. EXINT is connected to pin 47 of the Board's Digital Signal Connector P3. NOTE: For all PCI-20098C on-board destinations (targets) this signal must be active high. If the source you wish to connect to EXINT is active-low, you may invert its sense with SetOptions98. Also see the SYNCConfigure call. Parameter Descriptions slot slot number of the PCI-20098C Multifunction Board. module module number 0 invertXIRQ invert EXINT signal. Set this parameter to "1" (TRUE) to invert the signal. The default is no inversion. 4-117 Chapter 4: Software Libraries Function Call Reference SetOptions364 int SetOptions364 (int slot, int module, int resolution, int mode, int commonformat) Call Description This call allows you to explicitly configure the PCI-20364M-1 High-Accuracy (12/16/18-Bit) Analog Input Module's resolution, integration mode, and output data format. Range, gain, input configuration (single-ended or differential) parameters are set using the AIReadExtended, AIRead, or AIConfigureList calls - depending the acquisition method you wish to employ. Resolution may be set for 12, 16 or 18-bits. The integration mode selects the Module's noise-rejection option normal, 60 Hz rejection, or 50 Hz rejection. Output data formats include common analog data format, or extended mode format. Common data format returns 16-bit two's complement data for Bipolar input ranges and straight 16-bit binary code for Unipolar input ranges. Extended mode is required for 18-bit resolution reads, but also supports 12-bit and 16-bit resolutions. Data is returned as a 32-bit signed integer in Extended mode (see the AIReadExtended data parameter description). In addition, valid readings are returned if the input exceeds the input range by up to 2 Volts. (±7 V limit for the ±5 V range, or -2V to 12V for the 0 to 10 V range.) If the PCI-20364M-1 Module is not configured with SetOptions364, the power-up default operating modes for the PCI-20364M-1 Module are; 16-bit resolution, normal integration mode, and extended (32-bit) output data format. You must use the AIReadExtended call to read an analog input channel on the PCI-20364M-1 with its power-on defaults. To read a channel using the AIRead call you must configure the Module for common analog data format (always returns a 16-bit integer). Note, you can still get valid results when the Module's A/D is configured for 18-bit resolution, but the 2 least significant bits are lost. Parameter Descriptions slot slot number of the Board or Carrier containing the PCI-20364M-1 Analog Input Module. module module position of the PCI-20364M-1. resolution A/D resolution. The resolution may be set to one of the following: RESOLUTION_12 = 12-Bit RESOLUTION_16 = 16-Bit RESOLUTION_18 = 18-Bit mode integration mode (sets integration period of A/D): MODE364_NORMAL = normal mode MODE364_60HZ_LN = 60 Hz Line Noise rejection mode MODE364_50HZ_LN = 50 Hz Line Noise rejection mode commonformat common result format flag. This flag is non-zero when the PCI-20364M is configured for common format results, or zero when configured for extended mode results (which is the power-on default). 4-118 Chapter 4: Software Libraries Function Call Reference SetOptions377 int SetOptions377 (int slot, int module, int rgdouble) Call Description This call provides you with the option of setting the PCI-20377W's rate generator for 32-bit or 16-bit operating mode. Set the rgdouble parameter to "1" (TRUE) for 32-bit operation, or "0" (FALSE) for 16-bit operation. When the Rate Generator is operated in 32-bit mode, 8254 Counter channel 0 is not available. The default mode is 16-bit operation. 16-Bit Rate Generator Operating Features Output frequency range for Pulse Mode and Square-Wave Modes: 122 Hz to 4 MHz Pulse mode pulse width range: A constant 125 nsec The Rate Generator output frequency, Fout, (in pulse or square wave modes) is determined by RGConfigure's parameters as follows: Fout = 8 MHz / count1 where count1 is a 16-bit integer greater than or equal to 2, and less than or equal to 65536. In pulse mode, the width of the low portion of the waveform, Tlow, is a constant 125 nsec: Tlow = 125 nsec 32-Bit Rate Generator Operating Features Output frequency range for Pulse Mode and Square-Wave Modes: 0.00189 Hz to 2 MHz Pulse mode pulse width range: Variable duty cycle from 250 nsec to 8.95 minutes The Rate Generator output frequency (in pulse or square wave modes) for 32-bit mode is described in the RGConfigure call description. Parameter Descriptions slot slot number of the PCI-20377W Board. module module number must be 0 rgdouble 16 or 32-bit mode flag. "1" or TRUE for 32-bit mode "0" or FALSE for 16-bit mode 4-119 Chapter 4: Software Libraries Function Call Reference 4.5.16 Utility Functions CountsToVolts Convert a count value returned by AIRead to a floating point voltage value C Pascal BASIC int CountsToVolts (int counts, int gain, int range, double far *volts); function CountsToVolts (counts, gain, range: Integer; var volts: Double): Integer; Function CountsToVolts% (ByVal counts%, ByVal gain%, ByVal range%, volts#) ExtendedCountsToVolts Convert an extended count value returned by AIReadExtended to a floating point voltage value C Pascal BASIC int ExtendedCountsToVolts (long counts, int gain, int range, double FAR *volts); function ExtendedCountsToVolts (counts: Longint; gain, range: Integer; var volts: Double): Integer; Function ExtendedCountsToVolts% (BYVAL counts&, BYVAL gain%, BYVAL range%, SEG volts#) FrequencyToRGCounts Computes the count1 and count2 parameters used in RGConfigure to obtain a rate generator frequency C Pascal BASIC int FrequencyToRGCounts (double frequency, int rgdouble, unsigned far *count1, unsigned far *count2); function FrequencyToRGCounts (frequency: Double; rgdouble: Integer; var count1: Word; var count2: Word): Integer; function FrequencyToRGCounts% (BYVAL frequency#, BYVAL rgdouble%, SEG count1%, SEG count2%) VoltsToCounts Convert from a voltage value to count value suitable as parameter for AOWrite, AOWriteGroup or TRIGConfigure. C Pascal Basic int VoltsToCounts (double volts, int range, int far *counts); function VoltsToCounts (volts: Double; range: Integer; var counts: Integer): Integer; Function VoltsToCounts% (ByVal volts#, ByVal range%, counts%) CountsToVolts int CountsToVolts (int counts, int gain, int range, double far *volts); Description This utility performs a conversion from common analog format counts data to a floating point voltage value. CountsToVolts is provided for converting the counts values returned from the function call AIRead to voltage. The calculation requires the input voltage range and the gain used when the input reading was taken. Parameter Descriptions counts count value (from an AIRead operation) you want converted to a voltage value. 4-120 Chapter 4: Software Libraries Function Call Reference range analog input voltage range used for calculating the counts to voltage conversion. The range value should be the same as that passed to AIRead. UNIPOLAR_5 = 0 - 5 V UNIPOLAR_10 = 0 - 10 V BIPOLAR_5 = ±2.5 V BIPOLAR_10 = ±5 V BIPOLAR_20 = ±10 V gain gain used for calculating the counts to voltage conversion. The gain value should be the same as that passed to AIRead. volts voltage value calculated and returned by the call. ExtendedCountsToVolts int ExtendedCountsToVolts (long counts, int gain, int range, double far *volts); Description This utility performs a conversion from extended analog counts data to a floating point voltage value. ExtendedCountsToVolts is provided for converting the counts values returned from the function call AIReadExtended to voltage. The calculation requires the input voltage range and the gain used when the input reading was taken. Note, AIReadExtended is used to read 18-bit result data from a PCI-20364M HighResolution Analog Input Module. Parameter Descriptions counts count value (from an AIReadExtended operation) you want converted to a voltage value. range analog input voltage range used for calculating the counts to voltage conversion. The range value should be the same as that passed to AIReadExtended. UNIPOLAR_5 = 0 - 5 V UNIPOLAR_10 = 0 - 10 V BIPOLAR_5 = ±2.5 V BIPOLAR_10 = ±5 V BIPOLAR_20 = ±10 V gain gain used for calculating the counts to voltage conversion. The gain value should be the same as that passed to AIReadExtended. volts voltage value calculated and returned by the call. 4-121 Chapter 4: Software Libraries Function Call Reference FrequencyToRGCounts int FrequencyToRGCounts (double frequency, int rgdouble, unsigned far *count1, unsigned far *count2); Description Based on a frequency value in Hz, this utility calulates the counts values used by the RGConfigure call for configuring a rate generator. An iterative process is used to compute the best values for count1 and count2. If the call’s rgdouble flag is set to TRUE, count values for both count1 and count2 are returned (for configuring a 32-bit or two section rate generator). If the rgdouble flag is set to FALSE, only count1 is returned (for configuring a 16bit or single section rate generator). Parameter Descriptions frequency frequency value in Hz you want converted to count1 and count2 integer values rgdouble 16 or 32-bit mode flag. "1" or TRUE for 32-bit rate generator mode "0" or FALSE for 16-bit rate generator mode count1and count2 returned values for count1and count2 in the rate generator frequency formula VoltsToCounts int VoltsToCounts (double volts, int range, int far *counts); Description This utility performs a conversion from a floating point voltage value to a common analog format counts value. The VoltsToCounts conversion function is provided to prepare voltage data for the functions AOWrite, AOWriteGroup or TRIGConfigure. Parameter Descriptions volts voltage value you want converted to a counts value. range analog output range used for calculating the volts to counts conversion. The range value should be the same as that passed to the AOConfigure or TRIGConfigure call. UNIPOLAR_5 = 0 - 5 V UNIPOLAR_10 = 0 - 10 V BIPOLAR_5 = ±2.5 V BIPOLAR_10 = ±5 V BIPOLAR_20 = ±10 V counts common analog format counts value calculated and returned by the call. 4-122 Appendix A: Sample Program Descriptions Appendix A: Sample Program Descriptions This appendix contains a listing and brief descriptions of all sample programs supplied with the Master Link Software Libraries. Section A.1 lists the sample DOS based programs, section A.2 lists the sample Microsoft Windows 3.x based programs and section A.3 lists the Win32 based sample programs. Sample programs are listed by functional group, such as Analog Input, Analog Output, Digital Input/Output, etc. The functions provided through these sample programs are intended to serve as a "tool set" from which code segments can be easily extracted and recombined to form the core of a final applications program. You are invited to draw upon the furnished examples for your own programs. Please note, in order for the sample programs to work you must also compile and link certain utility routines to the sample programs. For example, every sample program requires the error handler function 'ErrorRoutine' defined in the utility program ERR.C for C, ERR.PAS for Pascal, ERR.BAS for DOS applications, ERRW.C for C, ERRW.PAS for Pascal, ERRW.BAS for Windows 3.x and Win32 applications. Before compiling a sample program be sure to glance over the source code for any utility functions that may be needed. A.1 DOS Based Sample Programs The following DOS sample programs, in all supported language versions, are supplied with the Master Link Software Libraries package. Every functional category supported by the Software Libraries are represented in this sample program group. A.1.1 Analog Input Both single channel type reads and analog input DMA acquisition sample programs are provided in this functional category. AI (Analog Input - Single Channel Read) Language C Pascal QuickBASIC File Name AI_C.C AI_P.PAS AI_B.BAS This sample program demonstrates reading analog input data from an Analog Input Board or Module or an Analog Expansion Module. The following function call is featured: AIRead. This sample program will work without substantial modification with the following hardware components: PCI20501C, PCI-20098C, PCI-20089W, PCI-20091W, PCI-20377W, PCI-20428W, PCI-20368M, PCI-20341M, PCI-20031M, PCI-20023M, PCI-20019M, PCI-20005M, PCI-20002M. AI364 (Automatic Calibration and Analog Input Single Channel Read for a PCI-20364M-1 Module) Language C Pascal QuickBASIC File Name AI364_C.C AI364_P.PAS AI364_B.BAS A-1 Appendix A: Sample Program Descriptions This sample program demonstrates the use of a PCI-20364M High Resolution Analog Input Module to acquire analog input data. The following function calls are featured: AICalibrate, AICalibrationStatus, AIRead, AIReadExtended, and SetOptions364. AIDMA (Analog Input DMA Acquisition) Language C Pascal QuickBASIC File Name AIDMA_C.C AIDMA_P.PAS AIDMA_B.BAS This sample program demonstrates the use of DMA to acquire analog input data. The following function calls are featured: AIConfigureList, BUFAllocate, BUFAttachProcess, BUFSeek, BUFDecode, BUFDeallocate, DMAGetHandle, DMASetOptions, DMASetPacer, DMASetTrigger, DMAConfigureList, DMAStart, DMAStatus, DMAFreeHandle, and SYNCConfigure. This sample program will work without substantial modification with the following hardware components: PCI20501C-1, PCI-20098C-1, PCI-20368M, PCI-20031M. AIDMR (Rate Generator Paced Analog Input DMA Acquisition) Language C Pascal QuickBASIC File Name AIDMR_C.C AIDMR_P.PAS AIDMR_B.BAS This sample program demonstrates the use of a rate generator to pace an analog input DMA process. The following function calls are featured: AIConfigureList, BUFAllocate, BUFAttachProcess, BUFSeek, BUFDecode, BUFDeallocate, DMAGetHandle, DMASetOptions, DMASetPacer, DMASetTrigger, DMAConfigureList, DMAStart, DMAStatus, DMAFreeHandle, and SYNCConfigure. This sample program will work without substantial modification with the following hardware components: PCI20041C, PCI-20428W, PCI-20377W, PCI-20091W, PCI-20368M, PCI-20364M, PCI-20363M, PCI-20341M, PCI-20031M, PCI-20023M, and the PCI-20019M. A.1.2 Analog Output AO (Analog Output) Language C Pascal QuickBASIC File Name AO_C.C AO_P.PAS AO_B.BAS This sample program demonstrates the use of an analog output channel. The following function calls are featured: AOConfigure, and AOWrite. This sample program will work without substantial modification with the following hardware components: PCI20428W, PCI-20093W, PCI-20021M, PCI-20006M, and PCI-20003M. A-2 Appendix A: Sample Program Descriptions AODMA (Analog Output DMA transfer) Language C Pascal QuickBASIC File Name AODMA_C.C AODMA_P.PAS AODMA_B.BAS This sample program demonstrates the transfer of analog output data via DMA transfer. The following function calls are featured: AOConfigure, BUFAllocate, BUFAttachProcess, BUFEncode, BUFDeallocate, DMAGetHandle, DMASetOptions, DMASetPacer, DMASetTrigger, DMAConfigureList, DMAStart, DMAStatus, DMAFreeHandle, and SYNCConfigure. This sample program will work without substantial modification with the following hardware components: PCI20501C-1 and PCI-20501C-2. AODMR (Rate Generator Paced Analog Output DMA) Language C Pascal QuickBASIC File Name AODMR_C.C AODMR_P.PAS AODMR_B.BAS This sample program demonstrates the use of a rate generator to pace an analog output DMA process. The following function calls are featured: AOConfigure, BUFAllocate, BUFAttachProcess, BUFEncode, BUFDeallocate, DMAGetHandle, DMASetOptions, DMASetPacer, DMASetTrigger, DMAConfigureList, DMAStart, DMAStatus, DMAFreeHandle, and SYNCConfigure. ' This sample program will work without substantial modification with the following hardware components: PCI20041C, PCI-20428W. A.1.3 Burst Generator BG (Burst Generator) Language C Pascal QuickBASIC File Name BG_C.C BG_P.PAS BG_B.PAS This sample program demonstrates the use of a burst generator channel. The following function calls are featured: BGConfigure, BGEnable, and BGDisable. This sample program will work without substantial modification with the following hardware components: PCI20501C, and PCI-20098C. A-3 Appendix A: Sample Program Descriptions A.1.4 Counters, 8254-Based CT8254 (Counter 8254-Based) Language C Pascal QuickBASIC File Name CT8254_C.C CT8254_P.PAS CT8254_B.BAS This sample program demonstrates the use of 8254-based counter type channels in event counter mode. The following function calls are featured: CTR8254Configure, CTR8254Enable, CTR8254Disable, and CTR8254ReadGroup. This sample program will work without substantial modification with the following hardware components: PCI20428W, PCI-20377W, PCI-20089W and PCI-20007M. A.1.5 Counters CTR16 (Counter, 16-Bit) Language C Pascal QuickBASIC File Name CTR16_C.C CTR16_P.PAS CTR16_B.BAS This sample program demonstrates the use of 16-bit on-board counter type channels in event counter mode. The following function calls are featured: CTRConfigure, CTREnable, CTRDisable, and CTRRead. This sample program will work without substantial modification with the following hardware components: PCI20501C, and PCI-20098C. MSR32 (Signal Measurement Using a 32-Bit Counter) Language C Pascal QuickBASIC File Name MSR32_C.C MSR32_P.PAS MSR32_B.BAS This sample program demonstrates the use of 32-bit on-board counter type channels in signal measurement mode for a 32-bit Signal Measurement. The following function calls are featured: CTRConfigure, and CTRMeasure. This sample program will work without substantial modification with the following hardware components: PCI20501C, and PCI-20098C. A-4 Appendix A: Sample Program Descriptions A.1.6 Digital Input/Output DIO (Basic Digital Input/Output) Language C Pascal QuickBASIC File Name DIO_C.C DIO_P.PAS DIO_B.BAS This sample program demonstrates the use of digital I/O ports. The following function calls are featured: DIOConfigure, DIORead, and DIOWrite. This sample program will work without substantial modification with the following hardware components: PCI20501C, PCI-20098C, PCI-20041C, PCI-20001C, PCI-20428W, PCI-20378W, PCI-20377W, PCI-20087W, and PCI-20004M. DIOH (Digital Input/Output, Handshake Mode) Language C Pascal QuickBASIC File Name DIOH_C.C DIOH_P.PAS DIOH_B.BAS This sample program demonstrates the use of digital I/O ports configured for handshaking. This program assumes that the data bits of port 0 are connected to the data bits of port 1, and that the handshake lines are connected correctly for port 0 to be an output port handshaking with port 1, which will be an input port. The correct connections are: OBF (output port) ───────────────_ STROBE (input port) IBF (input port) ───── invert ─────_ ACK (output port) Note that IBF from the input port must be inverted before being connected to ACK on the output port. For the PCI-20098C connected to a PCI-20025T termination panel, the correct connections are: CH. 7 (of TS3) ──────────────────────_ CH. 2 (of TS3) CH. 1 (of TS3) ───────── invert ────────_ CH. 6 (of TS3) The following function calls are featured: DIOConfigure, DIOStatus, DIORead, and DIOWrite. This sample program will work without substantial modification with the following hardware components: PCI20501C, PCI-20098C, and PCI-20087W. A-5 Appendix A: Sample Program Descriptions A.1.7 General Purpose DMA MIXDMA (Mixed I/O Type DMA Transfer) Language C Pascal QuickBASIC File Name MIXDMA_C.C MIXDMA_P.PAS MIXDMA_B.BAS This sample program demonstrates the transfer of mixed data types (analog input and digital input) via a single DMA process. The following function calls are featured: AIConfigureList, BUFAllocate, BUFAttachProcess, BUFSeek, BUFDecode, BUFDeallocate, DMAGetHandle, DMASetOptions, DMASetPacer, DMASetTrigger, DMAConfigureList, DMAStart, DMAStatus, DMAFreeHandle, and SYNCConfigure. This sample program will work without substantial modification with the following hardware components: PCI20501C-1, PCI-20501C-2, PCI-20368M, PCI-20364M, PCI-20341M, PCI-20031M, PCI-20023M, and PCI20019M. SWAP (Swap DMA Buffer at End of Terminal Count Mode) Language C Pascal QuickBASIC File Name SWAP_C.C SWAP_P.PAS SWAP_B.BAS This sample program demonstrates the technique of buffer swapping for DMA data acquisition. The following function calls are featured: AIConfigureList, BUFAllocate, BUFAttachProcess, BUFSeek, BUFDecode, BUFDeallocate, DMAGetHandle, DMASetOptions, DMASetPacer, DMASetTrigger, DMAConfigureList, DMAStart, DMAStatus, DMASwap, DMAFreeHandle, and SYNCConfigure. This sample program will work without substantial modification with the following hardware components: PCI20098C, PCI-20368M, and PCI-20031M. A.1.8 Rate Generator RG (Rate Generator) Language C Pascal QuickBASIC File Name RG_C.C RG_P.PAS RG_B.BAS This sample program demonstrates the use of a rate generator channel. The following function calls are featured: RGConfigure, RGEnable, and RGDisable. This sample program will work without substantial modification with the following hardware components: PCI20041C, PCI-20428W, PCI-20377W, PCI-20091W, PCI-20089W and PCI-20007M. A-6 Appendix A: Sample Program Descriptions A.1.9 Simultaneous Sample/Hold SSH (Simultaneous Sample/Hold Acquisition) Language C Pascal QuickBASIC File Name SSH_C.C SSH_P.PAS SSH_B.BAS This sample program demonstrates the use of a Simultaneous Sample/Hold Module to acquire analog input data. The following function call is featured: SSHReadGroup. This sample program will work without substantial modification with the following hardware components: PCI20363M. SSHDMA (Simultaneous Sample/Hold Acquisition Using DMA) Language C Pascal QuickBASIC File Name SSHDMA_C.C SSHDMA_P.PAS SSHDMA_B.BAS This sample program demonstrates the use of DMA to acquire Simultaneous Sample/Hold analog input data. The following function calls are featured: AIConfigureList, BUFAllocate, BUFAttachProcess, BUFSeek, BUFDecode, BUFDeallocate, DMAGetHandle, DMASetOptions, DMASetPacer, DMASetTrigger, DMAConfigureList, DMAStart, DMAStatus, DMAFreeHandle and SYNCConfigure. This sample program will work without substantial modification with the following hardware components: PCI20501C, PCI-20098C, and PCI-20363M. A.1.10 Thermocouple Measurement TCPL (Thermocouple Measurement) Language C Pascal QuickBASIC File Name TCPL_C.C TCPL_P.PAS TCPL_B.BAS This sample program demonstrates the use of a thermocouple to measure temperature. The following function call is featured: TCMeasure. This sample program will work without substantial modification with the following hardware components: PCI20098C, PCI-20428W, PCI-20377W, PCI-20089W, PCI-20341M, PCI-20364M and PCI-20002M. A-7 Appendix A: Sample Program Descriptions A.1.11 Analog Trigger TRIG (Analog Trigger) Language C Pascal QuickBASIC File Name TRIG_C.C TRIG_P.PAS TRIG_B.BAS This sample program demonstrates the use of an analog trigger channel. The following function calls are featured: TRIGConfigure, TRIGEnable, TRIGDisable, and TRIGStatus. This sample program will work without substantial modification with the following hardware components: PCI20020M. A-8 Appendix A: Sample Program Descriptions A.2 Microsoft Windows 3.x Based Sample Programs The following Windows 3.x sample programs, in all supported language versions, are supplied with the Master Link Software Libraries. A.2.1 Analog Input Both single channel type reads and analog input DMA acquisition sample programs are provided in this functional category. AI (Analog Input - Single Channel Read) Language C Pascal Visual Basic File Name AI_CW.C AI_PW.PAS AI_BW.FRM This sample program demonstrates reading analog input data from an Analog Input Board or Module or an Analog Expansion Module. The following function call is featured: AIRead. This sample program will work without substantial modification with the following hardware components: PCI20098C, PCI-20428W, PCI-20377W, PCI-20091W, PCI-20089W, PCI-20368M, PCI-20341M, PCI-20031M, PCI-20023M, PCI-20019M, PCI-20005M, and PCI-20002M. AIDMA (Analog Input - DMA Acquisition) Language C Pascal Visual BASIC File Name AIDMA_CW.C AIDMA_PW.PAS AIDMA_BW.FRM This sample program demonstrates the use of DMA to acquire and display analog input data. The following function calls are featured: AIConfigureList, BUFAllocate, BUFAttachProcess, BUFSeek, BUFDecode, BUFDeallocate, DMAGetHandle, DMASetOptions, DMASetPacer, DMASetTrigger, DMAConfigureList, DMAStart, DMAStatus, DMAFreeHandle and SYNCConfigure. This sample program will work without substantial modification with the following hardware components: PCI20098C, PCI-20368M and PCI-20031M. AIDMR (Rate Generator Paced Analog Input DMA Acquisition) Language C Pascal Visual Basic File Name AIDMR_CW.C AIDMR_PW.PAS AIDMR_BW.FRM This sample program demonstrates the use of a rate generator to pace an analog input DMA process. The following function calls are featured: AIConfigureList, BUFAllocate, BUFAttachProcess, BUFSeek, BUFDecode, BUFDeallocate, DMAGetHandle, DMASetOptions, DMASetPacer, DMASetTrigger, DMAConfigureList, DMAStart, DMAStatus, DMAFreeHandle and SYNCConfigure. A-9 Appendix A: Sample Program Descriptions This sample program will work without substantial modification with the following hardware components: PCI20041C, PCI-20428W, PCI-20377W, PCI-20091W, PCI-20368M, PCI-20364M, PCI-20363M, PCI-20341M, PCI-20031M, PCI-20023M and PCI-20019M. HDMA (Huge DMA Acquisition) Language C Pascal Visual Basic File Name HDMA_CW.C HDMA_PW.PAS HDMA_BW.FRM This sample program demonstrates a Huge DMA process (greater than 64 kbytes of data). The following function calls are featured: AIConfigureList, BUFAllocate, BUFAttachProcess, BUFSeek, BUFDecode, BUFDeallocate, DMAHugeGetHandle, DMASetOptions, DMASetPacer, DMASetTrigger, DMAConfigureList, DMAStart, DMAStatus, DMAFreeHandle and SYNCConfigure. This sample program will work without substantial modification with the following hardware components: PCI20098C, PCI-20368M and PCI-20031M. A.2.2 Analog Output AO (Analog Output) Language C Pascal Visual Basic File Name AO_CW.C AO_PW.PAS AO_BW.FRM This sample program demonstrates writing analog output data. The following function calls are featured: AOConfigure, and AOWrite. This sample program will work without substantial modification with the following hardware components: PCI20428W, PCI-20093W, PCI-20021M, PCI-20006M and PCI-20003M. AODMR (Rate Generator Paced Analog Output DMA) Language C Pascal Visual Basic File Name AODMR_CW.C AODMR_PW.PAS AODMR_BW.FRM This sample program demonstrates the use of a rate generator to pace an analog output DMA process. The following function calls are featured: AOConfigure, BUFAllocate, BUFAttachProcess, BUFEncode, BUFDeallocate, DMAGetHandle, DMASetOptions, DMASetPacer, DMASetTrigger, DMAConfigureList, DMAStart, DMAStatus, DMAFreeHandle and SYNCConfigure. This sample program will work without substantial modification with the following hardware components: PCI20041C and PCI-20428W. A-10 Appendix A: Sample Program Descriptions A.2.3 Digital Input/Output DIO (Basic Digital Input/Output) Language C Pascal Visual Basic File Name DIO_CW.C DIO_PW.PAS DIO_BW.FRM This sample program demonstrates the use of digital I/O ports. The following function calls are featured: DIOConfigure, DIORead, and DIOWrite. This sample program will work without substantial modification with the following hardware components: PCI20098C, PCI-20041C, PCI-20001C, PCI-20428W, PCI-20378W, PCI-20377W, PCI-20087W and PCI-20004M. A.2.4 Signal Measurement MEAS (Signal Measurement Using a 32-Bit Counter) Language C Pascal Visual BASIC File Name MEAS_CW.C MEAS_PW.PAS MEAS_BW.FRM This sample program demonstrates the use of 32-bit on-board counter type channels in signal measurement mode for a 32-bit Signal Measurement. The following function calls are featured: CTRConfigure, and CTRMeasure. This sample program will work without substantial modification with the following hardware components: PCI20098C. A-11 Appendix A: Sample Program Descriptions A.3 Win32 Based Sample Programs The following Win32 sample programs, in all supported language versions, are supplied with the Master Link 32bit Software Libraries. A.3.1 Analog Input Both single channel type reads and analog input DMA acquisition sample programs are provided in this functional category. AI (Analog Input - Single Channel Read) Language C Visual Basic File Name AI_CW.C AI_BW.FRM This sample program demonstrates reading analog input data from an Analog Input Board or Module or an Analog Expansion Module. The following function call is featured: AIRead. This sample program will work without substantial modification with the following hardware components: PCI20098C, PCI-20428W, PCI-20377W, PCI-20091W, PCI-20089W, PCI-20368M, PCI-20341M, PCI-20031M, PCI-20023M, PCI-20019M, PCI-20005M, and PCI-20002M. AIDMA (Analog Input - DMA Acquisition) Language C Visual BASIC File Name AIDMA_CW.C AIDMA_BW.FRM This sample program demonstrates the use of DMA to acquire and display analog input data. The following function calls are featured: AIConfigureList, BUFAllocate, BUFAttachProcess, BUFSeek, BUFDecode, BUFDeallocate, DMAGetHandle, DMASetOptions, DMASetPacer, DMASetTrigger, DMAConfigureList, DMAStart, DMAStatus, DMAFreeHandle and SYNCConfigure. This sample program will work without substantial modification with the following hardware components: PCI20098C, PCI-20368M and PCI-20031M. AIDMR (Rate Generator Paced Analog Input DMA Acquisition) Language C Visual Basic File Name AIDMR_CW.C AIDMR_BW.FRM This sample program demonstrates the use of a rate generator to pace an analog input DMA process. The following function calls are featured: AIConfigureList, BUFAllocate, BUFAttachProcess, BUFSeek, BUFDecode, BUFDeallocate, DMAGetHandle, DMASetOptions, DMASetPacer, DMASetTrigger, DMAConfigureList, DMAStart, DMAStatus, DMAFreeHandle and SYNCConfigure. A-12 Appendix A: Sample Program Descriptions This sample program will work without substantial modification with the following hardware components: PCI20041C, PCI-20428W, PCI-20377W, PCI-20091W, PCI-20368M, PCI-20364M, PCI-20363M, PCI-20341M, PCI-20031M, PCI-20023M and PCI-20019M. HDMA (Huge DMA Acquisition) Language C Visual Basic File Name HDMA_CW.C HDMA_BW.FRM This sample program demonstrates a Huge DMA process (greater than 64 kbytes of data). The following function calls are featured: AIConfigureList, BUFAllocate, BUFAttachProcess, BUFSeek, BUFDecode, BUFDeallocate, DMAHugeGetHandle, DMASetOptions, DMASetPacer, DMASetTrigger, DMAConfigureList, DMAStart, DMAStatus, DMAFreeHandle and SYNCConfigure. This sample program will work without substantial modification with the following hardware components: PCI20098C, PCI-20368M and PCI-20031M. A.3.2 Analog Output AO (Analog Output) Language C Visual Basic File Name AO_CW.C AO_BW.FRM This sample program demonstrates writing analog output data. The following function calls are featured: AOConfigure, and AOWrite. This sample program will work without substantial modification with the following hardware components: PCI20428W, PCI-20093W, PCI-20021M, PCI-20006M and PCI-20003M. AODMR (Rate Generator Paced Analog Output DMA) Language C Visual Basic File Name AODMR_CW.C AODMR_BW.FRM This sample program demonstrates the use of a rate generator to pace an analog output DMA process. The following function calls are featured: AOConfigure, BUFAllocate, BUFAttachProcess, BUFEncode, BUFDeallocate, DMAGetHandle, DMASetOptions, DMASetPacer, DMASetTrigger, DMAConfigureList, DMAStart, DMAStatus, DMAFreeHandle and SYNCConfigure. This sample program will work without substantial modification with the following hardware components: PCI20041C and PCI-20428W. A-13 Appendix A: Sample Program Descriptions A.3.3 Digital Input/Output DIO (Basic Digital Input/Output) Language C Visual Basic File Name DIO_CW.C DIO_BW.FRM This sample program demonstrates the use of digital I/O ports. The following function calls are featured: DIOConfigure, DIORead, and DIOWrite. This sample program will work without substantial modification with the following hardware components: PCI20098C, PCI-20041C, PCI-20001C, PCI-20428W, PCI-20378W, PCI-20377W, PCI-20087W and PCI-20004M. A.3.4 Signal Measurement MEAS (Signal Measurement Using a 32-Bit Counter) Language C Visual BASIC File Name MEAS_CW.C MEAS_BW.FRM This sample program demonstrates the use of 32-bit on-board counter type channels in signal measurement mode for a 32-bit Signal Measurement. The following function calls are featured: CTRConfigure, and CTRMeasure. This sample program will work without substantial modification with the following hardware components: PCI20098C. This sample program has been tested with the following compilers: Borland C++ 5.0 and Microsoft Visual Basic 4.0. A-14 Appendix B: Memory Manager, DMA Device Driver, Initialization Options and Interrupt Notes Appendix B: Memory Manager, DMA Device Driver, Initialization Options and Interrupt Notes B.1 Memory Manager Notes for DOS and Windows 3.x Intelligent Instrumentation hardware and software can be used in conjunction with '386 memory managers, such as 386MAX, EMM386 and QEMM, but because PCI-20000 Series hardware is generally memory-mapped, special switches need to be specified when loading the memory manager. If this step is not taken, error -201 will generally be returned from the HWInit call and the SlotSearchISA call will not find the boards. When using PCI-20501C EISA Boards under Microsoft Windows 3.x, additional steps may be required to assure that the EISA extended BIOS is available to the Master Link drivers. Where necessary, the steps to assure access to the EISA BIOS are documented below. The memory managers mentioned above can provide users of '386 and '486-based computers with more DOS memory than DOS alone can provide. In the process of returning sections of the computer's memory map to DOS, however, the memory managers will generally not be able to detect the presence of one or more PCI-20000 Boards in the computer and may actually 'remap' the memory which the board is occupying into another part of memory. If this happens, a board that has its segment address set to $CDOO, for example, no longer appears to be located at that segment. To prevent this, you must prevent the memory manager from remapping the section of memory which the board is set to occupy. B.1.1 386MAX To prevent 386MAX (from Qualitas) from remapping a particular section of memory, you must alter the contents of the profile file in the 386MAX subdirectory of your hard disk. This file, 386MAX.PRO, needs to have the RAM switch added to it. The parameter to the RAM switch should be the address range to be occupied by a PCI-20000 Board. Multiple RAM statements can be used, if necessary, to prevent remapping of multiple boards. For example, if you have a PCI-20098C Multifunction Board addressed at segment $CD00, then add the following line to the 386MAX.PRO file: RAM=CD00-CD40 ; Address PCI-20098C Board at $CD00. Note that, for the PCI-20501C Series High-Performance EISA Boards, you must use your EISA configuration program to determine the base address setting for each PCI-20501C Board and add a RAM statement to 386MAX.PRO for each address. 386MAX correctly handles the EISA extended BIOS area, so no additional switches are required when using PCI-20501C Boards under Microsoft Windows 3.x. B.1.2 EMM386 To prevent EMM386 (from Microsoft) from remapping a particular section of memory, you must alter the contents of your CONFIG.SYS file, changing the parameters with which EMM386 is loaded. You should add an x= memory option to the line in CONFIG.SYS which loads EMM386. This causes EMM386 to exclude the specified range of segment addresses from remapping. Multiple x= memory options can be used, if necessary, to prevent remapping of multiple boards. For example, if you have a PCI-20098C Multifunction Board addressed at segment $CD00, then the DEVICE=EMM386 line in your CONFIG.SYS file might look something like this: DEVICE=C:\WINDOWS\EMM386.EXE x=CD00-CD40 Note that, for the PCI-20501C Series Multifunction Board, you must use your EISA configuration program to determine the base address setting for each PCI-20501C Board and add an x= memory option to your CONFIG.SYS file for each address. B-1 Appendix B: Memory Manager, DMA Device Driver, Initialization Options and Interrupt Notes IMPORTANT NOTES FOR EMM386 USERS: 1. EISA DMA channels 5 and 7 are not handled correctly by EMM386.EXE. If your application uses one of the PCI20501C Series Multifunction Boards, you must assign DMA channel 1 or 3 to the on-board DMA controller that is being used. Note that the DMA channel selections are made in the EISA configuration program. 2. The DOS based DMASwap() function does not work correctly when EMM386.EXE is loaded. If your application uses DMASwap(), you must remove, or “Remark out”, the CONFIG.SYS line that loads EMM386.EXE. B.1.3 QEMM To prevent QEMM (from Quarterdeck Systems) from remapping a particular section of memory, you must alter the contents of your CONFIG.SYS file, changing the parameters with which QEMM is loaded. You should add an EXCLUDE statement to the line in CONFIG.SYS which loads QEMMTM. This causes QEMM to exclude the specified range of segment addresses from remapping. Multiple EXCLUDE statements can be used, if necessary, to prevent remapping of multiple boards. For example, if you have a PCI-20098C Multifunction Board addressed at segment $CD00, then the DEVICE=QEMM line in your CONFIG.SYS file might look something like this: DEVICE=C:\QEMM\QEMM386.SYS EXCLUDE=CD00-CD40 RAM Note that, for the PCI-20501C Series High-Performance EISA Boards, you must use your EISA configuration program to determine the base address setting for each PCI-20501C Board and add an EXCLUDE statement to your CONFIG.SYS file for each address. If you are using Microsoft Windows 3.x with any of the PCI-20501C Series Boards for the EISA bus, you must further exclude the EISA extended BIOS area so that PCI-20369S will be able to access information about your PCI-20501C Boards. To do this, add the additional statement EXCLUDE=F000-FFFF to the DEVICE=QEMM line in your CONFIG.SYS file. Newer versions of QEMM also have a feature called Stealth which allows QEMM to remap system ROM code to other locations in memory and to use the previous location of the ROM as DOS memory, possibly increasing available memory. Stealth options cannot be used when PCI-20501C Boards are to be used from within Windows 3.x. If the DEVICE=QEMM line in your CONFIG.SYS file contains any options of the form ST:[x], Stealth is enabled and the SlotSearchEISA call will not function from within Windows 3.x. If you are not using PCI-20501C Boards, or if you are not using Windows 3.x with the Master Link Software Libraries, you may enable Stealth options. B.1.4 EMMExclude Notes Windows 3.x performs a scan of the host computer's memory map to find any unused address space. This scanning can interfere with the operation of your memory-mapped Intelligent Instrumentation hardware. If you are using the SlotSearchISA function, the board(s) may not be identified by the software. The EMMExclude setting in the SYSTEM.INI file is used to specify range of memory the Windows 3.x will not scan to find unused address space. The range (two paragraph values separated by a hyphen) must be between A000 and EFFF. The starting value is rounded down and the ending value is rounded up to a multiple of 16K. For example, you could set EMMExclude=C800-CFFF B-2 Appendix B: Memory Manager, DMA Device Driver, Initialization Options and Interrupt Notes to prevent Windows 3.x from scanning the addresses C800:0000 through CFFF:000F. You can specify more than one address range by including more than one EMMExclude entry in the SYSTEM.INI file. For more information on the SYSTEM.INI settings, refer to the SYSINI.WRI file in the Windows 3.x installation directory. B.2 Notes or Performing DMA in Windows B.2.1 Windows 3.x and DMA If you are using Master Link with Windows 3.x and need to transfer data between your computer and Intelligent Instrumentation hardware via Direct Memory Access (DMA), you must install a replacement Virtual DMA Device driver. This driver replaces the one that comes with Windows 3.x and allows for pre- and post-trigger data acquisition. To install this driver in your system, copy PCIVDMAD.386 from the distribution disk to your WINDOWS directory. Next, you must edit your SYSTEM.INI file (found in the WINDOWS directory) to force Windows to use the new VDMAD rather than the driver which is built-in. Find the line in SYSTEM.INI that looks like this (you can use the search function of Notepad to do this): device=*vdmad and change it so that the following two lines appear in its place: ; device=*vdmad device=pcivdmad.386 To switch back to the built-in Windows VDMAD, insert a ';' at the start of the second line and remove the ';' from the start of the first line. Save the changes to SYSTEM.INI. The changes will take effect the next time that Windows is started. Note that certain disk management packages (such as PC TOOLS and Norton Desktop for Windows) may install their own VDMAD drivers. To assure that your PCI hardware will have the ability to perform pre- and posttrigger data acquisition, however, you should disable their VDMAD (by placing a ';' at the start of the line in SYSTEM.INI that loads their VDMAD driver) and add the line that activates PCIVDMAD.386. B.2.2 Windows 95 and DMA 16-bit DMA Applications If you are using the Windows 3.x 16-bit Master Link drivers (not the Win32 version) with Windows 95 and need to transfer data between your computer and Intelligent Instrumentation hardware via Direct Memory Access (DMA), you must perform the following steps: 1. Copy VDMAD.VXD from your \PCIMASTR directory to your WINDOWS\SYSTEM\VMM32 directory. 2. Copy MASTRLNK.VXD from your \PCIMASTR directory to your WINDOWS\SYSTEM directory. 3. Remove any reference to PCIVDMAD.386 from the SYSTEM.INI file found in the C:\WINDOWS directory. 4. Add a line similar (i.e. your path might be different) to the following line to the [386Enh] section of your SYSTEM.INI file: B-3 Appendix B: Memory Manager, DMA Device Driver, Initialization Options and Interrupt Notes device=c:\windows\system\mastrlnk.vxd 5. Restart Windows 95. 32-bit DMA Applications The Win32 Master Link installation program will offer to install a Master Link driver and a Virtual DMA device driver when running on Windows 95. In order to access hardware, the Master Link driver option must be selected. In order to use the DMA feature of some hardware, the Virtual DMA device option must be selected as well. B.2.3 Windows NT and DMA The Win32 Master Link installation program will offer to install a Master Link driver (MASTER_NT.SYS) when running on Windows NT. In order to access hardware and perform DMA operations, this option must be selected. After installation of the Windows NT driver, the system must be restarted to complete the driver installation. Note, you cannot run any 16-bit Master Link application under Windows NT, let alone a DMA application. B.3 Initialization Options The following flags have been defined to customize driver initialization. You may use any combination of these flags in your application program. Simply, replace the last parameter of the InitSW function call with the desired flag(s). The InitSW function call is found in the PCIDATAW source file (for Windows) or the PCIDATA source file (for DOS). Note that the default value for the last parameter in the InitSW function call is 0. To use a combination of software initialization options, perform a bitwise OR of the desired flags and pass the result to the InitSW function. SWINIT_NOT_EISA - This flag can be set to inform the drivers that the host computer is not an EISA machine. Certain ISA motherboards (e.g. DTK) use a BIOS that does not fully support the extended functions used by the drivers to determine if the host computer is an EISA machine. As a result, the application program may not work properly or may even crash the computer. If the SWINIT_NOT_EISA flag is set, the drivers will flag the host computer as an ISA machine and will bypass the extended EISA BIOS function calls. Note: This option applies to DOS and Windows 3.x only. SWINIT_NO_INT15_EISA - This flag can be used to inform the drivers not to use int86x (0x15...) to determine whether or not the host computer is an EISA machine. Certain EISA computers (e.g. Compaq DESKPRO XL 590) use a BIOS that does not correctly handle calls to int86x (0x15...). As a result, the application program may not work properly or may even crash the computer during the SWInit() call. If the SWINIT_NO_INT15_EISA flag is set, however, the drivers will use an alternate method to determine whether or not the host computer is an EISA machine. Note: This option applies to DOS and Windows 3.x only. SWINIT_DELAY_AO_INIT - This flag can be used to delay initialization of the output channels on an analog output board. Normally, the drivers output a mid-range count value to all of the analog output channels during HWInit(). If the board is jumpered for bipolar operation, the initial output voltage will be 0 volts for each channel. However, if the board is jumpered for unipolar operation, the initial output voltage will be 2.5V for each channel configured for the 0-5V range and 5V for each channel configured for the 0-10V range. If the SWINIT_DELAY_AO_INIT flag is used, the drivers will delay, or suppress, initialization of the analog output channels until the first AOWrite or AOWriteGroup function call. At that time, all of the analog output channels on a PCI-20021M or PCI-20093W, except for the specified channel, will be initialized to 0 volts regardless of the selected range. For the PCI-20003M, PCI-20006M or PCI-20428W, the initial output value of each channel is determined by a hardware jumper on the board. B-4 Appendix B: Memory Manager, DMA Device Driver, Initialization Options and Interrupt Notes SWINIT_NO_DPMI - This flag can be used to inform the drivers that there is no DPMI server available. Certain integrated development environments (e.g. Turbo C++ 3.0) do not fully support the extended BIOS functions used by the drivers to determine if there is a DPMI server available. As a result, the application program may crash the computer if it is run from inside of the environment. If the SWINIT_NO_DPMI flag is used, the drivers will bypass the extended EISA BIOS function calls used to detect whether or not a DPMI server is available. Note: This option applies to DOS and Windows 3.x only. SWINIT_LOCK_SEGMENTS - This flag can be used to lock the driver dynamic memory allocations in physical memory. Set this flag if your application intends to access the drivers at interrupt time. If the flag is not set, Windows may generate a page fault when a driver function is called at interrupt time. For additional information, see the application note on “Interrupts and Segment Locking” below. B.4 Interrupts and Segment Locking (Windows 3.x only) If you wish to make driver function calls from an interrupt routine (e.g. an Multimedia System callback function), you must ensure that all of the driver data and code segments are locked in physical memory at interrupt time by performing the following steps. 1. Set the SWINIT_LOCK_SEGMENTS flag described above in the “Initialization Options” section. 2. Use the LockSegment() Windows API function to lock the code segment(s) of the target hardware in memory as shown below LockSegment (HIWORD (IncludeXXXX)); where IncludeXXXX can be Include98C, Include31M, IncludeDMA, etc. Note that although we have left it out for clarity, the return value of the LockSegment() function call should be checked to ensure that the lock was successful. 3. Lock the driver utility code segments in memory using SWLock() Master Link function (see the function declaration header file(s) for function syntax). 4. Before the application terminates, unlock the hardware code segments and driver utility code segments from memory using the UnlockSegment() Windows API function and the SWUnlock() Master Link function, respectively (see the function declaration header file(s) for function syntax). B-5 Appendix B: Memory Manager, DMA Device Driver, Initialization Options and Interrupt Notes This page intentionally blank B-6 Index Index 2's complement, 3-8 386MAXTM, B-1 8254 configuration, 3-27 8254 Counter I/O type, 3-28 8254 Counter Reading and Status, 3-27 8254 counter reset-on-read, 3-27 8254 Hardware Retriggerable One-Shot, 3-25 8254 Hardware Triggered Strobe, 3-26 8254 Interrupt on Terminal Count, 3-25 8254 Mode Summary, 3-26 8254 Software Triggered Strobe, 3-26 8254 Square Wave Generator, 3-26 8254-Based Counter Sample Programs, A-4 8254-Based Counters, 3-25 Frequency Measurement, 3-27 Modes, 3-25 Programming Procedures, 3-28 Reading, 3-27 Software gate, 3-25 8254-Based Counters, 4-57 A AICalibrate, 3-9, 3-10 AICalibrate364, 3-9 AICalibrationStatus, 3-9 AIConfigureList, 3-11, 3-14, 3-45 AIRead, 3-8, 3-9, 3-58 AIReadExtended, 3-9, 3-10 Allocating Buffers, 3-12 Analog Input Modules, 3-Boards and Carriers, 3-8 Analog Input Sample Programs, A-1, A-9, A-12 Analog Input, 3-35 DMA Buffers, 3-12 Burst Mode, 3-84 Channel selection, 3-13 Cluster, 3-85 Pacing, 3-11 Repetition Modes, 3-84 Single-shot Mode, 3-85 Summary, 3-13 Throughput, 3-85 Modes of Operation, 3-8 Overrun Errors, 3-15 Programming Procedures DMA, 3-13 Non-DMA, 3-9 Analog Input DMA, 3-10 Analog Input/Output Data Format, 4-4 Analog Output Board PCI-20093W-1, 3-16 Analog Output function calls, 3-16 Analog Output Levels, 3-16 Analog Output Modules, 3-16, 3-18 PCI-20003M-2,4, 3-16 PCI-20006M-2, 3-16 PCI-20021M-1B, 3-16 Analog Output Procedures, 3-16 Analog Output Programming Procedures, 3-16 Analog Output Sample Programs, A-2, A-10, A-13 Analog Output Operations, 3-16 Analog Trigger Module, 3-61 Analog Trigger Sample Program, A-8 Analog Trigger Programming Procedures, 3-61 AOConfigure, 3-16 AOWrite, 3-16 AOWriteGroup, 3-16 auto-zero correction, 3-58 auto-zero correction, 4-21, 4-22, 4-111 B Basic Digital I/O mode, 3-30 Basic Digital I/O Operation, 3-30 BGDisable, 3-18 BGEnable, 3-18 BGSetOptions, 3-18 BUFAllocate, 3-14, 3-41 BUFAttachProcess, 3-14, 3-46 BUFDeallocate, 3-15, 3-42 BUFDecode, 3-15, 3-46 Buffer Allocation, 3-41 Buffer Decoding, 3-42 Buffer Encoding, 3-42 buffer information structure, 3-12, 3-43 Buffer Locations, 3-42 buffer pointer, 3-14, 3-42 Buffer size, 3-14, 3-41 Buffer, 3-38 bufferhandle, 3-14, 3-42 Buffers, 3-12, 3-41 BUFSeek, 3-15, 3-46 Burst Generator as a DMA Pacer, 3-18 Burst Generator I/O type, 3-18 Burst Generator Modes Continuous, 3-18 Single-Shot, 3-18 Sync Start and Stop, 3-18 Burst Generator Sample Programs, A-3 Burst Generator Waveform, 3-18 Burst Generator, 3-18 Programming Procedures, 3-19 Burst Mode, 3-84 Index-1 Index C Call Format, 4-2 Call Parameters, 4-2 Call specifications notes, 4-10 Channel Scanner Analog, 3-11 Channel/Port Parameters, 4-3 Circular Buffer, 3-38, 3-39 CJC, 3-58 cluster size, 3-41 clustercount, 3-12 clustersize, 3-12, 3-14, 3-41, 3-46 Cold-Junction-Compensation, 3-58 common analog data format, 3-8, 3-16, 3-61 Common data segment, 2-3, 2-4, 2-10, 2-11, 2-12, 2-13, 2-19, 2-20, 2-21 Connecting a Trigger Source, 3-38 Connection Pairs, 3-53 Conventional Memory, 3-14, 3-42 Counter I/O type, 3-23 counter reset-on-read, 3-27 counter result format, 3-22 Counter Sample Programs, A-4 Counters 8254-based, 3-25 Divide-by-N Continuous Mode, 3-22 Divide-by-N Mode, 3-22 counts to voltage formula, 4-5 Creating a Buffer, 3-41 also see BUFAllocate, 3-14 CTR8254Disable, 3-25 CTR8254Enable, 3-25 CTR8254Measure, 3-27 CTR8254ReadGroup, 3-27 CTRConfigure, 3-20 CTRDisable, 3-23 CTREnable, 3-22 CTRMeasure, 3-23 CTRRead, 3-22 CTRReadGroup, 3-22 CTRSetOptions, 3-21 Customize driver initialization, B-4 D data cluster, 3-41, 3-85 Data Types, 4-4 Deallocating a buffer, 3-42 deallocating buffers, 3-15 Decoding data, 3-42 Digital I/O handshake mode, 3-30 Digital I/O Operation, 3-30 Digital I/O Programming Procedures, 3-31 Digital I/O, 3-31 Digital Input/Output Sample Programs, A-5, A-11, A14 Index - 2 DIOConfigure, 3-30 DIORead, 3-30 DIOReadBit, 3-30 DIOStatus, 3-31 DIOWrite, 3-31 DIOWriteBit, 3-30 Divide-by-N Trigger, 3-22 Event counting, 3-21 On-board Divide-by-N Latched Mode, 3-22 PCI-20098C Series, 3-20 PCI-20501C Series, 3-20 Programming Procedures, 3-23 Signal Measurement Modes Period, 3-20 Signal Measurement Modes Pulsewidth, 3-21 Variable Duty-Cycle Mode, 3-22 Divider Continuous mode, 3-22 Counter, 3-22 Latched, 3-22 Trigger, 3-22, 3-56 DMA Buffer Swap Sample Program, A-6 DMA channel list, 3-14, 3-41 DMA Data transfer methods, 3-36 DMA output, 3-36 PCI-20041C, 3-36 PCI-20501C, 3-36 PCI-20428W, 3-36 DMA processhandle, 3-13 DMA Basic Information, 3-32 buffer size, 3-46 Channel Selection, 3-44 Controller, 3-32 data format, 3-42 Definition, 3-32 Hardware Notes, 3-32 I/O type combinations, 3-36 I/O Types, 3-33 Pacer, 3-23, 3-28 PCI-20000 Hardware devices, 3-32 Planning, 3-33 Programming Procedures, 3-44 Start/Stop Modes, 3-36 Transfer List, 3-33 Trigger, 3-23, 3-28 Trigger Mode, 3-37 DMAConfigureList, 3-11, 3-14, 3-46 DMAFreeHandle, 3-15 DMAGetHandle, 3-13, 3-44 DMAHugeGetHandle, 3-13, 3-44 DMASetOptions, 3-13, 3-44 DMASetPacer, 3-14, 3-23, 3-45, 3-46, 3-51 DMASetTrigger, 3-14, 3-23, 3-45, 3-46, 3-51 DMAStart, 3-15, 3-46 DMAStatus, 3-15, 3-46 DMAStop, 3-15, 3-46 Index DOS Based Sample Programs, A-1 DOS Based Software Libraries Files, 2-2 E EMM386, B-1 EMMExclude, B-2 Encoding data, 3-42 extended counts to voltage formula, 4-5 Extended Memory Buffer, 3-42 Extended memory driver, 3-1, 3-42 Extended Memory, 3-12, 3-42 Required Drivers, 2-1 external counter clock inversion, 3-21 external counter gate inversion, 3-21 F Frame mode, 3-41 Frequency measurement gatetime, 3-27 Frequency measurement hardware set up, 3-28 Function Call Specifications AICalibrate, 4-14 AICalibrate364, 4-15 AICalibrationStatus, 4-16 AIConfigureList, 4-17 AIRead, 4-20 AIReadExtended, 4-22 AISetTime, 4-23 AOConfigure, 4-27 AOWrite, 4-28 AOWriteGroup, 4-29 BGConfigure, 4-43 BGDisable, 4-45 BGEnable, 4-45 BGSetOptions, 4-45 BUFAllocate, 4-32 BUFAttachProcess, 4-34 BUFDeallocate, 4-36 BUFDecode, 4-37 BUFEncode, 4-38 BUFMoveIn, 4-40 BUFMoveOut, 4-41 BUFSeek, 4-42 CountsToVolts, 4-120 CTR8254Configure, 4-57 CTR8254Disable, 4-59 CTR8254Enable, 4-60 CTR8254Measure, 4-60 CTR8254Read, 4-62 CTR8254ReadGroup, 4-63 CTRConfigure, 4-48 CTRDisable, 4-50 CTREnable, 4-50 CTRMeasure, 4-51 CTRRead, 4-52 CTRReadGroup, 4-52 CTRSetOptions, 4-53 DIOConfigure, 4-65 DIORead, 4-66 DIOReadBit, 4-67 DIOStatus, 4-67 DIOWrite, 4-68 DIOWriteBit, 4-68 DMAConfigureList, 4-71 DMAFreeHandle, 4-77 DMAGetHandle, 4-78 DMAHugeGetHandle, 4-78 DMASetOptions, 4-78 DMASetPacer, 4-79 DMASetTrigger, 4-80 DMAStart, 4-81 DMAStatus, 4-82 DMAStop, 4-83 DMASwap, 4-83 ExtendedCountsToVolts, 4-121 FrequencyToRGCounts, 4-122 HWInit, 4-87 IncludeXXXX, 4-94 RegisterClient, 4-87 RGConfigure, 4-100 RGDisable, 4-103 RGEnable, 4-103 SetOptions364, 4-118 SetOptions377, 4-119 SetOptions98, 4-117 SlotAssign, 4-88 SlotAssignIO, 4-89 SlotInquire, 4-89 SlotSearchEISA, 4-92 SlotSearchIO, 4-93 SlotSearchISA, 4-92 SoftInt, 4-99 SSHReadGroup, 4-24 SWInit, 4-88 SWReset, 4-88 SYNCConfigure, 4-104 TCLinearize, 4-109 TCMeasure, 4-110 TRIGConfigure, 4-113 TRIGDisable, 4-114 TRIGEnable, 4-115 TRIGStatus, 4-115 UnregisterClient, 4-93 VoltsToCounts, 4-122 Function call summary table, 4-7 G General Purpose DMA Sample Programs, A-6 General Purpose DMA Analog Input, 3-35 Index - 3 Index Buffer Allocation, 3-41 Controller, 3-32 Decoding data, 3-42 Direction, 3-33 Encoding data, 3-42 I/O Types, 3-33 Mixed I/O Types, 3-36 Pacers, 3-34 Sources, 3-34 Planning, 3-33 Programming Procedures, 3-44 Sampling Rate, 3-34 Start/Stop Modes, 3-36 Terminal Count Mode, 3-40 Transfer List, 3-33 Trigger Mode, 3-37 Group mode, 3-41 groupAI, 3-14, 3-46 H Handshake Digital I/O Operation, 3-30 Hardware Initialization States, 4-96 Hardware Retriggerable One-Shot, 3-25 Hardware Triggered Strobe, 3-26 Huge DMA processes, 3-42 Huge DMA Sample Program, A-10, A-13 HWInit, 3-4 I M Master Link Software Libraries Configuration Requirements, 1-2 Description, 1-1 DOS Support, 1-2 Win32 Support, 1-2 Windows Support, 1-2 Measuring a period, 3-21 Measuring a pulsewidth, 3-21 Memory Manager Notes, B-1 Memory Managers 386MAX, B-1 EMM386, B-1 preventing remapp, B-1 QEMM, B-2 Windows 3.x applications, B-3 memory-map, 3-6 Microsoft Windows 3.x Based Sample Programs, A-9 Mixed I/O transfer, 3-32 Mixed I/O Types, 3-36 Module ID Code, 3-6 Module Parameter, 4-3 Multiple Channel Acquisition, 3-10 multiple channel analog output, 3-17 Multiple DMA processes, 3-35 O Overrun Errors, 3-15 I/O-map, 3-6 IncludeXXXX, 3-4 Example, 3-5 Initialization flags, B-4 Initialization options, B-4 Initialization Call Sequence, 3-7 Description, 3-4 Functions, 3-4 Hardware, 3-4 InitRoutine, 3-5 Inter-Board SYNC Lines, 3-54 Interrupt on Terminal Count, 3-25 Interrupt Request lines, 3-57 Interrupts and Segment Locking, B-5 Interrupts, 3-47 IRQ lines, 3-57 L License Agreement, 1-3 Local Data Block, 2-13, 2-21 LONG Period Measurement, 3-21 Index - 4 P pacer sources, 3-13 Pacer A/D, 3-11 DMA, 3-34 General, 3-11, 3-34 Using a 8254-Based Counter, 3-28 Using a Counter, 3-23 Using a Rate Generator, 3-51 Using a Burst Generator, 3-18 PC Interrupt Requests, 3-57, B-5 PCI-20001C, 3-30 PCI-20002M, 3-11 PCI-20004M, 3-30 PCI-20007M, 3-1, 3-25, 3-48 PCI-20020M, 3-2, 3-11, 3-13, 3-61 PCI-20041C, 3-30, 3-32, 3-48 PCI-20041C-3A, 3-11 PCI-20087W, 3-30 PCI-20089W, 3-1, 3-25, 3-48 PCI-20091W, 3-1, 3-11, 3-32, 3-48 PCI-20098C, 3-1, 3-4, 3-5, 3-11, 3-30, 3-32 PCI-20341M, 3-84 PCI-20363M-1, 3-8, 3-10 Index PCI-20364M-1, 3-2, 3-10 Function Support, 3-9 PCI-20368M-1, 3-5 PCI-20369S DOS Based Software Libraries Files, 2-2 Windows 3.x Software Libraries Files, 2-10 PCI-20369S Installation DOS, 2-1 Windows 3.x, 2-8 PCI-20377W, 3-1, 3-5, 3-11, 3-25, 3-30, 3-32, 3-48 PCI-20378W, 3-30 PCI-20428W, 3-1, 3-5, 3-25, 3-30, 3-32, 3-48 PCI-20485S Installation , 2-15 Win32 Language Support, 4-1 PCI-20501C, 3-1, 3-11, 3-18, 3-30, 3-32, 3-84 PCI-5B37 Thermocouple Blocks, 3-58 Post-trigger transfers, 3-40 processhandle, 3-14 Programming Procedures, 3-47 8254-Based Counters, 3-28 Analog Input (DMA), 3-13 Analog Input (non-DMA), 3-9 Analog Output, 3-16 Analog Trigger, 3-61 Burst Generator, 3-19 Counters, 3-23 Digital I/O, 3-31 General Purpose DMA, 3-44 Initialization, 3-7 Rate Generator, 3-52 SYNC Bus, 3-57 Thermocouple Measurement, 3-59 pulse mode, 3-48 pulsewidth measurement range, 3-21 Q QEMM, B-2 R Rate Generator Mode, 3-26 Rate Generator Sample Programs, A-6 Rate Generator Definition, 3-48 Modes, 3-48 Output frequency, 3-48 Programming Procedures, 3-52 Software Gate, 3-51 Waveforms, 3-48 Rate Generator, 3-16-bit Output frequency, 3-50 Waveforms, 3-50 Reading all counters (8254), 3-27 Reading all counters (PCI-20501C, 3-PCI-20098C), 324 Repetition Modes, 3-84 RGConfigure, 3-48 S Segment Address Finding, 3-6 SetOptions364, 3-9, 3-10 SetOptions377, 3-27 SHORT Period Measurement, 3-21 Signal Measurement Sample Program, A-4, A-11, A-14 Signal Measurement, 3-20 Simultaneous Sample/Hold Sample Programs, A-7 Single Channel Reading, 3-8, 3-9 Single-shot Mode, 3-85 Slot Assignment, 3-5, 3-6 Slot Inquiry, 3-6 Slot Parameter, 4-3 SlotAssign, 3-5 Example, 3-6 SlotAssignIO, 3-5 SlotInquire, 3-6 SlotSearchEISA, 3-5 SlotSearchIO, 3-6 SlotSearchISA, 3-6 Example, 3-6 SoftInt, 3-47 Software gate jumper, 3-25, 3-51 Software Interrupts, 3-47 Software Libraries Files, DOS C, 2-2 QuickBASIC, 2-4 Turbo Pascal, 2-3 Software Libraries Files, Windows C, 2-11, 2-19 Pascal, 2-12 Visual Basic 2-8, 2-18 Software Libraries DOS Installation, 2-1 Linking, 2-5, 2-13, 2-21 Win32 Installation, 2-15 Windows 3.x Installation, 2-8 Software Triggered Strobe, 3-26 source only types, 3-54 Source/Target Descriptions, 3-54 source/target types, 3-54 sources and targets, 3-53 Specification Structure and Notational Conventions, 410 Square Wave Generator, 3-26 square wave mode, 3-49 SSHReadGroup, 3-8 start and stop modes, 3-11 Starting analog input DMA, 3-15 Stop on Terminal Count, 3-12 Index - 5 Index Stopping analog input DMA, 3-15 SWInit, 3-4 SWReset, 3-4 SYNC Bus Definition, 3-53 Programming Procedures, 3-57 SYNC Source Descriptions, 3-54 SYNCConfigure, 3-11, 3-13, 3-18 Description, 3-53 Supported Hardware, 3-53 System Configuration Summary, 4-6 T Target Descriptions, 3-54, 3-55 target only types, 3-55 TCLinearize, 3-58 TCMeasure, 3-58, 3-59 Thermocouple Measurement Sample Programs, A-7 Thermocouple Measurement Cold-Junction Compensation, 3-58 Function call parameters, 3-58 PCI-5B37 Scaling Equations, 3-59 Programming Procedures, 3-59 Thermocouple Types, 3-58 TRIGConfigure, 3-61 Trigger Mode acquisition, 3-12 Trigger Mode, 3-37 Trigger Module Resolution, 3-61 Trigger Threshold, 3-61 Trigger, 3-11, 3-13, 3-61 PCI-20341M, 3-38 Using a 8254-Based Counter, 3-28 Trigger/Alarm Module, 3-61 TRIGStatus, 3-61 Turbo Pascal Units, 2-5 U Using a Counter as a DMA Pacer or Trigger, 3-23 Utility routines for sample programs, A-1 V Variable Duty-Cycle Generator clock input, 3-22 Variable Duty-Cycle Generator, 3-20, 3-22 VDMAD (Virtual DMA Device Driver), 3-44, B-3 Index - 6 W Win32 Based Sample Programs, A-12 Win32 Based Software Libraries Files, 2-18 Window Comparator, 3-61 Windows 3.x Based Sample Programs, A-9 Windows 3.x Based Software Libraries Files, 2-10 X XMS Buffer, 3-42 XMS bufferhandle, 3-14 XMS Drivers, 2-1 XMSflag, 3-42