This example shows how to use the Quick-Control Oscilloscope to acquire waveforms from an oscilloscope.
Instrument Control Toolbox™ software supports communication with instruments through Quick-Control Instrument objects. In this example you will learn to acquire a waveform from a Keysight Technologies® (formerly Agilent Technologies®) MSO6014 mixed signal oscilloscope using a Quick-Control oscilloscope object.
For a complete list of hardware supported by the toolbox, visit the Instrument Control Toolbox homepage at https://www.mathworks.com/products/instrument/
This example is tested on a 32-bit Microsoft® Windows® system, National Instruments® Compliance Package 4.1 . Keysight I/O Suite and 546XX IVI-C driver version 1.3.20.0, which can be downloaded from Keysight’s website: http://www.keysight.com. Ensure that the VISA utility has been set up to recognize the instrument resource before you execute this example.
Before acquiring any data, you must create an oscilloscope instance.
myScope = oscilloscope()
myScope = oscilloscope: No connection has been setup with instrument, type help oscilloscope for more information
Find out available resources. A resource is a string identifier to the instrument. You have to set it before connecting to the instrument.
availableResources = getResources(myScope)
availableResources = TCPIP0::a-m6104a-004598.dhcp.mathworks.com::inst0::INSTR
If multiple resources are available, use a VISA utility to verify the correct resource and set it.
myScope.Resource = 'TCPIP0::a-m6104a-004598::inst0::INSTR'; % Connect to the instrument. connect(myScope);
get(myScope);
AcquisitionTime: 0.0100 AcquisitionStartDelay: -0.0050 TriggerLevel: 0.1000 TriggerSlope: 'rising' TriggerSource: 'Channel1' WaveformLength: 2000 TriggerMode: 'normal' SingleSweepMode: 'on' ChannelNames: {'Channel1' 'Channel2' 'Channel3' 'Channel4'} ChannelsEnabled: {'Channel1'} Resource: 'TCPIP0::a-m6104a-004598::inst0::INSTR' Driver: 'Ag546XX' DriverDetectionMode: 'auto' Timeout: 10 Status: 'open'
Configure the oscilloscope's settings. The configuration we will use in this example is: acquisition time of 0.01 second with 2000 data points, trigger level of 0.1v and normal trigger mode, channel one enabled and vertical settings as shown below.
% Automatically configuring the instrument based on the input signal. autoSetup(myScope); myScope.AcquisitionTime = 0.01; myScope.WaveformLength = 2000; myScope.TriggerMode = 'normal'; myScope.TriggerLevel = 0.1; enableChannel(myScope, 'Channel1'); setVerticalCoupling (myScope, 'Channel1', 'AC'); setVerticalRange (myScope, 'Channel1', 5.0);
This function initiates an acquisition on the enabled channel. It then waits for the acquisition to complete and returns the waveform for the specified channel.
waveformArray = getWaveform(myScope, 'acquisition', true); % Plot the waveform. plot(waveformArray); xlabel('Samples'); ylabel('Voltage');
Once you have finished configuring the instrument and retrieved data from it, you need to close the connection and remove it from the workspace.
disconnect(myScope);
clear myScope;