From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Programmatically determining the module to which a cDAQ task belongs

Solved!
Go to solution

I have some code that does some work organizing analog inputs on M and X series devices. Basically, I want to take in a list of physical channels on one or more devices, and automatically sort them into tasks. The code iterates through each physical channel and identifies the device to which it belongs, then iterates through the already-created tasks to look for a task that uses that device (via the DAQmx Task -> Devices property node). If it finds a task with that device in it, it adds the physical channel to that task. If it doesn't find it, it creates a new task.

 

This works fine on the M and X series devices I tried it on. Unfortunately, it doesn't work on cDAQ tasks due to the way the chassis and modules are named. My original code takes a channel name and looks for the / character, and uses the preceeding text to determine a device name (e.g., "Dev1/ai1" returns "Dev1"). This can be matched to the values returned by the DAQmx Task property node.

 

This unfortunately does NOT work with cDAQ devices. With cDAQ, the channel name is "cDAQModule/ai1", but the DAQmx Task -> Devices property node returns chassis names, not module names (e.g., "cDAQChassis").

 

I would like to either:

1- Determine the cDAQ chassis to which a physical channel belongs (so I can detect if there's already a task created for that chassis, as I only want to create one task), or

2- Determine the module to which a task belongs (this would create one task per module; not ideal, but workable)

 

Any thoughts on this? I can take a device reference and see ALL of the modules it has, but I can't see a way to find which specific module(s) is being used by said task. I'd like to be able to run this code multiple times to generate multiple tasks for a given chassis, so I need to know if one task is "using up" a module.

0 Kudos
Message 1 of 5
(2,770 Views)
Solution
Accepted by topic author BertMcMahan

You can use the DAQmx Device Property Node to extract the specific module information, there is an example program forum that shows this.There is a knowledge base article that describes how you can grab all the physical channels associated with a particular task, which then you can identify which module the channels belongs to based on how you name them.  You can find that article here.   I imagine you will have to combine the abilities of these two property nodes to get your desired outcome.

CC
Applications Engineering
National Instruments
http://www.ni.com/support
0 Kudos
Message 2 of 5
(2,706 Views)

This did it, thanks. I didn't know about the PhysicalChanName property, that was what I was missing.

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

Whoops- spoke incorrectly there, got things backwards in my head 🙂

 

I didn't end up using that particular node I mentioned above; instead, I just iterated through all devices in the system (as in the example you linked), and if the text before the "\" matched a module, I stopped iterating and used that device. If there were no matches, then it wasn't a module to begin with, so I just use the text before the "\" as my device name.

 

I think this will work, thanks again for the help!

0 Kudos
Message 4 of 5
(2,575 Views)

That's great to hear! Glad I could be of assistance.

CC
Applications Engineering
National Instruments
http://www.ni.com/support
0 Kudos
Message 5 of 5
(2,566 Views)