Looking Assistance for Data Acquisition and Parallel Processing with USRP B200 in MATLAB

9 visualizaciones (últimos 30 días)
Hello dear MATLAB Community,
I am looking for a solution to receive and save data from the USRP B200 using the USRP Communicatios Toolbox and Parallel Computing Toolbox. When I try to save data using a parallel pool, I experience a delay of 2-3 seconds, during which I believe some samples are lost.
I am seeking a solution that allows my program to continuously receive data and, after a certain number of samples or a specific time period, save it using a parallel process.
Below is a part of my code. My system specifications include an 8-core CPU, 32 GB of RAM, and the latest version of MATLAB R2023a.
Thank you very much!
%% Create a parallel pool
poolobj = gcp('nocreate'); % If no pool, do not create new one.
if isempty(poolobj)
poolobj = parpool(6); % Create a new pool
end
%% Data acquisition loop
data = complex(zeros(round(receiveSettings.samples_per_frame), round(calculatedParameters.corr_iterations)));
if hardware.radioFound
% Capture loop
for o_frame = 1 : calculatedParameters.capture_number
while i_frame < calculatedParameters.corr_iterations
[output, dataLen, overrun, timestamp] = radio();
% Overrun check
if overrun == 1
overrun_counter = overrun_counter + 1;
end
% Validate received data
if dataLen >= receiveSettings.samples_per_frame
step(scope, output); % Display frequency spectrum
data(:, i_frame) = output; % Save data from USRP
i_frame = i_frame + 1;
end
end
tic
f = parfeval(poolobj, @saveDataAsync, 0, data, calculatedParameters, recorderSettings, usrpSettings, o_frame); % call save fuction
toc
end
%% Function that handles the saving of data to a WAV file
function saveDataAsync(data, calculatedParameters, recorderSettings, usrpSettings, o_frame)
data = reshape(data, [], 1); % Reshape 'data' into a column vector
% Normalize IQ data
data_I = real(data) / max(abs(real(data)));
data_Q = imag(data) / max(abs(imag(data)));
data_cat = [data_I, data_Q];
% Prepare filename for WAV saving
wavefile_IQ = sprintf('%s_%dHz_MCR_%dHz_Cfr_%dDf_%d', char(recorderSettings.wav_time), usrpSettings.master_clock_rate, usrpSettings.center_frequency, usrpSettings.descimationfactor, o_frame);
folderPath = 'D:\test';
filePath = fullfile(folderPath, [wavefile_IQ, '.wav']);
wavwrite_personal_function(data_cat, calculatedParameters.sample_rate, recorderSettings.rcvr, recorderSettings.nbits, filePath);
disp('Audio file saved successfully.');
end
  4 comentarios
Nik Rocky
Nik Rocky el 20 de Nov. de 2023
Yes, Sure: https://de.mathworks.com/help/supportpkg/usrpradio/ug/sdrureceiver.html#d126e7863

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Communications Toolbox en Help Center y File Exchange.

Productos


Versión

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by