Transition from Traditional NI-DAQ (Legacy) to NI-DAQmx using Microsoft Visual Basic .NET

Overview

NOTE: This document is the first document in the series, Transition from Traditional NI-DAQ (Legacy) to NI-DAQmx Using Microsoft Visual Basic .NET. Refer to Links to Other Topics in this Series to access other documents in this series.

Contents

Transition from Traditional NI-DAQ (Legacy) to NI-DAQmx Using Microsoft Visual Basic .NET Series Introduction

This series aims to help you make the transition from using Traditional NI-DAQ (Legacy) and Microsoft Visual Basic 6.0 to NI-DAQmx and Microsoft Visual Basic .NET.

The Traditional NI-DAQ (Legacy) driver is being obsoleted. NI-DAQmx is the new, recommended driver that is designed for use with some of the newest data acquisition devices available from National Instruments.

NI recommends using the native .NET application programming interface (API) that is optimized for use with the .NET framework to create DAQ applications in Visual Basic .NET.
Refer to the Traditional NI-DAQ (Legacy) Overview and NI-DAQmx Overview sections for more information about the different solutions available to you.

This series assumes that you are familiar with creating data acquisition applications using the Traditional NI-DAQ (Legacy) CWDAQ ActiveX controls with Visual Basic 6.0. Even if you have not used the Traditional NI-DAQ (Legacy) CWDAQ ActiveX controls, you can use this document as an introduction to using the NI-DAQmx .NET API to create data acquisition applications in Visual Basic .NET.

National Instruments provides several solutions for developing data acquisition applications (DAQ). The following table lists options available to you based on the current versions of NI data acquisition drivers and Visual Basic.



Accessing Help in NI-DAQmx


This series references two main types of reference manuals that ship with NI-DAQmx.

  • NI-DAQmx Core Help--references the language agnostic manual for NI-DAQmx. The NI-DAQmx Core Help explains NI-DAQmx concepts and provides a background about the various features and capabilities of the driver. Refer to Start » Programs » National Instruments » NI-DAQ » NI-DAQmx Help to access this manual.
  • NI-DAQmx .NET Help--references the manual for the .NET DAQmx API. This reference is specific to the .NET API and provides documentation for NI-DAQmx classes, methods, and properties. There are also concept topics in this manual which are specific to using the NI-DAQmx .NET API. This help is integrated into the Visual Studio .NET documentation. In Visual Studio .NET, select Help»Contents. To view the NI-DAQmx .NET Library help, select NI Measurement Studio Help»NI Measurement Studio .NET Class Library»Reference»National Instruments.DAQmx. For tasks and concepts, select NI Measurement Studio Class .NET Library»Using the Measurement Studio .NET Class Libraries»Using the Measurement Studio NI-DAQmx .NET Library.
    See Also:
    Microsoft Visual Basic Developer Center

Traditional NI-DAQ (Legacy) using CWDAQ ActiveX Overview

The CWDAQ controls are organized based on the type of operation they perform. The following table provides an overview of the available controls.


NI-DAQ ActiveX control
Purpose
CWAIPointAcquires one point of data from one or more analog input channels to monitor slowly changing processes, such as temperature. Use CWAIPoint methods such as SingleRead to acquire a software-timed measurement from the configured device.
CWAIPerforms continuous hardware timed acquisition operations with various configuration operations. You can use this control to acquire data from one or more channels and to configure many different modes, such as start and stop triggers, pause conditions, and different channel and scan clocks. Use this control for applications that require high sampling rates on multiple points per channel, such as frequency analysis.
CWAOPointPerforms single-point software-timed analog-output operations. Updates one or more analog output channels for slow process control systems, such as setting a control output.
CWAOPerforms hardware-timed analog-output operations with various configurations. The waveform generation can be run in a continuous or finite mode. Use this control for applications that require dynamic analog signals, such as testing of analog devices.
CWDIOPerforms single-point updates or reads on the digital lines of a data acquisition device. You can use the CWDIO control to control the state of a physical device (such as a valve, relay, or LED) or read the current state of a similar device (such as a switch or light gate).
CWDOPerforms buffered digital waveform output. You can generate a digital pattern from the digital outputs at a rate specified by an external signal or internal clock.
CWDIPerforms buffered waveform digital input. You can acquire data from your digital input at a rate specified by an external signal or internal clock.
CWPulseGenerates individual pulses and pulse trains with the counter/timer component on a data acquisition device.
CWCounterCounts or measures incoming digital pulses using the counter/timer components on a data acquisition device. Typical operations include counting a number of events, measuring the period of an unknown pulse, or measuring the frequency of a signal.
CWDAQToolsA utility control for Traditional DAQ. This control provides functions for scaling transducer values and configuration options not present in the other controls.


These controls are designed for Visual Basic 6.0 and are organized based on the hardware operation that is required. Because of the way the controls are organized, it is not always intuitive which controls should be used for a specific measurement task. You must ensure that the acquired data is processed correctly to provide meaningful results, since the CWDAQ controls are not aware of the kind of measurement being made or whether the data acquired is coming from an RTD, thermocouple, or other transducer type. For example, if you require a strain measurement, you must ensure that the correct excitation is applied, scaling is correct, and that all the strain gauge parameters are set correctly. You also need to manage any scaling or unit conversion. These settings are not directly configurable using the CWDAQ controls.
Due to the nature of Visual Basic 6.0 and some limitations of Traditional DAQ, creating multi-threaded, object-oriented DAQ applications with the Traditional NI-DAQ (Legacy) CWDAQ controls is a complex process.

The following section introduces the NI-DAQmx driver and the NI-DAQmx .NET API and describes some of the advantages provided over Traditional NI-DAQ (Legacy) and the CWDAQ ActiveX controls.

See Also:
Answers to Frequently Asked Questions about NI-DAQmx and Traditional NI-DAQ (Legacy)
What are the Terminology Changes in NI-DAQmx?

 NI-DAQmx .NET overview

NI-DAQmx is the new NI data acquisition driver framework that addresses several weaknesses that were present in Traditional NI-DAQ (Legacy). Some of the advantages include the following:


 

Performance

  • NI-DAQmx provides significant performance improvements over Traditional NI-DAQ (Legacy), especially for single-point software-timed analog input.

Measurement based API

  • The API for NI-DAQmx revolves around the type of measurement that is made. The API provides abstraction that allows you to specify what hardware will do based on the measurement. The measurement based API is in contrast to Traditional NI-DAQ (Legacy), which allows you to specify what the hardware will do based on the hardware subsystem.

Multithreaded Driver

  • Using the NI-DAQmx driver, concurrent I/O operations is easy to setup, and you can create multithreaded data acquisition systems without much additional work.

Improved State Model

  • NI-DAQmx defines and enforces a state model, which eliminates unnecessary reconfigurations of input limits, timing, triggering, and accessories. This improvement significantly increases overall performance.

Consistent API across all programming languages

  • The NI-DAQmx programming paradigm is consistent across multiple languages. Because of this consistency, you will not have to reacquaint yourself with NI DAQmx driver concepts if you decide to move between programming NI-DAQmx in LabVIEW, LabWindows/CVI, and Measurement Studio.

Robustness in exceptional conditions

  • Traditional NI-DAQ can have difficulty handling exceptional conditions, like abnormal process termination. NI-DAQmx defines and enforces policies for such conditions and is much more robust than Traditional NI-DAQ (Legacy).


The NI-DAQmx DAQ framework introduces several new concepts, the two most important being Tasks and the Task State Model.



We will see how tasks are set up as we discuss the DAQmx .NET API in the following sections.

Task State Model

NI-DAQmx uses a task state model to improve ease of use and speed up driver performance. The task state model consists of five states—Unverified, Verified, Reserved, Committed, and Running.

You can choose to interact with as little or as much of the task state model as your application requires.

For more information about the task model of DAQmx, select NI-DAQmx Help » Key NI-DAQmx Concepts » Tasks » Task State Model in the NI-DAQmx Core Help.

The NI-DAQmx Help provides information about some of the other concepts of DAQmx as well. For more information, select NI-DAQmx Help » Key NI-DAQmx Concepts in the NI-DAQmx Core Help.

Migration from Visual Basic 6.0 to Visual Basic .NET


Visual Basic .NET has several new language features such as inheritance, interfaces, full multithreading support and structured exception handling that makes it possible for a Visual Basic developer to create multi threaded, scalable applications. You must be familiar with Visual Basic .NET to apply these new features in your applications.

This document will not discuss Visual Basic 6.0 migration to Visual Basic .NET. This migration process is not a trivial one. The Visual Basic .NET language is not backwards compatible with the Visual Basic 6.0 language. There are several resources available on the Microsoft Developers Network (MSDN) that will guide you through the new features in Visual Basic .NET and guide you through migrating applications that were created using Visual Basic 6.0. Refer to Reference section for more information.

Typical NI-DAQ Application

When framing a DAQ application, irrespective of the type of driver or device used for acquiring data, you organize the application into five main steps. The approaches to these five steps will vary based on how the data acquisition driver is organized and the functionality it provides. These steps include the following:

1. Identifying your Measurement
2. Configuring your measurement
3. Running the data acquisition operation
4. I/O
5. Cleanup

These steps provide the basic building blocks for creating a typical data acquisition application. You should be familiar with how a DAQ application uses the DAQ driver to address each of these steps to create a robust data acquisition application. We compare the NI-DAQmx .NET API with the Traditional NI DAQ (Legacy) CWDAQ controls by breaking down their functionality into these five steps. We discuss these steps in the other documents in this series. Refer to the Links to Other Topics in this Series section to access these documents.

Installation Instructions for the .NET NI-DAQmx API




The DAQmx .NET API is available as a part of the NI-DAQ driver. Installing support for the .NET languages install the DAQmx assemblies, shipping examples and the API reference and concept documents. The .NET API is available for free as part of NI-DAQ.

VB.NET Shipping Examples for DAQmx 

C# and VB.NET shipping examples for the DAQmx .NET API are installed as part of the language support and are available under ..\National Instruments\MeasurementStudio2003\DotNET\Examples\DAQmx for Visual Studio .NET 2003 and ..\National Instruments\MeasurementStudio2005\DotNET\Examples\DAQmx for Visual Studio 2005.

NI-DAQmx Quick Start Guide

The NI-DAQmx Quick Start Guide is a great document to get your DAQ system up and running. It provides an introduction to setting up and installing NI-DAQ devices on your machine and also provides information about the various programming interfaces available for NI-DAQmx. To find out information about the programming interfaces and how to get started with them, refer to the Getting Started Developing an Application section in the NI-DAQmx Quick Start Guide. You can find the Quick Start Guide from Start » Programs » National Instruments » NI-DAQ » DAQ Quick Start Guide.

Identifying Your Measurement


Before any code can be written, you need to identify what kind of measurement is required.

Are you measuring temperature, strain, position, or something else? Are you using external sensors that need calibration or excitation? Will the sensor data require scaling of any kind?

Once you have a good understanding of the type of measurement you will be making, the next step is to configure the operation. Refer to Transition from Traditional NI-DAQ (Legacy) to NI-DAQmx using Microsoft Visual Basic .NET: Part Two for information on configuring your operation.

Was this information helpful?

Yes

No