LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem using DAQ assistant

I have an application where I am using DAQ assistant within a VI to control a DAC on a National Instruments PXI card.  At the end of the VI I use DAQmx Stop Task and DAQmx Clear Task to close the task.  The VI works fine if I run it by itself, however if I call the VI from our homebrew test executive, it only runs fine the first time.  Subsequent calls to the VI result in error code -200429.
 
Documentation on DAQmx Clear Task states "You cannot use a task after you clear it unless you recreate the task".  I think this is my problem.
 
What is the easiest way to fix this problem?
 
Should I delete DAQmx Clear Task (if I do this are there memory leak repercussions)?
 
Should I convert the DAQ assistant (Express VI) to a standard subVI, and then modify the created standard subVI to ensure the task is recreated?
 
0 Kudos
Message 1 of 11
(4,641 Views)

I guess you are deleting the task inside the subvi which is being called again and again. Try using the clear task Vis out of the continous loop(if you have one)

 

You need not change the DAQmx express VI. Only wire the DAQmx tasks out of the sub Vi and clear these tasks in your Main VI after the stop button is pressed.

You can see the way DAQmx tasks are used on any of the DAQmx examples shipped with Labview.

Hope it makes sense to you.

Attach your vi if possible.

Regards

Regards

CLAD
Using Labview 5.1,6.1,7.1.8.0
0 Kudos
Message 2 of 11
(4,630 Views)

It really in not very practical for me to wire the DAQmx task out of my subvi and to clear the task in my main vi after the stop button is pressed.  I actually have 84 test vis with this problem, some with multiple DAQmx tasks.  It seems unreasonable to have my test executive keep track of what each test vi is doing and to clear any tasks created just prior to stopping.

What are the consequences of not using DAQmx Clear Task?

Can I force LabView to reload the subvi each time I call it?

0 Kudos
Message 3 of 11
(4,623 Views)

If I am inderstanding your problem right, you want to create tasks dynamically evertime you open your application and clear them before you start runnning application again.

 

I have attached a screenshot of what I am trying to tell you.

Let me know if that works for you.

 

Regards

CLAD
Using Labview 5.1,6.1,7.1.8.0
0 Kudos
Message 4 of 11
(4,614 Views)
My test executive calls a subvi based on a user selection.  The user selects a test and the associated subvi is executed.  Inside the subvi, I create and close a DAQmx task (in some case multiple tasks) as you show in the screen shot you sent to me.  Bear in mind that the test executive never stops running.  The operator is free to run the same test a second time.  However, since the DAQmx task was cleared the first time the associated subvi was called, I get error code -200429 on any subsequent selection.
 
What I want to do is create tasks dynamically inside a subvi every time my test executive calls that particular subvi.
0 Kudos
Message 5 of 11
(4,611 Views)
Creating tasks does take up memory, and clearing them does free that memory, however if in your case, you need those tasks to remain available to you, then just stopping them might be a better option.  I wouldn't think that this would be cause for memory concern, as their footprint (as I understand it) is quite small.

As far as speed performance is concerned, you would be better off not creating, starting, stopping, clearing, each time you run your sub-vi's.  Create each task ONCE, and then start them and stop them before and after they enter a collection/command loop.
0 Kudos
Message 6 of 11
(4,605 Views)

My test vis (subvis to my test executive)  are ment to be completely self-contained.  I would like any necessary DAQ tasks to be created at the start of the subvi and closed prior to returning to the test executive.  Performance is not an issue.  The slowest part of the operation is the operator selecting the test.

What I find very frustrating is that I clear the tasks I create within my test vis, but if I call the same test vi from my test executive a subsequent time, DAQ Assistant will not create a new task.  If I want DAQ Assistant to create a new task, then I have to stop my test executive and then restart.  DAQ Assistant will only create a new task the first time it is called.

How can I force LabView to reload a subvi whenever is called?

0 Kudos
Message 7 of 11
(4,598 Views)
If you would just right click on the DAQ Assistant and select Open Front Panel, you could look at the code and see what is causing this. The Create Task is inside a case statement wired to a 'First Call' function. When you click the run button, this is a first call and this is what you do when you run the VI stand-alone. When you have it as a subVI and keep it in memory by your test exec, you only have a First Call true the very first time the test exec runs it. While using the DAQ Assistant can save you some time, in cases like this it is better to use the DAQmx functions directly. You have better control over what is going on.
Message 8 of 11
(4,593 Views)
Thanks for your help.  This isn't what I want to hear, but I guess I will just have to deal with it.
0 Kudos
Message 9 of 11
(4,556 Views)
It might help you to hear that DAQmx has automatic code generation that you can access directly from the DAQ Assistant. Just right click on the DAQ Assistant in your test executive and click on Generate DAQmx Code. It will create the configuration and read information usually stored inside the Express VI directly in your test executive subVI.

It might need a little tweeking, but it will help you remedy the problem Dennis described of only creating the task on the first run.

P.S. You can use automatic DAQmx code generation by right clicking any DAQ Assistant or DAQmx Name control (such as a task). Hope this helps!
Jarrod S.
National Instruments
0 Kudos
Message 10 of 11
(4,548 Views)