Instrument Control Toolbox

Reading Waveforms from an oscilloscope using a Quick-Control Oscilloscope Object

This example shows how to use the Quick-Control Oscilloscope to acquire waveforms from an oscilloscope.

Instrument Control Toolbox™ software supports communication with instruments through Quick-Control Instrument objects. In this example you will learn to acquire a waveform from an Agilent Technologies® MSO6014 mixed signal oscilloscope using a Quick-Control oscilloscope object.

For a complete list of hardware supported by the toolbox, visit the Instrument Control Toolbox homepage at http://www.mathworks.com//products/instrument/

Introduction

This example is tested on a 32-bit Microsoft® Windows® system, National Instruments® Compliance Package 4.1 . Agilent I/O library and Agilent 546XX IVI-C driver version 1.3.20.0, which can be downloaded from Agilent's website: http://www.agilent.com. Ensure that the VISA utility has been set up to recognize the instrument resource before you execute this example.

Creating an Oscilloscope

Before acquiring any data, you must create an oscilloscope instance.

myScope = oscilloscope()
myScope = 

oscilloscope: No connection has been setup with instrument, type help oscilloscope for more information

Discovering Available Resources

Find out available resources. A resource is a string identifier to the instrument. You have to set it before connecting to the instrument.

availableResources = getResources(myScope)
availableResources =

 TCPIP0::a-m6104a-004598.dhcp.mathworks.com::inst0::INSTR

Connecting to the Oscilloscope Object

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

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

% Connect to the instrument.
connect(myScope);

Examine the Current Oscilloscope Setting

get(myScope);
          AcquisitionTime: 0.0100
    AcquisitionStartDelay: -0.0050
             TriggerLevel: 0.1000
             TriggerSlope: 'rising'
            TriggerSource: 'Channel1'
           WaveformLength: 2000
              TriggerMode: 'normal'
          SingleSweepMode: 'on'
             ChannelNames: {'Channel1'  'Channel2'  'Channel3'  'Channel4'}
          ChannelsEnabled: {'Channel1'}
                 Resource: 'TCPIP0::a-m6104a-004598::inst0::INSTR'
                   Driver: 'Ag546XX'
      DriverDetectionMode: 'auto'
                  Timeout: 10
                   Status: 'open'

Configuring the Oscilloscope

Configure the oscilloscope's settings. The configuration we will use in this example is: acquisition time of 0.01 second with 2000 data points, trigger level of 0.1v and normal trigger mode, channel one enabled and vertical settings as shown below.

% Automatically configuring the instrument based on the input signal.
autoSetup(myScope);

set(myScope, 'AcquisitionTime' ,0.01 );

set(myScope, 'WaveformLength', 2000);

set(myScope, 'TriggerMode', 'normal');

set(myScope, 'TriggerLevel', 0.1);

enableChannel(myScope, 'Channel1');

setVerticalCoupling (myScope, 'Channel1', 'AC');

setVerticalRange (myScope, 'Channel1', 5.0);

Getting a Waveform from Channel One

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

waveformArray = getWaveform(myScope, 'acquisition', true);

% Plot the waveform.
plot(waveformArray);
xlabel('Samples');
ylabel('Voltage');

Cleaning Up

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

disconnect(myScope);
clear myScope;