5.0

5.0 | 1 rating Rate this file 47 Downloads (last 30 days) File Size: 3.44 KB File ID: #28887
image thumbnail

Capturing a waveform from an Agilent oscilloscope over a standard VISA interface

by Vinod Cherian

 

29 Sep 2010 (Updated 05 Mar 2011)

MATLAB example to capture a waveform from an Agilent oscilloscope and grab a screenshot.

| Watch this File

File Information
Description

MATLAB is a software environment and programming language with over 1,000,000 users. MATLAB extends the functionality of Agilent oscilloscopes by enabling you to analyze and visualize live or acquired oscilloscope signals, make application-specific measurements, create and apply your own filters and equalization methods, and automate tests.

This example shows you how you can use MATLAB to control an Agilent oscilloscope, capture a waveform and grab a screenshot on the instrument. The user can customize the code to allow for different segment number of points, sample rates, etc. For more information on the SCPI commands used to control the instrument, refer to your instrument's programmer's guide.

To execute this example, type ‘SCPIScope’ in the MATLAB command window. Note: Change the VISA resource string in the SCPIScope.m file to the VISA address of the instrument, as obtained from Agilent Connection Expert.

This MATLAB example has been tested on an Agilent MSO6104A InfiniiVision oscilloscope but should work on most Agilent InfiniiVision 5000, 6000, and 7000 Series as well as the Infiniium 9000 and 90000 Series oscilloscopes.

To learn more about using or purchasing MATLAB with Agilent oscilloscopes, visit:
http://www.agilent.com/find/matlab_oscilloscopes

To request your free trial of MATLAB and/or Instrument Control Toolbox, visit http://www.mathworks.com/agilent/instrument/tryit.html

Required Products Instrument Control Toolbox
MATLAB release MATLAB 7.8 (R2009a)
Other requirements Agilent IO Libraries
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (10)
05 Jan 2011 Francesc Rullan Solana

Excellent work and help!

08 Feb 2011 Gerald

Does the following code also work for agilent infiniium 54831D MSO?

Is it also possible to plot the current instead of the voltage?
fprintf (oszi, ':CHANnel1:UNITs AMPere');

04 Mar 2011 Vinod Cherian

NOTE: This has been tested on an Agilent 6000 series oscilloscope. Agilent 6000 series oscilloscopes return word data in unsigned integer format. Other series oscilloscopes (such as the 8000 series, for example) return word data in signed integer format.

If the waveform does not look correct in MATLAB, try changing line 76 from:

waveform.RawData = binblockread(visaObj,'uint16'); fread(visaObj,1);

TO

waveform.RawData = binblockread(visaObj,'int16'); fread(visaObj,1);

04 Mar 2011 Vinod Cherian

NOTE: Certain Agilent firmware (such as on the 54831D) may have a difference in the SCPI commands from the 6000 series. You may need to change the line in the MATLAB-file from:

fprintf(visaObj,':WAV:POINTS 5000');

TO

fprintf(visaObj,':ACQ:POINTS 5000');

07 May 2012 Florian Jungbold

hey there,

did anyone try this example with the InfiniiVision DSO-X-3034A (3000 series DSO)?
I am a bit confused because the 3000 series is not mentioned here and on the agilent page for the "MATLAB Data Analysis Software for Agilent InfiniiVision and Infiniium Oscilloscopes" ( http://www.home.agilent.com/agilent/product.jspx?cc=DE&lc=ger&ckey=1559383&nid=-35491.868946.00&id=1559383&cmpid=21300 ). But there is a driver called "2000 and 3000 InfiniiVision X-Series Oscilloscope IVI and MATLAB Instrument Drivers" ( http://www.home.agilent.com/agilent/editorial.jspx?cc=DE&lc=ger&ckey=2019021&nid=-11143.0.00&id=2019021&pselect=SR.GENERAL ).

When i run this m-File, i get the figure with the plot of the measured values in Matlab, but in figure2 no bmp-File (Screenshot) is loaded. Overall i get these messages:
----------------------------
Instrument Error: -222,"Data out of range"

Warning: A binblock is not available to be read.
Warning: VISA: A timeout occurred
??? Error using ==> imbmpinfo at 27
File C:\Users\Florian.Jungbold\Downloads\SCPIScope\test1.bmp is empty.

Error in ==> readbmp at 15
info = imbmpinfo(filename);

Error in ==> imread at 443
    [X, map] = feval(fmt_s.read, filename, extraArgs{:});

Error in ==> SCPIScope at 140
imageMatrix = imread('test1.bmp','bmp');
----------------------------

After writing such a long comment, i ask myself if it would be better to post this to the forum?
Greetings

10 May 2012 Graham

I had the same problem with the Agilent 2014A oscilloscope. I contacted customer support and he said the object may still be locked, and gave me some code to fix it.

Running the code below fixed that problem, but I still cant get the oscilloscope to work with MATLAB.

%Find all previously created instrument objects
 newobjs = instrfind;

%If there are any existing objects
 if (~isempty(newobjs))
     %close the connection to the instrument
     fclose(newobjs);
     %and free up the object resources
     delete(newobjs);
 end
 
%Remove the object list from the workspace.
 clear newobjs;
 
Good luck.

14 May 2012 Florian Jungbold

@Graham

where did you place this code or when did you have to execute it?

Instead of (in the end of the code):
% Delete objects and clear them.
delete(visaObj); clear visaObj;
?

19 May 2012 Paul

Hello all,

I\m trying to run this code with a 3014A system, and I'm getting a variety of instrument errors (typicaly 113 undefined header, 222 data out of range, 224 Illegal parameter value, 410 query interrupted, 420 query unterminated). It eventually does output a square-wave to figure 1 (I'm using the Demo 2 system with the oscilloscope) but the output is of the wrong sign (I expect a square between 0 and 2.5 V, it goes from -2.7 to 0).

Any advice?
Thank you,
Paul

19 May 2012 Paul

And I just answered my own question:

For a 3000 series oscilloscope, set ACQUIRE:COUNT to be between 2 and 65536 (1 is not supported). The data also needs to be uint16.

For the screen-capture to work properly, you need to change the line to
fprintf(visaObj,':DISPLAY:DATA? BMP, GRAYSCALE');

27 May 2012 Paul

One final note for anyone reading this--in order to pull data off from multiple channels, you need to read each channel sequentially (so call WAVEFORM CHAN1 and read out the data, then WAVEFORMCHAN2, u.s.w.)--there's no routines to pull off multiple channels at the same time.

Please login to add a comment or rating.
Updates
05 Oct 2010

Minor update to comments

04 Mar 2011

Minor modifications. Tested with Agilent MSO6104A.

05 Mar 2011

minor update

Tag Activity for this File
Tag Applied By Date/Time
agilent Vinod Cherian 05 Oct 2010 12:18:32
infiniium Vinod Cherian 05 Oct 2010 12:18:32
infiniivision Vinod Cherian 05 Oct 2010 12:18:32
matlab example Vinod Cherian 05 Oct 2010 12:18:32
usb Vinod Cherian 05 Oct 2010 12:18:32
oscilloscopes Vinod Cherian 05 Oct 2010 12:18:32
visa Vinod Cherian 05 Oct 2010 12:18:32
oscilloscope Vinod Cherian 05 Oct 2010 12:18:32
usb Chamila 10 Jun 2011 02:33:36

Contact us at files@mathworks.com