⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 acquire trace timer.m

📁 Agilent 仪器与MATLAB互联
💻 M
字号:
function example6
% MATLAB/MXA example 6
% Getting and plotting trace data
% Continuous aquisition	with timer

% Version: 1.0
% Date: Sep 11, 2006  
% 2006 Agilent Technologies, Inc.

oldobjs=instrfind;
if ~isempty(oldobjs)
disp('Cleaning up ...')
delete(oldobjs);
clear oldobjs;
end

% Initial setup
mxa_ip = '141.121.92.157';
mxa=tcpip(mxa_ip, 5025);
set(mxa,'InputBufferSize',30000);
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)
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])
grid on

th =timer('timerfcn',@update_plot,...
          'ExecutionMode','FixedRate',...
          'Period',0.1);
 
start(th)
pause(10)
stop(th)



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

    function update_plot(varargin)
        % Get the trace data
        fprintf(mxa,'TRAC? TRACE1');

        data = binblockread(mxa,'float32');
        fscanf(mxa); %removes the terminator character

        % Plot trace data vs sweep point index
        set(ph,'Ydata',data);
        drawnow
        

    end

end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -