PCIS-DASK Data Acquisition Software Development Kit For NuDAQ PCI-bus Cards, Windows NT/98/2000 User’s Guide
@Copyright 1997-2003 ADLink Technology Inc. All Rights Reserved. Manual Rev. 4.01: Mar. 07, 2003 The information in this document is subject to change without prior notice in order to improve reliability, design and function and does not represent a commitment on the part of the manufacturer.
CONTENTS INTRODUCTION TO PCIS-DASK............................................................................................................................1 1.1 A BOUT THE PCIS-DASK SOFTWARE ..................................................................................................................1 1.2 PCIS-DASK HARDWARE SUPPORT .....................................................................................................................2 1.3 PCIS-DASK LANGUAGE SUPPORT .....................
3.2.1 Creating a Windows NT/98/2000 PCIS-DASK Applications Using Microsoft Visual Basic ........................ 11 PCIS-DASK APPLICATION HINTS .......................................................................................................................14 4.1 A NALOG I NPUT PROGRAMMING HINTS .............................................................................................................. 15 4.1.1 One-Shot Analog input programming Scheme.................................................
7.1.2 Microsoft C/C++ Sample Programs ......................................................................................................... 59 7.2 EXECUTE SAMPLE PROGRAMS .......................................................................................................................... 59 7.3 THE DETAILED DESCRIPTIONS OF THESE SAMPLE PROGRAMS ............................................................................. 59 7.3.1 A/D conversion, D/A conversion, D/I, and D/O.........................
How to Use This Manual This manual is to help you use the PCIS-DASK software driver for NuDAQ PCI-bus data acquisition cards. The manual describes how to install and use the software library to meet your requirements and help you program your own software applications. It is organized as follows: ??Chapter 1, "Introduction to PCIS-DASK" describes the hardware and language support of PCIS-DASK.
1 Introduction to PCIS-DASK 1.1 About the PCIS-DASK Software PCIS-DASK is a software development kit for NuDAQ PCI-bus data acquisition cards. It contains a high performance data acquisition driver for developing custom applications under Windows NT, Windows 98 and Windows 2000 environments. The memory and data buffer management capabilities free developers from dealing with there complex issues.
1.2 PCIS-DASK Hardware Support ADLink will periodically upgrade PCIS-DASK for new NuDAQ PCI-bus data acquisition cards and NuIPC CompactPCI cards. Please refer to Release Notes for the cards that the current PCIS-DASK actually supports.
2 PCIS-DASK Overview This chapter describes the classes of functions in PCIS-DASK and briefly describes each function.
GetActualRate 2.3 Returns the actual sampling rate the device will perform for the defined sampling rate value. Analog Input Function Group 2.3.1 Analog Input Configuration Functions AI_9111_Config Informs PCIS-DASK library of the trigger source and trigger mode selected for the analog input operation of PCI9111. You must call this function before calling function to perform continuous analog input operation of PCI9111.
AI_ContReadChannel Performs continuous A/D conversions on the specified analog input channel at a rate as close to the rate you specified. AI_ContScanChannels Performs continuous A/D conversions on the specified continuous analog input channels at a rate as close to the rate you specified. This function is only available for those cards that support auto-scan functionality.
AO_6308A_Config Informs PCIS-DASK library of the current range selected for the analog output operation of PCI6308A. You must call this function before calling function to perform current output operation. AO_6308V_Config Informs PCIS-DASK library of the polarity (unipolar or bipolar) that the output channel is configured for the analog output and the reference voltage value selected for the analog output channel(s) of PCI6308V.
DI_ReadPort Reads digital data from the specified digital input port. 2.5.3 Continuous Digital Input Functions DI_ContReadPort Performs continuous digital input on the specified digital input port at a rate as close to the rate you specified. DI_ContReadPortToFile Performs continuous digital input on the specified digital input port at a rate as close to the rate you specified and saves the acquired data in a disk file.
DO_InitialMemoryAllocated Gets the actual size of digital output DMA memory that is available in the device driver. DO_GetView Gets the mapped buffer address of the digital output memory that is available in the device driver. 2.6.2 One-Shot Digital Output Functions DO_WriteLine Sets the specified digital output line in the specified digital output port to the specified state. This function is only available for those cards that support digital output read-back functionality.
CTR_Read Reads the current contents of the selected counter. CTR_Clear Sets the output of the selected counter to the specified state. CTR_Update Writes a new initial count to the selected counter. CTR_8554_ClkSrc_Config Sets the counter clock source. CTR_8554_CK1_Config Sets the source of CK1. CTR_8554_Debounce_Config Sets the debounce clock. 2.7.2 The General-Purpose Timer/Counter Functions 2.8 GCTR_Setup Controls the general-purpose counter to operate in the specified mode.
DIO_T2_EventMessage 10 ? PCIS-DASK Overview Controls Timer2 Interrupt and notifies the user’s application when an interrupt event occurs. The notification is performed through a userspecified callback function or the Windows PostMessage API.
3 Creating PCIS-DASK Application 3.1 Contiguous Memory Allocation in Driver for Continuous Operation The continuous data transfer functions in PCIS-DASK input or output blocks of data to or from a plugin NuDAQ PCI device. To avoid the data transfer performance reduction caused by memory fragment, PCIS-DASK allocates physically contiguous buffers in device driver at system startup time (windows 98) or when system boots (Windows NT/2000/XP).
Open a new project by selecting the New Project command from the File menu. If it is an existing project, open it by selecting the Open Project command from the File menu. Then the Open Project dialog box appears. Changed directory to the place the project file located. Double-click the project file name in the File Name list to load the project. step 2. Add file DASK.BAS into the project if this file is not included in the project.
The event code defines the action you want to perform when an event occurs. To write the event code, double-click the desired control or form to view the code module and then add code you want. You can call the functions that declared in the file DASK.BAS to perform data acquisition operations. step 6. Run your application. To run the application, choose Start from the Run menu, or click the Start icon toolbar (you can also press F5). on the step 7. Distribute your application.
4 PCIS-DASK Application Hints This chapter provides the programming schemes showing the function flow of that PCIS-DASK performs analog I/O and digital I/O. The figure below shows the basic building blocks of a PCIS-DASK application. However, except using Register_Card at the beginning and Release_Card at the end, depending on the specific devices and applications you have, the PCISDASK functions comprising each building block vary.
4.1 Analog Input Programming Hints PCIS-DASK provides two kinds of analog input operation ? buffered continuous analog input operation. nonbuffered single-point analog input readings and The non-buffered single-point AI uses software polling method to read data from the device. The programming scheme for this kind of AI operation is described in section 4.1.1. The buffered continuous analog input uses interrupt transfer or DMA transfer method to transfer data from device to user’s buffer.
4.1.1 One-Shot Analog input programming Scheme This section described the function flow typical of non-buffered single-point analog input readings. While performing one-shot AI operation, most of the cards (except PCI-9118 series cards) don’t need to include AI configuration step at the beginning of your application.
4.1.2 Synchronous Continuous Analog input programming Scheme This section described the function flow typical of synchronous analog input operation. While performing continuous AI operation, the AI configuration function has to be called at the beginning of your application. In addition, for synchronous AI, the SyncMode argument in continuous AI functions has to be set as SYNCH_OP. AI_xxxx_Config (xxxx means the card type, e.g.
AI_xxxx_Config (xxxx means the card type, e.g.
AI_xxxx_Config (xxxx means the card type, e.g.
4.1.5 Trigger Mode Non-double-buffered Asynchronous Continuous Analog input programming Scheme This section described the function flow typical of trigger mode double-buffered asynchronous analog input operation. A trigger is an event that occurs based on a specified set of conditions. An interrupt mode or DMA-mode Analog input operation can use a trigger to determinate when acquisition stop.
trigger is an event that occurs based on a specified set of conditions. An interrupt mode or DMA-mode Analog input operation can use a trigger to determinate when acquisition stop. The trigger mode data acquisition programming is almost the same as the non-trigger mode asynchronous analog input programming. Using PCIS-DASK to perform trigger mode data acquisition, the SyncMode of continuous AI should be set as ASYNCH_OP.
[Example Code Fragment] card = Register_Card(PCI_9118, card_number); … AI_9118_Config(card,P9118_AI_BiPolar|P9118_AI_SingEnded, P9118_AI_DtrgPositive|P9118_AI_EtrgPositive| P9118_AI_AboutTrgEn,0,postCount) AI_AsyncDblBufferMode (card, 1); Double-buffered AI AI_ContScanChannels (card, channel, range, ai_buf, data_size, (F64)sample_rate, ASYNCH_OP); or AI_ContReadChannel(card, channel, range, ai_buf, data_size, (F64)sample_rate, ASYNCH_OP) do { do { AI_AsyncDblBufferHalfReady(card, &HalfReady, &fstop); } whil
4.2 Analog Output Programming Hints This section described the function flow typical of single-point analog output conversion. While performing the following operation, the AO configuration function has to be called at the beginning of your application: a. Use PCI-6208A, PCI-6308A to perform current output b. Use the analog output function that can convert a voltage value to a binary value and then write it to device, the AO configuration function has to be called at the beginning of your application.
4.3 Digital Input Programming Hints PCIS-DASK provides two kinds of digital input operation ? buffered continuous digital input operation. non-buffered single-point digital input operation and The non-buffered single-point DI uses software polling method to read data from the device. The programming scheme for this kind of DI operation is described in section 4.3.1. The buffered continuous DI uses DMA transfer method to transfer data from device to user’s buffer.
4.3.1 One-Shot Digital input programming Scheme This section described the function flow typical of non-buffered single-point digital input readings. While performing oneshot DI operation, the devices whose I/O port can be set as input or out put port (PCI-7248 and PCI7296) need to include port configuration function at the beginning of your application.
Release_Card(card); 26 ? PCIS-DASK Application Hints
4.3.3 Non-double-buffered Asynchronous Continuous Digital input programming Scheme This section described the function flow typical of non-double-buffered asynchronous digital input operation. While performing continuous DI operation, the DI configuration function has to be called at the beginning of your application. In addition, for asynchronous DI operation, the SyncMode argument in continuous DI functions has to be set as ASYNCH_OP. DI_xxxx_Config (xxxx means the card type, e.g.
DI_xxxx_Config (xxxx means the card type, e.g.
DI_xxxx_Config (xxxx means the card type, e.g.
buffered continuous digital output operation and pattern generation. The non-buffered single-point DO uses software polling method to write data to the device. The programming scheme for this kind of DO operation is described in section 4.4.1. The buffered continuous DO uses DMA transfer method to transfer data from user’s buffer to device. The maximum number of count in one transfer depends on the size of initially allocated memory for digital output in the driver.
4.4.1 One-Shot Digital output programming Scheme This section described the function flow typical of non-buffered single-point digital output operation. While performing one-shot DO operation, the cards whose I/O port can be set as input or out put port (PCI-7248, PCI7249 and PCI-7296) need to include port configuration function at the beginning of your application.
Release_Card(card); 32 ? PCIS-DASK Application Hints
4.4.3 Asynchronous Continuous Digital output programming Scheme This section described the function flow typical of asynchronous digital output operation. While performing continuous DO operation, the DO configuration function has to be called at the beginning of your application. In addition, for asynchronous DO operation, the SyncMode argument in continuous DO functions for asynchronous mode has to be set as ASYNCH_OP. DO_xxxx_Config (xxxx means the card type, e.g.
[Example Code Fragment] card = Register_Card(PCI_7300A_RevB, card_number); … DO_7300B_Config (card, 16, TRIG_INT_PACER, P7300_WAIT_NO, P7300_TERM_ON, 0, 0x40004000); //start pattern generation DO_PGStart (card, out_buf, 10000, 5000000); … //stop pattern generation DO_PGStop (card); Release_Card(card); 4.4.5 Multiple-buffered Asynchronous Continuous Digital output programming Scheme This section described the function flow typical of multi-buffered asynchronous digital output operation.
… // start multi-buffered DO DO_ContMultiBufferStart (card, 0, 1); do { do { DO_AsyncDblBufferHalfReady(card, &HalfReady); } while (!HalfReady); // Copy prepared data to the ready buffer } while (!clear_op); DO_AsyncClear(card, &count); … Release_Card(card); PCIS-DASK Application Hints ? 35
4.5 DAQ Event Message Programming Hints DAQ Event Message functions are an efficient way to monitor your background data acquisition processes, without dedicating your foreground process for status checking. There are two kinds of events, which are AI/DI/DO operation completeness notification event and half buffer ready notification event.
4.6 Interrupt Event Message Programming Hints PCIS-DASK provides two methods to perform interrupt occurrence notification for NuDAQ DIO cards that have dual interrupt system. The Event Message method handles event notification through user-defined callbacks and/or the Windows Message queue (for VB5, through user-defined callbacks only).
… .. //wait for INT2 event if (WaitForSingleObject(hEvent[1], INFINITE) == WAIT_OBJECT_0) { ResetEvent(hEvent[1]); …… } … ..
5 Continuous Data Transfer in PCIS-DASK The continuous data transfer functions in PCIS-DASK input or output blocks of data to or from a plug-in NuDAQ PCI device. For input operations, PCIS-DASK must transfer the incoming data to a buffer in the computer memory. For output operations, PCIS-DASK must transfer outgoing data from a buffer in the computer memory to the NuDAQ PCI device.
5.2 Double-Buffered AI/DI Operation PCIS-DASK uses double-buffering techniques in its driver software for continuous input of large amounts of data. 5.2.1 Double Buffer Mode Principle The data buffer for double-buffered continuous input operation is a circular buffer logically. It is logically divided into two equal halves. The double-buffered input begins when device starts writing data into the first half of the circular buffer (Figure 6-1a).
The PCIS-DASK double buffer mode functions were designed according to the principle described above. If you use AI_AsyncDblBufferMode/DI_AsyncDblBufferModeto enable double buffer mode, the following continuous AI/DI function will perform double-buffered continuous AI/DI. You can call AI_AsyncDblBufferHalfReady/DI_AsyncDblBufferHalfReadyto check if data in the circular buffer is half full and ready for copying to the transfer buffer.
5.3 Trigger Mode Data Acquisition for Analog Input A trigger is an event that occurs based on a specified set of conditions. An interrupt mode or DMA-mode analog input operation can use a trigger to determinate when acquisition stops or starts. PCIS-DASK also provides two buffering methods for trigger mode AI – double-buffering and single-buffering. However, the single buffer in trigger mode AI is different from that in non-trigger mode AI.
6 PCIS-DASK Utilities This chapter introduces the tools that accompanied with the PCIS-DASK package. 6.1 NuDAQ Registry/Configuration utility (PciUtil) PciUtil is used for the users to register PCIS-DASK drivers (Windows NT4 only), remove installed drivers (Windows NT4 only), and set/modify the allocated buffer sizes of AI, AO, DI and DO. The default location of this utility is \Util directory. [PciUtil in Windows NT] The PciUtil main window is shown as the following window.
DMA or Interrupt transfer can be performed. It will induce an unexpected result in that DMA or Interrupt transfer performed exceeds the initially allocated size. After the device configurations of the driver you select is finished, click “OK” to register the driver and return to the PciUtil main window.
Using PciUtil to change the buffer allocated settings of one of the PCIS-DASK drivers, select the driver from the Registered Driver list and click “Modify… ” button and then a “Driver Configuration” window is shown as below. Inside the allocated buffer size fields of AI, AO, DI and DO are the originally set values. Type the value in the box corresponding to AI, AO, DI, or DO according to the requirement of your applications, and then click “OK” button.
[PciUtil in Windows 98] This utility is used to set/modify the allocated buffer sizes of AI, AO, DI and DO. The allocated buffer sizes of AI, AO, DI, DO represent the sizes of contiguous Initially Allocated memory for continuous analog input, analog output, digital input, digital output respectively. Its unit is page KB, i.e. 1024 bytes. Device driver will try to allocate these sizes of memory at system startup time.
[PciUtil in Windows 2000] This utility is used to set/modify the allocated buffer sizes of AI, AO, DI and DO. The allocated buffer sizes of AI, AO, DI, DO represent the sizes of contiguous Initially Allocated memory for continuous analog input, analog output, digital input, digital output respectively. Its unit is page KB, i.e. 1024 bytes. Device driver will try to allocate these sizes of memory at system startup time.
6.2 PCIS-DASK Data File Converter utility (DAQCvt) The data files, generated by the PCIS-DASK functions performing continuous data acquisition followed by storing the data to disk, is written in binary format. Since a binary file can’t be read by the normal text editor and can’t be used to analyze the accessed data by Excel, PCIS-DASK provides a convenient tool DAQCvt to convert the binary file to the file format read easily. The default location of this utility is \Util directory.
The data in hexadecimal is scaled to engineering unit (voltage, ample, … etc) according to the card type, data width and data range and then written to disk in binary file format. This type is available for the data accessed from continuous AI operation only. Binary codes to text file : The data in hexadecimal format or converted to a decimal value is written to disk in text file format. If the original data includes channel information, the raw value will be handled to get the real data value.
7 Sample Programs There are several sample programs provided in this software diskette. They could help you to program your own applications by using PCIS-DASK easily.
SDK7230Int D/I, and D/O of PCI-7230/cPCI-7230 by Interrupt Event Status checking and waiting method Visual C/C++ Program SDK7230DbEvt D/I, and D/O of PCI-7230/cPCI-7230 by Interrupt Event Status checking and waiting method (Dual Interrupt Events) Visual C/C++ Program SDK7230IntMsg D/I, and D/O of PCI-7230/cPCI-7230 by Interrupt Event Message method Visual C/C++ Program SDK7230DbEvtMsg D/I, and D/O of PCI-7230/cPCI-7230 by Interrupt Event Message method (Dual Interrupt Events) VB7230 D/I, and D/O of
VB7250 D/I, and D/O of PCI-7250/51 Visual Basic Program PCI-7252 SDK7252 D/I, and D/O of cPCI-7252 VB7252 D/I, and D/O of cPCI-7252 Visual C/C++ Program Visual Basic Program PCI-7256 SDK7256 D/I, and D/O of PCI-7256 Visual C/C++ Program SDK7256Int D/I, and D/O of PCI-7256 by Interrupt Event Status checking and waiting method Visual C/C++ Program SDK7256DbEvt D/I, and D/O of PCI-7256 by Interrupt Event Status checking and waiting method (Dual Interrupt Events) VB7256 D/I, and D/O of PCI-7256
SDK7300aMBufWav Multiple buffer mode digital input of PCI-7300A_Rev.B/cPCI-7300A_Rev.B through DMA transfer Visual C/C++ Program SDK7300Int Interrupt operation of PCI-7300A_Rev.B/cPCI-7300A_Rev.B by Event Status checking and waiting method Visual C/C++ program SDK7300DbEvt Interrupt operation of PCI-7300A_Rev.B/cPCI-7300A_Rev.B by Interrupt Event Status checking and waiting method (Dual Interrupt Events) Visual C/C++ Program C7300bDbfDO Double buffer mode digital output 7300A_Rev.
SDK7432DbEvt D/I, and D/O of PCI-7432/cPCI-7432 by Interrupt Event Status checking and waiting method (Dual Interrupt Events) Visual C/C++ Program SDK7432IntMsg D/I, and D/O of PCI-7432/cPCI-7432 by Interrupt Event Message method Visual C/C++ Program SDK7432DbEvtMsg D/I, and D/O of PCI-7432/cPCI-7432 by Interrupt Event Message method (Dual Interrupt Events) VB7432 D/I, and D/O of PCI-7432/cPCI-7433 Visual C/C++ Program Visual Basic Program PCI-7433 SDK7433 D/I of PCI-7433/cPCI-7433 Visual C/C++ s
C9111DbfFile 1.Double buffer mode analog input of PCI-9111 through Interrupt operation 2.
SDK9114DbfInt Double buffer mode analog input of PCI-9114 through Interrupt operation Visual C/C++ sample program C9114File 7.Analog input of PCI-9114 through Interrupt operation 8.Storing the data to disk Visual C/C++ console Program C9114DbfFile 7.Double buffer mode analog input of PCI-9114 through Interrupt operation 8.
SDK9118DbfDma Double buffer mode analog input of PCI-9118 through DMA data transfer Visual C/C++ Program SDK9118HRDbfDma Double buffer mode analog input of transfer PCI-9118HR through DMA data Visual C/C++ Program SDK9118ScanDma Autoscan Analog input of PCI-9118 through DMA data transfer Visual C/C++ Program SDK9118HRScanDma Autoscan Analog input of PCI-9118HR through DMA data transfer SDK9118DbfPreTrg Pre-trigger with Double buffer mode analog input of PCI-9118 through DMA data transfer SDK9118
SDK9812DelayTrg Delay trigger with Single buffer mode analog input of PCI-9812/cPCI-9812 through DMA data transfer Visual C/C++ Program SDK9812DbfMidTrg Middle trigger with Double buffer mode analog input of PCI-9812/cPCI9812 through DMA data transfer Visual C/C++ Program SDK9812DbfPreTrg Pre-trigger with Double buffer mode analog input of PCI-9812/cPCI-9812 through DMA data transfer Visual C/C++ Program SDK9812DbfPostTrg Post trigger with Double buffer mode analog input of PCI-9812/cPCI-9812 through
7.1 Sample Programs Development Environment 7.1.1 Visual Basic Sample Programs There are several Visual Basic sample programs provided for each card in this software package. The following files are included in each sample program (Using VB9112DMA as an example): ??VB project file --- VB9112D.VBP ??VB form files --- VB9112D.FRM ??Executable file --- VB9112D.EXE You must have 32-bit Microsoft Visual Basic 4.0 Professional Edition or above to deal with these sample programs.
Figure 7.2 Analog Input (A/D) : This is used to show the results of A/D conversion. You can select the Input channels (allows multiple channels) and the input range (gain) you want to test from the main screen. Analog output (D/A): This is used to show the results of D/A conversion. Turning the turner to set the output voltage. You can also choose the output waveform (sine or square). D/I and D/O: This is used to show the results of Read/Write data from/to digital input/output channels.
7.3.2 Data I/O through DMA Data Transfer or Interrupt operation This kind of programs is used to demonstrate how to use PCIS-DASK to operate data I/O through DMA data transfer or Interrupt operation. The main screen of this kind of programs is shown below (Figure 7.3): Figure 7.
In this kind of programs you can select Input channels, Input range (PCI-7200 does not have these two options), sampling rate, and data size (transfer count) as you wish. To view the input data, push “Data Value” button in the main screen as data transfer is finished (Figure 7.4). Figure 7.
7.3.3 Double buffer mode data I/O through DMA transfer or Interrupt operation This kind of programs is used to demonstrate how to use PCIS-DASK to operate double-buffered data I/O through DMA transfer or Interrupt operation. The screen of this kind of programs is shown below (Figure 7.5) : Figure 7.5 In this kind of programs you can select Input channel, input range (PCI-7200 does not have this two options), sampling rate, and data size (transfer count) as you wish.
7.3.4 Trigger Mode Data I/O through DMA Data Transfer or Interrupt operation This kind of programs is used to demonstrate how to use PCIS-DASK to operate Trigger Mode data I/O through DMA data transfer or Interrupt operation. Except an additional input item, postCount, the running steps and the main screen of this kind of programs (Figure 7.6) are almost the same as those mentioned in section 7.3.2 (For Single-Buffer Mode) or section 7.3.3 (For Double-Buffer Mode).
8 Distribution of Applications 8.1 Files To install an application using PCIS-DASK on another computer, you also must install the necessary driver files and supporting libraries on the target machine. You can create an automatic installer to install your program and all of the files needed to run that program or you can manually install the program and program files. Whichever installation method you choose, you must install the following files: ??Required support DLLs: – Pci-dask.
third-party tools such as InstallShield. Some programming environments provide simplified or trial versions of third-party installer creation tools on their installation CDs. The installation program not only copies all the required files into the appropriated location, but executes Device configuration utility to configure the devices. 8.3 Manual Installation If your programming environment does not include a setup or distribution kit tool, you can perform the installation task manually.