AnsweredAssumed Answered

Getting real-time traces from DSO81204A using Matlab

Question asked by Psamadi on Nov 4, 2009
Latest reply on Nov 12, 2009 by algoss
Hi folks.

I'm very new to the instrument programming. I'm trying to connect to DSO81204A with GPIB or TCPIP using Matlab and get real-time traces from the oscilloscope. I've found some sample codes for Continuous trace acquisition (sync), Continuous trace acquisition (assync), and Single trace acquisition. This is my sample code:

mxa_ip = '10.11.231.96';
mxa_port = 80;
mxa=tcpip(mxa_ip, 80);
set(mxa,'InputBufferSize',100000);
set(mxa,'Timeout',5);
fopen(mxa);

% Set the data trace format to REAL, 32 bits
fprintf(mxa,':FORM:DATA REAL,32');
% Get the nr of trace points
nr_points = str2double(query(mxa,':SWE:POIN?'));
% Get the reference level
ref_lev = str2num(query(mxa,':DISP:WIND:TRAC:Y:RLEV?'));
% Put the instrument in continuos mode
fprintf(mxa,':INIT:CONT ON');

% Create and bring to front figure number 1
figure(1)
% Create a plot handle, ph,  and draw a line at the ref level
ph = plot(1:nr_points,ref_lev*ones(1,nr_points));
% Adjust the x limits to the nr of points
% and the y limits for 100 dB of dynamic range
xlim([1 nr_points])
ylim([ref_lev-100 ref_lev])
% Activate the grid
grid on

% Plot cycle
for i=1:100
    fprintf(mxa,':TRAC? TRACE1');
    data = binblockread(mxa,'float32');
    fscanf(mxa); %removes the terminator character

    % Change the plot line data (fast update method)
    set(ph,'Ydata',data);
    % flushes the plot event queue
    drawnow
end

% Disconnect an clean up
fclose(mxa);
delete(mxa);
clear mxa;

I've no problem with connecting and opening the GPIB/TCPIP connection, and setting the data trace format, but when I use query(mxa,':SWE:POIN?') to get the data, it takes a lot of time and at the end my data is empty and nr_points is NAN.
Also I'm looking for a manual for Agilent remote connection commands. (like: :FORM:DATA REAL,32)
I appreciate your help!  

Outcomes