Skip to Main Content Skip to Search
Product Documentation

Using IVI-C Class-Compliant Wrappers

IVI-C Wrappers

The IVI-C wrappers provide an interface to MATLAB for instruments running on IVI-C class-compliant drivers.

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

Prerequisites

To use the wrapper you must have the following software installed.

You can use instrhwinfo to confirm that these software modules are installed.

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

Example: Reading Waveforms Using the IVI-C Class Compliant Interface

This example shows the general workflow to use with an IVI-C class-compliant device. This example uses a specific instrument, an Agilent MSO6104A oscilloscope. This feature works with any IVI-C class-compliant instrument. You can follow the basic steps using your particular instrument if it is IVI-C class-compliant.

  1. Ensure all necessary software is installed. See 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. Set up the logical name using the Configuration Store. The VISA resource string shown in this code was acquired from the VISA utility in step 2.

    % Construct a configStore.
    configStore = iviconfigurationstore;
    
    % Set up the hardware asset called myScopeHWAsset, and resource description
         TCPIP0::a-m6104a-004598::INSTR.
    add(configStore, 'HardwareAsset', 'myScopeHWAsset', 'TCPIP0::a-m6104a-004598::INSTR');
    
    % Add a driver session called myScopeSession, and use the asset created in the 
         step above. Ag546XX is the Agilent driver version. 
    add(configStore, 'DriverSession', 'myScopeSession', 'Ag546XX', 'myScopeHWAsset');
    
    % Add a logical name to the configStore called myScope and driver session called  
         myScopeSession.
    add(configStore, 'LogicalName', 'myScope', 'myScopeSession');
    
    % Save the changes to the IVI configuration store data file.
    commit(configStore);
    
    % You can verify that the steps you just performed worked.
    logicalNameInfo = instrhwinfo('ivi', 'myscope')

    For more information about the configuration store, see IVI Configuration Store.

  4. Create an instance of the scope.

    % Instantiate an instance of the scope.
    ivicScope = instrument.ivic.IviScope();
    
  5. Connect to the instrument.

    % Open the hardware session. 
    ivicScope.init('myScope', true, true);
  6. Communicate with the instrument. For example, read a waveform.

    % Use the AutoSetup method to automatically set up the oscilloscope.
    ivicScope.Configuration.AutoSetup();
    
    % Create a record length variable. 
    recordLength = ivicScope.Acquisition.Horizontal_Record_Length;
    
    % Preallocate buffer to store the data read from the scope. 
    waveformArray = zeros(1, recordLength);
    
    % Read a waveform with channel name set to channel1 and timeout to 1000. 
    [waveformArray,actualPoints,initiaX,xIncrement] = ivicScope.WaveformAcquisition.
         ReadWaveform('channel1', recordLength, 1000, waveformArray);
    
    % Plot the waveform and assign labels for the plot. 
    plot(waveformArray);
    xlabel('Samples');
    ylabel('Voltage');
  7. After configuring the instrument and retrieving its data, close the session and remove it from the workspace.

    ivicScope.close();
    clear ivicScope;

IVI-C Class Compliant Wrappers in Test & Measurement Tool

You can also use the IVI-C Wrappers functionality from the Test & Measurement Tool. View the IVI-C nodes by setting a preference in MATLAB.

  1. In MATLAB, go to File > Preferences, then Instrument Control.

  2. Select the Show IVI Instruments in TMTool option in the IVI Instruments section.

    If you do not have the required software installed, you will get a message indicating that. See Prerequisites for the list of required software.

  3. Start the Test & Measurement Tool (using the tmtool function), and the new IVI Instruments node appears under Instrument Drivers.

For information on using it in the Test & Measurement Tool, see the Help within the tool by selecting the IVI Instruments node in the tree once it is visible after setting the MATLAB preference.

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS