oscilloscope

Create Quick-Control Oscilloscope object

Syntax

myScope = oscilloscope()
connect(myScope);
set(myScope, 'P1',V1,'P2',V2,...)
waveformArray = getWaveform(myScope);

Description

The Quick-Control Oscilloscope can be used for any oscilloscope that uses VISA and an underlying IVI-C or IVI-COM driver. However, you do not have to directly deal with the underlying driver. You can also use it for Tektronix® oscilloscopes. This is an easy to use oscilloscope object.

myScope = oscilloscope() creates an instance of the scope named myScope.

connect(myScope); connects to the scope.

set(myScope, 'P1',V1,'P2',V2,...) assigns the specified property values.

waveformArray = getWaveform(myScope); acquires a waveform from the scope.

For information on the prerequisites for using oscilloscope, see Quick-Control Oscilloscope Prerequisites.

The Quick-Control Oscilloscope oscilloscope function can use the following special functions, in addition to standard functions such as connect and disconnect.

FunctionDescription
autoSetupAutomatically configures the instrument based on the input signal.
autoSetup(myScope);
disableChannel Disables oscilloscope's channel(s).
 disableChannel('Channel1');
 disableChannel({'Channel1', 'Channel2'});
enableChannelEnables oscilloscope's channel(s) from which waveform(s) will be retrieved.
 enableChannel('Channel1');
 enableChannel({'Channel1', 'Channel2'});
getDriversRetrieves a list of available oscilloscope instrument drivers. Returns a list of available drivers with their supported instrument models.
drivers = getDrivers(myScope);
getResourcesRetrieves a list of available resources of instruments. It returns a list of available VISA resource strings when using an IVI-C or IVI-COM scope. It returns the interface resource information when using a Tektronix scope.
res = getResources(myScope);
getVerticalCouplingReturns the value of how the oscilloscope couples the input signal for the selected channel name as a MATLAB string. Possible values returned are 'AC', 'DC', and 'GND'.
 VC = getVerticalCoupling(myScope, 'Channel1');
getVerticalOffsetReturns location of the center of the range for the selected channel name as a MATLAB string. The units are volts.
 VO = getVerticalOffset(myScope, 'Channel1');
getVerticalRangeReturns absolute value of the input range the oscilloscope can acquire for selected channel name as a MATLAB string. The units are volts.
 VR = getVerticalRange(myScope, 'Channel1');
getWaveformReturns the waveform(s) displayed on the scope screen. Retrieves the waveform(s) from enabled channel(s).
w = getWaveform(myScope);
setVerticalCouplingSpecifies how the oscilloscope couples the input signal for the selected channel name as a MATLAB string. Valid values are 'AC', 'DC', and 'GND'.
 setVerticalCoupling(myScope, 'Channel1', 'AC');
setVerticalOffsetSpecifies location of the center of the range for the selected channel name as a MATLAB string. For example, to acquire a sine wave that spans between 0.0 and 10.0 volts, set this attribute to 5.0 volts.
 setVerticalOffset(myScope, 'Channel1', 5);
setVerticalRangeSpecifies the absolute value of the input range the oscilloscope can acquire for the selected channel name as a MATLAB string. The units are volts.
 setVerticalRange(myScope, 'Channel1', 10);

Arguments

The Quick-Control Oscilloscope oscilloscope function can use the following properties.

PropertyDescription
ChannelNamesRead-only property that provides available channel names in a cell array.
ChannelsEnabledRead-only property that provides currently enabled channel names in a cell array.
StatusRead-only property that indicates the communication status.

Valid values are open or closed.

TimeoutUse to get or set a timeout value.

Value cannot be negative number. Default is 10 seconds.

AcquisitionTimeUse to get or set acquisition time value. Used to control the time in seconds that corresponds to the record length.

Value must be a positive, finite number.

AcquisitionStartDelayUse to set or get the length of time in seconds from the trigger event to first point in waveform record.

If positive, the first point in the waveform occurs after the trigger. If negative, the first point in the waveform occurs before the trigger.

TriggerModeUse to set the triggering behavior. Values are:

'normal' – the oscilloscope waits until the trigger the user specifies occurs.

'auto' – the oscilloscope automatically triggers if the configured trigger does not occur within the oscilloscope's timeout period.

TriggerSlopeUse to set or get trigger slope value.

Valid values are falling or rising.

TriggerLevelSpecifies the voltage threshold in volts for the trigger control.
TriggerSourceSpecifies the source the oscilloscope monitors for a trigger. It can be channel name or other values.
ResourceSet up before connecting to instrument. Set with value of your instrument's resource string, for example:
set(myScope, 'Resource', 
     'TCPIP0::a-m6104a-004598::inst0::INSTR');
DriverDetectionModeOptionally used to set up criteria for connection.

Valid values are auto or manual. Default is auto.

auto means you do not have to set a driver name before connecting to an instrument.

If set to manual, a driver name must be provided before connecting.

DriverUse only if set DriverDetectionMode to manual. Then use to give driver name. Only use if driver name cannot be figured out programmatically.

Examples

Create an instance of the scope called myScope.

myScope = oscilloscope()

Discover available resources. A resource string is an identifier to the instrument. You need to set it before connecting to the instrument.

availableResources = getResources(myScope)

If multiple resources are available, use your VISA utility to verify the correct resource and set it.

set(myScope, 'Resource', 'TCPIP0::a-m6104a-004598::inst0::INSTR');

Connect to the scope.

connect(myScope);

Automatically configure the scope based on the input signal.

autoSetup(myScope);

Configure the oscilloscope.

% Set the acquisition time to 0.01 second. 
set(myScope, 'AcquisitionTime', 0.01);

% Set the acquisition to collect 2000 data points. 
set(myScope, 'WaveformLength', 2000);

% Set the trigger mode to normal. 
set(myScope, 'TriggerMode', 'normal');

% Set the trigger level to 0.1 volt. 
set(myScope, 'TriggerLevel', 0.1);

% Enable channel 1. 
enableChannel(myScope, 'Channel1');

% Set the vertical coupling to AC. 
setVerticalCoupling (myScope, 'Channel1', 'AC');
     
% Set the vertical range to 5.0. 
setVerticalRange (myScope, 'Channel1', 5.0);

Communicate with the instrument. For example, read a waveform.

% Acquire the waveform. 
waveformArray = getWaveform(myScope);

% Plot the waveform and assign labels for the plot. 
plot(waveformArray);
xlabel('Samples');
ylabel('Voltage');
Was this topic helpful?