Risposta
+++Code+++
% Preconditions:
% - Installed latest R&S VISA
clc;
analyzer_handle = visa('rs','TCPIP::10.205.0.101::INSTR'); %visa connection, toolbox required
analyzer_handle.OutputBufferSize = 1000000; %output buffer size in bytes
analyzer_handle.InputBufferSize = 1000000; %input buffer size in bytes
fopen(analyzer_handle);
fprintf(analyzer_handle,'*RST;*WAI');
fprintf(analyzer_handle,'*IDN?');
a=fscanf(analyzer_handle);
disp(a);
fprintf(analyzer_handle,'INIT:CONT OFF'); %Selects single sweep mode.
%--------------Configuring the Frequency and Span-------------
fcenter=1000000000;
fprintf(analyzer_handle,'FREQ:CENT %d',fcenter); %Defines the center frequency
fspan=5000000;
fprintf(analyzer_handle,'FREQ:SPAN %d',fspan); %Sets the span
%--------------Configuring the Sweep--------------------------
fprintf(analyzer_handle,'SENS:SWE:COUN 1'); %Defines 1 sweep
points=10000; %nr of points sets resolution of the trace
fprintf(analyzer_handle, 'SENS:SWE:POIN %d',points);
%--------------Configuring the Bandwidth----------------------
fprintf(analyzer_handle,'BAND:AUTO OFF');
fprintf(analyzer_handle,'BAND 100000'); %Defines the RBW
fprintf(analyzer_handle,'BAND:VID 500kHz'); %Decouples the VBW from the RBW and decreases it to smooth the trace.
%--------------trace acquisition-----------------------------
timeout=30; %timeout in seconds
set(analyzer_handle,'Timeout',timeout); %timeout increased before acquisition to avoid sync errors
fprintf(analyzer_handle,'INIT:IMM;*WAI');
fprintf('Fetching waveform ...\n ');
fprintf(analyzer_handle,':FORM REAL,32');
fprintf(analyzer_handle,':TRAC? TRACE1;*WAI');
data=binblockread(analyzer_handle,'float32');
fread(analyzer_handle,1); %fread removes the extra terminator in the buffer
timeout=1; %timeout in seconds goes back to a normal value
set(analyzer_handle,'Timeout',timeout);
%--------------Presentation of the trace in a plot---------
fstart=fcenter-fspan/2;
fstop=fcenter+fspan/2;
resolution=fspan/points;
points_array=1:1:points;
for c = 1:points %scale time axis and power data
points_array(1,c)=points_array(1,c)*resolution;
points_array(1,c)=points_array(1,c) + fstart;
end
plot(points_array,data);
title('SA Spectrum Acquisition')
xlabel('frequency domain [Hz]')
ylabel('power [dbm]')
%--------------error check up----------------------
fprintf(analyzer_handle,'SYST:ERR?');
a=fscanf(analyzer_handle);
disp(a);
fclose(analyzer_handle);
+++
Di seguito è riportata la forma d'onda osservata nell'analizzatore di spettro dopo l'esecuzione dello script precedente con Matlab.