Code covered by the BSD License  

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

5.0

5.0 | 2 ratings Rate this file 132 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

 

29 Sep 2010 (Updated )

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 oscilloscopes. With minor modification, based on the SCPI commands available in your instrument’s programmer’s manual, it should work with the Infiniium 9000 and 90000 Series oscilloscopes, or Agilent InfiniiVision 1000 series, 2000-X series, 3000-X series, 4000-X series, etc.

Please refer to your instrument's programmer's manual for the complete list of SCPI commands of your specific instrument model. Modify this example accordingly if your instrument screen displays errors as you step through the code.

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   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (15)
20 May 2014 DAVID

very helpful. Then i can start my work based on this script. Thanks.

27 Aug 2013 Guillermo L

Hi every one, I have this testetd on a MSO9254A and after few modifications works fine.
now...
I'm building a complete matlab GUI suite for fast testing, but I'm unable to capture data from the digital analyzer.
I've look over the internet but I didn't find a matlab script or other language for this task.

does any one know an example code for Logic Analyzer capture?

Thanks,
Guillermo

02 Aug 2012 Rui

I have solved my problem.The unsuccessful read is due to data acquisition. Be careful in the DSO1012A the :RUN and :STOP command is used for acquisition while in this example the :DIGITIZE CHAN1 command is for date acquisition.

31 Jul 2012 Rui

Anyone try this m file on Agilent DSO1012A oscilloscope?

After successful connection between my oscilloscope and Matlab, I runned the m file, but failed.
I stepped the programming and found the problem occurs at binblockread function.
The error meassage is
Warning: Unsuccessful read: A binblock is not available to be read.

Accoridng to the comments
I also tried changing line 76 from:
waveform.RawData = binblockread(visaObj,'uint16'); fread(visaObj,1);
TO
waveform.RawData = binblockread(visaObj,'int16'); fread(visaObj,1);
and also to
waveform.RawData = binblockread(visaObj); fread(visaObj,1);
But the error also occurs .

I dont konw if this m file is compatiable with my DSO1012A oscilloscope? Could anyone give me some suggestion to resolve this problem? Thanks in advance.

11 Jul 2012 Vinod Cherian

Folks trying this with 2000/3000 series scopes - if you get errors such as "undefined header" that is likely because the scope does not support the SCPI command. Please refer to the programmer's manual for the scope for the exact SCPI commands for your oscilloscope and use that to replace the offending commands in the script.

"Data out of range" typically is because you are trying to set a value, such as timebase, that the scope is not capable of. Again - modify the parameter to a value supported by the scope.

An easy way to figure out which command causes an error is to put a breakpoint after "fprintf(visaObj,'*RST; :AUTOSCALE');
" and then single step through the code. When you send an incorrect/incompatible command the scope will display an error on it's screen. Go through the scope's programmer manual and find the appropriate command (or parameter range) and modify your version of this code accordingly.

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.

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');

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

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;
?

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.

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

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');

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);

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');

05 Jan 2011 Francesc Rullan Solana

Excellent work and help!

Updates
05 Oct 2010

Minor update to comments

04 Mar 2011

Minor modifications. Tested with Agilent MSO6104A.

29 Mar 2013

minor update

Contact us