Programmatically Finding Device Name of DAQ Device in System in LabVIEW

Updated Jan 24, 2023

Environment

Software

  • LabVIEW

Driver

  • NI-DAQmx

How can I programmatically find the name given to the new device in MAX?
  • My code breaks when I use a new device of the same model
  • I want to change my device name without using NI MAX
  • 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.

To find 1 device name, use the following flow:
  1. A DAQmx System property node can be used to find the device name.
  2. 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. 
  3. A For Loop with Conditional Terminal checked is used to iterate through all the device names in the system and stops when the first device name match is found. 
  4. When the loop stops, the device name is passed out of the loop and the channel is appended to the end of the string through Concatenate Strings
  5. The resulting string can be used as the physical channel input for DAQmx Create Channel VI

Note: This image is a LabVIEW snippet, which includes LabVIEW code that you can reuse in your project. To use a snippet, right-click the image, save it to your computer, and drag the file onto your LabVIEW diagram. 
If multiple devices of the same model are installed, modify the code to use a Conditional Indexing Tunnel on the For Loop

Note: This image is a LabVIEW snippet, which includes LabVIEW code that you can reuse in your project. To use a snippet, right-click the image, save it to your computer, and drag the file onto your LabVIEW diagram. 

 

 

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.

If you are distinguishing between more than one of the same device, you can use a hardware property node to compare the device's serial number to select the correct device. If only one device is present but several are listed in NI MAX, you can use the "Is Present" method from a hardware property node or error validation.