NATIONAL INSTRUMENTS NI-DAQ Data Acquisition Software for PC User Guide

June 12, 2024
NATIONAL INSTRUMENTS

NATIONAL INSTRUMENTS NI-DAQ Data Acquisition Software for PC

NATIONAL-INSTRUMENTS-NI-DAQ-Data-Acquisition-Software-for-
PC

Product Information

  • Product Name: SCXI-2000 DAQ
  • Product Description: The SCXI-2000 DAQ is a data acquisition system designed for use with PC compatibles. It is equipped with version 6.9 of the NI-DAQ software, which enables users to acquire and analyze data from various sensors and devices.
  • Manufacturer: National Instruments Corporation
  • Headquarters: 11500 North Mopac Expressway Austin, Texas 78759-3504 USA
  • Contact Number: 512 794 0100
  • Website: ni.com

Product Usage Instructions

  1. Setting up Your DAQ System:
    • Refer to the user manual for detailed instructions on setting up the SCXI-2000 DAQ system.
    • Ensure that the system is compatible with your PC.
    • Install the NI-DAQ software version 6.9 provided with the product.
    • Connect the SCXI-2000 DAQ to your PC using the appropriate cables and connectors.
    • Follow the device configuration steps outlined in the user manual.
  2. Using Measurement & Automation Explorer:
    • Launch the Measurement & Automation Explorer software included with NI-DAQ.
    • Refer to the user manual for instructions on using Measurement & Automation Explorer to configure and control your SCXI-2000 DAQ system.
  3. Building Windows Applications:
    • Refer to the user manual for instructions on using the NI-DAQ libraries to create Windows applications.
    • If using Microsoft Visual C++, follow the provided instructions in the user manual to create a Windows application.

Please note that this is a brief overview of the product usage instructions. For detailed information and specific steps, refer to the NI-DAQ User Manual for PC Compatibles (October 2000 Edition, Part Number 371644A-01).

SCXI-2000

DAQ
NI-DAQTM User Manual for PC Compatibles
Version 6.9 Data Acquisition Software for the PC
NI-DAQ User Manual for PC Compatibles
October 2000 Edition Part Number 371644A-01

Worldwide Technical Support and Product Information ni.com
National Instruments Corporate Headquarters 11500 North Mopac Expressway Austin, Texas 78759-3504 USA Tel: 512 794 0100
Worldwide Offices Australia 03 9879 5166, Austria 0662 45 79 90 0, Belgium 02 757 00 20, Brazil 011 284 5011, Canada (Calgary) 403 274 9391, Canada (Ontario) 905 785 0085, Canada (Québec) 514 694 8521, China 0755 3904939, Denmark 45 76 26 00, Finland 09 725 725 11, France 01 48 14 24 24, Germany 089 741 31 30, Greece 30 1 42 96 427, Hong Kong 2645 3186, India 91805275406, Israel 03 6120092, Italy 02 413091, Japan 03 5472 2970, Korea 02 596 7456, Mexico (D.F.) 5 280 7625, Mexico (Monterrey) 8 357 7695, Netherlands 0348 433466, New Zealand 09 914 0488, Norway 32 27 73 00, Poland 0 22 528 94 06, Portugal 351 1 726 9011, Singapore 2265886, Spain 91 640 0085, Sweden 08 587 895 00, Switzerland 056 200 51 51, Taiwan 02 2528 7227, United Kingdom 01635 523545
For further support information, see the Technical Support Resources appendix. To comment on the documentation, send e-mail to techpubs@ni.com
© Copyright 1991, 2000 National Instruments Corporation. All rights reserved.

Important Information

Warranty
The media on which you receive National Instruments software are warranted not to fail to execute programming instructions, due to defects in materials and workmanship, for a period of 90 days from date of shipment, as evidenced by receipts or other documentation. National Instruments will, at its option, repair or replace software media that do not execute programming instructions if National Instruments receives notice of such defects during the warranty period. National Instruments does not warrant that the operation of the software shall be uninterrupted or error free.
A Return Material Authorization (RMA) number must be obtained from the factory and clearly marked on the outside of the package before any equipment will be accepted for warranty work. National Instruments will pay the shipping costs of returning to the owner parts which are covered by warranty.
National Instruments believes that the information in this document is accurate. The document has been carefully reviewed for technical accuracy. In the event that technical or typographical errors exist, National Instruments reserves the right to make changes to subsequent editions of this document without prior notice to holders of this edition. The reader should consult National Instruments if errors are suspected. In no event shall National Instruments be liable for any damages arising out of or related to this document or the information contained in it.
EXCEPT AS SPECIFIED HEREIN, NATIONAL INSTRUMENTS MAKES NO WARRANTIES, EXPRESS OR IMPLIED, AND SPECIFICALLY DISCLAIMS ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. CUSTOMER’S RIGHT TO RECOVER DAMAGES CAUSED BY FAULT OR NEGLIGENCE ON THE PART OF NATIONAL INSTRUMENTS SHALL BE LIMITED TO THE AMOUNT THERETOFORE PAID BY THE CUSTOMER. NATIONAL INSTRUMENTS WILL NOT BE LIABLE FOR DAMAGES RESULTING FROM LOSS OF DATA, PROFITS, USE OF PRODUCTS, OR INCIDENTAL OR CONSEQUENTIAL DAMAGES, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. This limitation of the liability of National Instruments will apply regardless of the form of action, whether in contract or tort, including negligence. Any action against National Instruments must be brought within one year after the cause of action accrues. National Instruments shall not be liable for any delay in performance due to causes beyond its reasonable control. The warranty provided herein does not cover damages, defects, malfunctions, or service failures caused by owner’s failure to follow the National Instruments installation, operation, or maintenance instructions; owner’s modification of the product; owner’s abuse, misuse, or negligent acts; and power failure or surges, fire, flood, accident, actions of third parties, or other events outside reasonable control.

Copyright
Under the copyright laws, this publication may not be reproduced or transmitted in any form, electronic or mechanical, including photocopying, recording, storing in an information retrieval system, or translating, in whole or in part, without the prior written consent of National Instruments Corporation.

Trademarks
ComponentWorksTM, CVITM, DAQCardTM, DAQ DesignerTM, DAQPadTM, DAQ-PnPTM, DAQ- STCTM, LabVIEWTM, National InstrumentsTM, ni.comTM, NI-DAQTM, PXITM, RTSITM, SCXITM, and VirtualBenchTM are trademarks of National Instruments Corporation.
Product and company names mentioned herein are trademarks or trade names of their respective companies.
WARNING REGARDING USE OF NATIONAL INSTRUMENTS PRODUCTS
(1) NATIONAL INSTRUMENTS PRODUCTS ARE NOT DESIGNED WITH COMPONENTS AND TESTING FOR A LEVEL OF RELIABILITY SUITABLE FOR USE IN OR IN CONNECTION WITH SURGICAL IMPLANTS OR AS CRITICAL COMPONENTS IN ANY LIFE SUPPORT SYSTEMS WHOSE FAILURE TO PERFORM CAN REASONABLY BE EXPECTED TO CAUSE SIGNIFICANT INJURY TO A HUMAN.
(2) IN ANY APPLICATION, INCLUDING THE ABOVE, RELIABILITY OF OPERATION OF THE SOFTWARE PRODUCTS CAN BE IMPAIRED BY ADVERSE FACTORS, INCLUDING BUT NOT LIMITED TO FLUCTUATIONS IN ELECTRICAL POWER SUPPLY, COMPUTER HARDWARE MALFUNCTIONS, COMPUTER OPERATING SYSTEM SOFTWARE FITNESS, FITNESS OF COMPILERS AND DEVELOPMENT SOFTWARE USED TO DEVELOP AN APPLICATION, INSTALLATION ERRORS, SOFTWARE AND HARDWARE COMPATIBILITY PROBLEMS, MALFUNCTIONS OR FAILURES OF ELECTRONIC MONITORING OR CONTROL DEVICES, TRANSIENT FAILURES OF ELECTRONIC SYSTEMS (HARDWARE AND/OR SOFTWARE), UNANTICIPATED USES OR MISUSES, OR ERRORS ON THE PART OF THE USER OR APPLICATIONS DESIGNER (ADVERSE FACTORS SUCH AS THESE ARE HEREAFTER COLLECTIVELY TERMED “SYSTEM FAILURES”). ANY APPLICATION WHERE A SYSTEM FAILURE WOULD CREATE A RISK OF HARM TO PROPERTY OR PERSONS (INCLUDING THE RISK OF BODILY INJURY AND DEATH) SHOULD NOT BE RELIANT SOLELY UPON ONE FORM OF ELECTRONIC SYSTEM DUE TO THE RISK OF SYSTEM FAILURE. TO AVOID DAMAGE, INJURY, OR DEATH, THE USER OR APPLICATION DESIGNER MUST TAKE REASONABLY PRUDENT STEPS TO PROTECT AGAINST SYSTEM FAILURES, INCLUDING BUT NOT LIMITED TO BACK-UP OR SHUT DOWN MECHANISMS. BECAUSE EACH END-USER SYSTEM IS CUSTOMIZED AND DIFFERS FROM NATIONAL INSTRUMENTS’ TESTING PLATFORMS AND BECAUSE A USER OR APPLICATION DESIGNER MAY USE NATIONAL INSTRUMENTS PRODUCTS IN COMBINATION WITH OTHER PRODUCTS IN A MANNER NOT EVALUATED OR CONTEMPLATED BY NATIONAL INSTRUMENTS, THE USER OR APPLICATION DESIGNER IS ULTIMATELY RESPONSIBLE FOR VERIFYING AND VALIDATING THE SUITABILITY OF NATIONAL INSTRUMENTS PRODUCTS WHENEVER NATIONAL INSTRUMENTS PRODUCTS ARE INCORPORATED IN A SYSTEM OR APPLICATION, INCLUDING, WITHOUT LIMITATION, THE APPROPRIATE DESIGN, PROCESS AND SAFETY LEVEL OF SUCH SYSTEM OR APPLICATION.

Appendix A Technical Support Resources
Glossary
Index

NI-DAQ User Manual for PC Compatibles

viii

ni.com

About This Manual

The NI-DAQ User Manual for PC Compatibles is for users of the NI-DAQ software for PC compatibles version 6.9. NI-DAQ software is a powerful application programming interface (API) between your data acquisition (DAQ) application and the National Instruments DAQ devices. Source code for several example applications is included in this manual.

How to Use the NI-DAQ Documentation Set

Begin by reading the NI-DAQ release notes and this manual. Chapter 1, Introduction to NI-DAQ, contains a flowchart that illustrates how to set up your DAQ system using either NI-DAQ or other National Instruments application software.
When you are familiar with the material in this manual, you can begin to use the NI-DAQ Function Reference Online Help file, Nidaqpc.hlp, the Windows help file that contains detailed descriptions of the NI-DAQ functions. Other documentation includes the DAQ Hardware Overview Guide, and the DAQ provider help contained in Measurement & Automation Explorer.
For detailed hardware information, refer to the user manual included with each device.

Conventions Used in This Manual

»
1102/B/C modules 12-bit device

The following conventions are used in this manual.
The » symbol leads you through nested menu items and dialog box options to a final action. The sequence File»Page Setup»Options directs you to pull down the File menu, select the Page Setup item, and select Options from the last dialog box.
This icon denotes a note, which alerts you to important information.
Refers to the SCXI-1102, SCXI-1102B, and SCXI-1102C modules and the VXI- SC-1102, VXI-SC-1102B, and VXI-SC-1102C submodules.
These MIO and AI devices are listed in Table 1.

© National Instruments Corporation

ix

NI-DAQ User Manual for PC Compatibles

About This Manual

1200 and 1200AI device Refers to the DAQCard-1200, DAQPad-1200, Lab-PC-1200, Lab-PC-1200AI, PCI-1200, and SCXI-1200.

1394

Refers to a high-speed external bus that implements the IEEE 1394 serial bus protocol.

16-bit device

These MIO and AI devices are listed in Table 1.

44XX device

Refers to the NI 4451 for PCI, NI 4452 for PCI, NI 4454 for PCI, and NI 4472 for PXI/CompactPCI.

45XX device

Refers to the NI 4551 for PCI and NI 4552 for PCI.

516 device

Refers to the DAQCard-516 and PC-516.

6025E device

Refers to the PCI-6025E and PXI-6025E.

6052E device

Refers to the PCI-6052E, PXI-6052E, DAQPad-6052E for1394, and DAQPad-6052E for USB.

6053E device

Refers to the PCI-6053E and PXI-6053E.

61XX device

Refers to the PCI-6110, PCI-6111, PCI-6115, PXI-6115, PCI-6120, and PXI-6120.

622X device

Refers to the NI-6222 for PCI, NI-6222 for PXI, and NI-6224 for Ethernet.

652X device

Refers to the PCI-6527 and PXI-6527.

653X device

Refers to the AT-DIO-32HS, PCI-DIO-32HS, DAQCard-6533, PXI-6533, PCI-6534, and PXI-6534.

660X device

Refers to the DAQCard-6601, PCI-6601, PCI-6602, PXI-6602, PCI-6608, and PXI-6608.

6602 device

Refers to the PCI-6602 and PXI-6602.

671X device

Refers to the DAQCard-6715, PCI-6711, PXI-6711, PCI-6713, and PXI-6713.

AI device

These analog input devices are listed in Table 1.

bold

Bold text denotes items that you must select or click on in the software,

such as menu items and dialog box options. Bold text also denotes

parameter names and function prototypes.

DAQCard-500/700

Refers to the DAQCard-500 and DAQCard-700.

NI-DAQ User Manual for PC Compatibles

x

ni.com

About This Manual

DIO device DIO-24 DIO-32F DIO-96 DSA device
E Series device italic
Lab and 1200 analog output device Lab and 1200 device LPM device MIO device MIO-16XE-50 device MIO-64 monospace
monospace bold

Refers to any DIO-24, DIO-32, DIO-6533, or DIO-96.
Refers to the PC-DIO-24, PC-DIO-24PnP, DAQCard-DIO-24, PCI-6503.
Refers to the AT-DIO-32F.
Refers to the PC-DIO-96, PC-DIO-96PnP, PCI-DIO-96, DAQPad-6507, DAQPad-6508, and PXI-6508.
Refers to the NI 4451 for PCI, NI 4452 for PCI, NI 4454 for PCI, NI 4551 for PCI, NI 4552 for PCI, and NI 4472 for PXI/CompactPCI dynamic signal acquisition devices.
These are MIO and AI devices. Refer to Table 1 for a complete list of these devices.
Italic text denotes variables, emphasis, a cross reference, or an introduction to a key concept. This font also denotes text that is a placeholder for a word or value that you must supply.
Refers to the DAQCard-1200, DAQPad-1200, Lab-PC+, Lab-PC-1200, PCI-1200, and SCXI-1200.
Refers to the DAQCard-1200, DAQPad-1200, Lab-PC+, Lab-PC-1200, Lab-PC-1200AI, PCI-1200, and SCXI-1200.
Refers to the PC-LPM-16 and PC-LPM-16PnP.
Refers to multifunction I/O devices. See Table 1 for a list of these devices.
Refers to the AT-MIO-16XE-50, DAQPad-MIO-16XE-50, and NEC-MIO-16XE-50, and PCI-MIO-16XE-50.
Refers to the AT-MIO-64E-3, PCI-6031E, PCI-6071E, VXI-MIO-64E-1, and VXI-MIO- 64XE-10.
Text in this font denotes text or characters that you should enter from the keyboard, sections of code, programming examples, and syntax examples. This font is also used for the proper names of disk drives, paths, directories, programs, subprograms, subroutines, device names, functions, operations, properties, methods, variables, filenames and extensions, and code excerpts.
Bold text in this font denotes the messages and responses that the computer automatically prints to the screen. This font also emphasizes lines of code that are different from the other examples.

© National Instruments Corporation

xi

NI-DAQ User Manual for PC Compatibles

About This Manual

monospace italic

Italic text in this font denotes text that is a placeholder for a word or value that you must supply.

NI-DAQ

Refers to the NI-DAQ software for PC compatibles, unless otherwise noted.

NI-TIO based device

Refers to the NI 4551, NI 4552, DAQCard-6601, PCI-6601, PCI-6602, PXI-6602, PCI-6608, PXI-6608.

PC

Refers to the IBM PC/XT, IBM PC AT, and compatible computers.

PCI Series

Refers to the National Instruments products that use the high-performance expansion bus architecture originally developed by Intel.

PXI

Refers to PCI eXtensions for Instrumentation, derived from the

CompactPCI standard.

remote SCXI

Refers to an SCXI configuration where either an SCXI-2000 chassis or an SCXI-2400 remote communications module is connected to the PC serial port.

SCXI-1102/B/C

SCXI-1102/B/C refers to the SCXI-1102, SCXI-1102B, and SCXI-1102C.

SCXI-1120/D

SCXI-1120/D refers to the SCXI-1120 and SCXI-1120D.

SCXI-1104/C

SCXI-1104/C refers to the SCXI-1104 and SCXI-1104C.

SCXI analog input module

Refers to the SCXI-1100, SCXI-1101, SCXI-1102, SCXI-1104,SCXI-1104C, SCXI-1112, SCXI-1120, SCXI-1120D, SCXI-1121, SCXI-1122, SCXI-1125, SCXI-1140, SCXI-1141, SCXI-1142, SCXI-1143, and SCXI-1520.

SCXI analog output module

Refers to the SCXI-1124 module.

SCXI chassis

Refers to the SCXI-1000, SCXI-1000DC, SCXI-1001, and SCXI-2000.

SCXI digital module

Refers to the SCXI-1160, SCXI-1161, SCXI-1162, SCXI-1162HV, SCXI-1163, and SCXI-1163R.

SCXI switch module Refers to the SCXI-1190, SCXI-1191, SCXI-1127, and SCXI-1128.

simultaneous sampling device

Refers to the PCI-6110, PCI-6111, PCI-6115, PXI-6115, PCI-6120, PXI-6120, NI 4451 for PCI, NI 4452 for PCI, NI 4454 for PCI, NI 4551 for PCI, NI 4552 for PCI, and NI 4472 for PXI/CompactPCI.

NI-DAQ User Manual for PC Compatibles

xii

ni.com

About This Manual

track-and-hold module
VXI-MIO device
VXI-SC-1102/B/C

Refers to the SCXI-1140, SCXI-1520, SCXI-1530, and SCXI-1531.
Refers to the VXI-MIO-64E-1 and VXI-MIO-64XE-10. Refers to the VXI-SC-1102, VXI-SC-1102B, and VXI-SC-1102C.

MIO and AI Device Terminology
This manual uses generic terms to describe groups of devices whenever possible. The generic terms for the MIO and AI devices are based on the number of bits, the platform, and the functionality. These devices are also collectively known as E Series devices. The following table lists each MIO and AI device and the possible classifications for each.

Table 1. MIO and AI Device Classifications

Device AT-AI-16XE-10 AT-MIO-16DE-10 AT-MIO-16E-1 AT-MIO-16E-2 AT-MIO-16E-10 AT-MIO-16F-5 AT-MIO-16XE-10 AT-MIO-16XE-50 AT-MIO-64E-3 DAQCard-6023E DAQCard- 6024E DAQCard-6062E DAQCard-AI-16E-4 DAQCard-AI-16XE-50 DAQPad-MIO-16XE-50 DAQPad-6020E DAQPad-6052E for 1394 DAQPad-6052E for USB

Number of SE Channels 16 16 16 16 16 16 16 16 64 16 16 16 16 16 16 16 16 16

Bit 16-bit 12-bit 12-bit 12-bit 12-bit 12-bit 16-bit 16-bit 12-bit 12-bit 12-bit 12-bit 12-bit 16-bit 16-bit 12-bit 16-bit 16-bit

Type AT AT AT AT AT AT AT AT AT PCMCIA PCMCIA PCMCIA PCMCIA PCMCIA Parallel Port USB 1394 USB

Functionality AI MIO MIO MIO MIO MIO MIO MIO MIO AI MIO MIO AI AI MIO MIO MIO MIO

© National Instruments Corporation

xiii

NI-DAQ User Manual for PC Compatibles

About This Manual

Table 1. MIO and AI Device Classifications (Continued)

Device DAQPad-6070E NEC-AI-16E-4 NEC-AI-16XE-50 NEC-MIO-16E-4 NEC-MIO-16XE-50 NI 6222 for PCI NI 6222 for PXI NI 6224 for Ethernet PCI-6023E PCI-6024E PCI- 6025E PCI-6031E (MIO-64XE-10) PCI-6032E (AI-16XE-10) PCI-6033E (AI-64XE-10) PCI-6034E PCI-6035E PCI-6052E PCI-6053E PCI-6071E (MIO-64E-1) PCI-6110 PCI-6111 PCI-6115 PCI-6120 PCI-MIO-16E-1 PCI-MIO-16E-4 PCI-MIO-16XE-10 PCI- MIO-16XE-50 PXI-6011E

Number of SE Channels 16 16 16 16 16 24 24 56 16 16 16 64 16 64 16 16 16 64 64
4, DIFF only 2, DIFF only 4, DIFF only 4, DIFF only
16 16 16 16 16

Bit 12-bit 12-bit 16-bit 12-bit 16-bit AI, 16-bit AI, 12-bit AO 16-bit AI, 12-bit AO 16-bit AI, 12-bit AO 12-bit 12-bit 12-bit 16-bit 16-bit 16-bit 16-bit 16-bit AI, 12-bit AO 16-bit 16-bit 12-bit 12-bit AI, 16-bit AO 12-bit AI, 16-bit AO 12-bit 16-bit 12-bit 12-bit 16-bit 16-bit 16-bit

Type 1394 NEC NEC NEC NEC PCI PXI Ethernet PCI PCI PCI PCI PCI PCI PCI PCI PCI PCI PCI PCI PCI PCI PCI PCI PCI PCI PCI PXI

Functionality MIO AI AI MIO MIO MIO MIO MIO AI MIO MIO MIO AI AI AI MIO MIO MIO MIO MIO MIO MIO MIO MIO MIO MIO MIO MIO

NI-DAQ User Manual for PC Compatibles

xiv

ni.com

Device PXI-6023E PXI-6024E PXI-6025E PXI-6030E PXI-6031E PXI-6034E PXI-6035E PXI-6040E PXI-6052E PXI-6053E PXI-6070E PXI-6115 PXI-6120 VXI-MIO-64E-1 VXI- MIO-64XE-10

About This Manual

Table 1. MIO and AI Device Classifications (Continued)

Number of SE Channels 16 16 16 16 64 16 16 16 16 64 16
4, DIFF only 4, DIFF only
64 64

Bit 12-bit 12-bit 12-bit 16-bit 16-bit 16-bit 16-bit AI, 12-bit AO 12-bit 16-bit 16-bit 12-bit 12-bit 16-bit 12-bit 16-bit

Type PXI PXI PXI PXI PXI PXI PXI PXI PXI PXI PXI PXI PXI VXI VXI

Functionality AI MIO MIO MIO MIO AI MIO MIO MIO MIO MIO MIO MIO MIO MIO

© National Instruments Corporation

xv

NI-DAQ User Manual for PC Compatibles

Introduction to NI-DAQ

This chapter describes how to set up your DAQ system and configure your DAQ devices.
About the NI-DAQ Software for PC Compatibles
Thank you for buying a National Instruments DAQ device, which includes NI-DAQ software for PC compatibles. NI-DAQ is a set of functions that control all of the National Instruments plug-in DAQ devices for analog I/O, digital I/O, timing I/O, SCXI signal conditioning, and RTSI multiboard synchronization.
NI-DAQ has both high-level DAQ I/O functions for maximum ease of use, and low- level DAQ I/O functions for maximum flexibility and performance. Examples of high-level functions are streaming data to disk or acquiring a certain number of data points. Examples of low-level functions are writing directly to the DAQ device registers or calibrating the analog inputs. NI-DAQ does not sacrifice the performance of National Instruments DAQ devices because it lets multiple devices operate at their peak performance.
NI-DAQ includes a Buffer and Data Manager that uses sophisticated techniques for handling and managing data acquisition buffers so that you can acquire and process data simultaneously. NI-DAQ can transfer data using DMA, interrupts, or software polling. NI-DAQ can use DMA to transfer data into memory above 16 MB even on ISA bus computers.
With the NI-DAQ Resource Manager, you can use several functions and several devices simultaneously. The Resource Manager prevents multiboard contention over DMA channels, interrupt levels, and RTSI channels.

© National Instruments Corporation

1-1

NI-DAQ User Manual for PC Compatibles

Chapter 1 Introduction to NI-DAQ
NI-DAQ can send event-driven messages to Windows or Windows NT applications each time a user-specified event occurs. Thus, polling is eliminated and you can develop event-driven DAQ applications. Some examples of NI-DAQ user events are: · When a specified number of analog samples has been acquired · When the analog level and slope of a signal match specified levels · When the signal is inside or outside a voltage band · When a specified digital I/O pattern is matched · When a rising or falling edge occurred on a timing I/O line
How to Set Up Your DAQ System
After you have installed your software and hardware and configured your hardware, see Figure 1-1 to begin using NI-DAQ in your application programs.
If you are accessing the NI-DAQ device drivers through LabVIEW, read the NI- DAQ release notes and then use your LabVIEW Online Reference to help you get started using the data acquisition VIs in LabVIEW.

NI-DAQ User Manual for PC Compatibles

1-2

ni.com

Chapter 1 Introduction to NI-DAQ

Install your software and hardware according to the instructions in the DAQ Quick Start Guide and, if appicable, the SCXI Quick Start Guide.

Yes Are you using LabVIEW?

No

Read the LabVIEW Measurements Manual. You no longer need the NI-DAQ document set.

Are you using NI-DAQ Functions in your application (LabWindows/CVI, Microsoft Visual C++,
Microsoft Visual Basic, or Borland C++)?
Yes

No
Read the documentation appropriate for your application software, such as VirtualBench, ComponentWorks, and Measure. You no longer
need the NI-DAQ document set.

Read the sections of Chapter 2, Fundamentals of Building Windows Applications, in this manual that apply to your application development environment.

Read the appropriate chapters in the DAQ Hardware Overview Guide, an online- only PDF document.
Read the sections in Chapter 3, Software Overview, in this manual that apply to the NI-DAQ function groups you will use in your application. Chapter 3 contains
valuable NI-DAQ concepts, including flowcharts for NI-DAQ applications.

Look at the internally documented example source code on your distribution media for your application language and environment.

Use the the NI-DAQ Function Reference Online Help file for specific information about individual NI-DAQ functions.

NI-DAQ Overview

Figure 1-1. How to Set up Your DAQ System

NI-DAQ is a library of routines that work with National Instruments DAQ devices. NI-DAQ helps you overcome difficulties ranging from simple device initialization to advanced high-speed data logging. The number of services you need for your applications depends on the types of DAQ devices you have and the complexity of your applications.

© National Instruments Corporation

1-3

NI-DAQ User Manual for PC Compatibles

Chapter 1 Introduction to NI-DAQ

NI-DAQ Hardware Support
National Instruments periodically upgrades NI-DAQ to add support for new DAQ hardware. To ensure that this version of NI-DAQ supports your hardware, consult Tables 1-1 through 1-5.

Table 1-1. NI-DAQ Version 6.9 Plug-in Device Support for AT, PC, and NEC Buses

AT AT-AI-16XE-10 AT-AO-6/10 AT-DIO-32F AT-MIO-16DE-10 AT-MIO-16E-1 AT-MIO- 16E-2 AT-MIO-16E-10 AT-MIO-16XE-10 AT-MIO-16XE-50 AT-MIO-64E-3 AT-DIO-32HS

PC

Lab-PC+

PC-DIO-96

Lab-PC-1200

PC-DIO-96PnP

Lab-PC-1200AI PC-LPM-16

PC-516

PC-LPM-16PnP

PC-AO-2DC

PC-OPDIO-16

PC-DIO-24

PC-TIO-10

PC-DIO-24PnP

NEC NEC-AI-16E-4 NEC-AI-16XE-50 NEC-MIO-16E-4 NEC-MIO-16XE-50

Table 1-2. NI-DAQ Version 6.9 Plug-in Device Support for PCI Buses

NI 4451 for PCI NI 4452 for PCI NI 4454 for PCI NI 4551 for PCI NI 4552 for PCI NI 6222 for PCI PCI-MIO-16E-1 PCI-MIO-16E-4 PCI-MIO-16XE-10 PCI-6034E PCI- 6035E PCI-MIO-16XE-50 PCI-DIO-32HS

PCI PCI-DIO-96 PCI-1200 PCI-6023E PCI-6024E PCI-6025E PCI-6031E (MIO-64XE-10) PCI-6032E (AI-16XE-10) PCI-6033E (AI-64XE-10) PCI-6052E PCI-6071E (MIO-64E-1) PCI-6110 PCI-6111

PCI-6115 PCI-6120 PCI-6503 PCI-6527 PCI-6534 PCI-6602 PCI-6608 PCI-6703 PCI-6704 PCI-6711 PCI-6713 PCI-4452

NI-DAQ User Manual for PC Compatibles

1-4

ni.com

Chapter 1 Introduction to NI-DAQ

Table 1-3. NI-DAQ Version 6.9 Plug-in Device Support for PXI Buses

NI 4472 for PXI/CompactPCI NI 6222 for PXI PXI-6023E PXI-6024E PXI-6025E PXI- 6030E PXI-6031E PXI-6034E

PXI PXI-6035E PXI-6040E PXI-6052E PXI-6070E PXI-6071E PXI-6115 PXI-6120 PXI-6508

PXI-6527 PXI-6533 PXI-6534 PXI-6602 PXI-6608 PXI-6703 PXI-6704

Table 1-4. NI-DAQ Version 6.9 Plug-in Device Support for PC Card, CardBus, and VXI Buses

PC Card

CardBus

DAQCard-500

DAQCard-6533

DAQCard-6601

DAQCard-516

DAQCard-6715

DAQCard-6533

DAQCard-700

DAQCard-AI-16E-4

DAQCard-1200 DAQCard-AI-16XE-50

DAQCard-6023E DAQCard-AO-2DC

DAQCard-6024E DAQCard-DIO-24

DAQCard-6062E

VXI VXI-MIO-64E-1 VXI-MIO-64XE-10 VXI-DIO-128 VXI-AO-48XDC

© National Instruments Corporation

1-5

NI-DAQ User Manual for PC Compatibles

Chapter 1 Introduction to NI-DAQ

Table 1-5. NI-DAQ Version 6.9 External Device Support for SCXI and USB Devices

SCXI

USB2

PXI-1010

SCXI-1120D

SCXI-12001

DAQPad-6507

PXI-1011

SCXI-1121

SCXI-1520

DAQPad-6508

SCXI-1000

SCXI-1122

SCXI-1530

DAQPad-6020E

SCXI-1000DC SCXI-1124

SCXI-1531

DAQPad-6052E for USB

SCXI-1001

SCXI-1125

SCXI-1540

SCXI-1010

SCXI-1126

SCXI-2000

SCXI-1011

SCXI-1140

SCXI-2400

SCXI-1100

SCXI-1141

SCXI-1122

SCXI-1101

SCXI-1142

VXI-SC-1000

SCXI-1102

SCXI-1143

VXI-SC-1102

SCXI-1102B

SCXI-1160

VXI-SC-1102B

SCXI-1102C

SCXI-1161

VXI-SC-1102C

SCXI-1104

SCXI-1162

VXI-SC-1150

SCXI-1104C

SCXI-1162HV

SCXI-1112

SCXI-1163

SCXI-1120

SCXI-1163R

1 This device works with NEC PC-9800 computers only when used with remote SCXI. 2 These devices do not work with NEC PC-9800 computers.

Table 1-6. NI-DAQ Version 6.9 External Device Support for Parallel Port, 1394, and Other Devices

Parallel Port2 DAQPad-1200 DAQPad-MIO-16XE-50

1394 DAQPad-6052E for 1394 DAQPad-6070E

Other Devices AMUX-64T SC-2040 SC-2042-RTD SC-2043-SG SC-2345 NI 6224 for Ethernet

Throughout this manual, many of the devices are grouped into categories that are similar in functionality. The categories are often used in the text to avoid long lists of specific devices. The Conventions Used in This Manual section of About This Manual lists the devices in each functional type. Any device not included in a category will be referred to by its name.

NI-DAQ User Manual for PC Compatibles

1-6

ni.com

Chapter 1 Introduction to NI-DAQ
NI-DAQ Language Support
NI-DAQ supplies header files, examples, and instructions on how to use an Integrated Development Environment (IDE) for one of the following languages under Windows 2000/NT/98/95: · Microsoft Visual C++ 4.X, 5.0, or 6.0 · Visual Basic 4.0 (32-bit), 5.0, or 6.0 · Borland C++ 5.X
NI-DAQ also provides an NI-DAQ function prototype file for use with Borland Delphi 2 (32-bit), 3, and 4.
Most of the files on the release media are compressed. Always run the NI-DAQ installation utilities to extract the files you want. For a brief description of the directories produced by the install programs and the names and purposes of the uncompressed files, consult the NI-DAQ Readme File (Start»Programs»National Instruments DAQ»NI-DAQ Readme File).
Device Configuration
Before you begin your NI-DAQ application development, you must configure your National Instruments DAQ devices, which can be plug-in devices, PC cards (PCMCIA), or external devices you connect to the parallel port of your computer. NI-DAQ needs the device configuration information to program your hardware properly.
Using Measurement & Automation Explorer
Measurement & Automation Explorer is a Windows-based application that you use to configure and view National Instruments DAQ device settings under Windows 2000/NT/98/95.
Note To use Measurement & Automation Explorer, quit any applications that are performing DAQ operations.
Double-click the Measurement & Automation icon on your desktop to run Measurement & Automation Explorer. Refer to the Measurement & Automation Explorer online help for more information and detailed instructions.

© National Instruments Corporation

1-7

NI-DAQ User Manual for PC Compatibles

2
Fundamentals of Building Windows Applications
This chapter describes the fundamentals of creating NI-DAQ applications in Windows 2000/NT/98/95.
The following section contains general information about building NI-DAQ applications, describes the nature of the NI-DAQ files used in building NI-DAQ applications, and explains the basics of making applications using the following tools: · Borland C++ for Windows · Microsoft Visual C++ · Microsoft Visual Basic
If you are not using the tools listed, consult your development tool reference manual for details on creating applications that call DLLs.
The NI-DAQ Libraries
The NI-DAQ for Windows function libraries are DLLs, which means that NI-DAQ routines are not linked into the executable files of applications. Only the information about the NI-DAQ routines in the NI-DAQ import libraries is stored in the executable files.
Note Use the 32-bit nidaq32.dll. If you are programming in C or C++, link in the appropriate import library. See the following sections for language- specific details.
Using function prototypes is a good programming practice. That is why NI-DAQ is packaged with function prototype files for different Windows development tools. The installation utility copies the appropriate prototype files for the development tools you choose. If you are not using any of the development tools that NI-DAQ works with, you must create your own function prototype file.

© National Instruments Corporation

2-1

NI-DAQ User Manual for PC Compatibles

Chapter 2 Fundamentals of Building Windows Applications
Creating a Windows Application Using Microsoft Visual C++
This section assumes that you will be using the Microsoft Visual C++ Integrated Development Environment (IDE) to manage your code development, and that you are familiar with the IDE.
Developing an NI-DAQ Application
To develop an NI-DAQ application, follow these general steps: 1. Open an existing or new Visual C++ project to manage your
application code. 2. Create files of type .c (C source code) or .cpp (C++ source code)
and add them to the project. Make sure you include the NI-DAQ header file, nidaq.h, as such in your source code files: #include “nidaq.h” You may also want to include nidaqcns.h and nidaqerr.h. Optionally, you can include other files (for example, .rc, .def) that you have created for graphical user interface (GUI) applications. 3. Specify the directory which contains the NI- DAQ header files under the preprocessor»include directory settings in your compiler. (For Visual C++ 4.X, this is under Build»Settings»C/C++. For Visual C++ 5.0/6.0, this is under Project»Settings»C/C++.) The NI-DAQ header files are located in the .Include directory under your NI-DAQ directory. 4. Add the NI-DAQ import library nidaq32.lib to the project. The NI-DAQ import library files are located in the .Lib directory under your NI-DAQ directory. 5. Build your application.
Example Programs
You can find some example programs and project files in .ExamplesVisualC directory under your NI-DAQ directory.
To load an example program, use one of the generic makefiles with the.mak extension.
To load an example project with Visual C++ 4.X or later, select the menu option File»Open Project Workspace, and select List Files of Type to be Makefiles. Then select the.mak file of your choice.

NI-DAQ User Manual for PC Compatibles

2-2

ni.com

Chapter 2 Fundamentals of Building Windows Applications
Refer to the NI-DAQ Examples Help (Start»Programs»National Instruments DAQ»NI- DAQ Examples Help) for additional information regarding NI-DAQ examples.
Special Considerations Buffer Allocation
To allocate memory, you can use the Windows API function GlobalAlloc(). After allocation, lock memory with GlobalLock() to use a buffer of memory. You can use the memory handle returned by GlobalLock()in place of the buffer parameter in NI-DAQ API functions that accept buffers (Align_DMA_Buffer, DAQ_DB_Transfer, DAQ_Monitor, DAQ_Op, DAQ_Start, DIG_Block_In, DIG_Block_Out, DIG_DB_Transfer, GPCTR_Config_Buffer, GPCTR_Read_Buffer, Lab_ISCAN_Op, Lab_ISCAN_Start, SCAN_Op, SCAN_Start, SCAN_Sequence_Demux, WFM_DB_Transfer, WFM_Load, WFM_Op). After using the memory, unlock memory with GlobalUnlock() and free it with GlobalFree().
Note If you allocate memory from GlobalAlloc(), you must call GlobalLock() on the memory object before passing it to NI-DAQ.
String Passing
To pass strings, pass a pointer to the first element of the character array. Be sure that the string is null-terminated.
Parameter Passing
By default, C passes parameters by value. Remember to pass pointers to variables when you need to pass by address.

© National Instruments Corporation

2-3

NI-DAQ User Manual for PC Compatibles

Chapter 2 Fundamentals of Building Windows Applications
Creating a Windows Application Using Microsoft Visual Basic
This section assumes that you will be using the Microsoft Visual Basic IDE to manage your code development, and that you are familiar with the IDE.
Developing an NI-DAQ Application
To develop an NI-DAQ application, follow these general steps: 1. Open an existing or new Visual Basic project to manage your
application code. 2. Create files of type.frm (form definition and event handling code),
.bas (Visual Basic generic code module), or .cls (Visual Basic class module) and add them to the project. 3. Include the NI-DAQ include file for Visual Basic, nidaq32.bas, into your project. You may also want to include nidaqcns.inc and nidaqerr.inc. The NI-DAQ include files for Visual Basic are located in the .Include directory under your NI-DAQ directory. For Visual Basic 5.0/6.0, you can select the Project»Add Module menu option, click on the Existing tab, then select the module of your choice. Alternatively, you can add a reference to the National Instruments Data Acquisition Type Library, which is part of the NI-DAQ DLL. In Visual Basic 5.0/6.0, select the Project»References menu option, and check National Instruments Data Acquisition Library. If you do not see it listed there, click on the Browse button and locate nidaq32.dll in your Windowssystem or Windowssystem32 directory. 4. Run your application by clicking the Run button.
Note In Visual Basic, function declarations have scope globally throughout the project. In other words, you can define your prototypes in any module. The functions will be recognized even in other modules.
For information on using the NI-DAQ Visual Basic Custom Controls, see the NI- DAQ Events in Visual Basic for Windows section in Chapter 3, Software Overview.
Please also refer to the Programming Language Considerations topic in the NI- DAQ Function Reference Online Help file for more information on using the NI- DAQ functions in Visual Basic for Windows.

NI-DAQ User Manual for PC Compatibles

2-4

ni.com

Chapter 2 Fundamentals of Building Windows Applications
Example Programs
You can find some example programs and project files in .ExamplesVBasic directory under your NI-DAQ directory.
To load an example program, use one of the Visual Basic project files with the.vbp extension. These are Visual Basic 4.0 projects, which you can open only with Visual Basic 4.0 or later.
To load an example project with Visual Basic 4.0 or later, select the menu option File»Open Project, then select the.vbp file of your choice.
Refer to the NI-DAQ Examples Help (Start»Programs»National Instruments DAQ»NI- DAQ Examples Help) for additional information regarding NI-DAQ examples.
Special Considerations
Buffer Allocation
Visual Basic 4.0 is quite restrictive when allocating memory. You allocate memory by declaring an array of the data type with which you want to work. Visual Basic uses dynamic memory allocation so you can redimension an array to a variable size during run time. However, arrays are restricted to being less than 64 KB in total size (this translates to about 32,767 (16-bit) integers, 16,384 (32-bit) long integers, or 8,191 doubles).
To break the 64 KB buffer size barrier, you can use the Windows API functions GlobalAlloc() to allocate buffers larger than 64 KB. After allocation, you must lock memory with GlobalLock()to use a buffer of memory. You can use the memory handle returned by GlobalLock() in place of the buffer parameter in NI- DAQ API functions that accept buffers (Align_DMA_Buffer, DAQ_DB_Transfer, DAQ_Monitor, DAQ_Op, DAQ_Start, DIG_Block_In, DIG_Block_Out, DIG_DB_Transfer, GPCTR_Config_Buffer, GPCTR_Read_Buffer, Lab_ISCAN_Op, Lab_ISCAN_Start, SCAN_Op, SCAN_Start, SCAN_Sequence_Demux, WFM_DB_Transfer, WFM_Load, WFM_Op). The NI-DAQ header file declares the buffer parameter “As Any.” After using the memory, you must unlock memory with GlobalUnlock()and free it with GlobalFree().
Note If you allocate memory from GlobalAlloc(), you must call GlobalLock on the memory object before passing it to NI-DAQ.

© National Instruments Corporation

2-5

NI-DAQ User Manual for PC Compatibles

Chapter 2 Fundamentals of Building Windows Applications
The following paragraph illustrates declarations of functions.
For Visual Basic 4.0 or later, 32-bit: Declare Function GlobalAlloc Lib “kernel32” Alias “GlobalAlloc” (ByVal wFlags As Long, ByVal dwBytes As Long) As Long Declare Function GlobalFree Lib “kernel32” Alias “GlobalFree” (ByVal hMem As Long) As Long Declare Function GlobalLock Lib “kernel32” Alias “GlobalLock” (ByVal hMem As Long) As Long Declare Function GlobalReAlloc Lib “kernel32” Alias “GlobalReAlloc” (ByVal hMem As Long, ByVal dwBytes As Long, ByVal wFlags As Long) As Long Declare Function GlobalUnlock Lib “kernel32” Alias “GlobalUnlock” (ByVal hMem As Long) As Long
String Passing
In Visual Basic, variables of data type String need no special modifications to be passed to NI-DAQ for Windows functions. Visual Basic automatically appends a null character to the end of a string before passing it (by reference, because strings cannot be passed by value in Visual Basic) to a procedure or function.
Parameter Passing
By default, Visual Basic passes parameters by reference. Prepend the ByVal keyword if you need to pass by value.

NI-DAQ User Manual for PC Compatibles

2-6

ni.com

Chapter 2 Fundamentals of Building Windows Applications
Creating a Windows Application Using Borland C++
This section assumes that you will be using the Borland C++ IDE to manage your code development, and that you are familiar with the IDE.
Developing an NI-DAQ Application
To develop an NI-DAQ application, follow these general steps: 1. Open an existing or new Borland C++ project to manage your
application code. 2. Create files of type.c (C source code) or.cpp (C++ source code) and
add them to the project. · Make sure you include the NI-DAQ header file, nidaq.h, as such
in your source code files: #include “nidaq.h” · You may also want to include nidaqcns.h and nidaqerr.h. · Optionally, you can include other files (for example,.rc,.def) for GUI applications. 3. Specify the directory that contains the NI-DAQ header and import library files under the source directories (Include, Libary) settings of your compiler. For Borland C++ 5.0, this directory is under Options»Projects»Directories. The NI-DAQ header files are located in the.Include directory under your NI-DAQ directory, and the import library files are located in the.Lib directory under your NI-DAQ directory. 4. Add the NI-DAQ import library, nidaq32.lib, to the project. 5. Build your application.
Example Programs
You can find some example programs and project files in .ExamplesBorlandC directory under your NI-DAQ directory.
To build an example program, run one of the batch files with the.bat extension from a DOS prompt. You will have to modify the batch file to set one of the environmental variables to point to your Borland C++ IDE directory. If you open one of the batch files with a text editor, you will see the following line: set BorlandDir=e:appsbc5

© National Instruments Corporation

2-7

NI-DAQ User Manual for PC Compatibles

Chapter 2 Fundamentals of Building Windows Applications
Change the right hand side of the equal sign to indicate your Borland C++ IDE directory. For help on the usage of the batch file, type <batchfile.bat> /? from a DOS prompt, where <batchfile.bat> is the file name of batch file you want to run (for example, AIonePoint.bat).
To create your own example project with Borland C++ 5.0 or later using the provided example files, follow the steps mentioned above in Developing an NI- DAQ Application. In place of nidaq.h, make sure you include nidaqex.h. Also, make sure you include the import library nidex32b.lib into your project in addition to nidaq32b.lib.
Refer to the NI-DAQ Examples Help (Start»Programs»National Instruments DAQ»NI- DAQ Examples Help) for additional information regarding NI-DAQ examples.
Special Considerations
Refer to Special Considerations in the Creating a Windows Application Using Microsoft Visual C++ section.
Using Borland Delphi with NI-DAQ
The NI-DAQ installer installs a prototype file for use with Borland Delphi 2.0 or later, which is stored in the .Include directory in your NI-DAQ directory. To use this prototype file, include the file nidaq.pas into your Borland Delphi project, and be sure to include this line in your Delphi source code: uses NIDAQ;
Note There are no examples written with the NI-DAQ API for Borland Delphi. For examples on NI-DAQ function flow, refer to the examples of other languages and the flowchart in Chapter 3, Software Overview. Refer to the note at the end of the NI-DAQ Examples section of this chapter for information on examples using ComponentWorks ActiveX controls.

NI-DAQ User Manual for PC Compatibles

2-8

ni.com

Chapter 2 Fundamentals of Building Windows Applications

NI-DAQ Examples

The NI-DAQ installer installs a suite of concisely written examples in the following application development environments: · LabWindows/CVI 5.0.x · Microsoft Visual C++ 2.x (32-bit) or later · Microsoft Visual Basic 4.0 (32-bit) or later · Borland C++ 5.0

These examples illustrate how to use NI-DAQ functions to perform a single task. All examples are devoid of any code to extract values from GUI objects so that you can focus on how the code flow is formed. In addition, most parameters are hardcoded at the top of the routine so that if you decide to change them, you can simply change the assignment.

The examples correspond to the function flowcharts that you will see in Chapter 3, Software Overview. If a task and a flowchart in the following chapter suits your data acquisition needs, you should find a corresponding example to get you started.

Each example consists of the following files:
· An appropriate project file for the programming language (except for Borland C++, where .bat files are included to help build the executable)
· A single source code file to illustrate the task at hand
· A library of NI-DAQ example utility functions (for buffer creation, waveform plotting, error checking, and implementing a delay)

Note None of the examples are installed in their executable (.exe) format. To run them, you first must build them or load them into the IDE for the appropriate programming language.

The examples are stored in the hierarchy shown below for each language:

.AI

Analog Input examples

.AO

Analog Output examples

.DI

Digital Input examples

.DO

Digital Output examples

.CTR

Counter/timer examples

.SCXI

SCXI examples

.CALIB

Calibration examples

© National Instruments Corporation

2-9

NI-DAQ User Manual for PC Compatibles

Chapter 2 Fundamentals of Building Windows Applications
The project files have the same file name (not including extension) as the source code files. The following types are installed: · LabWindows/CVI:
.prj (project file), .c (source file) · Visual C++:
.mak (generic make file), .c (source file) · Visual Basic:
.vbp (project file, for Visual Basic 4.0 [32-bit] or later), .frm (form module) · Borland C++: .bat (Batchfile), .c (source file)
For more information about each example, how to compile examples, and details on the NI-DAQ Example Utility functions, please refer to the NI-DAQ Examples Online Help file. To open this file, go to Start»Programs»National Instruments DAQ»NI-DAQ Examples Help. You will have this file only if you installed support for LabWindows/CVI, Visual C++, Visual Basic, or Borland C++ examples.
In addition to examples using the NI-DAQ API, you can install and use examples using the ComponentWorks DAQ controls.
Run the NI-DAQ Setup Utility (Start»Programs»National Instruments DAQ»NI-DAQ Setup) and choose either of the following: · Microsoft Visual Basic (under Details, select ComponentWorks
ActiveX Controls and ComponentWorks DAQ Visual Basic Examples) · Borland Delphi (under Details, select ComponentWorks ActiveX Controls and ComponentWorks DAQ Borland Delphi Examples)
These examples will be installed in the .ExamplesVisual Basic and .ExamplesBorland Delphi directories, respectively, under your NI-DAQ directory.

NI-DAQ User Manual for PC Compatibles

2-10

ni.com

3
Software Overview

This chapter describes the function classes in NI-DAQ and briefly describes each function.
NI-DAQ functions are grouped according to the following classes: · Initialization and general-configuration · Software-calibration and device- specific · Event message · Analog input function group
­ One-shot analog input · Single-channel analog input
­ Data acquisition · High-level data acquisition · Low-level data acquisition · Low-level double-buffered data acquisition
· Analog output function group ­ One-shot analog output ­ Waveform generation · High-level waveform generation · Low-level waveform generation
· Digital I/O function group ­ Digital I/O ­ Group digital I/O · Double- buffered digital I/O ­ Change Notification ­ Filtering
· Counter/Timer function group ­ Counter/timer ­ Interval counter/timer ­ General-purpose counter/timer

© National Instruments Corporation

3-1

NI-DAQ User Manual for PC Compatibles

Chapter 3 Software Overview

· RTSI bus trigger · SCXI · Transducer conversion

Initialization and General-Configuration Functions

Use these general functions for initializing and configuring your hardware and software.

Refer to the NI-DAQ Function Reference Online Help file to determine which functions your device supports.

Align_DMA_Buffer

Aligns the data in a DMA buffer to avoid crossing a physical page boundary. This function is for use with DMA waveform generation and digital I/O pattern generation.

Get_DAQ_Device_Info

Retrieves parameters pertaining to the device operation.

Get_NI_DAQ_Version

Returns the version number of the NI-DAQ library.

Init_DA_Brds

Initializes the hardware and software states of a National Instruments DAQ device to its default state and then returns a numeric device code that corresponds to the type of device initialized. Any operation that the device is performing is halted. NI-DAQ automatically calls this function; your application does not have to call it explicitly. This function is useful for reinitializing the device hardware, for reinitializing the NI-DAQ software, and for determining which device has been assigned to a particular slot number.

NI-DAQ User Manual for PC Compatibles

3-2

ni.com

Chapter 3 Software Overview

Set_DAQ_Device_Info

Selects parameters pertaining to the device operation.

Timeout_Config

Establishes a timeout limit that is used by the synchronous functions to ensure that these functions eventually return control to your application. Examples of synchronous functions are DAQ_Op, DAQ_DB_Transfer, and WFM_from_Disk.

Software-Calibration and Device-Specific Functions

Each of these software-calibration and configuration functions is specific to only one type of device or class of devices.

Refer to the NI-DAQ Function Reference Online Help file to determine which functions your device supports.

AO_Calibrate

Loads a set of calibration constants into the calibration DACs or copies a set of calibration constants from one of four EEPROM areas to EEPROM area 1. You can load an existing set of calibration constants into the calibration DACs from a storage area in the onboard EEPROM. You can copy EEPROM storage areas 2 through 5 (EEPROM area 5 contains the factory-calibration constants) to storage area 1. NI-DAQ automatically loads the calibration constants stored in EEPROM area 1 the first time a function pertaining to the AT-AO-6/10 is called.

Calibrate_1200

Calibrates the gain and offset values for the 1200/AI devices ADCs and DACs. You can perform a new calibration or use an existing set of calibration constants by copying the constants from their storage location in the onboard EEPROM. You can store up to six sets of calibration constants.

© National Instruments Corporation

3-3

NI-DAQ User Manual for PC Compatibles

Chapter 3 Software Overview

Calibrate_TIO Calibrate_DSA Calibrate_E_Series

NI-DAQ automatically loads the calibration constants stored in EEPROM user area 5 the first time you call a function pertaining to the device.
Use the function to calibrate the crystal oscillator on your timing I/O 660X device.
Use this function to calibrate your DSA device.
Use this function to calibrate your E Series device or 671X device and to select a set of calibration constants for NI-DAQ to use.

Configure_HW_Analog_Trigger Configures the hardware analog trigger available on your E Series device.

LPM16_Calibrate MIO_Config

Calibrates the LPM device converter. The function calculates the correct offset voltage for the voltage comparator, adjusts positive linearity and full-scale errors to less than ±0.5 LSB each, and adjusts zero error to less than ±1 LSB.
Turns dithering on and off. For the MIO-64, this function also lets you specify whether to use AMUX-64T channels or onboard channels.

SCXI_Calibrate

Performs a self-calibration (or internal calibration) for certain SCXI modules.

Select_Signal

Selects the source and polarity of certain signals used by the E Series and DSA devices. You typically need to use this function to externally control timing, to use the RTSI bus, or to configure one of the I/O connector PFI pins.

NI-DAQ User Manual for PC Compatibles

3-4

ni.com

Chapter 3 Software Overview
Event Message Functions
NI-DAQ Event Message functions are an efficient way to monitor your background data acquisition processes, without dedicating your foreground process for status checking.
The NI-DAQ Event Message dispatcher notifies your application when a user- specified DAQ event occurs. Using event messaging eliminates continuous polling of data acquisition processes.
Config_Alarm_Deadband Specify alarm on/off condition for data acquisition event messaging.
Config_ATrig_Event_Message Specify analog input trigger level and slope for data acquisition event messaging.
Config_DAQ_Event_Message Specify analog input, analog output, digital input, or digital output trigger condition for event messaging.
Event Messaging Application Tips
To receive notification from the NI-DAQ data acquisition process in case of special events, you can call Config_Alarm_Deadband, Config_ATrig_Event_Message, or Config_DAQ_Event_Message to specify an event in which you are interested. If you are interested in more than one event, you can call any of those three functions again for each event.
After you have configured all event messages, you can begin your data acquisition by calling SCAN_Start, DIG_Block_In, and so on.
When any of the events you specified occur, NI-DAQ notifies your application.
Event notification can be done through user-defined callbacks and/or the Windows Message queue. When a user-specified event occurs, NI-DAQ calls the user-defined callback (if defined) and/or puts a message into the Windows Message queue, if you specified a window handle. Your application receives the message when it calls the Windows GetMessage API.

© National Instruments Corporation

3-5

NI-DAQ User Manual for PC Compatibles

Chapter 3 Software Overview
After your application receives an event message, it can carry out the appropriate task, such as updating the screen or saving data to disk.
To restart your data acquisition process after it completes, you do not need to call the message configuration calls again. They remain defined as long as your application does not explicitly remove them or call Init_DA_Brds.
To add or remove a message, first clear your data acquisition process. Then, call one of the three event message configuration functions.
NI-DAQ Events in Visual Basic for Windows ActiveX Controls for Visual Basic
Unlike standard control-flow programming languages, event occurrences drive Visual Basic code. You interact with outside events through the properties and procedures of a control. For any given control, there is a set of procedures called event procedures that affect that control. For example, a command button named Run has a procedure called Run_Click() that is called when you click on the Run button. If you want something to run when you click the Run button, enter code in the Run_Click() procedure. When a program starts executing, Visual Basic looks for events related to controls and calls control procedures as necessary. You do not write an event loop.
There are three NI-DAQ ActiveX controls for Visual Basic applications: · General Data Acquisition Event (daqevent.ocx)
· Analog Trigger Event (atrigev.ocx)
· Analog Alarm Event (alarmev.ocx)

The NI-DAQ installer places all of these ActiveX controls in the NIDAQ subdirectory of your Windows 2000/NT/98/95 directory under the file names shown.

NI-DAQ User Manual for PC Compatibles

3-6

ni.com

Chapter 3 Software Overview

These three ActiveX controls actually call the NI-DAQ Config_DAQ_Event_Message, Config_ATrig_Event_Message and Config_Alarm_Deadband functions. Visual Basic applications cannot receive Windows messages, but if you use NI-DAQ ActiveX controls shown previously in this section, your Visual Basic application can receive NI-DAQ messages.
Note You can use the OCXs in Visual Basic, version 4.0 (32-bit) or later.
General DAQ Event
You use the General DAQ Event control to configure and enable a single data acquisition event. See the Event Message Functions section earlier in this chapter for a complete description of NI-DAQ events. Table 3-1 lists the properties for the General DAQ Event control.
Note An n represents a generic number and is not the same value in every occurrence.

Table 3-1. General DAQ Event Control Properties

Property

Allowed Property Values

Name Board

GeneralDAQEventn (default) 1­n (default)

ChanStr

See Config_DAQ_Event_Message in the NI-DAQ Function Reference Online Help file.

DAQEvent

0–Acquired or generated n scans 1–Every n scans 2–Completed operation or stopped by error 3–Voltage out of bounds 4–Voltage within bounds 5–Analog positive slope triggering 6–Analog negative slope triggering 7–Digital pattern not matched 8–Digital pattern matched 9–Counter pulse event

DAQTrigVal0

Long

DAQTrigVal1

Long

TrigSkipCount

Long

© National Instruments Corporation

3-7

NI-DAQ User Manual for PC Compatibles

Chapter 3 Software Overview

Table 3-1. General DAQ Event Control Properties (Continued)

Property

Allowed Property Values

PreTrigScans

Long

PostTrigScans

Long

Index

N/A

Tag

N/A

Enabled

0–False (default) 1–True

Some General DAQ Events can be implemented only by a select group of National Instruments DAQ devices. Also, some General DAQ Events require that you set the asynchronous data acquisition or generation operation to use interrupts. For more information on the different types of General DAQ Events, refer to the description for the Config_DAQ_Event_Message function in the NI-DAQ Function Reference Online Help file.

Set each of these properties as follows: GeneralDAQEventn.property name = property value

For example, to set the ChanStr property to Analog Input channel 0 for GeneralDAQEvent 1:
GeneralDAQEvent1.ChanStr = “AI0”

Set up your program flow like this:
1. Set the properties of the General DAQ Event control. Then, configure the acquisition or generation operations using the appropriate NI-DAQ functions.
2. Set the Enabled property of the General DAQ Event control to 1 (True).
3. Invoke the GeneralDAQEventn.Refresh method to set the DAQ Event in the NI- DAQ driver. Each subsequent use of GeneralDAQEventn.Refresh deletes the old DAQ Event and sets a new one with the current set of properties.

NI-DAQ User Manual for PC Compatibles

3-8

ni.com

Chapter 3 Software Overview

4. Start an asynchronous data acquisition or generation operation. 5. When the selected event occurs, the GeneralDAQEventn_Fire
procedure is called. You can perform the necessary event processing within this procedure, such as updating a global count variable, or toggling digital I/O lines.
The GeneralDAQEventn_Fire procedure is prototyped as follows:
Sub GeneralDAQEventn_Fire (DoneFlag As Integer, Scans As Long)
The parameter DoneFlag equals 1 if the acquisition was over when the DAQ Event fired. Otherwise, it is 0. Scans equals the number of the scan that caused the DAQ Event to fire.
For a detailed example of how to use the General DAQ Event control in a Visual Basic program, please see the General DAQ Event example at the end of the NI- DAQ Events in Visual Basic for Windows section.

Analog Trigger Event
Use the Analog Trigger Event control to configure and enable an analog trigger. See the Event Message Functions section earlier in this chapter for a definition of the analog trigger.

Table 3-2 lists the properties for the Analog Trigger Event control.

Table 3-2. Analog Trigger Event Control Properties

Property Name Board ChanStr
Level WindowSize Slope
TrigSkipCount PreTrigScans PostTrigScans

Allowed Property Values GeneralDAQEventn (default) 1­n (default) See Config_DAQ_Event_Message in the NI-DAQ Function Reference Online Help file Single (voltage) Single (voltage) 0–Positive (default) 1–Negative Long Long Long

© National Instruments Corporation

3-9

NI-DAQ User Manual for PC Compatibles

Chapter 3 Software Overview

Table 3-2. Analog Trigger Event Control Properties (Continued)

Property

Allowed Property Values

Index

N/A

Tag

N/A

Enabled

0–False (default) 1–True

The Analog Trigger Event requires that you set the asynchronous data acquisition operation to use interrupts. For more information on Analog Trigger Events, refer to the descriptions for the Config_ATrig_Event_Message function in the NI-DAQ Function Reference Online Help file.

Each of these properties should be set as follows: AnalogTriggerEventn.property name = property value

For example, to set the ChanStr property to Analog Input channel 0 for Analog Trigger Event 1:
AnalogTriggerEvent1.ChanStr = “AI0”

Set up your program flow like this:
1. Set the properties of the Analog Trigger Event control. Next, configure the acquisition or generation operations using the appropriate NI-DAQ functions.
2. Set the Enabled property of the Analog Trigger Event control to 1 (True).
3. Invoke the AnalogTriggerEventn. Refresh method to actually set the Analog Trigger Event in the NI-DAQ driver. Each subsequent invocation of AnalogTriggerEventn. Refresh deletes the old Analog Trigger Event and sets a new one with the current set of properties.
4. Start an asynchronous data acquisition operation.
5. When the Analog Trigger conditions are met, the AnalogTriggerEventn_Fire procedure is called. You can perform the necessary event processing within this procedure, such as updating a global count variable, or toggling digital I/O lines.

NI-DAQ User Manual for PC Compatibles

3-10

ni.com

Chapter 3 Software Overview

The AnalogTriggerEventn_Fire procedure is prototyped as follows:
Sub AnalogTriggerEventn_Fire (DoneFlag As Integer, Scans As Long)
The parameter DoneFlag equals 1 if the acquisition was over when the Analog Trigger Event fired. Otherwise, it is 0. Scans equals the number of the scan that caused the Analog Trigger Event to fire.

Analog Alarm Event
Use the Analog Alarm Event control to configure and enable an analog trigger. See the Event Message Functions section earlier in this chapter for a definition of the analog trigger.

Table 3-3 lists the properties for the Analog Alarm Event control.

Table 3-3. Analog Alarm Event Control Properties

Property Name Board ChanStr
HighAlarmLevel LowAlarmLevel HighDeadbandWidth LowDeadbandWidth Index Tag Enabled

Allowed Property Values GeneralDAQEventn (default) 1­n (default) See Config_DAQ_Event_Message in the NI-DAQ Function Reference Online Help file Single (voltage) Single (voltage) Single (voltage) Single (voltage) N/A N/A 0–False (default) 1–True

The Analog Alarm Event requires that you set the asynchronous data acquisition operation to use interrupts. For more information on Analog Alarm Events, refer to the description for the Config_Alarm_Deadband function in the NI-DAQ Function Reference Online Help file.

© National Instruments Corporation

3-11

NI-DAQ User Manual for PC Compatibles

Chapter 3 Software Overview
Each of these properties should be set as follows: AnalogAlarmEventn.property name = property value
For instance, to set the ChanStr property to Analog Input channel 0 for Analog Alarm Event 1: AnalogAlarmEvent1.ChanStr = “AI0”
Set up your program flow like this: 1. Set the properties of the Analog Alarm Event control. Next configure
the acquisition or generation operations using the appropriate NI-DAQ functions. 2. Set the Enabled property of the Analog Alarm Event control to 1 (True). 3. Invoke the AnalogAlarmEventn.Refresh method to set the Analog Alarm Event in the NI-DAQ driver. Each subsequent invocation of AnalogAlarmEventn.Refresh deletes the old Analog Alarm Event and sets a new one with the current set of properties. 4. Start an asynchronous data acquisition operation. 5. Call any one of the four following procedures: · AnalogAlarm_HighAlarmOn · AnalogAlarm_HighAlarmOff · AnalogAlarm_LowAlarmOn · AnalogAlarm_LowAlarmOff
You can perform necessary event processing within this procedure, such as updating a global count variable or toggling digital I/O lines.
The four Analog Alarm procedures are prototyped as follows:
Sub AnalogAlarmn_HighAlarmOn (DoneFlag As Integer, Scans As Long)
Sub AnalogAlarmn_HighAlarmOff (DoneFlag As Integer, Scans As Long)
Sub AnalogAlarmn_LowAlarmOn (DoneFlag As Integer, Scans As Long)
Sub AnalogAlarmn_LowAlarmOff (DoneFlag As Integer, Scans As Long)

NI-DAQ User Manual for PC Compatibles

3-12

ni.com

Chapter 3 Software Overview
The parameter DoneFlag equals 1 if the acquisition was over when the Analog Alarm Event fired. Otherwise, it is 0. Scans equals the number of the scan that caused the Analog Alarm Event to fire.
Using Multiple Controls
In general, a program might contain any number of General DAQ Event, Analog Trigger Event, and Analog Alarm Event controls. Just like regular Visual Basic controls, there are two ways you can place multiple controls on a Visual Basic form:
· You can create control arrays by copying and pasting a control that already exists on the form. Each individual element in the control array is then distinguished by the Index property, and the event procedures is an extra parameter Index as Integer. The first element has Index = 0, the second element has Index = 1, and so on. You have only one procedure for each type of event custom control; however, you can determine which control array element caused the event to occur by examining the Index property.
· You can place multiple controls from the Visual Basic Tool Box onto the form. Each individual custom control of the same type is then distinguished by the number after the name of the custom control, such as GeneralDAQEvent1, GeneralDAQEvent2, and so on. Consequently, you can have separate procedures for each custom control, such as GeneralDAQEvent1_Fire, GeneralDAQEvent2_Fire, and so on.
General DAQ Event Example
The following steps provide an outline of how to use the General DAQ Event control in a Visual Basic program. A working knowledge of Visual Basic is assumed; otherwise, this example is complete, except for error checking:
1. To use the GeneralDAQEvent control, you must first include the proper control into your project.
· If you are using Visual Basic 4.0 (32-bit), select the Tools»Custom Controls option, and select the National Instruments GeneralDAQEvent custom control.
· If you are using Visual Basic 5.0, select the Project»Components option, and select the National Instruments GeneralDAQEvent custom control. In either version, if you do not find the custom control listed, click on the Browse button and find the custom control in the NI-DAQ subdirectory under your Windows directory.

© National Instruments Corporation

3-13

NI-DAQ User Manual for PC Compatibles

Chapter 3 Software Overview
2. To place the GeneralDAQEvent control into your form, go to the tool box window and select the GeneralDAQEvent tool, labelled DAQ EVENT.
3. Click somewhere on the form, and while holding down the mouse button, drag the mouse to place the control onto the form. You will see a small icon, which does not appear in run time.
4. To set up a DAQ Event that notifies you after every n scans (DAQ Event

1), unless you decide to make n very large, you can use the

Set_DAQ_Device_Info function to set the device analog inputs to use interrupts. The constants used in this function come from NIDAQCNS.INC. See the function description for Set_DAQ_Device_Info in the NI-DAQ Function Reference Online Help file for more information. You must also configure some parameters so that the GeneralDAQEvent can occur when it needs to. In the Form_Load event routine, add the following to the existing code:
er% = Set_DAQ_Device_Info(1, ND_DATA_XFER_MODE_AI, ND_INTERRUPTS) set AI to use INTR
GeneralDAQEvent1.Board = 1 assume Device 1 GeneralDAQEvent1.DAQEvent = 1event every N scans
GeneralDAQEvent1.DAQTrigVal0 = 1000 set N=1000 scans GeneralDAQEvent1.Enabled = True 5\. Next, start an asynchronous operation. Use the NI-DAQ function DAQ_Start. Set up your program so it does a DAQ_Start on channel 0 when you click on a button you have placed on your form. To do so, add the following code in the Command1_Click() subroutine as follows: Redim buffer%(10000) GeneralDAQEvent1.ChanStr = “AI0″ GeneralDAQEvent1.Refreshrefresh to set params
er% = DAQ_Start(1, 0, 1, buffer%(0), 10000, 3, 10)
6. Next, define what to do when the DAQ Event occurs. In this example, we can easily update a text box upon every 1,000 scans and also when the whole acquisition is complete. Place a text box on your form. It is automatically named Text 1.

NI-DAQ User Manual for PC Compatibles

3-14

ni.com

Chapter 3 Software Overview
7. Go to the code window, pull down on the Object combo box, and select GeneralDAQEvent1. The only Proc for this control object is Fire. Within the subroutine, enter the following code:
If (DoneFlag% <> 1) Then
Text1.Text = Str$(Scans&)+”scans have been acquired.”
Else
Text1.Text = “Acquisition is complete!”
er% = DAQ_Clear(1)
End If 8. Make sure that you stop any ongoing acquisition when you stop the
program. To do so, call the DAQ_Clear function before the End statement in the subroutine Command2Click(). Place another button on your form and label it Exit. The subroutine should have code as follows:
er% = DAQ_Clear(1)
End 9. Run the program. Because you are not going to display the data onto a
graph, it does not matter what the data is; however, when you click on the Click Me! button, the text box should update its contents every second. After all the scans are acquired, you should see the text box display a completion message. If you run into errors, refer to the NI-DAQ Function Reference Online Help file for guidance. 10. Click on the Exit button to stop the program.
Analog Input Function Group
The analog input function group contains two sets of functions–the one-shot analog input functions, which perform single A/D conversions, and the data acquisition functions, which perform multiple clocked, buffered A/D functions. Within the analog input functions, single-channel analog input (AI) functions perform single A/D conversions on one channel. Within the data acquisition functions, there are high-level, low-level, and low-level double buffered functions.
If you are using SCXI analog input modules (other than the SCXI-1200) you must use the SCXI functions first to program the SCXI hardware. Then you can use these functions to acquire the data using your DAQ device or SCXI-1200 module.

© National Instruments Corporation

3-15

NI-DAQ User Manual for PC Compatibles

Chapter 3 Software Overview

One-Shot Analog Input Functions
Single-Channel Analog Input Functions
Use the single-channel Analog Input functions for analog input on the 516 devices, DAQCard-700, analog input Lab and 1200 devices, MIO and AI devices, and LPM devices.

Refer to the NI-DAQ Function Reference Online Help file to determine which functions your device supports.

AI_Check

Returns the status of the analog input circuitry and an analog input reading if one is available. AI_Check is intended for use when A/D conversions are initiated by external pulses applied at the appropriate pin; see DAQ_Config in the NI-DAQ Function Reference Online Help file for information on enabling external conversions.

AI_Clear

Clears the analog input circuitry and empties the FIFO memory.

AI_Change_Parameter

Selects a specific parameter setting for the analog input section or analog input channel. Use this to set the coupling for AI channels.

AI_Configure

Informs NI-DAQ of the input mode (single-ended or differential), input range, and input polarity selected for the device. Use this function if you change the jumpers affecting the analog input configuration from their factory settings. For the E Series devices which have no jumpers for analog input configuration, this function programs the device for the settings you want. For the E Series devices you can configure the input mode and polarity on a per channel basis. Also use AI_Configure to specify whether to drive AISENSE to onboard ground.

NI-DAQ User Manual for PC Compatibles

3-16

ni.com

Chapter 3 Software Overview

AI_Mux_Config
AI_Read AI_Read_Scan AI_Read_VScan AI_Setup AI_VRead AI_VScale

Configures the number of multiplexer (AMUX-64T) devices connected to an MIO and AI device and informs NI-DAQ if any AMUX-64T devices are attached to the system. This function applies only to the MIO and AI devices.
Reads an analog input channel (initiates an A/D conversion on an analog input channel) and returns the unscaled result.
Returns readings for all analog input channels selected by Scan_Setup.
Returns readings in volts for analog input channels selected by Scan_Setup.
Selects the specified analog input channel and gain setting for externally pulsed conversion operations.
Reads an analog input channel (initiates an A/D conversion on an analog input channel) and returns the result scaled to a voltage in units of volts.
Converts the binary result from an AI_Read call to the actual input voltage.

Single-Channel Analog Input Application Tips
All of the NI-DAQ functions described in this section are for nonbuffered single-point analog input readings. For buffered data acquisition, consult the Data Acquisition Functions section later in this chapter.
Two of the AI functions are related to device configuration. If you have changed the device jumper settings from the factory-default settings or want to reprogram the E Series devices, call AI_Configure at the beginning of your application to inform NI-DAQ about the changes. Furthermore, if you have connected multiplexer devices (AMUX-64T) to your MIO and AI devices, call AI_Mux_Config once at the beginning of your application to inform NI-DAQ about the multiplexer devices.
For most purposes, AI_VRead is the only function required to perform single- point analog input readings. Use AI_Read when unscaled data is sufficient or when extra time taken by AI_VRead to scale the data is

© National Instruments Corporation

3-17

NI-DAQ User Manual for PC Compatibles

Chapter 3 Software Overview
detrimental to your applications. Use AI_VScale to convert the binary values to voltages at a later time if you want. See Figure 3-1 for the function flow typical of single-point data acquisition. Also, refer to the NI-DAQ Examples Online Help file (nidaqex.hlp) to find a related example.
When using SCXI as a front end for analog input to the DAQCard-700, analog input Lab and 1200 devices, MIO and AI device, or LPM devices, it is not advisable to use the AI_VRead function because that function does not take into account the gain of the SCXI module when scaling the data. Use the AI_Read function to obtain the unscaled data, then call the SCXI_Scale function using both the SCXI module gain and the DAQ device gain.
Change analog input default configuration.
AI_Configure
Add AMUX-64T configuration.
AI_Mux_Config

Yes

Binary reading?

Retrieve an analog reading in terms of a binary value.

AI_Read

No
Retrieve an analog reading in terms of voltage.
AI_VRead

Yes Another reading? No
Figure 3-1. Single-Point Analog Reading with Onboard Conversion Timing

NI-DAQ User Manual for PC Compatibles

3-18

ni.com

Chapter 3 Software Overview
When accurate sample timing is important, you can use external conversion pulses with AI_Clear, AI_Setup, and AI_Check to sample your signal on the analog input channels. See Figure 3-2 for the function flow typical of single- point data acquisition using external conversion pulses. However, this method works only if your computer is faster than the rate of conversion pulses. Refer to the Data Acquisition Functions section later in this chapter to learn more about interrupt and DMA-driven data acquisition by using high-speed data acquisition.
When you are using SCXI analog input modules, use the SCXI functions to set up the SCXI chassis and modules before using the AI functions described in Figures 3-1 and 3-2.
Change analog input default configuration.
AI_Configure
Add AMUX-64T configuration.
AI_Mux_Config
Clean up onboard FIFO memory for new conversion.
AI_Clear
Select an analog input channel.
AI_Setup
Check for new data in FIFO memory.
AI_Check
Yes Another reading?
No
Figure 3-2. Single-Point Analog Reading with External Conversion Timing

© National Instruments Corporation

3-19

NI-DAQ User Manual for PC Compatibles

Chapter 3 Software Overview

Data Acquisition Functions
High-Level Data Acquisition Functions
These high-level data acquisition functions are synchronous calls that acquire data and return when data acquisition is complete.

Refer to the NI-DAQ Function Reference Online Help file to determine which functions your device supports.

DAQ_Op

Performs a synchronous, single-channel data acquisition operation. DAQ_Op does not return until NI-DAQ has acquired all the data or an acquisition error has occurred.

DAQ_to_Disk

Performs a synchronous, single-channel data acquisition operation and saves the acquired data in a disk file. DAQ_to_Disk does not return until NI-DAQ has acquired and saved all the data or an acquisition error has occurred.

Lab_ISCAN_Op

Performs a synchronous, multiple-channel scanned data acquisition operation. Lab_ISCAN_Op does not return until NI-DAQ has acquired all the data or an acquisition error has occurred.

Lab_ISCAN_to_Disk

Performs a synchronous, multiple-channel scanned data acquisition operation and simultaneously saves the acquired data in a disk file. Lab_ISCAN_to_Disk does not return until NI-DAQ has acquired all the data and saved all the data or an acquisition error has occurred.

NI-DAQ User Manual for PC Compatibles

3-20

ni.com

Chapter 3 Software Overview

SCAN_Op SCAN_to_Disk

Performs a synchronous, multiple-channel scanned data acquisition operation. SCAN_Op does not return until NI-DAQ has acquired all the data or an acquisition error has occurred.
Performs a synchronous, multiple-channel scanned data acquisition operation and simultaneously saves the acquired data in a disk file. SCAN_to_Disk does not return until NI-DAQ has acquired all the data and saved it or until an acquisition error has occurred.

Low-Level Data Acquisition Functions
These functions are low-level primitives used for setting up, starting, and monitoring asynchronous data acquisition operations.

Refer to the NI-DAQ Function Reference Online Help file to determine which functions your device supports.

DAQ_Check

Checks if the current data acquisition operation is complete and returns the status and the number of samples acquired to that point.

DAQ_Clear

Cancels the current data acquisition operation (both single-channel and multiple-channel scanned) and reinitializes the data acquisition circuitry.

DAQ_Config

Stores configuration information for subsequent data acquisition operations.

DAQ_Monitor

Returns data from an asynchronous data acquisition in progress. During a multiple-channel acquisition, you can call DAQ_Monitor to retrieve data from a single channel or from all channels being scanned. Using the oldest/newest mode, you can specify whether DAQ_Monitor returns sequential (oldest) blocks of data, or the most recently acquired (newest) blocks of data.

© National Instruments Corporation

3-21

NI-DAQ User Manual for PC Compatibles

Chapter 3 Software Overview

DAQ_Rate

Converts a data acquisition rate into the timebase and sample-interval values needed to produce the rate you want.

DAQ_Set_Clock

Sets the scan rate for a group of channels.

DAQ_Start

Initiates an asynchronous, single-channel data acquisition operation and stores its input in an array.

DAQ_StopTrigger_Config Enables the pretrigger mode of data acquisition and indicates the number of data points to acquire after you apply the stop trigger pulse at the appropriate PFI pin.

DAQ_VScale

Converts the values of an array of acquired binary data and the gain setting for that data to actual input voltages measured.

Lab_ISCAN_Check

Checks if the current scan data acquisition operation begun by the Lab_ISCAN_Start function is complete and returns the status, the number of samples acquired to that point, and the scanning order of the channels in the data array.

Lab_ISCAN_Start

Initiates a multiple-channel scanned data acquisition operation and stores its input in an array.

SCAN_Demux

Rearranges, or demultiplexes, data acquired by a SCAN operation into row-major order (that is, each row of the array holding the data corresponds to a scanned channel) for easier access by C applications. SCAN_Demux does not need to be called by BASIC applications to rearrange two-dimensional arrays because these arrays are accessed in column-major order.

SCAN_Sequence_Demux

Rearranges the data produced by a multirate acquisition so that all the data

NI-DAQ User Manual for PC Compatibles

3-22

ni.com

Chapter 3 Software Overview

from each channel is stored in adjacent elements of your buffer.

SCAN_Sequence_Retrieve Returns the scan sequence created by NI-DAQ as a result of a previous call to SCAN_Sequence_Setup.

SCAN_Sequence_Setup

Initializes the device for a multirate scanned data acquisition operation. Initialization includes selecting the channels to be scanned, assigning gains to these channels, and assigning different sampling rates to each channel by dividing down the base scan rate.

SCAN_Setup

Initializes circuitry for a scanned data acquisition operation. Initialization includes storing a table of the channel sequence and gain setting for each channel to be digitized.

SCAN_Start

Initiates a multiple-channel scanned data acquisition operation, with or without interval scanning, and stores its input in an array.

Low-Level Double-Buffered Data Acquisition Functions
These functions are low-level primitives used for setting up and monitoring asynchronous double-buffered data acquisition operations.

Refer to the NI-DAQ Function Reference Online Help file to determine which functions your device supports.

DAQ_DB_Config

Enables or disables double-buffered data acquisition operations.

© National Instruments Corporation

3-23

NI-DAQ User Manual for PC Compatibles

Chapter 3 Software Overview

DAQ_DB_HalfReady DAQ_DB_Transfer

Checks if the next half buffer of data is available during a double-buffered data acquisition.
Transfers half of the data from the buffer being used for double-buffered data acquisition to another buffer, which is passed to the function. This function waits until the data to be transferred is available before returning. You can execute DAQ_DB_Transfer repeatedly to return sequential half buffers of the data.

Data Acquisition Application Tips
Lab and 1200 Device Counter/Timer Signals
For the Lab and 1200 devices, counter A2 produces the total sample interval for data acquisition timing. However, if the total sample interval is greater than 65,535 µs, counter B0 generates the clock for a slower timebase, which counter A2 uses for the total sample interval. Thus, the ICTR_Setup and ICTR_Reset functions cannot use counter B0 for the duration of the data acquisition operation.
In addition, the Waveform Generation functions cannot use counter B0 if the total update interval for waveform generation is also greater than 65,535 µs and counter B0 must produce a timebase for waveform generation different from the timebase counter B0 produced for data acquisition. If waveform generation is not in progress, counter B0 is available for data acquisition if you have made no ICTR_Setup call on counter B0 since startup, or if you have made an ICTR_Reset call on counter B0. If waveform generation is in progress and is using counter B0 to obtain the timebase required to produce the total update interval, counter B0 is only available for data acquisition if this timebase is the same as that required by the Data Acquisition functions to produce the total sample interval. In this case, counter B0 provides the same timebase for data acquisition and waveform generation.

NI-DAQ User Manual for PC Compatibles

3-24

ni.com

Chapter 3 Software Overview
DAQCard-500/700, 516 Device, and LPM Device Counter/Timer Signals
For these devices, counter 0 produces the sample interval for data acquisition timing. If data acquisition is not in progress, you can call the ICTR functions to use counter 0 as a general-purpose counter. Because the CLOCK0 input is connected to a 1 MHz oscillator, the timebase for counter 0 is fixed.
External Multiplexer Support (AMUX-64T)
You can expand the number of analog input signals measurable by the MIO and AI devices with an external multiplexer device (AMUX-64T). Refer to the AMUX-64T External Multiplexer Devices chapter in the DAQ Hardware Overview Guide, for more information on using the AMUX-64T with your MIO and AI device. See the AMUX-64T User Manual for more information on the external multiplexer device.
Basic Building Blocks
Most of the buffered data acquisition applications are made up of four building blocks, as shown in Figure 3-3. However, depending on the specific devices and applications you have, the NI-DAQ functions comprising each building block vary. Typical applications can include the NI-DAQ functions in each of their four building blocks.
Configuration
Start
Checking
Cleaning up
Figure 3-3. Buffered Data Acquisition Basic Building Blocks

© National Instruments Corporation

3-25

NI-DAQ User Manual for PC Compatibles

Chapter 3 Software Overview
When using SCXI analog input modules, use the SCXI functions to set up the SCXI chassis and modules before using the AI, DAQ, SCAN, and Lab_ISCAN functions shown in the following flowcharts.
Building Block 1: Configuration
Five configuration functions are available for creating the first building block, as shown in Figure 3-4. However, you do not have to call all five functions every time you start a data acquisition.
Alter low-level board configuration such as analog input mode.
AI_Configure
Add AMUX-64T Configuration.
AI_Mux_Config
Alter start trigger, external conversion, and external scan clock modes.
DAQ_Config
Alter pretrigger mode.
DAQ_StopTrigger_Config
Alter double-buffered mode.
DAQ_DB_Config
Figure 3-4. Buffered Data Acquisition Application Building Block 1, Configuration
NI-DAQ records the device configurations and the default configurations. (See the Init_DA_Brds description in the NI-DAQ Function Reference Online Help file for device default configurations.) Therefore, if you are satisfied with the default or the current configurations of your devices, your configuration building block will be empty, and you can go on to the next building block, Start.

NI-DAQ User Manual for PC Compatibles

3-26

ni.com

Chapter 3 Software Overview
Building Block 2: Start
NI-DAQ has high-level and low-level start functions. The high-level start functions are as follows: · DAQ_Op · SCAN_Op (MIO, AI, and DSA devices only) · Lab_ISCAN_Op (DAQCard-500/700, 516 devices, LPM devices,
and Lab and 1200 devices only) · DAQ_to_Disk · SCAN_to_Disk (MIO, AI, and DSA devices only) · Lab_ISCAN_to_Disk (DAQCard-500/700, 516 devices,
LPM devices, and Lab and 1200 devices only)
A high-level start call initiates data acquisition but does not return to the function caller until the data acquisition is complete. For that reason, you do not need the next building block, Checking, when you use high-level start functions.

No DAQ_Op

No

Streaming

Yes

to disk?

Scan Multiple

Yes

Channels?

No

Scan Multiple

Yes

Channels?

DAQ_to_Disk

No

MIO, AI or

Yes

DSA Device?

No

MIO, AI or

Yes

DSA Device?

Lab_ISCAN_Op

SCAN_Op

Lab_ISCAN_to_Disk

SCAN_to_Disk

Figure 3-5. Buffered Data Acquisition Application Building Block 2, Start
The major advantage of the high-level start functions is that they are simple. A single call can produce a buffer full or a disk full of data. However, if your application is acquiring data at a very slow rate or is acquiring a lot of data, the high-level start functions might tie up the computer for a significant amount of time. Therefore, NI-DAQ has some low-level (or asynchronous) start functions that initiate data acquisition and return to the calling program function caller immediately.

© National Instruments Corporation

3-27

NI-DAQ User Manual for PC Compatibles

Chapter 3 Software Overview
Asynchronous start functions include DAQ_Start, SCAN_Start, and Lab_ISCAN_Start. Figures 3-6 and 3-7 show how the start calls make up building block 2 for different devices.
Convert sampling rate to sample timebase and sample interval.
DAQ_Rate

Yes Select channels and their gain for multiple-channel scanning.
SCAN_Setup
Initiate multiple-channel data acquisition.
SCAN_Start

Sample multiple channels?

No
Initiate single-channel data acquisition.
DAQ_Start

Figure 3-6. Buffered Data Acquisition Application Building Block 2, Start, for the MIO, AI, and DSA Devices
For DSA devices, substitute DAQ_Set_Clock for DAQ_Rate in Figure 3-6. DAQ_Rate will not produce the correct clock settings for DSA devices.
If your device works with multirate scanning, you can use SCAN_Sequence_Setup instead of SCAN_Setup in building block 2.

NI-DAQ User Manual for PC Compatibles

3-28

ni.com

Chapter 3 Software Overview
Convert sampling rate to sample timebase and sample interval.
DAQ_Rate

Yes

Sample multiple

channels?

Initiate multiple-channel data acquisition.

Lab_ISCAN_Start

No
Initiate single-channel data acquisition.
DAQ_Start

Figure 3-7. Buffered Data Acquisition Application Building Block 2, Start, for the 516 Devices, DAQCard-500/700, Lab and 1200 Devices, and LPM Devices
When you have the asynchronous start calls in your building block 2, the next building block, Checking, is very useful for determining the status of the ongoing data acquisition process.

© National Instruments Corporation

3-29

NI-DAQ User Manual for PC Compatibles

Chapter 3 Software Overview
Building Block 3: Checking
DAQ_Check and Lab_ISCAN_Check, shown in Figures 3-8 and 3-9, are simple and quick ways to check the ongoing data acquisition process. This call is often put in a while loop so that the application can periodically monitor the data acquisition process.
Check ongoing single or multiple-channel data acquisition status.
DAQ_Check

No

Data Acquisition

complete?

Yes

Figure 3-8. Buffered Data Acquisition Application Building Block 3, Checking, for the MIO, AI, and DSA Devices

Yes

Sample multiple

channels?

Check ongoing multiple-channel data acquisition status.
Lab_ISCAN_Check

No
Check ongoing single-channel data acquisition status.
DAQ_Check

Figure 3-9. Buffered Data Acquisition Application Building Block 3, Checking, for the 516 Devices, DAQCard-500/700, Lab and 1200 Devices, and LPM Devices

NI-DAQ User Manual for PC Compatibles

3-30

ni.com

Chapter 3 Software Overview
However, if the information provided by DAQ_Check is not sufficient, DAQ_Monitor or the double-buffered functions might be a better choice. With DAQ_Monitor, not only can you monitor the data acquisition process, but you can also retrieve a portion of the acquired data. With the double-buffered functions, you can retrieve half of the data buffer at a time. Double-buffered functions are very useful when your application has a real-time strip chart displaying the incoming data.
Building Block 4: Cleaning up
The purpose of this building block is to stop the data acquisition and free any system resources (such as DMA channels) used for the data acquisition. DAQ_Clear is the only function needed for this building block and is automatically called by the check functions described in the previous building block when the data acquisition is complete. Therefore, you can eliminate this last building block if your application continuously calls the previously described check functions until the data acquisition is complete.
Note DAQ_Clear does not alter the device configurations made by building block

  1. Double-Buffered Data Acquisition
    The double-buffered (DAQ_DB) data acquisition functions return data from an ongoing data acquisition without interrupting the acquisition. These functions use a double, or circular, buffering scheme that permits half buffers of data to be retrieved and processed as the data becomes available. By using a circular buffer, you can collect an unlimited amount of data without needing an unlimited amount of memory. Double-buffered data acquisition is useful for applications such as streaming data to disk and real-time data display.
    Initiating double-buffered data acquisition requires some simple changes to the first and third basic building blocks, Configuration and Checking, respectively.
    In building block 1, turn on double-buffered mode data acquisition through the DAQ_DB_Config call. After the double-buffered mode is enabled, all subsequent data acquisitions are in double-buffered mode.
    In building block 3, different checking functions are needed. Figure 3-10 shows a simple way to monitor the data acquisition in progress and to retrieve data when they are available.
    For further details on double-buffered data acquisition, consult Chapter 4, NI-DAQ Double Buffering.

© National Instruments Corporation

3-31

NI-DAQ User Manual for PC Compatibles

Chapter 3 Software Overview

Check for next half buffer availability.
DAQ_DB_HalfReady

No

Next half buffer

ready for transfer?

Retrieve half of the data in Yes the data acquisition buffer.
DAQ_DB_Transfer

No

Data acquisition

complete?

Yes

Figure 3-10. Double-Buffered Data Acquisition Application Building Block 3, Checking
Multirate Scanning
Use multirate scanning to scan multiple channels at different scan rates and acquire the minimum amount of data necessary for your application. This is particularly useful if you are scanning very fast and want to write your data to disk, or if you are acquiring large amounts of data and want to keep your buffer size to a minimum.
Multirate scanning works by scanning each channel at a rate that is a fraction of the specified scan rate. For example, if you want to scan four channels at 6,000, 4,000, 3,000, and 1,000 scans per second, specify a scan rate of 12,000 scans per second and a scan rate divisor vector of 2, 3, 4, and 12.

NI-DAQ User Manual for PC Compatibles

3-32

ni.com

Chapter 3 Software Overview
NI-DAQ includes three functions for multirate scanning: · SCAN_Sequence_Setup · SCAN_Sequence_Retrieve · SCAN_Sequence_Demux
Use SCAN_Sequence_Setup to identify the channels to scan, their gains, and their scan rate divisors. After the data is acquired, use SCAN_Sequence_Retrieve and SCAN_Sequence_Demux to arrange the data into a more convenient format.
Figure 3-11 shows how to use the multirate scanning functions in conjunction with other NI-DAQ functions.

© National Instruments Corporation

3-33

NI-DAQ User Manual for PC Compatibles

Chapter 3 Software Overview

Convert sampling rate to sample timebase and sample interval; convert scan rate to scan timebase and scan interval.
DAQ_Rate
Select channels and their gains and scan rate divisors.
SCAN_Sequence_Setup

Allocate your buffer using the values returned by SCAN_Sequence_Setup
in the scansPerSequence and samplesPerSequence output variables.
Retrieve the scan sequence vector
for use in the SCAN_Sequence_Demux function. SCAN_Sequence_Retrieve
Initiate multiple-channel data acquisition.
SCAN_Start
Check ongoing data acquisition status.
DAQ_Check

No

Data acquisition

complete?

Yes Rearrange the data in your data acquisition buffer so that all data from each channel is stored in adjacent elements of your buffer.
SCAN_Sequence_Demux

Figure 3-11. Multirate Scanning

NI-DAQ User Manual for PC Compatibles

3-34

ni.com

Chapter 3 Software Overview

Analog Output Function Group

The Analog Output function group contains two sets of functions–the Analog Output (AO) functions, which perform single D/A conversions, and the Waveform (WFM) functions, which perform buffered D/A conversions.

Note Use the SCXI functions described later in this chapter for the SCXI-1124 analog output module.

One-Shot Analog Output Functions
Use the Analog Output functions to perform single D/A conversions with analog output devices.

Refer to the NI-DAQ Function Reference Online Help file to determine which functions your device supports.

AO_Change_Parameter

Selects a specific parameter setting for the analog output section or analog output channel. These parameters might be data transfer conditions, filter settings, or similar device settings.

AO_Configure

Records the output range and polarity selected for each analog output channel by the jumper settings on the device and indicates the update mode of the DACs. Use this function if you have changed the jumper settings affecting analog output range and polarity from their factory settings. Also use this function to change the analog output settings on devices without jumpers.

AO_Update

Updates analog output channels on the specified device to new voltage values when the later internal update mode is enabled by a previous call to AO_Configure.

© National Instruments Corporation

3-35

NI-DAQ User Manual for PC Compatibles

Chapter 3 Software Overview

AO_VScale AO_VWrite AO_Write

Scales a voltage to a binary value that, when written to one of the analog output channels, produces the specified voltage.
Accepts a floating-point voltage value, scales it to the proper binary number, and writes that number to an analog output channel to change the output voltage.
Writes a binary value to one of the analog output channels, changing the voltage produced at the channel.

Analog Output Application Tips
This section contains a basic explanation of how to construct an application using the analog output functions. The flowcharts are a quick reference for constructing potential applications from the NI-DAQ function calls.
For most purposes, AO_VWrite is the only function required to generate single analog voltages. It converts the floating-point voltage to binary and writes the value to the device. AO_VWrite is the equivalent of a call to AO_VScale followed by a call to AO_Write. Figure 3-12 illustrates the equivalency.

Scale floating-point voltage to binary value.
AO_VScale
Output binary voltage to board.
AO_Write

Scale floating-point voltage to binary value and output binary voltage to board.
AO_VWrite

Figure 3-12. Equivalent Analog Output Calls
The following applications are shown using AO_VWrite. However, substituting the equivalent AO_VScale and AO_Write calls will not change the results.

NI-DAQ User Manual for PC Compatibles

3-36

ni.com

Chapter 3 Software Overview
Simple Analog Output Application
Figure 3-13 illustrates the basic series of calls for a simple analog output application.
Account for any changes in the jumper settings. Enable external update pulses?
AO_Configure
Output voltage to board.
AO_VWrite
No Done outputting data?
Yes
Figure 3-13. Simple Analog Output Application
The call to AO_Configure in Figure 3-13 must be made only if you have changed the jumper settings of an MIO, AT-AO-6/10, or Lab-PC+ device. You also might call AO_Configure to enable external updating of the voltage. When you select external update mode, voltages written to the device are not output until you apply a pulse to pin 48 (EXTUPDATE) on the AT-AO-6/10, to pin 39 (EXTUPDATE) on the Lab and 1200 analog output devices, or to the selected pin on an E Series device or 671X device. You can simultaneously change the voltages at all the analog output channels. The final steps in Figure 3-13 form a simple loop. New voltages are output until the data ends.
Analog Output with Software Update Application
Another application option is to enable later software updates. Like the external update mode, voltages written to the device are not immediately output. Instead, the device does not output the voltages until you call AO_Update. In later software update mode, the device changes voltages simultaneously at all the channels. Figure 3-14 illustrates a modified version of the flowchart in Figure 3-13.

© National Instruments Corporation

3-37

NI-DAQ User Manual for PC Compatibles

Chapter 3 Software Overview

Account for changes in the jumper settings. Enable software voltage update.
AO_Configure

Output voltage to board.
AO_VWrite

Wait until you are ready to output voltage.

No

Update?

Yes Output voltage from board.
AO_Update

No

Done outputting data?

Yes

Figure 3-14. Analog Output with Software Updates
The first modification you make is to enable later internal updates when you call AO_Configure. The next change, which follows the AO_VWrite step, is the decision to wait or to output the voltage. If you want the voltage to be output, your application must call AO_Update to write out the voltage. The rest of the flowchart is identical to Figure 3-13.
Note Implement buffered analog output using the Waveform Generation (WFM) functions.

NI-DAQ User Manual for PC Compatibles

3-38

ni.com

Chapter 3 Software Overview

Waveform Generation Functions
Use the Waveform Generation (WFM) functions to perform buffered analog output operations with the MIO devices, 671X devices, AT-AO-6/10 devices, and Lab and 1200 analog output devices.
Refer to the NI-DAQ Function Reference Online Help file to determine which functions your device supports.

High-Level Waveform Generation Functions
The following high-level Waveform Generation functions accomplish with a single call tasks that require several low-level calls to accomplish:

WFM_from_Disk

Assigns a disk file to one or more analog output channels, selects the rate and the number of times the data in the file is to be generated, and starts the generation. WFM_from_Disk always waits for completion before returning, unless you call Timeout_Config.

WFM_Op

Assigns a waveform buffer to one or more analog output channels, selects the rate and the number of times the data in the buffer is to be generated, and starts the generation. If the number of buffer generations is finite, WFM_Op waits for completion before returning, unless you call Timeout_Config.

Low-Level Waveform Generation Functions
Low-level Waveform Generation functions are for setting up, starting, and controlling synchronous waveform generation operations:

WFM_Chan_Control

Temporarily halts or restarts waveform generation for a single analog output channel.

WFM_Check

Returns status information concerning a waveform generation operation.

WFM_ClockRate

Sets an update rate and a delay rate for a group of analog output channels.

© National Instruments Corporation

3-39

NI-DAQ User Manual for PC Compatibles

Chapter 3 Software Overview
WFM_DB_Config WFM_DB_HalfReady
WFM_DB_Transfer
WFM_Group_Control WFM_Group_Setup
WFM_Load
WFM_Rate

Enables and disables the double-buffered mode of waveform generation.
Checks if the next half buffer for one or more channels is available for new data during a double-buffered waveform generation operation. You can use WFM_DB_HalfReady to avoid the waiting period possible with the double-buffered transfer functions.
Transfers new data into one or more waveform buffers (selected in WFM_Load) as waveform generation is in progress. WFM_DB_Transfer waits until NI-DAQ can transfer the data from the buffer to the waveform buffer.
Controls waveform generation for a group of analog output channels.
Assigns one or more analog output channels to a waveform generation group. A call to WFM_Group_Setup is required only for the AT-AO-6/10. By default, all analog output channels for the Lab and 1200 analog output, 671X devices, and MIO devices are in group 1.
Assigns a waveform buffer to one or more analog output channels and indicates the number of waveform cycles to generate. For the 671X devices, E Series devices, and AT-AO-6/10, this function also enables or disables FIFO mode waveform generation.
Converts a waveform generation update rate into the timebase and update- interval values needed to produce the rate you want.

NI-DAQ User Manual for PC Compatibles

3-40

ni.com

Chapter 3 Software Overview

WFM_Scale WFM_Set_Clock

Translates an array of floating-point values that represent voltages into an array of binary values that produce those voltages. The function uses the current analog output configuration settings to perform the conversions.
Sets an update rate for a group of channels.

Waveform Generation Application Tips
This section outlines a basic explanation of constructing an application with the Waveform Generation functions. The flowcharts are a quick reference for constructing potential applications from the NI-DAQ function calls.

Basic Waveform Generation Applications
A basic waveform application outputs a series of voltages to an analog output channel. Figure 3-15 illustrates the ordinary series of calls for a basic waveform application.
The first step of Figure 3-15 calls WFM_Scale. The WFM_Scale function converts floating-point voltages to integer values, thus producing the voltages (DAC values) you want.
You have two options available for starting a waveform generation. The first option is to call the high-level function WFM_Op. The WFM_Op function immediately begins the waveform generation after you call it. If the number of iterations is nonzero, WFM_Op does not return until the waveform generation is done and all cleanup work is complete. Setting the iterations equal to 0 signals NI-DAQ to place the waveform generation in continuous double-buffered mode. In continuous double-buffered mode, waveform generation occurs in the background, and the WFM_Op function returns immediately to your application. See the Double-Buffered Waveform Generation Applications section later in this chapter for more information.
The second option to start a waveform generation is to call the following sequence of functions:
1. WFM_Group_Setup (required only for the AT-AO-6/10) to assign one or more analog output channels to a group.
2. WFM_Load to assign a waveform buffer to one or more analog output channels.

© National Instruments Corporation

3-41

NI-DAQ User Manual for PC Compatibles

Chapter 3 Software Overview
3. WFM_Rate to convert a data output rate to a timebase and an update interval that generates the rate you want. WFM_Rate only supports some devices. Because it does not have a device number parameter, it cannot return an error if you use it with a non-supported device. See the NI-DAQ Function Reference Online Help file for supported devices.
4. WFM_ClockRate or WFM_Set_Clock to set the update rate (see the NI-DAQ Function Reference Online Help file to find out which function supports your device).
5. WFM_Group_Control (with operation=START) to start the waveform generation in the background and return to your application after the waveform generation has begun.
The next step in Figure 3-15 shows how the call to WFM_Check. WFM_Check retrieves the current status of the waveform generation. Your application uses this information to determine if the generation is complete or should be stopped.
The final step is to call WFM_Group_Control (operation=CLEAR). The CLEAR operation performs all of the necessary cleanup work after a waveform generation. Additionally, CLEAR halts any ongoing waveform generation.

NI-DAQ User Manual for PC Compatibles

3-42

ni.com

Chapter 3 Software Overview

Convert floating-point voltages to binary values.
WFM_Scale

Assign channels to the waveform generation group.
WFM_Group_Setup
Load waveform buffer and specify iterations.
WFM_Load
Convert output rate to timebase and interval.
WFM_Rate
Set the update rate.
WFM_ClockRate or WFM_Set_Clock

Load waveform buffer, specify iterations, and start waveform.
WFM_Op
If iterations > 0, the waveform generation is complete.
Iterations > 0 Yes
No

Start background waveform generation.
WFM_Group_Control
(operation = START)

WFM_Check
Yes Any more data to output?
No Clear waveform.
WFM_Group_Control
(operation = CLEAR)

© National Instruments Corporation

Figure 3-15. Basic Waveform Generation Application

3-43

NI-DAQ User Manual for PC Compatibles

Chapter 3 Software Overview
Basic Waveform Generation with Pauses The application skeleton described in this section is nearly identical to the basic waveform generation application skeleton. The difference is that the description in this section includes the pause and resume operations. Figure 3-16 illustrates the ordinary series of calls for a basic waveform application with pauses.
The first step of Figure 3-16 calls WFM_Group_Setup. The WFM_Group_Setup function assigns one or more analog output channels to a group.
The second step is to assign a buffer to the analog output channels using the calls WFM_Scale and WFM_Load. The WFM_Scale function converts floating-point voltages to integer values that produce the voltages you want. The WFM_Load function assigns a waveform buffer to one or more analog output channels.
The next step is to assign an update rate to the group of channels using the calls WFM_Rate and WFM_ClockRate. The WFM_Rate function converts a data output rate to a timebase and an update interval that generates the rate you want. The WFM_ClockRate function assigns a timebase, update interval, and delay interval to a group of analog output channels.
Notice that there are restrictions for using the WFM_ClockRate function to specify delay rate. Refer to the WFM_ClockRate function description in the NI- DAQ Function Reference Online Help file for further details.
Your application is now ready to start a waveform generation. Call WFM_Group_Control (operation=START) to start the waveform generation in the background. WFM_Group_Control will return to your application after the waveform generation begins.
The next step in Figure 3-16 is an application decision to pause the waveform generation. The application uses a number of conditions for making this decision, including status information returned by WFM_Check.
Pause the waveform generation by calling WFM_Group_Control (operation=PAUSE). PAUSE stops the waveform generation and maintains the current waveform voltage at the channel output.

NI-DAQ User Manual for PC Compatibles

3-44

ni.com

Chapter 3 Software Overview
Resume the waveform generation by calling WFM_Group_Control (operation=RESUME). RESUME restarts the waveform generation at the data point where it was paused. The output rate and the data buffer are unchanged.
The final step is to call WFM_Group_Control (operation=CLEAR). CLEAR performs all the necessary cleanup work after a waveform generation. Additionally, CLEAR halts any ongoing waveform generation.

© National Instruments Corporation

3-45

NI-DAQ User Manual for PC Compatibles

Chapter 3 Software Overview

Assign channels to waveform generation group.
WFM_Group_Setup
Convert floating-point voltages to binary values.
WFM_Scale
Load waveform buffer and specify iterations.
WFM_Load
Convert output rate to timebase and interval.
WFM_Rate
Set the update and delay rates.
WFM_ClockRate
Start background waveform generation.
WFM_Group_Control
(operation = START)

Should you pause waveform generation?

Pause wave?

Yes

Pause the waveform generator.

No Start waveform generation

WFM_Group_Control
(operation = PAUSE)

where it was paused. No

Resume waveform generation? Resume wave?

WFM_Group_Control
(operation = RESUME)

Yes
WFM_Group_Control
(operation = CLEAR)

Clear waveform.

Figure 3-16. Waveform Generation with Pauses

NI-DAQ User Manual for PC Compatibles

3-46

ni.com

Chapter 3 Software Overview
Double-Buffered Waveform Generation Applications You also can configure waveform generation as a double-buffered operation. Double-buffered operations can perform continuous waveform generation with a limited amount of memory. For an explanation of double buffering, refer to Chapter 4, NI-DAQ Double Buffering. Figure 3-17 outlines the basic steps for double-buffered waveform applications.
First, enable double buffering by calling WFM_DB_Config as shown in the first step of Figure 3-17.
Although every step is not in the diagram, you might also call WFM_Rate and/or WFM_Scale as described in the basic waveform application outline.
There are two ways in which your application can start waveform generation. The first way is to call the high-level function WFM_Op. The second way is to call the following sequence of functions– WFM_Group_Setup (only required on the AT-AO-6/10), WFM_Load, WFM_ClockRate or WFM_Set_Clock, WFM_Group_Control (operation=START). The WFM_Group_Setup function assigns one or more analog output channels to a group. The WFM_Load function assigns a waveform buffer to one or more analog output channels. This buffer is called a circular buffer. The WFM_ClockRate and WFM_Set_Clock functions (see the NI-DAQ Function Reference Online Help file for the function that supports your device) assign an update rate to a group of analog output channels. Calling WFM_Group_Control (operation=START) starts the background waveform generation. WFM_Group_Control returns to your application after the waveform generation begins.
After the operation begins, you can perform unlimited transfers to the circular waveform buffer. To transfer data to the circular buffer, call the WFM_DB_Transfer function. After you call the function, NI-DAQ waits until it is able to transfer the data before returning to the application. To avoid the waiting period, you can call WFM_DB_HalfReady to determine if the transfer can be made immediately. If WFM_DB_HalfReady indicates NI-DAQ is not ready for a transfer, your application is free to do other processing and check the status later.
After the final transfer, you can call WFM_Check to get the current transfer progress. Remember, NI-DAQ requires some time after the final transfer to actually output the data.

© National Instruments Corporation

3-47

NI-DAQ User Manual for PC Compatibles

Chapter 3 Software Overview
The final step is to call WFM_Group_Control (operation=CLEAR). The CLEAR operation performs all of the necessary cleanup work after a waveform generation. Additionally, CLEAR halts any ongoing waveform generation.
Enable double buffering.
WFM_DB_Config
Assign channels to waveform generation group.
WFM_Group_Setup
Load waveform buffer and specify iterations.
WFM_Load
Set the update rate.
WFM_ClockRate or WFM_Set_Clock
Start background waveform generation.
WFM_Group_Control
(operation = START)
Check if the next half buffer is ready for data. No
WFM_DB_HalfReady
Yes Transfer the next half of the data to the waveform data buffer.
WFM_DB_Transfer
Do you want to transfer more data to the waveform buffer? Yes Transfer?
No Any more data to output?
Yes
WFM_Check
No Clear the waveform.
WFM_Group_Control (operation = CLEAR)

NI-DAQ User Manual for PC Compatibles

Figure 3-17. Double-Buffered Waveform Generation
3-48

ni.com

Chapter 3 Software Overview

Reference Voltages for Analog Output Devices
Table 3-4 shows the output voltages produced when you select unipolar output polarity.

Table 3-4. Output Voltages with Unipolar Output Polarity

Device

Value in Waveform Buffer

0

4,095

65,535

AT-MIO-16X, AT-MIO-16XE-10,

0V

PCI-MIO-16XE-10, PCI-MIO-16XE-50,

PCI-6031E (MIO-64XE-10),

VXI-MIO-64XE-10, 6052E,

6053E devices

Reference voltage

All other MIO devices

0V

Reference voltage

AT-AO-6/10

0V

Reference voltage

(+10 V in default case)

Lab and 1200 devices with analog output 0 V

+5 V

Table 3-5 shows the output voltages produced when you select bipolar output polarity.

Table 3-5. Output Voltages with Bipolar Output Polarity

Device

­2,048

Value in Waveform Buffer

2,047

­32,768

32,767

AT-MIO-16XE-10,

Negative of

Reference

PCI-MIO-16XE-10,

the reference

voltage

PCI-MIO-16XE-50,

voltage

PCI-6031E

(MIO-64XE-10),

VXI-MIO-64XE-10,

PCI-6110, PCI-6111,

6052E, 6053E devices

All other MIO devices,

Negative of

Reference

671X devices, 622X devices the reference

voltage

voltage

© National Instruments Corporation

3-49

NI-DAQ User Manual for PC Compatibles

Chapter 3 Software Overview

Table 3-5. Output Voltages with Bipolar Output Polarity (Continued)

Value in Waveform Buffer

Device

­2,048

2,047

­32,768

AT-AO-6/10

Negative of

Reference

the reference

voltage

voltage

(+10 V in

(­10 V in

default case)

default case)

Lab and 1200 devices

­5 V

+5 V

with analog output

32,767 —

Note NI 4451 for PCI and NI 4551 for PCI devices use signed, 18-bit binary data left-justified in a 32-bit word. Their output voltage range is ±10 V.

Minimum Update Intervals
The rate at which a device can output analog data is limited by the performance of the host computer. For waveform generation, the limitation is in terms of minimum update intervals. The update interval is the period of time between outputting new voltages. Therefore, the minimum update interval specifies the smallest possible time delay between outputting new data points. In other words, the minimum update interval specifies the fastest rate at which a device can output data. Refer to Chapter 4, NI-DAQ Double Buffering, for more information on the minimum update intervals.

Counter Usage
NI 4451 for PCI and NI 4551 for PCI devices use the same counter for both waveform generation and analog input data acquisition. See WFM_Set_Clock in the NI-DAQ Function Reference Online Help file for an explanation of the restrictions this causes. This counter is separate from the general-purpose counters.
The MIO, 671X, 622X, and E Series devices use dedicated counters from the DAQ- STC chip for waveform-generation control and timing.
On the Lab and 1200 devices and analog output devices, counter A2 produces the total update interval for waveform generation. However, if the total update interval is greater than 65,535 µs, counter B0 generates the clock for a slower timebase, which counter A2 uses for the total update interval. The ICTR_Setup and ICTR_Reset functions cannot then use counter B0 for the duration of the waveform generation

NI-DAQ User Manual for PC Compatibles

3-50

ni.com

Chapter 3 Software Overview
operation. In addition, the data acquisition functions DAQ_Start and Lab_ISCAN_Start cannot use counter B0 if the total sample interval for data acquisition is also greater than 65,535 µs, unless the timebase required for data acquisition is the same as the timebase counter B0 produces for waveform generation. If data acquisition is not in progress, counter B0 is available for waveform generation if ICTR_Setup has not been called on counter B0 since startup, or an CTR_Reset call has been made on counter B0. If data acquisition is in progress and is using counter B0 to produce the sample timebase, counter B0 is available for waveform generation only if this timebase is the same as required by the Waveform Generation functions to produce the total update interval. In this case, counter B0 produces the same timebase for data acquisition and waveform generation.
On the AT-AO-6/10, counter 0 produces the total update interval for group 1 waveform generation, and counter 1 produces the total update interval for group 2 waveform generation. However, if the total update interval is greater than 65,535 µs for either group 1 or 2, counter 2 is used by counter 0 (group

  1. or counter 1 (group 2) to produce the total update interval. If either group is using counter 2 to produce the sample timebase, counter 2 is available to the other group only if the timebase is the same as the timebase required by the Waveform Generation functions to produce the total update interval. In this case, counter 2 produces the same timebase for both waveform generation groups.
    FIFO Lag Effe

References

Read User Manual Online (PDF format)

Read User Manual Online (PDF format)  >>

Download This Manual (PDF format)

Download this manual  >>

NATIONAL INSTRUMENTS User Manuals

Related Manuals