Programmatically Finding Device Name of DAQ Device in System

Updated Jan 26, 2018

Reported In

Software

  • LabVIEW

Driver

  • NI-DAQmx

Other

Multifunction DAQ

Issue Details

I am using low level DAQmx VIs, specifically Create Channel VI, which requires a physical channel input.  When I run my executable with a new device that is the same model (e.g., two different USB-6210s), my code breaks because Measurement & Automation Explorer (MAX) names the second device as Dev2 and the original device as Dev1.

How can I programmatically find the name given to the new device in MAX, so that my code does not break when I use a new device of the same model?

Solution

A DAQmx System property node can be used to find the list of device names.  A DAQmx Device property node can be used to determine the product type, which can be matched against a string containing the desired device model name.  A conditional for loop is used to iterate through all the device names in the system and stops when the first device name match is found.  When the loop stops, the device name is passed out of the loop and the channel is appended to the end of the string.  The resulting string can be used as the physical channel input for Create Channel VI.


Another approach that is useful if multiple devices of the same model are installed, is to use a conditional indexing tunnel on the for loop. This is shown in the second snippet and will return an array of all matching devices.
 

 

Additional Information

These snippets will only only work with NI DAQmx devices. If you need to find other devices you should consider using the NI System Configuration API.

WAS THIS ARTICLE HELPFUL?

Not Helpful