Example Code

Programatically Create New DAQmx Task from Template 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.

    Hardware

  • Data Acquisition (DAQ)

    Software

  • LabVIEW

    Driver

  • NI DAQmx

Code and Documents

Attachment

Overview

This example shows how to programmatically create a DAQmx task from a template task (say a MAX task) under the requirements that I needed to pass in the Task name, Task reference and I may be using a different physical channel.

 

Description

This VI allows you to create one handle for all your tasks. If you take away the task requirement this can be done with just one property node (physical channel, when you commit the task but only on newer DAQmx cards, sorry SCXI do it this way).It`s useful to programatically create a DAQmx task under tight restrictions.Have implementations for every AI channel measurement type.

   

Requirements

  • LabVIEW 2012 or compatible
  • NI Multifunction DAQ Device.

 

Steps to Implement or Execute Code

  1. Create a Template Task (MAX).
  2. Add code snippet block diagram and provide the new task name, physical channel, and previous task name to use as a template.
  3. Execute as normal AI Task.

 

Additional Information or References

MAX Task.PNG

 

Note: 

If you are using a Windows 7 machine, the String Constant in the Volume Ctrl case of the Case Structure should be changed from "System32\sndvol32.exe" to "System32\sndvol.exe"

Tested Channels:Voltage, Current, Voltage RMS, Current RMS, Temperature (RTD, Vex and Iex Thermistor, Thermocouple), LVDT

 

 

Limitations

 

Only supports AI tasks currently. These channels types were tested originally and decided to add additional.

Need work to add other channel types AO, DI, DO, Counters.

TEDS channel type needs a way to sort by the simulated measurement type.

Rosette Strain Gage needs multiple channels to work.

Did not have a card to test frequency on Need to place two property nodes for hystersis and threshold.

 

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

 

Kyle Hartley
Senior Embedded Software Engineer

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