Example Code

Save Task to MAX Programatically and Perform DAQmx Read in SubVI

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 VI creates and saves a task to MAX and then reads from that task in a subVI.

 

Description

This VI allows you to create and save a task to MAX and then perform DAQmx functions in a subVI.
 

Requirements

Software

  • LabVIEW 2012 or compatible
  • NI-DAQmx 9.5.5 or compatible

Hardware

  • NI Multifunction DAQ Device

 

Steps to Implement or Execute Code

  1. First, go into the block diagram of the main VI and change the new task name for the DAQmx Create Task to what you want the task to be named.  Do the same for the DAQmx Create Virtual Channel.

  2. The first time you run this program, change the boolean to create new task or channel to true.  This will create your task and channel and save them to MAX.  Once they are created the first time, change the boolean to false.

  3. Before running again, make sure that the false case I/O constant in the main VI is set to your created task.

  4. Also before running again, open up the sub VI and in the task/channels in, choose the task that you would like to reference.

  5. From here, you should be able to run the main VI as many times as you would like.  You will also be able to run the subVI by itself without the main VI running.

  6. If you would like to erase your task from MAX before you close out the program, change the boolean for Delete Task from MAX? to true and run the VI.

 

Additional Information or References 

Main VI:

 

搜狗截图17年01月21日2208_11.png

 

SubVI:

 

DAQmxSubBD.jpg

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

Applications Engineer
National Instruments

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