LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

about using global task

Solved!
Go to solution

Hi there,

  I have been using labview 7 for long time and I didn't use task. Recently, I swtiched to CVI and that I created all need tasks upon the start of the application and reuse the tasks before the end of the application. Last week, I got a copy of labview 2013 and I am porting the old labview code to 2013. However, I came to a problem. Different from the compiled C code, the vi code need to be run each time when needed, if I create the task on the fly in the vi, it is pretty heavy. I would like to create the global tasks so it could be used everywhere anytime. The example found in NI said I could create those tasks in MAX. So my question is to use the task, do I only have to specify the name of task (created in MAX) as the IO channel to use it?

 

By the way, if I create a global task, do I have to clear the task at the end of the application? If I clear the task, will be global task removed from the MAX or not?

 

Finally, I wonder if it is possible for more than one vi using the same task in different time? For example, I created a global task for analog output. I run two vi, A and B. In A, it use the task to output analog voltage while B is doing something else. After A's done, B is using the same task for other output. Will they conflict any way? What happen if both A and B call the same task about the same time?

0 Kudos
Message 1 of 4
(1,866 Views)

Hi driver,

 


if I create the task on the fly in the vi, it is pretty heavy.


 

What means "heavy"?

 

- Yes, you should clear the task at end: the task is just the definition of a (DAQ) hardware setup, by clearing the task you free up that hardware...

- No, the task definition will not be removed from MAX. You just release the hardware.

- No, you cannot use the task more than once at the same time. As it is bound to some hardware you cannot use that single piece of hardware for more than one operation at a time…

- Yes, you may use the task in two VIs, that are called one after the other - but not at the same time…

- When you need two VIs "A" and "B" to output values to the same task you should use a different VI "C" that handles all hardware access while "A" and "B" just send new "commands" to "C". Think as "multiple producer, single consumer" scheme...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO
0 Kudos
Message 2 of 4
(1,838 Views)

@GerdW wrote:

Hi driver,

 


if I create the task on the fly in the vi, it is pretty heavy.


 

What means "heavy"?

 

- Yes, you should clear the task at end: the task is just the definition of a (DAQ) hardware setup, by clearing the task you free up that hardware...

- No, the task definition will not be removed from MAX. You just release the hardware.

- No, you cannot use the task more than once at the same time. As it is bound to some hardware you cannot use that single piece of hardware for more than one operation at a time…

- Yes, you may use the task in two VIs, that are called one after the other - but not at the same time…

- When you need two VIs "A" and "B" to output values to the same task you should use a different VI "C" that handles all hardware access while "A" and "B" just send new "commands" to "C". Think as "multiple producer, single consumer" scheme...


Thanks for the clarification. So it doesn't work if I create two tasks both binding to the same channel and I call those two task at the same time, right?

0 Kudos
Message 3 of 4
(1,816 Views)
Solution
Accepted by topic author dragondriver

@dragondriver wrote:

...

 


Thanks for the clarification. So it doesn't work if I create two tasks both binding to the same channel and I call those two task at the same time, right?


Time to dig up the DAQmx help file and check into the DAQmx state transition chart.

 

Any number of Tasks may be created (any reasonable number).

 

If all the stuff is sane the Task can be verified (if it calls non-existant hardware DAQmx thows an error and the task cannot be verified)

 

If all the resources are available (Clocks, routes, chanels) the Task can be "Reserved" (Commited)  If something esle has reserved any resources the Task cannot be commited and DAQmx throws an error.

 

So having mutliple tasks that use the same chanel is perfectly fine BUT, only one can be in any state other than "Verified"  Use Control Task.vi to explicitly transition Task States.


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 4
(1,809 Views)