Example Code

Using a Virtual Channel in LabVIEW with NI-DAQmx

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

    Driver

  • NI-DAQmx

    Other

  • Measurement & Automation Explorer (MAX)

Code and Documents

Attachment

Description

A virtual channel is a collection of settings such as a name, a physical channel, input terminal connections, the type of measurement or generation, and can include scaling information.

In NI-DAQmx, virtual channels are integral to every measurement. You can create virtual channels with the DAQmx Create Channel VI or with the DAQ Assistant. You can also use the DAQ Assistant, accessible from Measurement & Automation Explorer or NI application software, to configure channels and measurement tasks. 

How to Use

  1. Open the Measurement & Automation Explorer by going to Start » All Programs » National Instruments » Measurement & Automation

  2. Open LabVIEW  Start » All Programs» National Instruments » LabVIEW » LabVIEW.

  3. Open the VI attached to this document, found in the Attachments section.

  4. Select a Global Virtual Channel

  5. Set the rate for the sample clock. Additionally, define the sample mode to be continuous.

  6. Call the Start VI to start the acquisition.

  7. Read the waveform data in a loop until the user hits the stop button or an error occurs.
    Note: This example reads data from one or more channels and returns an array of data. Use the Index Array function to access an individual channel of data.

  8. Call the Clear Task VI to clear the Task.

  9. Use the popup dialog box to display an error if any.

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.