LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I remove a channel from a DAQmx task?

My question is similar to, but not the same as, this one: https://forums.ni.com/t5/LabVIEW/Is-it-possible-to-remove-channels-from-a-running-DAQmx-task-on/m-p/...

 

Basically, I just want to make a task setup screen where you can edit the channels that will be monitored before starting data collection. It seems like a no-brainer to me that, in the context of a channel editor, you might want to remove channels from the task before starting. So, my questions are these:

1) Why can you not remove channels from a task? Are DAQmx tasks just not meant to be used like this?

2) What would be a better way of doing this? I thought of maybe storing all the configuration information (in an array of clusters or something) and then building the task once the user is done configuring all the channels, but I don't know if that would be any better.

0 Kudos
Message 1 of 5
(2,303 Views)

1.  I don't know, and probably not.

2.  That is what I would do.  Just kill the old task and create a new one without the unwanted channels.

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

Right, that is what I have the program set up to do, but it's not working.

 

I can use a DAQmx Task property node to get all the channels out of the task, but it returns just the physical channels. If I then feed those channels into the DAQmx Create Task VI, I get an error because it only takes virtual channels. I could put all those bare physical channels into the DAQmx Create Channel VI, but in the process I lose all the other settings like min/max voltage, units, clock source, sample rate, etc.

 

I could provide just the front-panel controls that would be needed to set up a task, but without the DAQmx VIs none of those controls would show any of the pre-defined settings that they would have if they were connected directly to the DAQmx VIs. I could create all the channels with the Create Channel VI and surreptitiously save all the settings that get entered to an array of clusters for in case I need them later, but that seems like a really clunky way to do it.

 

All these design issues I'm having make me think that there is either a better way to do what I'm trying to do or that I'm trying to do something that the DAQmx system just isn't designed for. So, how can I get the channels out without losing all the other settings and data that go with them?

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

Hi duwaar,

 

I could create all the channels with the Create Channel VI and surreptitiously save all the settings that get entered to an array of clusters for in case I need them later,

"Saving data for later use" is the way to go!

When you want to provide an DAQmx task editor to your users then you should provide a way to save (and load) settings. This should include not just the DAQmx channel, but also all other needed values. Why read settings from existing DAQmx tasks when you can load a configuration file?

 

My users can edit an Excel worksheet to provide all needed information, like channel names and scalings. In Excel you can implement additional sanity checks using macros and other stuff…

Best regards,
GerdW


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

Have just a couple minutes for quick remarks.

 

1. You don't need to use "DAQmx Create Task.vi", I almost never have.  Instead, you can chain together a series of calls to "DAQmx Create Virtual Channel.vi".  Just leave the first 'task in' unwired.

 

2. If you define tasks in MAX, you'll probably be limited in what you can do to edit their configurations programmatically, possibly including the channels contained in the task.  It isn't something I've explored much as I typically define my tasks entirely on the block diagram and don't use MAX for global tasks or channels.

 

3.  It isn't clear to me what the *scope* of your problem is.  You seem to be talking about making a channel configuration GUI available to an operator *before* starting the task.  If that's all you need, it should be really straightforward if you do like I do and define your tasks programmatically on the block diagram rather than trying to modify global tasks defined in MAX.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
Message 5 of 5
(2,225 Views)