Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Checking for valid task names in NI-DAQ Base

Solved!
Go to solution

Hi,

 

I have a question about setting up tasks in the Base version of NI-DAQmx (I need Base because the application will have to be able to run on both Windows machines and Macs). Hardware is a USB-6009, controlled via LabView. When creating a task inside LabView, is there any way to tell whether the chosen name is already in use or not?  Similarly, is there a way of getting a list of what if any tasks are running?

 

The context is that I have a subroutine which does a brief burst of analog input acquistion and then passes the result back up to the caller. I'd also like the subroutine to be able to run stand-alone for various testing purposes. Normally, I would have the subroutine create and configure a task, do the measurement, and then close the task. The problem is that the create/configure/start process takes about 200-250 milliseconds (the measurement itself is ~20 ms) which is long enough that I don't want to go through it each time the subroutine is called from above (I need to call this routine plus do some other stuff a few times a second). So, what I'd like to is have the task name as a control on the subroutine, test wether the value is a currently-valid task, and if it's not valid do the initialization/etc. in the context of the subroutine, but if the subroutine has been passed a valid task from above to skip all that time-consuming step. 

 

Looking through all of the functions in NI-DAQ Base, there doesn't seem to be anything that lets me do that sort of check except for the brute-force approach of trying to create a task and then trapping any errors that might be generated. 

 

Suggestions (or alternative approaches) welcome.

0 Kudos
Message 1 of 7
(4,989 Views)

Have you looked at the getting started guide? In section 6 it talks about the different ways to create tasks in NI DAQmx Base. 

 

http://www.ni.com/pdf/manuals/371259h.pdf

 

If you use the Task Configuration Utility, you can look at all the tasks you've created in there. Does that help?

 

- Kelsey

Kelsey W.
National Instruments
Applications Engineer
0 Kudos
Message 2 of 7
(4,972 Views)

The task configuration utility doesn't seem to work for me (this is NI-DAQmx base 3.6 for OS X, which is the newest version that is stated to work with LV 2009). I can create a task without a problem, but if I'm in LabView and I try to activate one of the preconfigured tasks (or one that I've created) it gives me an error. Creating/configuring the task from within LabView is working; I just would prefer not to have to do it every time I execute the master loop.

0 Kudos
Message 3 of 7
(4,965 Views)

Does this work for you? You can compare the task name passed to the subroutine to the list of all tasks. If the indexing returns a value of the index, you know the task has already been created.

Kelsey W.
National Instruments
Applications Engineer
0 Kudos
Message 4 of 7
(4,938 Views)

Hi Kelsey,

 

Unfortunately, that code doesn't seem to work on my system. Running it, I am prompted to located the shared framework 'nilvaiu.framework', which doesn't seem to be part of the NI-DAQ install on my machine. If I cancel out of the dialog box, the property node executes but simply returns an empty array. 

0 Kudos
Message 5 of 7
(4,936 Views)
Solution
Accepted by dmsilev

Kelsey,

 

It looks like the property node is a DAQmx component, not a DAQmx Base component.  I cannot find any DAQmx Base property nodes.

 

dmsilev,

 

Try replacing the Tasks property node with the DAQmx Base get tasks.vi.  It is not on the DAQmx Base palette. It is a subVI of DAQmx Base Create Task.vi.  One caution: When using a subVI which is not on the palettes, be aware that they are usually not documented well and are subject to changes in future versions of LV.

 

DAQmx Base.png

 

If you were not aware, DAQmx Base is written in LV and almost all of the block diagrams are not p[rotected so you can look inside and see how things are done.

 

Lynn

Message 6 of 7
(4,929 Views)

Hi Lynn,

 

That worked. Thank you very much both for the specific suggestion and the pointer to digging through the source for additional nuggets.

 

Best,

Daniel

0 Kudos
Message 7 of 7
(4,911 Views)