Example Code

Make Dissimilar Measurements with Limited Resources Using 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 program exploits the DAQmx Task State Model to use the same hardware resource for two different DAQmx tasks.

 
Description
When multiple tasks are executed on a device that lacks the ability to run tasks in parallel, error -50103 often results. An easy workaround is to use global channels (http://search.ni.com/nisearch/app/main/p/bot/no/ap/tech/lang/en/pg/1/sn/ssnav:dzn/q/global%20channel...) and separate the incoming measurements using functions from the LabVIEW array palette. However, in situations where the DAQmx create global channels function is not an acceptable solution, the attached code can provide an effective alternative. One's first impulse may be to repeatedly start and stop the two tasks, alternating between each one. Unfortunately, the time it takes to stop and then start each task between loop iterations creates an undesirable delay in execution time. The work-around presented here is based on the start-and-stop principle, but makes extensive use of the Control Task VI from the "DAQmx Advanced Task Options" sub-palette. Instead of stopping each task which kicks the resources back to an unverified state, it simply unreserved the resources of one of the tasks so they may be used in the other. This method has been benchmarked to ensure that it would perform better than stopping and starting the two tasks. The Control Task method presented here took five seconds less to perform the same measurements than using DAQmx Start and DAQmx Stop when run for 1000 iterations. Again, if global channels are a tenable solution, you should use them instead. The Control Task VI is a direct way to step through the stages of the DAQmx Task-State model.  More information on the task-state model may be found in DAQmx Help.

 
Requirements

  • LabVIEW 2012 (or compatible)
  • NI DAQ-mx 12.0 (or compatible)


Steps to Implement or Execute Code

  1. Select the device or physical channels you pick.
  2. Run the program

 

Additional Information or References
VI Snippet

3-156.png

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

Matthew H.
Applications Engineer
National Instruments

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

Comments
James_McN
Active Participant Active Participant
Active Participant
on

Nice use of the DAQmx state model, there is a lot that goes on under the hood that many people don't realise.

There is another way to do this though which is similar to global channels but they don't have to be global. You can call the create channel VI twice on a single task to add one voltage and once current channel to one task, then as you point out you must split the array that you get back. This will enable hardware timing on the task as well.

James Mc
========
CLA and cRIO Fanatic
My writings on LabVIEW Development are at devs.wiresmithtech.com
Not applicable
on

Yes..I a agree with you views..But, I did not get your point "There is another way to do this though which is similar to global channels but they don't have to be global".Can you explain me...

free job posting websites in india