Discussion:
Automatically scanning for hardware
(too old to reply)
Fabrice Prieur
2010-02-12 09:56:05 UTC
Permalink
Hi!
I am trying to write a program controlling Agilent instruments. I would like the program to be able to communicate with one type of instrument but not one particular instance of this type. For example, any signal generator of type 33220A.

When creating a visa object, one argument of the function (rsrcname) contains the serial number of the instrument. Since I cannot hardcode a serial number, I need to find the value for this argument.
I can find the value of rsrcname by using instrhwinfo('visa','agilent'). But this works only if the instrument has been found by Matlab.
To do that, I can of course choose 'Tools', 'Scan for all instruments' in the Test and measurement tool. But I wonder if it is possible to do this automatically in my code.
In other words, is there a function I can call to scan for instruments?

Thanks for your help.
Fabrice Prieur
2010-02-12 13:19:02 UTC
Permalink
My bet, it looks like instrhwinfo is able to find USB devices after all.

inst = instrhwinfo('visa','agilent');inst.ObjectConstructorName

gives me a table looking like:

'visa('agilent', 'USB0::2391::5924::MY45003315::0::INSTR');'
'visa('agilent', 'USB0::2391::1031::MY44020716::0::INSTR');'

after executing usb1 = visa('agilent', 'USB0::2391::1031::MY44020716::0::INSTR');;
I can do fopen(usb1).
If I want to know which instrument this is, I can use query(usb1, '*IDN?'), which gives me in this case

Agilent Technologies,33220A,MY44020716,2.07-2.02-22-2

Hope this helps others.
Vinod Cherian
2010-02-12 15:26:21 UTC
Permalink
Fabrice,

You might want to ensure that any instruments you want to connect to are identified in your VISA library. Instrument Control Toolbox relies on the VISA libraries' information to populate and return the results of "instrhwinfo('visa','agilent')".

If for example you plug in an instrument to your LAN, it will likely not show up in the results of "instrhwinfo('visa','agilent')" until you have added it to your Agilent Connection Expert configuration.

Once the assumption that "instrhwinfo('visa','agilent')" will return the complete set of instruments is ensured, your approach to FOPEN a connection to each instrument in the list and send the '*IDN?' to identify particular instruments is a good one.

HTH,
-Vinod
Post by Fabrice Prieur
My bet, it looks like instrhwinfo is able to find USB devices after all.
inst = instrhwinfo('visa','agilent');inst.ObjectConstructorName
'visa('agilent', 'USB0::2391::5924::MY45003315::0::INSTR');'
'visa('agilent', 'USB0::2391::1031::MY44020716::0::INSTR');'
after executing usb1 = visa('agilent', 'USB0::2391::1031::MY44020716::0::INSTR');;
I can do fopen(usb1).
If I want to know which instrument this is, I can use query(usb1, '*IDN?'), which gives me in this case
Agilent Technologies,33220A,MY44020716,2.07-2.02-22-2
Hope this helps others.
Loading...