MORECHEMISTRY.COM::MORE CHEMISTRY ON THE WEB |
LabVIEW utilities - find connected USB DAQmx device
[LabVIEW vi collection]
[LabVIEW links]
[LabVIEW bookstore]
[programming topics] [drivers] [device simulators] [utilities] [projects] [events] [related topics] Find out which USB DAQmx is connected to your computerThe problemSuppose 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:
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. In LabVIEWCreate 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: Downloadsfinddevice.vi Remarks
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. In LabVIEWUse 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:
Downloadsdevice finder.vi device finder_errors.txt Remarks
Bart Boshuizen, 2012/11/20
|
|