def __init__(self): gr.top_block.__init__(self) parser = OptionParser(option_class=eng_option) parser.add_option("-O", "--audio-output", type="string", default="", help="pcm output device name") parser.add_option("-r", "--sample-rate", type="eng_float", default=192000, help="set sample rate to RATE (192000)") parser.add_option("-f", "--frequency", type="eng_float", default=81000) parser.add_option("-a", "--amplitude", type="eng_float", default=0.5) (options, args) = parser.parse_args () if len(args) != 0: parser.print_help() raise SystemExit, 1 sample_rate = int(options.sample_rate) ampl = float(options.amplitude) pulse_freq = 1.0 # 1Hz pulse_dc = 0.1 # Low DC value to give high/low value rather than on/off if ampl > 1.0: ampl = 1.0 osc = analog.sig_source_f (sample_rate, analog.GR_SIN_WAVE, options.frequency, ampl) osc2 = analog.sig_source_f (sample_rate, analog.GR_SIN_WAVE, 80000, .5) mixer = blocks.multiply_ff () self.connect (osc, (mixer, 0)) self.connect (osc2, (mixer, 1)) dst = audio.sink (sample_rate, options.audio_output, True) self.connect (mixer, dst)
def __init__(self): gr.top_block.__init__(self) # standard quality sample rate and amplitude value sample_rate = 32000 ampl = 0.1 startFreq0 = 350 startFreq1 = 440 # We create two sine waves with the same amplitude and sameple rate # from above. src0 = analog.sig_source_f(sample_rate, analog.GR_SIN_WAVE, startFreq0, ampl) src1 = analog.sig_source_f(sample_rate, analog.GR_SIN_WAVE, startFreq1, ampl) # dst is the "destination" or audio sink block dst = audio.sink(sample_rate, "") # We then connect the two sine waves to the destination block self.connect(src0, (dst, 0)) self.connect(src1, (dst, 1)) for a in range(1000): src0.set_frequency(startFreq0 + a) src1.set_frequency(startFreq1 + a) time.sleep(0.5)
def __init__(self): gr.top_block.__init__(self) usage = "%prog: [options] filename" parser = OptionParser(option_class=eng_option, usage=usage) parser.add_option("-r", "--sample-rate", type="eng_float", default=48000, help="set sample rate to RATE (48000)") parser.add_option("-N", "--samples", type="eng_float", default=None, help="number of samples to record") (options, args) = parser.parse_args () if len(args) != 1 or options.samples is None: parser.print_help() raise SystemExit, 1 sample_rate = int(options.sample_rate) ampl = 0.1 src0 = analog.sig_source_f(sample_rate, analog.GR_SIN_WAVE, 350, ampl) src1 = analog.sig_source_f(sample_rate, analog.GR_SIN_WAVE, 440, ampl) head0 = blocks.head(gr.sizeof_float, int(options.samples)) head1 = blocks.head(gr.sizeof_float, int(options.samples)) dst = blocks.wavfile_sink(args[0], 2, int(options.sample_rate), 16) self.connect(src0, head0, (dst, 0)) self.connect(src1, head1, (dst, 1))
def __init__(self): gr.top_block.__init__(self) sample_rate = 32000 ampl = 0.1 src0 = analog.sig_source_f(sample_rate, analog.GR_SIN_WAVE, 350, ampl) src1 = analog.sig_source_f(sample_rate, analog.GR_SIN_WAVE, 440, ampl) dst = audio.sink (sample_rate, "") self.connect (src0, (dst, 0)) self.connect (src1, (dst, 1))
def __init__(self, context, mode, angle=0.0): gr.hier_block2.__init__( self, 'SimulatedDevice VOR modulator', gr.io_signature(1, 1, gr.sizeof_float * 1), gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), ) self.__angle = 0.0 # dummy statically visible value will be overwritten # TODO: My signal level parameters are probably wrong because this signal doesn't look like a real VOR signal vor_30 = analog.sig_source_f(self.__audio_rate, analog.GR_COS_WAVE, self.__vor_sig_freq, 1, 0) vor_add = blocks.add_cc(1) vor_audio = blocks.add_ff(1) # Audio/AM signal self.connect( vor_30, blocks.multiply_const_ff(0.3), # M_n (vor_audio, 0)) self.connect( self, blocks.multiply_const_ff(audio_modulation_index), # M_i (vor_audio, 1)) # Carrier component self.connect( analog.sig_source_c(0, analog.GR_CONST_WAVE, 0, 0, 1), (vor_add, 0)) # AM component self.__delay = blocks.delay(gr.sizeof_gr_complex, 0) # configured by set_angle self.connect( vor_audio, make_resampler(self.__audio_rate, self.__rf_rate), # TODO make a complex version and do this last blocks.float_to_complex(1), self.__delay, (vor_add, 1)) # FM component vor_fm_mult = blocks.multiply_cc(1) self.connect( # carrier generation analog.sig_source_f(self.__rf_rate, analog.GR_COS_WAVE, fm_subcarrier, 1, 0), blocks.float_to_complex(1), (vor_fm_mult, 1)) self.connect( # modulation vor_30, make_resampler(self.__audio_rate, self.__rf_rate), analog.frequency_modulator_fc(2 * math.pi * fm_deviation / self.__rf_rate), blocks.multiply_const_cc(0.3), # M_d vor_fm_mult, (vor_add, 2)) self.connect( vor_add, self) # calculate and initialize delay self.set_angle(angle)
def test_001_t (self): left_src = analog.sig_source_f(96000, analog.GR_COS_WAVE, 1000, .2, 0) right_src = analog.sig_source_f(96000, analog.GR_COS_WAVE, 440, .2, 0) sink = pulseaudio.pa_sink( samp_rate=96000, nchannels=2, application_name='GNU Radio test', stream_name='test', channel_map=None) self.tb.connect((left_src, 0), (sink, 0)) self.tb.connect((right_src, 0), (sink, 1)) self.tb.run ()
def __init__(self, samp_rate): gr.hier_block2.__init__(self, "BPM Signal from ADC", gr.io_signature(0,0,0),#no input, this is a source gr.io_signature(1,1,gr.sizeof_float)) carrier = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 20e6, 1, 0) modulating = analog.sig_source_f(samp_rate, analog.GR_SIN_WAVE, 2e3, 0.05, 0.975) mixer = blocks.multiply_ff(1) self.connect(carrier, (mixer,0)) self.connect(modulating, (mixer,1)) self.connect(mixer,self)
def build_graph(): sampling_freq = 32000 ampl = 0.1 tb = gr.top_block() src0 = analog.sig_source_f(sampling_freq, analog.GR_SIN_WAVE, 350, ampl) src1 = analog.sig_source_f(sampling_freq, analog.GR_SIN_WAVE, 440, ampl) dst = audio.sink(sampling_freq) tb.connect(src0, (dst, 0)) tb.connect(src1, (dst, 1)) return tb
def __init__(self): gr.top_block.__init__(self) Rs = 8000 f1 = 100 f2 = 200 npts = 2048 self.qapp = QtWidgets.QApplication(sys.argv) src1 = analog.sig_source_f(Rs, analog.GR_SIN_WAVE, f1, 0.1, 0) src2 = analog.sig_source_f(Rs, analog.GR_SIN_WAVE, f2, 0.1, 0) src = blocks.add_ff() thr = blocks.throttle(gr.sizeof_float, 100*npts) noise = analog.noise_source_f(analog.GR_GAUSSIAN, 0.001) add = blocks.add_ff() self.snk1 = qtgui.time_sink_f(npts, Rs, "Complex Time Example", 3) self.connect(src1, (src,0)) self.connect(src2, (src,1)) self.connect(src, thr, (add,0)) self.connect(noise, (add,1)) self.connect(add, self.snk1) self.connect(src1, (self.snk1, 1)) self.connect(src2, (self.snk1, 2)) self.ctrl_win = control_box() self.ctrl_win.attach_signal1(src1) self.ctrl_win.attach_signal2(src2) # Get the reference pointer to the SpectrumDisplayForm QWidget pyQt = self.snk1.pyqwidget() # Wrap the pointer as a PyQt SIP object # This can now be manipulated as a PyQt5.QtWidgets.QWidget pyWin = sip.wrapinstance(pyQt, QtWidgets.QWidget) # Example of using signal/slot to set the title of a curve # FIXME: update for Qt5 #pyWin.setLineLabel.connect(pyWin.setLineLabel) #pyWin.emit(QtCore.SIGNAL("setLineLabel(int, QString)"), 0, "Re{sum}") self.snk1.set_line_label(0, "Re{sum}") self.snk1.set_line_label(1, "src1") self.snk1.set_line_label(2, "src2") # Can also set the color of a curve #self.snk1.set_color(5, "blue") #pyWin.show() self.main_box = dialog_box(pyWin, self.ctrl_win) self.main_box.show()
def __init__(self, host, port, pkt_size, sample_rate, eof): gr.top_block.__init__(self, "dial_tone_source") amplitude = 0.3 src0 = analog.sig_source_f(sample_rate, analog.GR_SIN_WAVE, 350, amplitude) src1 = analog.sig_source_f(sample_rate, analog.GR_SIN_WAVE, 440, amplitude) add = blocks.add_ff() # Throttle needed here to account for the other side's audio card sampling rate thr = blocks.throttle(gr.sizeof_float, sample_rate) sink = blocks.udp_sink(gr.sizeof_float, host, port, pkt_size, eof=eof) self.connect(src0, (add, 0)) self.connect(src1, (add, 1)) self.connect(add, thr, sink)
def __init__(self, sample_rate, tone_freq): gr.hier_block2.__init__( self, "ctcss_gen_f", gr.io_signature(0, 0, 0), gr.io_signature(1, 1, gr.sizeof_float) # Input signature ) # Output signature self.plgen = analog.sig_source_f(sample_rate, analog.GR_SIN_WAVE, tone_freq, 0.1, 0.0) self.connect(self.plgen, self)
def __init__(self): gr.top_block.__init__(self) parser = ArgumentParser() parser.add_argument("-O", "--audio-output", default="", help="pcm output device name. E.g., hw:0,0 or /dev/dsp") parser.add_argument("-i", "--input-rate", type=eng_float, default=8000, help="set input sample rate to RATE %(default)r") parser.add_argument("-o", "--output-rate", type=eng_float, default=48000, help="set output sample rate to RATE %(default)r") args = parser.parse_args() input_rate = int(args.input_rate) output_rate = int(args.output_rate) interp = gru.lcm(input_rate / output_rate, input_rate) decim = gru.lcm(input_rate / output_rate, output_rate) print("interp =", interp) print("decim =", decim) ampl = 0.1 src0 = analog.sig_source_f(input_rate, analog.GR_SIN_WAVE, 650, ampl) rr = filter.rational_resampler_fff(interp, decim) dst = audio.sink(output_rate, args.audio_output) self.connect(src0, rr, (dst, 0))
def __init__(self, carrier=8000, samp_rate=192000, amp=0.1): gr.top_block.__init__(self, "Top Block") analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, carrier, amp, 0) audio_sink_0 = audio.sink(samp_rate, "") self.connect((analog_sig_source_x_0, 0), (audio_sink_0, 0))
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()) ################################################## # Blocks ################################################## self.audio_sink_0 = audio.sink(48000, "", True) self.analog_sig_source_x_0 = analog.sig_source_f(48000, analog.GR_COS_WAVE, 1000, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.audio_sink_0, 0))
def __init__(self): gr.top_block.__init__(self) parser = OptionParser(option_class=eng_option) parser.add_option("-O", "--audio-output", type="string", default="", help="pcm output device name. E.g., hw:0,0 or /dev/dsp") parser.add_option("-i", "--input-rate", type="eng_float", default=8000, help="set input sample rate to RATE (%default)") parser.add_option("-o", "--output-rate", type="eng_float", default=48000, help="set output sample rate to RATE (%default)") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() raise SystemExit, 1 input_rate = int(options.input_rate) output_rate = int(options.output_rate) interp = gru.lcm(input_rate, output_rate) / input_rate decim = gru.lcm(input_rate, output_rate) / output_rate print "interp =", interp print "decim =", decim ampl = 0.1 src0 = analog.sig_source_f(input_rate, analog.GR_SIN_WAVE, 650, ampl) rr = filter.rational_resampler_fff(interp, decim) dst = audio.sink(output_rate, options.audio_output) self.connect(src0, rr, (dst, 0))
def __init__(self): gr.top_block.__init__(self) parser = OptionParser(option_class=eng_option) parser.add_option("-I", "--audio-input", type="string", default="", help="pcm input device name. E.g., hw:0,0 or /dev/dsp") parser.add_option("-O", "--audio-output", type="string", default="", help="pcm output device name") parser.add_option("-r", "--sample-rate", type="eng_float", default=192000, help="set sample rate to RATE (192000)") parser.add_option("-f", "--frequency", type="eng_float", default=45000) parser.add_option("-a", "--amplitude", type="eng_float", default=0.5) (options, args) = parser.parse_args () if len(args) != 0: parser.print_help() raise SystemExit, 1 sample_rate = int(options.sample_rate) ampl = float(options.amplitude) if ampl > 1.0: ampl = 1.0 osc = analog.sig_source_f (sample_rate, analog.GR_SIN_WAVE, options.frequency, ampl) src = audio.source (sample_rate, options.audio_input) mixer = blocks.multiply_ff () self.connect (osc, (mixer, 0)) self.connect (src, (mixer, 1)) dst = audio.sink (sample_rate, options.audio_output, True) self.connect (mixer, dst)
def __init__(self): gr.top_block.__init__(self) Rs = 8000 f1 = 100 npts = 2048 self.qapp = QtGui.QApplication(sys.argv) src1 = analog.sig_source_f(Rs, analog.GR_SIN_WAVE, f1, 0, 0) src2 = analog.noise_source_f(analog.GR_GAUSSIAN, 1) src = blocks.add_ff() thr = blocks.throttle(gr.sizeof_float, 100*npts) self.snk1 = qtgui.histogram_sink_f(npts, 200, -5, 5, "Histogram") self.connect(src1, (src,0)) self.connect(src2, (src,1)) self.connect(src, thr, self.snk1) self.ctrl_win = control_box(self.snk1) self.ctrl_win.attach_signal1(src1) self.ctrl_win.attach_signal2(src2) # Get the reference pointer to the SpectrumDisplayForm QWidget pyQt = self.snk1.pyqwidget() # Wrap the pointer as a PyQt SIP object # This can now be manipulated as a PyQt4.QtGui.QWidget pyWin = sip.wrapinstance(pyQt, QtGui.QWidget) #pyWin.show() self.main_box = dialog_box(pyWin, self.ctrl_win) self.main_box.show()
def test_sig_source_square(): top = gr.top_block() src = analog.sig_source_f(1e6, analog.GR_SQR_WAVE, 200e3, 1.0) probe = blocks.probe_rate(gr.sizeof_float) top.connect(src, probe) return top, probe
def __init__(self, frame, panel, vbox, argv): stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv) fft_size = 512 # build our flow graph input_rate = 20.000e3 # Generate a complex sinusoid self.src1 = analog.sig_source_c(input_rate, analog.GR_SIN_WAVE, 5.75e3, 1000) #src1 = analog.sig_source_c(input_rate, analog.GR_CONST_WAVE, 5.75e3, 1000) # We add these throttle blocks so that this demo doesn't # suck down all the CPU available. Normally you wouldn't use these. self.thr1 = blocks.throttle(gr.sizeof_gr_complex, input_rate) sink1 = waterfall_sink_c(panel, title="Complex Data", fft_size=fft_size, sample_rate=input_rate, baseband_freq=100e3) self.connect(self.src1, self.thr1, sink1) vbox.Add(sink1.win, 1, wx.EXPAND) # generate a real sinusoid self.src2 = analog.sig_source_f(input_rate, analog.GR_SIN_WAVE, 5.75e3, 1000) self.thr2 = blocks.throttle(gr.sizeof_float, input_rate) sink2 = waterfall_sink_f(panel, title="Real Data", fft_size=fft_size, sample_rate=input_rate, baseband_freq=100e3) self.connect(self.src2, self.thr2, sink2) vbox.Add(sink2.win, 1, wx.EXPAND)
def __init__(self, frame, panel, vbox, argv): stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv) # build our flow graph input_rate = 20.48e3 # Generate a real and complex sinusoids src1 = analog.sig_source_f(input_rate, analog.GR_SIN_WAVE, 2.21e3, 1) src2 = analog.sig_source_c(input_rate, analog.GR_SIN_WAVE, 2.21e3, 1) # We add these throttle blocks so that this demo doesn't # suck down all the CPU available. Normally you wouldn't use these. thr1 = blocks.throttle(gr.sizeof_float, input_rate) thr2 = blocks.throttle(gr.sizeof_gr_complex, input_rate) sink1 = number_sink_f(panel, unit='V',label="Real Data", avg_alpha=0.001, sample_rate=input_rate, minval=-1, maxval=1, ref_level=0, decimal_places=3) vbox.Add(sink1.win, 1, wx.EXPAND) sink2 = number_sink_c(panel, unit='V',label="Complex Data", avg_alpha=0.001, sample_rate=input_rate, minval=-1, maxval=1, ref_level=0, decimal_places=3) vbox.Add(sink2.win, 1, wx.EXPAND) self.connect(src1, thr1, sink1) self.connect(src2, thr2, sink2)
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Lab 1") _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 = 32000 self.my_var = my_var = 5 + 6 # this is a + b self.freq = freq = 1e3 ################################################## # Blocks ################################################## _freq_sizer = wx.BoxSizer(wx.VERTICAL) self._freq_text_box = forms.text_box( parent=self.GetWin(), sizer=_freq_sizer, value=self.freq, callback=self.set_freq, label="Frequency", converter=forms.float_converter(), proportion=0, ) self._freq_slider = forms.slider( parent=self.GetWin(), sizer=_freq_sizer, value=self.freq, callback=self.set_freq, minimum=0, maximum=16e3, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_freq_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.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate,True) self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, freq, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.wxgui_scopesink2_0, 0))
def __init__(self): gr.top_block.__init__(self) parser = OptionParser(option_class=eng_option) parser.add_option("-O", "--audio-output", type="string", default="", help="pcm output device name. E.g., hw:0,0 or /dev/dsp") parser.add_option("-r", "--sample-rate", type="eng_float", default=48000, help="set sample rate to RATE (48000)") parser.add_option("-D", "--dont-block", action="store_false", default=True, dest="ok_to_block") (options, args) = parser.parse_args () if len(args) != 0: parser.print_help() raise SystemExit, 1 sample_rate = int(options.sample_rate) ampl = 0.1 src0 = analog.sig_source_f(sample_rate, analog.GR_SIN_WAVE, 650, ampl) dst = audio.sink(sample_rate, options.audio_output, options.ok_to_block) self.connect (src0, (dst, 0))
def add_vor(freq, angle): compensation = math.pi / 180 * -6.5 # empirical, calibrated against VOR receiver (and therefore probably wrong) angle = angle + compensation angle = angle % (2 * math.pi) vor_sig_freq = 30 phase_shift = int(rf_rate / vor_sig_freq * (angle / (2 * math.pi))) vor_dev = 480 vor_channel = make_channel(freq) vor_30 = analog.sig_source_f(audio_rate, analog.GR_COS_WAVE, vor_sig_freq, 1, 0) vor_add = blocks.add_cc(1) vor_audio = blocks.add_ff(1) # Audio/AM signal self.connect( vor_30, blocks.multiply_const_ff(0.3), # M_n (vor_audio, 0)) self.connect(audio_signal, blocks.multiply_const_ff(0.07), # M_i (vor_audio, 1)) # Carrier component self.connect( analog.sig_source_c(0, analog.GR_CONST_WAVE, 0, 0, 1), (vor_add, 0)) # AM component self.connect( vor_audio, blocks.float_to_complex(1), make_interpolator(), blocks.delay(gr.sizeof_gr_complex, phase_shift), (vor_add, 1)) # FM component vor_fm_mult = blocks.multiply_cc(1) self.connect( # carrier generation analog.sig_source_f(rf_rate, analog.GR_COS_WAVE, 9960, 1, 0), blocks.float_to_complex(1), (vor_fm_mult, 1)) self.connect( # modulation vor_30, filter.interp_fir_filter_fff(interp, interp_taps), # float not complex analog.frequency_modulator_fc(2 * math.pi * vor_dev / rf_rate), blocks.multiply_const_cc(0.3), # M_d vor_fm_mult, (vor_add, 2)) self.connect( vor_add, vor_channel) signals.append(vor_channel)
def __init__(self): gr.top_block.__init__(self) parser = ArgumentParser() parser.add_argument("-O", "--audio-output", default="", help="pcm output device name. E.g., hw:0,0 or /dev/dsp") parser.add_argument("-r", "--sample-rate", type=eng_float, default=48000, help="set sample rate to RATE (%(default)r)") args = parser.parse_args() sample_rate = int(args.sample_rate) ampl = 0.1 src0 = analog.sig_source_f(sample_rate, analog.GR_SIN_WAVE, 350, ampl) src1 = analog.sig_source_f(sample_rate, analog.GR_SIN_WAVE, 440, ampl) dst = audio.sink(sample_rate, args.audio_output) self.connect(src0, (dst, 0)) self.connect(src1, (dst, 1))
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 = 44100 self.center1 = center1 = 0 ################################################## # Blocks ################################################## self._center1_range = Range(-20000, 20000, 100, 0, 200) self._center1_win = RangeWidget(self._center1_range, self.set_center1, "center1", "counter_slider", float) self.top_layout.addWidget(self._center1_win) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_fcf(1, (1, ), center1, samp_rate) self.freq_xlating_fft_filter_ccc_0 = filter.freq_xlating_fft_filter_ccc(1, (1, ), center1, samp_rate) self.freq_xlating_fft_filter_ccc_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0.declare_sample_delay(0) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_complex_to_float_0_0 = blocks.complex_to_float(1) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.audio_source_0 = audio.source(samp_rate, "", True) self.audio_sink_0 = audio.sink(samp_rate, "", True) self.analog_const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0) ################################################## # Connections ################################################## self.connect((self.analog_const_source_x_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.audio_source_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.audio_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_complex_to_float_0_0, 0), (self.audio_sink_0, 1)) self.connect((self.blocks_float_to_complex_0, 0), (self.freq_xlating_fft_filter_ccc_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.blocks_complex_to_float_0_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_complex_to_float_0, 0))
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 = 32000 self.center_freq = center_freq = 0 ################################################## # Blocks ################################################## self.freq_sweep_probe = blocks.probe_signal_f() def _center_freq_probe(): while True: val = self.freq_sweep_probe.level() try: self.set_center_freq(val) except AttributeError: pass time.sleep(1.0 / (10)) _center_freq_thread = threading.Thread(target=_center_freq_probe) _center_freq_thread.daemon = True _center_freq_thread.start() self.blocks_throttle_0 = blocks.throttle(gr.sizeof_int*1, samp_rate,True) self.blocks_int_to_float_1 = blocks.int_to_float(1, 1) self.audio_sink_0 = audio.sink(samp_rate, "", True) self.analog_sig_source_x_1 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, center_freq*300+300, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_i(samp_rate, analog.GR_SAW_WAVE, 0.1, 3, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.analog_sig_source_x_1, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_int_to_float_1, 0), (self.freq_sweep_probe, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_int_to_float_1, 0))
def __init__(self): gr.top_block.__init__(self) sample_rate = 48000 ampl = 0.1 src = analog.sig_source_f(sample_rate, analog.GR_SIN_WAVE, 350, ampl) sink = iio.fmcomms_sink() self.connect(src, sink) print "Devices instantiated and connect"
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 50000 ################################################## # 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 = 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.low_pass_filter_0 = filter.fir_filter_fff(1, firdes.low_pass( 1, samp_rate, 1000, 1, firdes.WIN_HAMMING, 6.76)) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate,True) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_float*1, "/home/students/btech/b13236/EE304P/Lab_2/sample_signal", True) self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 10000, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_file_source_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.wxgui_scopesink2_0, 0))
def __init__(self): gr.top_block.__init__(self) self._nsamples = 1000000 self._audio_rate = 8000 # Set up N channels with their own baseband and IF frequencies self._N = 5 chspacing = 16000 freq = [10, 20, 30, 40, 50] f_lo = [0, 1*chspacing, -1*chspacing, 2*chspacing, -2*chspacing] self._if_rate = 4*self._N*self._audio_rate # Create a signal source and frequency modulate it self.sum = blocks.add_cc() for n in xrange(self._N): sig = analog.sig_source_f(self._audio_rate, analog.GR_SIN_WAVE, freq[n], 0.5) fm = fmtx(f_lo[n], self._audio_rate, self._if_rate) self.connect(sig, fm) self.connect(fm, (self.sum, n)) self.head = blocks.head(gr.sizeof_gr_complex, self._nsamples) self.snk_tx = blocks.vector_sink_c() self.channel = channels.channel_model(0.1) self.connect(self.sum, self.head, self.channel, self.snk_tx) # Design the channlizer self._M = 10 bw = chspacing/2.0 t_bw = chspacing/10.0 self._chan_rate = self._if_rate / self._M self._taps = filter.firdes.low_pass_2(1, self._if_rate, bw, t_bw, attenuation_dB=100, window=filter.firdes.WIN_BLACKMAN_hARRIS) tpc = math.ceil(float(len(self._taps)) / float(self._M)) print "Number of taps: ", len(self._taps) print "Number of channels: ", self._M print "Taps per channel: ", tpc self.pfb = filter.pfb.channelizer_ccf(self._M, self._taps) self.connect(self.channel, self.pfb) # Create a file sink for each of M output channels of the filter and connect it self.fmdet = list() self.squelch = list() self.snks = list() for i in xrange(self._M): self.fmdet.append(analog.nbfm_rx(self._audio_rate, self._chan_rate)) self.squelch.append(analog.standard_squelch(self._audio_rate*10)) self.snks.append(blocks.vector_sink_f()) self.connect((self.pfb, i), self.fmdet[i], self.squelch[i], self.snks[i])
def __init__(self): gr.top_block.__init__(self) # standard quality sample rate and amplitude value sample_rate = 32000 ampl = 0.1 # We create two sine waves with the same amplitude and sameple rate # from above. src0 = analog.sig_source_f(sample_rate, analog.GR_SIN_WAVE, 350, ampl) src1 = analog.sig_source_f(sample_rate, analog.GR_SIN_WAVE, 440, ampl) # dst is the "destination" or audio sink block dst = audio.sink(sample_rate, "") # We then connect the two sine waves to the destination block self.connect(src0, (dst, 0)) self.connect(src1, (dst, 1))
class if_else(gr.top_block, Qt.QWidget): def __init__(self): gr.top_block.__init__(self, "If Else") Qt.QWidget.__init__(self) self.setWindowTitle("If Else") 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", "if_else") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.variable_function_probe_0 = variable_function_probe_0 = 0 self.samp_rate = samp_rate = 32000 self.freq = freq = 1000 self.ampl = ampl = 1 ################################################## # Blocks ################################################## self.probe = blocks.probe_signal_f() self._freq_tool_bar = Qt.QToolBar(self) self._freq_tool_bar.addWidget(Qt.QLabel("freq" + ": ")) self._freq_line_edit = Qt.QLineEdit(str(self.freq)) self._freq_tool_bar.addWidget(self._freq_line_edit) self._freq_line_edit.returnPressed.connect( lambda: self.set_freq(int(self._freq_line_edit.text().toAscii()))) self.top_layout.addWidget(self._freq_tool_bar) self._ampl_tool_bar = Qt.QToolBar(self) self._ampl_tool_bar.addWidget(Qt.QLabel("ampl" + ": ")) self._ampl_line_edit = Qt.QLineEdit(str(self.ampl)) self._ampl_tool_bar.addWidget(self._ampl_line_edit) self._ampl_line_edit.returnPressed.connect( lambda: self.set_ampl(int(self._ampl_line_edit.text().toAscii()))) self.top_layout.addWidget(self._ampl_tool_bar) def _variable_function_probe_0_probe(): while True: val = self.probe.level() print "Val:", val if val == 1: self.set_ampl(1) self.set_freq(1000) else: self.set_ampl(.3) self.set_freq(100) try: self.set_variable_function_probe_0(val) except AttributeError, e: pass time.sleep(1.0 / (10)) _variable_function_probe_0_thread = threading.Thread( target=_variable_function_probe_0_probe) _variable_function_probe_0_thread.daemon = True _variable_function_probe_0_thread.start() self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "QT GUI Plot", #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.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_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1, samp_rate) self.analog_sig_source_x_1 = analog.sig_source_f( samp_rate, analog.GR_SIN_WAVE, freq, ampl, 0) self.analog_sig_source_x_0 = analog.sig_source_f( samp_rate, analog.GR_SQR_WAVE, 0.1, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_1, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.probe, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") 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", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.tx_gain = tx_gain = 50 self.samp_rate = samp_rate = 1000000 self.rx_gain = rx_gain = 10 self.fc = fc = 910000000 self.dac_rate = dac_rate = 1000000 ################################################## # Blocks ################################################## self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(fc, 0) self.uhd_usrp_source_0.set_gain(rx_gain, 0) self.uhd_usrp_source_0.set_antenna('RX2', 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(fc, 0) self.uhd_usrp_sink_0.set_gain(tx_gain, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self.rfid_reader_reader_0 = rfid_reader.reader(dac_rate) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 4096, #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(False) 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) 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(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) 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_grid_layout.addWidget(self._qtgui_time_sink_x_0_win) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1, samp_rate, True) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.analog_const_source_x_0 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, 0) ################################################## # Connections ################################################## self.connect((self.analog_const_source_x_0, 0), (self.rfid_reader_reader_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.rfid_reader_reader_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_time_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "Tutorial Three 2") Qt.QWidget.__init__(self) self.setWindowTitle("Tutorial Three 2") 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", "tutorial_three_2") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.tutorial_multiply_py_ff_0 = tutorial.multiply_py_ff(2) 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(-5, 5) 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(False) 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.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1, samp_rate, True) self.analog_sig_source_x_0 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, 1000, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.tutorial_multiply_py_ff_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.tutorial_multiply_py_ff_0, 0), (self.blocks_throttle_0, 0))
def test_004(self): ''' Test the floating point AGC loop (attack and decay rate inputs) ''' tb = self.tb expected_result = \ (0.0, 58.83704376220703, 40.194339752197266, 2.9184224605560303, 0.6760660409927368, -6.79303795436681e-08, -1.4542515277862549, -1.9210143089294434, -1.0450801849365234, -0.6193966865539551, 1.3429632872430375e-07, 1.4308913946151733, 1.9054334163665771, 1.044317603111267, 0.619373619556427, -2.003930177352231e-07, -1.4308818578720093, -1.905427098274231, -1.0443172454833984, -0.6193735599517822, 2.6858961632569844e-07, 1.4308820962905884, 1.9054267406463623, 1.0443172454833984, 0.6193734407424927, -3.3468785431978176e-07, -1.4308820962905884, -1.9054267406463623, -1.0443171262741089, -0.6193735599517822, 4.0288449554282124e-07, 1.430882215499878, 1.905427098274231, 1.0443170070648193, 0.6193734407424927, -4.689827903803234e-07, -1.430882453918457, -1.9054268598556519, -1.0443170070648193, -0.6193733811378479, 5.371793463382346e-07, 1.4308825731277466, 1.9054265022277832, 1.0443170070648193, 0.6193733811378479, -6.032776127540274e-07, -1.4308825731277466, -1.9054265022277832, -1.0443168878555298, -0.6193733811378479) sampling_freq = 100 src1 = analog.sig_source_f(sampling_freq, analog.GR_SIN_WAVE, sampling_freq * 0.10, 100) dst1 = blocks.vector_sink_f() head = blocks.head(gr.sizeof_float, int(5 * sampling_freq * 0.10)) agc = analog.agc2_ff(1e-2, 1e-3, 1, 1) tb.connect(src1, head) tb.connect(head, agc) tb.connect(agc, dst1) tb.run() dst_data = dst1.data() self.assertFloatTuplesAlmostEqual(expected_result, dst_data, 4)
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): 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.freq_0 = freq_0 = 525.2e6 self.threshold = threshold = -60 self.samp_rate = samp_rate = 2.048e6 self.freq = freq = freq_0 ################################################## # Blocks ################################################## _threshold_sizer = wx.BoxSizer(wx.VERTICAL) self._threshold_text_box = forms.text_box( parent=self.GetWin(), sizer=_threshold_sizer, value=self.threshold, callback=self.set_threshold, label="threshold", converter=forms.float_converter(), proportion=0, ) self._threshold_slider = forms.slider( parent=self.GetWin(), sizer=_threshold_sizer, value=self.threshold, callback=self.set_threshold, minimum=-100, maximum=0, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_threshold_sizer) self.wxgui_numbersink2_0_0 = numbersink2.number_sink_f( self.GetWin(), unit="signal present", minval=0, maxval=1, factor=1.0, decimal_places=10, ref_level=0, sample_rate=2.048e6, number_rate=15, average=False, avg_alpha=None, label="Signal detection", peak_hold=False, show_gauge=True, ) self.Add(self.wxgui_numbersink2_0_0.win) self.wxgui_numbersink2_0 = numbersink2.number_sink_f( self.GetWin(), unit="Units", minval=-120, maxval=0, factor=1.0, decimal_places=10, ref_level=0, sample_rate=2048000, number_rate=15, average=True, avg_alpha=0.03, label="Level", peak_hold=False, show_gauge=True, ) self.Add(self.wxgui_numbersink2_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=2048000, fft_size=1024, fft_rate=15, average=True, avg_alpha=0.030, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + "") self.rtlsdr_source_0.set_sample_rate(2.048e6) self.rtlsdr_source_0.set_center_freq(freq, 0) self.rtlsdr_source_0.set_freq_corr(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(2, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(35, 0) self.rtlsdr_source_0.set_if_gain(35, 0) self.rtlsdr_source_0.set_bb_gain(5, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "tab1") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "tab2") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "tab3") self.Add(self.notebook_0) _freq_0_sizer = wx.BoxSizer(wx.VERTICAL) self._freq_0_text_box = forms.text_box( parent=self.GetWin(), sizer=_freq_0_sizer, value=self.freq_0, callback=self.set_freq_0, label='freq_0', converter=forms.float_converter(), proportion=0, ) self._freq_0_slider = forms.slider( parent=self.GetWin(), sizer=_freq_0_sizer, value=self.freq_0, callback=self.set_freq_0, minimum=478e6, maximum=862e6, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_freq_0_sizer) self.fft_vxx_0 = fft.fft_vcc(1024, True, (window.rectangular(1024)), True, 1) self.blocks_vector_to_stream_0 = blocks.vector_to_stream( gr.sizeof_float * 1, 1024) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, 2048000, True) self.blocks_threshold_ff_0 = blocks.threshold_ff(-100, threshold, -60) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, 1024) self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, 1, 0) self.blocks_file_sink_0 = blocks.file_sink( gr.sizeof_int * 1, "/media/ubuntu/01D165566F075780/Q3/wireless networking/GNU/out1.txt", False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_divide_xx_0 = blocks.divide_ff(1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared( 1024) self.analog_const_source_x_0 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, 1.04858e6) ################################################## # Connections ################################################## self.connect((self.analog_const_source_x_0, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_vector_to_stream_0, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.blocks_nlog10_ff_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_threshold_ff_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.wxgui_numbersink2_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) self.connect((self.blocks_threshold_ff_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_threshold_ff_0, 0), (self.wxgui_numbersink2_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_divide_xx_0, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.wxgui_fftsink2_0, 0))
def __init__(self): gr.top_block.__init__(self, "Loopback QAM Modulation - Sine Signals") Qt.QWidget.__init__(self) self.setWindowTitle("Loopback QAM Modulation - Sine Signals") 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", "loopback_qam_sine_signals") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 400000 self.carrier = carrier = 80e3 ################################################## # Blocks ################################################## self.janela = Qt.QTabWidget() self.janela_widget_0 = Qt.QWidget() self.janela_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.janela_widget_0) self.janela_grid_layout_0 = Qt.QGridLayout() self.janela_layout_0.addLayout(self.janela_grid_layout_0) self.janela.addTab(self.janela_widget_0, "Frequency") self.janela_widget_1 = Qt.QWidget() self.janela_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.janela_widget_1) self.janela_grid_layout_1 = Qt.QGridLayout() self.janela_layout_1.addLayout(self.janela_grid_layout_1) self.janela.addTab(self.janela_widget_1, "QAM Signal") self.top_layout.addWidget(self.janela) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 4 #number of inputs ) self.qtgui_freq_sink_x_1.set_update_time(0.10) self.qtgui_freq_sink_x_1.set_y_axis(-140, 10) self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(False) self.qtgui_freq_sink_x_1.enable_grid(True) self.qtgui_freq_sink_x_1.set_fft_average(0.2) self.qtgui_freq_sink_x_1.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_1.disable_legend() if "float" == "float" or "float" == "msg_float": self.qtgui_freq_sink_x_1.set_plot_pos_half(not True) labels = ["Original Signal 1", "Original Signal 2", "Demodulated Signal 1", "Demodulated Signal 2", "", "", "", "", "", ""] 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 xrange(4): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_win = sip.wrapinstance(self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget) self.janela_layout_0.addWidget(self._qtgui_freq_sink_x_1_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN, #wintype 0, #fc samp_rate, #bw "Signal Modulated", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 0) 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_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "float" == "float" or "float" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ["QAM Signal", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["magenta", "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 xrange(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.janela_layout_1.addWidget(self._qtgui_freq_sink_x_0_win) self.low_pass_filter_0_0 = filter.fir_filter_fff(1, firdes.low_pass( 1, samp_rate, 12000, 100, firdes.WIN_HANN, 6.76)) self.low_pass_filter_0 = filter.fir_filter_fff(1, firdes.low_pass( 1, samp_rate, 8000, 100, firdes.WIN_HANN, 6.76)) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate,True) self.blocks_multiply_xx_0_0_0_0 = blocks.multiply_vff(1) self.blocks_multiply_xx_0_0_0 = blocks.multiply_vff(1) self.blocks_multiply_xx_0_0 = blocks.multiply_vff(1) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_add_xx_0_1 = blocks.add_vff(1) self.audio_sink_0 = audio.sink(samp_rate, "", True) self.analog_sig_source_x_1_2_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 12000, 1, 0) self.analog_sig_source_x_1_2 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 8000, 2, 0) self.analog_sig_source_x_1_1 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, carrier, 1, 0) self.analog_sig_source_x_1_0_0 = analog.sig_source_f(samp_rate, analog.GR_SIN_WAVE, carrier, 1, 0) self.analog_sig_source_x_1_0 = analog.sig_source_f(samp_rate, analog.GR_SIN_WAVE, carrier, 2, 0) self.analog_sig_source_x_1 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, carrier, 2, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_sig_source_x_1_0, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.analog_sig_source_x_1_0_0, 0), (self.blocks_multiply_xx_0_0_0_0, 0)) self.connect((self.analog_sig_source_x_1_1, 0), (self.blocks_multiply_xx_0_0_0, 0)) self.connect((self.analog_sig_source_x_1_2, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.analog_sig_source_x_1_2, 0), (self.qtgui_freq_sink_x_1, 3)) self.connect((self.analog_sig_source_x_1_2_0, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.analog_sig_source_x_1_2_0, 0), (self.qtgui_freq_sink_x_1, 2)) self.connect((self.blocks_add_xx_0_1, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0_1, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.blocks_add_xx_0_1, 1)) self.connect((self.blocks_multiply_xx_0_0_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_multiply_xx_0_0_0_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_xx_0_0_0, 1)) self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_xx_0_0_0_0, 1)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.audio_sink_0, 1)) self.connect((self.low_pass_filter_0, 0), (self.qtgui_freq_sink_x_1, 1)) self.connect((self.low_pass_filter_0_0, 0), (self.audio_sink_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.qtgui_freq_sink_x_1, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") 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", "top_block") 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 = 32000 ################################################## # Blocks ################################################## self.view_tabs = Qt.QTabWidget() self.view_tabs_widget_0 = Qt.QWidget() self.view_tabs_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.view_tabs_widget_0) self.view_tabs_grid_layout_0 = Qt.QGridLayout() self.view_tabs_layout_0.addLayout(self.view_tabs_grid_layout_0) self.view_tabs.addTab(self.view_tabs_widget_0, 'Tiempo') self.view_tabs_widget_1 = Qt.QWidget() self.view_tabs_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.view_tabs_widget_1) self.view_tabs_grid_layout_1 = Qt.QGridLayout() self.view_tabs_layout_1.addLayout(self.view_tabs_grid_layout_1) self.view_tabs.addTab(self.view_tabs_widget_1, 'Frecuencia') self.top_grid_layout.addWidget(self.view_tabs) self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "Generador Real", #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(False) 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 = ['', '', '', '', '', '', '', '', '', ''] 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.view_tabs_layout_0.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "Generador Complejo", #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(False) 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 = ['', '', '', '', '', '', '', '', '', ''] 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(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) 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.view_tabs_layout_0.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "Generador Real", #name 1 ) self.qtgui_freq_sink_x_1.set_update_time(0.10) self.qtgui_freq_sink_x_1.set_y_axis(-140, 10) self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(False) self.qtgui_freq_sink_x_1.enable_grid(False) self.qtgui_freq_sink_x_1.set_fft_average(1.0) self.qtgui_freq_sink_x_1.enable_axis_labels(True) self.qtgui_freq_sink_x_1.enable_control_panel(False) self.qtgui_freq_sink_x_1.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_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_win = sip.wrapinstance(self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget) self.view_tabs_layout_1.addWidget(self._qtgui_freq_sink_x_1_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "Generador Complejo", #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_AUTO, 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) 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.view_tabs_layout_1.addWidget(self._qtgui_freq_sink_x_0_win) self.analog_sig_source_x_1 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 1000, 1, 0, 0) self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 1000, 1, 0, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.qtgui_freq_sink_x_1, 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.qtgui_freq_sink_x_0, 0)) self.connect((self.analog_sig_source_x_1, 0), (self.qtgui_time_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "Bpsk Tx") Qt.QWidget.__init__(self) self.setWindowTitle("Bpsk Tx") 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", "bpsk_tx") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate_u = samp_rate_u = 200e3 self.samp_rate = samp_rate = 48000 self.center_freq = center_freq = .135e10 ################################################## # Blocks ################################################## self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("addr=192.168.10.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(samp_rate_u) self.uhd_usrp_sink_0.set_center_freq(center_freq, 0) self.uhd_usrp_sink_0.set_normalized_gain(1, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) self.uhd_usrp_sink_0.set_bandwidth(200e6, 0) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((2, )) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_float * 1, "/root/SDR_Class/Lab4/bpsk_audio.mp3", True) self.blocks_add_const_vxx_1 = blocks.add_const_vff((-1, )) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-97, )) self.analog_const_source_x_0 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, 0) self.TXConstellation = qtgui.const_sink_c( 1024, #size "TX Constellation", #name 1 #number of inputs ) self.TXConstellation.set_update_time(0.10) self.TXConstellation.set_y_axis(-2, 2) self.TXConstellation.set_x_axis(-2, 2) self.TXConstellation.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.TXConstellation.enable_autoscale(False) self.TXConstellation.enable_grid(True) if not True: self.TXConstellation.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [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 xrange(1): if len(labels[i]) == 0: self.TXConstellation.set_line_label(i, "Data {0}".format(i)) else: self.TXConstellation.set_line_label(i, labels[i]) self.TXConstellation.set_line_width(i, widths[i]) self.TXConstellation.set_line_color(i, colors[i]) self.TXConstellation.set_line_style(i, styles[i]) self.TXConstellation.set_line_marker(i, markers[i]) self.TXConstellation.set_line_alpha(i, alphas[i]) self._TXConstellation_win = sip.wrapinstance( self.TXConstellation.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._TXConstellation_win) ################################################## # Connections ################################################## self.connect((self.analog_const_source_x_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_add_const_vxx_1, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.TXConstellation, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_const_vxx_1, 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 ################################################## # Blocks ################################################## self.low_pass_filter_0 = filter.interp_fir_filter_fff( 1, firdes.low_pass(1, samp_rate, 50e3, 50, firdes.WIN_HAMMING, 6.76)) self.hilbert_fc_0_0 = filter.hilbert_fc(5000 * 2, firdes.WIN_HAMMING, 6.76) self.hilbert_fc_0 = filter.hilbert_fc(10000, firdes.WIN_HAMMING, 6.76) self.blocks_wavfile_source_0 = blocks.wavfile_source( "/home/ritesh/Dropbox/Sem5/EE340_communications_Lab/Lab 5/Q2/vocal.wav", True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1, samp_rate, True) self.blocks_multiply_xx_1 = blocks.multiply_vff(1) self.blocks_multiply_xx_0_0 = blocks.multiply_vff(1) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_complex_to_float_0_1 = blocks.complex_to_float(1) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.audio_sink_0 = audio.sink(48000, "", True) self.analog_sig_source_x_0_0 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, 100e3, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.analog_sig_source_x_0_0, 0), (self.hilbert_fc_0_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.blocks_complex_to_float_0_1, 1), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_complex_to_float_0_1, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.hilbert_fc_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.hilbert_fc_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.hilbert_fc_0_0, 0), (self.blocks_complex_to_float_0_1, 0)) self.connect((self.low_pass_filter_0, 0), (self.audio_sink_0, 0))
def test_002(self): ''' Test the floating point AGC loop (single rate input) ''' tb = self.tb expected_result = ( 0.0, 58.83704376220703, 89.69985961914062, 81.26403045654297, 45.50606918334961, -3.3625440210016677e-06, -42.9488639831543, -65.50326538085938, -59.368656158447266, -33.26097869873047, 4.995997642254224e-06, 31.423521041870117, 47.950958251953125, 43.48566436767578, 24.37834358215332, -5.4677821026416495e-06, -23.06298828125, -35.21844482421875, -31.964082717895508, -17.93484115600586, 5.396469077822985e-06, 16.998228073120117, 25.982229232788086, 23.60628318786621, 13.260700225830078, -4.97806149724056e-06, -12.598825454711914, -19.282241821289062, -17.543500900268555, -9.870061874389648, 4.467380676942412e-06, 9.407480239868164, 14.422045707702637, 13.14553451538086, 7.410478591918945, -3.91256025977782e-06, -7.092466354370117, -10.896439552307129, -9.955231666564941, -5.62628698348999, 3.411524403418298e-06, 5.413146018981934, 8.338950157165527, 7.640974521636963, 4.332027435302734, -2.95963241114805e-06, -4.19495964050293, -6.483736991882324, -5.962202072143555, -3.3931667804718018) sampling_freq = 100 src1 = analog.sig_source_f(sampling_freq, analog.GR_SIN_WAVE, sampling_freq * 0.10, 100.0) dst1 = blocks.vector_sink_f() head = blocks.head(gr.sizeof_float, int(5 * sampling_freq * 0.10)) agc = analog.agc_ff(1e-3, 1, 1) tb.connect(src1, head) tb.connect(head, agc) tb.connect(agc, dst1) tb.run() dst_data = dst1.data() self.assertFloatTuplesAlmostEqual(expected_result, dst_data, 4)
def __init__(self): gr.top_block.__init__(self, "VOR Decoder") Qt.QWidget.__init__(self) self.setWindowTitle("VOR Decoder") 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", "vor_playback_sigmf_4") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 250e3 self.decim = decim = 5 self.throttle_rate = throttle_rate = 1 self.nfft = nfft = 512 self.goertzel_avg = goertzel_avg = 1000.0 self.fine = fine = 1e3 self.delay = delay = 400 self.avg = avg = 1000.0 self.audio_rate = audio_rate = samp_rate/decim/25*24 self.audio_gain = audio_gain = 1 ################################################## # Blocks ################################################## self._throttle_rate_tool_bar = Qt.QToolBar(self) self._throttle_rate_tool_bar.addWidget(Qt.QLabel("throttle_rate"+": ")) self._throttle_rate_line_edit = Qt.QLineEdit(str(self.throttle_rate)) self._throttle_rate_tool_bar.addWidget(self._throttle_rate_line_edit) self._throttle_rate_line_edit.returnPressed.connect( lambda: self.set_throttle_rate(eng_notation.str_to_num(str(self._throttle_rate_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._throttle_rate_tool_bar, 0, 6, 1, 2) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(6, 8): self.top_grid_layout.setColumnStretch(c, 1) self._samp_rate_tool_bar = Qt.QToolBar(self) self._samp_rate_tool_bar.addWidget(Qt.QLabel("samp_rate"+": ")) self._samp_rate_line_edit = Qt.QLineEdit(str(self.samp_rate)) self._samp_rate_tool_bar.addWidget(self._samp_rate_line_edit) self._samp_rate_line_edit.returnPressed.connect( lambda: self.set_samp_rate(eng_notation.str_to_num(str(self._samp_rate_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._samp_rate_tool_bar, 0, 4, 1, 2) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 6): self.top_grid_layout.setColumnStretch(c, 1) self._goertzel_avg_tool_bar = Qt.QToolBar(self) self._goertzel_avg_tool_bar.addWidget(Qt.QLabel("goertzel_avg"+": ")) self._goertzel_avg_line_edit = Qt.QLineEdit(str(self.goertzel_avg)) self._goertzel_avg_tool_bar.addWidget(self._goertzel_avg_line_edit) self._goertzel_avg_line_edit.returnPressed.connect( lambda: self.set_goertzel_avg(eng_notation.str_to_num(str(self._goertzel_avg_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._goertzel_avg_tool_bar, 8, 6, 1, 2) for r in range(8, 9): self.top_grid_layout.setRowStretch(r, 1) for c in range(6, 8): self.top_grid_layout.setColumnStretch(c, 1) self._delay_tool_bar = Qt.QToolBar(self) self._delay_tool_bar.addWidget(Qt.QLabel("delay"+": ")) self._delay_line_edit = Qt.QLineEdit(str(self.delay)) self._delay_tool_bar.addWidget(self._delay_line_edit) self._delay_line_edit.returnPressed.connect( lambda: self.set_delay(int(str(self._delay_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._delay_tool_bar, 2, 4, 1, 2) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 6): self.top_grid_layout.setColumnStretch(c, 1) self._avg_tool_bar = Qt.QToolBar(self) self._avg_tool_bar.addWidget(Qt.QLabel("avg"+": ")) self._avg_line_edit = Qt.QLineEdit(str(self.avg)) self._avg_tool_bar.addWidget(self._avg_line_edit) self._avg_line_edit.returnPressed.connect( lambda: self.set_avg(eng_notation.str_to_num(str(self._avg_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._avg_tool_bar, 8, 2, 1, 2) for r in range(8, 9): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 4): self.top_grid_layout.setColumnStretch(c, 1) self.sigmf_source_0 = gr_sigmf.source('/captures/20191228/VOR_2019-12-28T19:34:28Z.sigmf-data', "cf32" + ("_le" if sys.byteorder == "little" else "_be"), False) self.rational_resampler_xxx_0_0_0 = filter.rational_resampler_ccc( interpolation=24, decimation=25*5, taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024*2, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / decim, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.010) self.qtgui_waterfall_sink_x_0.enable_grid(False) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": 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 xrange(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.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 4, 0, 2, 4) for r in range(4, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_0_0_0 = qtgui.time_sink_f( 256*8, #size audio_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0_0_0.set_update_time(0.0010) self.qtgui_time_sink_x_0_0_0_0.set_y_axis(-180, 180) self.qtgui_time_sink_x_0_0_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, .25, 0, 0, "") self.qtgui_time_sink_x_0_0_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0_0_0.enable_grid(True) self.qtgui_time_sink_x_0_0_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0_0_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_0_0_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_0_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_0_0_win, 6, 0, 2, 4) for r in range(6, 8): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_0_0 = qtgui.time_sink_f( 256, #size audio_rate / 3 / 8, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0_0.set_update_time(0.0010) self.qtgui_time_sink_x_0_0_0.set_y_axis(-180, 180) self.qtgui_time_sink_x_0_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, .25, 0, 0, "") self.qtgui_time_sink_x_0_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0_0.enable_grid(True) self.qtgui_time_sink_x_0_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_0_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_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_0_win, 6, 4, 2, 4) for r in range(6, 8): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 8): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 8192 /2, #size samp_rate / decim /25 * 24, #samp_rate "30 Hz Variable", #name 2 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.0010) self.qtgui_time_sink_x_0.set_y_axis(-4, 4) 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_NORM, qtgui.TRIG_SLOPE_POS, 0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(True) 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) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['ref', 'var', '', '', '', '', '', '', '', ''] 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): 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_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 4, 4, 2, 4) for r in range(4, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 8): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_number_sink_0_0 = qtgui.number_sink( gr.sizeof_float, 1, qtgui.NUM_GRAPH_NONE, 1 ) self.qtgui_number_sink_0_0.set_update_time(0.10) self.qtgui_number_sink_0_0.set_title("") labels = ['', '', '', '', '', '', '', '', '', ''] units = ['', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0_0.set_min(i, -1) self.qtgui_number_sink_0_0.set_max(i, 1) self.qtgui_number_sink_0_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0.set_label(i, labels[i]) self.qtgui_number_sink_0_0.set_unit(i, units[i]) self.qtgui_number_sink_0_0.set_factor(i, factor[i]) self.qtgui_number_sink_0_0.enable_autoscale(False) self._qtgui_number_sink_0_0_win = sip.wrapinstance(self.qtgui_number_sink_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_0_win, 8, 4, 1, 2) for r in range(8, 9): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 6): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_number_sink_0 = qtgui.number_sink( gr.sizeof_float, 1, qtgui.NUM_GRAPH_NONE, 1 ) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("") labels = ['', '', '', '', '', '', '', '', '', ''] units = ['', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, -1) self.qtgui_number_sink_0.set_max(i, 1) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance(self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_win, 8, 0, 1, 2) for r in range(8, 9): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_1_0 = qtgui.freq_sink_c( 4096, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / decim / 25 * 24, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_1_0.set_update_time(0.010) self.qtgui_freq_sink_x_1_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_1_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1_0.enable_autoscale(False) self.qtgui_freq_sink_x_1_0.enable_grid(True) self.qtgui_freq_sink_x_1_0.set_fft_average(1.0) self.qtgui_freq_sink_x_1_0.enable_axis_labels(True) self.qtgui_freq_sink_x_1_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_1_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_1_0.set_plot_pos_half(not 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 xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_1_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_0_win, 0, 0, 4, 4) for r in range(0, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_f( 4096, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc audio_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_1.set_update_time(0.10) self.qtgui_freq_sink_x_1.set_y_axis(-140, 10) self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(False) self.qtgui_freq_sink_x_1.enable_grid(False) self.qtgui_freq_sink_x_1.set_fft_average(1.0) self.qtgui_freq_sink_x_1.enable_axis_labels(True) self.qtgui_freq_sink_x_1.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_1.disable_legend() if "float" == "float" or "float" == "msg_float": self.qtgui_freq_sink_x_1.set_plot_pos_half(not 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 xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_win = sip.wrapinstance(self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_win, 3, 4, 1, 4) for r in range(3, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 8): self.top_grid_layout.setColumnStretch(c, 1) self.low_pass_filter_0_0 = filter.fir_filter_fff(1, firdes.low_pass( 10, samp_rate / decim / 25 *24, 1e3, 500, firdes.WIN_HAMMING, 6.76)) self.goertzel_fc_0_0 = fft.goertzel_fc(int(audio_rate), 64, 30) self.goertzel_fc_0 = fft.goertzel_fc(int(audio_rate), 64, 30) self._fine_tool_bar = Qt.QToolBar(self) self._fine_tool_bar.addWidget(Qt.QLabel('Fine [Hz]'+": ")) self._fine_line_edit = Qt.QLineEdit(str(self.fine)) self._fine_tool_bar.addWidget(self._fine_line_edit) self._fine_line_edit.returnPressed.connect( lambda: self.set_fine(eng_notation.str_to_num(str(self._fine_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._fine_tool_bar, 1, 4, 1, 2) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 6): self.top_grid_layout.setColumnStretch(c, 1) self.dc_blocker_xx_0_0 = filter.dc_blocker_ff(128, True) self.dc_blocker_xx_0 = filter.dc_blocker_ff(128, True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate*throttle_rate,True) self.blocks_multiply_xx_3 = blocks.multiply_vff(1) self.blocks_multiply_xx_2 = blocks.multiply_vff(1) self.blocks_multiply_xx_1 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vff((180/math.pi, )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((180/math.pi, )) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) self.blocks_moving_average_xx_0_0_1 = blocks.moving_average_ff(int(goertzel_avg), 1/goertzel_avg, 4000, 1) self.blocks_moving_average_xx_0_0_0 = blocks.moving_average_ff(int(avg), 1/avg, 4000, 1) self.blocks_moving_average_xx_0_0 = blocks.moving_average_ff(int(avg), 1/avg, 4000, 1) self.blocks_float_to_complex_1 = blocks.float_to_complex(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_delay_1 = blocks.delay(gr.sizeof_float*1, 0) self.blocks_delay_0 = blocks.delay(gr.sizeof_float*1, delay) self.blocks_complex_to_arg_0_0 = blocks.complex_to_arg(1) self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1) self.band_pass_filter_0_0 = filter.fir_filter_fff(1, firdes.band_pass( 1, samp_rate / decim / 25 * 24 , 25, 35, 5, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0 = filter.fir_filter_fff(1, firdes.band_pass( 1, samp_rate / decim / 25 * 24 , 25, 35, 5, firdes.WIN_HAMMING, 6.76)) self._audio_gain_tool_bar = Qt.QToolBar(self) self._audio_gain_tool_bar.addWidget(Qt.QLabel('vol30'+": ")) self._audio_gain_line_edit = Qt.QLineEdit(str(self.audio_gain)) self._audio_gain_tool_bar.addWidget(self._audio_gain_line_edit) self._audio_gain_line_edit.returnPressed.connect( lambda: self.set_audio_gain(eng_notation.str_to_num(str(self._audio_gain_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._audio_gain_tool_bar, 1, 7, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(7, 8): self.top_grid_layout.setColumnStretch(c, 1) self.analog_sig_source_x_1 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 9960, 1, 0) self.analog_pll_carriertracking_cc_0 = analog.pll_carriertracking_cc(math.pi/200, math.pi/10, -math.pi/10) self.analog_fm_demod_cf_0 = analog.fm_demod_cf( channel_rate=samp_rate / decim / 25 * 24, audio_decim=1, deviation=1e3, audio_pass=100, audio_stop=200, gain=1.0, tau=75e-6, ) self.analog_const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0) self.analog_am_demod_cf_0 = analog.am_demod_cf( channel_rate=48e3, audio_decim=1, audio_pass=12000, audio_stop=13000, ) self.analog_agc2_xx_2 = analog.agc2_ff(1e-2, 1e-2, 1, 1.0) self.analog_agc2_xx_2.set_max_gain(65536) self.analog_agc2_xx_1 = analog.agc2_ff(1e-2, 1e-2, 1, 1) self.analog_agc2_xx_1.set_max_gain(65536) self.analog_agc2_xx_0 = analog.agc2_cc(1e-2, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.analog_pll_carriertracking_cc_0, 0)) self.connect((self.analog_agc2_xx_1, 0), (self.blocks_delay_0, 0)) self.connect((self.analog_agc2_xx_1, 0), (self.blocks_multiply_xx_2, 0)) self.connect((self.analog_agc2_xx_1, 0), (self.goertzel_fc_0, 0)) self.connect((self.analog_agc2_xx_1, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.analog_agc2_xx_2, 0), (self.blocks_delay_1, 0)) self.connect((self.analog_agc2_xx_2, 0), (self.blocks_multiply_xx_3, 0)) self.connect((self.analog_agc2_xx_2, 0), (self.goertzel_fc_0_0, 0)) self.connect((self.analog_agc2_xx_2, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.analog_am_demod_cf_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.analog_const_source_x_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.analog_fm_demod_cf_0, 0), (self.band_pass_filter_0_0, 0)) self.connect((self.analog_pll_carriertracking_cc_0, 0), (self.rational_resampler_xxx_0_0_0, 0)) self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.band_pass_filter_0, 0), (self.dc_blocker_xx_0, 0)) self.connect((self.band_pass_filter_0_0, 0), (self.dc_blocker_xx_0_0, 0)) self.connect((self.blocks_complex_to_arg_0, 0), (self.blocks_moving_average_xx_0_0_1, 0)) self.connect((self.blocks_complex_to_arg_0_0, 0), (self.blocks_multiply_const_vxx_1_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_xx_3, 1)) self.connect((self.blocks_delay_1, 0), (self.blocks_multiply_xx_2, 1)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.blocks_float_to_complex_1, 0), (self.blocks_complex_to_arg_0_0, 0)) self.connect((self.blocks_moving_average_xx_0_0, 0), (self.blocks_float_to_complex_1, 0)) self.connect((self.blocks_moving_average_xx_0_0_0, 0), (self.blocks_float_to_complex_1, 1)) self.connect((self.blocks_moving_average_xx_0_0_1, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_complex_to_arg_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.qtgui_number_sink_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.qtgui_time_sink_x_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.qtgui_time_sink_x_0_0_0_0, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.analog_fm_demod_cf_0, 0)) self.connect((self.blocks_multiply_xx_2, 0), (self.blocks_moving_average_xx_0_0, 0)) self.connect((self.blocks_multiply_xx_3, 0), (self.blocks_moving_average_xx_0_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.dc_blocker_xx_0, 0), (self.analog_agc2_xx_1, 0)) self.connect((self.dc_blocker_xx_0_0, 0), (self.analog_agc2_xx_2, 0)) self.connect((self.goertzel_fc_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.goertzel_fc_0_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.low_pass_filter_0_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.rational_resampler_xxx_0_0_0, 0), (self.analog_am_demod_cf_0, 0)) self.connect((self.rational_resampler_xxx_0_0_0, 0), (self.qtgui_freq_sink_x_1_0, 0)) self.connect((self.rational_resampler_xxx_0_0_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.sigmf_source_0, 0), (self.blocks_throttle_0, 0))
def __init__(self): gr.top_block.__init__(self, "AM Modulation") Qt.QWidget.__init__(self) self.setWindowTitle("AM Modulation") 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", "am_modulation") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 400000 ################################################## # Blocks ################################################## self.janela = Qt.QTabWidget() self.janela_widget_0 = Qt.QWidget() self.janela_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.janela_widget_0) self.janela_grid_layout_0 = Qt.QGridLayout() self.janela_layout_0.addLayout(self.janela_grid_layout_0) self.janela.addTab(self.janela_widget_0, "Sinal Original") self.janela_widget_1 = Qt.QWidget() self.janela_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.janela_widget_1) self.janela_grid_layout_1 = Qt.QGridLayout() self.janela_layout_1.addLayout(self.janela_grid_layout_1) self.janela.addTab(self.janela_widget_1, "Sinal Modulado ") self.janela_widget_2 = Qt.QWidget() self.janela_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.janela_widget_2) self.janela_grid_layout_2 = Qt.QGridLayout() self.janela_layout_2.addLayout(self.janela_grid_layout_2) self.janela.addTab(self.janela_widget_2, "Sinal modulado na frequência") self.top_layout.addWidget(self.janela) self.rational_resampler_xxx_1 = filter.rational_resampler_fff( interpolation=441, decimation=4000, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=4000, decimation=441, taps=None, fractional_bw=None, ) self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "Scope Plot", #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(-2, 2) self.qtgui_time_sink_x_1.set_y_label("Amplitude", "") self.qtgui_time_sink_x_1.enable_tags(-1, 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(False) self.qtgui_time_sink_x_1.enable_grid(False) self.qtgui_time_sink_x_1.enable_control_panel(False) if not True: self.qtgui_time_sink_x_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_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.janela_layout_1.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "Scope Plot", #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(-2, 2) 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(False) 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.janela_layout_0.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 Scope", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-160, 0) 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_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "float" == "float" or "float" == "msg_float": 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 xrange(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.janela_layout_2.addWidget(self._qtgui_freq_sink_x_0_win) self.blocks_wavfile_source_0 = blocks.wavfile_source( "/home/alunos/Downloads/handson2_file_minicurso_44_1KHz.wav", True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1, samp_rate, True) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.audio_sink_0 = audio.sink(44100, "", True) self.analog_sig_source_x_1 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, 80000, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, 0, 1, 0) self.analog_am_demod_cf_0 = analog.am_demod_cf( channel_rate=samp_rate, audio_decim=1, audio_pass=5000, audio_stop=5500, ) ################################################## # Connections ################################################## self.connect((self.analog_am_demod_cf_0, 0), (self.rational_resampler_xxx_1, 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.blocks_add_xx_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.analog_am_demod_cf_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_float_to_complex_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_1, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.audio_sink_0, 0))
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 = 25000 ################################################## # Blocks ################################################## self.qtgui_time_sink_x_2 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "receive", #name 1 #number of inputs ) self.qtgui_time_sink_x_2.set_update_time(0.10) self.qtgui_time_sink_x_2.set_y_axis(-1, 1) self.qtgui_time_sink_x_2.set_y_label("Amplitude", "") self.qtgui_time_sink_x_2.enable_tags(-1, True) self.qtgui_time_sink_x_2.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_2.enable_autoscale(True) self.qtgui_time_sink_x_2.enable_grid(False) self.qtgui_time_sink_x_2.enable_control_panel(False) if not True: self.qtgui_time_sink_x_2.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_2.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_2.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_2.set_line_label(i, labels[i]) self.qtgui_time_sink_x_2.set_line_width(i, widths[i]) self.qtgui_time_sink_x_2.set_line_color(i, colors[i]) self.qtgui_time_sink_x_2.set_line_style(i, styles[i]) self.qtgui_time_sink_x_2.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_2.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_2_win = sip.wrapinstance(self.qtgui_time_sink_x_2.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_2_win) self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "after_demod", #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(-1, 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_control_panel(False) if not True: self.qtgui_time_sink_x_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_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_layout.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_time_sink_x_0_0_0 = qtgui.time_sink_f( 1000, #size samp_rate, #samp_rate "txt", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_0_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_0_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_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_0_win) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 1000, #size samp_rate, #samp_rate "pass", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(True) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_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_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1000, #size samp_rate, #samp_rate "enlarge", #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.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.osmosdr_source_0.set_sample_rate(1e6) self.osmosdr_source_0.set_center_freq(1000e6, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(14, 0) self.osmosdr_source_0.set_if_gain(40, 0) self.osmosdr_source_0.set_bb_gain(10, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.low_pass_filter_0 = filter.fir_filter_fff(1, firdes.low_pass( 1, samp_rate, 1.5e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_int_to_float_0 = blocks.int_to_float(1, 1) self.blocks_float_to_int_0 = blocks.float_to_int(1, 11) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_int*1, "/home/andy/receive.txt", False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-0.043, )) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=320e3, audio_decimation=10, ) self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_CONST_WAVE, 1000, 12, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_wfm_rcv_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_float_to_int_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_float_to_int_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_float_to_int_0, 0), (self.blocks_int_to_float_0, 0)) self.connect((self.blocks_int_to_float_0, 0), (self.qtgui_time_sink_x_0_0_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.analog_wfm_rcv_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.qtgui_time_sink_x_2, 0))
def main(): N = 1000000 fs = 8000 freqs = [100, 200, 300, 400, 500] nchans = 7 sigs = list() fmtx = list() for fi in freqs: s = analog.sig_source_f(fs, analog.GR_SIN_WAVE, fi, 1) fm = analog.nbfm_tx(fs, 4 * fs, max_dev=10000, tau=75e-6, fh=0.925 * (4 * fs) / 2.0) sigs.append(s) fmtx.append(fm) syntaps = filter.firdes.low_pass_2(len(freqs), fs, fs / float(nchans) / 2, 100, 100) print("Synthesis Num. Taps = %d (taps per filter = %d)" % (len(syntaps), len(syntaps) / nchans)) chtaps = filter.firdes.low_pass_2(len(freqs), fs, fs / float(nchans) / 2, 100, 100) print("Channelizer Num. Taps = %d (taps per filter = %d)" % (len(chtaps), len(chtaps) / nchans)) filtbank = filter.pfb_synthesizer_ccf(nchans, syntaps) channelizer = filter.pfb.channelizer_ccf(nchans, chtaps) noise_level = 0.01 head = blocks.head(gr.sizeof_gr_complex, N) noise = analog.noise_source_c(analog.GR_GAUSSIAN, noise_level) addnoise = blocks.add_cc() snk_synth = blocks.vector_sink_c() tb = gr.top_block() tb.connect(noise, (addnoise, 0)) tb.connect(filtbank, head, (addnoise, 1)) tb.connect(addnoise, channelizer) tb.connect(addnoise, snk_synth) snk = list() for i, si in enumerate(sigs): tb.connect(si, fmtx[i], (filtbank, i)) for i in range(nchans): snk.append(blocks.vector_sink_c()) tb.connect((channelizer, i), snk[i]) tb.run() if 1: channel = 1 data = snk[channel].data()[1000:] f1 = pyplot.figure(1) s1 = f1.add_subplot(1, 1, 1) s1.plot(data[10000:10200]) s1.set_title(("Output Signal from Channel %d" % channel)) fftlen = 2048 winfunc = numpy.blackman #winfunc = numpy.hamming f2 = pyplot.figure(2) s2 = f2.add_subplot(1, 1, 1) s2.psd(data, NFFT=fftlen, Fs=nchans * fs, noverlap=fftlen / 4, window=lambda d: d * winfunc(fftlen)) s2.set_title(("Output PSD from Channel %d" % channel)) f3 = pyplot.figure(3) s3 = f3.add_subplot(1, 1, 1) s3.psd(snk_synth.data()[1000:], NFFT=fftlen, Fs=nchans * fs, noverlap=fftlen / 4, window=lambda d: d * winfunc(fftlen)) s3.set_title("Output of Synthesis Filter") pyplot.show()
def __init__(self): gr.top_block.__init__(self, "MODULADOR DQPSK") Qt.QWidget.__init__(self) self.setWindowTitle("MODULADOR DQPSK") 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", "top_block") 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_2920_rx = samp_rate_2920_rx = 100000000 self.coef_rx = coef_rx = 2**8 self.samp_rate = samp_rate = int(samp_rate_2920_rx / coef_rx) self.Sps = Sps = 128 self.M = M = 2 self.Rs = Rs = samp_rate / Sps self.BpS = BpS = int(math.log(M, 2)) self.Rb = Rb = Rs / BpS self.no_code = no_code = digital.utils.mod_codes.NO_CODE self.W = W = Rb / 2 self.Rolloff = Rolloff = 1.0 self.ntaps = ntaps = Sps * 16 self.h = h = wform.rect(Sps) self.constelacion = constelacion = digital.psk_constellation( M, no_code, False) self.Retardo_bits = Retardo_bits = 0 self.Retardo_Timing = Retardo_Timing = 0 self.BW_rect = BW_rect = samp_rate / 2 self.BW = BW = W * (1 + Rolloff) ################################################## # Blocks ################################################## self.menu = Qt.QTabWidget() self.menu_widget_0 = Qt.QWidget() self.menu_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.menu_widget_0) self.menu_grid_layout_0 = Qt.QGridLayout() self.menu_layout_0.addLayout(self.menu_grid_layout_0) self.menu.addTab(self.menu_widget_0, 'Timing') self.menu_widget_1 = Qt.QWidget() self.menu_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.menu_widget_1) self.menu_grid_layout_1 = Qt.QGridLayout() self.menu_layout_1.addLayout(self.menu_grid_layout_1) self.menu.addTab(self.menu_widget_1, 'T0 versus R0') self.menu_widget_2 = Qt.QWidget() self.menu_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.menu_widget_2) self.menu_grid_layout_2 = Qt.QGridLayout() self.menu_layout_2.addLayout(self.menu_grid_layout_2) self.menu.addTab(self.menu_widget_2, 'T1 versus R1') self.menu_widget_3 = Qt.QWidget() self.menu_layout_3 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.menu_widget_3) self.menu_grid_layout_3 = Qt.QGridLayout() self.menu_layout_3.addLayout(self.menu_grid_layout_3) self.menu.addTab(self.menu_widget_3, 'T2 versus R2') self.menu_widget_4 = Qt.QWidget() self.menu_layout_4 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.menu_widget_4) self.menu_grid_layout_4 = Qt.QGridLayout() self.menu_layout_4.addLayout(self.menu_grid_layout_4) self.menu.addTab(self.menu_widget_4, 'T3 versus R3') self.menu_widget_5 = Qt.QWidget() self.menu_layout_5 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.menu_widget_5) self.menu_grid_layout_5 = Qt.QGridLayout() self.menu_layout_5.addLayout(self.menu_grid_layout_5) self.menu.addTab(self.menu_widget_5, 'RF') self.top_grid_layout.addWidget(self.menu, 2, 0, 1, 2) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self._Retardo_bits_range = Range(0, Sps * 10, 1, 0, 200) self._Retardo_bits_win = RangeWidget( self._Retardo_bits_range, self.set_Retardo_bits, 'Delay transmited signal to match with the received signal', "counter_slider", int) self.menu_grid_layout_4.addWidget(self._Retardo_bits_win, 0, 0, 1, 1) for r in range(0, 1): self.menu_grid_layout_4.setRowStretch(r, 1) for c in range(0, 1): self.menu_grid_layout_4.setColumnStretch(c, 1) self._Retardo_Timing_range = Range(0, Sps - 1, 1, 0, 200) self._Retardo_Timing_win = RangeWidget(self._Retardo_Timing_range, self.set_Retardo_Timing, 'Timing', "counter", int) self.menu_grid_layout_0.addWidget(self._Retardo_Timing_win, 0, 0, 1, 1) for r in range(0, 1): self.menu_grid_layout_0.setRowStretch(r, 1) for c in range(0, 1): self.menu_grid_layout_0.setColumnStretch(c, 1) self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 3 #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(False) 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 = [ 'Senal RF', 'EC (Re)', 'EC(Im)', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10' ] widths = [3, 3, 3, 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(3): 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.menu_grid_layout_5.addWidget(self._qtgui_time_sink_x_1_win, 0, 0, 1, 1) for r in range(0, 1): self.menu_grid_layout_5.setRowStretch(r, 1) for c in range(0, 1): self.menu_grid_layout_5.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_1 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "", #name 2 #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(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(False) self.qtgui_time_sink_x_0_1.enable_grid(False) self.qtgui_time_sink_x_0_1.enable_axis_labels(True) self.qtgui_time_sink_x_0_1.enable_control_panel(False) self.qtgui_time_sink_x_0_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(4): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0_1.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0_1.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) 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.menu_grid_layout_1.addWidget(self._qtgui_time_sink_x_0_1_win, 2, 0, 1, 1) for r in range(2, 3): self.menu_grid_layout_1.setRowStretch(r, 1) for c in range(0, 1): self.menu_grid_layout_1.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 1024, #size Rs, #samp_rate "", #name 2 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-0.5, 1.5) self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0.enable_tags(True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0.enable_stem_plot(True) 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 = [0, 0, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(2): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.menu_grid_layout_4.addWidget(self._qtgui_time_sink_x_0_0_win, 1, 0, 1, 1) for r in range(1, 2): self.menu_grid_layout_4.setRowStretch(r, 1) for c in range(0, 1): self.menu_grid_layout_4.setColumnStretch(c, 1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size Rs, #samp_rate "", #name 2 #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(False) 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(True) 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 = [0, 0, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(2): 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.menu_grid_layout_3.addWidget(self._qtgui_time_sink_x_0_win, 1, 0, 1, 1) for r in range(1, 2): self.menu_grid_layout_3.setRowStretch(r, 1) for c in range(0, 1): self.menu_grid_layout_3.setColumnStretch(c, 1) self.qtgui_const_sink_x_0_0_0_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0_0_0.set_trigger_mode( qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0_0_0.enable_grid(False) self.qtgui_const_sink_x_0_0_0_0.enable_axis_labels(True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [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_const_sink_x_0_0_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_0_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget) self.menu_grid_layout_0.addWidget(self._qtgui_const_sink_x_0_0_0_0_win, 2, 1, 1, 1) for r in range(2, 3): self.menu_grid_layout_0.setRowStretch(r, 1) for c in range(1, 2): self.menu_grid_layout_0.setColumnStretch(c, 1) self.qtgui_const_sink_x_0_0_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0_0.enable_grid(False) self.qtgui_const_sink_x_0_0_0.enable_axis_labels(True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [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_const_sink_x_0_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.menu_grid_layout_0.addWidget(self._qtgui_const_sink_x_0_0_0_win, 2, 0, 1, 1) for r in range(2, 3): self.menu_grid_layout_0.setRowStretch(r, 1) for c in range(0, 1): self.menu_grid_layout_0.setColumnStretch(c, 1) self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( 1024, #size "", #name 2 #number of inputs ) self.qtgui_const_sink_x_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0.enable_grid(False) self.qtgui_const_sink_x_0_0.enable_axis_labels(True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [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(2): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget) self.menu_grid_layout_2.addWidget(self._qtgui_const_sink_x_0_0_win, 1, 0, 1, 1) for r in range(1, 2): self.menu_grid_layout_2.setRowStretch(r, 1) for c in range(0, 1): self.menu_grid_layout_2.setColumnStretch(c, 1) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 2 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [1, 1, 0, 0, 0, 0, 0, 0, 0, 0] markers = [-1, -1, 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(2): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.menu_grid_layout_1.addWidget(self._qtgui_const_sink_x_0_win, 1, 0, 1, 1) for r in range(1, 2): self.menu_grid_layout_1.setRowStretch(r, 1) for c in range(0, 1): self.menu_grid_layout_1.setColumnStretch(c, 1) self.interp_fir_filter_xxx_0_0 = filter.interp_fir_filter_ccc(1, h) self.interp_fir_filter_xxx_0_0.declare_sample_delay(0) self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_ccc(Sps, h) self.interp_fir_filter_xxx_0.declare_sample_delay(0) self.epy_block_0 = epy_block_0.blk(Sps=Sps) self.e_VCO_fase_fc_0 = e_VCO_fase_fc_0.blk() self.digital_constellation_receiver_cb_0 = digital.constellation_receiver_cb( constelacion.base(), 2 * math.pi / 1000.0, -0.250, 0.250) self.blocks_unpacked_to_packed_xx_0_1 = blocks.unpacked_to_packed_bb( BpS, gr.GR_MSB_FIRST) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(8) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_packed_to_unpacked_xx_0_0 = blocks.packed_to_unpacked_bb( BpS, gr.GR_MSB_FIRST) self.blocks_pack_k_bits_bb_0_0_0 = blocks.pack_k_bits_bb(8) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_char * 1) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_ff( (2 * math.pi) / M) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_cc(1 / Sps) self.blocks_delay_1 = blocks.delay(gr.sizeof_float * 1, Retardo_bits) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, Retardo_Timing) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_char_to_float_0_2 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0_1 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0_0_0 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.b_upconverter_cf_0 = b_upconverter_cf( Fc=Rs * 2, samp_rate=44000, ) self.b_PSD_c_0 = b_PSD_c( Ensayos=1000000, Fc=0, N=1024, Ymax=6e-6, samp_rate_audio=samp_rate, ) self.menu_grid_layout_1.addWidget(self.b_PSD_c_0, 3, 0, 1, 1) for r in range(3, 4): self.menu_grid_layout_1.setRowStretch(r, 1) for c in range(0, 1): self.menu_grid_layout_1.setColumnStretch(c, 1) self.b_Eye_Diagram_simple_c_0 = b_Eye_Diagram_simple_c( AlphaLineas=0.5, Delay_i=0, GrosorLineas=20, Kint=1, N_eyes=2, Samprate1=samp_rate, Sps1=Sps, Title="Eye Diagramm", Ymax=2, Ymin=-2, ) self.menu_grid_layout_0.addWidget(self.b_Eye_Diagram_simple_c_0, 1, 0, 1, 2) for r in range(1, 2): self.menu_grid_layout_0.setRowStretch(r, 1) for c in range(0, 2): self.menu_grid_layout_0.setColumnStretch(c, 1) self.analog_random_source_x_0 = blocks.vector_source_b( list(map(int, numpy.random.randint(0, 2, 10000000))), True) self.analog_noise_source_x_0 = analog.noise_source_c( analog.GR_GAUSSIAN, 0.1, 0) self.analog_const_source_x_0_0_0 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, 1) ################################################## # Connections ################################################## self.connect((self.analog_const_source_x_0_0_0, 0), (self.e_VCO_fase_fc_0, 1)) self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.blocks_char_to_float_0_1, 0)) self.connect((self.analog_random_source_x_0, 0), (self.blocks_pack_k_bits_bb_0_0_0, 0)) self.connect((self.b_upconverter_cf_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.blocks_add_xx_0, 0), (self.interp_fir_filter_xxx_0_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_char_to_float_0_0, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.blocks_char_to_float_0_0_0, 0), (self.qtgui_time_sink_x_0_0, 1)) self.connect((self.blocks_char_to_float_0_1, 0), (self.blocks_delay_1, 0)) self.connect((self.blocks_char_to_float_0_2, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.qtgui_time_sink_x_1, 2)) self.connect((self.blocks_complex_to_float_0, 0), (self.qtgui_time_sink_x_1, 1)) self.connect((self.blocks_delay_0, 0), (self.b_Eye_Diagram_simple_c_0, 0)) self.connect((self.blocks_delay_0, 0), (self.epy_block_0, 0)) self.connect((self.blocks_delay_0, 0), (self.qtgui_const_sink_x_0_0_0, 0)) self.connect((self.blocks_delay_1, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.b_PSD_c_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_time_sink_x_0_1, 1)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.e_VCO_fase_fc_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0_0_0, 0), (self.blocks_packed_to_unpacked_xx_0_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0_0, 0), (self.blocks_char_to_float_0_2, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_char_to_float_0_0_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.blocks_unpacked_to_packed_xx_0_1, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.digital_constellation_receiver_cb_0, 0), (self.blocks_char_to_float_0_0, 0)) self.connect((self.digital_constellation_receiver_cb_0, 0), (self.blocks_unpacked_to_packed_xx_0_1, 0)) self.connect((self.e_VCO_fase_fc_0, 0), (self.interp_fir_filter_xxx_0, 0)) self.connect((self.e_VCO_fase_fc_0, 0), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.epy_block_0, 0), (self.digital_constellation_receiver_cb_0, 0)) self.connect((self.epy_block_0, 0), (self.qtgui_const_sink_x_0_0, 1)) self.connect((self.epy_block_0, 0), (self.qtgui_const_sink_x_0_0_0_0, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.b_upconverter_cf_0, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.qtgui_const_sink_x_0, 1)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.qtgui_time_sink_x_0_1, 0)) self.connect((self.interp_fir_filter_xxx_0_0, 0), (self.blocks_multiply_const_vxx_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="SSB RX") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 256000 ################################################## # Blocks ################################################## self.wxgui_fftsink2_0_1 = 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 / 8, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title='FFT Plot', peak_hold=False, ) self.Add(self.wxgui_fftsink2_0_1.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 / 8, 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 / 8, 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.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( 8, (firdes.low_pass(1, samp_rate / 8, 2000, 100)), 51500, samp_rate) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_multiply_xx_0_0 = blocks.multiply_vff(1) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_gr_complex * 1, '/Users/ampoulog/Documents/gnuradio/Wireless-communication-systems-Lab/Lab2/example7/ssb_lsb_256k_complex2.dat', True) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.audio_sink_0 = audio.sink(samp_rate, '', True) self.analog_sig_source_x_0_0 = analog.sig_source_f( samp_rate, analog.GR_SIN_WAVE, 1500, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, 1500, 1, 0) ################################################## # Connections ################################################## 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.blocks_multiply_xx_0_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.wxgui_fftsink2_0_1, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.wxgui_fftsink2_0_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_throttle_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_complex_to_float_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") 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", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 25e3 ################################################## # Blocks ################################################## self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=8, decimation=1, taps=None, fractional_bw=None, ) self.qtgui_time_sink_x_3 = qtgui.time_sink_f( 500, #size samp_rate, #samp_rate 'before_mod', #name 1 #number of inputs ) self.qtgui_time_sink_x_3.set_update_time(0.10) self.qtgui_time_sink_x_3.set_y_axis(-1, 1) self.qtgui_time_sink_x_3.set_y_label('Amplitude', "") self.qtgui_time_sink_x_3.enable_tags(-1, True) self.qtgui_time_sink_x_3.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_3.enable_autoscale(False) self.qtgui_time_sink_x_3.enable_grid(False) self.qtgui_time_sink_x_3.enable_axis_labels(True) self.qtgui_time_sink_x_3.enable_control_panel(False) if not True: self.qtgui_time_sink_x_3.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_3.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_3.set_line_label(i, labels[i]) self.qtgui_time_sink_x_3.set_line_width(i, widths[i]) self.qtgui_time_sink_x_3.set_line_color(i, colors[i]) self.qtgui_time_sink_x_3.set_line_style(i, styles[i]) self.qtgui_time_sink_x_3.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_3.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_3_win = sip.wrapinstance(self.qtgui_time_sink_x_3.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_3_win) self.qtgui_time_sink_x_1 = qtgui.time_sink_c( 500, #size samp_rate, #samp_rate 'after_resampler', #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(-1, 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(False) 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) if not True: self.qtgui_time_sink_x_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(2): if len(labels[i]) == 0: if(i % 2 == 0): self.qtgui_time_sink_x_1.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_1.set_line_label(i, "Im{{Data {0}}}".format(i/2)) 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_layout.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 500, #size samp_rate, #samp_rate 'after_mod', #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_axis_labels(True) 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(2): if len(labels[i]) == 0: if(i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) 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.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + '' ) self.osmosdr_sink_0.set_sample_rate(1e6) self.osmosdr_sink_0.set_center_freq(1000e6, 0) self.osmosdr_sink_0.set_freq_corr(6, 0) self.osmosdr_sink_0.set_gain(0, 0) self.osmosdr_sink_0.set_if_gain(40, 0) self.osmosdr_sink_0.set_bb_gain(30, 0) self.osmosdr_sink_0.set_antenna('', 0) self.osmosdr_sink_0.set_bandwidth(250e3, 0) self.fractional_interpolator_xx_0 = filter.fractional_interpolator_ff(1, 0.875) self.before_interpolator = qtgui.time_sink_f( 500, #size samp_rate, #samp_rate 'before_interpolator', #name 1 #number of inputs ) self.before_interpolator.set_update_time(0.10) self.before_interpolator.set_y_axis(-1, 1) self.before_interpolator.set_y_label('Amplitude', "") self.before_interpolator.enable_tags(-1, True) self.before_interpolator.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.before_interpolator.enable_autoscale(False) self.before_interpolator.enable_grid(False) self.before_interpolator.enable_axis_labels(True) self.before_interpolator.enable_control_panel(False) if not True: self.before_interpolator.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.before_interpolator.set_line_label(i, "Data {0}".format(i)) else: self.before_interpolator.set_line_label(i, labels[i]) self.before_interpolator.set_line_width(i, widths[i]) self.before_interpolator.set_line_color(i, colors[i]) self.before_interpolator.set_line_style(i, styles[i]) self.before_interpolator.set_line_marker(i, markers[i]) self.before_interpolator.set_line_alpha(i, alphas[i]) self._before_interpolator_win = sip.wrapinstance(self.before_interpolator.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._before_interpolator_win) self.analog_wfm_tx_0 = analog.wfm_tx( audio_rate=int(32e3), quad_rate=int(320e3), tau=3e-6, max_dev=50e3, fh=0, ) self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_SQR_WAVE, 1000, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.analog_wfm_tx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.before_interpolator, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.fractional_interpolator_xx_0, 0)) self.connect((self.analog_wfm_tx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.analog_wfm_tx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.fractional_interpolator_xx_0, 0), (self.qtgui_time_sink_x_3, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.osmosdr_sink_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_time_sink_x_1, 0))
def set_waveform(self, type): self.lock() self.disconnect_all() if type == analog.GR_SIN_WAVE or type == analog.GR_CONST_WAVE: self._src = analog.sig_source_c( self[SAMP_RATE_KEY], # Sample rate type, # Waveform type self[WAVEFORM_FREQ_KEY], # Waveform frequency self[AMPLITUDE_KEY], # Waveform amplitude self[WAVEFORM_OFFSET_KEY]) # Waveform offset elif type == analog.GR_GAUSSIAN or type == analog.GR_UNIFORM: self._src = analog.noise_source_c(type, self[AMPLITUDE_KEY]) elif type == "2tone": self._src1 = analog.sig_source_c(self[SAMP_RATE_KEY], analog.GR_SIN_WAVE, self[WAVEFORM_FREQ_KEY], self[AMPLITUDE_KEY] / 2.0, 0) if (self[WAVEFORM2_FREQ_KEY] is None): self[WAVEFORM2_FREQ_KEY] = -self[WAVEFORM_FREQ_KEY] self._src2 = analog.sig_source_c(self[SAMP_RATE_KEY], analog.GR_SIN_WAVE, self[WAVEFORM2_FREQ_KEY], self[AMPLITUDE_KEY] / 2.0, 0) self._src = blocks.add_cc() self.connect(self._src1, (self._src, 0)) self.connect(self._src2, (self._src, 1)) elif type == "sweep": # rf freq is center frequency # waveform_freq is total swept width # waveform2_freq is sweep rate # will sweep from (rf_freq-waveform_freq/2) to (rf_freq+waveform_freq/2) if self[WAVEFORM2_FREQ_KEY] is None: self[WAVEFORM2_FREQ_KEY] = 0.1 self._src1 = analog.sig_source_f(self[SAMP_RATE_KEY], analog.GR_TRI_WAVE, self[WAVEFORM2_FREQ_KEY], 1.0, -0.5) self._src2 = analog.frequency_modulator_fc( self[WAVEFORM_FREQ_KEY] * 2 * math.pi / self[SAMP_RATE_KEY]) self._src = blocks.multiply_const_cc(self[AMPLITUDE_KEY]) self.connect(self._src1, self._src2, self._src) elif type == "gsm": self._src = gsm_source_c(self[SAMP_RATE_KEY], self[AMPLITUDE_KEY]) else: raise RuntimeError("Unknown waveform type") self.connect(self._src, self._sink) self.unlock() if self._verbose: print "Set baseband modulation to:", waveforms[type] if type == analog.GR_SIN_WAVE: print "Modulation frequency: %sHz" % (n2s( self[WAVEFORM_FREQ_KEY]), ) print "Initial phase:", self[WAVEFORM_OFFSET_KEY] elif type == "2tone": print "Tone 1: %sHz" % (n2s(self[WAVEFORM_FREQ_KEY]), ) print "Tone 2: %sHz" % (n2s(self[WAVEFORM2_FREQ_KEY]), ) elif type == "sweep": print "Sweeping across %sHz to %sHz" % (n2s( -self[WAVEFORM_FREQ_KEY] / 2.0), n2s(self[WAVEFORM_FREQ_KEY] / 2.0)) print "Sweep rate: %sHz" % (n2s(self[WAVEFORM2_FREQ_KEY]), ) elif type == "gsm": print "GSM Burst Sequence" print "TX amplitude:", self[AMPLITUDE_KEY]
def __init__(self): gr.top_block.__init__(self, "Adsb Test") Qt.QWidget.__init__(self) self.setWindowTitle("Adsb Test") 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", "adsb_test") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.tresh = tresh = -20 self.samp_rate = samp_rate = 2e6 ################################################## # Blocks ################################################## self._tresh_range = Range(-40, -1, 1, -20, 200) self._tresh_win = RangeWidget(self._tresh_range, self.set_tresh, "tresh", "counter_slider", float) self.top_layout.addWidget(self._tresh_win) self.zeromq_pub_msg_sink_0 = zeromq.pub_msg_sink( 'tcp://127.0.0.1:5001', 10) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 3 #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(False) 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) 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(3): 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.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + '') self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(1089.85e6, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(48, 0) self.osmosdr_source_0.set_if_gain(20, 0) self.osmosdr_source_0.set_bb_gain(20, 0) self.osmosdr_source_0.set_antenna('', 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.analog_const_source_x_0 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, pow(10, tresh / 10)) self.adsb_framer_0 = adsb.framer(samp_rate, pow(10, tresh / 10)) self.adsb_demod_0 = adsb.demod(samp_rate) self.adsb_decoder_0 = adsb.decoder("All Messages", "Conservative", "Verbose") ################################################## # Connections ################################################## self.msg_connect((self.adsb_decoder_0, 'decoded'), (self.zeromq_pub_msg_sink_0, 'in')) self.msg_connect((self.adsb_demod_0, 'demodulated'), (self.adsb_decoder_0, 'demodulated')) self.connect((self.adsb_demod_0, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.adsb_framer_0, 0), (self.adsb_demod_0, 0)) self.connect((self.analog_const_source_x_0, 0), (self.qtgui_time_sink_x_0, 2)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.adsb_framer_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_complex_to_mag_squared_0, 0))
def __init__(self): gr.top_block.__init__(self, "Loopback QAM Modulation - Sound Signals") Qt.QWidget.__init__(self) self.setWindowTitle("Loopback QAM Modulation - Sound Signals") 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", "loopback_qam_sound_signals") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 400000 ################################################## # Blocks ################################################## self.janela = Qt.QTabWidget() self.janela_widget_0 = Qt.QWidget() self.janela_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.janela_widget_0) self.janela_grid_layout_0 = Qt.QGridLayout() self.janela_layout_0.addLayout(self.janela_grid_layout_0) self.janela.addTab(self.janela_widget_0, "Frequency") self.janela_widget_1 = Qt.QWidget() self.janela_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.janela_widget_1) self.janela_grid_layout_1 = Qt.QGridLayout() self.janela_layout_1.addLayout(self.janela_grid_layout_1) self.janela.addTab(self.janela_widget_1, "Time ") self.janela_widget_2 = Qt.QWidget() self.janela_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.janela_widget_2) self.janela_grid_layout_2 = Qt.QGridLayout() self.janela_layout_2.addLayout(self.janela_grid_layout_2) self.janela.addTab(self.janela_widget_2, "QAM Signal (Frequency)") self.top_layout.addWidget(self.janela) self.rational_resampler_xxx_1_0 = filter.rational_resampler_fff( interpolation=441, decimation=4000, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_1 = filter.rational_resampler_fff( interpolation=441, decimation=4000, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0_0 = filter.rational_resampler_fff( interpolation=4000, decimation=441, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=4000, decimation=441, taps=None, fractional_bw=None, ) self.qtgui_time_sink_x_0_0_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "Original Signal - Time", #name 4 #number of inputs ) self.qtgui_time_sink_x_0_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0_0.set_y_axis(-2, 2) self.qtgui_time_sink_x_0_0_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0_0.enable_autoscale(True) self.qtgui_time_sink_x_0_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_0_0.disable_legend() labels = ["Original Signal 1", "Original Siginal 2", "Demodulated Signal 1", "Demodulated Signal 2", "", "", "", "", "", ""] 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, 2, 2, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 0.8, 0.8, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(4): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.janela_layout_1.addWidget(self._qtgui_time_sink_x_0_0_0_win) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_f( 1024, #size firdes.WIN_HAMMING, #wintype 0, #fc samp_rate, #bw "Original Signal - Frequency", #name 4 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 0) self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_0.set_fft_average(0.1) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0_0.disable_legend() if "float" == "float" or "float" == "msg_float": self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True) labels = ["Original Signal 1", "Original Signal 2", "Demodulated Signal 1", "Demodulated Signal 2", "", "", "", "", "", ""] 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, 0.8, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(4): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.janela_layout_0.addWidget(self._qtgui_freq_sink_x_0_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "Signal Modulated", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-160, 0) 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_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "float" == "float" or "float" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ["QAM Signal", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["magenta", "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 xrange(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.janela_layout_2.addWidget(self._qtgui_freq_sink_x_0_win) self.low_pass_filter_0_0 = filter.fir_filter_fff(1, firdes.low_pass( 1, samp_rate, 45.1e3, 100, firdes.WIN_HANN, 6.76)) self.low_pass_filter_0 = filter.fir_filter_fff(1, firdes.low_pass( 1, samp_rate, 45.1e3, 100, firdes.WIN_HANN, 6.76)) self.blocks_wavfile_source_0_0 = blocks.wavfile_source("/home/alunos/Área de Trabalho/principles-of-telecommunications/static/Electronic-Tom-4.wav", True) self.blocks_wavfile_source_0 = blocks.wavfile_source("/home/alunos/Área de Trabalho/principles-of-telecommunications/static/Electro-Tom.wav", True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate,True) self.blocks_multiply_xx_0_0_0_0 = blocks.multiply_vff(1) self.blocks_multiply_xx_0_0_0 = blocks.multiply_vff(1) self.blocks_multiply_xx_0_0 = blocks.multiply_vff(1) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_add_xx_0_1 = blocks.add_vff(1) self.audio_sink_0 = audio.sink(44100, "", True) self.analog_sig_source_x_1_1 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 80000, 1, 0) self.analog_sig_source_x_1_0_0 = analog.sig_source_f(samp_rate, analog.GR_SIN_WAVE, 80000, 1, 0) self.analog_sig_source_x_1_0 = analog.sig_source_f(samp_rate, analog.GR_SIN_WAVE, 80000, 2, 0) self.analog_sig_source_x_1 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 80000, 2, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_sig_source_x_1_0, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.analog_sig_source_x_1_0_0, 0), (self.blocks_multiply_xx_0_0_0_0, 0)) self.connect((self.analog_sig_source_x_1_1, 0), (self.blocks_multiply_xx_0_0_0, 0)) self.connect((self.blocks_add_xx_0_1, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0_1, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.blocks_add_xx_0_1, 1)) self.connect((self.blocks_multiply_xx_0_0_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_multiply_xx_0_0_0_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_xx_0_0_0, 1)) self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_xx_0_0_0_0, 1)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.qtgui_freq_sink_x_0_0, 3)) self.connect((self.blocks_wavfile_source_0, 0), (self.qtgui_time_sink_x_0_0_0, 3)) self.connect((self.blocks_wavfile_source_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_wavfile_source_0_0, 0), (self.qtgui_freq_sink_x_0_0, 2)) self.connect((self.blocks_wavfile_source_0_0, 0), (self.qtgui_time_sink_x_0_0_0, 2)) self.connect((self.blocks_wavfile_source_0_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.rational_resampler_xxx_1_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.audio_sink_0, 1)) self.connect((self.rational_resampler_xxx_1, 0), (self.qtgui_freq_sink_x_0_0, 1)) self.connect((self.rational_resampler_xxx_1, 0), (self.qtgui_time_sink_x_0_0_0, 1)) self.connect((self.rational_resampler_xxx_1_0, 0), (self.audio_sink_0, 0)) self.connect((self.rational_resampler_xxx_1_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.rational_resampler_xxx_1_0, 0), (self.qtgui_time_sink_x_0_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "If Psk Tx") Qt.QWidget.__init__(self) self.setWindowTitle("If Psk Tx") 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", "if_psk_tx") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sound_card_sample_rate = sound_card_sample_rate = 11025 self.samples_per_symbol = samples_per_symbol = 16 self.symbol_rate = symbol_rate = sound_card_sample_rate/samples_per_symbol self.bits_per_symbol = bits_per_symbol = 2 self.hdlc_packet_overhead = hdlc_packet_overhead = 6*8 self.hdlc_packet_length = hdlc_packet_length = 16*8 self.channel_bit_rate = channel_bit_rate = symbol_rate*bits_per_symbol self.source_bit_rate = source_bit_rate = channel_bit_rate*hdlc_packet_length/(hdlc_packet_overhead+hdlc_packet_length) self.rolloff = rolloff = 0.5 self.quantization_depth = quantization_depth = 16 self.if_frequency = if_frequency = sound_card_sample_rate/4 ################################################## # Blocks ################################################## self.final_0 = qtgui.sink_f( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc sound_card_sample_rate, #bw "IF modulated signal", #name True, #plotfreq True, #plotwaterfall True, #plottime False, #plotconst ) self.final_0.set_update_time(1.0/10) self._final_0_win = sip.wrapinstance(self.final_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._final_0_win) self.final_0.enable_rf_freq(False) self.final = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc sound_card_sample_rate, #bw "Baseband signal", #name True, #plotfreq True, #plotwaterfall True, #plottime True, #plotconst ) self.final.set_update_time(1.0/10) self._final_win = sip.wrapinstance(self.final.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._final_win) self.final.enable_rf_freq(False) self.digital_psk_mod_0 = digital.psk.psk_mod( constellation_points=pow(2,bits_per_symbol), mod_code="gray", differential=True, samples_per_symbol=samples_per_symbol, excess_bw=rolloff, verbose=False, log=False, ) self.digital_hdlc_framer_pb_0 = digital.hdlc_framer_pb("packet_len") self.blocks_wavfile_sink_0 = blocks.wavfile_sink("tx_signal.wav", 1, sound_card_sample_rate, quantization_depth) self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST) self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_char*1, source_bit_rate/8,True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, sound_card_sample_rate,True) self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(blocks.byte_t, "packet_len") self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, hdlc_packet_length/8, "packet_len") self.blocks_multiply_xx_0_0_1 = blocks.multiply_vff(1) self.blocks_multiply_xx_0_0_0 = blocks.multiply_vff(1) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "test_tx_file_ordered.csv", False) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.analog_sig_source_x_0_0 = analog.sig_source_f(sound_card_sample_rate, analog.GR_COS_WAVE, if_frequency, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_f(sound_card_sample_rate, analog.GR_SIN_WAVE, if_frequency, 1, 0) ################################################## # Connections ################################################## self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.digital_hdlc_framer_pb_0, 'in')) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0_0_1, 1)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_0_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.final_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_multiply_xx_0_0_0, 1)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_multiply_xx_0_0_1, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0_0, 0)) self.connect((self.blocks_multiply_xx_0_0_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_xx_0_0_1, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.digital_psk_mod_0, 0)) self.connect((self.digital_hdlc_framer_pb_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0)) self.connect((self.digital_psk_mod_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.digital_psk_mod_0, 0), (self.final, 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 = 500000 ################################################## # Blocks ################################################## self.wxgui_scopesink2_1 = 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_1.win) 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_constellationsink2_0 = constsink_gl.const_sink_c( self.GetWin(), title='Constellation Plot', sample_rate=samp_rate, frame_rate=5, const_size=2048, M=4, theta=0, loop_bw=6.28 / 100.0, fmax=0.06, mu=0.5, gain_mu=0.005, symbol_rate=samp_rate / 4., omega_limit=0.005, ) self.Add(self.wxgui_constellationsink2_0.win) self.digital_qam_mod_0 = digital.qam.qam_mod( constellation_points=16, mod_code="gray", differential=True, samples_per_symbol=4, excess_bw=0.90, verbose=False, log=False, ) self.digital_qam_demod_0 = digital.qam.qam_demod( constellation_points=16, differential=True, samples_per_symbol=4, excess_bw=0.90, freq_bw=6.28 / 100.0, timing_bw=6.28 / 100.0, phase_bw=6.28 / 100.0, mod_code="gray", verbose=False, log=False, ) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1, samp_rate, True) self.blocks_short_to_float_0 = blocks.short_to_float(1, 1) self.blocks_multiply_xx_0_2 = blocks.multiply_vff(1) self.blocks_multiply_xx_0_1 = blocks.multiply_vff(1) self.blocks_multiply_xx_0_0 = blocks.multiply_vff(1) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_float_to_char_0 = blocks.float_to_char(1, 1) self.blocks_complex_to_imag_0_0 = blocks.complex_to_imag(1) self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1) self.blocks_char_to_float_1 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.blocks_add_xx_0 = blocks.add_vff(1) self.analog_sig_source_x_0_0 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, 25000, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_f( samp_rate, analog.GR_SIN_WAVE, 25000, 1, 0) self.analog_random_source_x_0 = blocks.vector_source_s( map(int, numpy.random.randint(0, 2, 2000000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.blocks_short_to_float_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), (self.blocks_multiply_xx_0_1, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_2, 1)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_xx_0_1, 1)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_xx_0_2, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.blocks_char_to_float_1, 0), (self.wxgui_scopesink2_1, 0)) self.connect((self.blocks_complex_to_imag_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_complex_to_imag_0_0, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.blocks_float_to_char_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.blocks_float_to_char_0, 0), (self.digital_qam_mod_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.digital_qam_demod_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_multiply_xx_0_1, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_multiply_xx_0_2, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_short_to_float_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_float_to_char_0, 0)) self.connect((self.digital_qam_demod_0, 0), (self.blocks_char_to_float_1, 0)) self.connect((self.digital_qam_mod_0, 0), (self.blocks_complex_to_imag_0, 0)) self.connect((self.digital_qam_mod_0, 0), (self.blocks_complex_to_imag_0_0, 0)) self.connect((self.digital_qam_mod_0, 0), (self.wxgui_constellationsink2_0, 0))
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 = 25000 ################################################## # Blocks ################################################## self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=8, decimation=1, taps=None, fractional_bw=None, ) self.qtgui_time_sink_x_3_0 = qtgui.time_sink_f( 500, #size samp_rate, #samp_rate "after_interpolator", #name 1 #number of inputs ) self.qtgui_time_sink_x_3_0.set_update_time(0.10) self.qtgui_time_sink_x_3_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_3_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_3_0.enable_tags(-1, True) self.qtgui_time_sink_x_3_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_3_0.enable_autoscale(False) self.qtgui_time_sink_x_3_0.enable_grid(False) self.qtgui_time_sink_x_3_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_3_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_3_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_3_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_3_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_3_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_3_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_3_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_3_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_3_0_win = sip.wrapinstance( self.qtgui_time_sink_x_3_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_3_0_win) self.qtgui_time_sink_x_2 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "receive", #name 1 #number of inputs ) self.qtgui_time_sink_x_2.set_update_time(0.10) self.qtgui_time_sink_x_2.set_y_axis(-1, 1) self.qtgui_time_sink_x_2.set_y_label("Amplitude", "") self.qtgui_time_sink_x_2.enable_tags(-1, True) self.qtgui_time_sink_x_2.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_2.enable_autoscale(True) self.qtgui_time_sink_x_2.enable_grid(False) self.qtgui_time_sink_x_2.enable_control_panel(False) if not True: self.qtgui_time_sink_x_2.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_2.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_2.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_2.set_line_label(i, labels[i]) self.qtgui_time_sink_x_2.set_line_width(i, widths[i]) self.qtgui_time_sink_x_2.set_line_color(i, colors[i]) self.qtgui_time_sink_x_2.set_line_style(i, styles[i]) self.qtgui_time_sink_x_2.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_2.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_2_win = sip.wrapinstance( self.qtgui_time_sink_x_2.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_2_win) self.qtgui_time_sink_x_1_0 = qtgui.time_sink_c( 1000, #size samp_rate, #samp_rate "after_resampler", #name 1 #number of inputs ) self.qtgui_time_sink_x_1_0.set_update_time(0.10) self.qtgui_time_sink_x_1_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_1_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_1_0.enable_tags(-1, True) self.qtgui_time_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1_0.enable_autoscale(False) self.qtgui_time_sink_x_1_0.enable_grid(False) self.qtgui_time_sink_x_1_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_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_1_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_0_win = sip.wrapinstance( self.qtgui_time_sink_x_1_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_1_0_win) self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "after_demod", #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(-1, 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_control_panel(False) if not True: self.qtgui_time_sink_x_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_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_layout.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_time_sink_x_0_0_0 = qtgui.time_sink_f( 1000, #size samp_rate, #samp_rate "txt", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_0_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0_0.enable_autoscale(True) self.qtgui_time_sink_x_0_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_0_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_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_0_win) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_c( 500, #size samp_rate, #samp_rate "after_FM", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(True) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_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_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1000, #size samp_rate, #samp_rate "enlarge", #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.fractional_interpolator_xx_0 = filter.fractional_interpolator_ff( 1, 0.875) self.file_input = qtgui.time_sink_f( 500, #size samp_rate, #samp_rate "file_input", #name 1 #number of inputs ) self.file_input.set_update_time(0.10) self.file_input.set_y_axis(-1, 1) self.file_input.set_y_label("Amplitude", "") self.file_input.enable_tags(-1, True) self.file_input.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.file_input.enable_autoscale(False) self.file_input.enable_grid(False) self.file_input.enable_control_panel(False) if not True: self.file_input.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.file_input.set_line_label(i, "Data {0}".format(i)) else: self.file_input.set_line_label(i, labels[i]) self.file_input.set_line_width(i, widths[i]) self.file_input.set_line_color(i, colors[i]) self.file_input.set_line_style(i, styles[i]) self.file_input.set_line_marker(i, markers[i]) self.file_input.set_line_alpha(i, alphas[i]) self._file_input_win = sip.wrapinstance(self.file_input.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._file_input_win) self.blocks_vector_source_x_0 = blocks.vector_source_f((0, 0, 0), True, 1, []) self.blocks_stream_mux_0 = blocks.stream_mux(gr.sizeof_float * 1, (1, 1)) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float * 1, 10) self.blocks_multiply_xx_0_1 = blocks.multiply_vff(1) self.blocks_multiply_xx_0_0 = blocks.multiply_vff(1) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_int_to_float_0 = blocks.int_to_float(1, 1) self.blocks_float_to_int_0 = blocks.float_to_int(1, 10) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char * 1, "/home/andy/code.txt", True) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_int * 1, "/home/andy/receive.txt", False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-0.5, )) self.bipolar_wave = qtgui.time_sink_f( 500, #size samp_rate, #samp_rate "bipolar_wave", #name 1 #number of inputs ) self.bipolar_wave.set_update_time(0.10) self.bipolar_wave.set_y_axis(-1, 1) self.bipolar_wave.set_y_label("Amplitude", "") self.bipolar_wave.enable_tags(-1, True) self.bipolar_wave.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.bipolar_wave.enable_autoscale(False) self.bipolar_wave.enable_grid(False) self.bipolar_wave.enable_control_panel(False) if not True: self.bipolar_wave.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.bipolar_wave.set_line_label(i, "Data {0}".format(i)) else: self.bipolar_wave.set_line_label(i, labels[i]) self.bipolar_wave.set_line_width(i, widths[i]) self.bipolar_wave.set_line_color(i, colors[i]) self.bipolar_wave.set_line_style(i, styles[i]) self.bipolar_wave.set_line_marker(i, markers[i]) self.bipolar_wave.set_line_alpha(i, alphas[i]) self._bipolar_wave_win = sip.wrapinstance( self.bipolar_wave.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._bipolar_wave_win) self.analog_wfm_tx_0 = analog.wfm_tx( audio_rate=int(25e3), quad_rate=int(500e3), tau=3e-6, max_dev=50e3, ) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=320e3, audio_decimation=10, ) self.analog_sig_source_x_0_1 = analog.sig_source_f( samp_rate, analog.GR_CONST_WAVE, 1000, 12, 0) self.analog_sig_source_x_0_0 = analog.sig_source_f( samp_rate, analog.GR_CONST_WAVE, 1000, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_f( samp_rate, analog.GR_CONST_WAVE, 1000, 1, 0) ################################################## # Connections ################################################## 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_0_1, 0), (self.blocks_multiply_xx_0_1, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.blocks_multiply_xx_0_1, 1)) self.connect((self.analog_wfm_rcv_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.analog_wfm_tx_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.analog_wfm_tx_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.file_input, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.blocks_float_to_int_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_float_to_int_0, 0), (self.blocks_int_to_float_0, 0)) self.connect((self.blocks_int_to_float_0, 0), (self.qtgui_time_sink_x_0_0_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_stream_mux_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.bipolar_wave, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.fractional_interpolator_xx_0, 0)) self.connect((self.blocks_multiply_xx_0_1, 0), (self.blocks_float_to_int_0, 0)) self.connect((self.blocks_multiply_xx_0_1, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.blocks_stream_mux_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_stream_mux_0, 1)) self.connect((self.fractional_interpolator_xx_0, 0), (self.analog_wfm_tx_0, 0)) self.connect((self.fractional_interpolator_xx_0, 0), (self.qtgui_time_sink_x_3_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.analog_wfm_rcv_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.qtgui_time_sink_x_1_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.qtgui_time_sink_x_2, 0))
def __init__(self, carrier_freq=1080, input_path='/tmp/data.wav', output_path='/tmp/data.bin'): gr.top_block.__init__(self, "Fsk Demodulation") ################################################## # Parameters ################################################## self.carrier_freq = carrier_freq self.input_path = input_path self.output_path = output_path ################################################## # Variables ################################################## self.nfilts = nfilts = 32 self.SPS = SPS = 147 self.RX_decimation = RX_decimation = 49 self.EBW = EBW = .05 self.samp_rate = samp_rate = 44.1E3 self.fsk_deviation_hz = fsk_deviation_hz = 100 self.RRC_filter_taps = RRC_filter_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0, EBW, 5 * SPS * nfilts / RX_decimation) ################################################## # Blocks ################################################## self.rational_resampler_xxx_1 = filter.rational_resampler_ccc( interpolation=1, decimation=RX_decimation, taps=None, fractional_bw=None, ) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_fff( SPS / RX_decimation, 6.28 / 400.0 * 2 / 70, (RRC_filter_taps), nfilts, nfilts / 2, 2, 1) self.digital_binary_slicer_fb_0_0 = digital.binary_slicer_fb() self.blocks_wavfile_source_0 = blocks.wavfile_source(input_path, False) self.blocks_multiply_xx_1 = blocks.multiply_vcc(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1, output_path, False) self.blocks_file_sink_0.set_unbuffered(False) self.analog_sig_source_x_1 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, -carrier_freq, 1, 0) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf( samp_rate / (2 * math.pi * fsk_deviation_hz / 8.0) / (RX_decimation)) self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(-60, .01, 0, True) self.analog_feedforward_agc_cc_0 = analog.feedforward_agc_cc(1024, 1.0) self.analog_const_source_x_0 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, 0) ################################################## # Connections ################################################## self.connect((self.analog_const_source_x_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.analog_feedforward_agc_cc_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.analog_pwr_squelch_xx_0, 0), (self.analog_feedforward_agc_cc_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.digital_binary_slicer_fb_0_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_binary_slicer_fb_0_0, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.analog_pwr_squelch_xx_0, 0))
def __init__(self): gr.top_block.__init__(self, "HFS second channel") ################################################## # Variables ################################################## self.snr = snr = 10 self.vol = vol = 1 self.tau_a = tau_a = 1 / 100. self.tau = tau = 0.002 self.snr_out_func = snr_out_func = ([0] * 3) self.samp_rate_0 = samp_rate_0 = 48000 self.samp_rate = samp_rate = 48000 self.out_rms_func = out_rms_func = 0 self.noSpread = noSpread = 0 self.kN = kN = pow(10.0, (-snr / 20.0)) self.freqShift = freqShift = 0.0 self.fd = fd = 1 self.en_noise = en_noise = 0 self.doppler_ir = doppler_ir = [ 0.0016502763167573274, 0.0018854799389366934, 0.002149957633383614, 0.0024466994528029662, 0.002778907461425479, 0.003149998028185868, 0.003563602180973301, 0.00402356375450247, 0.004533935060796761, 0.0050989698117900155, 0.005723113028669535, 0.006410987682800636, 0.007167377828853199, 0.007997208012493867, 0.008905518763040982, 0.00989743801603955, 0.010978148351927763, 0.012152849984840378, 0.013426719489994542, 0.014804864318746317, 0.016292273216847054, 0.01789376273305468, 0.019613920081278834, 0.021457042698902442, 0.023427074925696508, 0.025527542310538734, 0.027761484135525694, 0.030131384827462734, 0.03263910500345486, 0.035285812968654906, 0.03807191754835305, 0.04099700319171279, 0.04405976832879332, 0.04725796799434838, 0.050588361749672524, 0.05404666793605477, 0.057627525278984175, 0.06132446283016882, 0.06512987918400244, 0.0690350318359975, 0.073030037462906, 0.07710388379815894, 0.08124445365265866, 0.08543856149104095, 0.08967200281887802, 0.0939296164688993, 0.09819535969651079, 0.10245239580938088, 0.10668319386560887, 0.1108696397832219, 0.11499315801386097, 0.11903484274903825, 0.12297559745183839, 0.12679628134392928, 0.1304778613306593, 0.13400156771907581, 0.1373490519778611, 0.14050254470705797, 0.14344501193124823, 0.14616030780428022, 0.14863332181791858, 0.15085011864154488, 0.1527980687853246, 0.154465968374505, 0.15584414644656272, 0.15692455833401583, 0.15770086387153975, 0.1581684893637365, 0.15832467246620405, 0.1581684893637365, 0.15770086387153975, 0.15692455833401583, 0.15584414644656272, 0.154465968374505, 0.1527980687853246, 0.15085011864154488, 0.14863332181791858, 0.14616030780428022, 0.14344501193124823, 0.14050254470705797, 0.1373490519778611, 0.13400156771907581, 0.1304778613306593, 0.12679628134392928, 0.12297559745183839, 0.11903484274903825, 0.11499315801386097, 0.1108696397832219, 0.10668319386560887, 0.10245239580938088, 0.09819535969651079, 0.0939296164688993, 0.08967200281887802, 0.08543856149104095, 0.08124445365265866, 0.07710388379815894, 0.073030037462906, 0.0690350318359975, 0.06512987918400244, 0.06132446283016882, 0.057627525278984175, 0.05404666793605477, 0.050588361749672524, 0.04725796799434838, 0.04405976832879332, 0.04099700319171279, 0.03807191754835305, 0.035285812968654906, 0.03263910500345486, 0.030131384827462734, 0.027761484135525694, 0.025527542310538734, 0.023427074925696508, 0.021457042698902442, 0.019613920081278834, 0.01789376273305468, 0.016292273216847054, 0.014804864318746317, 0.013426719489994542, 0.012152849984840378, 0.010978148351927763, 0.00989743801603955, 0.008905518763040982, 0.007997208012493867, 0.007167377828853199, 0.006410987682800636, 0.005723113028669535, 0.0050989698117900155, 0.004533935060796761, 0.00402356375450247, 0.003563602180973301, 0.003149998028185868, 0.002778907461425479, 0.0024466994528029662, 0.002149957633383614, 0.0018854799389366934, 0.0016502763167573274 ] self.ampl = ampl = [[1.0, 1.0], [1.0, 1.0]] ################################################## # Blocks ################################################## self.snr_out = blocks.probe_signal_f() self.out_rms = blocks.probe_signal_f() def _snr_out_func_probe(): while True: val = self.snr_out.level() try: self.set_snr_out_func(val) except AttributeError: pass time.sleep(1.0 / (10)) _snr_out_func_thread = threading.Thread(target=_snr_out_func_probe) _snr_out_func_thread.daemon = True _snr_out_func_thread.start() self.single_pole_iir_filter_xx_0_0 = filter.single_pole_iir_filter_ff( 2 * pi * tau_a / samp_rate, 1) self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff( 2 * pi * tau_a / samp_rate, 1) def _out_rms_func_probe(): while True: val = self.out_rms.level() try: self.set_out_rms_func(val) except AttributeError: pass time.sleep(1.0 / (10)) _out_rms_func_thread = threading.Thread(target=_out_rms_func_probe) _out_rms_func_thread.daemon = True _out_rms_func_thread.start() self.low_pass_filter_2 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate, 1550, 100, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_1_0 = filter.interp_fir_filter_ccf( int(samp_rate / 100), firdes.low_pass(ampl[0][1] * (samp_rate / 100.0), samp_rate, 50, 25, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_1 = filter.interp_fir_filter_ccf( int(samp_rate / 100), firdes.low_pass(ampl[0][0] * (samp_rate / 100.0), samp_rate, 50, 25, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate, 1750 + 100, 600, firdes.WIN_HAMMING, 6.76)) self.epy_block_0_0 = epy_block_0_0.blk(fd=fd) self.epy_block_0 = epy_block_0.blk(fd=fd) self.blocks_selector_0_0 = blocks.selector(gr.sizeof_gr_complex * 1, noSpread, 0) self.blocks_selector_0_0.set_enabled(True) self.blocks_selector_0 = blocks.selector(gr.sizeof_gr_complex * 1, noSpread, 0) self.blocks_selector_0.set_enabled(True) self.blocks_rms_xx_0_0 = blocks.rms_ff(2 * pi * tau_a * 10 / samp_rate) self.blocks_rms_xx_0 = blocks.rms_cf(2 * pi * tau_a * 100 / samp_rate) self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, 1, 0) self.blocks_multiply_xx_1_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0_0_0_0_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0_0_0_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0_0_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_3 = blocks.multiply_const_ff(en_noise) self.blocks_multiply_const_vxx_2_0 = blocks.multiply_const_cc(vol) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_ff( 2 * sqrt(ampl[0][0]**2 + ampl[0][1]**2) * 2) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(0.5) self.blocks_float_to_complex_1 = blocks.float_to_complex(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_divide_xx_1 = blocks.divide_ff(1) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, int(tau * samp_rate)) self.blocks_complex_to_real_0_0 = blocks.complex_to_real(1) self.blocks_complex_to_mag_squared_2_0 = blocks.complex_to_mag_squared( 1) self.blocks_complex_to_mag_squared_2 = blocks.complex_to_mag_squared(1) self.blocks_add_xx_1 = blocks.add_vff(1) self.blocks_add_xx_0_0_1 = blocks.add_vcc(1) self.blocks_add_xx_0_0_0_0 = blocks.add_vcc(1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.audio_source_1 = audio.source(samp_rate, '', True) self.audio_sink_0 = audio.sink(samp_rate, '', True) self.analog_sig_source_x_2 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, 1850, 1, 0, 0) self.analog_sig_source_x_1_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, freqShift, 1, 0, 0) self.analog_sig_source_x_0_0_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, 1850, 1, 0, 0) self.analog_sig_source_x_0_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, -1850, 1, 0, 0) self.analog_noise_source_x_1 = analog.noise_source_c( analog.GR_GAUSSIAN, 1e-0 * kN, 3) self.analog_fastnoise_source_x_2 = analog.fastnoise_source_c( analog.GR_GAUSSIAN, 1, 11, 8192) self.analog_fastnoise_source_x_1 = analog.fastnoise_source_c( analog.GR_GAUSSIAN, 1, 10, 8192) self.analog_fastnoise_source_x_0 = analog.fastnoise_source_f( analog.GR_GAUSSIAN, 0.3, 0, 8192) self.analog_const_source_x_2 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, 0) self.analog_const_source_x_1_0 = analog.sig_source_c( 0, analog.GR_CONST_WAVE, 0, 0, ampl[0][1]) self.analog_const_source_x_1 = analog.sig_source_c( 0, analog.GR_CONST_WAVE, 0, 0, ampl[0][0]) self.analog_const_source_x_0 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, 0) ################################################## # Connections ################################################## self.connect((self.analog_const_source_x_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.analog_const_source_x_1, 0), (self.blocks_selector_0, 1)) self.connect((self.analog_const_source_x_1_0, 0), (self.blocks_selector_0_0, 1)) self.connect((self.analog_const_source_x_2, 0), (self.blocks_float_to_complex_1, 1)) self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_multiply_const_vxx_3, 0)) self.connect((self.analog_fastnoise_source_x_1, 0), (self.epy_block_0, 0)) self.connect((self.analog_fastnoise_source_x_2, 0), (self.epy_block_0_0, 0)) self.connect((self.analog_noise_source_x_1, 0), (self.low_pass_filter_2, 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, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.analog_sig_source_x_1_0, 0), (self.blocks_multiply_xx_1_0, 0)) self.connect((self.analog_sig_source_x_2, 0), (self.blocks_multiply_xx_0_0_0_0_0, 1)) self.connect((self.audio_source_1, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_add_xx_0_0_1, 0)) self.connect((self.blocks_add_xx_0_0_0_0, 0), (self.blocks_multiply_const_vxx_2_0, 0)) self.connect((self.blocks_add_xx_0_0_1, 0), (self.blocks_multiply_xx_1_0, 1)) self.connect((self.blocks_add_xx_1, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_complex_to_mag_squared_2, 0), (self.single_pole_iir_filter_xx_0, 0)) self.connect((self.blocks_complex_to_mag_squared_2_0, 0), (self.single_pole_iir_filter_xx_0_0, 0)) self.connect((self.blocks_complex_to_real_0_0, 0), (self.blocks_add_xx_1, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_xx_0_0_0_0, 0)) self.connect((self.blocks_divide_xx_1, 0), (self.blocks_nlog10_ff_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_float_to_complex_1, 0), (self.blocks_multiply_xx_0_0_0_0_0, 2)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_rms_xx_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_float_to_complex_1, 0)) self.connect((self.blocks_multiply_const_vxx_2_0, 0), (self.blocks_complex_to_real_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_3, 0), (self.blocks_add_xx_1, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.blocks_multiply_xx_0_0_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.blocks_rms_xx_0, 0)) self.connect((self.blocks_multiply_xx_0_0_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_xx_0_0_0_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_multiply_xx_0_0_0_0_0, 0), (self.blocks_add_xx_0_0_0_0, 1)) self.connect((self.blocks_multiply_xx_0_0_0_0_0, 0), (self.blocks_add_xx_0_0_1, 1)) self.connect((self.blocks_multiply_xx_0_0_0_0_0, 0), (self.blocks_complex_to_mag_squared_2_0, 0)) self.connect((self.blocks_multiply_xx_1_0, 0), (self.blocks_add_xx_0_0_0_0, 0)) self.connect((self.blocks_multiply_xx_1_0, 0), (self.blocks_complex_to_mag_squared_2, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.snr_out, 0)) self.connect((self.blocks_rms_xx_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_rms_xx_0_0, 0), (self.out_rms, 0)) self.connect((self.blocks_selector_0, 0), (self.blocks_multiply_xx_0_0_0, 1)) self.connect((self.blocks_selector_0_0, 0), (self.blocks_multiply_xx_0_0_0_0, 1)) self.connect((self.epy_block_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.epy_block_0_0, 0), (self.low_pass_filter_1_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.blocks_selector_0, 0)) self.connect((self.low_pass_filter_1_0, 0), (self.blocks_selector_0_0, 0)) self.connect((self.low_pass_filter_2, 0), (self.blocks_multiply_xx_0_0_0_0_0, 0)) self.connect((self.single_pole_iir_filter_xx_0, 0), (self.blocks_divide_xx_1, 0)) self.connect((self.single_pole_iir_filter_xx_0_0, 0), (self.blocks_divide_xx_1, 1))
def __init__(self): gr.top_block.__init__( self, "Self-Interference Cancellation with Adaptive Filters") Qt.QWidget.__init__(self) self.setWindowTitle( "Self-Interference Cancellation with Adaptive Filters") 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", "self_interference_cancellation") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 self.n_taps = n_taps = 16 self.gui_reset = gui_reset = False self.gui_nlms_mu = gui_nlms_mu = 1 self.gui_lms_mu = gui_lms_mu = 0.01 self.gui_lambda = gui_lambda = 1 self.gui_delta = gui_delta = 1 self.gui_adapt = gui_adapt = True self.frequency = frequency = 2e3 ################################################## # Blocks ################################################## _gui_reset_check_box = Qt.QCheckBox('Reset') self._gui_reset_choices = {True: True, False: False} self._gui_reset_choices_inv = dict( (v, k) for k, v in self._gui_reset_choices.iteritems()) self._gui_reset_callback = lambda i: Qt.QMetaObject.invokeMethod( _gui_reset_check_box, "setChecked", Qt.Q_ARG("bool", self._gui_reset_choices_inv[i])) self._gui_reset_callback(self.gui_reset) _gui_reset_check_box.stateChanged.connect( lambda i: self.set_gui_reset(self._gui_reset_choices[bool(i)])) self.top_grid_layout.addWidget(_gui_reset_check_box, 2, 2, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self._gui_lms_mu_range = Range(0.001, 1, 0.01, 0.01, 100) self._gui_lms_mu_win = RangeWidget(self._gui_lms_mu_range, self.set_gui_lms_mu, 'LMS Mu', "counter_slider", float) self.top_grid_layout.addWidget(self._gui_lms_mu_win, 0, 0, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) _gui_adapt_check_box = Qt.QCheckBox('Adapt') self._gui_adapt_choices = {True: True, False: False} self._gui_adapt_choices_inv = dict( (v, k) for k, v in self._gui_adapt_choices.iteritems()) self._gui_adapt_callback = lambda i: Qt.QMetaObject.invokeMethod( _gui_adapt_check_box, "setChecked", Qt.Q_ARG("bool", self._gui_adapt_choices_inv[i])) self._gui_adapt_callback(self.gui_adapt) _gui_adapt_check_box.stateChanged.connect( lambda i: self.set_gui_adapt(self._gui_adapt_choices[bool(i)])) self.top_grid_layout.addWidget(_gui_adapt_check_box, 2, 1, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_vector_sink_f_0 = qtgui.vector_sink_f( n_taps, 0, 1.0, "x-Axis", "y-Axis", "", 1 # Number of inputs ) self.qtgui_vector_sink_f_0.set_update_time(0.10) self.qtgui_vector_sink_f_0.set_y_axis(-1, 1) self.qtgui_vector_sink_f_0.enable_autoscale(False) self.qtgui_vector_sink_f_0.enable_grid(True) self.qtgui_vector_sink_f_0.set_x_axis_units("") self.qtgui_vector_sink_f_0.set_y_axis_units("") self.qtgui_vector_sink_f_0.set_ref_level(0) 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 xrange(1): if len(labels[i]) == 0: self.qtgui_vector_sink_f_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_vector_sink_f_0.set_line_label(i, labels[i]) self.qtgui_vector_sink_f_0.set_line_width(i, widths[i]) self.qtgui_vector_sink_f_0.set_line_color(i, colors[i]) self.qtgui_vector_sink_f_0.set_line_alpha(i, alphas[i]) self._qtgui_vector_sink_f_0_win = sip.wrapinstance( self.qtgui_vector_sink_f_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_vector_sink_f_0_win, 3, 0, 3, 3) for r in range(3, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 3): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 4 #number of inputs ) 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) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "float" == "float" or "float" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['Input', 'Reference', 'Out', 'Error', '', '', '', '', '', ''] 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 xrange(4): 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_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 6, 0, 3, 3) for r in range(6, 9): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 3): self.top_grid_layout.setColumnStretch(c, 1) self._gui_nlms_mu_range = Range(0.001, 2, 0.01, 1, 100) self._gui_nlms_mu_win = RangeWidget(self._gui_nlms_mu_range, self.set_gui_nlms_mu, 'NLMS Mu', "counter_slider", float) self.top_grid_layout.addWidget(self._gui_nlms_mu_win, 1, 0, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._gui_lambda_range = Range(0.01, 1, 0.01, 1, 100) self._gui_lambda_win = RangeWidget(self._gui_lambda_range, self.set_gui_lambda, 'Lambda', "counter_slider", float) self.top_grid_layout.addWidget(self._gui_lambda_win, 1, 1, 1, 2) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 3): self.top_grid_layout.setColumnStretch(c, 1) self._gui_delta_range = Range(0, 300, 1, 1, 300) self._gui_delta_win = RangeWidget(self._gui_delta_range, self.set_gui_delta, 'Delta', "counter_slider", float) self.top_grid_layout.addWidget(self._gui_delta_win, 0, 1, 1, 2) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 3): self.top_grid_layout.setColumnStretch(c, 1) self._frequency_range = Range(1e3, 1e4, 1e3, 2e3, 10) self._frequency_win = RangeWidget(self._frequency_range, self.set_frequency, 'Frequency', "counter_slider", float) self.top_grid_layout.addWidget(self._frequency_win, 2, 0, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.fir_filter_xxx_0 = filter.fir_filter_fff(1, (1, 0.5, 0.3, 0.9)) self.fir_filter_xxx_0.declare_sample_delay(0) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1, samp_rate, True) self.blocks_add_xx_0 = blocks.add_vff(1) self.analog_sig_source_x_0 = analog.sig_source_f( samp_rate, analog.GR_SIN_WAVE, samp_rate / 32, 1, 0) self.analog_noise_source_x_0_0 = analog.noise_source_f( analog.GR_GAUSSIAN, 1, 0) self.adapt_lms_filter_xx_0 = adapt.lms_filter_ff( False, n_taps, gui_lms_mu, 0, 1, gui_adapt, False, gui_reset) ################################################## # Connections ################################################## self.connect((self.adapt_lms_filter_xx_0, 1), (self.qtgui_freq_sink_x_0, 2)) self.connect((self.adapt_lms_filter_xx_0, 0), (self.qtgui_freq_sink_x_0, 3)) self.connect((self.adapt_lms_filter_xx_0, 2), (self.qtgui_vector_sink_f_0, 0)) self.connect((self.analog_noise_source_x_0_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.adapt_lms_filter_xx_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.blocks_throttle_0, 0), (self.adapt_lms_filter_xx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.blocks_add_xx_0, 1))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Multi Tx") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.audio_rate = audio_rate = 48000 self.wpm = wpm = 15 self.wbfm_on = wbfm_on = True self.usb_on = usb_on = True self.samp_rate = samp_rate = audio_rate * 40 self.q_offset = q_offset = 0 self.psk_on = psk_on = True self.phase = phase = 0 self.nbfm_on = nbfm_on = True self.magnitude = magnitude = 0 self.lsb_on = lsb_on = True self.i_offset = i_offset = 0 self.gain = gain = 25 self.cw_on = cw_on = True self.center_freq = center_freq = 441000000 self.am_on = am_on = True ################################################## # Blocks ################################################## self._wbfm_on_check_box = forms.check_box( parent=self.GetWin(), value=self.wbfm_on, callback=self.set_wbfm_on, label='WBFM', true=True, false=False, ) self.GridAdd(self._wbfm_on_check_box, 4, 1, 1, 1) self._usb_on_check_box = forms.check_box( parent=self.GetWin(), value=self.usb_on, callback=self.set_usb_on, label='USB', true=True, false=False, ) self.GridAdd(self._usb_on_check_box, 4, 4, 1, 1) _q_offset_sizer = wx.BoxSizer(wx.VERTICAL) self._q_offset_text_box = forms.text_box( parent=self.GetWin(), sizer=_q_offset_sizer, value=self.q_offset, callback=self.set_q_offset, label='DC offset Q', converter=forms.float_converter(), proportion=0, ) self._q_offset_slider = forms.slider( parent=self.GetWin(), sizer=_q_offset_sizer, value=self.q_offset, callback=self.set_q_offset, minimum=-0.1, maximum=0.1, num_steps=200, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_q_offset_sizer, 3, 0, 1, 7) self._psk_on_check_box = forms.check_box( parent=self.GetWin(), value=self.psk_on, callback=self.set_psk_on, label='PSK31', true=True, false=False, ) self.GridAdd(self._psk_on_check_box, 4, 6, 1, 1) _phase_sizer = wx.BoxSizer(wx.VERTICAL) self._phase_text_box = forms.text_box( parent=self.GetWin(), sizer=_phase_sizer, value=self.phase, callback=self.set_phase, label='Phase correction', converter=forms.float_converter(), proportion=0, ) self._phase_slider = forms.slider( parent=self.GetWin(), sizer=_phase_sizer, value=self.phase, callback=self.set_phase, minimum=-0.1, maximum=0.1, num_steps=200, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_phase_sizer, 0, 0, 1, 7) self._nbfm_on_check_box = forms.check_box( parent=self.GetWin(), value=self.nbfm_on, callback=self.set_nbfm_on, label='NBFM', true=True, false=False, ) self.GridAdd(self._nbfm_on_check_box, 4, 0, 1, 1) _magnitude_sizer = wx.BoxSizer(wx.VERTICAL) self._magnitude_text_box = forms.text_box( parent=self.GetWin(), sizer=_magnitude_sizer, value=self.magnitude, callback=self.set_magnitude, label='Magnitude correction', converter=forms.float_converter(), proportion=0, ) self._magnitude_slider = forms.slider( parent=self.GetWin(), sizer=_magnitude_sizer, value=self.magnitude, callback=self.set_magnitude, minimum=-0.1, maximum=0.1, num_steps=200, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_magnitude_sizer, 1, 0, 1, 7) self._lsb_on_check_box = forms.check_box( parent=self.GetWin(), value=self.lsb_on, callback=self.set_lsb_on, label='LSB', true=True, false=False, ) self.GridAdd(self._lsb_on_check_box, 4, 3, 1, 1) _i_offset_sizer = wx.BoxSizer(wx.VERTICAL) self._i_offset_text_box = forms.text_box( parent=self.GetWin(), sizer=_i_offset_sizer, value=self.i_offset, callback=self.set_i_offset, label='DC offset I', converter=forms.float_converter(), proportion=0, ) self._i_offset_slider = forms.slider( parent=self.GetWin(), sizer=_i_offset_sizer, value=self.i_offset, callback=self.set_i_offset, minimum=-0.1, maximum=0.1, num_steps=200, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_i_offset_sizer, 2, 0, 1, 7) self._cw_on_check_box = forms.check_box( parent=self.GetWin(), value=self.cw_on, callback=self.set_cw_on, label='CW', true=True, false=False, ) self.GridAdd(self._cw_on_check_box, 4, 5, 1, 1) self._am_on_check_box = forms.check_box( parent=self.GetWin(), value=self.am_on, callback=self.set_am_on, label='AM', true=True, false=False, ) self.GridAdd(self._am_on_check_box, 4, 2, 1, 1) self.root_raised_cosine_filter_1 = filter.fir_filter_ccf( 1, firdes.root_raised_cosine(1, audio_rate, 5, 0.35, 200)) self.root_raised_cosine_filter_0 = filter.fir_filter_ccf( 1, firdes.root_raised_cosine(1, audio_rate, 5, 0.35, 200)) self.rational_resampler_xxx_3 = filter.rational_resampler_ccc( interpolation=192, decimation=1, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_2 = filter.rational_resampler_ccc( interpolation=samp_rate, decimation=audio_rate, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_1 = filter.rational_resampler_ccc( interpolation=samp_rate / audio_rate / 2, decimation=1, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=samp_rate / audio_rate / 4, decimation=1, taps=None, fractional_bw=None, ) self.osmosdr_sink_0 = osmosdr.sink(args="numchan=" + str(1) + " " + '') self.osmosdr_sink_0.set_sample_rate(samp_rate) self.osmosdr_sink_0.set_center_freq(center_freq, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(gain, 0) self.osmosdr_sink_0.set_if_gain(20, 0) self.osmosdr_sink_0.set_bb_gain(20, 0) self.osmosdr_sink_0.set_antenna('', 0) self.osmosdr_sink_0.set_bandwidth(0, 0) self.low_pass_filter_1 = filter.interp_fir_filter_ccf( 1, firdes.low_pass(0.5, audio_rate, 5000, 400, firdes.WIN_HAMMING, 6.76)) self.iqbalance_fix_cc_0 = iqbalance.fix_cc(magnitude, phase) self.digital_psk_mod_0 = digital.psk.psk_mod( constellation_points=2, mod_code="none", differential=True, samples_per_symbol=8, excess_bw=0.35, verbose=False, log=False, ) self.digital_map_bb_0 = digital.map_bb(([1, 0])) self.blocks_wavfile_source_0 = blocks.wavfile_source( '/home/nocomp/Musique/wave/maybe-next-time.wav', True) self.blocks_vector_source_x_2 = blocks.vector_source_b( (0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1), True, 1, []) self.blocks_vector_source_x_0 = blocks.vector_source_c( (1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0), True, 1, []) self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb( 1, gr.GR_MSB_FIRST) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex * 1, int(1.2 * audio_rate / wpm)) self.blocks_multiply_xx_6 = blocks.multiply_vcc(1) self.blocks_multiply_xx_5 = blocks.multiply_vcc(1) self.blocks_multiply_xx_4 = blocks.multiply_vcc(1) self.blocks_multiply_xx_3_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_3 = blocks.multiply_vcc(1) self.blocks_multiply_xx_2 = blocks.multiply_vcc(1) self.blocks_multiply_xx_1 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_add_xx_1 = blocks.add_vcc(1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.blocks_add_const_vxx_1 = blocks.add_const_vcc( (i_offset + 1j * q_offset, )) self.blocks_add_const_vxx_0 = blocks.add_const_vcc((0.5, )) self.band_pass_filter_0_0 = filter.interp_fir_filter_ccc( 1, firdes.complex_band_pass(1, audio_rate, -2800, -200, 200, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0 = filter.interp_fir_filter_ccc( 1, firdes.complex_band_pass(1, audio_rate, 200, 2800, 200, firdes.WIN_HAMMING, 6.76)) self.analog_wfm_tx_0 = analog.wfm_tx( audio_rate=audio_rate, quad_rate=audio_rate * 4, tau=75e-6, max_dev=75e3, fh=-1.0, ) self.analog_sig_source_x_6 = analog.sig_source_c( audio_rate, analog.GR_COS_WAVE, 22000, 1 if psk_on else 0, 0) self.analog_sig_source_x_5 = analog.sig_source_c( audio_rate, analog.GR_COS_WAVE, 20000, 1 if cw_on else 0, 0) self.analog_sig_source_x_4 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, 120000, 1.0 / 7, 0) self.analog_sig_source_x_3_0 = analog.sig_source_c( audio_rate, analog.GR_COS_WAVE, 11000, 1.8 if lsb_on else 0, 0) self.analog_sig_source_x_3 = analog.sig_source_c( audio_rate, analog.GR_COS_WAVE, 14000, 1.8 if usb_on else 0, 0) self.analog_sig_source_x_2 = analog.sig_source_c( audio_rate, analog.GR_COS_WAVE, 0, 1 if am_on else 0, 0) self.analog_sig_source_x_1 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, 0, 1.0 / 7 if wbfm_on else 0, 0) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, -100000, 1.0 / 7 if nbfm_on else 0, 0) self.analog_nbfm_tx_0 = analog.nbfm_tx( audio_rate=audio_rate, quad_rate=audio_rate * 2, tau=75e-6, max_dev=5e3, fh=-1.0, ) self.analog_const_source_x_0 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, 0) ################################################## # Connections ################################################## self.connect((self.analog_const_source_x_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.analog_nbfm_tx_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.analog_sig_source_x_2, 0), (self.blocks_multiply_xx_2, 1)) self.connect((self.analog_sig_source_x_3, 0), (self.blocks_multiply_xx_3, 1)) self.connect((self.analog_sig_source_x_3_0, 0), (self.blocks_multiply_xx_3_0, 1)) self.connect((self.analog_sig_source_x_4, 0), (self.blocks_multiply_xx_4, 1)) self.connect((self.analog_sig_source_x_5, 0), (self.blocks_multiply_xx_5, 1)) self.connect((self.analog_sig_source_x_6, 0), (self.blocks_multiply_xx_6, 1)) self.connect((self.analog_wfm_tx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.blocks_multiply_xx_3, 0)) self.connect((self.band_pass_filter_0_0, 0), (self.blocks_multiply_xx_3_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_xx_2, 0)) self.connect((self.blocks_add_const_vxx_1, 0), (self.osmosdr_sink_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.iqbalance_fix_cc_0, 0)) self.connect((self.blocks_add_xx_1, 0), (self.rational_resampler_xxx_2, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.band_pass_filter_0_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_xx_2, 0), (self.blocks_add_xx_1, 0)) self.connect((self.blocks_multiply_xx_3, 0), (self.blocks_add_xx_1, 2)) self.connect((self.blocks_multiply_xx_3_0, 0), (self.blocks_add_xx_1, 1)) self.connect((self.blocks_multiply_xx_4, 0), (self.blocks_add_xx_0, 2)) self.connect((self.blocks_multiply_xx_5, 0), (self.blocks_add_xx_1, 3)) self.connect((self.blocks_multiply_xx_6, 0), (self.blocks_add_xx_1, 4)) self.connect((self.blocks_repeat_0, 0), (self.root_raised_cosine_filter_1, 0)) self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.digital_psk_mod_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.blocks_vector_source_x_2, 0), (self.digital_map_bb_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.analog_nbfm_tx_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.analog_wfm_tx_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.digital_map_bb_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0)) self.connect((self.digital_psk_mod_0, 0), (self.rational_resampler_xxx_3, 0)) self.connect((self.iqbalance_fix_cc_0, 0), (self.blocks_add_const_vxx_1, 0)) self.connect((self.low_pass_filter_1, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.rational_resampler_xxx_2, 0), (self.blocks_multiply_xx_4, 0)) self.connect((self.rational_resampler_xxx_3, 0), (self.blocks_multiply_xx_6, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.blocks_multiply_xx_5, 0)) self.connect((self.root_raised_cosine_filter_1, 0), (self.root_raised_cosine_filter_0, 0))
def __init__(self): gr.top_block.__init__(self, "Dtmf") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 self.bstar = bstar = 0 self.bhash = bhash = 0 self.b9 = b9 = 0 self.b8 = b8 = 0 self.b7 = b7 = 0 self.b6 = b6 = 0 self.b5 = b5 = 0 self.b4 = b4 = 0 self.b3 = b3 = 0 self.b2 = b2 = 0 self.b1 = b1 = 0 self.b0 = b0 = 0 ################################################## # Blocks ################################################## self.blocks_multiply_const_vxx_0_9 = blocks.multiply_const_vff((b9, )) self.blocks_multiply_const_vxx_0_8 = blocks.multiply_const_vff((b6, )) self.blocks_multiply_const_vxx_0_7 = blocks.multiply_const_vff((b3, )) self.blocks_multiply_const_vxx_0_6 = blocks.multiply_const_vff((0, )) self.blocks_multiply_const_vxx_0_5 = blocks.multiply_const_vff((b8, )) self.blocks_multiply_const_vxx_0_4 = blocks.multiply_const_vff((b5, )) self.blocks_multiply_const_vxx_0_3 = blocks.multiply_const_vff((b2, )) self.blocks_multiply_const_vxx_0_2 = blocks.multiply_const_vff( (bstar, )) self.blocks_multiply_const_vxx_0_10 = blocks.multiply_const_vff((0, )) self.blocks_multiply_const_vxx_0_1 = blocks.multiply_const_vff((b7, )) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((b4, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((b1, )) self.blocks_add_xx_0_9 = blocks.add_vff(1) self.blocks_add_xx_0_8 = blocks.add_vff(1) self.blocks_add_xx_0_7 = blocks.add_vff(1) self.blocks_add_xx_0_6 = blocks.add_vff(1) self.blocks_add_xx_0_5 = blocks.add_vff(1) self.blocks_add_xx_0_4 = blocks.add_vff(1) self.blocks_add_xx_0_3 = blocks.add_vff(1) self.blocks_add_xx_0_2 = blocks.add_vff(1) self.blocks_add_xx_0_11_0_0_0 = blocks.add_vff(1) self.blocks_add_xx_0_11_0_0 = blocks.add_vff(1) self.blocks_add_xx_0_11_0 = blocks.add_vff(1) self.blocks_add_xx_0_11 = blocks.add_vff(1) self.blocks_add_xx_0_10 = blocks.add_vff(1) self.blocks_add_xx_0_1 = blocks.add_vff(1) self.blocks_add_xx_0_0 = blocks.add_vff(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.audio_sink_0 = audio.sink(samp_rate, '', True) self.analog_sig_source_x_0_5 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, 941, .5, 0) self.analog_sig_source_x_0_4 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, 852, .5, 0) self.analog_sig_source_x_0_3 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, 770, .5, 0) self.analog_sig_source_x_0_2 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, 1477, .5, 0) self.analog_sig_source_x_0_1 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, 1336, .5, 0) self.analog_sig_source_x_0_0 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, 697, 0.5, 0) self.analog_sig_source_x_0 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, 1209, .5, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_add_xx_0_2, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_add_xx_0_5, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_add_xx_0_8, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_add_xx_0_0, 1)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_add_xx_0_1, 1)) self.connect((self.analog_sig_source_x_0_1, 0), (self.blocks_add_xx_0_0, 0)) self.connect((self.analog_sig_source_x_0_1, 0), (self.blocks_add_xx_0_3, 0)) self.connect((self.analog_sig_source_x_0_1, 0), (self.blocks_add_xx_0_6, 0)) self.connect((self.analog_sig_source_x_0_1, 0), (self.blocks_add_xx_0_9, 0)) self.connect((self.analog_sig_source_x_0_2, 0), (self.blocks_add_xx_0_1, 0)) self.connect((self.analog_sig_source_x_0_2, 0), (self.blocks_add_xx_0_10, 0)) self.connect((self.analog_sig_source_x_0_2, 0), (self.blocks_add_xx_0_4, 0)) self.connect((self.analog_sig_source_x_0_2, 0), (self.blocks_add_xx_0_7, 0)) self.connect((self.analog_sig_source_x_0_3, 0), (self.blocks_add_xx_0_2, 1)) self.connect((self.analog_sig_source_x_0_3, 0), (self.blocks_add_xx_0_3, 1)) self.connect((self.analog_sig_source_x_0_3, 0), (self.blocks_add_xx_0_4, 1)) self.connect((self.analog_sig_source_x_0_4, 0), (self.blocks_add_xx_0_5, 1)) self.connect((self.analog_sig_source_x_0_4, 0), (self.blocks_add_xx_0_6, 1)) self.connect((self.analog_sig_source_x_0_4, 0), (self.blocks_add_xx_0_7, 1)) self.connect((self.analog_sig_source_x_0_5, 0), (self.blocks_add_xx_0_10, 1)) self.connect((self.analog_sig_source_x_0_5, 0), (self.blocks_add_xx_0_8, 1)) self.connect((self.analog_sig_source_x_0_5, 0), (self.blocks_add_xx_0_9, 1)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_add_xx_0_0, 0), (self.blocks_multiply_const_vxx_0_3, 0)) self.connect((self.blocks_add_xx_0_1, 0), (self.blocks_multiply_const_vxx_0_7, 0)) self.connect((self.blocks_add_xx_0_10, 0), (self.blocks_multiply_const_vxx_0_10, 0)) self.connect((self.blocks_add_xx_0_11, 0), (self.blocks_add_xx_0_11_0_0_0, 2)) self.connect((self.blocks_add_xx_0_11_0, 0), (self.blocks_add_xx_0_11_0_0_0, 1)) self.connect((self.blocks_add_xx_0_11_0_0, 0), (self.blocks_add_xx_0_11_0_0_0, 0)) self.connect((self.blocks_add_xx_0_11_0_0_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_add_xx_0_2, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.blocks_add_xx_0_3, 0), (self.blocks_multiply_const_vxx_0_4, 0)) self.connect((self.blocks_add_xx_0_4, 0), (self.blocks_multiply_const_vxx_0_8, 0)) self.connect((self.blocks_add_xx_0_5, 0), (self.blocks_multiply_const_vxx_0_1, 0)) self.connect((self.blocks_add_xx_0_6, 0), (self.blocks_multiply_const_vxx_0_5, 0)) self.connect((self.blocks_add_xx_0_7, 0), (self.blocks_multiply_const_vxx_0_9, 0)) self.connect((self.blocks_add_xx_0_8, 0), (self.blocks_multiply_const_vxx_0_2, 0)) self.connect((self.blocks_add_xx_0_9, 0), (self.blocks_multiply_const_vxx_0_6, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_xx_0_11, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_add_xx_0_11, 1)) self.connect((self.blocks_multiply_const_vxx_0_1, 0), (self.blocks_add_xx_0_11, 2)) self.connect((self.blocks_multiply_const_vxx_0_10, 0), (self.blocks_add_xx_0_11_0_0, 3)) self.connect((self.blocks_multiply_const_vxx_0_2, 0), (self.blocks_add_xx_0_11, 3)) self.connect((self.blocks_multiply_const_vxx_0_3, 0), (self.blocks_add_xx_0_11_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_4, 0), (self.blocks_add_xx_0_11_0, 1)) self.connect((self.blocks_multiply_const_vxx_0_5, 0), (self.blocks_add_xx_0_11_0, 2)) self.connect((self.blocks_multiply_const_vxx_0_6, 0), (self.blocks_add_xx_0_11_0, 3)) self.connect((self.blocks_multiply_const_vxx_0_7, 0), (self.blocks_add_xx_0_11_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_8, 0), (self.blocks_add_xx_0_11_0_0, 1)) self.connect((self.blocks_multiply_const_vxx_0_9, 0), (self.blocks_add_xx_0_11_0_0, 2))
def __init__(self): gr.top_block.__init__(self, "Pythonblockex") Qt.QWidget.__init__(self) self.setWindowTitle("Pythonblockex") 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", "pythonBlockEx") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000.0 self.Ampt = Ampt = 3 ################################################## # Blocks ################################################## 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(False) 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.qtgui_freq_sink_x_0 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) 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_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_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "float" == "float" or "float" == "msg_float": 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 xrange(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.pyBlockSigGenerator = blk(sample_rate=samp_rate, freq_to_add=300.0, signal_amp=1.0, factor=Ampt) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1, samp_rate, True) self.analog_sig_source_x_0 = analog.sig_source_f( samp_rate, analog.GR_SIN_WAVE, 10000, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.pyBlockSigGenerator, 0)) self.connect((self.pyBlockSigGenerator, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.pyBlockSigGenerator, 0), (self.qtgui_time_sink_x_0, 0))