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.

  • Windows® 32-bit or Windows 64-bit

  • VISA shared components

  • VISA

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

  • National Instruments® compliance package NICP 4.1

  • Your instrument driver

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

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

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.

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, on the Home tab, in the Environment section, click Preferences. Then select Instrument Control in the Preferences dialog box.

  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.

Was this topic helpful?