Example Code

Using Different Types of DAQmx Global Channels in the Same Task

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-DAQ™mx

Code and Documents

Attachment

Download All

Description

This example will show you how to read from multiple types of DAQmx global channels simultaneously within the same task in LabVIEW. It will also show you how to add multiple types of channels to a single DAQ Assistant.

How to Use

With NI-DAQmx 7.2 and earlier, you cannot add channels of different types to a task within MAX or within a single DAQ Assistant Express VI. To do this, you will need to use NI-DAQmx 7.3 or later; see link below for more information.

There is, however, a way to set up an acquisition to acquire data from different types of global channels in LabVIEW. Complete the following steps to set up the acquisition:

  1. Create and test the global channels in MAX.
  2. Open LabVIEW and place a DAQmx Global Channel control on the front panel.
  3. Click the arrow on the control for a list of channels. Select Browse. You can select multiple global channels by holding <Ctrl> and clicking the channels you want to use.


This allows you to have one acquisition to acquire data from different types of global channels.  The example program attached, MultipleChannels_Global.vi, illustrates how to use the DAQmx VIs to read from multiple DAQmx global channels simultaneously.

Another method of reading from multiple types of channels in one task is by wiring two or more DAQmx Create Virtual Channel VIs together in series in LabVIEW. Each of these VIs effectively adds one or more channels to the current DAQmx task. The advantage to this method is that the DAQmx Global Channels do not have to be configured in MAX prior to running the VI.  As seen below it is only necessary to wire the Task Out of the first VI to the Task In of the following VI, along with the Error Out to the Error In.  This method is also illustrated in the attached example program, MultipleChannels_Created.vi.
 
multiple_channels.png
In the above image, there are multiple Analog Input channels: Thermocouple, Voltage, and Accelerometer.  All of the channels are contained in the same task, and will have the same timing.  When the data is read from the device it will be in the form of an array of data where the first channels data will be indexed first.

It should be noted that all of the channels must be of the same overarching type, such  as Analog Input, and it is not possible to add an Analog Output channel to the same task as an Analog Input task.

Related Links

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

Contributors