LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Should I create a task for DAQmx write/read when needed?

Hi there,

  I just switch from labview to CVI recently. In labview, I don't use the global variable very offen so every time when I need to write to/read from a channel, I will create a task, perform the operation and clear the task. But in CVI, since it is C based, it reminds me to the old time in C programming I defined some common global or static variable outside the main function or in the header, but for DAQmx, should I keep one global variable for each channel  and create only one taskID for each channel during the initialization process; or should I create it dynamically when needed? What's the advantage or disadvantage for those ways?

0 Kudos
Message 1 of 3
(3,077 Views)

Hi Dragondriver,

 

That's a great question, I think it depends on your own programming preferences and style. What exactly is the application you are trying to develop? Once you know that, you might want to check online for some community examples and see how they implemented the task handling and global variables. Why would you want to have a global variable for each channel? Is it an input or output task?

 

Regards,
Basil
Applications Engineering
National Instruments
0 Kudos
Message 2 of 3
(3,034 Views)

A very basic suggestion is to properly design the use of DAQmx resources.

 

Do you have some persistent process that need to execute for a long time and be visible throughout the whole program (i.e. a continuous background acquisition)? In this case you may need to save task handle in a global variable so that you can access it in all project functions.

 

Are your requirements too fast for the create-use-dispoe paradigm? In this case also you may want to develop the application so that the task is created at program start and disposed of at program conclusion. In this case also you will need some global variable where t store the task handle so that you can access it wherever you neede it.

 

Other tasks may be created and disposed of when needed.

 



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 3 of 3
(3,027 Views)