From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Example Code

Modify Unsupported Channel Properties Using LabVIEW with 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.

    Hardware

  • Data Acquisition (DAQ)

    Software

  • LabVIEW

    Driver

  • NI DAQmx

Code and Documents

Attachment

Overview

This example demonstrates how you can create a single DAQmx Task that combine different kinds of acquisition, whilst allowing you to modify properties which could be unsupported in some of the channels.

 
Description
In this example, we'll be performing two different kinds of acquisition; Analog Voltage Input via a NI-9221 and Analog Current Input via a NI-9219. The NI-9219 supports the modification of its ADCTimingMode property (In this instance we will be setting it to High Speed), however the Analog Voltage channels do not. As these channels are part of the same task, depending on the order of execution of the property modification, errors can be thrown if we're not careful.

The snippet below allows us to see the following:

  • By modifying the ADCTimingMode property to the AI Current Channels (a supported function) before initializing the AI Voltage task, we only modify this property for the Current channel. Therefore, by subsequently adding this AI Voltage channel to the task, it essentially misses out on this command.
  • You'll see after instantiation of the AI Voltage channel, I've included a case structure which contains another ADCTimingMode property modification in the True case (In the False case, the task and error wires are wired straight through). Therefore, when entering the True case, because the unsupported channel has since been added, an error will be thrown due to the task containing a channel which can't support this property. If we enter the false case, the task will continue as normal.

I've attached the VI shown in the VI Snippet for you to play around with. You'll probably need to simulate the appropriate modules from the Measurement and Automation Explorer (MAX) in order to derive the appropriate functionality from this code.

 
Requirements

  • LabVIEW 2012 (or compatible)
  • NI DAQmx 12.0


Steps to Implement or Execute Code

  1. Unzip the attached folder to your computer
  2. Open the VI "High Resolution Current Measurements 2012 NIVerified"
  3. Run the program

 

Additional Information or References
VI Snippet

 3-181.png

**This document has been updated to meet the current required format for the NI Code Exchange.**


Alex Thomas, University of Manchester School of EEE LabVIEW Ambassador (CLAD)

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

Comments
Theo_K
Member
Member
on

Would not the property in the True case overwrite the High Speed setting of the current inputs since the current inputs task has already initialised?!

Assuming that both devices support the ADCTimingMode property, I want to be able to set the Current Input device to 'High Speed mode' and the Voltage Inputs device to 'High Precision' mode, or vice versa. Will the code shown above do it?

I found the following instruction in the link below. Would this be the solution?

"When setting AI Convert instances of the DAQmx Timing attribute/property, you must use the ActiveDev attribute/property to specify the device to which you are referring."

http://zone.ni.com/reference/en-XX/help/370466AC-01/mxdevconsid/cdaqtimingconsiderations/