def test_fm_001(self): pi = math.pi sensitivity = pi / 4 src_data = (1.0 / 4, 1.0 / 2, 1.0 / 4, -1.0 / 4, -1.0 / 2, -1 / 4.0) expected_result = tuple([sincos(sensitivity * x) for x in src_data]) src = blocks.vector_source_f(src_data) op = analog.phase_modulator_fc(sensitivity) dst = blocks.vector_sink_c() self.tb.connect(src, op) self.tb.connect(op, dst) self.tb.run() result_data = dst.data() self.assertComplexTuplesAlmostEqual(expected_result, result_data, 5)
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") _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 = 1e6 ################################################## # Blocks ################################################## self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.GetWin(), title="Scope Plot", sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Add(self.wxgui_scopesink2_0.win) self.iir_filter_xxx_0 = filter.iir_filter_ffd((0.000005, ), ([1,1]), True) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.analog_sig_source_x_0_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 10000, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 100000, 1, 0) self.analog_phase_modulator_fc_0 = analog.phase_modulator_fc(100000) ################################################## # Connections ################################################## self.connect((self.analog_phase_modulator_fc_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.iir_filter_xxx_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.iir_filter_xxx_0, 0), (self.analog_phase_modulator_fc_0, 0))
def __init__(self, sym_rate=256, samp_per_sym=256, nominal_uplink_freq=2041.95e6*0 + 2041.9479e6 + 1e6*0, lo_off=5e6 * 0, tx_gain=15*0 + 13.5*0, backoff=0.150*0 + (0.6+0.1)*0 + 1e-3, record_path='/media/balint/PATRIOT/ICE/TX/'): grc_wxgui.top_block_gui.__init__(self, title="Uplink") ################################################## # Parameters ################################################## self.sym_rate = sym_rate self.samp_per_sym = samp_per_sym self.nominal_uplink_freq = nominal_uplink_freq self.lo_off = lo_off self.tx_gain = tx_gain self.backoff = backoff self.record_path = record_path ################################################## # Variables ################################################## self.time_format = time_format = "%Y-%d-%m_%H-%M-%S" self.time_now = time_now = time.strftime(time_format) self.samp_rate = samp_rate = 250000 self.pre_resamp_rate = pre_resamp_rate = sym_rate * samp_per_sym self.f1 = f1 = 9000.0 self.f0 = f0 = 7500.0 self.resamp_rate = resamp_rate = float(samp_rate)/float(pre_resamp_rate) self.pm = pm = 1.2*0 + 1.0 self.nominal_uplink_freq_chooser = nominal_uplink_freq_chooser = nominal_uplink_freq self.manual_doppler = manual_doppler = 0 self.file_name = file_name = time_now + ".mcfile" self.doppler = doppler = 0 self.deviation = deviation = (f1 - f0) / 2.0 self.tx_gain_user = tx_gain_user = tx_gain self.subcarrier_freq = subcarrier_freq = f0 + deviation self.source = source = 'external' self.pm_txt = pm_txt = pm self.nominal_uplink_freq_user = nominal_uplink_freq_user = nominal_uplink_freq_chooser self.lo_off_user = lo_off_user = lo_off self.length_mul = length_mul = float(samp_per_sym) * resamp_rate self.invert = invert = 1 self.final_record_path = final_record_path = os.path.join(record_path, file_name) self.final_doppler = final_doppler = doppler + manual_doppler self.backoff_user = backoff_user = backoff ################################################## # Blocks ################################################## _tx_gain_user_sizer = wx.BoxSizer(wx.VERTICAL) self._tx_gain_user_text_box = forms.text_box( parent=self.GetWin(), sizer=_tx_gain_user_sizer, value=self.tx_gain_user, callback=self.set_tx_gain_user, label="TX Gain", converter=forms.float_converter(), proportion=0, ) self._tx_gain_user_slider = forms.slider( parent=self.GetWin(), sizer=_tx_gain_user_sizer, value=self.tx_gain_user, callback=self.set_tx_gain_user, minimum=0, maximum=32, num_steps=32, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_tx_gain_user_sizer) self._nominal_uplink_freq_user_text_box = forms.text_box( parent=self.GetWin(), value=self.nominal_uplink_freq_user, callback=self.set_nominal_uplink_freq_user, label="Nominal Uplink Freq", converter=forms.float_converter(), ) self.Add(self._nominal_uplink_freq_user_text_box) self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.nb.AddPage(grc_wxgui.Panel(self.nb), "Output FFT") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Input FFT") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Input Phase/Mag") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Mod Clk/Data") self.nb.AddPage(grc_wxgui.Panel(self.nb), "PM Output Scope") self.nb.AddPage(grc_wxgui.Panel(self.nb), "PM Input") self.Add(self.nb) self._lo_off_user_text_box = forms.text_box( parent=self.GetWin(), value=self.lo_off_user, callback=self.set_lo_off_user, label="LO Offset", converter=forms.float_converter(), ) self.Add(self._lo_off_user_text_box) self._final_doppler_static_text = forms.static_text( parent=self.GetWin(), value=self.final_doppler, callback=self.set_final_doppler, label="Final Doppler", converter=forms.float_converter(), ) self.Add(self._final_doppler_static_text) self._doppler_text_box = forms.text_box( parent=self.GetWin(), value=self.doppler, callback=self.set_doppler, label="Doppler Shift", converter=forms.float_converter(), ) self.Add(self._doppler_text_box) _backoff_user_sizer = wx.BoxSizer(wx.VERTICAL) self._backoff_user_text_box = forms.text_box( parent=self.GetWin(), sizer=_backoff_user_sizer, value=self.backoff_user, callback=self.set_backoff_user, label="Backoff", converter=forms.float_converter(), proportion=0, ) self._backoff_user_slider = forms.slider( parent=self.GetWin(), sizer=_backoff_user_sizer, value=self.backoff_user, callback=self.set_backoff_user, minimum=0, maximum=1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_backoff_user_sizer) self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer(("", 52003), allow_none=True) self.xmlrpc_server_0.register_instance(self) threading.Thread(target=self.xmlrpc_server_0.serve_forever).start() self.wxgui_scopesink2_2 = scopesink2.scope_sink_f( self.nb.GetPage(5).GetWin(), title="Scope Plot", sample_rate=pre_resamp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(5).Add(self.wxgui_scopesink2_2.win) self.wxgui_scopesink2_1 = scopesink2.scope_sink_c( self.nb.GetPage(4).GetWin(), title="Scope Plot", sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(4).Add(self.wxgui_scopesink2_1.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.nb.GetPage(0).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=256, fft_rate=10, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, fft_in=False, always_run=False, fft_out=False, ) self.nb.GetPage(0).Add(self.wxgui_fftsink2_0.win) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("serial=F4A7C3", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), "", True, ) self.uhd_usrp_sink_0.set_clock_source(source, 0) self.uhd_usrp_sink_0.set_time_source(source, 0) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(uhd.tune_request(nominal_uplink_freq_user,lo_off_user), 0) self.uhd_usrp_sink_0.set_gain(tx_gain*0 + tx_gain_user, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=int(samp_rate), decimation=int(pre_resamp_rate), taps=None, fractional_bw=None, ) self._pm_txt_static_text = forms.static_text( parent=self.GetWin(), value=self.pm_txt, callback=self.set_pm_txt, label="Phase Moduation Index", converter=forms.float_converter(), ) self.Add(self._pm_txt_static_text) self._nominal_uplink_freq_chooser_chooser = forms.drop_down( parent=self.GetWin(), value=self.nominal_uplink_freq_chooser, callback=self.set_nominal_uplink_freq_chooser, label="Nomial Uplink Frequency", choices=[2041.9479e6, 2090.66e6], labels=['B: 2041.9479', 'A: 2090.66'], ) self.Add(self._nominal_uplink_freq_chooser_chooser) self._manual_doppler_text_box = forms.text_box( parent=self.GetWin(), value=self.manual_doppler, callback=self.set_manual_doppler, label="Manual Doppler", converter=forms.float_converter(), ) self.Add(self._manual_doppler_text_box) self.mac_burst_tagger_0 = mac.burst_tagger('packet_len', length_mul, 256, 32*0 + 256, True, False) self.clock_and_data = scopesink2.scope_sink_c( self.nb.GetPage(3).GetWin(), title="Scope Plot", sample_rate=pre_resamp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(3).Add(self.clock_and_data.win) self.carrier = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, doppler*0 + final_doppler, 0*backoff + backoff_user, 0) self.blocks_vector_source_x_0 = blocks.vector_source_f(tuple([1] * (samp_per_sym/4) + [0] * (samp_per_sym/4) + [0] * (samp_per_sym/4) + [1] * (samp_per_sym/4)), True, 1, []) self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_SERVER", "", "52002", 10000, False) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float*1, samp_per_sym) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, "packet_len", 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1) self.blocks_multiply_xx_1 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vff((2.0/3, )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((2, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((invert, )) self.blocks_message_strobe_0_0 = blocks.message_strobe(pmt.cons(pmt.to_pmt({'ignore': True}), pmt.init_u8vector(1, 1*[0])), 0) self.blocks_float_to_complex_2 = blocks.float_to_complex(1) self.blocks_float_to_complex_1 = blocks.float_to_complex(1) self.blocks_file_meta_sink_0 = blocks.file_meta_sink(gr.sizeof_gr_complex*1, final_record_path, samp_rate, 1, blocks.GR_FILE_FLOAT, True, 1000000, "", True) self.blocks_file_meta_sink_0.set_unbuffered(False) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.blocks_add_const_vxx_1_0 = blocks.add_const_vff((1.0/3, )) self.blocks_add_const_vxx_1 = blocks.add_const_vff((-1, )) self.binary_to_pdu0 = isee3.binary_to_pdu() self.analog_sig_source_x_0 = analog.sig_source_c(pre_resamp_rate, analog.GR_COS_WAVE, subcarrier_freq, 1/1.333, 0) self.analog_phase_modulator_fc_1 = analog.phase_modulator_fc(pm / (2.0*0 + 1)) self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc(float(deviation) / float(pre_resamp_rate) * math.pi*2.0) ################################################## # Connections ################################################## self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_add_const_vxx_1, 0)) self.connect((self.blocks_add_const_vxx_1, 0), (self.blocks_repeat_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.analog_frequency_modulator_fc_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.blocks_add_const_vxx_1_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_multiply_const_vxx_1_0, 0)) self.connect((self.blocks_add_const_vxx_1_0, 0), (self.blocks_float_to_complex_2, 0)) self.connect((self.blocks_float_to_complex_1, 0), (self.clock_and_data, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.carrier, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.blocks_add_const_vxx_1_0, 0), (self.blocks_float_to_complex_1, 1)) self.connect((self.blocks_repeat_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.analog_frequency_modulator_fc_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.analog_phase_modulator_fc_1, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_null_sink_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.wxgui_scopesink2_2, 0)) self.connect((self.blocks_add_const_vxx_1_0, 0), (self.blocks_float_to_complex_2, 1)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_float_to_complex_1, 0)) self.connect((self.blocks_float_to_complex_2, 0), (self.blocks_multiply_xx_0, 2)) self.connect((self.mac_burst_tagger_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.mac_burst_tagger_0, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.wxgui_scopesink2_1, 0)) self.connect((self.analog_phase_modulator_fc_1, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.mac_burst_tagger_0, 0), (self.blocks_file_meta_sink_0, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.binary_to_pdu0, "pdu_out", self.blocks_pdu_to_tagged_stream_0, "pdus") self.msg_connect(self.blocks_socket_pdu_0, "pdus", self.binary_to_pdu0, "binary_in") self.msg_connect(self.blocks_message_strobe_0_0, "strobe", self.blocks_pdu_to_tagged_stream_0, "pdus") self.msg_connect(self.uhd_usrp_sink_0, "ctl", self.blocks_message_strobe_0_0, "trigger")
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 300e3 ################################################## # Blocks ################################################## self.qtgui_time_sink_x_0_1_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_1_0.set_update_time(0.10) self.qtgui_time_sink_x_0_1_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_1_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0_1_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_1_0.enable_autoscale(True) self.qtgui_time_sink_x_0_1_0.enable_grid(False) self.qtgui_time_sink_x_0_1_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_1_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2 * 1): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0_1_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0_1_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0_1_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_1_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_1_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_1_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_1_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_1_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_1_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_1_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_1_0_win) self.qtgui_time_sink_x_0_1 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_1.set_update_time(0.10) self.qtgui_time_sink_x_0_1.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_1.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0_1.enable_tags(-1, True) self.qtgui_time_sink_x_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_1.enable_autoscale(True) self.qtgui_time_sink_x_0_1.enable_grid(False) self.qtgui_time_sink_x_0_1.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_1.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_1_win = sip.wrapinstance( self.qtgui_time_sink_x_0_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_1_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(True) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.iir_filter_xxx_0 = filter.iir_filter_ffd((1.0 / samp_rate, ), ([1, 1]), True) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.analog_sig_source_x_0_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, 10000, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, 1000, 1, 0) self.analog_phase_modulator_fc_0 = analog.phase_modulator_fc(2 * 3.14 * 5000) ################################################## # Connections ################################################## self.connect((self.analog_phase_modulator_fc_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.iir_filter_xxx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.qtgui_time_sink_x_0_1, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_sig_source_x_0_0, 0), (self.qtgui_time_sink_x_0_1_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.iir_filter_xxx_0, 0), (self.analog_phase_modulator_fc_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.quad_rate = quad_rate = 640000 self.audio_rate = audio_rate = 40000 ################################################## # Blocks ################################################## self.n = self.n = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.n.AddPage(grc_wxgui.Panel(self.n), "FM") self.n.AddPage(grc_wxgui.Panel(self.n), "FFT") self.Add(self.n) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.n.GetPage(0).GetWin(), title="Scope Plot", sample_rate=audio_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.n.GetPage(0).Add(self.wxgui_scopesink2_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_f( self.n.GetPage(1).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=audio_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.n.GetPage(1).Add(self.wxgui_fftsink2_0.win) self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=16, decimation=1, taps=None, fractional_bw=None, ) self.low_pass_filter_0 = filter.fir_filter_fff(16, firdes.low_pass( 1, quad_rate, 15000, 4000, firdes.WIN_HAMMING, 6.76)) self.iir_filter_xxx_2 = filter.iir_filter_ffd(([1,0]), ([1,0.95]), True) self.iir_filter_xxx_1 = filter.iir_filter_ffd(([1,-0.95]), ([1,0]), True) self.iir_filter_xxx_0 = filter.iir_filter_ffd((25e-6, ), ([1,1]), True) self.dc_blocker_xx_0 = filter.dc_blocker_ff(32, True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, audio_rate,True) self.blocks_multiply_xx_1 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, 1) self.blocks_conjugate_cc_0 = blocks.conjugate_cc() self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_add_xx_1 = blocks.add_vcc(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.analog_sig_source_x_2 = analog.sig_source_c(quad_rate, analog.GR_COS_WAVE, 100000, 1, 0) self.analog_sig_source_x_1 = analog.sig_source_f(audio_rate, analog.GR_COS_WAVE, 1100, 0.5, 0) self.analog_sig_source_x_0 = analog.sig_source_f(audio_rate, analog.GR_COS_WAVE, 11000, .5, 0) self.analog_phase_modulator_fc_0 = analog.phase_modulator_fc(2*3.14*75000) self.analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, .2, 0) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_1, 1)) self.connect((self.analog_phase_modulator_fc_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_sig_source_x_1, 0), (self.blocks_add_xx_0, 0)) self.connect((self.analog_sig_source_x_2, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.iir_filter_xxx_1, 0)) self.connect((self.blocks_add_xx_1, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_add_xx_1, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_conjugate_cc_0, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.blocks_delay_0, 0), (self.blocks_conjugate_cc_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_1, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.dc_blocker_xx_0, 0), (self.iir_filter_xxx_2, 0)) self.connect((self.iir_filter_xxx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.iir_filter_xxx_1, 0), (self.iir_filter_xxx_0, 0)) self.connect((self.iir_filter_xxx_2, 0), (self.blocks_throttle_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.dc_blocker_xx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.analog_phase_modulator_fc_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") _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 = 40000 ################################################## # Blocks ################################################## self.lab5_part2 = self.lab5_part2 = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.lab5_part2.AddPage(grc_wxgui.Panel(self.lab5_part2), "scope") self.lab5_part2.AddPage(grc_wxgui.Panel(self.lab5_part2), "fft") self.Add(self.lab5_part2) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.lab5_part2.GetPage(0).GetWin(), title="Scope Plot", sample_rate=40000, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.lab5_part2.GetPage(0).Add(self.wxgui_scopesink2_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_f( self.lab5_part2.GetPage(1).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=40000, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.lab5_part2.GetPage(1).Add(self.wxgui_fftsink2_0.win) self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=16, decimation=1, taps=None, fractional_bw=None, ) self.low_pass_filter_0 = filter.fir_filter_fff( 16, firdes.low_pass(1, 640000, 20000, 4000, firdes.WIN_HAMMING, 6.76)) self.iir_filter_xxx_2 = filter.iir_filter_ffd((1, -0.95), (1, ), True) self.iir_filter_xxx_1 = filter.iir_filter_ffd((1, ), (1, 0.95), True) self.iir_filter_xxx_0 = filter.iir_filter_ffd((1 / 40e3, ), (1, 1), True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, 640000, True) self.blocks_multiply_xx_1 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( (1 / 640e3, )) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, 1) self.blocks_conjugate_cc_0 = blocks.conjugate_cc() self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1) self.blocks_add_xx_1 = blocks.add_vcc(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.analog_sig_source_x_2 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, 11000, 0.5, 0) self.analog_sig_source_x_1 = analog.sig_source_c( 640000, analog.GR_COS_WAVE, 100000, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, 1100, 0.5, 0) self.analog_phase_modulator_fc_0 = analog.phase_modulator_fc(471000) self.analog_noise_source_x_0 = analog.noise_source_c( analog.GR_GAUSSIAN, 0.2, 0) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_1, 1)) self.connect((self.analog_phase_modulator_fc_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_sig_source_x_2, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.iir_filter_xxx_0, 0)) self.connect((self.blocks_add_xx_1, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_add_xx_1, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.blocks_complex_to_arg_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_conjugate_cc_0, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.blocks_delay_0, 0), (self.blocks_conjugate_cc_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_complex_to_arg_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_add_xx_1, 0)) self.connect((self.iir_filter_xxx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.iir_filter_xxx_1, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.iir_filter_xxx_1, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.iir_filter_xxx_2, 0), (self.analog_phase_modulator_fc_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.iir_filter_xxx_1, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.iir_filter_xxx_2, 0))
def __init__(self, samp_rate=32000): gr.top_block.__init__(self, "Carrier Sweep") Qt.QWidget.__init__(self) self.setWindowTitle("Carrier Sweep") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "carrier_sweep") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Parameters ################################################## self.samp_rate = samp_rate ################################################## # Variables ################################################## self.sweep_rate = sweep_rate = 2000 self.sweep_range = sweep_range = 8000 self.subcarrier = subcarrier = 16000 self.snr = snr = 20 self.modulation_coeff = modulation_coeff = 0.1 self.frequency = frequency = 2000 ################################################## # Blocks ################################################## self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) self.qtgui_freq_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.blocks_vco_c_0 = blocks.vco_c(samp_rate, 1, 1) self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_float * 1, samp_rate, True) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_add_xx_1 = blocks.add_vcc(1) self.analog_sig_source_x_2_1 = analog.sig_source_f( samp_rate, analog.GR_TRI_WAVE, 0 if sweep_range == 0 else sweep_rate / sweep_range, 2 * 3.14159265359 * sweep_range, 2 * 3.14159265359 * frequency, -3.14159265359) self.analog_sig_source_x_2_0 = analog.sig_source_f( samp_rate, analog.GR_SIN_WAVE, subcarrier, modulation_coeff, 0, 0) self.analog_phase_modulator_fc_0 = analog.phase_modulator_fc(1) self.analog_noise_source_x_0 = analog.noise_source_c( analog.GR_GAUSSIAN, 10**(-snr / 10), 0) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_1, 1)) self.connect((self.analog_phase_modulator_fc_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.analog_sig_source_x_2_0, 0), (self.blocks_throttle_0_0, 0)) self.connect((self.analog_sig_source_x_2_1, 0), (self.blocks_vco_c_0, 0)) self.connect((self.blocks_add_xx_1, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_1, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.analog_phase_modulator_fc_0, 0)) self.connect((self.blocks_vco_c_0, 0), (self.blocks_multiply_xx_0, 1))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") _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 = 960e3 ################################################## # Blocks ################################################## self.wxgui_fftsink2_0 = fftsink2.fft_sink_f( self.GetWin(), baseband_freq=0, 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.Add(self.wxgui_fftsink2_0.win) self.rational_resampler_xxx_1 = filter.rational_resampler_fff( interpolation=1, decimation=30, taps=None, fractional_bw=None, ) self.iir_filter_xxx_2 = filter.iir_filter_ffd((10, ), (1, .95), True) self.iir_filter_xxx_1 = filter.iir_filter_ffd((1/(5e3), ), ([1,1]), True) self.iir_filter_xxx_0 = filter.iir_filter_ffd(([1,0.95]), ([1,0]), False) self.hilbert_fc_0 = filter.hilbert_fc(65, firdes.WIN_HAMMING, 6.76) self.dc_blocker_xx_0 = filter.dc_blocker_ff(8192, True) self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, 1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1) self.blocks_add_xx_2 = blocks.add_vff(1) self.blocks_add_xx_1_0 = blocks.add_vff(1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.audio_sink_0 = audio.sink(32000, "", True) self.analog_sig_source_x_3 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 1000, 1, 0) self.analog_sig_source_x_2_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 10000, 1, 0) self.analog_sig_source_x_1_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 5000, 1, 0) self.analog_sig_source_x_0_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 300000, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -300000, 1, 0) self.analog_phase_modulator_fc_0 = analog.phase_modulator_fc(5e-6) self.analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, 0.01, 0) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_phase_modulator_fc_0, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.analog_sig_source_x_1_0, 0), (self.blocks_add_xx_1_0, 1)) self.connect((self.analog_sig_source_x_2_0, 0), (self.blocks_add_xx_2, 1)) self.connect((self.analog_sig_source_x_3, 0), (self.blocks_add_xx_1_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.blocks_add_xx_1_0, 0), (self.blocks_add_xx_2, 0)) self.connect((self.blocks_add_xx_2, 0), (self.iir_filter_xxx_0, 0)) self.connect((self.blocks_complex_to_arg_0, 0), (self.iir_filter_xxx_2, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.hilbert_fc_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_complex_to_arg_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.dc_blocker_xx_0, 0), (self.audio_sink_0, 0)) self.connect((self.dc_blocker_xx_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.hilbert_fc_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.iir_filter_xxx_0, 0), (self.iir_filter_xxx_1, 0)) self.connect((self.iir_filter_xxx_1, 0), (self.analog_phase_modulator_fc_0, 0)) self.connect((self.iir_filter_xxx_2, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.dc_blocker_xx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Lab 3 Task 0") Qt.QWidget.__init__(self) self.setWindowTitle("Lab 3 Task 0") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "lab3_task0") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.samp_rate = samp_rate = 5000000 self.samp_msg = samp_msg = 44100 ################################################## # Blocks ################################################## self.tab = Qt.QTabWidget() self.tab_widget_0 = Qt.QWidget() self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0) self.tab_grid_layout_0 = Qt.QGridLayout() self.tab_layout_0.addLayout(self.tab_grid_layout_0) self.tab.addTab(self.tab_widget_0, 'Message') self.tab_widget_1 = Qt.QWidget() self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1) self.tab_grid_layout_1 = Qt.QGridLayout() self.tab_layout_1.addLayout(self.tab_grid_layout_1) self.tab.addTab(self.tab_widget_1, 'Modulated') self.tab_widget_2 = Qt.QWidget() self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_2) self.tab_grid_layout_2 = Qt.QGridLayout() self.tab_layout_2.addLayout(self.tab_grid_layout_2) self.tab.addTab(self.tab_widget_2, 'Demodulated') self.top_grid_layout.addWidget(self.tab) self.rational_resampler_xxx_0_0 = filter.rational_resampler_fff( interpolation=samp_msg, decimation=samp_rate, taps=None, fractional_bw=None) self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=samp_rate, decimation=samp_msg, taps=None, fractional_bw=None) self.qtgui_sink_x_1 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw 'Modulated', #name True, #plotfreq True, #plotwaterfall True, #plottime True #plotconst ) self.qtgui_sink_x_1.set_update_time(1.0 / 10) self._qtgui_sink_x_1_win = sip.wrapinstance( self.qtgui_sink_x_1.pyqwidget(), Qt.QWidget) self.qtgui_sink_x_1.enable_rf_freq(False) self.tab_layout_1.addWidget(self._qtgui_sink_x_1_win) self.qtgui_sink_x_0_1 = qtgui.sink_f( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_msg, #bw 'Message', #name True, #plotfreq True, #plotwaterfall True, #plottime True #plotconst ) self.qtgui_sink_x_0_1.set_update_time(1.0 / 10) self._qtgui_sink_x_0_1_win = sip.wrapinstance( self.qtgui_sink_x_0_1.pyqwidget(), Qt.QWidget) self.qtgui_sink_x_0_1.enable_rf_freq(False) self.tab_layout_0.addWidget(self._qtgui_sink_x_0_1_win) self.qtgui_sink_x_0 = qtgui.sink_f( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_msg, #bw 'Demodulated', #name True, #plotfreq True, #plotwaterfall True, #plottime True #plotconst ) self.qtgui_sink_x_0.set_update_time(1.0 / 10) self._qtgui_sink_x_0_win = sip.wrapinstance( self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget) self.qtgui_sink_x_0.enable_rf_freq(False) self.tab_layout_2.addWidget(self._qtgui_sink_x_0_win) self.low_pass_filter_0 = filter.fir_filter_fff( 1, firdes.low_pass(1, samp_rate, 12000, 1000, firdes.WIN_KAISER, 6.76)) self.iir_filter_xxx_0 = filter.iir_filter_ffd([0, 1 / samp_msg], [1, 1], True) self.dc_blocker_xx_0 = filter.dc_blocker_ff(20000, True) self.blocks_throttle_1_0 = blocks.throttle(gr.sizeof_float * 1, samp_msg, True) self.blocks_throttle_1 = blocks.throttle(gr.sizeof_float * 1, samp_msg, True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_multiply_xx_1 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_ff(1 / 6.28) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(100) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, 1) self.blocks_conjugate_cc_0 = blocks.conjugate_cc() self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1) self.blocks_add_xx_1 = blocks.add_vff(1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_sig_source_x_1_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, 100000, 2, 0, 0) self.analog_sig_source_x_1 = analog.sig_source_f( samp_msg, analog.GR_COS_WAVE, 11000, 0.5, 0, 0) self.analog_sig_source_x_0 = analog.sig_source_f( samp_msg, analog.GR_COS_WAVE, 1100, 0.5, 0, 0) self.analog_phase_modulator_fc_0 = analog.phase_modulator_fc(2 * 3.14 * 75 * 1000) self.analog_noise_source_x_0 = analog.noise_source_c( analog.GR_GAUSSIAN, 0.2, 0) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_phase_modulator_fc_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_add_xx_1, 0)) self.connect((self.analog_sig_source_x_1, 0), (self.blocks_add_xx_1, 1)) self.connect((self.analog_sig_source_x_1_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.blocks_add_xx_1, 0), (self.blocks_throttle_1, 0)) self.connect((self.blocks_add_xx_1, 0), (self.iir_filter_xxx_0, 0)) self.connect((self.blocks_complex_to_arg_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.blocks_conjugate_cc_0, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.blocks_delay_0, 0), (self.blocks_conjugate_cc_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_throttle_1_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_complex_to_arg_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_sink_x_1, 0)) self.connect((self.blocks_throttle_1, 0), (self.qtgui_sink_x_0_1, 0)) self.connect((self.blocks_throttle_1_0, 0), (self.qtgui_sink_x_0, 0)) self.connect((self.dc_blocker_xx_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.iir_filter_xxx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.dc_blocker_xx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.analog_phase_modulator_fc_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.blocks_multiply_const_vxx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Lab 2 Task 3") Qt.QWidget.__init__(self) self.setWindowTitle("Lab 2 Task 3") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "lab2_task3") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.samp_rate = samp_rate = 2000000 ################################################## # Blocks ################################################## self.tab = Qt.QTabWidget() self.tab_widget_0 = Qt.QWidget() self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0) self.tab_grid_layout_0 = Qt.QGridLayout() self.tab_layout_0.addLayout(self.tab_grid_layout_0) self.tab.addTab(self.tab_widget_0, 'Frequency') self.tab_widget_1 = Qt.QWidget() self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1) self.tab_grid_layout_1 = Qt.QGridLayout() self.tab_layout_1.addLayout(self.tab_grid_layout_1) self.tab.addTab(self.tab_widget_1, 'Waterfall') self.tab_widget_2 = Qt.QWidget() self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_2) self.tab_grid_layout_2 = Qt.QGridLayout() self.tab_layout_2.addLayout(self.tab_grid_layout_2) self.tab.addTab(self.tab_widget_2, 'Time') self.top_grid_layout.addWidget(self.tab) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.10) self.qtgui_waterfall_sink_x_0.enable_grid(False) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_layout_1.addWidget(self._qtgui_waterfall_sink_x_0_win) self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate 'Message', #name 1 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.10) self.qtgui_time_sink_x_1.set_y_axis(-1, 1) self.qtgui_time_sink_x_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1.enable_tags(True) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1.enable_autoscale(True) self.qtgui_time_sink_x_1.enable_grid(False) self.qtgui_time_sink_x_1.enable_axis_labels(True) self.qtgui_time_sink_x_1.enable_control_panel(False) self.qtgui_time_sink_x_1.enable_stem_plot(False) labels = [ 'Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10' ] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ 'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue' ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_win = sip.wrapinstance( self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate 'Frequency Modulated Signal', #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(True) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) labels = [ 'Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10' ] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ 'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue' ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_layout_2.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw 'Frequency Modulated Signal', #name 1) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-120, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(True) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_layout_0.addWidget(self._qtgui_freq_sink_x_0_win) self.iir_filter_xxx_0 = filter.iir_filter_ffd([1 / samp_rate], [1, 1], True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1, samp_rate, True) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.analog_sig_source_x_1 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, 100000, 1, 0, 0) self.analog_sig_source_x_0 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, 20000, 4, 0, 0) self.analog_phase_modulator_fc_0 = analog.phase_modulator_fc( 62831.85307) ################################################## # Connections ################################################## self.connect((self.analog_phase_modulator_fc_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.iir_filter_xxx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.iir_filter_xxx_0, 0), (self.analog_phase_modulator_fc_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 960e3 ################################################## # Blocks ################################################## self.notebook = self.notebook = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.notebook.AddPage(grc_wxgui.Panel(self.notebook), "modulated") self.notebook.AddPage(grc_wxgui.Panel(self.notebook), "FFT modulated") self.Add(self.notebook) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.notebook.GetPage(0).GetWin(), title='Scope Plot', sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label='Counts', ) self.notebook.GetPage(0).Add(self.wxgui_scopesink2_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_f( self.notebook.GetPage(1).GetWin(), baseband_freq=0, 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.GetPage(1).Add(self.wxgui_fftsink2_0.win) self.iir_filter_xxx_0 = filter.iir_filter_ffd((1 / samp_rate, ), ([1, 0.99]), True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1, samp_rate, True) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.analog_sig_source_x_1 = analog.sig_source_c( samp_rate, analog.GR_SIN_WAVE, 100e3, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, 1000, 1, 0) self.analog_phase_modulator_fc_0 = analog.phase_modulator_fc(6.28 * 75e3) ################################################## # Connections ################################################## self.connect((self.analog_phase_modulator_fc_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.iir_filter_xxx_0, 0)) self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.iir_filter_xxx_0, 0), (self.analog_phase_modulator_fc_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") _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 = 960e3 self.m = m = 0.5 self.fm = fm = 1e3 self.fc = fc = 100e3 ################################################## # Blocks ################################################## self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.GetWin(), title="Scope Plot", sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Add(self.wxgui_scopesink2_0.win) self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_f( self.GetWin(), baseband_freq=0, 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.Add(self.wxgui_fftsink2_0_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_f( self.GetWin(), baseband_freq=0, 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.Add(self.wxgui_fftsink2_0.win) self.message = analog.sig_source_f(samp_rate, analog.GR_CONST_WAVE, 1000, 1, 0) self.iir_filter_xxx_1 = filter.iir_filter_ffd( ([1 / samp_rate, -1 / samp_rate]), ([1]), True) self.iir_filter_xxx_0 = filter.iir_filter_ffd(([1 / samp_rate]), ([1, 1]), True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1, samp_rate, True) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( (2 * 3.14 * m * fm, )) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_complex_to_arg_1 = blocks.complex_to_arg(1) self.band_pass_filter_0 = filter.fir_filter_fff( 30, firdes.band_pass(20, samp_rate, 20, 20e3, 1000, firdes.WIN_HAMMING, 6.76)) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, fc, 1, 0) self.analog_phase_modulator_fc_0 = analog.phase_modulator_fc(1) ################################################## # Connections ################################################## self.connect((self.analog_phase_modulator_fc_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.band_pass_filter_0, 0), (self.wxgui_fftsink2_0_0, 0)) self.connect((self.blocks_complex_to_arg_1, 0), (self.iir_filter_xxx_1, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.analog_phase_modulator_fc_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_complex_to_arg_1, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.iir_filter_xxx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.iir_filter_xxx_1, 0), (self.band_pass_filter_0, 0)) self.connect((self.message, 0), (self.iir_filter_xxx_0, 0))
def __init__(self, options): grc_wxgui.top_block_gui.__init__(self, title="DSSDR") self.initialized = False self.stopped = False self.options = copy.copy(options) self._constellation = digital.constellation_bpsk() self._excess_bw = options.excess_bw self._phase_bw = options.phase_bw self._freq_bw = options.freq_bw self._timing_bw = options.timing_bw self._if_freq = options.if_freq self._timing_max_dev= 1.5 self._demod_class = digital.bpsk_demod # the demodulator_class we're using self._chbw_factor = options.chbw_factor # channel filter bandwidth factor self._samples_per_second = 2e6 self._nav_samples_per_second = 16e6 self._down_decim = 1 self._down_samples_per_second = self._scope_sample_rate = self._samples_per_second/self._down_decim self._up_samples_per_second = 1e6 self._asm_threshold = 0 self._access_code = None self._tm_packet_id = 4 self._timestamp_id = 5 self._down_bitrate = options.bitrate self._up_bitrate = options.up_bitrate self._up_samples_per_symbol = self._up_samples_per_second/self._up_bitrate self._samples_per_symbol = self._samples_per_second/self._down_decim/self._down_bitrate self._down_sub_freq = options.down_sub_freq self._up_sub_freq = 25e3 self._tm_len = 8920 self._up_tm_len = 8920 self._coding_method = options.coding_method self._up_coding_method = 'None' self._up_subcarrier = 'Square' self._rs_i = 1 self._ccsds_channel = 38 self._uhd_carrier_offset = 10e3 self._turn_div = 749 self._turn_mult = 880 self._modulation_index = 'pi/3' self._up_modulation_index = 1.047 self._max_carrier_offset = 0.1 self._dssdr_mixer_freq = options.rf_freq self._up_coding_rate = '1' self._down_coding_rate = '1' self._down_conv_en = "False" self._down_randomizer_en = options.down_randomizer_en self._down_manchester_en = options.down_manchester_en self._up_conv_en = "False" self._up_idle_sequence = "\\x55" self._down_default_gain = 64 self._up_default_gain = 44 self._up_en = True if self._access_code is None: self._access_code = packet_utils.default_access_code #Construct the lookup table for parameter-setting functions self.param_setters = { "DSSDR_CHANNEL": self.setChannel, "DSSDR_LO_FREQ": self.setLOFreq, "DSSDR_REF_FREQ": self.setRefFreq, "DSSDR_TURN_MULT": self.setTurnMult, "DSSDR_TURN_DIV": self.setTurnDiv, "DSSDR_UP_GAIN": self.setUpGain, "DSSDR_DOWN_GAIN": self.setDownGain, "DSSDR_UP_BITRATE": self.setUpBitrate, "DSSDR_DOWN_BITRATE": self.setDownBitrate, "DSSDR_DOWN_SAMPLE_RATE": self.setSampRate, "DSSDR_UP_SUB_FREQ": self.setUpSubFreq, "DSSDR_DOWN_SUB_FREQ": self.setDownSubFreq, "DSSDR_DOPPLER_REPORT": self.dopplerReport, "DSSDR_PN_RANGE": self.rangePN, "DSSDR_SEQUENTIAL_RANGE": self.rangeSequential, "DSSDR_DOWN_CODING_METHOD": self.setDownCodingMethod, "DSSDR_UP_CODING_METHOD": self.setUpCodingMethod, "DSSDR_DOWN_TM_LEN": self.setTMLen, "DSSDR_UP_TM_LEN": self.setUpTMLen, "DSSDR_DOWN_MOD_IDX": self.setDownModulationIndex, "DSSDR_UP_MOD_IDX": self.setUpModulationIndex, "DSSDR_DOWN_CONV_EN": self.setDownConvEn, "DSSDR_UP_CONV_EN": self.setUpConvEn, "DSSDR_ASM_TOL": self.setASMThreshold, "DSSDR_UP_SWEEP": self.freqSweep, "DSSDR_UP_IDLE": self.setUpIdleSequence, "DSSDR_UP_EN": self.setUpEn, "DSSDR_SYNC_TIME": self.syncSDRTime, "DSSDR_UP_SWEEP": self.freqSweep, "DSSDR_DOWN_ACQUIRE": self.acquireCarrier, "DSSDR_INPUT_SELECT": self.setPanelSelect, "DSSDR_REF_SELECT": self.setRefSelect, "DSSDR_PPS_SELECT": self.setPPSSelect } #TODO:Add status fields for things like DSSDR_REF_LOCK self._dssdr_channels = { 3: [7149597994, 8400061729], 4: [7150753857, 8401419752], 5: [7151909723, 8402777779], 6: [7153065586, 8404135802], 7: [7154221449, 8405493825], 8: [7155377316, 8406851853], 9: [7156533179, 8408209877], 10: [7157689045, 8409567903], 11: [7158844908, 8410925927], 12: [7160000771, 8412283950], 13: [7161156637, 8413641977], 14: [7162312500, 8415000000], 15: [7163468363, 8416358023], 16: [7164624229, 8417716050], 17: [7165780092, 8419074073], 18: [7166935955, 8420432097], 19: [7168091821, 8421790123], 20: [7169247684, 8423148147], 21: [7170403551, 8424506175], 22: [7171559414, 8425864198], 23: [7172715277, 8427222221], 24: [7173871143, 8428580248], 25: [7175027006, 8429938271], 26: [7176182869, 8431296295], 27: [7177338735, 8432654321], 28: [7178494598, 8434012345], 29: [7179650464, 8435370372], 30: [7180806327, 8436728395], 31: [7181962190, 8438086418], 32: [7183118057, 8439444446], 33: [7184273920, 8440802469], 34: [7185429783, 8442160493], 35: [7186585649, 8443518520], 36: [7187741512, 8444876543], 37: [7188897378, 8446234570], 38: [7190000000, 8450000000], } #FLOWGRAPH STUFF if options.test == True: self.u = blks2.tcp_source( itemsize=gr.sizeof_gr_complex*1, addr="", port=12905, server=True ) elif options.fromfile == True: self.u2 = blocks.file_meta_source("iq_in.dat") self.u = blocks.throttle(gr.sizeof_gr_complex*1, self._samples_per_second) elif options.frombitlog == True: self.u3 = blocks.file_source(gr.sizeof_char, "bitstream_recording.in", True) self.u2 = blocks.uchar_to_float() self.u1 = blocks.throttle(gr.sizeof_float*1, self._down_bitrate) self.u = blocks.add_const_ff(-0.5) else: self.u = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('fc32')) self.u.set_clock_source("external") self.u.set_time_source("external") self.u.set_samp_rate(self._samples_per_second) self.u.set_antenna("RX2") self.u.set_gain(self._down_default_gain) self.frontend = dfi.dssdrFrontendInterface(self.u) if options.debug_pps == True: self.debug_pps = blocks.tag_debug(gr.sizeof_gr_complex, "debug-pps", "rx_time") if options.tofile == True: self.u_tx = blocks.file_meta_sink(gr.sizeof_gr_complex, "iq_out.dat", self._up_samples_per_second) elif options.tonull == True: self.u_tx = blocks.null_sink(gr.sizeof_gr_complex) else: self.u_tx = uhd.usrp_sink(device_addr=options.args, stream_args=uhd.stream_args('fc32')) self.u_tx.set_clock_source("external") self.u_tx.set_time_source("external") self.u_tx.set_samp_rate(self._up_samples_per_second) self.u_tx.set_antenna("TX/RX") self.u_tx.set_gain(self._up_default_gain) #GUI STUFF if options.graphics == True: self.nb0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.nb0.AddPage(grc_wxgui.Panel(self.nb0), "RX") self.nb0.AddPage(grc_wxgui.Panel(self.nb0), "TX") self.nb0.AddPage(grc_wxgui.Panel(self.nb0), "Nav") self.Add(self.nb0) self.constellation_scope = scopesink2.scope_sink_c( self.nb0.GetPage(0).GetWin(), title="Scope Plot", sample_rate=self._scope_sample_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=True, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb0.GetPage(0).Add(self.constellation_scope.win) #self.constellation_scope.win.set_marker('plus') self._scope_is_fft = False self.time_scope = scopesink2.scope_sink_f( self.nb0.GetPage(0).GetWin(), title="Scope Plot", sample_rate=self._scope_sample_rate, v_scale=0, v_offset=0, t_scale=.005, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb0.GetPage(0).Add(self.time_scope.win) self.nb0.GetPage(0).GetWin()._box.Hide(self.time_scope.win) self.fft_scope = fftsink2.fft_sink_c( self.nb0.GetPage(0).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=self._scope_sample_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.nb0.GetPage(0).Add(self.fft_scope.win) self.nb0.GetPage(0).GetWin()._box.Hide(self.fft_scope.win) self.row1_sizer = wx.BoxSizer(wx.HORIZONTAL) self.recording_onoff_chooser = forms.radio_buttons( parent=self.nb0.GetPage(0).GetWin(), value='Off', callback=self.setRecording, label="IQ Recording", choices=['Off','On'], labels=[], style=wx.RA_HORIZONTAL, ) self.front_panel_chooser = forms.radio_buttons( parent=self.nb0.GetPage(0).GetWin(), value='RF', callback=self.setPanelSelect, label="Input Select", choices=['RF','IF'], labels=[], style=wx.RA_HORIZONTAL, ) self.ref_chooser = forms.radio_buttons( parent=self.nb0.GetPage(0).GetWin(), value='Internal', callback=self.setRefSelect, label="Ref Select", choices=['Internal','External'], labels=[], style=wx.RA_HORIZONTAL, ) self.pps_chooser = forms.radio_buttons( parent=self.nb0.GetPage(0).GetWin(), value='Internal', callback=self.setPPSSelect, label="PPS Select", choices=['Internal','External'], labels=[], style=wx.RA_HORIZONTAL, ) self.sync_button = forms.button( parent=self.nb0.GetPage(0).GetWin(), value='Sync to PPS', callback=self.syncSDRTime, choices=['Sync to PPS'], style=wx.RA_HORIZONTAL, ) self.ref_locked_text = forms.static_text( parent=self.nb0.GetPage(0).GetWin(), value="", callback=self.setRefLocked, label="", converter=forms.str_converter(), ) self.row1_sizer.Add(self.recording_onoff_chooser, flag=wx.ALIGN_CENTER) self.row1_sizer.Add(self.front_panel_chooser, flag=wx.ALIGN_CENTER) self.row1_sizer.Add(self.ref_chooser, flag=wx.ALIGN_CENTER) self.row1_sizer.Add(self.pps_chooser, flag=wx.ALIGN_CENTER) self.row1_sizer.Add(self.sync_button, flag=wx.ALIGN_CENTER) self.row1_sizer.Add(self.ref_locked_text, flag=wx.ALIGN_CENTER) self.nb0.GetPage(0).Add(self.row1_sizer) self.complex_scope_chooser = forms.radio_buttons( parent=self.nb0.GetPage(0).GetWin(), value='Constellation', callback=self.setComplexScopeStyle, label="Complex Scope", choices=['Constellation','FFT'], labels=[], style=wx.RA_HORIZONTAL, ) self.nb0.GetPage(0).Add(self.complex_scope_chooser) self.scope_chooser = forms.radio_buttons( parent=self.nb0.GetPage(0).GetWin(), value='USRP', callback=self.setScopePoint, label="Scope Probe Point", choices=['USRP','Carrier Tracking','Sub-Carrier Costas','Sub-Carrier Sync','Data Sync'], labels=[], style=wx.RA_HORIZONTAL, ) self.nb0.GetPage(0).Add(self.scope_chooser) self._bitrate_text_box = forms.text_box( parent=self.nb0.GetPage(0).GetWin(), value=self._down_bitrate, callback=self.setDownBitrate, label="Symbol Rate", converter=forms.float_converter(), ) self.nb0.GetPage(0).Add(self._bitrate_text_box) self._samprate_text_box = forms.text_box( parent=self.nb0.GetPage(0).GetWin(), value=self._samples_per_second, callback=self.setSampRate, label="Sampling Rate", converter=forms.float_converter(), ) self.nb0.GetPage(0).Add(self._samprate_text_box) self._subcfreq_text_box = forms.text_box( parent=self.nb0.GetPage(0).GetWin(), value=self._down_sub_freq, callback=self.setDownSubFreq, label="Downlink Subcarrier Frequency", converter=forms.float_converter(), ) self.nb0.GetPage(0).Add(self._subcfreq_text_box) self._mod_index_chooser = forms.radio_buttons( parent=self.nb0.GetPage(0).GetWin(), value=self._modulation_index, callback=self.setDownModulationIndex, label="Modulation Index", choices=['pi/2', 'pi/3'], labels=[], style=wx.RA_HORIZONTAL, ) self.nb0.GetPage(0).Add(self._mod_index_chooser) self._pktlen_text_box = forms.text_box( parent=self.nb0.GetPage(0).GetWin(), value=self._tm_len, callback=self.setTMLen, label="Downlink Packet Length (bits)", converter=forms.float_converter(), ) self.nb0.GetPage(0).Add(self._pktlen_text_box) self._coding_chooser = forms.radio_buttons( parent=self.nb0.GetPage(0).GetWin(), value=self._coding_method, callback=self.setDownCodingMethod, label="Coding", choices=['None', 'RS', 'Turbo 1/2', 'Turbo 1/3', 'Turbo 1/4', 'Turbo 1/6'], labels=[], style=wx.RA_HORIZONTAL, ) self.nb0.GetPage(0).Add(self._coding_chooser) self._down_conv_check_box = forms.check_box( parent=self.nb0.GetPage(0).GetWin(), value=self._down_conv_en, callback=self.setDownConvEn, label="Convolutional Decode", true="True", false="False", ) self.nb0.GetPage(0).Add(self._down_conv_check_box) self._down_randomizer_check_box = forms.check_box( parent=self.nb0.GetPage(0).GetWin(), value=self._down_randomizer_en, callback=self.setDownRandomizerEn, label="De-randomizer", true=True, false=False, ) self.nb0.GetPage(0).Add(self._down_randomizer_check_box) self._down_manchester_check_box = forms.check_box( parent=self.nb0.GetPage(0).GetWin(), value=self._down_manchester_en, callback=self.setDownManchesterEn, label="Manchester Decode", true=True, false=False, ) self.nb0.GetPage(0).Add(self._down_manchester_check_box) self._pktlen_text_box = forms.text_box( parent=self.nb0.GetPage(0).GetWin(), value=self._asm_threshold, callback=self.setASMThreshold, label="ASM Error Tolerance (bits)", converter=forms.float_converter(), ) self.nb0.GetPage(0).Add(self._pktlen_text_box) self._coding_chooser = forms.radio_buttons( parent=self.nb0.GetPage(0).GetWin(), value=self._rs_i, callback=self.setRSI, label="Reed-Solomon Interleaving Depth", choices=[1,5], labels=[], style=wx.RA_HORIZONTAL, ) self.nb0.GetPage(0).Add(self._coding_chooser) self._ccsds_chan_text_box = forms.text_box( parent=self.nb0.GetPage(0).GetWin(), value=self._ccsds_channel, callback=self.setChannel, label="CCSDS Channel", converter=forms.int_converter(), ) self.nb0.GetPage(0).Add(self._ccsds_chan_text_box) self.setChannel(self._ccsds_channel) if options.test == True or options.fromfile == True or options.frombitlog == True: glow = 0.0 ghigh = 1.0 cur_g = 0.5 else: g = self.u.get_gain_range() cur_g = self._down_default_gain # some configurations don't have gain control if g.stop() <= g.start(): glow = 0.0 ghigh = 1.0 else: glow = g.start() ghigh = g.stop() self._uhd_gain_slider = wx.BoxSizer(wx.HORIZONTAL) form.slider_field( parent=self.nb0.GetPage(0).GetWin(), sizer=self._uhd_gain_slider, label="USRP RX Gain", weight=3, min=int(glow), max=int(ghigh), value=cur_g, callback=self.setDownGain ) self.nb0.GetPage(0).Add(self._uhd_gain_slider) #TX chain GUI components if options.test == True or options.tofile == True or options.tonull == True: gtxlow = 0.0 gtxhigh = 1.0 cur_gtx = 0.5 else: gtx = self.u_tx.get_gain_range() cur_gtx = self._up_default_gain # some configurations don't have gain control if gtx.stop() <= gtx.start(): gtxlow = 0.0 gtxhigh = 1.0 else: gtxlow = gtx.start() gtxhigh = gtx.stop() self._up_en_chooser = forms.check_box( parent=self.nb0.GetPage(1).GetWin(), value='True', callback=self.setUpEn, label="TX Enable", true='True', false='False', ) self.nb0.GetPage(1).Add(self._up_en_chooser) self._uhd_tx_gain_slider = wx.BoxSizer(wx.HORIZONTAL) form.slider_field( parent=self.nb0.GetPage(1).GetWin(), sizer=self._uhd_tx_gain_slider, label="USRP TX Gain", weight=3, min=int(gtxlow), max=int(gtxhigh), value=cur_gtx, callback=self.setUpGain ) self.nb0.GetPage(1).Add(self._uhd_tx_gain_slider) self._subcfreq_up_text_box = forms.text_box( parent=self.nb0.GetPage(1).GetWin(), value=self._up_sub_freq, callback=self.setUpSubFreq, label="Uplink Subcarrier Frequency", converter=forms.float_converter(), ) self.nb0.GetPage(1).Add(self._subcfreq_up_text_box) self._up_bitrate_text_box = forms.text_box( parent=self.nb0.GetPage(1).GetWin(), value=self._up_bitrate, callback=self.setUpBitrate, label="Uplink Bitrate", converter=forms.float_converter(), ) self.nb0.GetPage(1).Add(self._up_bitrate_text_box) self._up_data_text_box = forms.text_box( parent=self.nb0.GetPage(1).GetWin(), value="1234ABCD", callback=self.txData, label="TX Data", converter=forms.str_converter(), ) self.nb0.GetPage(1).Add(self._up_data_text_box) self._up_mod_index_chooser = forms.text_box( parent=self.nb0.GetPage(1).GetWin(), value=self._up_modulation_index, callback=self.setUpModulationIndex, label="Uplink Modulation Index", converter=forms.float_converter(), ) self.nb0.GetPage(1).Add(self._up_mod_index_chooser) self._up_coding_chooser = forms.radio_buttons( parent=self.nb0.GetPage(1).GetWin(), value=self._up_coding_method, callback=self.setUpCodingMethod, label="Coding", choices=['None', 'RS'], labels=[], style=wx.RA_HORIZONTAL, ) self.nb0.GetPage(1).Add(self._up_coding_chooser) self._subcarrier_chooser = forms.radio_buttons( parent=self.nb0.GetPage(1).GetWin(), value=self._up_subcarrier, callback=self.setUpSubcarrier, label="Subcarrier Type", choices=['Square','Sine'], labels=[], style=wx.RA_HORIZONTAL, ) self.nb0.GetPage(1).Add(self._subcarrier_chooser) self._up_conv_check_box = forms.check_box( parent=self.nb0.GetPage(1).GetWin(), value=self._up_conv_en, callback=self.setUpConvEn, label="Convolutional Encode", true="True", false="False", ) self.nb0.GetPage(1).Add(self._up_conv_check_box) self._up_pktlen_text_box = forms.text_box( parent=self.nb0.GetPage(1).GetWin(), value=self._up_tm_len, callback=self.setUpTMLen, label="Uplink Packet Length (bits)", converter=forms.float_converter(), ) self.nb0.GetPage(1).Add(self._up_pktlen_text_box) self._uhd_offset_text_box = forms.text_box( parent=self.nb0.GetPage(1).GetWin(), value=self._uhd_carrier_offset, callback=self.setUHDCarrierOffset, label="USRP Offset Frequency (Hz)", converter=forms.float_converter(), ) self.nb0.GetPage(1).Add(self._uhd_offset_text_box) self._sweep_gen_text_box = forms.text_box( parent=self.nb0.GetPage(1).GetWin(), value="rf2_1", callback=self.freqSweep, label="Frequency Sweep Profile", converter=forms.str_converter(), ) self.nb0.GetPage(1).Add(self._sweep_gen_text_box) self._idle_sequence_text_box = forms.text_box( parent=self.nb0.GetPage(1).GetWin(), value=self._up_idle_sequence, callback=self.setUpIdleSequence, label="Uplink Idle Sequence", converter=forms.str_converter(), ) self.nb0.GetPage(1).Add(self._idle_sequence_text_box) self._pn_ranging_text_box = forms.text_box( parent=self.nb0.GetPage(2).GetWin(), value="", callback=self.rangePN, label="Queue PN Ranging", converter=forms.str_converter(), ) self.nb0.GetPage(2).Add(self._pn_ranging_text_box) self._sequential_ranging_text_box = forms.text_box( parent=self.nb0.GetPage(2).GetWin(), value="", callback=self.rangeSequential, label="Queue Sequential Ranging", converter=forms.str_converter(), ) self.nb0.GetPage(2).Add(self._sequential_ranging_text_box) self.row2_sizer = wx.BoxSizer(wx.HORIZONTAL) self.freq_acq_button = forms.button( parent=self.nb0.GetPage(2).GetWin(), value='Acquire Carrier Offset', callback=self.acquireCarrier, choices=['Acquire Carrier Offset'], style=wx.RA_HORIZONTAL, ) self.carrier_offset_text = forms.static_text( parent=self.nb0.GetPage(2).GetWin(), value="", label="", converter=forms.str_converter(), ) self.row2_sizer.Add(self.freq_acq_button, flag=wx.ALIGN_CENTER) self.row2_sizer.Add(self.carrier_offset_text, flag=wx.ALIGN_CENTER) self.nb0.GetPage(2).Add(self.row2_sizer) self.file_sink = blocks.file_meta_sink(gr.sizeof_gr_complex, "iq_recording.dat", self._samples_per_second) self.file_sink.close() self.iq_recording_ctr = 0 # Selection logic to switch between recording and normal flowgraph routes # NOTE: u_valve logic is implemented backwards in GNURadio.... #self.u_valve = blks2.valve( # item_size=gr.sizeof_gr_complex, # open=False #) # Temporary code used to verify coherent turnaround self.turnaround_mixer = blocks.multiply_cc() self.turnaround_mixer_source = analog.sig_source_c(self._down_samples_per_second, analog.GR_SIN_WAVE, -25e3, 1.0) self.turnaround_iir = filter.single_pole_iir_filter_cc(0.0001) self.turnaround_null = blocks.null_sink(gr.sizeof_float) # PLL and associated carrier for tracking carrier frequency if residual carrier is used self.carrier_tracking = sdrp.pll_freq_acq_cc(math.pi/2000, math.pi, -math.pi, int(options.acq_samples)) self.imag_to_float = blocks.complex_to_imag() #Suppressed carrier requires costas after subcarrier mixer self.subcarrier_costas = digital.costas_loop_cc(0.001, 2) self.real_to_float = blocks.complex_to_real() #Square wave subcarrier sync self.subcarrier_sync = sdrp.square_sub_tracker_ff(0.001, 2*self._down_sub_freq/self._down_samples_per_second*1.0001, 2*self._down_sub_freq/self._down_samples_per_second*0.9999) #Data sync self.data_sync = sdrp.square_data_tracker_ff(0.001, self._down_bitrate/self._down_samples_per_second*1.001, self._down_bitrate/self._down_samples_per_second*0.999) #Data framing self.soft_correlator = sdrp.correlate_soft_access_tag_ff(conv_packed_binary_string_to_1_0_string('\x1A\xCF\xFC\x1D'), self._asm_threshold, "asm_corr") self.conv_decoder = sdrp.ccsds_tm_conv_decoder("asm_corr") self.de_randomizer = sdrp.ccsds_tm_derandomizer("asm_corr") self.tm_framer = sdrp.ccsds_tm_framer(self._tm_packet_id, self._timestamp_id, "asm_corr", "rx_time", self._down_bitrate) self.tm_framer.setFrameLength(self._tm_len) self._current_scope_block = None self._current_scoped_block = self.u self._current_scoped_block_port = 0 self._recording = 'Off' #TX path in flowgraph self.pkt_gen_msgq = gr.msg_queue(10) self.pkt_gen = sdrp.ccsds_tm_tx(self._tm_packet_id, self._timestamp_id, 1.0, 16, self.pkt_gen_msgq) self.conj = blocks.conjugate_cc() #Sweep generator for transponder lock self.sweep_gen = sdrp.sweep_generator_cc(self._up_samples_per_second) # DSSDR subcarrier mixer (either 25 kHz or 0 kHz depending on baud rate) self.up_subcarrier_mixer = blocks.multiply_ff() self.subcarrier_mixer_source_tx = analog.sig_source_f(self._up_samples_per_second, analog.GR_SQR_WAVE, 25e3, 2.0, -1.0) self.phase_mod_tx = analog.phase_modulator_fc(self._up_modulation_index) self.tx_attenuator = blocks.multiply_const_cc((0.1+0.0j)) #Add in bit recorder if needed if self.options.bitlog: self.bit_slicer = digital.binary_slicer_fb() self.bit_recorder = blocks.file_sink(1, "bitstream_recording.out") self.setDownCodingMethod(self._coding_method) self.setUpCodingMethod("None") self.setUpSubcarrier(self._up_subcarrier) self.setDownBitrate(self._down_bitrate) self.setUpBitrate(self._up_bitrate) self.setDownModulationIndex(self._modulation_index) self.setUpModulationIndex(self._up_modulation_index) self.setDownConvEn(self._down_conv_en) self.setUpConvEn(self._up_conv_en) self.setUpIdleSequence(self._up_idle_sequence) self.setDownRandomizerEn(self._down_randomizer_en) self.setDownManchesterEn(self._down_manchester_en) #Connection to outside world self.socket_pdu = blocks.socket_pdu("TCP_SERVER", "127.0.0.1", "12902", 10000) self.sdrp_interpreter = sdrp.sdrp_packet_interpreter() self.msg_connect(self.tm_framer, "tm_frame_out", self.sdrp_interpreter, "sdrp_pdu_in") self.msg_connect(self.sdrp_interpreter, "socket_pdu_out", self.socket_pdu, "pdus") self.msg_connect(self.socket_pdu, "pdus", self.sdrp_interpreter, "socket_pdu_in") self.msg_connect(self.sdrp_interpreter,"sdrp_pdu_out", self.pkt_gen, "ccsds_tx_msg_in") if options.test == False and options.fromfile == False and options.frombitlog == False: _threading.Thread(target=self.watchRef).start() self.initialized = True print "DS-SDR Initialized"
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") _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 = 960000 ################################################## # Blocks ################################################## self.lab2_part4 = self.lab2_part4 = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.lab2_part4.AddPage(grc_wxgui.Panel(self.lab2_part4), "scope") self.lab2_part4.AddPage(grc_wxgui.Panel(self.lab2_part4), "fft") self.Add(self.lab2_part4) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.lab2_part4.GetPage(0).GetWin(), title="Scope Plot", sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.lab2_part4.GetPage(0).Add(self.wxgui_scopesink2_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_f( self.lab2_part4.GetPage(1).GetWin(), baseband_freq=0, 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.lab2_part4.GetPage(1).Add(self.wxgui_fftsink2_0.win) self.iir_filter_ffd_0 = filter.iir_filter_ffd((1 / 960e3, ), (1, 1), True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1, samp_rate) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.analog_sig_source_x_1 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, 100000, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, 10000, 1, 0) self.analog_phase_modulator_fc_0 = analog.phase_modulator_fc(471000) ################################################## # Connections ################################################## self.connect((self.blocks_throttle_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.analog_phase_modulator_fc_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.iir_filter_ffd_0, 0), (self.analog_phase_modulator_fc_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.iir_filter_ffd_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") _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 = 1e6 self.m = m = 50 self.kf = kf = 17 self.fm = fm = 1.1e3 ################################################## # Blocks ################################################## _kf_sizer = wx.BoxSizer(wx.VERTICAL) self._kf_text_box = forms.text_box( parent=self.GetWin(), sizer=_kf_sizer, value=self.kf, callback=self.set_kf, label='kf', converter=forms.float_converter(), proportion=0, ) self._kf_slider = forms.slider( parent=self.GetWin(), sizer=_kf_sizer, value=self.kf, callback=self.set_kf, minimum=0, maximum=25, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_kf_sizer) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.GetWin(), title="Scope Plot", sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Add(self.wxgui_scopesink2_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_f( self.GetWin(), baseband_freq=0, 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.Add(self.wxgui_fftsink2_0.win) self.message_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 11e3, 0.5, 0) self.message = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 1.1e3, 0.5, 0) _m_sizer = wx.BoxSizer(wx.VERTICAL) self._m_text_box = forms.text_box( parent=self.GetWin(), sizer=_m_sizer, value=self.m, callback=self.set_m, label='m', converter=forms.float_converter(), proportion=0, ) self._m_slider = forms.slider( parent=self.GetWin(), sizer=_m_sizer, value=self.m, callback=self.set_m, minimum=1, maximum=80, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_m_sizer) self.iir_filter_xxx_0 = filter.iir_filter_ffd(([1.0/samp_rate]), ([1,1]), True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((10e3, )) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, 1) self.blocks_conjugate_cc_0 = blocks.conjugate_cc() self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1) self.blocks_add_xx_1 = blocks.add_vcc(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 100e3, 1, 0) self.analog_phase_modulator_fc_0 = analog.phase_modulator_fc(kf) self.analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, 0, 0) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_1, 1)) self.connect((self.analog_phase_modulator_fc_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.iir_filter_xxx_0, 0)) self.connect((self.blocks_add_xx_1, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_add_xx_1, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.blocks_complex_to_arg_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.blocks_complex_to_arg_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.blocks_conjugate_cc_0, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.blocks_delay_0, 0), (self.blocks_conjugate_cc_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.analog_phase_modulator_fc_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.blocks_complex_to_arg_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_add_xx_1, 0)) self.connect((self.iir_filter_xxx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.message, 0), (self.blocks_add_xx_0, 0)) self.connect((self.message_0, 0), (self.blocks_add_xx_0, 1))
def __init__(self): gr.top_block.__init__(self, "Residual Carrier") Qt.QWidget.__init__(self) self.setWindowTitle("Residual Carrier") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "residual_carrier") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.sweep_rate = sweep_rate = 0 self.sweep_range = sweep_range = 0 self.snr = snr = 20 self.samp_rate = samp_rate = 100000 self.modulation_coeff = modulation_coeff = 0 self.frequency = frequency = 0 self.datarate = datarate = 4000 self.constellation_0 = constellation_0 = digital.constellation_calcdist( [-1 - 0.5j, -1 + 0.5j], [0, 1], 4, 1).base() ################################################## # Blocks ################################################## self._sweep_rate_range = Range(0, 50e3, 100, 0, 200) self._sweep_rate_win = RangeWidget(self._sweep_rate_range, self.set_sweep_rate, 'Sweep rate (Hz/s)', "counter_slider", float) self.top_layout.addWidget(self._sweep_rate_win) self._sweep_range_range = Range(0, 50e3, 1e3, 0, 200) self._sweep_range_win = RangeWidget(self._sweep_range_range, self.set_sweep_range, 'Sweep Range (Hz)', "counter_slider", float) self.top_layout.addWidget(self._sweep_range_win) self._snr_range = Range(-20, 50, 1, 20, 200) self._snr_win = RangeWidget(self._snr_range, self.set_snr, 'SNR (dB)', "counter_slider", float) self.top_layout.addWidget(self._snr_win) self._modulation_coeff_range = Range(0, 2, 0.1, 0, 200) self._modulation_coeff_win = RangeWidget(self._modulation_coeff_range, self.set_modulation_coeff, 'Modulation Coefficent', "counter", float) self.top_layout.addWidget(self._modulation_coeff_win) self._frequency_range = Range(-10e3, 10e3, 100, 0, 200) self._frequency_win = RangeWidget(self._frequency_range, self.set_frequency, 'Center frequency (Hz)', "counter_slider", float) self.top_layout.addWidget(self._frequency_win) self._datarate_range = Range(1000, 20000, 1000, 4000, 200) self._datarate_win = RangeWidget(self._datarate_range, self.set_datarate, 'Data Rate (bps', "counter", float) self.top_layout.addWidget(self._datarate_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(0.1) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.blocks_vco_c_0 = blocks.vco_c(samp_rate, 1, 1) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_int * 1, datarate * 16, True) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float * 1, 25) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_int_to_float_0 = blocks.int_to_float(1, 1) self.blocks_add_xx_1 = blocks.add_vcc(1) self.blocks_add_const_vxx_0 = blocks.add_const_ff(-0.5) self.analog_sig_source_x_2_1 = analog.sig_source_f( samp_rate, analog.GR_TRI_WAVE, 0 if sweep_range == 0 else sweep_rate / sweep_range, 2 * 3.14159265359 * sweep_range, 2 * 3.14159265359 * frequency, -3.14159265359) self.analog_random_source_x_1 = blocks.vector_source_i( list(map(int, numpy.random.randint(0, 2, 1000))), True) self.analog_phase_modulator_fc_0 = analog.phase_modulator_fc( 2 * modulation_coeff) self.analog_noise_source_x_0 = analog.noise_source_c( analog.GR_GAUSSIAN, 10**(-snr / 10), 0) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_1, 1)) self.connect((self.analog_phase_modulator_fc_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.analog_random_source_x_1, 0), (self.blocks_throttle_0, 0)) self.connect((self.analog_sig_source_x_2_1, 0), (self.blocks_vco_c_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.blocks_add_xx_1, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_int_to_float_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_1, 0)) self.connect((self.blocks_repeat_0, 0), (self.analog_phase_modulator_fc_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_int_to_float_0, 0)) self.connect((self.blocks_vco_c_0, 0), (self.blocks_multiply_xx_0, 1))