LabVIEW utilities - find connected USB DAQmx device
Find out which USB DAQmx is connected to your computer
Suppose you have 4 PCs and 4 USB devices, e.g. NI USB-6009. And suppose you want to be able to use any of those devices on any of those PCs with one and the same LabVIEW program. That looks easy enough, but there is a small issue: Using DAQmx each device has its own ID and will be given its own name, like Dev1 for the first device which you connect to a particular PC for the first time and Dev2 for the second device which you connect to that PC for the first time. Still not a big issue if all the USB devices are the same. But it becomes more of an issue, for example:
- when, with each USB device, some additional hardware, like a set of selectable resistors, will be attached, or
- when one of the USB devices behaves differently e.g. because of a malfunctioning analog input channel.
In those cases your LabVIEW application has to know exactly which device you have attached this time.
The solution (1)
One solution to this problem is as follows. First attach each device, one after the other, to each PC once, so they will be known as Dev1, Dev2, Dev3 and Dev4. Then pick (and attach) the device that will be used by the application. Let your application first try to collect an analog input using Dev1 through Dev4. The one device that returns no error apparently is the connected device.
Create an array of DAQmx channel constants where each element refers to the first analog input channel for each of the consecutive devices:
Try to measure an analog signal for each of those channels and remember which one caused no error:
Offer some information for further processing:
LabVIEW VI which shows which USB-6009 has been connected.
- This DAQmx based VI has been made with LabVIEW 7.1 Full Development System.
- This approach requires some work, which is both tedious and error-prone and which can be avoided.
The solution (2)
Another solution is based on the fact that each USB device has a unique serial number. This number can be obtained through a DAQmx function. So from any device which can be connected, make note of its serial number. Let your application check all of the connected DAQmx devices. If there is one (and only one) device that has a known serial number, then there is a match.
Use the Device Names parameter on the DAQmx System Node (Measurement I/O >> Advanced >> System Setup >> System Node) to get an array of all the active (connected) DAQmx devices. Use an array to hold the serial numbers and check these serial numbers against the serial numbers of the active DAQmx devices. There should be a single match.
Again offer some information for further processing:
LabVIEW VI which shows which DAQmx device has been connected.
Error description file which should be placed in the folder user.lib\errors.
- The VI has been made with LabVIEW 2011 SP 1 Full Development System.
- Using this approach only one device needs to be installed up-front.
Bart Boshuizen, 2012/11/20