-
Notifications
You must be signed in to change notification settings - Fork 2
Using the Python API
Benjamin Havens edited this page Jun 6, 2022
·
6 revisions
Follow the installation page on this wiki for your platform to install the Python UHD module.
This has a couple tricks to it. Our initial approach, which worked in MATLAB, did not transmit the proper cosine in python. We had to follow the example from uhd/host/examples/python; using this, we came up with this code to generate the waveform prototype:
# Generator function for low-pass equivalent signal of a cosine
sine = lambda n, freq_offset, rate: exp(n * 2j * pi * freq_offset / rate)
freq_offset = f1 - fc # Low pass equivalent frequency
n = arange(int(10 * floor(sample_rate / freq_offset)), dtype=complex64)
x_tilde = sine(n, freq_offset, sample_rate) # One period
We then create a MultiUSRP()
object and call send_waveform
on it.
We made a few changes to the module code itself. They are minute, but allow, at the moment:
- receiving with different gains on the two channels
To be able to use our receive.py
, you must make the following changes.
- On line 44 and 102 of
multi_usrp.py
in the~/uhd/host/python/uhd/usrp
folder: change line 44 to readgain=[10, 10],
rather thangain=10,
. Change line 102 to readsuper(MultiUSRP, self).set_rx_gain(gain[chan], chan)
rather thansuper(MultiUSRP, self).set_rx_gain(gain, chan)
. Once this is done, the two channels can have different gains when receiving.