Multifunction DAQ

Showing results for 
Search instead for 
Did you mean: 

Labvew - Generate Physical Channel Name from Device Name

Go to solution

Currently I can define the required DAQmx physical channels using an Control. Thats very straightforward.


But because several channels have to be selected, I would like the user to select the DAQmx device name, and then append the required channel names in the backend. 

How could that be concatenated?

0 Kudos
Message 1 of 7

Can you be more specific when you say "How could that be concatenated?"  I assume you're not asking how to concatenate strings in general (but let us know if you are).  If you're asking how to form a DAQmx Physical Channels constant, then consecutive channels can be defined with a colon, but not consecutive channels must be separated by a comma with a repeat of the device identifier.  For example:  "Dev1/ai0:3, Dev1/ai7".


If you wanted to make it super easy for yourself, once your user had selected the device and the channels, you could just comma separate every single channel without being smart about the colon syntax.  For example:  "Dev1/ai0, Dev1/ai1, Dev1/ai2, Dev1/ai3, Dev1/ai7".  That's also totally valid.  It's annoying to type out manually, but you'd be creating it programmatically.


The more complicated question is probably around what kind of user interface you want to provide so that users can provide the device name and select their channels.  I'm not sure exactly what help you're asking for, so it's hard to be prescriptive.  Can you elaborate if the above doesn't help?

0 Kudos
Message 2 of 7

DAQmx provides two data types, one labeled "PHYS" for physical channel, one for "DEV" for device.

Asked differently, how can I concatenate DEV device and channel suffix to a PHYS physical channel as in the image below.



0 Kudos
Message 3 of 7
Accepted by topic author Schultze

For *that* part of things, you should change from the Build Array function to Concatenate Strings.   The DAQmx Create Channel function will interpret the output string "Dev1/ai1" correctly (though it will show a coercion dot).


However, there's no DAQmx front panel control type that will let you drop-down and find physical a pure physical channel like "/ai1" that doesn't have a leading device designator.  You'd need to do something yourself, such as populate a combo box with appropriate channel-only strings to be selected.



-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 4 of 7

You can concatenate I/O terminals just like strings.  I personally like Format Into String over Concatenate Strings because it gives you more flexibility and avoids coercion dots.  Something like this should get you started:



Message 5 of 7

Even fancier, let users select directly from an array of physical channels constants:



DAQmx already has a built-in function called "DAQmx Flatten Channel String" that does this (minus the type casting to avoid coercion dots):




It all depends on what interface you want to provide the user.

Message 6 of 7

I did come back here, googling the same problem 3 years later, finding your solution again 🙂


Thanks all.

0 Kudos
Message 7 of 7