LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to copy DAQmx task without using MAX?

Solved!
Go to solution

Howdy--

 

I've hit a bit of trouble here that I think points to some fundamental misunderstanding I may have about DAQmx Channels and Tasks.  I can hack together work-arounds, but I'd like to learn how to do these things the right way.

 

In a nutshell, I prefer to do everything in code, and not use MAX.  For my application, I would like to create a single Channel/Task initialized with all scaling, units, and physical channel parameters (that is what is, for my purposes, a "Channel").  I would then like to create copies of that Channel/Task and configure each one with task-specific sampling parameters...corresponding to what I would call different "Tasks" to be performed using that "Channel".

 

I'm having no luck, so obviously I don't correctly understand what I'm doing.  Any reading/posts I've come across use MAX.  Here's what I've attempted so far:

 

Attempt One.pngAttempt Two.pngAttempt Three.pngAttempt Four.pngAttempt Five.png

 

Even when attempting to use MAX, I'm blowing it.  Any help straightening out my confusion here is much appreciated.

 

Thanks in advance, and have a great day.

 

--Brad

0 Kudos
Message 1 of 5
(2,904 Views)
Solution
Accepted by BradNC

Actually, you are not confused.  In this instance perhaps National Instruments is.......

 

See these Ideas links in the link. Smiley Wink

 

But, a "Task" really is just a section in an XML file.  if that file is named *.lvproj the project has access to the tasks.  If that file is *.nce any labview application has access to the tasks.  If that file is created by the RTE that vi has access to the task.  In a nutshell, "Tasks" are never really defined by "Code" but by the XML file that declairs them and teir properties.  Tasks need to be defined once-Preferably during project design-

 

Yes that is somewhat of an oversimplification but a good analogy!

 

Go ahead and embrace MAX to define your Tasks......use DAQmx Property nodes if you need to programatically determine any Task property.   "do everything in code" as you say is just not really the way it is.... the way I think you mean it..  It really is not "Done in code" but more like the way LabVIEW is inherintly multithreaded.  The IDE just handles it for you "So easy a Caveman could code it!"  Relax and let it work the way it works work for you.


"Should be" isn't "Is" -Jay
Message 2 of 5
(2,888 Views)

Hmmm, I am starting to see your point I think.  Sigh...I suppose I should familiarize myself with the MAX.  I've avoided it for several years now, but it was only while pursuing your suggestions that I realized one can define MAX Tasks/Channels within the Project Explorer.  I suppose I can see the wisdom in creating those things in a way that they can be independantly tested outside any particular VI (i.e. in the MAX utility).

 

So be it.  Thanks a bunch Jeff for sharing the wisdom.

 

By the way, if you have any great explainations for why a VI called "Create Virtual Channel" outputs an object called a "Task", and not a "Channel", that would be very interesting.  I never have gotten that straight in my head.

 

Be well.

 

--Brad

0 Kudos
Message 3 of 5
(2,859 Views)

bcro

 

The DAQmx Create Virtual Channel VI actually creates a virtual channel and adds it to a task.  If you have not created a task to add to, then the VI creates both task and channel.  If you wanted to create a task first, you would use the DAQmx Create Task VI.

 

The task in and task out terminals on DAQmx VIs allow us to maintain proper reference when configuring and adding to a task.  So, essentially, DAQmx Create Virtual Channel does not have an output -- it simply passes through the task reference and the error cluster.

 

Message 4 of 5
(2,841 Views)

Aha....I'm getting it now.  So if a "Task" were a LabView object, the Create Virtual Channel VI would be equivalent to a "Write Channel" method for the "Task" class, with the caveat that you are actually adding to an array of channels within the object.

 

Thank you Amp-KB for setting me straight on that one.  It's making sense now.

 

--Brad

0 Kudos
Message 5 of 5
(2,823 Views)