Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

the specified amount of data was not returned within the timeout period?

Asked by su on 16 Jun 2014

I am using the tcpip to connect the matlab and Agilent N9020A. I would like to use the matlab to control the N9020A to measure periodically and transmit the measurement data to matlab real-time.the code is as-follow:

addressMXA='169.254.33.22';
centerFrequency=2.16e9;
bandwidth=25e6;
measureTime=8e-3;
mechAttenuation=0;
startFrequency=2.15e9;
stopFrequency=2.17e9;
resolutionBandwidth=200e3;
videoBandwidth=300;
spectrumAnalyzerObject=tcpip(addressMXA,5023);
set(spectrumAnalyzerObject,'InputBufferSize',30e4);
set(spectrumAnalyzerObject,'Timeout',50);
fopen(spectrumAnalyzerObject);
fprintf(spectrumAnalyzerObject, '*RST');
instrumentInfo = query(spectrumAnalyzerObject, '*IDN?');
disp(['Instrument identification information: ' instrumentInfo]);
fprintf(spectrumAnalyzerObject,':INSTrument:SELect BASIC');
fprintf(spectrumAnalyzerObject,[':SENSe:FREQuency:CENTer ' num2str(centerFrequency)]);
fprintf(spectrumAnalyzerObject,[':SENSe:WAVEform:BANDwidth:RESolution ' num2str(bandwidth)]);
fprintf(spectrumAnalyzerObject,':SENSe:WAVeform:AVER OFF');
fprintf(spectrumAnalyzerObject,':INIT:CONT OFF');
fprintf(spectrumAnalyzerObject,':TRIGger:WAVeform:SOURce EXTernal1');
fprintf(spectrumAnalyzerObject,':TRIGger:EXTernal1:SLOPe POSitive');
fprintf(spectrumAnalyzerObject,':SENSe:POWer:RF:EATTenuation:STATe OFF');
fprintf(spectrumAnalyzerObject,[':SENSe:POWer:RF:ATTenuation ' num2str(mechAttenuation)]);
% Turn IQ signal ranging to auto
fprintf(spectrumAnalyzerObject,':SENSe:VOLTage:IQ:RANGe:AUTO ON');
% Set the endianness of returned data
fprintf(spectrumAnalyzerObject,':FORMat:BORDer NORMal');
% Set the format of the returned data
fprintf(spectrumAnalyzerObject,':FORMat:DATA REAL,32');
fprintf(spectrumAnalyzerObject,'*TRG');
fprintf(spectrumAnalyzerObject,':INITiate:WAVeform');
% wait till measure operation is complete
measureComplete = query(spectrumAnalyzerObject,'*OPC?');
% Read the IQ data
fprintf(spectrumAnalyzerObject,':READ:WAV0?');
data=binblockread(spectrumAnalyzerObject,'float');
% Get the nr of trace points
nr_points = str2double(query(spectrumAnalyzerObject,':SWE:POIN?'));
% Get the trace data
fprintf(spectrumAnalyzerObject,':TRAC? TRACE1');
fscanf(spectrumAnalyzerObject); 
% Read the additional terminator character from the instrument
    fread(spectrumAnalyzerObject,1);
but it can't work, I could't get the trace_data.and the warning is: the specified amount of data was not returned within the timeout period.
could someone give me some advice or point out my fault? it has confused me long time,need your help!
huge thanks

0 Comments

su

Products

No products are associated with this question.

0 Answers

Contact us