LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmx Task Deletion Concern

Solved!
Go to solution

So when I use the DAQmx Create Channel VI, it creates a task "unnamedTask xx" where xx is a hex number. Let's say I set the task state to verify. Now if these are in a loop, it will then create another task, using the same physical channel and because it is only reserve it will create another task, increment the unnamedTask by 1 and set it to verify. My question is, what happens to the previous task? Is it stored in memory? Or garbage collected. I would assume since the hardware is assigned to another task the previous one will be garbage collected. But I wanted to make sure. I have many tasks so if I can avoid using the clear task and simply overwrite it somehow that would be best I think. Thanks.

 

Brad

0 Kudos
Message 1 of 6
(3,072 Views)

Creating one more task using the same hardware does not delete previous task. It is possible to use task references to switch between them, provided that you unreserve hardware in time.

0 Kudos
Message 2 of 6
(3,064 Views)

That tasks exists until it's explicitly closed or the top level VI in which it was created stops running.  I usually use DAQmx Create Task.vi in the DAQmx Advanced Task Options palette to create and name my tasks, then add the channels.  This lets you reference tasks by name in subvis instead of running wires everywhere.  I highly recommend a typedef'd combobox for the names, much easier to keep track of.  Creating a new task for repeated measurements on the channel isn't very efficient, any reason you can't reuse the same task?


--Using LV8.2, 8.6, 2009, 2012--
0 Kudos
Message 3 of 6
(3,062 Views)

Well I have a case structure that has a "start up" case where it creates channels for all my different tasks, among all other resources like VISA, DIO, etc. If an error occurs in that start up routine, I have the user able to retry the last step, which would be start up, and it would create channels again. Since I never had a task to begin with, the first time it would create the task and save it to its class. If I tried using that task again in the start up routine, it would error out saying "Specified channel cannot be added to the task, because a channel with the same name is already in the task." Error 200489. And that is with me verifying the task, not reserving the resources.

0 Kudos
Message 4 of 6
(3,050 Views)
Solution
Accepted by BradD2

You can call DAQmx Clear Task.vi between Create Task and Create Channel, that'll clear any existing setup and won't error if the task doesn't exist yet.


--Using LV8.2, 8.6, 2009, 2012--
Message 5 of 6
(3,044 Views)

Thanks taper, should have thought of that.

0 Kudos
Message 6 of 6
(3,033 Views)