Reading Waveforms from an Oscilloscope using IVI-C Class Compliant Interface

This example shows how to communicate with an oscilloscope using the IVI-C Class Compliant Interface Wrapper.

Instrument Control Toolbox™ software supports communication with instruments through IVI drivers. In this example, a waveform is acquired from an Agilent Technologies® mixed signal oscilloscope modular instrument (MSO6014) using an IVI-C Class Compliant Scope Wrapper.

For a complete list of hardware supported by the toolbox, visit the Instrument Control Toolbox homepage at


For this example you need a 32-bit Microsoft® Windows system, Agilent I/O library and 546XX IVI-C driver version This example requires NI Compliance Package 4.0 and higher and it was tested with the NI Compliance Package 4.1. Be sure that the VISA utility (such as Agilent Connectivity Expert) recognizes the instrument before you use this example.

Getting Information about the Instrument

Use INSTRHWINFO to find the instrument resource string.

% Get the resource string from the Agilent VISA ObjectConstructorName and
% verify it is the one used to communicate with the instrument.
agilentVisaInfo = instrhwinfo('visa', 'agilent');
resourceInfo = agilentVisaInfo.ObjectConstructorName
resourceInfo = 

    'visa('agilent', '');'
    'visa('agilent', '');'
    'visa('agilent', 'GPIB0::1::INSTR');'

Exploring the IVI Configuration Store and locating installed IVI drivers to make sure that Ag546XX is inside IviInfo's Modules

IviInfo = instrhwinfo('ivi')
IviInfo = 

                  LogicalNames: {1x13 cell}
                    ProgramIDs: {1x19 cell}
                       Modules: {1x35 cell}
    ConfigurationServerVersion: ''
      MasterConfigurationStore: 'C:\ProgramData\IVI Foundation\IVI\IviConfigurationStore.xml'
                   IVIRootPath: 'C:\Program Files (x86)\IVI Foundation\IVI\'

Creating a logical name in the IVI Configuration Store

% Construct configStore.
configStore = iviconfigurationstore;

% Add a hardware asset with name myScopeHWAsset, and resource description TCPIP0::a-m6104a-004598::INSTR.
% You can use Agilent I/O library utility to find out the resource description.
add(configStore, 'HardwareAsset', 'myScopeHWAsset', 'TCPIP0::a-m6104a-004598::INSTR');

% Add a driver session with name myScopeSession, that uses the Ag546XX software module and the hardware asset created in the step above.
add(configStore, 'DriverSession', 'myScopeSession', 'Ag546XX', 'myScopeHWAsset');

% Add a logical name to configStore, with name myScope, driver session name myScopeSession.
add(configStore, 'LogicalName', 'myScope', 'myScopeSession');

% Save the changes to the IVI configuration store data file.

% To learn more on how to create an entry in the configuration store, see:

Verifying myScope Logical Name Created in the Above Steps

logicalNameInfo = instrhwinfo('ivi', 'myScope')
logicalNameInfo = 

                DriverSession: 'myScopeSession'
                HardwareAsset: 'myScopeHWAsset'
               SoftwareModule: 'Ag546XX'
         IOResourceDescriptor: 'TCPIP0::a-m6104a-004598::INSTR'
    SupportedInstrumentModels: [1x566 char]
            ModuleDescription: 'IVI Driver for Agilent 546XX, 5462X, 6XXX, 5XXX and 7XXX family of Oscilloscopes'
               ModuleLocation: 'Ag546XX.dll'

Creating the IvicScope

The IviScope MATLAB wrapper provides programming support for the IVI-C Scope Class. The driver contains all the functionalities required in the IviScope specification defined by the IVI Foundation.

ivicScope = instrument.ivic.IviScope();

Opening a Session to the Specific Driver Using the Logical Name and Setting IDQuery and Reset Flags

% Open a session to communicate with real instruments using init() method.
init(ivicScope, 'myScope', true, true);

% Open a session in the simulation mode and set IDQuery and reset flags to true.
% InitWithOptions(ivicScope, 'myScope', true, true, 'simulate=true');

Exploring the Functional Groups Information of IvicScope

ivicScope = 

 IviScope MATLAB wrapper provides programming support
 for the IVI-C Scope Class.  The driver contains all the functionalities
 required in the IviScope specification defined by the IVI Foundation.
 This wrapper requires VISA ,IVI Compliance Package and an IVI instrument
 specific driver that is compliant with the IviScope class. The
 IviScope class wrapper accesses the specific driver using the logical
 name in the configuration store.
 Resource Descriptor: TCPIP0::a-m6104a-004598::INSTR 

           Configuration: This class contains functions and
     WaveformAcquisition: This class contains functions and
                 Utility: This class contains functions and sub-classes that
   InherentIVIAttributes: Attributes common to all IVI
             Acquisition: Attributes that configure the various
        ChannelSubsystem: Channel-based attributes that you use to
        TriggerSubsystem: Attributes that control how the
   WaveformMeasurementWM: Attributes that configure the
             initialized: true

Setting Up the Instrument

Invoke the AutoSetup method to automatically configure the oscilloscope.


Exploring Available Channels

channelCount = ivicScope.InherentIVIAttributes.SpecificDriverCapabilities.Channel_Count
% preallocate a cell array to store channel names.

for idx= 1:channelCount
    channelNames{idx, 1} =  ivicScope.Utility.GetChannelName(idx, 256);
channelCount =


    'Channel1 '
    'Channel2 '
    'Channel3 '
    'Channel4 '

Reading Waveform from Channel One

This function initiates an acquisition on the specified channel. It then waits for the acquisition to complete and returns the waveform for the channel you specify.

% Current record length.
recordLength = ivicScope.Acquisition.Horizontal_Record_Length;
% Preallocate buffer to store the data read from scope.
waveformArray = zeros(1, recordLength);
% Set maximum time out.
maxTimeOut = 1000;
% Note: It is important to set the channel name for some driver methods.
% Connect channel one to a signal source and read the waveform from it.
[waveformArray,actualPoints,initialX,xIncrement] = ReadWaveform(ivicScope.WaveformAcquisition, channelNames{1} ,recordLength, maxTimeOut, waveformArray);
% Plot the waveform.

Cleaning Up

Once you have finished configuring the instrument and retrieved data from it, you need to close the session and remove it from the workspace.

clear ivicScope;
Was this topic helpful?