This example shows how to use Quick-Control Oscilloscope to read waveforms. This example uses a specific instrument, a Keysight™ MSO6104 oscilloscope, but works with any oscilloscope using an IVI-C driver. You can follow the basic steps using your particular scope. This example uses Keysight VISA, but you can use any vendor’s implementation of VISA.
For use with a Tektronix® scope, see Read Waveforms Using a Tektronix Scope.
Ensure all necessary software is installed. See Quick Control Oscilloscope Requirements for the list.
Ensure that your instrument is recognized by the VISA utility. In this case, open Keysight Connectivity Expert (formerly Agilent Connectivity Expert) and make sure it recognizes the oscilloscope.
Create an instance of the oscilloscope.
% Instantiate an instance of the scope. myScope = oscilloscope()
Discover available resources. A resource string is an identifier to the instrument. You must set it before connecting to the instrument.
% Find resources. availableResources = resources(myScope)
This returns a resource string or an array of resource strings.
availableResources = TCPIP0::a-m6104a-004598.dhcp.mathworks.com::inst0::INSTR
Connect to the scope.
If multiple resources are available, use the VISA utility to verify the correct resource and set it.
myScope.Resource = 'TCPIP0::a-m6104a-004598::inst0::INSTR';
% Connect to the scope. connect(myScope);
Configure the oscilloscope.
You can configure any of the scope’s properties that are able to be set. In this example enable channel 1 and configure various acquisition settings as shown.
% Automatically configure the scope based on the input signal. autoSetup(myScope); % Set the acquisition time to 0.01 second. myScope.AcquisitionTime = 0.01; % Set the acquisition to collect 2000 data points. myScope.WaveformLength = 2000; % Set the trigger mode to normal. myScope.TriggerMode = 'normal'; % Set the trigger level to 0.1 volt. myScope.TriggerLevel = 0.1; % Enable channel 1. enableChannel(myScope, 'CH1'); % Set the vertical coupling to AC. setVerticalCoupling (myScope, 'CH1', 'AC'); % Set the vertical range to 5.0. setVerticalRange (myScope, 'CH1', 5.0);
Communicate with the instrument. For example, read a waveform.
In this example, the
readWaveform function returns the waveform that was
acquired using the front panel of the scope. The function can also initiate an acquisition
on the enabled channel and then return the waveform after the acquisition. For examples on
all the use cases for this function, see Quick-Control Oscilloscope Functions.
% Acquire the waveform. waveformArray = readWaveform(myScope); % Plot the waveform and assign labels for the plot. plot(waveformArray); xlabel('Samples'); ylabel('Voltage');
After configuring the instrument and retrieving its data, close the session and remove it from the workspace.
disconnect(myScope); clear myScope;
For a list of supported functions for use with Quick-Control Oscilloscope, see Quick-Control Oscilloscope Functions.