LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Close all DAQmx Base tasks

Hello
I am using the 600x Interactive Control vi as a starting point for some LV 7.0 programming. Sometimes when I cancel the program the tasks are left active. This is the only task on this computer. How Can I close all open tasks so that my program will start again? Closing LV is a bit tedious?
Thanks
John
0 Kudos
Message 1 of 7
(5,045 Views)
All you have to do is close all of the tasks that you have opened. This is a process that you need to get used to when you have finnished using a task or application or VI reference. To close the task use this VI located on the DaqMx - Acquisition pallet.

To close a reference you need to us the close reference VI on the Application control panel.
Tim
GHSP
Download All
0 Kudos
Message 2 of 7
(5,023 Views)
Thank you very much for taking the time to help me.

I guess that my problem is more discovering the name of the tasks that I have opened. Once I know that, then as you say it's easy to close them. The program structure that appeals to me is to start off my program by closing all open tasks. I am not at all clear how to do this. The example that comes with a USB 6009 does not start again if I cancel it. I have to exit LV to get it all cleared up.
0 Kudos
Message 3 of 7
(5,018 Views)

Hi jbrohan,

in which way do you cancel your vi? If you close it with the "RED" CANCEL Button it could be that there are some tasks open after stoping the vi. Or do you use the "X" Button of the window? You have to ensure that your program close all created tasks before it stops ruinning.

Mike

0 Kudos
Message 4 of 7
(5,011 Views)
John,

The DAQmxBase Create Task.vi block diagram (at least in the version I am using with LV 8.5) has a flow chart that shows some task checking by name. Digging down into that leads to a DAQmxBase get tasks.vi which simply calls the DAQmxBase globals.vi with the item Task Names selected.

Now, where they hide that global is a good question, but this may give you some ideas.

The nice thing about DAQmx Base is that it is almost completely written in G so you can see what is done. Unfortunately you sometimes have to go through about 900 subVIs to find what you are looking for.

Lynn
0 Kudos
Message 5 of 7
(4,994 Views)

Hello jbrohan,

I believe that aeastet, Mike S81, and johnsold have provided excellent suggestions and I just wanted to elaborate a little bit on what they’ve said.  It sounds to me like you are using the Abort button to exit your VIs as opposed to a stop button on a while loop.  As aeastet said, you need to clear all of the tasks you create at the end of your VI’s execution so that the program will run correctly the next time you run it.  Below is a screenshot of a typical data acquisition (DAQ) program.  If you use the abort button (top left in the screenshot) then program execution will stop immediately in the middle of the while loop and the clear task VI will not run.  However, if you use the stop button on the while loop that will stop the while loop and then the Clear Task VI will execute before it stops—thus properly closing the tasks.  In general is it not recommended to use the Abort button primarily because it causes the affects you have been seeing.

If for some reason you have extenuating circumstances that require the use of the abort button you should be able to call the DAQmxBase Reset Device VI at the start of your program.  This will clear all tasks associated with the device and reset it to an initialized state.  I want to stress that this is not a very good programming practice because it will leave the tasks active between subsequent executions of the code.  For instance if you have a digital output task and you use the abort button sometime during execution when the digital output is high then it will stay in this state until you run the program again and the Reset Device VI runs.  On the other hand if you use the stop button and the Clear Task VI the task will be closed at the end of the VI’s execution and the output states will be reset to their defaults immediately.

I hope that this explains a little bit of what is going on.  If I’ve misunderstood what it is that you are asking please reply back with more information so we can offer further suggestions.

Have a good night!



Message Edited by Brooks_C on 02-11-2008 07:17 PM
Brooks
0 Kudos
Message 6 of 7
(4,978 Views)
Thanks to everyone who wrote with valuable comments. The cancellation issue arises because I made a mistake elsewhere in the program. Defensive programming might suggest making sure the task is finished and clear before starting it.

Using your suggestions I now save the task and make it teh default value, and this I stop and clear before starting my main DAQ Module.

Thanks for your help
John
0 Kudos
Message 7 of 7
(4,963 Views)