Documentation

Using Quick-Control Oscilloscope

Quick-Control Oscilloscope

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

This documentation example uses a specific instrument, an Agilent® MSO6104 oscilloscope. This feature works with any IVI-C class oscilloscope. You can follow the basic steps, using your particular instrument.

Quick-Control Oscilloscope Prerequisites

Using IVI-C

To use the Quick-Control Oscilloscope for an IVI-C scope, you must have the following software installed.

  • Windows® 32-bit or Windows 64-bit platforms

  • VISA shared components

  • VISA

    Note, the following example uses Agilent VISA, but you can use any version of VISA.

  • National Instruments® IVI® compliance package NICP 4.1

  • Your instrument's device-specific driver

You can use instrhwinfo to confirm that the required software is installed.

% Check that the software is properly installed.
instrhwinfo('ivi')

Reading Waveforms Using the Quick-Control Oscilloscope

This example shows the general workflow to use for the Quick-Control Oscilloscope. This example uses a specific instrument, an Agilent MSO6104 oscilloscope. This feature works with any oscilloscope using an IVI-C driver. You can follow the basic steps using your particular scope. For use with a Tektronix scope, see the example in the next section.

  1. Ensure all necessary software is installed. See Quick-Control Oscilloscope Prerequisites for the list.

  2. Ensure that your instrument is recognized by the VISA utility. In this case, open Agilent Connectivity Expert and make sure it recognizes the oscilloscope.

  3. Create an instance of the oscilloscope.

    % Instantiate an instance of the scope.
    myScope = oscilloscope()
  4. Discover available resources. A resource string is an identifier to the instrument. You must set it before connecting to the instrument.

    % Find resources. 
    availableResources = getResources(myScope)

    This returns a resource string or an array of resource strings.

    availableResources =
      TCPIP0::a-m6104a-004598.dhcp.mathworks.com::inst0::INSTR
  5. 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);
  6. 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);
    
  7. Communicate with the instrument. For example, read a waveform.

    In this example, the getWaveform 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 getWaveform.


    % Acquire the waveform. 
    waveformArray = getWaveform(myScope);
    
    % Plot the waveform and assign labels for the plot. 
    plot(waveformArray);
    xlabel('Samples');
    ylabel('Voltage');
  8. After configuring the instrument and retrieving its data, close the session and remove it from the workspace.

    disconnect(myScope);
    clear myScope;

Reading a Waveform Using a Tektronix Scope

Reading a waveform with a Tektronix scope using Quick-Control Oscilloscope is basically the same workflow as described in the previous example using an Agilent scope with VISA. But the resource and driver information is different.

If you use the getResources function, instead of getting a VISA resource string as shown in step 4 of the previous example, you will get the interface resource of the Tektronix scope. For example:

% Find resources. 
availableResources = getResources(myScope)

This returns the interface resource information.

availableResources =
  interface::gpib::agilent::7::10;

Where gpib is the interface being used, agilent is the interface type for the adaptor that the Tektronix scope is connected to, and the numbers are interface constructor parameters.

If you use the getDrivers function, you get information about the driver and its supported instrument models. For example:

% Get driver information. 
drivers = getDrivers(myScope)

This returns the driver and instrument model information.

Driver: tekronix
Supported Models:
  TDS200, TDS1000, TDS2000, TDS1000B, TDS2000B, TPS2000
  TDS3000, TDS3000B, MSO4000, DPO4000, DPO7000, DPO7000B

This example shows the general workflow to use for the Quick-Control Oscilloscope for a Tektronix scope. This feature works with any supported oscilloscope model. You can follow the basic steps using your particular scope.

  1. Create an instance of the oscilloscope.

    % Instantiate an instance of the scope.
    myScope = oscilloscope()
  2. Discover available resources. A resource string is an identifier to the instrument. You must set it before connecting to the instrument.

    % Find resources. 
    availableResources = getResources(myScope)

    This returns a resource string or an array of resource strings.

    availableResources =
      interface::gpib::agilent::7::10;

    Where gpib is the interface being used, agilent is the interface type for the adaptor that the Tektronix scope is connected to, and the numbers are interface constructor parameters.

  3. Connect to the scope.

    % Connect to the scope.
    connect(myScope);
  4. 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 set acquisition time as shown. You can see examples of other acquisition parameters in step 6 of the previous example.

    % Set the acquisition time to 0.01 second.
    myScope.AcquisitionTime = 0.01);
    
    % Set the acquisition to collect 2000 data points.
    set(myScope, 'WaveformLength', 2000);
    
    % Enable channel 1. 
    enableChannel(myScope, 'CH1');
    
  5. Communicate with the instrument. For example, read a waveform.

    In this example, the getWaveform 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 getWaveform.


    % Acquire the waveform. 
    waveformArray = getWaveform(myScope);
    
    % Plot the waveform and assign labels for the plot. 
    plot(waveformArray);
    xlabel('Samples');
    ylabel('Voltage');
  6. After configuring the instrument and retrieving its data, close the session and remove it from the workspace.

    disconnect(myScope);
    clear myScope;

Quick-Control Oscilloscope Functions

The 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 the oscilloscope's channel(s).
 disableChannel(myScope, 'Channel1');
 disableChannel(myScope, {'Channel1', 'Channel2'});
enableChannelEnables the oscilloscope's channel(s) from which waveform(s) will be retrieved.
 enableChannel(myScope, 'Channel1');
 enableChannel(myScope, {'Channel1', 'Channel2'});
getDriversReturns 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 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 the 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 the 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);
resetResets the device.
reset(myScope);
setVerticalCouplingSpecifies how the oscilloscope couples the input signal for the selected channel name as a MATLAB string. Values are 'AC', 'DC', and 'GND'.
 setVerticalCoupling (myScope, 'Channel1', 'AC');
setVerticalOffsetSpecifies the 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 from 0.0 to 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);

Creating Shared Libraries or Standalone Applications When Using IVI-C or VXI

When using IVI-C or VXI Plug&Play drivers, executing your code will generate additional file(s) in the folder specified by executing the following code at the MATLAB prompt:

sprintf('%s',[tempdir 'ICTDeploymentFiles'])

On all supported platforms, a file with the name MATLABPrototypeFor<driverName>.m is generated, where <driverName> the name of the IVI-C or VXI Plug&Play driver. With 64-bit MATLAB® on Windows, a second file by the name <driverName>_thunk_pcwin64.dll is generated. When creating your deployed application or shared library, manually include these generated files. For more information on including additional files refer to the MATLAB Compiler documentation.

Was this topic helpful?