How to decrease elapsed time in the while loop?

조회 수: 7 (최근 30일)
Hassan hajj
Hassan hajj 2018년 4월 15일
I’m working on a radar project using USRP N210 with UBX-40 daughterboard using MATLAB. I am facing a problem when I run the code for receiving the echo of the transmitted pulse. It is taking 4 seconds for the board to start receiving and collecting first sample, which doesn’t suit at all my case. After the first sample, receiving elapsed time for the other echoes is in milliseconds which not good because, echoes in radars should be received within microseconds or less and not seconds and milliseconds!!
clear;
clc;
Fs= 50e6; % Sampling freq
t=0:1/Fs:10-1/Fs; %Time vector
PRI = 10e-6; %PRI
pw = 0.04e-6; %pulse width
d= 0:PRI:10; %delay vector
y_pulse = ones(Fs*pw,1);
connectedRadios = findsdru;
if strncmp(connectedRadios(1).Status, 'Success', 7)
radioFound = true;
platform = connectedRadios(1).Platform;
switch connectedRadios(1).Platform
case {'B200','B210'}
address = connectedRadios(1).SerialNum;
case {'N200/N210/USRP2','X300','X310'}
address = connectedRadios(1).IPAddress;
end
else
radioFound = false;
address = '192.168.10.2';
platform = 'N200/N210/USRP2';
end
gn = 23;
inf1=2;
rfTxFreq = 5e9; % RF Transmitter Center Frequency (Hz)
radioTx = comm.SDRuTransmitter('Platform', platform, ...
'IPAddress', address, ...
'CenterFrequency', rfTxFreq,...
'Gain', gn, ...
'InterpolationFactor', inf1)
radioRx = comm.SDRuReceiver(...
'Platform', platform, ...
'IPAddress', address, ...
'CenterFrequency', rfTxFreq,...
'Gain', gn, ...
'DecimationFactor', inf1,...
'SamplesPerFrame', 498,...
'OutputDataType','single')
for i=1:5
step(radioTx,y_pulse)
timeCounter = 0;
tic
while timeCounter < 1
[x, len] = step(radioRx);
pulses(:,i)=x ;
if len > 0
timeCounter = timeCounter + 1;
end
end
end
toc
release(radioTx)
release (radioRx)
clear radioRx

답변 (0개)

카테고리

Help CenterFile Exchange에서 Communications Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by