Hi all,
i have been doing my final year project of MIMO-OFDM using gnuradio.
For this i first want to transmit a sine wave and i made a simple
program by the concept used in usrp_siggen.py. Although sine is
recieved successfully and its fft is plotted but it has a very low
amplitude and many harmonics. kindly have a look at my code:
#!/usr/bin/env python
from gnuradio import gr, gru
from gnuradio import usrp
import sys
class my_top_block(gr.top_block):
def init(self):
gr.top_block.init(self)
#1. source
#2. sink
#3. connect
self.interp = 64
self.sink = usrp.sink_c (0, self.interp) # Transmitter code
self.usb_freq = 1000000
self.src = gr.sig_source_c(self.usb_freq, gr.GR_SIN_WAVE,
2450000000, 32000, 0)
self.src.set_frequency(input(‘Set the frequency’))
self.connect(self.src, self.sink)
def main():
tb=my_top_block()
#tb.subdev.set_enable(True) # enable
transmitter
try:
tb.run()
except KeyboardInterrupt:
pass
if name == ‘main’:
main ()
Thanks in advance
Regards,
Ebtisam
So there’s a few things here. First, you’re using the old libusrp
driver,
which is fine, except it’s been deprecated for almost two years. I
recommend using UHD instead, it’s not hard to figure out, and we can
provide better support for it.
Second, you have a misunderstanding of how the USRP works with Gnuradio.
The USRP sink is set to a particular center frequency; the USRP will
handle
tuning the RF front end to that frequency. After that, your samples are
sent from your gr.sig_source_x to the USRP, which upconverts them to the
RF
frequency you selected earlier. In other words, you don’t send a 2.4GHz
sample rate to the USRP – you send a much lower sample rate to the
USRP,
and let it upconvert that to your center frequency. If you want to send
a
sine wave at 2400.5GHz, this is how it’d go:
from gnuradio import gr, gru, uhd
import sys
class my_tb(gr.top_block):
def init:
self.samp_rate = 2e6
self.center_freq = 2400e6
self.sig_freq = 500e3
self.src = gr.sig_source_c(self.samp_rate, gr.GR_SIN_WAVE,
self.sig_freq, 0.3) #0.3 is amplitude
self.sink = uhd.single_usrp_sink("",
uhd.io_type_t.COMPLEX_FLOAT32, 1)
self.sink.set_samp_rate(self.samp_rate) #set the sample rate to
2Msps
self.sink.set_gain(20) #set the gain to something reasonable
self.sink.set_center_freq(self.center_freq) #this is where you
tune
the RF center frequency
self.connect(self.src, self.sink)
if name == ‘main’:
tb = my_tb()
try:
my_tb.run()
except KeyboardInterrupt:
pass
–n