[DAQBench Column]
  Developing Data Acquisition Applications with DAQBench (2003.04.16)

DAQBench is an ActiveX Control software that is suitable for measurement and automation application development. By using the properties, methods, and events of DAQBench ActiveX controls, signals from measurements or data acquisition applications can be controlled, monitored, analyzed and displayed. If utilized with ADLINK's data acquisition devices, configuration and operation of the device can be made extremely easy. Therefore development tine of data acquisition applications can be dramatically reduced.

DAQBench has four types of ActiveX controls:

  • User Interface ActiveX Controls
  • Information Integration Controls
  • Analysis Control
  • SCADA/HMI ActiveX Controls

These ActiveX controls can be used in any software development environment that supports ActiveX controls such as Visual Basic, Visual C++, Delphi, and C++ Builder, etc.

In addition to DAQBench, ADLINK also supplies alternative ActiveX controls for ADLINK devices:

  • PCIS-OCX: ActiveX Controls for NuDAQ PCI-Bus Data Acquisition Cards
  • NDS-OCX: ActiveX Controls for NuDAM Modules
  • MOTION-OCX: ActiveX Controls for Motion Control Cards
  • HSL-OCX: ActiveX Controls for HSL Modules

Sample Program

A Visual Basic sample program is used to illustrate how to implement a data acquisition application with DAQBench and PCIS-OCX ActiveX controls. A complete Visual Basic program, which accepts digital inputs and continuous analog inputs working with the PCI-9112 data acquisition card, and then displaying the data in a graphical form to a monitor is outlined.

Building a Data Acquisition Application with Visual Basic
The implementation procedure is as follows:

  • Installing the necessary software and hardware
  • Set the card device name to PCI-9112
  • Creating a new Visual Basic project and load necessary DAQBench and PCIS-OCX ActiveX controls
  • Set appropriate property values for DAQBench and PCIS-OCX ActiveX controls
  • Design the user interface for the application
  • Write the program code
  • Test the program
  • Application program completed

Installing Necessary Software and Hardware
To develop an application, the following software is needed:

  • Visual Basic: Visual Basic 4.0 or higher version. The following sample uses Visual Basic 6.0.
  • DAQBench
  • PCIS-OCX
  • ADLINK's NuDAQ PCI-Bus Data Acquisition Card: The sample program uses the PCI-9112.

Setting the Device Name

 

The NuDAQ PCI-bus card device name must be set before developing any application. Invoke the NuDAQ Config Utility fro the sub-directory of ADLINK PCIS-OCX.

the sub-directory of ADLINK PCIS-OCX.

The following window will be displayed:

All NuDAQ PCI-bus cards plugged into the system will be listed in the list box. Select the PCI-9112 and enter a name to associate with the device in the Device Name field. Here the PCI-9112 card is named TestDevice. Then click the Add button to return to the main window. Now a device named TestDevice will appear in the list box of the main window.

Click the Add Local Device button.。

Creating a New Visual Basic Project and Loading Necessary DAQBench and PCIS-OCX ActiveX Controls.

  • Invoke Visual Basic
  • Create a new "Standard EXE" project
  • Click the mouse's right button on the Toolbox, which is located on the left side of the Visual Basic window. A pop-up menu will appear. Select Components on the pop-up menu.
  • A dialog box listing all installed ActiveX controls will appear. Select the ActiveX controls needed:

  • ADLINK NuDAQ PCI Multi-Function Card ActiveX Controls
    DAQBench User Interface ActiveX Controls
    DAQBench Graphs ActiveX Controls
  • ClickOK
    On the Toolbox, you will find some new icons:

Setting the Property Values of DAQBench and PCIS-OCX ActiveX Controls
To operate the NuDAQ PCI-bus data acquisition card, first set the properties of the card's ActiveX controls. This is easily done through the property page of the ActiveX control.

1. Click the PCI-9112 ActiveX control icon from the Visual Basic Toolbox and drag it to a form. Click the mouse's right button on the ActiveX control. Select Properties on the pop-up menu to bring up the property page. Now the properties of the PCI-9112 can be set (Figure 1).

2. General page

  • Device Name is used to specify the device. Select the PCI-9112 device that the ActiveX control refers to. The Combo box automatically lists all PCI-9112 devices having been set in the device name of the system.
  • Open Mode is used to set the activation mode for the PCI-9112 device, either Automatic or Manual。 Automatic: The PCI-9112 device automatically activates when the program is invoked.
    Manual: Manually activate the card but calling the open function with the program.
    Setting: Select TestDevice in Device Name field.(as shown on Figure 1)

3. Channels page

  • Channel is used to set the analog input channel. Range is from 0-15.
  • Auto Scan is used to set the scan mode for the analog inputs. Auto Scan check box is checked (Autoscan=True): Automatically scans the channels for input of data. The PCI-9112 scans the channels in descending order. For example, suppose Channel=3, the input scan order is 3, 2, 1, 0, 3, 2, 1, 0…
    Auto Scan check box is not checked (Autoscan = False): Input data from a single channel. The PCI-9112 inputs data from the specified channel.
  • AI Range is used to set the range of the analog input.
    Setting: Use the default values

4.Buffer page

  • Number of scan is used to set the number of input data points per channel
  • Double buffer is used to set whether to use double-buffering mechanism for the input data or not. Double buffer check box is checked (DoubleBufferMode = True): The input data are store in a circular buffer. The HalfReady event occurs when the circular buffer is half-full or full. Data can be read from the buffer when the HalfReady event flag is issued. This mode is suitable for long-term data acquisition tasks.
    Double buffer checked box is not checked (DoubleBufferMode = False): The data acquisition operation stops when acquiring the specified amount of data.
  • Return data type is used to set the format of the input data. The available formats include binary raw data and scaled engineering unit data。
  • Stream to file is used to specify if data is stored to a file or not.
    Setting: Set the Number of scan to 1000. (See above)

5. Clock page

  • Clock source is used to set the clock source for the continuous analog input operation. IInternal: Use the timer pacer of the PCI-9112
    External: Use an external clock signal
  • Scan rate is used to set the scan rate, i.e. the sampling rate of each channel of the analog input.
    Setting: Use default values

6. Click OK to close the property pages dialog box.

  • Note: How to set the property values is discussed in the next section.

Designing the User Interface for the Application

1. Insert a DAQBench DGraph ActiveX controlon the form.
DGraph control is one of the DAQBench User Interface ActiveX Controls that allows for display of data with waveform styles. It can be use to plot analog data acquired from a data acquisition devices in a graphical form. The X-axis is the data points and the Y-axis represents the data value. One DGraph control is capable of having at most 8 overlaying plots displayed from 8 data sources.
Click the mouse's right button on the DGraph control. Then select Properties on the pop-up menu to bring up the property page. Now the properties of the DGraph control can be set (Figure 2).

From the Style page, select the prefer graph style. On the Graph page, set the display mode of the plots, the total number of plots, and the caption of the DGraph. Set the Caption to "Analog Input" as the DGraph control will display the analog input data acquired from the PCI-9112 card. On the X-Axis page, set the number of data to be viewed. Set it to 1000. On the Y-Axis page, set the data display range. Set the Minimum to -5 and Maximum to +5. On the Ticks page, set the tick format for the Y-axis.

2.Insert a DAQBench DBoolean ActiveX control on the form.
DBoolean control is one of the DAQBench User Interface ActiveX Controls that can be used to control or display Boolean values. It can be used to monitor or control the digital signals. For the purpose of this program, it will be use to monitor the digital input signal of the PCI-9112 card.
Click the mouse's right button on the DBoolean control. Then select Properties on the pop-up menu to bring up the property page. Now set the properties of the DBoolean control (Figure 3).

On the General page, choose the prefer style, color, and caption. Here enter "Digital Input" in the Caption field; Select the fourth style from the first row (round LED). From the Button page, set the total button number and the operation mode. Set the Number to 16 as the PCI-9112 has 16 digital inputs. Set Mode to Indicator mode because the control is used to display the input data, interaction with user is not necessary.

3. Insert a Command Button control on the form. Set the Name and Caption to cmdStartAI and Start AI respectively.

4.Insert a Timer controlon the form. It will be used to control the frequency of the digital input operation from the PCI-9112 card. For this program, it has been set for Interval to 200, meaning one digital input every 200 msec.

After completing the processes above, the form should appear as follows:

Writing the Program Code
After completing the user interface design, writing the program code can proceed.

  • CmdStartAI button is used to start the continuous analog input task of the PCI-9112 card. Double-click on the cmdStartAI control to bring up the Code window and add the following programming code to cmdStartAI_Click:
    Private Sub cmdStartAI_Click()
    Pci91121.StartContAI 啟動連續AI
    End Sub
  • When the specified amount of data is acquired, the Pci9112 control inserts an AiComplete event indicating the AI task has completed. The data is store in the arguments of AiComplete event. Then by using DGraph control the analog input data can be displayed. Double-click on the Pci9112 control to bring up the Code window and add the following programming code to Pci91121_AiComplete:
    Private Sub Pci91121_AiComplete(ScaledData As Variant, BinaryCodes As Variant)
    DGraph1.PlotGraph ScaledData, 0 Show analog input data on the DGraph control
    End Sub
  • (The timer control is used to control the frequency of the digital input tasks of the PCI-9112 card and refreshes the digital displayed data. Double-click on the timer control to bring up the Code window and add the following programming code to Timer1_Timer:
    Private Sub Timer1_Timer()
    Pci91121.ReadDIPort DI_data Input data from PCI-9112's digital port
    DBoolean1.Value = DI_data Set the value of the DBoolean's Value property to show the DI data
    End Sub
  • Save the form and the project.
  • Execute the program for a test run.

Summary

  • DAQBench and Visual Basic can be simply integrated. DAQBench can also be integrated with Visual C++, C++ Builder, and Delphi, etc.
  • DAQBench provides plenty of user interface controls. By using them, development of a user interface for an application can be very easily and quick.
  • By using PCIS-OCX, ADLINK's NuDAQ PCI-bus data acquisition devices can be easily controlled using codes that are easy to understand; therefore it can reduces programming time dramatically.