Hello.Sorry about that.Here is the generated code with a few of our modifications at the end.
____________________________________________________________________
#!/usr/bin/env python
##################################################
# Gnuradio Python Flow Graph
# Title: Fm Example
# Generated: Tue Jan 6 10:37:52 2015
##################################################
from gnuradio import analog
from gnuradio import audio
from gnuradio import eng_notation
from gnuradio import filter
from gnuradio import gr
from gnuradio import uhd
from gnuradio import wxgui
from gnuradio.eng_option import eng_option
from gnuradio.fft import window
from gnuradio.filter import firdes
from gnuradio.wxgui import fftsink2
from gnuradio.wxgui import forms
from grc_gnuradio import wxgui as grc_wxgui
from optparse import OptionParser
import time
import wx
class fm_example(grc_wxgui.top_block_gui):
def __init__(self):
grc_wxgui.top_block_gui.__init__(self, title="Fm Example")
_icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))
##################################################
# Variables
##################################################
self.samp_rate = samp_rate = 4e6
#self.freq = freq = 88.1e6
self.freq = freq
##################################################
# Blocks
##################################################
self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_LEFT)
self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "RF Spectrum")
self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Demod Spectrum")
self.Add(self.notebook_0)
self._freq_text_box = forms.text_box(
parent=self.GetWin(),
value=self.freq,
callback=self.set_freq,
label='freq',
converter=forms.float_converter(),
)
self.Add(self._freq_text_box)
self.wxgui_fftsink2_1 = fftsink2.fft_sink_f(
self.notebook_0.GetPage(1).GetWin(),
baseband_freq=0,
y_per_div=10,
y_divs=10,
ref_level=0,
ref_scale=2.0,
sample_rate=600e3,
fft_size=1024,
fft_rate=15,
average=False,
avg_alpha=None,
title="FFT Plot",
peak_hold=False,
win=window.rectangular,
)
self.notebook_0.GetPage(1).Add(self.wxgui_fftsink2_1.win)
self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
self.notebook_0.GetPage(0).GetWin(),
baseband_freq=freq,
y_per_div=10,
y_divs=10,
ref_level=0,
ref_scale=2.0,
sample_rate=samp_rate,
fft_size=1024,
fft_rate=15,
average=False,
avg_alpha=None,
title="FFT Plot",
peak_hold=False,
)
self.notebook_0.GetPage(0).Add(self.wxgui_fftsink2_0.win)
self.uhd_usrp_source_0 = uhd.usrp_source(
",".join(("serial=2R2CU0U1", "")),
uhd.stream_args(
cpu_format="fc32",
channels=range(1),
),
)
self.uhd_usrp_source_0.set_subdev_spec("A:0", 0)
self.uhd_usrp_source_0.set_samp_rate(samp_rate)
self.uhd_usrp_source_0.set_center_freq(freq, 0)
self.uhd_usrp_source_0.set_gain(15, 0)
self.uhd_usrp_source_0.set_antenna("RX2", 0)
self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
interpolation=240,
decimation=48,
taps=None,
fractional_bw=None,
)
self.low_pass_filter_0 = filter.fir_filter_ccf(20, firdes.low_pass(
1, samp_rate, 100e3, 10e3, firdes.WIN_HANN, 6.76))
self.audio_sink_0 = audio.sink(48000, "", False)
self.analog_wfm_rcv_0 = analog.wfm_rcv(
quad_rate=600e3,
audio_decimation=20,
)
##################################################
# Connections
##################################################
self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_fftsink2_0, 0))
self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_0, 0))
self.connect((self.analog_wfm_rcv_0, 0), (self.wxgui_fftsink2_1, 0))
self.connect((self.low_pass_filter_0, 0), (self.analog_wfm_rcv_0, 0))
self.connect((self.rational_resampler_xxx_0, 0), (self.audio_sink_0, 0))
self.connect((self.analog_wfm_rcv_0, 0), (self.rational_resampler_xxx_0, 0))
def get_samp_rate(self):
return self.samp_rate
def set_samp_rate(self, samp_rate):
self.samp_rate = samp_rate
self.wxgui_fftsink2_0.set_sample_rate(self.samp_rate)
self.uhd_usrp_source_0.set_samp_rate(self.samp_rate)
self.low_pass_filter_0.set_taps(firdes.low_pass(1, self.samp_rate, 100e3, 10e3, firdes.WIN_HANN, 6.76))
def get_freq(self):
return self.freq
def set_freq(self, freq):
self.freq = freq
self.wxgui_fftsink2_0.set_baseband_freq(self.freq)
self.uhd_usrp_source_0.set_center_freq(self.freq, 0)
self._freq_text_box.set_value(self.freq)
if __name__ == '__main__':
import ctypes
import sys
if sys.platform.startswith('linux'):
try:
x11 = ctypes.cdll.LoadLibrary('libX11.so')
x11.XInitThreads()
except:
print "Warning: failed to XInitThreads()"
parser = OptionParser(option_class=eng_option, usage="%prog: [options]")
(options, args) = parser.parse_args()
freq = 88.1e6
tb1 = fm_example()
tb1.Start(True)
tb1.Wait()
freq = freq+200e3
tb2 = fm_example()
tb2.Start(True)
tb2.Wait()
freq = freq+200e3
tb3 = fm_example()
tb3.Start(True)
tb3.Wait()
freq = freq+200e3
tb4 = fm_example()
tb4.Start(True)
tb4.Wait()
freq = freq+200e3
tb5 = fm_example()
tb5.Start(True)
tb5.Wait()
freq = freq+200e3
__________________________________________________________________________
Actually,we didn't type Start and Wait in lowercase letters since when we generated the code,____________________________________________________________________
#!/usr/bin/env python
##################################################
# Gnuradio Python Flow Graph
# Title: Fm Example
# Generated: Tue Jan 6 10:37:52 2015
##################################################
from gnuradio import analog
from gnuradio import audio
from gnuradio import eng_notation
from gnuradio import filter
from gnuradio import gr
from gnuradio import uhd
from gnuradio import wxgui
from gnuradio.eng_option import eng_option
from gnuradio.fft import window
from gnuradio.filter import firdes
from gnuradio.wxgui import fftsink2
from gnuradio.wxgui import forms
from grc_gnuradio import wxgui as grc_wxgui
from optparse import OptionParser
import time
import wx
class fm_example(grc_wxgui.top_block_gui):
def __init__(self):
grc_wxgui.top_block_gui.__init__(self, title="Fm Example")
_icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))
##################################################
# Variables
##################################################
self.samp_rate = samp_rate = 4e6
#self.freq = freq = 88.1e6
self.freq = freq
##################################################
# Blocks
##################################################
self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_LEFT)
self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "RF Spectrum")
self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Demod Spectrum")
self.Add(self.notebook_0)
self._freq_text_box = forms.text_box(
parent=self.GetWin(),
value=self.freq,
callback=self.set_freq,
label='freq',
converter=forms.float_converter(),
)
self.Add(self._freq_text_box)
self.wxgui_fftsink2_1 = fftsink2.fft_sink_f(
self.notebook_0.GetPage(1).GetWin(),
baseband_freq=0,
y_per_div=10,
y_divs=10,
ref_level=0,
ref_scale=2.0,
sample_rate=600e3,
fft_size=1024,
fft_rate=15,
average=False,
avg_alpha=None,
title="FFT Plot",
peak_hold=False,
win=window.rectangular,
)
self.notebook_0.GetPage(1).Add(self.wxgui_fftsink2_1.win)
self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
self.notebook_0.GetPage(0).GetWin(),
baseband_freq=freq,
y_per_div=10,
y_divs=10,
ref_level=0,
ref_scale=2.0,
sample_rate=samp_rate,
fft_size=1024,
fft_rate=15,
average=False,
avg_alpha=None,
title="FFT Plot",
peak_hold=False,
)
self.notebook_0.GetPage(0).Add(self.wxgui_fftsink2_0.win)
self.uhd_usrp_source_0 = uhd.usrp_source(
",".join(("serial=2R2CU0U1", "")),
uhd.stream_args(
cpu_format="fc32",
channels=range(1),
),
)
self.uhd_usrp_source_0.set_subdev_spec("A:0", 0)
self.uhd_usrp_source_0.set_samp_rate(samp_rate)
self.uhd_usrp_source_0.set_center_freq(freq, 0)
self.uhd_usrp_source_0.set_gain(15, 0)
self.uhd_usrp_source_0.set_antenna("RX2", 0)
self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
interpolation=240,
decimation=48,
taps=None,
fractional_bw=None,
)
self.low_pass_filter_0 = filter.fir_filter_ccf(20, firdes.low_pass(
1, samp_rate, 100e3, 10e3, firdes.WIN_HANN, 6.76))
self.audio_sink_0 = audio.sink(48000, "", False)
self.analog_wfm_rcv_0 = analog.wfm_rcv(
quad_rate=600e3,
audio_decimation=20,
)
##################################################
# Connections
##################################################
self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_fftsink2_0, 0))
self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_0, 0))
self.connect((self.analog_wfm_rcv_0, 0), (self.wxgui_fftsink2_1, 0))
self.connect((self.low_pass_filter_0, 0), (self.analog_wfm_rcv_0, 0))
self.connect((self.rational_resampler_xxx_0, 0), (self.audio_sink_0, 0))
self.connect((self.analog_wfm_rcv_0, 0), (self.rational_resampler_xxx_0, 0))
def get_samp_rate(self):
return self.samp_rate
def set_samp_rate(self, samp_rate):
self.samp_rate = samp_rate
self.wxgui_fftsink2_0.set_sample_rate(self.samp_rate)
self.uhd_usrp_source_0.set_samp_rate(self.samp_rate)
self.low_pass_filter_0.set_taps(firdes.low_pass(1, self.samp_rate, 100e3, 10e3, firdes.WIN_HANN, 6.76))
def get_freq(self):
return self.freq
def set_freq(self, freq):
self.freq = freq
self.wxgui_fftsink2_0.set_baseband_freq(self.freq)
self.uhd_usrp_source_0.set_center_freq(self.freq, 0)
self._freq_text_box.set_value(self.freq)
if __name__ == '__main__':
import ctypes
import sys
if sys.platform.startswith('linux'):
try:
x11 = ctypes.cdll.LoadLibrary('libX11.so')
x11.XInitThreads()
except:
print "Warning: failed to XInitThreads()"
parser = OptionParser(option_class=eng_option, usage="%prog: [options]")
(options, args) = parser.parse_args()
freq = 88.1e6
tb1 = fm_example()
tb1.Start(True)
tb1.Wait()
freq = freq+200e3
tb2 = fm_example()
tb2.Start(True)
tb2.Wait()
freq = freq+200e3
tb3 = fm_example()
tb3.Start(True)
tb3.Wait()
freq = freq+200e3
tb4 = fm_example()
tb4.Start(True)
tb4.Wait()
freq = freq+200e3
tb5 = fm_example()
tb5.Start(True)
tb5.Wait()
freq = freq+200e3
__________________________________________________________________________
Is there a limit to the number of "tb"s ?
We would also like to apologize for our mistake.What we meant by "closing the scope" was closing the output display, after running our modified code so that the next "tb" could run. Do you guys have any suggestions as to how to close the display On Thu, Feb 5, 2015 at 6:55 PM, Marcus Müller <marcus.mueller@ettus.com> wrote:
Hi Thesis,
first of all: be sure to actually copy and paste the code you're using; what you've pasted can't run, since python is case sensitive and start() and wait() are written in lower letters.
I don't understand what you mean with "close the scope"; can you elaborate?
Greetings,
Marcus
On 02/05/2015 05:12 AM, Thesis 2015 wrote:
Hello everyone!
We have been able to modify the python file to allow the receiver to jump from one frequency to another. We have modified it to be able to receive signals from local FM stations and jump from one frequency to another using the python file attached.
(Note:we modified it at the end part using:
tb1 = fm_example()
tb1.Start(True)
tb1.Wait()
freq = freq+200e3
We have also tried to increment it by 200kHZ for all frequencies using just the same code.We tried it up to tb70 and there is a certain point(after tb33, i believe) where it says the following error.(please see attached image)
We would like to ask the following questions:
1.From what I understand, tb.Wait is used for waiting for the flowgraph to finish.
WIth the code we used, we close the scope then it runs again with an incremented frequency.
Do you have any suggestions as to what code we can use to automatically close the
scope so it jumps to another frequency after a certain amount of seconds(lets say 10 seconds)?
2.What causes the error in the second similar code(pls see attached image)?
Thank you very much and have a good day.
On Wed, Dec 31, 2014 at 1:17 AM, Tom Rondeau <tom@trondeau.com> wrote:
On Sun, Dec 28, 2014 at 10:13 PM, Thesis 2015 <thesis15sie@gmail.com> wrote:If you have any other ideas that could help us, it would be greatly appreciated.Good day.Would it be fine if we placed a while or for loop statement under the variables section so that it would increment by 200kHz and would change to different frequencies within the FM spectrum.
-SKA15-
As Marcus said, feel free to play with these things to figure it out. But one hint you'll probably need is that any changes to the flowgraph need to happen after the top_block has already started. So look for the tb.run() or tb.start(). If using tb.run() this is a blocking call that you'll need to change:
tb.start()<your for-loop here>tb.stop()tb.wait()
Something like that.
Tom

No comments:
Post a Comment