08-20-2021 05:15 AM
Hello,
I am working with Labview 2019 SP1 (32 and 64 bits, the Problem is on both the same) and a USB-6212.
I created a Vi to test because I have some problems on a bigger Vi. I want to use the Task name (created with create channel) in other parts of my program. I observe that sometimes the task name was empty, so I create the attached VI to test it.
If I run the attached VI with highlight on, the "DAQ Create channel" create a task name. If I run the VI with normal speed (highlight off) "DAQmx Create channel" create an empty channel. Why?
I also observe that wenn I run the Programm on normal speed a couple of times and then I run it with highlight on, the name of the created task has been incremented by the same number of times I have run the program. So, what is going on?
Thanks
Solved! Go to Solution.
08-20-2021 05:57 AM
Hi Navarro,
@Navarro_ wrote:
I want to use the Task name (created with create channel) in other parts of my program. I observe that sometimes the task name was empty, so I create the attached VI to test it.
Why do you want to use "just" the task name? Why don't you use the DAQmx task reference instead?
(It also does not help to delete the task immediatly after creating it…)
@Navarro_ wrote:
I also observe that wenn I run the Programm on normal speed a couple of times and then I run it with highlight on, the name of the created task has been incremented by the same number of times I have run the program. So, what is going on?
As you did not supply your own task name LabVIEW will autocreate that label. And because you create a new task each time you run your VI it will also create a new task name each time…
08-20-2021 06:18 AM
Hi Gerdw,
thanks for the fast answer.
I am sorry, but I do not know what do you mean. What is a task reference?. The only thing I get from the "DAQ Create channel" is the task name.
The VI I create is only to test. I do not usually close the task after create it.
What I want to do is:
1. Create a task for a channel (for example, ai0) and put the task name in the shift register of my loop
2. Get the task name from the shift register and use the Start Task and Read to get data from ai0 a couple of times
3.Clear the task
4.Create a new task for an other channel (for example, ai0 and ai3:4) and do the same than on 1., 2. and 3
Thanks again
08-20-2021 06:46 AM
@Navarro_ wrote:
I am sorry, but I do not know what do you mean. What is a task reference?. The only thing I get from the "DAQ Create channel" is the task name.
The "task out" of that function is the task reference.
@Navarro_ wrote:
The VI I create is only to test. I do not usually close the task after create it.
Good. But your test, if run normally, is closing the task before it really has a chance to get started. Highlight Execution slows things down enough that the task can actually get started before you close it. If you are doing other stuff between, then you should be fine.
08-20-2021 08:33 AM
Hello,
thanks again for the answer. I am trying to reproduce the error with the VI attached. This is a piece of my code. But... as you say, this is working.
The original code is the same, but bigger. I use the same structure also for the output and digital output (see attached screenshot).
Could it be that I am trying to open and close tasks before waiting enough?. Any other Ideas?
Thanks
08-20-2021 08:46 AM
Sorry. I forgot to attach the Subvi
08-21-2021 10:07 AM
There are several ways to create Tasks with the correct Channel associations. One is to open MAX, find your device, configure it for the Channels you want (setting up all of the parameters you need, including Sampling, Range, etc.), and doing a "Save Task" (and picking a better Task Name than "MyAITask"). A second is to do more-or-less the same thing, but from within the LabVIEW Project (right-click My Computer and choose "New", "NI DAQ-mx Task"). The third way (which I now use exclusively) is to do it programmatically, starting with DAQmx Create Task (where you can find the Device you want to use), DAQmx Create Channel (where you Create and configure the Channels), and DAQmx Timing (where you set the Sampling Clock).
Do a Web Search for "Learn 10 Functions in NI-DAQmx and Handle 80 Percent of your Data Acquisition Applications" (I might have a word wrong in the title), but it shows all three of these methods. Do not use the Dreaded DAQ Assistant (a.k.a. the DDA), which it also mentions!
Bob Schor
08-23-2021 02:04 AM
Hello,
thanks for your answer. Maybe I should open a different thread. Please let me know if this is the case.
I have to create an executable and I don't know what cards or devices the target computer will have. That is, I need to find the card in the target computer and create/use the channels I need. I know that I can create a configuration with max, but this configuration has to work also on the target computer with a card that has a different name, without my help (programmatically).
So, I still have a couple of questions:
-How can I find programmatically the device on the target computer with DAQ Create Task?
-Is it better to have a fixed name for a task or to generate it dynamically?
-Is there any problem to create and clear tasks in parallel loops for different channels, e.g. analog input and digital output?
-Is there any limitation on the speed of creating and clearing tasks, as long as an operation is performed within the tasks? (Maybe USB latency?)
Thanks
08-23-2021 04:46 AM
Hi Navarro,
@Navarro_ wrote:
-How can I find programmatically the device on the target computer with DAQ Create Task?
-Is it better to have a fixed name for a task or to generate it dynamically?
-Is there any problem to create and clear tasks in parallel loops for different channels, e.g. analog input and digital output?
-Is there any limitation on the speed of creating and clearing tasks, as long as an operation is performed within the tasks? (Maybe USB latency?)
08-23-2021 05:18 AM
Hello,
thanks again for your answer.
What I meant was to create a task (for example for AI0) and another task for another channel (for example DO0) at the same time in parallel loops. So, different channels, different task but "at the same time" in parallel loops. Is it a problem?
I have continued testing with several VIs and have found the solution to the problem in this post https://forums.ni.com/t5/LabVIEW/DAQmx-Task-Questions/td-p/3754938. As Ben says, it is possible to configure different task for the same resources and activate only one of them by playing and stopping the task.
The only question that remains unanswered is if I can use the structure that Ben says (see attached) for 2 loops in parallel, one for the input and the second for the output.
Thanks