Contents
- Get a list of all the available instruments
- Find instruments with "10" in their model or vendor name.
- Find an instrument by model number
- Find an instrument by the Manufacturer code in the VISA resource string
- Find an instrument by the model code in the VISA resource string
- Find and delete all existing interface objects
Get a list of all the available instruments
findInstrument; % equivalent to passing an empty search tring
No instruments matched ''. Available instruments:
VISA Resource: USB0::0x0957::0x0588::CN49140544::INSTR
Vendor: Agilent Technologies
Model: DSO1014A
VISA Resource: USB0::0x0957::0x0618::TW46000285::INSTR
Vendor: Agilent Technologies
Model: 34405A
VISA Resource: USB0::0x0957::0x1507::MY48000278::INSTR
Vendor: Agilent Technologies
Model: 33210A
Find instruments with "10" in their model or vendor name.
obj is [] since there are several such instruments
obj = findInstrument('10')
2 instruments matched '10'
VISA Resource: USB0::0x0957::0x0588::CN49140544::INSTR
Vendor: Agilent Technologies
Model: DSO1014A
VISA Resource: USB0::0x0957::0x1507::MY48000278::INSTR
Vendor: Agilent Technologies
Model: 33210A
obj =
[]
Find an instrument by model number
obj = findInstrument('34405')
VISA-USB Object Using NI Adaptor : VISA-USB-0-0x0957-0x0618-TW46000285-0
Communication Address
ManufacturerID: 0x0957
ModelCode: 0x0618
SerialNumber: TW46000285
Communication State
Status: closed
RecordStatus: off
Read/Write State
TransferStatus: idle
BytesAvailable: 0
ValuesReceived: 0
ValuesSent: 0
Open the connection, and get the identification string
fopen(obj)
query(obj,'*IDN?')
ans = Agilent Technologies,34405A,TW46000285,1.40-3.08
If we try to find the same instrument again, findInstrument won't succeed (note the entry that says "Unable to connect"). This is because there is already a connection open.
obj2 = findInstrument('34405')
No instruments matched '34405'. Available instruments:
VISA Resource: USB0::0x0957::0x0588::CN49140544::INSTR
Vendor: Agilent Technologies
Model: DSO1014A
VISA Resource: USB0::0x0957::0x0618::TW46000285::INSTR
Unable to connect (instrument may be in use)
VISA Resource: USB0::0x0957::0x1507::MY48000278::INSTR
Vendor: Agilent Technologies
Model: 33210A
obj2 =
[]
We need to delete the existing object (which will automatically close it as well)
delete(obj);
findInstrument will now succeed
obj2 = findInstrument('34405')
VISA-USB Object Using NI Adaptor : VISA-USB-0-0x0957-0x0618-TW46000285-0
Communication Address
ManufacturerID: 0x0957
ModelCode: 0x0618
SerialNumber: TW46000285
Communication State
Status: closed
RecordStatus: off
Read/Write State
TransferStatus: idle
BytesAvailable: 0
ValuesReceived: 0
ValuesSent: 0
And we can open the connection and query the instrument
fopen(obj2);
query(obj2,'*IDN?')
delete(obj);
ans = Agilent Technologies,34405A,TW46000285,1.40-3.08
Find an instrument by the Manufacturer code in the VISA resource string
(0x975 is the code for Agilent). This fails since there are multiple Agilent instruments
obj = findInstrument('0x0957')
3 instrument(s) matched '0x0957' (VISA Resource)
VISA Resource: USB0::0x0957::0x0588::CN49140544::INSTR
Vendor: Agilent Technologies
Model: DSO1014A
VISA Resource: USB0::0x0957::0x0618::TW46000285::INSTR
Unable to connect (instrument may be in use)
VISA Resource: USB0::0x0957::0x1507::MY48000278::INSTR
Vendor: Agilent Technologies
Model: 33210A
obj =
[]
Find an instrument by the model code in the VISA resource string
0x1507 is the code for Agilent 33210A
obj = findInstrument('0x1507')
VISA-USB Object Using NI Adaptor : VISA-USB-0-0x0957-0x1507-MY48000278-0
Communication Address
ManufacturerID: 0x0957
ModelCode: 0x1507
SerialNumber: MY48000278
Communication State
Status: closed
RecordStatus: off
Read/Write State
TransferStatus: idle
BytesAvailable: 0
ValuesReceived: 0
ValuesSent: 0
Find and delete all existing interface objects
INSTRFINDALL returns all the existing interface objects
instrfindall
Instrument Object Array Index: Type: Status: Name: 1 visa-usb open VISA-USB-0-0x0957-0x0618-TW46000285-0 2 visa-usb closed VISA-USB-0-0x0957-0x1507-MY48000278-0
Delete all the existing interface objects with one command
delete(instrfindall)