LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Programmatically determine NI-DAQ devices available?

Solved!
Go to solution

Similar to the 'VISA Find Resource' function, is it possible to programmatically determine which NI-DAQ devices (in my case USB ones; i.e. USB-6003, USB-6501, et.al.) are connected to the computer?

 

I have a situation where I do all my programming on one laptop and spin-off compiled applications (via App Builder) to individual instruments and setups.  Right now when I have to work with one of them I have to go into NI MAX, see the devices available, determine which one is which, rename devices accordingly so that what's on that instrument becomes my Dev1 or Dev2, etc. (since the individual machines are all Dev1/Dev2 whereas on my laptop I've now got Dev1 through Dev18 for ALL the devices on ALL the instruments) and also change multiple filenames to be consistent with what's needed by that particular instrument (am keeping copies of the setup files for the various instruments on my laptop - and they can't ALL be called 'config.ini' in the same folder, yah?).

 

What I'd LIKE to do is plug in and run a separate VI which will look at the available devices, pull the device serial numbers so it'll know which machine it's plugged-into, and programmatically rename devices and files so the particular VI I'm running will always have consistent resources & file names going into it (so I don't have to do it all by-hand time-after-time in NI MAX and windows).

0 Kudos
Message 1 of 9
(5,111 Views)

Hi sjn,

 

To get the available devices using DAQmx, you can use the DAQmx System property node and Device Names.

This can be found either via Measurement I/O > NI DAQmx > Advanced > System Setup > System Node or by dropping a Property Node and choosing the class via the right click menu (Select Class > DAQmx > DAQmx System).

Example_VI.png

 

I'd suggest making the device name an input to the system, and using something like Format to String to replace its usage in your configurations, if that's an amenable solution.


GCentral
Message 2 of 9
(5,097 Views)

You might look here though I haven't tested it myself.

Message 3 of 9
(5,088 Views)

I do a similar thing... although I keep the operator well out of it.

I use the System property node to list all DAQmx devices registered in MAX.

I then

1)  filter for devices of a particular type (e.g. 6509) then return all of those.

2) process for device properties like 'simulated'; 'device name', 'chassis slot', ' chassis id'

3) as I know exactly what DAQ H/W is required for each project, I can use the above method to determine if it is plugged in. If more than 1 device of a particular type is used in the H/W I get H/W identification assigned to ports so I can auto detect. - This means that when switching between machines, or if a card gets replaced or goes off for cal the system auto detects it and doesn't need the operator to know the MAX alias.

 

Although it was long process to setup initially and figure out, it has been worth its weight over the years as it now only takes 5 mins to setup a system and if someone messes with the H/W or I deploy to another PC I don't have to work out the aliases.

 

(Also works with NI DMM if you create the functions)

 

James

CLD; LabVIEW since 8.0, Currently have LabVIEW 2015 SP1, 2018SP1 & 2020 installed
Message 4 of 9
(5,050 Views)

Thanks, all.  I didn't know about the DAQmx system property - owing it all to being lazy and not drilling-down enough into the menus...  Next to do is figure renaming devices and i'll be all set.  thanks again!

0 Kudos
Message 5 of 9
(5,029 Views)

@sjn wrote:

Thanks, all.  I didn't know about the DAQmx system property - owing it all to being lazy and not drilling-down enough into the menus...  Next to do is figure renaming devices and i'll be all set.  thanks again!


As I said - I'm to lazy to rename. I determine what's in the system and use the IDs instead, but the link provided does seem to allow renaming (If you know the type of DAQmx device you want to rename and you know it's name beforehand - but please note you can't have duplicate names in MAX, so avoiding renaming is why I went the route I did! You can still store the data in a config file.)

CLD; LabVIEW since 8.0, Currently have LabVIEW 2015 SP1, 2018SP1 & 2020 installed
0 Kudos
Message 6 of 9
(4,993 Views)

I would only have the intention of running this thing, once connected to an instrument, to read the hardware I'm connected-to and set things up for me to then open the source in LV to do what I have to do.  Renaming would only be so that the source only knows "Dev1" and the laptop would determine which device it has in its repertoire that matches the s/n on the just-plugged-in device, rename the current 'Dev1' to a number not yet used, and rename the s/n match to 'Dev1'.  And also fiddle with filenames the same way so I can neatly keep them all in the same folder.

0 Kudos
Message 7 of 9
(4,980 Views)
Solution
Accepted by topic author sjn

I would alternatively suggest the following style - you can do this as needed and avoid ever explicitly coding a device identifier:

Example_VI.png

 

I think that if you want to rename the device, you might need to go through the System Configuration VIs. The comment possibly worth making here is I'm not sure how you'd need to identify your device from the list - the name can be displayed but shouldn't be used programmatically, according to the Context Help, because it can change from version to version.

 

If you can uniquely identify with the available (and suitable) tools, that might be an option. The numeric part of the device name (e.g. 6210 in the above example) can be read, as can things like bus type, if simulated or not, number of slots...

 


GCentral
0 Kudos
Message 8 of 9
(4,956 Views)

@cbutcher wrote:

I would alternatively suggest the following style - you can do this as needed and avoid ever explicitly coding a device identifier:

Example_VI.png

 

I think that if you want to rename the device, you might need to go through the System Configuration VIs. The comment possibly worth making here is I'm not sure how you'd need to identify your device from the list - the name can be displayed but shouldn't be used programmatically, according to the Context Help, because it can change from version to version.

 

If you can uniquely identify with the available (and suitable) tools, that might be an option. The numeric part of the device name (e.g. 6210 in the above example) can be read, as can things like bus type, if simulated or not, number of slots...

 


Nice code, very similar to what I've written. Unfortunately doesn't handle these use cases yet

1) NI change the product name for essentially the same H/W (e.g. USB-6501 ; 6501-OEM) - but you might want to differentiate to that level. (Although I'm sure the product names have been changed in the H/W over the years with some H/W not having form factors in the product names until multiple form factors became available) It is possible to select by form factor and product number (but you need to verify with a physical device)

 

2) User plugs in more than 1 of correct device type

 

3) Have a physical device and a simulated device in MAX, simulated deice was created before physical device was plugged in.

 

The enhancement is basically to make the for loop conditionally indexing and then check the array size is correct for the desired number of devices on the system.

 

I do all this in an initialise DAQ function and store the array of cards cardnames in and FGV for indexing later and pre-pending onto the front of task names.

James

CLD; LabVIEW since 8.0, Currently have LabVIEW 2015 SP1, 2018SP1 & 2020 installed
0 Kudos
Message 9 of 9
(4,926 Views)