Example Code

Switch Between DAQmx Tasks with an External Trigger in LabVIEW

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 demonstrates how to switch between two different tasks using an external (Hardware) trigger.

 
Description

An example of a use for such a program is if you need to acquire at a slower rate during one part of a test and a faster rate for another part and you want to switch between these using a hardware trigger. The VI given here switches from one analog input task to another based on a rising or falling edge of a hardware trigger. The VI will run indefinitely and switch tasks on every edge of the trigger. The VI only shows 1 channel for each task, but more channels can be added to each task.

NOTE: This VI uses finite acquisition sampling. It does not and WILL not work for continuous acquisition sampling. This is because the trigger used is a reference trigger and continuous acquisitions cannot be used with reference triggers.


Requirements

  • LabVIEW 2012 (or compatible)


Steps to Implement or Execute Code

  1. Select the physical channel to correspond to where your signal is input on the DAQ device. Enter the minimum and maximum voltage ranges. Note:  For better accuracy try to match the Input Ranges to the expected voltage level of the measured signal. Select the physical channels you would like to acquire from for each task.
  2. Select the number of Samples per Channel to acquire and the rate of the acquisition for each task. Note:  The Rate should be AT LEAST twice as fast as the maximum frequency component of the signal being acquired.
  3. Set the trigger source and the polarity of which edge you want the first task to stop on, the second task will automatically take on the opposite edge to stop on.

 

Additional Information or References
VI Snippet

007.png

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

Product Support Engineer
National Instruments

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