AnsweredAssumed Answered

Acquiring Trace data in binary mode in Matlab

Question asked by knightm on Sep 12, 2013
Latest reply on Sep 12, 2013 by vcherian
Hi,

I'm trying to acquire trace data from EXA signal analyzer in binary mode in Matlab(2013a) to try to get faster speed. (ASCII works fine but takes a bit too long).

I modified the Agilent example below (basically just changing interface to GPIB and adding some timer).

I get correct data out, but only the first 100 points or so then the transmission stops and I get *"A timeout occurred before the binblock was read".*

Any idea what might be the problem? I tried changing GPIB timeout (as you can see in the code), but it doesn't seem to have any effect.

Regards
Martin



Example 2 Acquire Trace Single
% Getting and plotting trace data
% Single trace acquisition
 
% Initial setup
%mxa_ip = '10.10.10.10';
%mxa_port = 5025;
%mxa=tcpip(mxa_ip, 5025);
 
mxa = gpib('agilent',7,20); 
set(mxa,'EOSMode','read&write'); 
set(mxa,'EOSCharCode','LF');  % 
 
% input buffer size to receive trace data
% should be at least 4 times the number of trace
% points for 32-bit real format
set(mxa,'InputBufferSize',8009);
set(mxa,'timeout',1000); 
fopen(mxa);
 
fprintf(mxa,'INIT:CONT 0');
 
% Set the data trace format to REAL, 32 bits
fprintf(mxa,':FORM:DATA REAL,32');
%fprintf(mxa,':FORM:BORD NORM');
fprintf(mxa,':FORM:BORD SWAP');
 
fprintf(mxa,'INIT:IMM');
Operation_complete = query(mxa,'*OPC?');
 
% 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?'));
 
t1=clock;
% Get the trace data
fprintf(mxa,':TRAC? TRACE1');
[data,count,msg]  = binblockread(mxa,'float32')
fscanf(mxa); %removes the terminator character
pause(1)
etime(clock,t1)
 
% create and bring to front figure number 1
figure(1)
 
% Plot trace data vs sweep point index
plot(1:nr_points,data)
 
% 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 lines
grid on
title('Swept SA trace')
xlabel('Point index')
ylabel('Amplitude (dBm)')
 
% Disconnect an clean up
fclose(mxa);
delete(mxa);
clear mxa;  

Outcomes