Post Go back to editing

Pluto SDR transmitting and receiving Data samples using python and adi library.

Category: Software
Product Number: ADALM-PLUTO
Software Version: Pluto Firmware v0.31

I am currently working on the simulation of FMCW radar using a pluto SDR for my major project, I am using rev B of the SDR, I have written the code for the generation and transmission of the baseband chirp. I tried transmitting it and checking the output with a spectrum analyzer, the result of this was that I was not able to see the whole spectrum of the transmitted frequencies in a single go but when I changed the analyzer setting from clear & Write to Max hold, I could see the spectrum as i want it. So, I needed some help in transmitting the spectrum all at once.  Below is the python code used by me to generate and transmit the chirp, the video which shows the issue faced by me.


import time
import adi
import numpy as np
import time

# Create radio
sdr = adi.Pluto(uri="ip:192.168.2.1")

# Configure properties
sdr.sample_rate = 60000000 #60e6
sdr.tx_rf_bandwidth = 20000000 #20e6
sdr.tx_lo = 2400000000
sdr.tx_hardwaregain_chan0 = -20
sdr.gain_control_mode_chan0 = "slow_attack"

# Configuration data channels
sdr.tx_enabled_channels = [0]

# Create a waveform
sample_rate = sdr.sample_rate
center_freq = sdr.tx_lo
pulse_duration = 140e-6  # sec
num_samps = int(sample_rate * pulse_duration)
if(~(num_samps%1024)):
    num_samps = 1024*(num_samps//1024)
if(num_samps == 0):
    num_samps = 1024
print(num_samps)
bandwidth = sdr.tx_rf_bandwidth #20e6

# Create transmit waveform 

# Create axis for transmitted chirp
time_axis = np.linspace(0, pulse_duration, num_samps)
f0 = - bandwidth / 2
f1 = + bandwidth / 2
c = 3e8  # Speed of light
alpha = bandwidth / pulse_duration

# Generation of transmitted signal
trans_chirp = np.exp(1j * 2 * np.pi * (f0 * time_axis + (alpha * time_axis ** 2) / 2))
trans_chirp = 2*14 

t_end = time.time() + 60 * 5
while time.time() < t_end:
    sdr.tx(trans_chirp)



Changes to the title
[edited by: Rajpatil at 8:14 AM (GMT -5) on 15 Feb 2024]
  • So, I needed some help in transmitting the spectrum all at once.

    Can you explain what you mean? Your code is incomplete.

    -Travis

  • when we check the fft of the transmitted signal we get a full spectrum of the transmitting frequencies like shown in the figure below but when we check the actual transmitted signal on spectrum analyser that is not the case. Sorry but I don't understand what part of my code is missing.

    in the above video shouldn't I be getting the Spectrum that I get at max hold normally too.

  • Sorry but I don't understand what part of my code is missing.

    Your code ends with

    t_end = time.time() + 60 * 5
    while time.time() < t_end:
    sdr.tx(trans_ch

    when we check the fft of the transmitted signal we get a full spectrum of the transmitting frequencies like shown in the figure below but when we check the actual transmitted signal on spectrum analyser that is not the case.

    When comparing your plot to the received data, what are the lengths of data? Have you tried using a large capture?

    -Travis

  • Your code ends with

    t_end = time.time() + 60 * 5
    while time.time() < t_end:
    sdr.tx(trans_ch

    Sorry for providing the incomplete code I've completed the code.

    When comparing your plot to the received data, what are the lengths of data? Have you tried using a large capture?

    I don't loop back the signal but instead I connect the transmitter directly to the spectrum analyser. Should that be a problem, the spectrum analyser automatically takes a sweep time.

  • import time
    import adi
    import numpy as np
    import time
    from scipy.signal import chirp

    # Create radio
    sdr = adi.Pluto(uri="ip:192.168.2.1")

    # Configure properties
    sdr.sample_rate = 60000000 #60e6
    sdr.tx_rf_bandwidth = 15000000 #20e6
    sdr.tx_lo = 2400000000
    sdr.tx_hardwaregain_chan0 = -20
    sdr.gain_control_mode_chan0 = "slow_attack"

    # Configuration data channels
    sdr.tx_enabled_channels = [0]

    # Create a waveform
    sample_rate = sdr.sample_rate
    center_freq = sdr.tx_lo
    pulse_duration = 129e-6  # sec
    num_samps = int(sample_rate * pulse_duration)
    if(~(num_samps%1024)):
        num_samps = 1024*(num_samps//1024)
    if(num_samps == 0):
        num_samps = 1024
    print(num_samps)
    bandwidth = sdr.tx_rf_bandwidth #20e6

    # Create transmit waveform
    # Create axis for transmitted chirp
    time_axis = np.linspace(0, pulse_duration, num_samps)
    f0 = - bandwidth / 2
    f1 = + bandwidth / 2
    c = 3e8  # Speed of light
    alpha = bandwidth / pulse_duration

    # Generation of transmitted signal
    trans_chirp = np.exp(1j * 2 * np.pi * (f0 * time_axis + (alpha * time_axis ** 2) / 2))

    trans_chirp *= 2**14 # The PlutoSDR expects samples to be between -2^14 and +2^14, not -1 and +1 like some SDRs
    sdr.tx_cyclic_buffer = True # Enable cyclic buffers
    t_end = time.time() + 60 * 2
    while time.time() < t_end:
        sdr.tx(trans_chirp)
  • t_end = time.time() + 60 * 2
    while time.time() < t_end:
        sdr.tx(trans_chirp)

    Remove this loop and simply send the data once to the device and insert a pause to prevent python from exiting. In cyclic mode the hardware will repeat the data.

    -Travis

  • Are you saying that I do it like this?
    sdr.tx_cyclic_buffer = True # Enable cyclic buffers
    sdr.tx(trans_chirp)
    time.delay(300)  #delay of  5 min
    sdr.tx_destroy_buffer()

    -Raj
  • Okay tomorrow when I get to my lab I'll Check it out and let you know. thankyou

    -Raj

  • Thankyou very much the full spectrun is seen now. I am just a bit closer to achieving my goal now.