LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Create channel empty task (working with highlight execution)

Solved!
Go to solution

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

 

Download All
0 Kudos
Message 1 of 11
(1,353 Views)

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…

Best regards,
GerdW


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

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

0 Kudos
Message 3 of 11
(1,334 Views)

@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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 11
(1,330 Views)

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

0 Kudos
Message 5 of 11
(1,308 Views)

Sorry. I forgot to attach the Subvi

0 Kudos
Message 6 of 11
(1,306 Views)

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

0 Kudos
Message 7 of 11
(1,277 Views)

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

 

 

 

0 Kudos
Message 8 of 11
(1,261 Views)
Solution
Accepted by topic author Navarro_

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?)


  • You can use DAQmx properties to find all "known devices" for that specific computer and read their properties (like type). Based on that information you can decide which device to use…
  • I prefer fixed names, but it doesn't hurt to use task names generated by LabVIEW. Usually you only need to create a task once (or very limited times) while running your executable…
  • It can become a problem when the hardware does not support placing AI (or DI) channels into more than one task. All MUX devices only support one task per channel type…
  • Creating/clearing tasks is a slow operation in itself. USB latency usually is not the main problem…
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 9 of 11
(1,256 Views)

Hello,

thanks again for your answer.

  • It can become a problem when the hardware does not support placing AI (or DI) channels into more than one task. All MUX devices only support one task per channel type

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

 

Download All
0 Kudos
Message 10 of 11
(1,252 Views)