Can I program an Agilent DSO6012A oscilloscope through Matlab without the Instrument Control Toolbox?

17 views (last 30 days)
I am looking to control an Agilent DSO6012A oscilloscope using a VISA-USB interface. I am working without Matlab's Instrument Control Toolbox. Is there a command sequence that allows Matlab to control the scope without the Instrument control Toolbox?
  2 Comments
Jeff
Jeff on 24 Feb 2014
If you are using Windows and have the National Instruments ni488 drivers with VISA.net loaded it is easy to talk to instruments from MATLAB without using the Instrument Control Toolbox.
>> ni=NET.addAssembly('NationalInstruments.VisaNS')
ni =
NET.Assembly handle Package: NET
Properties for class NET.Assembly:
AssemblyHandle
Classes
Structures
Enums
GenericTypes
Interfaces
Delegates
>>
The variable "ni" contains useful information about the properties of the NET.Assembly such as which enumerations are available.
We can now use the methods located in this assembly.
>> res=NationalInstruments.VisaNS.ResourceManager.GetLocalManager.FindResources('?*').cell
res =
'ASRL1::INSTR' 'ASRL2::INSTR' 'ASRL10::INSTR' 'GPIB0::INTFC' 'GPIB0::25::INSTR'
>>
if you type "res=Nat" then press tab you will see that tab completion works! In my case res{5} is the string that identifies the device that I want to open.
>> dev=NationalInstruments.VisaNS.ResourceManager.GetLocalManager.Open(res{5})
dev =
GpibSession with properties:
ReaddressingEnabled: 1
UnaddressingEnabled: 0
AllowDma: 0
PrimaryAddress: 25
RenState: [1x1 NationalInstruments.VisaNS.LineState]
SecondaryAddress: -1
ReadToFileAppends: 0
DefaultBufferSize: 16384
IOProtocol: [1x1 NationalInstruments.VisaNS.IOProtocol]
SendEndEnabled: 1
TerminationCharacter: 10
TerminationCharacterEnabled: 0
HardwareInterfaceName: [1x1 System.String]
HardwareInterfaceNumber: 0
HardwareInterfaceType: [1x1 NationalInstruments.VisaNS.HardwareInterfaceType]
LastStatus: [1x1 NationalInstruments.VisaNS.VisaStatusCode]
ResourceClass: [1x1 System.String]
ResourceImplementationVersion: 5243904
ResourceLockState: [1x1 NationalInstruments.VisaNS.AccessModes]
ResourceManufacturerID: 4086
ResourceManufacturerName: [1x1 System.String]
ResourceName: [1x1 System.String]
ResourceSpecificationVersion: 5243136
Timeout: 3000
VisaEventQueueLength: 50
SynchronizingObject: []
Handle: [1x1 System.IntPtr]
SynchronizeCallbacks: 1
NoSecondaryAddress: -1
>>
Now I can talk to the device.
>> dev.Query('*IDN?')
ans =
Agilent Technologies,33250A,0,2.04-1.01-2.00-03-2
or I can use Write and ReadString
>> dev.Write('*IDN?')
>> dev.ReadString
ans =
Agilent Technologies,33250A,0,2.04-1.01-2.00-03-2
You need to be aware that the return type will be system.string so you may want to convert it to char so that you can use functions such as str2double().
>> x=dev.Query(':FREQ?')
x =
+1.0000000000000E+03
>> whos x Name Size Bytes Class Attributes
x 1x1 112 System.String
>>
>> x=dev.Query(':FREQ?').char
x =
+1.0000000000000E+03
>> whos x Name Size Bytes Class Attributes
x 1x21 42 char
>>
>> x=str2double(dev.Query(':FREQ?').char)
x =
1000
>> whos x Name Size Bytes Class Attributes
x 1x1 8 double
>>
To release the device and free the resource:
>> dev.ControlRen(NationalInstruments.VisaNS.RenMode.AddressAndGtl)
>> dev.Dispose
You can also read block data and handle service requests.

Sign in to comment.

Answers (2)

Vinod
Vinod on 9 Aug 2012
The standard way to connect to and control instruments from MATLAB is using the functions in Instrument Control Toolbox. It has functions and examples on connecting to a variety of T&M hardware, including the Agilent 6000 series scopes. See example here: http://www.mathworks.com/matlabcentral/fileexchange/28887

alice Samm
alice Samm on 16 Dec 2015
Hello,
Jeff, I think this is a way to do it with "National Instruments" oscilloscops, but is there an equivalent code for Keysight ones? Vinod, I know that the standard way is to use matlab toolbox but I don't have its licence. You think that i can't find another way to do it ?
Thank you.
  1 Comment
Ron Fredericks
Ron Fredericks on 7 Nov 2020
It is a testiment to MATLAB team to allow this question even to be answered. Alice is correct, the 11MB Instrument Control Toolbox is the best way to connect to oscilloscopes via VISA interface for ease and support. But it is great that MATLAB allows this discussion. Thank you MATLAB!

Sign in to comment.

Categories

Find more on Instrument Connection and Communication in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!