How do you recieve your transmission, Live-script

I have data that I want to send over from the TX antenna to the RX antenna. (using the Adalm-Pluto, and MATLAB live script)
This is what I have so far...
tx_symbols_QAM16 % This is where my data comes from
rx_symbols_QAM16 % This is where my recieved data should go to
% Create recieve and send objects.
recieve_object = sdrrx("Pluto", ...
"RadioID", "usb:0", ...
"CenterFrequency", Pluto_CenterFrequencyGHz *1e9, ...
"GainSource", "AGC Fast Attack", ... % Automatic gain, set for signals with rapidly changing power levels.
"BasebandSampleRate", Pluto_BaseBandSampleRateMHz *1e6, ...
"OutputDataType", "double", ...
"SamplesPerFrame", Pluto_SamplesPerFrame, ...
"EnableBurstMode", Pluto_EnableBurstMode, ...
"NumFramesInBurst", Pluto_NumFramesInBurst)
transmit_object = sdrtx("Pluto", ...
"RadioID", "usb:0", ...
"CenterFrequency", Pluto_CenterFrequencyGHz *1e9, ...
"Gain", -10, ... % [-87.75..0]dB D=-10, step=0.25dB
"BasebandSampleRate", Pluto_BaseBandSampleRateMHz *1e6)
rx_symbols_QAM16 = recieve_object(); % Start recieving
transmit_object(tx_symbols_QAM16); % Start sending
But when I run this then it first recieves and when it is done recieving it will start transmitting.
How to recieve your own transmission?

 Accepted Answer

Koen
Koen on 10 Apr 2025
Edited: Koen on 10 Apr 2025
You first make the radio objects, with the settings that you want, see sdrtx & sdrrx, for more options.
sdrtx_object = sdrtx("Pluto")
sdrrx_object = sdrrx("Pluto")
Then call transmitRepeat to continuously transmit the data given, and then call the recieving object.
transmitRepeat(sdrtx_object, tx_symbols_modulated);
rx_symbols_modulated = sdrrx_object();
Do not forget to call *.release to stop the transmission and clean things up. (otherwise I observed wierd behaviour)
sdrrx_object.release
sdrtx_object.release
Remember that you might drop in halfway into your message, so you'll have to record for twice the length of your message. You can after then search for your start symbols.

More Answers (1)

sdrtx() supports BISTLoopbackMode

11 Comments

Hello Walter Roberson, Thank you for your responce, but I would like to ask you to elaborate further please.
I could not find a BISTLoopback for the recieving end. And I do not understand how to get the output data without rx(). So I tried this:
tx_symbols_QAM16 = 3+3i;3-3i;-3+3i;-3-3i; % This is where my data comes from
Pluto_CenterFrequencyGHz = 1.8
Pluto_BaseBandSampleRateMHz = 1
% Transmitter parameter structure
configurePlutoRadio('AD9364','usb:0') % AD9364, has a higher samplerate and frequency range, and is non-default, see https://nl.mathworks.com/help/releases/R2024b/comm/plutoradio/ref/configureplutoradio.html
rx = sdrrx("Pluto", ...
"RadioID", "usb:0", ...
"CenterFrequency", Pluto_CenterFrequencyGHz *1e9, ...
"GainSource", "AGC Fast Attack", ... % Automatic gain, set for signals with rapidly changing power levels.
"BasebandSampleRate", Pluto_BaseBandSampleRateMHz *1e6, ...
"OutputDataType", "double", ...
"SamplesPerFrame", 20000)% [2..16777216] Default=20000: is how many symbols would be have to be recieved.
tx = sdrtx("Pluto", ...
"RadioID", "usb:0", ...
"CenterFrequency", Pluto_CenterFrequencyGHz *1e9, ...
"Gain", -10, ... % [-87.75..0]dB Default=-10, step=0.25dB
"BasebandSampleRate", Pluto_BaseBandSampleRateMHz *1e6,...
"BISTLoopbackMode", "RF Rx -> RF Tx")
rx_symbols_QAM16 = rx();
tx(tx_symbols_QAM16);
But it gives a warning for the sdrtx, and an error for the tx(tx_symbols_QAM16);
The rx() still picks up some faint background noice. Indicating that it still only recieves then sends.
I do not understand what either the warning nor the error mean.
I did notice that the warning goes away if I add:
"ShowAdvancedProperties",true,...
Before the "BISTLoopbackMode", but then the errors still remain.
I am doing something wrong, and I would appriciate some more help.
That does get rid of my warning but not the errors.
Did you enable ShowAdvancedProperties on the receiver as well?
I did now, and rebooted my pc for good luck, but still the same errors.
These are all the properties, they all look quite the same:
The error is due to that you need to add
rx.BISTLoopbackMode = "RF Rx -> RF Tx"
to your sdrrx object after creation, and before calling it. (rx is the object in example)
Unfortunately I cannot seem to both run the RX and TX at the same time, using the Adalm-Pluto; Kinda like how awgn works but then with the Adalm-Pluto antennas.
BISTLoopbackModes appear to more be made to bypass the real antennas in case of "RF", and the analog circuitry in case of "Digital", I rather want to have a function that is both the rx+tx at the same time, so I recieve what i transmitted with noice over it from the real world.
So far I have tried using:
  • eval (but I could not give the input variables with the functions, since the new window did not have access to the workspace)
eval('!matlab -nodesktop -nosplash -r "rx_symbols_QAM16 = rx()" &')
eval('!matlab -nodesktop -nosplash -r "tx(tx_symbols_QAM16)" &')
  • parfor (I couldn't get this to work for 2 different functions)
  • Then I found parfeval what is way more suited to the need, but I get an error stating that I cannot use it (or i am using it wrong):
parpool("Processes",2)
f(1) = parfeval(backgroundPool,@do_rx,1,rx)
f(2) = parfeval(backgroundPool,@do_tx,1,tx,tx_symbols_QAM16)
function rx_symbols_QAM16 = do_rx(sdrrx_object)
rx_symbols_QAM16 = sdrrx_object();
end
function done = do_tx(sdrtx_object, input_tx_symbols)
sdrtx_object(input_tx_symbols);
done = true;
end
Output: "Use of function cd to change current folder is not supported on a thread-based worker. Use alternatives supported on the background pool."
If you are using MS Windows, then you can use System.Diagnostics.Process to create processes that you can pipe input to and get "live" output from.
If you are using Linux, then you can go through the trouble of creating named pipes that can be read from or written to.
I don't fully understand how to use that. I am still quite new to MATLAB and windows console.
I found this thread https://nl.mathworks.com/matlabcentral/answers/575608-system-and-system-diagnostics-process it seems as this can run a command, to start matlab in a seperate process.
However my folowup questions would be:
  • How do I do that in such a way that that process has access to the workspace (of the main process).
  • And if I cannot how do i get the inputs to the sdrtx and output from the sdrrx?
It will never be possible to get access to a workspace from a process started by !matlab or System.Diagnostics.Process, or parfor or parfeval with process pool. (parfeval() with a background pool in theory shares some of the address space, but there are restricted things you can do with the shared access.)
To transfer information to a process started with System.Diagnostics.Process, use input redirection. See for example https://www.mathworks.com/matlabcentral/answers/586706-how-to-redirect-standard-input-and-standard-output-using-net-system-diagnostics-process#answer_487475
Koen
Koen on 10 Apr 2025
Edited: Koen on 10 Apr 2025
Unfortunately, I never got it to work.
When using pareval or parfor with process pool, together with the load() to get the variable data, there was always something not working or refusing to work properly.
I have found an other solution, Thank you for your help.

Sign in to comment.

Products

Release

R2024b

Asked:

on 19 Feb 2025

Edited:

on 10 Apr 2025

Community Treasure Hunt

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

Start Hunting!