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.

Example Code

LabVIEW - Get NI-DAQmx Device Alias from Product Name

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Hardware

  • Data Acquisition (DAQ)

    Software

  • LabVIEW

    Driver

  • NI DAQmx

Code and Documents

Attachment

Overview

 

This VI utilises the System Configuration API to search a local machine's resources to find the DAQmx Device alias based upon the product name.


Description

This is useful as a NI USB-6212 may appear as 'Dev1' on your machine, but have the name 'Dev2' auto-assigned on another.

 

Requirements

Software

  • LabVIEW 2012 or compatible
  • NI-DAQmx 9.5.5 or compatible

Hardware

  • NI Multifunction DAQ Device

 

Steps to Implement or Execute Code

  1. Download the VI
  2. Run the VI.

 

Additional Information or References

 

 

CH.png

搜狗截图17年01月07日1610_6.png

 


Regards,

Peter D

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
THMSaschaM
Member
Member
on

How could I change the Device Alias like this: "Dev1/ai2" ?

Pete.Dunc
Active Participant
Active Participant
on

It sounds like you're describing a Physical Channel rather than a device, you can do it a number of ways.  If you want to extract all of the physical channels available to the device, you can use a DAQmx Device property node.  Otherwise just treat the device name like a string and typecast to the correct datatype (you can also wire a string to DAQmx Create Virtual Channel, so don't necessarily need to convert back).

Snip.png


Regards,

Peter D

PghFool
Member
Member
on

I, too, would like to use the results of the Find Hardware routine to create a channel for a DAQmx task.  I am using LV2018, and when I run the Show All Hardware.vi from the examples, I get back aliases that are strings that look like 8 digit hexadecimal numbers.  If I concatenate such a string with a port0/line0:7 and send to DAQmx Create Channel.vi, I get a -200220 error, "Device identifier is invalid".  I have also tried typecasting the alias to a physical channel, concatenate it with port0/line0:7, and typecast it again, to more closely follow the example above, but with the same result.  Any ideas why it's not working?