AnsweredAssumed Answered

Pluto Tx/Rx in Matlab Script

Question asked by MarcusW on Nov 25, 2017
Latest reply on Nov 28, 2017 by IPrium

I've been playing around a bit with the Pluto using Matlab Simulink and have successfully been able to build some very simple designs - but I'm struggling a bit now as I'm trying to do the equivalent in a Matlab script .  I have a couple of questions I'm hoping someone might be able to address:

 

1, Can someone explain a bit about how frames are used to send data to the Pluto?  When used for transmit functionality is it analogous to a buffer?  Do you need to wait for the buffer to clear before sending more data to the Pluto or how does that work? 

 

2, I've successfully been able to use the "transmitRepeat()" function to save off a sine wave like the Matlab example provided, but does anyone know the limits of that function?  For example how long of a sample can you save to the Pluto to repeat?  (Note, here radio_rx = sdrrx(...) and radio_tx = sdrtx(...) )

 

% Save a constantly repeating waveform to the Pluto TX hardware

transmitRepeat(radio_tx, tx_waveform);

 

% Setup a receiver loop (20 seconds)

runtime = tic;

while toc(runtime) < 20

   data = radio_rx();   % Receive a frame of data

   scope(data);         % Display received data in DSP Spectrum Analyzer           

end

 

3, using the script shown above, I've been able to transmit and receive at the same time, but I'm struggling to implement a function that transmits continuous data provided over USB and receive that data simultaneously.  Is something like the code below sensible, or is there better and proper way to do it?  I feel like the code below would either (a) hang up until the tx_waveform data has completely finished transmitting, (b) result in the TX buffer getting overwritten with new data before the old data finished transmitting, or (c) would leave a gap in time between radio_tx and radio_rx functionality.  

 

% Setup a receiver loop (20 seconds)

runtime = tic;

while toc(runtime) < 20

   radio_tx(tx_waveform);   % Transmit data

   data = radio_rx();       % Receive a frame of data

   scope(data);             % Display received data in DSP Spectrum Analyzer           

end

 

4, I've been trying to prove that I can reliably transmit and receive data by doing a linear frequency modulated chirp and watch it move across the Matlab spectrum analyzer scope from 5 KHz to 20 KHz with a 1 second period, but have failed miserably at it - and I think my lack of understanding of the above 3 questions is at least partially to blame for it.  Below is my attempt at pulling it off.  Any suggestions or obvious mistakes? The output I get with this code is just a tone at 5 KHz and a spectrum in general that erratically jumps up and down in amplitude.  (.m file attached to this post).

 

 

% Initialize Script

clear all;

clc;

fs = 1e6;

 

% Initialize SDR

sdrdev('Pluto');

 

% Initialize SDR Receiver Functionality

radio_rx = sdrrx('Pluto',...

    'RadioID',              'usb:0',...

    'CenterFrequency',      1e9,...

    'BasebandSampleRate',   fs,...

    'GainSource',           'AGC Fast Attack',...

    'OutputDataType',       'double',...

    'SamplesPerFrame',      20000);

 

% Initialize SDR Transmit Functionality

radio_tx = sdrtx('Pluto',...

    'RadioID',              'usb:0',...

    'CenterFrequency',      1e9,...

    'BasebandSampleRate',   fs,...

    'Gain',-10);

 

% Create a spectrum analyzer scope to visualize the signal spectrum

scope = dsp.SpectrumAnalyzer(...

    'Name',                 'Spectrum Analyzer',...

    'Title',                'Spectrum Analyzer', ...

    'SpectrumType',         'Power',...

    'FrequencySpan',        'Full', ...

    'SampleRate',           fs, ...

    'YLimits',              [-60,40],...

    'SpectralAverages',     10, ...

    'FrequencySpan',        'Start and stop frequencies', ...

    'StartFrequency',       -100e3, ...

    'StopFrequency',        100e3,...

    'Position',             figposition([20 10 60 60]));

 

% Create TX Chirp from 5KHz - 20KHz

chrp = dsp.Chirp;

chrp.SweepDirection = 'Unidirectional';

chrp.TargetFrequency = 20e3;

chrp.InitialFrequency = 5e3;

chrp.TargetTime = 1;

chrp.SweepTime = 1;

chrp.SamplesPerFrame = 5000;

chrp.SampleRate = fs;

tx_waveform = chrp();

 

% Do an initial TX/RX so that tic/toc timing 

% works correctly in the main loop

radio_tx(tx_waveform);

data = radio_rx();

 

% Transmit/Receive for 20 seconds

disp('Starting Now');

runtime = tic;

while toc(runtime) < 20

    % Tx

    radio_tx(tx_waveform);

    

    % Receive a frame

    data = radio_rx();

    

    % Display the frame

    scope(data); 

 

end

 

% Release Pluto resources

release(radio_tx);

release(radio_rx);

disp('Done');

 

Chirp Result

 

5, Lastly, on a totally different note, how is it that when I send complex samples to the Pluto transmitter function I get a one sided spectrum, and when I send only real valued samples I get a double sided spectrum?  Is that a standard way that software defined radios operate?  I thought you had to run your signal through a Hilbert transform in order to just get a single sideband - is that function built into the radio?

 

Thank You,

Marcus

Attachments

Outcomes