def __init__(self): gr.hier_block2.__init__( self, "NBFM Chain", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signature(1, 1, gr.sizeof_float*1), ) ################################################## # Blocks ################################################## self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=192000, decimation=2400000, taps=None, fractional_bw=None, ) self.low_pass_filter_1 = filter.fir_filter_ccf(1, firdes.low_pass( 1, 192000, 5e3, 5e3, firdes.WIN_HAMMING, 6.76)) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((5, )) self.analog_nbfm_rx_0 = analog.nbfm_rx( audio_rate=48000, quad_rate=192000, tau=75e-6, max_dev=2.5e3, ) ################################################## # Connections ################################################## self.connect((self.analog_nbfm_rx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self, 0)) self.connect((self.low_pass_filter_1, 0), (self.analog_nbfm_rx_0, 0)) self.connect((self, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_1, 0))
def __init__(self): gr.top_block.__init__(self, "Dttsprx") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 8000000 ################################################## # Blocks ################################################## self.low_pass_filter_0 = filter.fir_filter_ccf(int(samp_rate/48000), firdes.low_pass( 1, samp_rate, 48000, 1000, firdes.WIN_HAMMING, 6.76)) self.blocks_interleaved_char_to_complex_0 = blocks.interleaved_char_to_complex(False) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "/tmp/iqdata", False) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.audio_sink_0 = audio.sink(48000, "", True) ################################################## # Connections ################################################## self.connect((self.blocks_complex_to_float_0, 1), (self.audio_sink_0, 1)) self.connect((self.blocks_complex_to_float_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_interleaved_char_to_complex_0, 0)) self.connect((self.blocks_interleaved_char_to_complex_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_complex_to_float_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Gmsk Record") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.target_freq = target_freq = 871.75e6 self.channel_wigth = channel_wigth = 2e6 self.samp_rate = samp_rate = 10e6 self.center_freq = center_freq = target_freq-channel_wigth ################################################## # Blocks ################################################## self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=center_freq, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate/2, 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.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(center_freq, 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(10, 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.low_pass_filter_0 = filter.fir_filter_ccf(2, firdes.low_pass( 1, samp_rate, 1e6, 1.5e6, firdes.WIN_HAMMING, 6.76)) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*1, "/home/twilight/GMSK_test/GMSK_data_record.raw", False) self.blocks_file_sink_0.set_unbuffered(False) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -channel_wigth, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_multiply_xx_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.transition = transition = 1000000 self.samp_rate = samp_rate = 2000000 self.quadrature = quadrature = 500000 self.cutoff = cutoff = 100000 self.audio_decimation = audio_decimation = 10 ################################################## # Blocks ################################################## self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(107.8e6, 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(0, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(20, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.rational_resampler_xxx_1 = filter.rational_resampler_fff( interpolation=2000, decimation=500, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=4, taps=None, fractional_bw=None, ) self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, samp_rate, cutoff, transition, firdes.WIN_HAMMING, 6.76)) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((1, )) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=quadrature, audio_decimation=audio_decimation, ) ################################################## # Connections ################################################## self.connect((self.rtlsdr_source_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_wfm_rcv_0, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_null_sink_0, 0))
def __init__(self): gr.hier_block2.__init__( self, "WBFM Chain", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signature(1, 1, gr.sizeof_float*1), ) ################################################## # Blocks ################################################## self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=192000, decimation=2400000, taps=None, fractional_bw=None, ) self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, 2400000, 200e3, 10e3, firdes.WIN_HAMMING, 6.76)) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=192000, audio_decimation=4, ) ################################################## # Connections ################################################## self.connect((self.analog_wfm_rcv_0, 0), (self, 0)) self.connect((self.low_pass_filter_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self, 0), (self.low_pass_filter_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.analog_wfm_rcv_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 125e6 ################################################## # Blocks ################################################## self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.GetWin(), baseband_freq=500e6, dynamic_range=40, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", ) self.Add(self.wxgui_waterfallsink2_0.win) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=3, decimation=125, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=48, decimation=30, taps=None, fractional_bw=None, ) self.low_pass_filter_0 = filter.fir_filter_ccf(10, firdes.low_pass( 1, 3e6, 5e3, 8e3, firdes.WIN_HAMMING, 6.76)) self.blocks_interleaved_short_to_complex_0 = blocks.interleaved_short_to_complex(False, False) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_short*1, "/dev/langford", True) self.audio_sink_0 = audio.sink(48000, "", True) self.analog_nbfm_rx_0 = analog.nbfm_rx( audio_rate=30000, quad_rate=300000, tau=75e-6, max_dev=5e3, ) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.blocks_interleaved_short_to_complex_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_nbfm_rx_0, 0)) self.connect((self.analog_nbfm_rx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_interleaved_short_to_complex_0, 0), (self.wxgui_waterfallsink2_0, 0)) self.connect((self.blocks_interleaved_short_to_complex_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.low_pass_filter_0, 0))
def test_five_fir_filter(): top = gr.top_block() src = blocks.null_source(gr.sizeof_gr_complex) filters = [filter.fir_filter_ccf(1, [random.random() for j in range(256)]) for i in range(5)] probe = blocks.probe_rate(gr.sizeof_gr_complex) top.connect(*([src] + filters + [probe])) return top, probe
def test_fir_filter_ccf(): top = gr.top_block() src = blocks.null_source(gr.sizeof_gr_complex) firfilter = filter.fir_filter_ccf(1, [random.random() for _ in range(256)]) probe = blocks.probe_rate(gr.sizeof_gr_complex) top.connect(src, firfilter, probe) return top, probe
def test02(self): # Test QPSK sync M = 4 theta = 0 loop_bw = cmath.pi/100.0 fmin = -0.5 fmax = 0.5 mu = 0.5 gain_mu = 0.01 omega = 2 gain_omega = 0.001 omega_rel = 0.001 self.test = digital.mpsk_receiver_cc(M, theta, loop_bw, fmin, fmax, mu, gain_mu, omega, gain_omega, omega_rel) data = 10000*[complex( 0.707, 0.707), complex(-0.707, 0.707), complex(-0.707, -0.707), complex( 0.707, -0.707)] data = [0.5*d for d in data] self.src = blocks.vector_source_c(data, False) self.snk = blocks.vector_sink_c() # pulse shaping interpolation filter nfilts = 32 excess_bw = 0.35 ntaps = 11 * int(omega*nfilts) rrc_taps0 = filter.firdes.root_raised_cosine( nfilts, nfilts, 1.0, excess_bw, ntaps) rrc_taps1 = filter.firdes.root_raised_cosine( 1, omega, 1.0, excess_bw, 11*omega) self.rrc0 = filter.pfb_arb_resampler_ccf(omega, rrc_taps0) self.rrc1 = filter.fir_filter_ccf(1, rrc_taps1) self.tb.connect(self.src, self.rrc0, self.rrc1, self.test, self.snk) self.tb.run() expected_result = 10000*[complex(-0.5, +0.0), complex(+0.0, -0.5), complex(+0.5, +0.0), complex(+0.0, +0.5)] # get data after a settling period dst_data = self.snk.data()[200:] # Only compare last Ncmp samples Ncmp = 1000 len_e = len(expected_result) len_d = len(dst_data) expected_result = expected_result[len_e - Ncmp - 1:-1] dst_data = dst_data[len_d - Ncmp:] #for e,d in zip(expected_result, dst_data): # print "{0:+.02f} {1:+.02f}".format(e, d) self.assertComplexTuplesAlmostEqual(expected_result, dst_data, 1)
def __init__(self): gr.top_block.__init__(self, "Scanner Grc") ################################################## # Variables ################################################## self.f_symb = f_symb = 1625000.0/6.0 self.f_900_b = f_900_b = 921.2e6 self.samp_rate = samp_rate = f_symb*4 self.fs = fs = f_900_b self.f_900_e = f_900_e = 959.8e6 self.f_1800_e = f_1800_e = 1879.8e6 self.f_1800_b = f_1800_b = 1805.2e6 self.OSR = OSR = 4 ################################################## # Blocks ################################################## self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "bladerf=0" ) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(fs, 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(2, 0) self.osmosdr_source_0.set_gain_mode(True, 0) self.osmosdr_source_0.set_gain(30, 0) self.osmosdr_source_0.set_if_gain(30, 0) self.osmosdr_source_0.set_bb_gain(30, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(200000, 0) self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, samp_rate, 200e3, 10e3, firdes.WIN_HAMMING, 6.76)) self.threshold_result = blocks.threshold_ff(0, 0.2, 0) self.blocks_threshold_ff_0_0 = blocks.threshold_ff(0, 0, 0) self.blocks_threshold_ff_0 = blocks.threshold_ff(int((138)*samp_rate/f_symb), int((138)*samp_rate/f_symb), 0) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) self.blocks_moving_average_xx_0 = blocks.moving_average_ff(int((142)*samp_rate/f_symb), 1, int(1e6)) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, int(OSR)) self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1) ################################################## # Connections ################################################## self.connect((self.blocks_complex_to_arg_0, 0), (self.blocks_threshold_ff_0_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_threshold_ff_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_complex_to_arg_0, 0)) self.connect((self.blocks_threshold_ff_0, 0), (self.threshold_result, 0)) self.connect((self.blocks_threshold_ff_0_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.threshold_result, 0), (self.blocks_null_sink_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_delay_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.low_pass_filter_0, 0))
def reference_filter_ccf(dec, taps, input): """ compute result using conventional fir filter """ tb = gr.top_block() src = blocks.vector_source_c(input) op = filter.fir_filter_ccf(dec, taps) dst = blocks.vector_sink_c() tb.connect(src, op, dst) tb.run() return dst.data()
def __init__(self, win, sat_name, mode_name, sample_rate, frequency_offset, filename_raw, frequency, line1, line2, lat, lon, alt, when): gr.hier_block2.__init__(self, "Channel "+str(sat_name), gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(1, 1, gr.sizeof_gr_complex)) self.sample_rate = sample_rate self.freq_offset = frequency_offset self.fine_freq_offset = 0.0 self.fname = filename_raw self.decim = 8 if isinstance(when, dict): when = datetime.datetime(when['year'], when['month'], when['day'], when['hour'], when['minute'], when['second'], when['microsecond']) self.dop = doppler.doppler_c(line1, line2, frequency, self.sample_rate / self.decim, lat, lon, alt/1000.0, when.year, when.month, when.day, when.hour, when.minute, when.second, when.microsecond) self.mult2 = blocks.multiply_vcc(1) self.wxgui_fftsink0 = fftsink2.fft_sink_c( win, baseband_freq=0, y_per_div=5, y_divs=10, ref_level=-35, ref_scale=2.0, sample_rate=self.sample_rate/(self.decim), fft_size=1024, fft_rate=15, average=True, avg_alpha=None, title="FFT Plot (Downsampled - "+sat_name+" "+str(mode_name)+")", peak_hold=True, ) self.low_pass_filter = filter.fir_filter_ccf(self.decim, filter.firdes.low_pass(1, sample_rate, 120000, 5000, filter.firdes.WIN_HAMMING, 6.76)) self.sig_source = analog.sig_source_c(sample_rate, analog.GR_COS_WAVE, -(self.freq_offset + self.fine_freq_offset), 1, 0) self.mult1 = blocks.multiply_vcc(1) self.file_sink_raw = blocks.file_sink(gr.sizeof_gr_complex*1, str(filename_raw)) self.file_sink_raw.set_unbuffered(False) self.connect(self, (self.mult1, 0)) self.connect((self.sig_source, 0), (self.mult1, 1)) self.connect((self.mult1, 0), (self.low_pass_filter, 0)) self.connect((self.low_pass_filter, 0), (self.mult2, 0)) self.connect((self.dop, 0), (self.mult2, 1)) self.connect((self.mult2, 0), (self.file_sink_raw, 0)) self.connect((self.mult2, 0), (self.wxgui_fftsink0, 0)) self.connect((self.mult2, 0), self)
def run_fir_filters_ccf(self): self.blocks = [] self.tb = gr.top_block() self.blocks.append(blocks.null_source(gr.sizeof_gr_complex)) self.blocks.append(blocks.head(gr.sizeof_gr_complex, self.N)) # First filter is much larger than others taps = numpy.random.random(self.mult*self.ntaps) self.blocks.append(filter.fir_filter_ccf(1, taps)) # Set up mfirs filters with new taps for each filter for m in xrange(1, self.mfirs): taps = numpy.random.random(self.ntaps) self.blocks.append(filter.fir_filter_ccf(1, taps)) # Add a null sink self.blocks.append(blocks.null_sink(gr.sizeof_gr_complex)) # Connect the blocks and run self.tb.connect(*self.blocks) self.tb.run()
def __init__(self, wpm, tx_freq, if_gain, rf_amp, morse_vector): gr.top_block.__init__(self, "Top Block") ################################################## # Variables ################################################## self.wpm = wpm self.tx_freq = tx_freq - cw_tone_ofs self.rf_sample_rate = rf_sample_rate = 500000 self.morse_vector = morse_vector self.audio_rate = audio_rate = 8000 ################################################## # Blocks ################################################## 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_0 = filter.rational_resampler_ccc( interpolation=rf_sample_rate, decimation=audio_rate, taps=None, fractional_bw=None, ) self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + "" ) self.osmosdr_sink_0.set_sample_rate(rf_sample_rate) self.osmosdr_sink_0.set_center_freq(self.tx_freq, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) # OK, osmocom is incredibly stupid. It interprets "0" for these fields as "not set", #and defaults to an IF gain of +16 and turning the RF amp *ON*. # A value of "1" for the RF gain turns it off, and a value >=7 turns it on. # For IF gain, 0->16, 1..47 behave as you'd expect. This means IF gain=0 is impossible. self.osmosdr_sink_0.set_gain( 14 if rf_amp > 0 else 1, 0) self.osmosdr_sink_0.set_if_gain(if_gain if if_gain > 0 else 1, 0) self.osmosdr_sink_0.set_antenna("", 0) self.osmosdr_sink_0.set_bandwidth(0, 0) self.blocks_vector_source_x_0 = blocks.vector_source_c(morse_vector, False, 1, []) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex*1, int(1.2 * audio_rate / wpm)) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.analog_sig_source_x_0 = analog.sig_source_c(audio_rate, analog.GR_COS_WAVE, cw_tone_ofs, 1, 0) ################################################## # Connections ################################################## self.connect((self.rational_resampler_xxx_0, 0), (self.osmosdr_sink_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.root_raised_cosine_filter_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.rational_resampler_xxx_0, 0))
def __init__(self, decay=0.001, samp_rate=48000, attack=0.1, Frequency=1200): gr.hier_block2.__init__( self, "Detectmarkspace", gr.io_signature(1, 1, gr.sizeof_float*1), gr.io_signaturev(2, 2, [gr.sizeof_float*1, gr.sizeof_float*1]), ) ################################################## # Parameters ################################################## self.decay = decay self.samp_rate = samp_rate self.attack = attack self.Frequency = Frequency ################################################## # Variables ################################################## self.Baud = Baud = 1200 ################################################## # Blocks ################################################## self.root_raised_cosine_filter_0 = filter.fir_filter_ccf(1, firdes.root_raised_cosine( 1, samp_rate, Baud, 0.35, samp_rate/Baud)) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_null_source_0 = blocks.null_source(gr.sizeof_float*1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((0.5, )) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -Frequency, 1, 0) self.analog_agc2_xx_0 = analog.agc2_ff(attack, decay, 1.0, 1.0) self.analog_agc2_xx_0.set_max_gain(1.0) ################################################## # Connections ################################################## self.connect((self, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_complex_to_mag_0, 0), (self, 1)) self.connect((self.blocks_complex_to_mag_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.blocks_null_source_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_sub_xx_0, 0), (self, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.blocks_complex_to_mag_0, 0))
def test_fir_filter_ccf_002(self): decim = 4 taps = 20*[0.5, 0.5] src_data = 40*[1+1j, 2+2j, 3+3j, 4+4j] expected_data = fir_filter(src_data, taps, decim) src = blocks.vector_source_c(src_data) op = filter.fir_filter_ccf(decim, taps) dst = blocks.vector_sink_c() self.tb.connect(src, op, dst) self.tb.run() result_data = dst.data() self.assertComplexTuplesAlmostEqual(expected_data, result_data, 5)
def test01(self): # Test BPSK sync M = 2 theta = 0 loop_bw = cmath.pi/100.0 fmin = -0.5 fmax = 0.5 mu = 0.5 gain_mu = 0.01 omega = 2 gain_omega = 0.001 omega_rel = 0.001 self.test = digital.mpsk_receiver_cc(M, theta, loop_bw, fmin, fmax, mu, gain_mu, omega, gain_omega, omega_rel) data = 10000*[complex(1,0), complex(-1,0)] #data = [2*random.randint(0,1)-1 for x in xrange(10000)] self.src = blocks.vector_source_c(data, False) self.snk = blocks.vector_sink_c() # pulse shaping interpolation filter nfilts = 32 excess_bw = 0.35 ntaps = 11 * int(omega*nfilts) rrc_taps0 = filter.firdes.root_raised_cosine( nfilts, nfilts, 1.0, excess_bw, ntaps) rrc_taps1 = filter.firdes.root_raised_cosine( 1, omega, 1.0, excess_bw, 11*omega) self.rrc0 = filter.pfb_arb_resampler_ccf(omega, rrc_taps0) self.rrc1 = filter.fir_filter_ccf(1, rrc_taps1) self.tb.connect(self.src, self.rrc0, self.rrc1, self.test, self.snk) self.tb.run() expected_result = [-0.5*d for d in data] dst_data = self.snk.data() # Only Ncmp samples after Nstrt samples Nstrt = 9000 Ncmp = 1000 expected_result = expected_result[Nstrt:Nstrt+Ncmp] dst_data = dst_data[Nstrt:Nstrt+Ncmp] #for e,d in zip(expected_result, dst_data): # print "{0:+.02f} {1:+.02f}".format(e, d) self.assertComplexTuplesAlmostEqual(expected_result, dst_data, 1)
def __init__(self, ppm=0, osr=4, fc=940e6, samp_rate_in=1e6): gr.hier_block2.__init__( self, "GSM input adaptor", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signature(1, 1, gr.sizeof_gr_complex*1), ) ################################################## # Parameters ################################################## self.ppm = ppm self.osr = osr self.fc = fc self.samp_rate_in = samp_rate_in ################################################## # Variables ################################################## self.samp_rate_out = samp_rate_out = 1625000.0/6.0*osr ################################################## # Blocks ################################################## if version(gr.version()) >= version('3.7.9'): self.message_port_register_hier_in("ppm_in") else: self.message_port_register_hier_out("ppm_in") self.low_pass_filter_0_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, samp_rate_out, 125e3, 5e3, firdes.WIN_HAMMING, 6.76)) self.gsm_clock_offset_corrector_0 = grgsm.clock_offset_corrector( fc=fc, ppm=ppm, samp_rate_in=samp_rate_in, ) self.fractional_resampler_xx_0 = filter.fractional_resampler_cc(0, samp_rate_in/samp_rate_out) ################################################## # Connections ################################################## self.connect((self.low_pass_filter_0_0, 0), (self, 0)) self.connect((self.fractional_resampler_xx_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.gsm_clock_offset_corrector_0, 0), (self.fractional_resampler_xx_0, 0)) self.connect((self, 0), (self.gsm_clock_offset_corrector_0, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self, "ppm_in", self.gsm_clock_offset_corrector_0, "ppm_in")
def __init__(self, input_samp_rate, output_samp_rate): gr.hier_block2.__init__( self, "FM Block", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signature(1, 1, gr.sizeof_float*1), ) # Parameters self.input_samp_rate = input_samp_rate self.output_samp_rate = output_samp_rate self.decimation = decimation = 4 self.cutoff = cutoff = 100e3 self.transition = transition = 10e3 # Blocks self.rational_resampler_1 = filter.rational_resampler_ccc( interpolation=1, decimation=decimation, taps=None, fractional_bw=None, ) self.low_pass_filter = filter.fir_filter_ccf(1, filter.firdes.low_pass( 1, int(input_samp_rate/decimation), cutoff, transition, filter.firdes.WIN_HAMMING, 6.76)) self.fm_demodulator = analog.wfm_rcv( quad_rate=int(input_samp_rate/decimation), audio_decimation=1, ) self.rational_resampler_2 = filter.rational_resampler_fff( interpolation=output_samp_rate, decimation=int(input_samp_rate/decimation), taps=None, fractional_bw=None, ) self.multiply = blocks.multiply_const_vff((80,)) # Connections self.connect( self, self.rational_resampler_1, self.low_pass_filter, self.fm_demodulator, self.rational_resampler_2, self.multiply, self )
def __init__(self): gr.top_block.__init__(self, "Top Block") ################################################## # Variables ################################################## self.wpm = wpm = 15 self.tx_freq = tx_freq = 433.000e6 self.rf_sample_rate = rf_sample_rate = 250000 self.morse_vector = morse_vector = (1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0) self.audio_rate = audio_rate = 8000 ################################################## # Blocks ################################################## 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_0 = filter.rational_resampler_ccc( interpolation=rf_sample_rate, decimation=audio_rate, taps=None, fractional_bw=None, ) self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + "" ) self.osmosdr_sink_0.set_sample_rate(rf_sample_rate) self.osmosdr_sink_0.set_center_freq(tx_freq, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(0, 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.blocks_vector_source_x_0 = blocks.vector_source_c(morse_vector, False, 1, []) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex*1, int(1.2 * audio_rate / wpm)) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.analog_sig_source_x_0 = analog.sig_source_c(audio_rate, analog.GR_COS_WAVE, 1000, 1, 0) ################################################## # Connections ################################################## self.connect((self.rational_resampler_xxx_0, 0), (self.osmosdr_sink_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.root_raised_cosine_filter_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.rational_resampler_xxx_0, 0))
def __init__(self): gr.top_block.__init__(self) self._N = 10000000 # number of samples to use self._fs = 10000 # initial sampling rate self._decim = 20 # Decimation rate # Generate the prototype filter taps for the decimators with a 200 Hz bandwidth self._taps = filter.firdes.low_pass_2(1, self._fs, 200, 150, attenuation_dB=120, window=filter.firdes.WIN_BLACKMAN_hARRIS) # Calculate the number of taps per channel for our own information tpc = scipy.ceil(float(len(self._taps)) / float(self._decim)) print "Number of taps: ", len(self._taps) print "Number of filters: ", self._decim print "Taps per channel: ", tpc # Build the input signal source # We create a list of freqs, and a sine wave is generated and added to the source # for each one of these frequencies. self.signals = list() self.add = blocks.add_cc() freqs = [10, 20, 2040] for i in xrange(len(freqs)): self.signals.append(analog.sig_source_c(self._fs, analog.GR_SIN_WAVE, freqs[i], 1)) self.connect(self.signals[i], (self.add,i)) self.head = blocks.head(gr.sizeof_gr_complex, self._N) # Construct a PFB decimator filter self.pfb = filter.pfb.decimator_ccf(self._decim, self._taps, 0) # Construct a standard FIR decimating filter self.dec = filter.fir_filter_ccf(self._decim, self._taps) self.snk_i = blocks.vector_sink_c() # Connect the blocks self.connect(self.add, self.head, self.pfb) self.connect(self.add, self.snk_i) # Create the sink for the decimated siganl self.snk = blocks.vector_sink_c() self.connect(self.pfb, self.snk)
def test_002 (self): decim = 4 taps = 20*[0.5, 0.5] src_data = 40*[1+1j, 2+2j, 3+3j, 4+4j] src = blocks.vector_source_c(src_data) op1 = filter.fir_filter_ccf(decim, taps) op2 = liquiddsp.fir_filter(decim, taps) dst1 = blocks.vector_sink_c() dst2 = blocks.vector_sink_c() self.tb.connect(src, op1, dst1) self.tb.connect(src, op2, dst2) self.tb.run() expected_data = dst1.data() result_data = dst2.data() self.assertComplexTuplesAlmostEqual(expected_data, result_data, 5)
def run_fir_filters_ccf(self): self.blocks = [] self.tb = gr.top_block() self.blocks.append(blocks.null_source(gr.sizeof_gr_complex)) self.blocks.append(blocks.head(gr.sizeof_gr_complex, self.N)) # Set up mfirs filters with new taps for each filter for m in xrange(self.mfirs): taps = numpy.random.random(self.ntaps) self.blocks.append(filter.fir_filter_ccf(1, taps)) #self.blocks[m].set_processor_affinity([m,]) # Add a null sink self.blocks.append(blocks.null_sink(gr.sizeof_gr_complex)) # Connect the blocks and run self.tb.connect(*self.blocks) self.tb.run()
def test_fir_filter_ccf_002(self): src_data = 40*[1+1j, 2+2j, 3+3j, 4+4j] expected_data = ((0.5+0.5j), (5.5+5.5j), (10.5+10.5j), (15.5+15.5j), (20.5+20.5j), (25.5+25.5j), (30.5+30.5j), (35.5+35.5j), (40.5+40.5j), (45.5+45.5j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j)) src = blocks.vector_source_c(src_data) op = filter.fir_filter_ccf(4, 20*[0.5, 0.5]) dst = blocks.vector_sink_c() self.tb.connect(src, op, dst) self.tb.run() result_data = dst.data() self.assertComplexTuplesAlmostEqual(expected_data, result_data, 5)
def __init__(self, fc=940e6, osr=4, ppm=0, samp_rate_in=1e6): gr.hier_block2.__init__( self, "GSM input adaptor", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signature(1, 1, gr.sizeof_gr_complex*1), ) self.message_port_register_hier_in("ctrl_in") ################################################## # Parameters ################################################## self.fc = fc self.osr = osr self.ppm = ppm self.samp_rate_in = samp_rate_in ################################################## # Variables ################################################## self.gsm_symb_rate = gsm_symb_rate = 1625000.0/6.0 self.samp_rate_out = samp_rate_out = gsm_symb_rate*osr print "samp_rate_in ",samp_rate_in," samp_rate_out",samp_rate_out ################################################## # Blocks ################################################## self.low_pass_filter_0_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, samp_rate_out, 125e3, 5e3, firdes.WIN_HAMMING, 6.76)) self.gsm_clock_offset_corrector_tagged_0 = grgsm.clock_offset_corrector_tagged( fc=fc, samp_rate_in=samp_rate_in, ppm=ppm, osr=osr, ) ################################################## # Connections ################################################## self.msg_connect((self, 'ctrl_in'), (self.gsm_clock_offset_corrector_tagged_0, 'ctrl')) self.connect((self.gsm_clock_offset_corrector_tagged_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self, 0)) self.connect((self, 0), (self.gsm_clock_offset_corrector_tagged_0, 0))
def __init__(self): gr.hier_block2.__init__( self, "AM Chain", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signature(1, 1, gr.sizeof_float*1), ) ################################################## # Blocks ################################################## self.rational_resampler_xxx_1 = filter.rational_resampler_ccc( interpolation=2, decimation=75, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=3, decimation=4, taps=None, fractional_bw=None, ) self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, 64000, 5000, 100, firdes.WIN_HAMMING, 6.76)) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((5, )) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.analog_agc2_xx_0 = analog.agc2_ff(6.25e-4, 1e-5, .2, 1.0) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.low_pass_filter_0, 0))
def test_fir_filter_ccf_001(self): src_data = 40*[1+1j, 2+2j, 3+3j, 4+4j] expected_data = ((0.5+0.5j), (1.5+1.5j), (3+3j), (5+5j), (5.5+5.5j), (6.5+6.5j), (8+8j), (10+10j), (10.5+10.5j), (11.5+11.5j), (13+13j), (15+15j), (15.5+15.5j), (16.5+16.5j), (18+18j), (20+20j), (20.5+20.5j), (21.5+21.5j), (23+23j), (25+25j), (25.5+25.5j), (26.5+26.5j), (28+28j), (30+30j), (30.5+30.5j), (31.5+31.5j), (33+33j), (35+35j), (35.5+35.5j), (36.5+36.5j), (38+38j), (40+40j), (40.5+40.5j), (41.5+41.5j), (43+43j), (45+45j), (45.5+45.5j), (46.5+46.5j), (48+48j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j), (50+50j)) src = blocks.vector_source_c(src_data) op = filter.fir_filter_ccf(1, 20*[0.5, 0.5]) dst = blocks.vector_sink_c() self.tb.connect(src, op, dst) self.tb.run() result_data = dst.data() self.assertComplexTuplesAlmostEqual(expected_data, result_data, 5)
def __init__(self): gr.top_block.__init__(self, "Gsm Meta Capture") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1e6 ################################################## # 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(906.2e6, 0) self.uhd_usrp_source_0.set_gain(10, 0) self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff(.0001, 1) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_float*1, 13300) self.blocks_file_meta_sink_0 = blocks.file_meta_sink(gr.sizeof_float*1, "meta_signal.bin", samp_rate, 1, blocks.GR_FILE_FLOAT, False, 10, "", False) self.blocks_file_meta_sink_0.set_unbuffered(False) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.band_pass_filter_0 = filter.fir_filter_ccf(1, firdes.band_pass( 1, samp_rate, 100e3, 300e3, 200, firdes.WIN_HAMMING, 6.76)) ################################################## # Connections ################################################## self.connect((self.band_pass_filter_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.single_pole_iir_filter_xx_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.blocks_file_meta_sink_0, 0)) self.connect((self.single_pole_iir_filter_xx_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.band_pass_filter_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Fm Radio") ################################################## # Variables ################################################## self.sec_delay = sec_delay = 1 self.samp_rate = samp_rate = 5e6 self.channel_width = channel_width = 200e3 self.channel_freq = channel_freq = 96.9e6 self.center_freq = center_freq = 97.9e6 self.audio_gain = audio_gain = 1 ################################################## # Blocks ################################################## _sec_delay_sizer = wx.BoxSizer(wx.VERTICAL) self._sec_delay_text_box = forms.text_box( parent=self.GetWin(), sizer=_sec_delay_sizer, value=self.sec_delay, callback=self.set_sec_delay, label="Delay (sec)", converter=forms.float_converter(), proportion=0, ) self._sec_delay_slider = forms.slider( parent=self.GetWin(), sizer=_sec_delay_sizer, value=self.sec_delay, callback=self.set_sec_delay, minimum=0, maximum=10, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_sec_delay_sizer) _channel_freq_sizer = wx.BoxSizer(wx.VERTICAL) self._channel_freq_text_box = forms.text_box( parent=self.GetWin(), sizer=_channel_freq_sizer, value=self.channel_freq, callback=self.set_channel_freq, label="Channel Freq (Hz)", converter=forms.float_converter(), proportion=0, ) self._channel_freq_slider = forms.slider( parent=self.GetWin(), sizer=_channel_freq_sizer, value=self.channel_freq, callback=self.set_channel_freq, minimum=87.9e6, maximum=107.9e6, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_channel_freq_sizer) _audio_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._audio_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_audio_gain_sizer, value=self.audio_gain, callback=self.set_audio_gain, label="Audio Gain", converter=forms.float_converter(), proportion=0, ) self._audio_gain_slider = forms.slider( parent=self.GetWin(), sizer=_audio_gain_sizer, value=self.audio_gain, callback=self.set_audio_gain, minimum=0, maximum=5, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_audio_gain_sizer) self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=center_freq, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=True, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0_0.win) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=12, decimation=5, taps=None, fractional_bw=None, ) 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(center_freq, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(2, 0) self.osmosdr_source_0.set_iq_balance_mode(2, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(0, 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.low_pass_filter_0 = filter.fir_filter_ccf(int(samp_rate / channel_width), firdes.low_pass( 1, samp_rate, 75e3, 25e3, firdes.WIN_HAMMING, 6.76)) self.blocks_wavfile_sink_0 = blocks.wavfile_sink("radio_recording.wav", 1, int(48e3), 8) self.blocks_multiply_xx_1 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((audio_gain, )) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_float*1, "radio_samples", False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, int(480000 * sec_delay)) self.audio_sink_0 = audio.sink(48000, "", True) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=480e3, audio_decimation=10, ) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, center_freq - channel_freq, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_wfm_rcv_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_xx_1, 0)) 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_file_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.analog_wfm_rcv_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.wxgui_fftsink2_0_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_delay_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_xx_1, 1))
def __init__(self, args): gr.top_block.__init__(self, "Top Block") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 48000 self.seed = seed = args.seed self.m_rate = m_rate = args.m_rate self.if_rate = if_rate = samp_rate * 40 self.gauss = gauss = args.gauss self.fc = fc = args.fc self.dpp = dpp = args.dop ################################################## # Blocks ################################################## self.rational_resampler_xxx_0_1 = filter.rational_resampler_fff( interpolation=3, decimation=1, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0_0 = filter.rational_resampler_fff( interpolation=40, decimation=1, taps=None, fractional_bw=None, ) self.low_pass_filter_1_0 = filter.fir_filter_fff( 40, firdes.low_pass(1, if_rate, 7500, 100, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_1 = filter.fir_filter_fff( 40, firdes.low_pass(1, if_rate, 7500, 100, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.interp_fir_filter_fff( 1, firdes.low_pass(1, samp_rate, 7500, 100, firdes.WIN_HAMMING, 6.76)) self.hilbert_fc_0 = filter.hilbert_fc(301, firdes.WIN_HAMMING, 6.76) self.high_pass_filter_0_1 = filter.fir_filter_fff( 1, firdes.high_pass(1, samp_rate, 50, 10, firdes.WIN_HAMMING, 6.76)) self.high_pass_filter_0_0_0_0 = filter.fir_filter_fff( 1, firdes.high_pass(1, samp_rate, 50, 10, firdes.WIN_HAMMING, 6.76)) self.high_pass_filter_0_0_0 = filter.fir_filter_fff( 1, firdes.high_pass(1, samp_rate, 50, 10, firdes.WIN_HAMMING, 6.76)) self.high_pass_filter_0_0 = filter.fir_filter_fff( 1, firdes.high_pass(1, samp_rate, 50, 10, firdes.WIN_HAMMING, 6.76)) self.high_pass_filter_0 = filter.fir_filter_fff( 1, firdes.high_pass(1, samp_rate, 50, 10, firdes.WIN_HAMMING, 6.76)) self.channels_fading_model_0 = channels.fading_model( 8, dpp / if_rate, True, 2, 256) self.blocks_wavfile_source_0 = blocks.wavfile_source(file1, False) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1, samp_rate, True) self.blocks_multiply_xx_1_0 = blocks.multiply_vff(1) self.blocks_multiply_xx_1 = blocks.multiply_vff(1) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((0, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( (m_rate, )) self.blocks_file_sink_0_5 = blocks.file_sink(gr.sizeof_float * 1, file2, False) self.blocks_file_sink_0_5.set_unbuffered(False) self.blocks_file_sink_0_4 = blocks.file_sink(gr.sizeof_float * 1, file3, False) self.blocks_file_sink_0_4.set_unbuffered(False) self.blocks_file_sink_0_3 = blocks.file_sink(gr.sizeof_float * 1, file4, False) self.blocks_file_sink_0_3.set_unbuffered(False) self.blocks_file_sink_0_2 = blocks.file_sink(gr.sizeof_float * 1, file5, False) self.blocks_file_sink_0_2.set_unbuffered(False) self.blocks_file_sink_0_1 = blocks.file_sink(gr.sizeof_float * 1, file6, False) self.blocks_file_sink_0_1.set_unbuffered(False) self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_float * 1, file7, False) self.blocks_file_sink_0_0.set_unbuffered(False) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_float * 1, file8, False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_complex_to_real_0_0 = blocks.complex_to_real(1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_add_xx_0_0_0 = blocks.add_vcc(1) self.blocks_add_xx_0_0 = blocks.add_vcc(1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.blocks_add_const_vxx_0 = blocks.add_const_vff((1, )) self.band_pass_filter_0_1 = filter.fir_filter_ccf( 1, firdes.band_pass(4, if_rate, fc - 7.5e3, fc + 7.5e3, 100, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0_0_0_0 = filter.fir_filter_ccf( 1, firdes.band_pass(4, if_rate, fc - 7.5e3, fc + 7.5e3, 100, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0_0_0 = filter.fir_filter_ccf( 1, firdes.band_pass(4, if_rate, fc - 7.5e3, fc + 7.5e3, 100, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0_0 = filter.fir_filter_ccf( 1, firdes.band_pass(4, if_rate, fc - 7.5e3, fc + 7.5e3, 100, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.band_pass(4, if_rate, fc - 7.5e3, fc + 7.5e3, 100, firdes.WIN_HAMMING, 6.76)) self.analog_sig_source_x_0_0 = analog.sig_source_f( if_rate, analog.GR_COS_WAVE, fc, 1, 0) self.analog_fastnoise_source_x_0 = analog.fastnoise_source_c( analog.GR_GAUSSIAN, gauss, seed, 8192) self.analog_am_demod_cf_0_1 = analog.am_demod_cf( channel_rate=fc, audio_decim=40, audio_pass=7500, audio_stop=10e3, ) self.analog_am_demod_cf_0_0_0_0 = analog.am_demod_cf( channel_rate=fc, audio_decim=40, audio_pass=7500, audio_stop=10e3, ) self.analog_am_demod_cf_0_0_0 = analog.am_demod_cf( channel_rate=fc, audio_decim=40, audio_pass=7500, audio_stop=10e3, ) self.analog_am_demod_cf_0_0 = analog.am_demod_cf( channel_rate=fc, audio_decim=40, audio_pass=7500, audio_stop=10e3, ) self.analog_am_demod_cf_0 = analog.am_demod_cf( channel_rate=fc, audio_decim=40, audio_pass=7500, audio_stop=10e3, ) ################################################## # Connections ################################################## self.connect((self.analog_am_demod_cf_0, 0), (self.high_pass_filter_0, 0)) self.connect((self.analog_am_demod_cf_0_0, 0), (self.high_pass_filter_0_0, 0)) self.connect((self.analog_am_demod_cf_0_0_0, 0), (self.high_pass_filter_0_0_0, 0)) self.connect((self.analog_am_demod_cf_0_0_0_0, 0), (self.high_pass_filter_0_0_0_0, 0)) self.connect((self.analog_am_demod_cf_0_1, 0), (self.high_pass_filter_0_1, 0)) self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_add_xx_0_0, 1)) self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_add_xx_0_0_0, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_1_0, 1)) self.connect((self.band_pass_filter_0, 0), (self.analog_am_demod_cf_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.blocks_complex_to_real_0_0, 0)) self.connect((self.band_pass_filter_0_0, 0), (self.analog_am_demod_cf_0_0, 0)) self.connect((self.band_pass_filter_0_0_0, 0), (self.analog_am_demod_cf_0_0_0, 0)) self.connect((self.band_pass_filter_0_0_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.band_pass_filter_0_0_0_0, 0), (self.analog_am_demod_cf_0_0_0_0, 0)) self.connect((self.band_pass_filter_0_1, 0), (self.analog_am_demod_cf_0_1, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.blocks_add_xx_0_0, 0), (self.band_pass_filter_0_1, 0)) self.connect((self.blocks_add_xx_0_0_0, 0), (self.band_pass_filter_0_0_0_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.blocks_complex_to_real_0_0, 0), (self.blocks_multiply_xx_1_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_add_xx_0_0_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.hilbert_fc_0, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.low_pass_filter_1, 0)) self.connect((self.blocks_multiply_xx_1_0, 0), (self.low_pass_filter_1_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.rational_resampler_xxx_0_1, 0)) self.connect((self.channels_fading_model_0, 0), (self.band_pass_filter_0_0_0, 0)) self.connect((self.channels_fading_model_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.channels_fading_model_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.high_pass_filter_0, 0), (self.blocks_file_sink_0_5, 0)) self.connect((self.high_pass_filter_0_0, 0), (self.blocks_file_sink_0_3, 0)) self.connect((self.high_pass_filter_0_0_0, 0), (self.blocks_file_sink_0_2, 0)) self.connect((self.high_pass_filter_0_0_0_0, 0), (self.blocks_file_sink_0_1, 0)) self.connect((self.high_pass_filter_0_1, 0), (self.blocks_file_sink_0_4, 0)) self.connect((self.hilbert_fc_0, 0), (self.band_pass_filter_0_0, 0)) self.connect((self.hilbert_fc_0, 0), (self.blocks_add_xx_0_0, 0)) self.connect((self.hilbert_fc_0, 0), (self.channels_fading_model_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.blocks_file_sink_0, 0)) self.connect((self.low_pass_filter_1_0, 0), (self.blocks_file_sink_0_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.rational_resampler_xxx_0_1, 0), (self.low_pass_filter_0, 0))
def __init__(self): gr.top_block.__init__(self, "TJ Cubesat No Gui with IQ streaming") ################################################## # Variables ################################################## self.interp = interp = 4 self.audio_rate = audio_rate = 48000 self.tx_gain = tx_gain = 10 self.rx_downsamp_bw = rx_downsamp_bw = 10000 self.rf_tx_rate = rf_tx_rate = audio_rate * interp self.rf_rx_rate = rf_rx_rate = 192000 self.preamble_len = preamble_len = 300 self.gain = gain = 40 self.freq = freq = 144.39e6 self.cubesat_zmq_port_4 = cubesat_zmq_port_4 = "5504" self.cubesat_zmq_port_3 = cubesat_zmq_port_3 = "5503" self.cubesat_zmq_port_2 = cubesat_zmq_port_2 = "5502" self.cubesat_zmq_port_1 = cubesat_zmq_port_1 = "5501" self.cubesat_port_2 = cubesat_port_2 = "5558" self.cubesat_port_1 = cubesat_port_1 = "5556" self.cubesat_ext_ip_addr = cubesat_ext_ip_addr = "192.168.1.10" self.baud_rate = baud_rate = 1200 self.audio_line_driver = audio_line_driver = .8 self.Decay = Decay = 0.8 self.Attack = Attack = 0.8 ################################################## # Blocks ################################################## self.zeromq_push_sink_0_0_0_0 = zeromq.push_sink( gr.sizeof_float, 1, "tcp://" + cubesat_ext_ip_addr + ":" + cubesat_zmq_port_4, 100, False, -1) self.zeromq_push_sink_0_0_0 = zeromq.push_sink( gr.sizeof_float, 1, "tcp://" + cubesat_ext_ip_addr + ":" + cubesat_zmq_port_3, 100, False, -1) self.zeromq_push_sink_0_0 = zeromq.push_sink( gr.sizeof_gr_complex, 1, "tcp://" + cubesat_ext_ip_addr + ":" + cubesat_zmq_port_2, 100, False, -1) self.zeromq_push_sink_0 = zeromq.push_sink( gr.sizeof_gr_complex, 1, "tcp://" + cubesat_ext_ip_addr + ":" + cubesat_zmq_port_1, 100, False, -1) self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer( ('', 1234), allow_none=True) self.xmlrpc_server_0.register_instance(self) self.xmlrpc_server_0_thread = threading.Thread( target=self.xmlrpc_server_0.serve_forever) self.xmlrpc_server_0_thread.daemon = True self.xmlrpc_server_0_thread.start() 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(rf_rx_rate) self.uhd_usrp_source_0.set_center_freq(freq, 0) self.uhd_usrp_source_0.set_gain(gain, 0) self.uhd_usrp_source_0.set_antenna('RX2', 0) self.uhd_usrp_source_0.set_bandwidth(rf_rx_rate, 0) self.uhd_usrp_sink_0_1 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0_1.set_samp_rate(rf_tx_rate) self.uhd_usrp_sink_0_1.set_center_freq(freq, 0) self.uhd_usrp_sink_0_1.set_gain(tx_gain, 0) self.uhd_usrp_sink_0_1.set_antenna('TX/RX', 0) self.uhd_usrp_sink_0_1.set_bandwidth(rf_tx_rate, 0) self.rational_resampler_xxx_0_0_0 = filter.rational_resampler_ccc( interpolation=4, decimation=1, taps=None, fractional_bw=None, ) self.low_pass_filter_0 = filter.fir_filter_ccf( 4, firdes.low_pass(1, rf_rx_rate, rx_downsamp_bw / 2, 1000, firdes.WIN_HAMMING, 6.76)) self.detectMarkSpace_1_0 = detectMarkSpace( Frequency=2200, attack=Attack, decay=Decay, samp_rate=audio_rate, ) self.detectMarkSpace_0_0 = detectMarkSpace( Frequency=1200, attack=Attack, decay=Decay, samp_rate=audio_rate, ) self.bruninga_str_to_aprs_0_1 = bruninga.str_to_aprs( 'KN4DTQ', 'KN4DTQ', []) self.bruninga_ax25_fsk_mod_0_0 = bruninga.ax25_fsk_mod( audio_rate, preamble_len, 5, 2200, 1200, baud_rate) self.blocks_udp_sink_0_0 = blocks.udp_sink(gr.sizeof_char * 1, '127.0.0.1', int(cubesat_port_1), 1472, True) self.blocks_sub_xx_0_0_0 = blocks.sub_ff(1) self.blocks_socket_pdu_0_0_0_0 = blocks.socket_pdu( "UDP_SERVER", '127.0.0.1', cubesat_port_2, 10000, False) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff( (audio_line_driver, )) self.analog_nbfm_tx_0_0 = analog.nbfm_tx( audio_rate=audio_rate, quad_rate=audio_rate, tau=75e-6, max_dev=5e3, fh=-1.0, ) self.analog_nbfm_rx_0 = analog.nbfm_rx( audio_rate=audio_rate, quad_rate=audio_rate, tau=75e-6, max_dev=5e3, ) self.afsk_ax25decode_1 = afsk.ax25decode(audio_rate, 1) ################################################## # Connections ################################################## self.msg_connect((self.blocks_socket_pdu_0_0_0_0, 'pdus'), (self.bruninga_str_to_aprs_0_1, 'in')) self.msg_connect((self.bruninga_str_to_aprs_0_1, 'out'), (self.bruninga_ax25_fsk_mod_0_0, 'in')) self.connect((self.afsk_ax25decode_1, 0), (self.blocks_udp_sink_0_0, 0)) self.connect((self.analog_nbfm_rx_0, 0), (self.detectMarkSpace_0_0, 0)) self.connect((self.analog_nbfm_rx_0, 0), (self.detectMarkSpace_1_0, 0)) self.connect((self.analog_nbfm_rx_0, 0), (self.zeromq_push_sink_0_0_0, 0)) self.connect((self.analog_nbfm_tx_0_0, 0), (self.rational_resampler_xxx_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.analog_nbfm_tx_0_0, 0)) self.connect((self.blocks_sub_xx_0_0_0, 0), (self.afsk_ax25decode_1, 0)) self.connect((self.bruninga_ax25_fsk_mod_0_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.bruninga_ax25_fsk_mod_0_0, 0), (self.zeromq_push_sink_0_0_0_0, 0)) self.connect((self.detectMarkSpace_0_0, 0), (self.blocks_sub_xx_0_0_0, 0)) self.connect((self.detectMarkSpace_1_0, 0), (self.blocks_sub_xx_0_0_0, 1)) self.connect((self.low_pass_filter_0, 0), (self.analog_nbfm_rx_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.zeromq_push_sink_0, 0)) self.connect((self.rational_resampler_xxx_0_0_0, 0), (self.uhd_usrp_sink_0_1, 0)) self.connect((self.rational_resampler_xxx_0_0_0, 0), (self.zeromq_push_sink_0_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_0, 0))
def __init__(self, control): self.ctl = control gr.top_block.__init__(self, "Fmrx") Qt.QWidget.__init__(self) self.setWindowTitle("Fmrx") 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", "fmRX") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.volume = volume = 1 self.swap__ = swap__ = 0 self.samp_in = samp_in = 10e6 self.ptl = ptl = 1 self.freq = freq = 103.7e6 self.die__ = die__ = 0 self.chan_width = chan_width = 200e3 ################################################## # Blocks ################################################## self._volume_range = Range(0, 100, 1, 1, 200) self._volume_win = RangeWidget(self._volume_range, self.set_volume, "volume", "counter_slider", float) self.top_layout.addWidget(self._volume_win) _ptl_check_box = Qt.QCheckBox("Mute") self._ptl_choices = {True: 0, False: 1} self._ptl_choices_inv = dict( (v, k) for k, v in self._ptl_choices.iteritems()) self._ptl_callback = lambda i: Qt.QMetaObject.invokeMethod( _ptl_check_box, "setChecked", Qt.Q_ARG("bool", self._ptl_choices_inv[i])) self._ptl_callback(self.ptl) _ptl_check_box.stateChanged.connect( lambda i: self.set_ptl(self._ptl_choices[bool(i)])) self.top_layout.addWidget(_ptl_check_box) self._freq_range = Range(88e6, 108e6, 100e3, 103.7e6, 200) self._freq_win = RangeWidget(self._freq_range, self.set_freq, "Frequency Slider", "counter_slider", float) self.top_layout.addWidget(self._freq_win) _swap___push_button = Qt.QPushButton("Switch to TX") self._swap___choices = {'Pressed': 1, 'Released': 0} _swap___push_button.pressed.connect( lambda: self.set_swap__(self._swap___choices['Pressed'])) _swap___push_button.released.connect( lambda: self.set_swap__(self._swap___choices['Released'])) self.top_layout.addWidget(_swap___push_button) self.rational_resampler_xxx_1 = filter.rational_resampler_ccc( interpolation=12, decimation=5, taps=None, fractional_bw=None, ) self.qtgui_sink_x_1 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype freq, #fc samp_in, #bw "", #name True, #plotfreq True, #plotwaterfall True, #plottime True, #plotconst ) self.qtgui_sink_x_1.set_update_time(1.0 / 10) self._qtgui_sink_x_1_win = sip.wrapinstance( self.qtgui_sink_x_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_sink_x_1_win) self.qtgui_sink_x_1.enable_rf_freq(True) self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + "") self.osmosdr_source_0.set_sample_rate(samp_in) self.osmosdr_source_0.set_center_freq(freq, 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(0, 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.low_pass_filter_0 = filter.fir_filter_ccf( int(10e6 / chan_width), firdes.low_pass(1, 10e6, 75e3, 25e3, firdes.WIN_HAMMING, 6.76)) _die___push_button = Qt.QPushButton("GUI Kill") self._die___choices = {'Pressed': 1, 'Released': 0} _die___push_button.pressed.connect( lambda: self.set_die__(self._die___choices['Pressed'])) _die___push_button.released.connect( lambda: self.set_die__(self._die___choices['Released'])) self.top_layout.addWidget(_die___push_button) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( (volume, )) self.audio_stop = blocks.multiply_const_vff((ptl, )) self.audio_sink_0 = audio.sink(48000, "", True) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=480e3, audio_decimation=10, ) self.analog_sig_source_x_0 = analog.sig_source_c( samp_in, analog.GR_COS_WAVE, 1000, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_wfm_rcv_0, 0), (self.audio_stop, 0)) self.connect((self.audio_stop, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.qtgui_sink_x_1, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.analog_wfm_rcv_0, 0))
def __init__(self): gr.top_block.__init__(self, "Receives ax.25/ aprs packets") Qt.QWidget.__init__(self) self.setWindowTitle("Receives ax.25/ aprs packets") 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", "APRS") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 192000 self.Modus = Modus = 144800 self.IFGain = IFGain = 7 self.FrequencyOffset = FrequencyOffset = 10 self.Frequency = Frequency = 97000 self.Decim = Decim = 4 self.Decay = Decay = 0.1 self.Attack = Attack = 0.8 ################################################## # Blocks ################################################## self._Modus_options = ( 144800, 145819, ) self._Modus_labels = ( 'APRS', 'ISS', ) self._Modus_tool_bar = Qt.QToolBar(self) self._Modus_tool_bar.addWidget(Qt.QLabel("Modus" + ": ")) self._Modus_combo_box = Qt.QComboBox() self._Modus_tool_bar.addWidget(self._Modus_combo_box) for label in self._Modus_labels: self._Modus_combo_box.addItem(label) self._Modus_callback = lambda i: Qt.QMetaObject.invokeMethod( self._Modus_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._Modus_options.index(i))) self._Modus_callback(self.Modus) self._Modus_combo_box.currentIndexChanged.connect( lambda i: self.set_Modus(self._Modus_options[i])) self.top_grid_layout.addWidget(self._Modus_tool_bar, 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) self._FrequencyOffset_range = Range(-20, 20, 1, 10, 200) self._FrequencyOffset_win = RangeWidget(self._FrequencyOffset_range, self.set_FrequencyOffset, "FrequencyOffset", "counter", float) self.top_grid_layout.addWidget(self._FrequencyOffset_win, 0, 2, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.Display = Qt.QTabWidget() self.Display_widget_0 = Qt.QWidget() self.Display_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.Display_widget_0) self.Display_grid_layout_0 = Qt.QGridLayout() self.Display_layout_0.addLayout(self.Display_grid_layout_0) self.Display.addTab(self.Display_widget_0, 'Settings') self.Display_widget_1 = Qt.QWidget() self.Display_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.Display_widget_1) self.Display_grid_layout_1 = Qt.QGridLayout() self.Display_layout_1.addLayout(self.Display_grid_layout_1) self.Display.addTab(self.Display_widget_1, 'Results') self.top_grid_layout.addWidget(self.Display, 1, 0, 1, 3) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 3): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / 4, #bw 'QT GUI Plot', #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.10) self.qtgui_waterfall_sink_x_0.enable_grid(False) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) 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) self.qtgui_sink_x_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype (Modus - FrequencyOffset) * 1000, #fc samp_rate, #bw 'QT GUI Plot', #name True, #plotfreq True, #plotwaterfall False, #plottime False, #plotconst ) self.qtgui_sink_x_0.set_update_time(1.0 / 10) self._qtgui_sink_x_0_win = sip.wrapinstance( self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget) self.Display_grid_layout_0.addWidget(self._qtgui_sink_x_0_win, 2, 0, 1, 1) for r in range(2, 3): self.Display_grid_layout_0.setRowStretch(r, 1) for c in range(0, 1): self.Display_grid_layout_0.setColumnStretch(c, 1) self.qtgui_sink_x_0.enable_rf_freq(True) self.low_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate / 4, 4900, 1000, firdes.WIN_HAMMING, 6.76)) self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_char * 1, '', 5577, 1472, True) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_gr_complex * 1, '/home/ben-mccall/Desktop/flowgraphs/vhf_noaa_captures/capture1', True) self.band_pass_filter_1 = filter.fir_filter_ccc( 4, firdes.complex_band_pass(4, samp_rate, FrequencyOffset * 500, FrequencyOffset * 500 + 10000, 300, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0_0 = filter.fir_filter_fff( 1, firdes.band_pass(1, samp_rate / Decim, 950, 2450, 100, firdes.WIN_HAMMING, 6.76)) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate / 4, analog.GR_COS_WAVE, -10000, 1, 0) self.analog_quadrature_demod_cf_0_0 = analog.quadrature_demod_cf(1) self.afsk_afsk1200_0 = afsk.afsk1200(samp_rate / Decim, 4) self._IFGain_range = Range(1, 25, 1, 7, 200) self._IFGain_win = RangeWidget(self._IFGain_range, self.set_IFGain, "IFGain", "counter", int) self.top_grid_layout.addWidget(self._IFGain_win, 0, 1, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) ################################################## # Connections ################################################## self.connect((self.afsk_afsk1200_0, 0), (self.blocks_udp_sink_0, 0)) self.connect((self.analog_quadrature_demod_cf_0_0, 0), (self.band_pass_filter_0_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, 0), (self.afsk_afsk1200_0, 0)) self.connect((self.band_pass_filter_1, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.band_pass_filter_1, 0)) self.connect((self.blocks_file_source_0, 0), (self.qtgui_sink_x_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_quadrature_demod_cf_0_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
def graph(args): print os.getpid() nargs = len(args) if nargs == 2: infile = args[0] outfile = args[1] else: raise ValueError('usage: interp.py input_file output_file.ts\n') input_rate = 19.2e6 IF_freq = 5.75e6 tb = gr.top_block() # Read from input file srcf = blocks.file_source(gr.sizeof_short, infile) # Convert interleaved shorts (I,Q,I,Q) to complex is2c = blocks.interleaved_short_to_complex() # 1/2 as wide because we're designing lp filter symbol_rate = atsc.ATSC_SYMBOL_RATE / 2. NTAPS = 279 tt = filter.firdes.root_raised_cosine(1.0, input_rate / 3, symbol_rate, .1152, NTAPS) rrc = filter.fir_filter_ccf(1, tt) # Interpolate Filter our 6MHz wide signal centered at 0 ilp_coeffs = filter.firdes.low_pass(1, input_rate, 3.2e6, .5e6, filter.firdes.WIN_HAMMING) ilp = filter.interp_fir_filter_ccf(3, ilp_coeffs) # Move the center frequency to 5.75MHz ( this wont be needed soon ) duc_coeffs = filter.firdes.low_pass(1, 19.2e6, 9e6, 1e6, filter.firdes.WIN_HAMMING) duc = filter.freq_xlating_fir_filter_ccf(1, duc_coeffs, -5.75e6, 19.2e6) # fpll input is float c2f = blocks.complex_to_float() # Phase locked loop fpll = atsc.fpll() # Clean fpll output lp_coeffs2 = filter.firdes.low_pass(1.0, input_rate, 5.75e6, 120e3, filter.firdes.WIN_HAMMING) lp_filter = filter.fir_filter_fff(1, lp_coeffs2) # Remove pilot ( at DC now ) iir = filter.single_pole_iir_filter_ff(1e-5) remove_dc = blocks.sub_ff() # Bit Timing Loop, Field Sync Checker and Equalizer btl = atsc.bit_timing_loop() fsc = atsc.fs_checker() eq = atsc.equalizer() fsd = atsc.field_sync_demux() # Viterbi viterbi = atsc.viterbi_decoder() deinter = atsc.deinterleaver() rs_dec = atsc.rs_decoder() derand = atsc.derandomizer() depad = atsc.depad() # Write to output file outf = blocks.file_sink(gr.sizeof_char, outfile) # Connect it all together tb.connect(srcf, is2c, rrc, ilp, duc, c2f, fpll, lp_filter) tb.connect(lp_filter, iir) tb.connect(lp_filter, (remove_dc, 0)) tb.connect(iir, (remove_dc, 1)) tb.connect(remove_dc, btl) tb.connect((btl, 0), (fsc, 0), (eq, 0), (fsd, 0)) tb.connect((btl, 1), (fsc, 1), (eq, 1), (fsd, 1)) tb.connect(fsd, viterbi, deinter, rs_dec, derand, depad, outf) tb.run()
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 = 4000000 ################################################## # Blocks ################################################## self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=12, decimation=5, taps=None, fractional_bw=None, ) self.qtgui_sink_x_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 102500000, #fc 20000, #bw "", #name True, #plotfreq True, #plotwaterfall True, #plottime True, #plotconst ) self.qtgui_sink_x_0.set_update_time(1.0 / 5) self._qtgui_sink_x_0_win = sip.wrapinstance( self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_sink_x_0_win) self.qtgui_sink_x_0.enable_rf_freq(True) self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + 'hackrf=0') self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(102500000, 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(2, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(0, 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.low_pass_filter_0 = filter.fir_filter_ccf( 20, firdes.low_pass(1, samp_rate, 75000, 25000, firdes.WIN_HAMMING, 6.76)) self.dc_blocker_xx_0 = filter.dc_blocker_cc(1024, True) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((100, )) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_file_sink_0 = blocks.file_sink( gr.sizeof_gr_complex * 1, 'C:\\Users\\patel\\Desktop\\CS 491\\print_test2.dat', False) self.blocks_file_sink_0.set_unbuffered(True) self.blocks_deinterleave_0 = blocks.deinterleave( gr.sizeof_float * 1, 1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.audio_sink_0 = audio.sink(48000, '', True) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=480000, audio_decimation=10, ) ################################################## # Connections ################################################## self.connect((self.analog_wfm_rcv_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_deinterleave_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_deinterleave_0, 1), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_deinterleave_0, 0)) self.connect((self.dc_blocker_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.dc_blocker_xx_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.qtgui_sink_x_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.analog_wfm_rcv_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="FM receiver") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 2e6 self.down_rate = down_rate = 150e3 self.VOLUMEN = VOLUMEN = 70 self.SINTONIZADOR = SINTONIZADOR = 90.1e6 self.GANANCIA = GANANCIA = 50 ################################################## # Blocks ################################################## _VOLUMEN_sizer = wx.BoxSizer(wx.VERTICAL) self._VOLUMEN_text_box = forms.text_box( parent=self.GetWin(), sizer=_VOLUMEN_sizer, value=self.VOLUMEN, callback=self.set_VOLUMEN, label='Ajuste de sonido', converter=forms.float_converter(), proportion=0, ) self._VOLUMEN_slider = forms.slider( parent=self.GetWin(), sizer=_VOLUMEN_sizer, value=self.VOLUMEN, callback=self.set_VOLUMEN, minimum=0, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_VOLUMEN_sizer, 1, 5, 1, 8) _SINTONIZADOR_sizer = wx.BoxSizer(wx.VERTICAL) self._SINTONIZADOR_text_box = forms.text_box( parent=self.GetWin(), sizer=_SINTONIZADOR_sizer, value=self.SINTONIZADOR, callback=self.set_SINTONIZADOR, label='Sintonizador', converter=forms.float_converter(), proportion=0, ) self._SINTONIZADOR_slider = forms.slider( parent=self.GetWin(), sizer=_SINTONIZADOR_sizer, value=self.SINTONIZADOR, callback=self.set_SINTONIZADOR, minimum=10e6, maximum=142e6, num_steps=10, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_SINTONIZADOR_sizer) _GANANCIA_sizer = wx.BoxSizer(wx.VERTICAL) self._GANANCIA_text_box = forms.text_box( parent=self.GetWin(), sizer=_GANANCIA_sizer, value=self.GANANCIA, callback=self.set_GANANCIA, label='Ganancia', converter=forms.int_converter(), proportion=0, ) self._GANANCIA_slider = forms.slider( parent=self.GetWin(), sizer=_GANANCIA_sizer, value=self.GANANCIA, callback=self.set_GANANCIA, minimum=10, maximum=70, num_steps=12, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.GridAdd(_GANANCIA_sizer, 1, 0, 1, 4) self.wxgui_fftsink2_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, fft_size=1024, fft_rate=1000, average=False, avg_alpha=None, title='Especto de frecuencias', peak_hold=False, ) self.Add(self.wxgui_fftsink2_1.win) self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + '') self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(SINTONIZADOR, 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(0, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(GANANCIA, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna('', 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.rational_resampler_xxx_1 = filter.rational_resampler_fff( interpolation=48, decimation=50, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccf( interpolation=1, decimation=4, taps=None, fractional_bw=None, ) self.low_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate, 100e3, 1e6, firdes.WIN_HAMMING, 6.76)) self.blocks_wavfile_sink_0 = blocks.wavfile_sink( 'C:\\Users\\camil\\Desktop\\PROYECTO DE PRUEBA\\Decodificador\\DemodulacionFM.wav', 1, 20800, 16) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( (VOLUMEN / 100, )) self.audio_sink_0 = audio.sink(48000, '', True) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=500000, audio_decimation=10, ) ################################################## # Connections ################################################## self.connect((self.analog_wfm_rcv_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.wxgui_fftsink2_1, 0)) 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_wavfile_sink_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_wfm_rcv_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.rational_resampler_xxx_0, 0))
def __init__(self, center_freq=440000000): gr.top_block.__init__(self, "Rx 2400 R2") ################################################## # Parameters ################################################## self.center_freq = center_freq ################################################## # Variables ################################################## self.sps = sps = 10 self.baud_rate = baud_rate = 2530 self.samp_rate_tx = samp_rate_tx = 400000 self.samp_rate = samp_rate = int(baud_rate * sps) self.rx_vga_gain = rx_vga_gain = 35 self.rx_lna_gain = rx_lna_gain = 6 self.quad_gain = quad_gain = 8 self.freq = freq = center_freq ################################################## # Blocks ################################################## self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + "bladerf=0") self.osmosdr_source_0.set_sample_rate(samp_rate_tx) self.osmosdr_source_0.set_center_freq(freq, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(1, 0) self.osmosdr_source_0.set_iq_balance_mode(1, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(rx_lna_gain, 0) self.osmosdr_source_0.set_if_gain(0, 0) self.osmosdr_source_0.set_bb_gain(rx_vga_gain, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(1500000, 0) self.low_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate_tx, 6000, 6000, firdes.WIN_HAMMING, 6.76)) self.fir_filter_xxx_0 = filter.fir_filter_fff(16, (firdes.low_pass( 1.0, baud_rate * sps, baud_rate, 0.25 * baud_rate))) self.fir_filter_xxx_0.declare_sample_delay(0) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_fff( sps, 2 * 3.14159265 / 100, (firdes.low_pass( 1.0, baud_rate * sps, baud_rate, 0.25 * baud_rate)), 32, 16, 1.5, 1) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_file_sink_0_0 = blocks.file_sink( gr.sizeof_char * 1, "/usr/share/adafruit/webide/repositories/seelab_drones/data/_out.bin", False) self.blocks_file_sink_0_0.set_unbuffered(True) self.blocks_add_const_vxx_0 = blocks.add_const_vff((0, )) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf( quad_gain) self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc( -70, 1e-4, 0, True) ################################################## # Connections ################################################## self.connect((self.analog_pwr_squelch_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_file_sink_0_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.analog_pwr_squelch_xx_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.volume = volume = 2 self.samp_rate = samp_rate = 2.88e6 self.freq = freq = 93.7e6 ################################################## # Blocks ################################################## self._volume_layout = Qt.QVBoxLayout() self._volume_tool_bar = Qt.QToolBar(self) self._volume_layout.addWidget(self._volume_tool_bar) self._volume_tool_bar.addWidget(Qt.QLabel("volume" + ": ")) self._volume_counter = Qwt.QwtCounter() self._volume_counter.setRange(0, 20, 1) self._volume_counter.setNumButtons(2) self._volume_counter.setValue(self.volume) self._volume_tool_bar.addWidget(self._volume_counter) self._volume_counter.valueChanged.connect(self.set_volume) self._volume_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._volume_slider.setRange(0, 20, 1) self._volume_slider.setValue(self.volume) self._volume_slider.setMinimumWidth(200) self._volume_slider.valueChanged.connect(self.set_volume) self._volume_layout.addWidget(self._volume_slider) self.top_layout.addLayout(self._volume_layout) self._freq_layout = Qt.QVBoxLayout() self._freq_tool_bar = Qt.QToolBar(self) self._freq_layout.addWidget(self._freq_tool_bar) self._freq_tool_bar.addWidget(Qt.QLabel("freq" + ": ")) self._freq_counter = Qwt.QwtCounter() self._freq_counter.setRange(76e6, 108e6, 200e3) self._freq_counter.setNumButtons(2) self._freq_counter.setValue(self.freq) self._freq_tool_bar.addWidget(self._freq_counter) self._freq_counter.valueChanged.connect(self.set_freq) self._freq_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._freq_slider.setRange(76e6, 108e6, 200e3) self._freq_slider.setValue(self.freq) self._freq_slider.setMinimumWidth(200) self._freq_slider.valueChanged.connect(self.set_freq) self._freq_layout.addWidget(self._freq_slider) self.top_layout.addLayout(self._freq_layout) self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + "") self.rtlsdr_source_0.set_sample_rate(samp_rate) 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(0, 0) self.rtlsdr_source_0.set_gain_mode(0, 0) self.rtlsdr_source_0.set_gain(10, 0) self.rtlsdr_source_0.set_if_gain(30, 0) self.rtlsdr_source_0.set_bb_gain(30, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.qtgui_sink_x_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name True, #plotfreq True, #plotwaterfall True, #plottime True, #plotconst ) self.qtgui_sink_x_0.set_update_time(1.0 / 10) self._qtgui_sink_x_0_win = sip.wrapinstance( self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_sink_x_0_win) self.low_pass_filter_1 = filter.interp_fir_filter_fff( 1, firdes.low_pass(1, 48e3, 15e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf( 10, firdes.low_pass(1, samp_rate, 100e3, 10e3, firdes.WIN_HAMMING, 6.76)) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( (volume, )) self.audio_sink_0 = audio.sink(48000, "", True) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=samp_rate / 10, audio_decimation=6, ) self.analog_fm_deemph_0 = analog.fm_deemph(fs=samp_rate / 10, tau=75e-6) ################################################## # Connections ################################################## self.connect((self.rtlsdr_source_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_wfm_rcv_0, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.analog_fm_deemph_0, 0)) self.connect((self.analog_fm_deemph_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.low_pass_filter_1, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.qtgui_sink_x_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 = 32e3 self.freq = freq = 434278100 ################################################## # Blocks ################################################## self._samp_rate_range = Range(1e3, 60e3, 200, 32e3, 200) self._samp_rate_win = RangeWidget(self._samp_rate_range, self.set_samp_rate, "samp_rate", "counter_slider", float) self.top_layout.addWidget(self._samp_rate_win) self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=4, decimation=3, taps=None, fractional_bw=0.45, ) self.qtgui_tab_widget_0 = Qt.QTabWidget() self.qtgui_tab_widget_0_widget_0 = Qt.QWidget() self.qtgui_tab_widget_0_layout_0 = Qt.QBoxLayout( Qt.QBoxLayout.TopToBottom, self.qtgui_tab_widget_0_widget_0) self.qtgui_tab_widget_0_grid_layout_0 = Qt.QGridLayout() self.qtgui_tab_widget_0_layout_0.addLayout( self.qtgui_tab_widget_0_grid_layout_0) self.qtgui_tab_widget_0.addTab(self.qtgui_tab_widget_0_widget_0, "LPDemodulatedSignal") self.qtgui_tab_widget_0_widget_1 = Qt.QWidget() self.qtgui_tab_widget_0_layout_1 = Qt.QBoxLayout( Qt.QBoxLayout.TopToBottom, self.qtgui_tab_widget_0_widget_1) self.qtgui_tab_widget_0_grid_layout_1 = Qt.QGridLayout() self.qtgui_tab_widget_0_layout_1.addLayout( self.qtgui_tab_widget_0_grid_layout_1) self.qtgui_tab_widget_0.addTab(self.qtgui_tab_widget_0_widget_1, "FrequencyDomainOfDemodulatedSignal") self.qtgui_tab_widget_0_widget_2 = Qt.QWidget() self.qtgui_tab_widget_0_layout_2 = Qt.QBoxLayout( Qt.QBoxLayout.TopToBottom, self.qtgui_tab_widget_0_widget_2) self.qtgui_tab_widget_0_grid_layout_2 = Qt.QGridLayout() self.qtgui_tab_widget_0_layout_2.addLayout( self.qtgui_tab_widget_0_grid_layout_2) self.qtgui_tab_widget_0.addTab(self.qtgui_tab_widget_0_widget_2, "TimeRepresentationOfCarrier") self.qtgui_tab_widget_0_widget_3 = Qt.QWidget() self.qtgui_tab_widget_0_layout_3 = Qt.QBoxLayout( Qt.QBoxLayout.TopToBottom, self.qtgui_tab_widget_0_widget_3) self.qtgui_tab_widget_0_grid_layout_3 = Qt.QGridLayout() self.qtgui_tab_widget_0_layout_3.addLayout( self.qtgui_tab_widget_0_grid_layout_3) self.qtgui_tab_widget_0.addTab(self.qtgui_tab_widget_0_widget_3, "TimeDomainForDemodSignal") self.top_layout.addWidget(self.qtgui_tab_widget_0) self.low_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate, 4000, 1, firdes.WIN_HAMMING, 6.76)) self.blocks_probe_signal_x_0 = blocks.probe_signal_c() self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((2, )) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_gr_complex * 1, "/home/asemwal/github/real_time_packet/signal/H.sig", True) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.analog_sig_source_x_0_0 = analog.sig_source_c( 900e6, analog.GR_COS_WAVE, 434278100, 10, 0) self.TimeDomainForDemodSignal_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.TimeDomainForDemodSignal_0.set_update_time(0.01) self.TimeDomainForDemodSignal_0.set_y_axis(-1.2, 1.2) self.TimeDomainForDemodSignal_0.set_y_label("Amplitude", "") self.TimeDomainForDemodSignal_0.enable_tags(-1, True) self.TimeDomainForDemodSignal_0.set_trigger_mode( qtgui.TRIG_MODE_AUTO, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.TimeDomainForDemodSignal_0.enable_autoscale(False) self.TimeDomainForDemodSignal_0.enable_grid(True) self.TimeDomainForDemodSignal_0.enable_control_panel(True) if not True: self.TimeDomainForDemodSignal_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.TimeDomainForDemodSignal_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.TimeDomainForDemodSignal_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.TimeDomainForDemodSignal_0.set_line_label(i, labels[i]) self.TimeDomainForDemodSignal_0.set_line_width(i, widths[i]) self.TimeDomainForDemodSignal_0.set_line_color(i, colors[i]) self.TimeDomainForDemodSignal_0.set_line_style(i, styles[i]) self.TimeDomainForDemodSignal_0.set_line_marker(i, markers[i]) self.TimeDomainForDemodSignal_0.set_line_alpha(i, alphas[i]) self._TimeDomainForDemodSignal_0_win = sip.wrapinstance( self.TimeDomainForDemodSignal_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._TimeDomainForDemodSignal_0_win) self.TimeDomainForDemodSignal = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.TimeDomainForDemodSignal.set_update_time(0.01) self.TimeDomainForDemodSignal.set_y_axis(-1.2, 1.2) self.TimeDomainForDemodSignal.set_y_label("Amplitude", "") self.TimeDomainForDemodSignal.enable_tags(-1, True) self.TimeDomainForDemodSignal.set_trigger_mode(qtgui.TRIG_MODE_AUTO, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.TimeDomainForDemodSignal.enable_autoscale(False) self.TimeDomainForDemodSignal.enable_grid(True) self.TimeDomainForDemodSignal.enable_control_panel(True) if not True: self.TimeDomainForDemodSignal.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.TimeDomainForDemodSignal.set_line_label( i, "Data {0}".format(i)) else: self.TimeDomainForDemodSignal.set_line_label(i, labels[i]) self.TimeDomainForDemodSignal.set_line_width(i, widths[i]) self.TimeDomainForDemodSignal.set_line_color(i, colors[i]) self.TimeDomainForDemodSignal.set_line_style(i, styles[i]) self.TimeDomainForDemodSignal.set_line_marker(i, markers[i]) self.TimeDomainForDemodSignal.set_line_alpha(i, alphas[i]) self._TimeDomainForDemodSignal_win = sip.wrapinstance( self.TimeDomainForDemodSignal.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._TimeDomainForDemodSignal_win) self.LPDemodulatedSignal_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc 1e9, #bw "", #name 1 #number of inputs ) self.LPDemodulatedSignal_0.set_update_time(0.10) self.LPDemodulatedSignal_0.set_y_axis(-140, 10) self.LPDemodulatedSignal_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.LPDemodulatedSignal_0.enable_autoscale(True) self.LPDemodulatedSignal_0.enable_grid(True) self.LPDemodulatedSignal_0.set_fft_average(1.0) self.LPDemodulatedSignal_0.enable_control_panel(True) if not True: self.LPDemodulatedSignal_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.LPDemodulatedSignal_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.LPDemodulatedSignal_0.set_line_label( i, "Data {0}".format(i)) else: self.LPDemodulatedSignal_0.set_line_label(i, labels[i]) self.LPDemodulatedSignal_0.set_line_width(i, widths[i]) self.LPDemodulatedSignal_0.set_line_color(i, colors[i]) self.LPDemodulatedSignal_0.set_line_alpha(i, alphas[i]) self._LPDemodulatedSignal_0_win = sip.wrapinstance( self.LPDemodulatedSignal_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._LPDemodulatedSignal_0_win) self.LPDemodulatedSignal = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 433.92e6, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.LPDemodulatedSignal.set_update_time(0.10) self.LPDemodulatedSignal.set_y_axis(-140, 10) self.LPDemodulatedSignal.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.LPDemodulatedSignal.enable_autoscale(True) self.LPDemodulatedSignal.enable_grid(True) self.LPDemodulatedSignal.set_fft_average(1.0) self.LPDemodulatedSignal.enable_control_panel(True) if not True: self.LPDemodulatedSignal.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.LPDemodulatedSignal.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.LPDemodulatedSignal.set_line_label( i, "Data {0}".format(i)) else: self.LPDemodulatedSignal.set_line_label(i, labels[i]) self.LPDemodulatedSignal.set_line_width(i, widths[i]) self.LPDemodulatedSignal.set_line_color(i, colors[i]) self.LPDemodulatedSignal.set_line_alpha(i, alphas[i]) self._LPDemodulatedSignal_win = sip.wrapinstance( self.LPDemodulatedSignal.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._LPDemodulatedSignal_win) self.FrequencyDomainOfDemodulatedSignal = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc 1000e6, #bw "", #name 1 #number of inputs ) self.FrequencyDomainOfDemodulatedSignal.set_update_time(0.10) self.FrequencyDomainOfDemodulatedSignal.set_y_axis(-140, 10) self.FrequencyDomainOfDemodulatedSignal.set_trigger_mode( qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.FrequencyDomainOfDemodulatedSignal.enable_autoscale(True) self.FrequencyDomainOfDemodulatedSignal.enable_grid(True) self.FrequencyDomainOfDemodulatedSignal.set_fft_average(1.0) self.FrequencyDomainOfDemodulatedSignal.enable_control_panel(True) if not True: self.FrequencyDomainOfDemodulatedSignal.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.FrequencyDomainOfDemodulatedSignal.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.FrequencyDomainOfDemodulatedSignal.set_line_label( i, "Data {0}".format(i)) else: self.FrequencyDomainOfDemodulatedSignal.set_line_label( i, labels[i]) self.FrequencyDomainOfDemodulatedSignal.set_line_width( i, widths[i]) self.FrequencyDomainOfDemodulatedSignal.set_line_color( i, colors[i]) self.FrequencyDomainOfDemodulatedSignal.set_line_alpha( i, alphas[i]) self._FrequencyDomainOfDemodulatedSignal_win = sip.wrapinstance( self.FrequencyDomainOfDemodulatedSignal.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._FrequencyDomainOfDemodulatedSignal_win) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.LPDemodulatedSignal_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.TimeDomainForDemodSignal_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.FrequencyDomainOfDemodulatedSignal, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.blocks_probe_signal_x_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.LPDemodulatedSignal, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.TimeDomainForDemodSignal, 0))
def __init__(self): gr.top_block.__init__(self, "COMMUNICATIONS-RECEIVER") Qt.QWidget.__init__(self) self.setWindowTitle("COMMUNICATIONS-RECEIVER") 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", "commrx") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.upconv = upconv = 0 self.rit = rit = 0 self.ften = ften = 50000000 self.fsel = fsel = 0 self.fone = fone = 5000000 self.fhun = fhun = 100000000 self.squelch = squelch = -70 self.scanw = scanw = 1000000 self.samp_rate = samp_rate = 1200000 self.msel = msel = 1 self.gain = gain = 35 self.freq = freq = fhun + ften + fone + fsel + rit - 100000 self.corr = corr = 3 self.FREQUENCY = FREQUENCY = ( (upconv + fhun + ften + fone + fsel + rit) / 1000000) ################################################## # Blocks ################################################## self._squelch_range = Range(-80, -20, 1, -70, 50) self._squelch_win = RangeWidget(self._squelch_range, self.set_squelch, "squelch", "dial", float) self.top_grid_layout.addWidget(self._squelch_win, 5, 3, 1, 1) self._scanw_range = Range(10000, 1000000, 10000, 1000000, 50) self._scanw_win = RangeWidget(self._scanw_range, self.set_scanw, "scanw", "counter", float) self.top_grid_layout.addWidget(self._scanw_win, 6, 0, 1, 2) self._msel_options = ( 0, 1, 2, 3, 4, ) self._msel_labels = ( "AM", "NFM", "WFM", "USB", "LSB", ) self._msel_group_box = Qt.QGroupBox("MODE") self._msel_box = Qt.QVBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._msel_button_group = variable_chooser_button_group() self._msel_group_box.setLayout(self._msel_box) for i, label in enumerate(self._msel_labels): radio_button = Qt.QRadioButton(label) self._msel_box.addWidget(radio_button) self._msel_button_group.addButton(radio_button, i) self._msel_callback = lambda i: Qt.QMetaObject.invokeMethod( self._msel_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._msel_options.index(i))) self._msel_callback(self.msel) self._msel_button_group.buttonClicked[int].connect( lambda i: self.set_msel(self._msel_options[i])) self.top_grid_layout.addWidget(self._msel_group_box, 1, 3, 1, 1) self._gain_range = Range(0, 50, 1, 35, 50) self._gain_win = RangeWidget(self._gain_range, self.set_gain, "gain", "dial", float) self.top_grid_layout.addWidget(self._gain_win, 4, 3, 1, 1) _upconv_check_box = Qt.QCheckBox("UPCONVERTER") self._upconv_choices = {True: -125000000, False: 0} self._upconv_choices_inv = dict( (v, k) for k, v in self._upconv_choices.iteritems()) self._upconv_callback = lambda i: Qt.QMetaObject.invokeMethod( _upconv_check_box, "setChecked", Qt.Q_ARG("bool", self._upconv_choices_inv[i])) self._upconv_callback(self.upconv) _upconv_check_box.stateChanged.connect( lambda i: self.set_upconv(self._upconv_choices[bool(i)])) self.top_grid_layout.addWidget(_upconv_check_box, 1, 4, 1, 1) self._rit_range = Range(-500, 500, 10, 0, 50) self._rit_win = RangeWidget(self._rit_range, self.set_rit, "RIT", "dial", float) self.top_grid_layout.addWidget(self._rit_win, 2, 1, 1, 1) self.qtgui_sink_x_0 = qtgui.sink_c( 512, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype (freq + 100000), #fc scanw, #bw "", #name False, #plotfreq True, #plotwaterfall False, #plottime False, #plotconst ) self.qtgui_sink_x_0.set_update_time(1.0 / 10) self._qtgui_sink_x_0_win = sip.wrapinstance( self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_sink_x_0_win, 5, 0, 1, 2) self.qtgui_sink_x_0.enable_rf_freq(True) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype freq + 100000, #fc scanw, #bw "RF", #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(True) self.qtgui_freq_sink_x_0.set_fft_average(0.2) self.qtgui_freq_sink_x_0.enable_control_panel(True) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "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 = [ "green", "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_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 4, 0, 1, 2) self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + "RTL2838UHIDIR") self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(freq, 0) self.osmosdr_source_0.set_freq_corr(corr, 0) self.osmosdr_source_0.set_dc_offset_mode(2, 0) self.osmosdr_source_0.set_iq_balance_mode(2, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(gain, 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(samp_rate, 0) (self.osmosdr_source_0).set_min_output_buffer(8) (self.osmosdr_source_0).set_max_output_buffer(32) self.msel1 = grc_blks2.selector( item_size=gr.sizeof_gr_complex * 1, num_inputs=1, num_outputs=5, input_index=0, output_index=msel, ) self.low_pass_filter_0_1 = filter.fir_filter_ccf( 5, firdes.low_pass(1, samp_rate, 75000, 25000, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0_0 = filter.fir_filter_ccf( 25, firdes.low_pass(1, samp_rate, 5000, 5000, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf( 25, firdes.low_pass(1, samp_rate, 7500, 5000, firdes.WIN_HAMMING, 6.76)) self._ften_range = Range(0, 90000000, 10000000, 50000000, 50) self._ften_win = RangeWidget(self._ften_range, self.set_ften, "10s", "dial", float) self.top_grid_layout.addWidget(self._ften_win, 1, 0, 1, 1) self._fsel_range = Range(0, 999000, 1000, 0, 1000) self._fsel_win = RangeWidget(self._fsel_range, self.set_fsel, "fsel", "counter_slider", float) self.top_grid_layout.addWidget(self._fsel_win, 0, 0, 1, 2) self._fone_range = Range(0, 9000000, 1000000, 5000000, 50) self._fone_win = RangeWidget(self._fone_range, self.set_fone, "1s", "dial", float) self.top_grid_layout.addWidget(self._fone_win, 1, 1, 1, 1) self._fhun_range = Range(0, 2000000000, 100000000, 100000000, 50) self._fhun_win = RangeWidget(self._fhun_range, self.set_fhun, "100s", "counter", float) self.top_grid_layout.addWidget(self._fhun_win, 2, 0, 1, 1) self.dc_blocker_xx_0 = filter.dc_blocker_ff(32, True) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_complex_to_real_0_0 = blocks.complex_to_real(1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.band_pass_filter_0_0 = filter.fir_filter_ccc( 25, firdes.complex_band_pass(1, samp_rate, -2800, 200, 1000, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0 = filter.fir_filter_ccc( 25, firdes.complex_band_pass(1, samp_rate, 200, 2800, 1000, firdes.WIN_HAMMING, 6.76)) self.audio_sink_0 = audio.sink(48000, "", True) self.asel = grc_blks2.selector( item_size=gr.sizeof_float * 1, num_inputs=5, num_outputs=1, input_index=msel, output_index=0, ) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=samp_rate / 5, audio_decimation=5, ) self.analog_simple_squelch_cc_4 = analog.simple_squelch_cc(squelch, 1) self.analog_simple_squelch_cc_3 = analog.simple_squelch_cc(squelch, 1) self.analog_simple_squelch_cc_2 = analog.simple_squelch_cc(squelch, 1) self.analog_simple_squelch_cc_1 = analog.simple_squelch_cc(squelch, 1) self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(squelch, 1) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, -100000, 1, 0) self.analog_nbfm_rx_0 = analog.nbfm_rx( audio_rate=48000, quad_rate=samp_rate / 25, tau=75e-6, max_dev=5.0e3, ) self.analog_agc_xx_0_1 = analog.agc_ff(1e-1, 0.02, 1.0) self.analog_agc_xx_0_1.set_max_gain(65536) self.analog_agc_xx_0_0 = analog.agc_ff(1e-1, 0.02, 1.0) self.analog_agc_xx_0_0.set_max_gain(65536) self.analog_agc_xx_0 = analog.agc_ff(1e-1, 0.02, 1.0) self.analog_agc_xx_0.set_max_gain(65536) self._FREQUENCY_tool_bar = Qt.QToolBar(self) if None: self._FREQUENCY_formatter = None else: self._FREQUENCY_formatter = lambda x: x self._FREQUENCY_tool_bar.addWidget(Qt.QLabel("FREQUENCY" + ": ")) self._FREQUENCY_label = Qt.QLabel( str(self._FREQUENCY_formatter(self.FREQUENCY))) self._FREQUENCY_tool_bar.addWidget(self._FREQUENCY_label) self.top_grid_layout.addWidget(self._FREQUENCY_tool_bar, 3, 0, 1, 1) ################################################## # Connections ################################################## self.connect((self.analog_agc_xx_0, 0), (self.asel, 0)) self.connect((self.analog_agc_xx_0_0, 0), (self.asel, 3)) self.connect((self.analog_agc_xx_0_1, 0), (self.asel, 4)) self.connect((self.analog_nbfm_rx_0, 0), (self.asel, 1)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_simple_squelch_cc_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.analog_simple_squelch_cc_1, 0), (self.analog_nbfm_rx_0, 0)) self.connect((self.analog_simple_squelch_cc_2, 0), (self.analog_wfm_rcv_0, 0)) self.connect((self.analog_simple_squelch_cc_3, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.analog_simple_squelch_cc_4, 0), (self.blocks_complex_to_real_0_0, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.asel, 2)) self.connect((self.asel, 0), (self.audio_sink_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.analog_simple_squelch_cc_3, 0)) self.connect((self.band_pass_filter_0_0, 0), (self.analog_simple_squelch_cc_4, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.dc_blocker_xx_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.analog_agc_xx_0_0, 0)) self.connect((self.blocks_complex_to_real_0_0, 0), (self.analog_agc_xx_0_1, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.msel1, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_sink_x_0, 0)) self.connect((self.dc_blocker_xx_0, 0), (self.analog_agc_xx_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_simple_squelch_cc_1, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.analog_simple_squelch_cc_0, 0)) self.connect((self.low_pass_filter_0_1, 0), (self.analog_simple_squelch_cc_2, 0)) self.connect((self.msel1, 3), (self.band_pass_filter_0, 0)) self.connect((self.msel1, 4), (self.band_pass_filter_0_0, 0)) self.connect((self.msel1, 1), (self.low_pass_filter_0, 0)) self.connect((self.msel1, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.msel1, 2), (self.low_pass_filter_0_1, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_multiply_xx_0, 0))
def __init__(self, antenna=satnogs.not_set_antenna, bb_gain=satnogs.not_set_rx_bb_gain, decoded_data_file_path='/tmp/.satnogs/data/data', dev_args=satnogs.not_set_dev_args, doppler_correction_per_sec=20, enable_iq_dump=0, file_path='test.ogg', if_gain=satnogs.not_set_rx_if_gain, iq_file_path='/tmp/iq.dat', lo_offset=100e3, ppm=0, rf_gain=satnogs.not_set_rx_rf_gain, rigctl_port=4532, rx_freq=100e6, rx_sdr_device='usrpb200', waterfall_file_path='/tmp/waterfall.dat'): gr.top_block.__init__(self, "AMSAT FOX DUV Decoder") ################################################## # Parameters ################################################## self.antenna = antenna self.bb_gain = bb_gain self.decoded_data_file_path = decoded_data_file_path self.dev_args = dev_args self.doppler_correction_per_sec = doppler_correction_per_sec self.enable_iq_dump = enable_iq_dump self.file_path = file_path self.if_gain = if_gain self.iq_file_path = iq_file_path self.lo_offset = lo_offset self.ppm = ppm self.rf_gain = rf_gain self.rigctl_port = rigctl_port self.rx_freq = rx_freq self.rx_sdr_device = rx_sdr_device self.waterfall_file_path = waterfall_file_path ################################################## # Variables ################################################## self.samp_rate_rx = samp_rate_rx = satnogs.hw_rx_settings[ rx_sdr_device]['samp_rate'] self.xlate_filter_taps = xlate_filter_taps = firdes.low_pass( 1, samp_rate_rx, 125000, 25000, firdes.WIN_HAMMING, 6.76) self.taps = taps = firdes.low_pass(12.0, samp_rate_rx, 100e3, 60000, firdes.WIN_HAMMING, 6.76) self.max_modulation_freq = max_modulation_freq = 3000 self.filter_rate = filter_rate = 250000 self.deviation = deviation = 5000 self.audio_samp_rate = audio_samp_rate = 48000 ################################################## # Blocks ################################################## self.satnogs_waterfall_sink_0 = satnogs.waterfall_sink( audio_samp_rate, 0.0, 10, 1024, waterfall_file_path, 1) self.satnogs_tcp_rigctl_msg_source_0 = satnogs.tcp_rigctl_msg_source( "127.0.0.1", rigctl_port, False, 1000 / doppler_correction_per_sec, 1500) self.satnogs_quad_demod_filter_ff_0 = satnogs.quad_demod_filter_ff(1.2) self.satnogs_ogg_encoder_0 = satnogs.ogg_encoder( file_path, audio_samp_rate, 1.0) self.satnogs_iq_sink_0 = satnogs.iq_sink(32767, iq_file_path, False, enable_iq_dump) self.satnogs_frame_file_sink_0_1_0 = satnogs.frame_file_sink( decoded_data_file_path, 0) self.satnogs_fox_telem_mm_0 = satnogs.fox_telem_mm() self.satnogs_decoder_8b10b_0 = satnogs.decoder_8b10b('0011111010', 960) self.satnogs_coarse_doppler_correction_cc_0 = satnogs.coarse_doppler_correction_cc( rx_freq, samp_rate_rx) self.satnogs_ccsds_rs_decoder_mm_0 = satnogs.ccsds_rs_decoder_mm() self.root_raised_cosine_filter_0 = filter.fir_filter_fff( 1, firdes.root_raised_cosine(1, 1, 2.4, 0.5, 512)) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + satnogs.handle_rx_dev_args(rx_sdr_device, dev_args)) self.osmosdr_source_0.set_sample_rate(samp_rate_rx) self.osmosdr_source_0.set_center_freq(rx_freq - lo_offset, 0) self.osmosdr_source_0.set_freq_corr(ppm, 0) self.osmosdr_source_0.set_dc_offset_mode(2, 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( satnogs.handle_rx_rf_gain(rx_sdr_device, rf_gain), 0) self.osmosdr_source_0.set_if_gain( satnogs.handle_rx_if_gain(rx_sdr_device, if_gain), 0) self.osmosdr_source_0.set_bb_gain( satnogs.handle_rx_bb_gain(rx_sdr_device, bb_gain), 0) self.osmosdr_source_0.set_antenna( satnogs.handle_rx_antenna(rx_sdr_device, antenna), 0) self.osmosdr_source_0.set_bandwidth(samp_rate_rx, 0) self.low_pass_filter_1 = filter.fir_filter_fff( 100, firdes.low_pass(100, audio_samp_rate, 195, 10, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, audio_samp_rate, deviation + max_modulation_freq, 3000, firdes.WIN_HAMMING, 6.76)) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( int(samp_rate_rx / filter_rate), (xlate_filter_taps), lo_offset, samp_rate_rx) self.digital_clock_recovery_mm_xx_0_0_0 = digital.clock_recovery_mm_ff( (audio_samp_rate / 100.0) / 200, 0.25 * 0.175 * 0.175, 0.5, 0.175, 0.005) self.digital_binary_slicer_fb_0_0 = digital.binary_slicer_fb() self.dc_blocker_xx_0 = filter.dc_blocker_ff(1024, True) self.blks2_rational_resampler_xxx_1 = filter.rational_resampler_ccc( interpolation=24, decimation=125, taps=None, fractional_bw=None, ) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1.0) ################################################## # Connections ################################################## self.msg_connect((self.satnogs_ccsds_rs_decoder_mm_0, 'pdu'), (self.satnogs_fox_telem_mm_0, 'in')) self.msg_connect((self.satnogs_decoder_8b10b_0, 'pdu'), (self.satnogs_ccsds_rs_decoder_mm_0, 'in')) self.msg_connect((self.satnogs_fox_telem_mm_0, 'raw'), (self.satnogs_frame_file_sink_0_1_0, 'frame')) self.msg_connect((self.satnogs_tcp_rigctl_msg_source_0, 'freq'), (self.satnogs_coarse_doppler_correction_cc_0, 'freq')) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.satnogs_ogg_encoder_0, 0)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.low_pass_filter_0, 0)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.satnogs_iq_sink_0, 0)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.satnogs_waterfall_sink_0, 0)) self.connect((self.dc_blocker_xx_0, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.digital_binary_slicer_fb_0_0, 0), (self.satnogs_decoder_8b10b_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0_0_0, 0), (self.satnogs_quad_demod_filter_ff_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blks2_rational_resampler_xxx_1, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.dc_blocker_xx_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.satnogs_coarse_doppler_correction_cc_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.digital_clock_recovery_mm_xx_0_0_0, 0)) self.connect((self.satnogs_coarse_doppler_correction_cc_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.satnogs_quad_demod_filter_ff_0, 0), (self.digital_binary_slicer_fb_0_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 10e6 self.channel_width = channel_width = 200e3 self.channel_freq = channel_freq = 96.25e6 self.center_freq = center_freq = 97.9e6 self.audio_gain = audio_gain = 1 ################################################## # Blocks ################################################## _audio_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._audio_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_audio_gain_sizer, value=self.audio_gain, callback=self.set_audio_gain, label='audio_gain', converter=forms.float_converter(), proportion=0, ) self._audio_gain_slider = forms.slider( parent=self.GetWin(), sizer=_audio_gain_sizer, value=self.audio_gain, callback=self.set_audio_gain, minimum=0, maximum=10, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_audio_gain_sizer) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=center_freq, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=True, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=12, decimation=5, taps=None, fractional_bw=None, ) 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(center_freq, 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(0, 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.low_pass_filter_0 = filter.fir_filter_ccf(int(samp_rate / channel_width), firdes.low_pass( 1, samp_rate, 75e3, 25e3, firdes.WIN_HAMMING, 6.76)) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((audio_gain, )) self.audio_sink_0 = audio.sink(48000, "", True) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=48e3, audio_decimation=10, ) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, center_freq - channel_freq, 1, 0) ################################################## # Connections ################################################## self.connect((self.osmosdr_source_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.analog_wfm_rcv_0, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_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.tun_gain = tun_gain = 20 self.samp_rate = samp_rate = 500e3 ################################################## # Blocks ################################################## self._tun_gain_range = Range(0, 30, 2, 20, 200) self._tun_gain_win = RangeWidget(self._tun_gain_range, self.set_tun_gain, "tun_gain", "counter_slider", float) self.top_layout.addWidget(self._tun_gain_win) 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(1e9, 0) self.uhd_usrp_source_0.set_gain(tun_gain, 0) self.uhd_usrp_source_0.set_antenna('RX2', 0) self.qtgui_sink_x_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name True, #plotfreq True, #plotwaterfall True, #plottime True, #plotconst ) self.qtgui_sink_x_0.set_update_time(1.0/10) self._qtgui_sink_x_0_win = sip.wrapinstance(self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_sink_x_0_win) self.qtgui_sink_x_0.enable_rf_freq(False) self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, samp_rate, 200e3, 50e3, firdes.WIN_HAMMING, 6.76)) self.digital_gmsk_demod_0 = digital.gmsk_demod( samples_per_symbol=2, gain_mu=0.175, mu=0.5, omega_relative_limit=0.005, freq_error=1e-4, verbose=False, log=False, ) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((1, )) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*1, '/home/ubuntu/vid_out.mp4', False) self.blocks_file_sink_0.set_unbuffered(False) self.blks2_packet_decoder_0 = grc_blks2.packet_demod_c(grc_blks2.packet_decoder( access_code='', threshold=-1, callback=lambda ok, payload: self.blks2_packet_decoder_0.recv_pkt(ok, payload), ), ) ################################################## # Connections ################################################## self.connect((self.blks2_packet_decoder_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.digital_gmsk_demod_0, 0), (self.blks2_packet_decoder_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.digital_gmsk_demod_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.qtgui_sink_x_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_multiply_const_vxx_0, 0))
def __init__(self, frame, panel, vbox, argv): stdgui2.std_top_block.__init__ (self, frame, panel, vbox, argv) parser=OptionParser(option_class=eng_option) parser.add_option("-a", "--args", type="string", default="", help="UHD device address args [default=%default]") parser.add_option("", "--spec", type="string", default=None, help="Subdevice of UHD device where appropriate") parser.add_option("-A", "--antenna", type="string", default=None, help="select Rx Antenna where appropriate") parser.add_option("-s", "--samp-rate", type="eng_float", default=1e6, help="set sample rate (bandwidth) [default=%default]") parser.add_option("-f", "--freq", type="eng_float", default=1008.0e3, help="set frequency to FREQ", metavar="FREQ") parser.add_option("-I", "--use-if-freq", action="store_true", default=False, help="use intermediate freq (compensates DC problems in quadrature boards)" ) parser.add_option("-g", "--gain", type="eng_float", default=None, help="set gain in dB (default is maximum)") parser.add_option("-V", "--volume", type="eng_float", default=None, help="set volume (default is midpoint)") parser.add_option("-O", "--audio-output", type="string", default="default", help="pcm device name. E.g., hw:0,0 or surround51 or /dev/dsp") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() sys.exit(1) self.frame = frame self.panel = panel self.use_IF=options.use_if_freq if self.use_IF: self.IF_freq=64000.0 else: self.IF_freq=0.0 self.vol = 0 self.state = "FREQ" self.freq = 0 # build graph self.u = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('fc32')) # Set the subdevice spec if(options.spec): self.u.set_subdev_spec(options.spec, 0) # Set the antenna if(options.antenna): self.u.set_antenna(options.antenna, 0) usrp_rate = 256e3 demod_rate = 64e3 audio_rate = 32e3 chanfilt_decim = int(usrp_rate // demod_rate) audio_decim = int(demod_rate // audio_rate) self.u.set_samp_rate(usrp_rate) dev_rate = self.u.get_samp_rate() # Resample signal to exactly self.usrp_rate # FIXME: make one of the follow-on filters an arb resampler rrate = usrp_rate / dev_rate self.resamp = filter.pfb.arb_resampler_ccf(rrate) chan_filt_coeffs = filter.firdes.low_pass_2(1, # gain usrp_rate, # sampling rate 8e3, # passband cutoff 4e3, # transition bw 60) # stopband attenuation if self.use_IF: # Turn If to baseband and filter. self.chan_filt = filter.freq_xlating_fir_filter_ccf(chanfilt_decim, chan_filt_coeffs, self.IF_freq, usrp_rate) else: self.chan_filt = filter.fir_filter_ccf(chanfilt_decim, chan_filt_coeffs) self.agc = analog.agc_cc(0.1, 1, 1, 100000) self.am_demod = blocks.complex_to_mag() self.volume_control = blocks.multiply_const_ff(self.vol) audio_filt_coeffs = filter.firdes.low_pass_2(1, # gain demod_rate, # sampling rate 8e3, # passband cutoff 2e3, # transition bw 60) # stopband attenuation self.audio_filt = filter.fir_filter_fff(audio_decim, audio_filt_coeffs) # sound card as final sink self.audio_sink = audio.sink(int (audio_rate), options.audio_output, False) # ok_to_block # now wire it all together self.connect (self.u, self.resamp, self.chan_filt, self.agc, self.am_demod, self.audio_filt, self.volume_control, self.audio_sink) self._build_gui(vbox, usrp_rate, demod_rate, audio_rate) if options.gain is None: g = self.u.get_gain_range() # if no gain was specified, use the mid gain options.gain = (g.start() + g.stop())/2.0 if options.volume is None: v = self.volume_range() options.volume = float(v[0]*3+v[1])/4.0 if abs(options.freq) < 1e3: options.freq *= 1e3 # set initial values self.set_gain(options.gain) self.set_vol(options.volume) if not(self.set_freq(options.freq)): self._set_status_msg("Failed to set initial frequency")
def __init__(self, target_freq, samp_rate = DEFAULT_SAMPLE_RATE, low_pass_filter_cutoff_freq = DEFAULT_LOW_PASS_FILTER_CUTOFF_FREQ, low_pass_filter_trans_width = DEFAULT_LOW_PASS_FILTER_TRANS_WIDTH, volume = DEFAULT_OUTPUT_SIGNAL_GAIN): gr.top_block.__init__(self, "FM receiver without GUI") ################################################## # Variables ################################################## self.wbfm_freq = 0 self.heterodyne_freq = 0 self.center_sdr_hardware_freq = 0 self.samp_rate = samp_rate self.low_pass_filter_cutoff_freq = low_pass_filter_cutoff_freq self.low_pass_filter_trans_width = low_pass_filter_trans_width self.output_audio_gain = volume if (0 == samp_rate): self.samp_rate = DEFAULT_SAMPLE_RATE if (0 == low_pass_filter_cutoff_freq): self.low_pass_filter_cutoff_freq = DEFAULT_LOW_PASS_FILTER_CUTOFF_FREQ if (0 == low_pass_filter_trans_width): self.low_pass_filter_trans_width = DEFAULT_LOW_PASS_FILTER_TRANS_WIDTH if (0 == volume): self.output_audio_gain = DEFAULT_OUTPUT_SIGNAL_GAIN self.calculate_frequencies (target_freq) ################################################## # Blocks ################################################## if ((self.audio_freq < 20e3) or (0 != self.samp_rate % self.wbfm_freq)): self.samp_rate = DEFAULT_SAMPLE_RATE self.wbfm_freq = DEFAULT_SAMPLE_RATE / 10 print ("Error! Sample rate % WBFM frequency should be == 0\n" + "Using default values: Sample rate = " + "%.1E"%(self.samp_rate) + " Hz\nWBFM frequency = " + "%.1E"%(self.wbfm_freq) + " Hz\n") if ((self.audio_freq < 20e3) or (0 != self.wbfm_freq % self.audio_freq)): self.wbfm_freq = self.samp_rate / 10 self.audio_freq = self.wbfm_freq / 10 print ("Error! WBFM frequency % audio final frequency should be == 0\n" + "Using default values:\nWBFM frequency = " + "%.1E"%(self.wbfm_freq) + " Hz\nAudio final frequency = " + "%.1E"%(self.audio_freq) + " Hz\n") print ("Your FM radio settings:\nTarget frequency = " + "%.5g"%(target_freq) + " Hz\nSample rate = " + "%.3g"%(self.samp_rate) + " Hz \nLow pass filter cutoff frequency = " + "%.3g"%(self.low_pass_filter_cutoff_freq) + " Hz \nLow pass filter transition width = " + "%.3g"%(self.low_pass_filter_trans_width) + " Hz \nOutput signal gain (volume) = " + str(self.output_audio_gain) + "\n") self.wbfm_receive = analog.wfm_rcv(quad_rate=self.wbfm_freq, audio_decimation=int(self.wbfm_freq / self.audio_freq),) self.src_heterodyne = analog.sig_source_c(self.samp_rate, analog.GR_COS_WAVE, self.heterodyne_freq, 1, 0) self.src_hackrf = osmosdr.source( args="numchan=" + str(1) + " " + '' ) self.src_hackrf.set_sample_rate(self.samp_rate) self.src_hackrf.set_center_freq(self.center_sdr_hardware_freq, 0) self.src_hackrf.set_freq_corr(0, 0) self.src_hackrf.set_dc_offset_mode(0, 0) self.src_hackrf.set_iq_balance_mode(0, 0) self.src_hackrf.set_gain_mode(False, 0) self.src_hackrf.set_gain(10, 0) self.src_hackrf.set_if_gain(20, 0) self.src_hackrf.set_bb_gain(30, 0) self.src_hackrf.set_antenna('', 0) self.src_hackrf.set_bandwidth(0, 0) self.output_audio_final = audio.sink(int(self.audio_freq), '', True) self.multiply_output_volume = blocks.multiply_const_vff((self.output_audio_gain, )) self.low_pass_filter = filter.fir_filter_ccf(int(self.samp_rate / self.wbfm_freq), firdes.low_pass(1, self.samp_rate, self.low_pass_filter_cutoff_freq, self.low_pass_filter_trans_width, firdes.WIN_HAMMING, 6.76)) self.IF_mixer = blocks.multiply_vcc(1) ################################################## # Connections ################################################## self.connect((self.IF_mixer, 0), (self.low_pass_filter, 0)) self.connect((self.low_pass_filter, 0), (self.wbfm_receive, 0)) self.connect((self.multiply_output_volume, 0), (self.output_audio_final, 0)) self.connect((self.src_hackrf, 0), (self.IF_mixer, 1)) self.connect((self.src_heterodyne, 0), (self.IF_mixer, 0)) self.connect((self.wbfm_receive, 0), (self.multiply_output_volume, 0))
def __init__(self): gr.top_block.__init__(self, "Hd Tx Usrp") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 2000000 self.freq = freq = 87.5e6 ################################################## # Blocks ################################################## self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", '')), uhd.stream_args( cpu_format="fc32", args='', channels=list(range(0,1)), ), '', ) self.uhd_usrp_sink_0.set_center_freq(freq, 0) self.uhd_usrp_sink_0.set_gain(70, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_time_unknown_pps(uhd.time_spec()) self.rational_resampler_xxx_2 = filter.rational_resampler_ccc( interpolation=256, decimation=243, taps=None, fractional_bw=None) self.rational_resampler_xxx_1 = filter.rational_resampler_ccc( interpolation=125, decimation=49, taps=None, fractional_bw=None) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=samp_rate // 200000, decimation=1, taps=None, fractional_bw=None) self.nrsc5_sis_encoder_0 = nrsc5.sis_encoder('ABCD') self.nrsc5_psd_encoder_0 = nrsc5.psd_encoder(0, 'Title', 'Artist') self.nrsc5_l2_encoder_0 = nrsc5.l2_encoder(1, 0, 146176) self.nrsc5_l1_fm_encoder_mp1_0 = nrsc5.l1_fm_encoder(1) self.nrsc5_hdc_encoder_0 = nrsc5.hdc_encoder(2, 64000) self.low_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.low_pass( 1, samp_rate, 80000, 20000, firdes.WIN_HAMMING, 6.76)) self.fft_vxx_0 = fft.fft_vcc(2048, False, window.rectangular(2048), True, 1) self.blocks_wavfile_source_0 = blocks.wavfile_source('sample.wav', True) self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, 2048) self.blocks_vector_source_x_0 = blocks.vector_source_c([math.sin(math.pi / 2 * i / 112) for i in range(112)] + [1] * (2048-112) + [math.cos(math.pi / 2 * i / 112) for i in range(112)], True, 1, []) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex*2048, 2) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_cc(0.1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_cc(0.001) self.blocks_keep_m_in_n_0 = blocks.keep_m_in_n(gr.sizeof_gr_complex, 2160, 4096, 0) self.blocks_conjugate_cc_0 = blocks.conjugate_cc() self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_wfm_tx_0 = analog.wfm_tx( audio_rate=50000, quad_rate=200000, tau=75e-6, max_dev=75e3, fh=-1.0, ) self.analog_sig_source_x_0 = analog.sig_source_f(50000, analog.GR_COS_WAVE, 1000, 0.1, 0, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.analog_wfm_tx_0, 0)) self.connect((self.analog_wfm_tx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_conjugate_cc_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.blocks_keep_m_in_n_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_conjugate_cc_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_vector_to_stream_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_keep_m_in_n_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.nrsc5_hdc_encoder_0, 0)) self.connect((self.blocks_wavfile_source_0, 1), (self.nrsc5_hdc_encoder_0, 1)) self.connect((self.fft_vxx_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.nrsc5_hdc_encoder_0, 0), (self.nrsc5_l2_encoder_0, 0)) self.connect((self.nrsc5_l1_fm_encoder_mp1_0, 0), (self.fft_vxx_0, 0)) self.connect((self.nrsc5_l2_encoder_0, 0), (self.nrsc5_l1_fm_encoder_mp1_0, 0)) self.connect((self.nrsc5_psd_encoder_0, 0), (self.nrsc5_l2_encoder_0, 1)) self.connect((self.nrsc5_sis_encoder_0, 0), (self.nrsc5_l1_fm_encoder_mp1_0, 1)) self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.rational_resampler_xxx_2, 0)) self.connect((self.rational_resampler_xxx_2, 0), (self.blocks_multiply_const_vxx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Receptor_FullSeg") Qt.QWidget.__init__(self) self.setWindowTitle("Receptor_FullSeg") 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", "fullseg") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.mode = mode = 3 self.total_carriers = total_carriers = 2**(10 + mode) self.samp_usrp = samp_usrp = 7.69231e6 self.samp_rate = samp_rate = 8e6 * 64 / 63 self.inter = inter = 1664 self.guard = guard = 1 / 16.0 self.decim = decim = 1575 self.data_carriers = data_carriers = 13 * 96 * 2**(mode - 1) self.center_freq = center_freq = 575.143e6 self.active_carriers = active_carriers = 13 * 108 * 2**(mode - 1) + 1 self.C = C = 0 self.B = B = 12 self.A = A = 1 ################################################## # Blocks ################################################## self._mode_options = ( 3, 2, 1, ) self._mode_labels = ( '3 (8k)', '2 (4k)', '1 (2k)', ) self._mode_tool_bar = Qt.QToolBar(self) self._mode_tool_bar.addWidget(Qt.QLabel('Mode' + ": ")) self._mode_combo_box = Qt.QComboBox() self._mode_tool_bar.addWidget(self._mode_combo_box) for label in self._mode_labels: self._mode_combo_box.addItem(label) self._mode_callback = lambda i: Qt.QMetaObject.invokeMethod( self._mode_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._mode_options.index(i))) self._mode_callback(self.mode) self._mode_combo_box.currentIndexChanged.connect( lambda i: self.set_mode(self._mode_options[i])) self.top_layout.addWidget(self._mode_tool_bar) self._guard_options = ( 1 / 4.0, 1 / 8.0, 1 / 16.0, 1 / 32.0, ) self._guard_labels = ( '1/4', '1/8', '1/16', '1/32', ) self._guard_tool_bar = Qt.QToolBar(self) self._guard_tool_bar.addWidget(Qt.QLabel('Guard Interval' + ": ")) self._guard_combo_box = Qt.QComboBox() self._guard_tool_bar.addWidget(self._guard_combo_box) for label in self._guard_labels: self._guard_combo_box.addItem(label) self._guard_callback = lambda i: Qt.QMetaObject.invokeMethod( self._guard_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._guard_options.index(i))) self._guard_callback(self.guard) self._guard_combo_box.currentIndexChanged.connect( lambda i: self.set_guard(self._guard_options[i])) self.top_layout.addWidget(self._guard_tool_bar) self._center_freq_tool_bar = Qt.QToolBar(self) self._center_freq_tool_bar.addWidget(Qt.QLabel('Frecuency' + ": ")) self._center_freq_line_edit = Qt.QLineEdit(str(self.center_freq)) self._center_freq_tool_bar.addWidget(self._center_freq_line_edit) self._center_freq_line_edit.returnPressed.connect( lambda: self.set_center_freq( eng_notation.str_to_num( str(self._center_freq_line_edit.text().toAscii())))) self.top_layout.addWidget(self._center_freq_tool_bar) self.Tabber = Qt.QTabWidget() self.Tabber_widget_0 = Qt.QWidget() self.Tabber_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.Tabber_widget_0) self.Tabber_grid_layout_0 = Qt.QGridLayout() self.Tabber_layout_0.addLayout(self.Tabber_grid_layout_0) self.Tabber.addTab(self.Tabber_widget_0, 'Spectrum') self.Tabber_widget_1 = Qt.QWidget() self.Tabber_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.Tabber_widget_1) self.Tabber_grid_layout_1 = Qt.QGridLayout() self.Tabber_layout_1.addLayout(self.Tabber_grid_layout_1) self.Tabber.addTab(self.Tabber_widget_1, 'Constellation') self.Tabber_widget_2 = Qt.QWidget() self.Tabber_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.Tabber_widget_2) self.Tabber_grid_layout_2 = Qt.QGridLayout() self.Tabber_layout_2.addLayout(self.Tabber_grid_layout_2) self.Tabber.addTab(self.Tabber_widget_2, 'Van de Beek') self.Tabber_widget_3 = Qt.QWidget() self.Tabber_layout_3 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.Tabber_widget_3) self.Tabber_grid_layout_3 = Qt.QGridLayout() self.Tabber_layout_3.addLayout(self.Tabber_grid_layout_3) self.Tabber.addTab(self.Tabber_widget_3, 'Measurements') self.top_grid_layout.addWidget(self.Tabber, 0, 0, 0, 0) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( (int(total_carriers * (1 + guard))), #size samp_rate, #samp_rate 'ML OFDM Synchronization', #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(-0.02, 0.0015) 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(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.Tabber_grid_layout_2.addWidget(self._qtgui_time_sink_x_0_win, 0, 1, 1, 1) self.qtgui_number_sink_0_1 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_VERT, 1) self.qtgui_number_sink_0_1.set_update_time(0.10) self.qtgui_number_sink_0_1.set_title("Modulation Error Rate B") 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_1.set_min(i, 0) self.qtgui_number_sink_0_1.set_max(i, 50) self.qtgui_number_sink_0_1.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_1.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_1.set_label(i, labels[i]) self.qtgui_number_sink_0_1.set_unit(i, units[i]) self.qtgui_number_sink_0_1.set_factor(i, factor[i]) self.qtgui_number_sink_0_1.enable_autoscale(False) self._qtgui_number_sink_0_1_win = sip.wrapinstance( self.qtgui_number_sink_0_1.pyqwidget(), Qt.QWidget) self.Tabber_grid_layout_3.addWidget(self._qtgui_number_sink_0_1_win, 1, 1, 1, 1) self.qtgui_number_sink_0_0_1_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_VERT, 1) self.qtgui_number_sink_0_0_1_0.set_update_time(0.10) self.qtgui_number_sink_0_0_1_0.set_title("BER Viterbi") 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_1_0.set_min(i, 0) self.qtgui_number_sink_0_0_1_0.set_max(i, 1) self.qtgui_number_sink_0_0_1_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0_1_0.set_label( i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0_1_0.set_label(i, labels[i]) self.qtgui_number_sink_0_0_1_0.set_unit(i, units[i]) self.qtgui_number_sink_0_0_1_0.set_factor(i, factor[i]) self.qtgui_number_sink_0_0_1_0.enable_autoscale(False) self._qtgui_number_sink_0_0_1_0_win = sip.wrapinstance( self.qtgui_number_sink_0_0_1_0.pyqwidget(), Qt.QWidget) self.Tabber_grid_layout_3.addWidget( self._qtgui_number_sink_0_0_1_0_win, 0, 2, 1, 1) self.qtgui_number_sink_0_0_1 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_VERT, 1) self.qtgui_number_sink_0_0_1.set_update_time(0.10) self.qtgui_number_sink_0_0_1.set_title("BER Viterbi") 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_1.set_min(i, 0) self.qtgui_number_sink_0_0_1.set_max(i, 1) self.qtgui_number_sink_0_0_1.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0_1.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0_1.set_label(i, labels[i]) self.qtgui_number_sink_0_0_1.set_unit(i, units[i]) self.qtgui_number_sink_0_0_1.set_factor(i, factor[i]) self.qtgui_number_sink_0_0_1.enable_autoscale(False) self._qtgui_number_sink_0_0_1_win = sip.wrapinstance( self.qtgui_number_sink_0_0_1.pyqwidget(), Qt.QWidget) self.Tabber_grid_layout_3.addWidget(self._qtgui_number_sink_0_0_1_win, 1, 2, 1, 1) self.qtgui_number_sink_0_0_0_0_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_VERT, 1) self.qtgui_number_sink_0_0_0_0_0.set_update_time(0.10) self.qtgui_number_sink_0_0_0_0_0.set_title("BER Reed Solomon") 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_0_0_0.set_min(i, 0) self.qtgui_number_sink_0_0_0_0_0.set_max(i, 1) self.qtgui_number_sink_0_0_0_0_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0_0_0_0.set_label( i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0_0_0_0.set_label(i, labels[i]) self.qtgui_number_sink_0_0_0_0_0.set_unit(i, units[i]) self.qtgui_number_sink_0_0_0_0_0.set_factor(i, factor[i]) self.qtgui_number_sink_0_0_0_0_0.enable_autoscale(False) self._qtgui_number_sink_0_0_0_0_0_win = sip.wrapinstance( self.qtgui_number_sink_0_0_0_0_0.pyqwidget(), Qt.QWidget) self.Tabber_grid_layout_3.addWidget( self._qtgui_number_sink_0_0_0_0_0_win, 0, 3, 1, 1) self.qtgui_number_sink_0_0_0_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_VERT, 1) self.qtgui_number_sink_0_0_0_0.set_update_time(0.10) self.qtgui_number_sink_0_0_0_0.set_title("BER Reed Solomon") 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_0_0.set_min(i, 0) self.qtgui_number_sink_0_0_0_0.set_max(i, 1) self.qtgui_number_sink_0_0_0_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0_0_0.set_label( i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0_0_0.set_label(i, labels[i]) self.qtgui_number_sink_0_0_0_0.set_unit(i, units[i]) self.qtgui_number_sink_0_0_0_0.set_factor(i, factor[i]) self.qtgui_number_sink_0_0_0_0.enable_autoscale(False) self._qtgui_number_sink_0_0_0_0_win = sip.wrapinstance( self.qtgui_number_sink_0_0_0_0.pyqwidget(), Qt.QWidget) self.Tabber_grid_layout_3.addWidget( self._qtgui_number_sink_0_0_0_0_win, 1, 3, 1, 1) self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_VERT, 1) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("Modulation Error Rate A") 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, 0) self.qtgui_number_sink_0.set_max(i, 50) 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.Tabber_grid_layout_3.addWidget(self._qtgui_number_sink_0_win, 0, 1, 1, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_RECTANGULAR, #wintype center_freq, #fc samp_rate, #bw "Incoming spectrum", #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(10, -140) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(True) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(0.2) 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 "complex" == "float" or "complex" == "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.Tabber_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 1, 1) self.qtgui_const_sink_x_0_1_0 = qtgui.const_sink_c( 0 * 96 * 2**(mode - 1), #size 'Constellation', #name 1 #number of inputs ) self.qtgui_const_sink_x_0_1_0.set_update_time(0.10) self.qtgui_const_sink_x_0_1_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_1_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_1_0.enable_autoscale(False) self.qtgui_const_sink_x_0_1_0.enable_grid(False) self.qtgui_const_sink_x_0_1_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_1_0.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.qtgui_const_sink_x_0_1_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_1_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_1_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_1_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_1_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_1_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_1_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_1_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_1_0.pyqwidget(), Qt.QWidget) self.Tabber_grid_layout_1.addWidget(self._qtgui_const_sink_x_0_1_0_win, 2, 0, 2, 2) self.qtgui_const_sink_x_0_1 = qtgui.const_sink_c( 12 * 96 * 2**(mode - 1), #size 'Constellation_Layer_B', #name 1 #number of inputs ) self.qtgui_const_sink_x_0_1.set_update_time(0.10) self.qtgui_const_sink_x_0_1.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_1.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_1.enable_autoscale(False) self.qtgui_const_sink_x_0_1.enable_grid(False) self.qtgui_const_sink_x_0_1.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_1.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.qtgui_const_sink_x_0_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_1.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_1.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_1.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_1.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_1.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_1.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_1_win = sip.wrapinstance( self.qtgui_const_sink_x_0_1.pyqwidget(), Qt.QWidget) self.Tabber_grid_layout_1.addWidget(self._qtgui_const_sink_x_0_1_win, 0, 2, 1, 1) self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( data_carriers, #size 'Constellation_Layer_All', #name 1 #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) if not True: self.qtgui_const_sink_x_0_0.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.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.Tabber_grid_layout_1.addWidget(self._qtgui_const_sink_x_0_0_win, 2, 2, 1, 1) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1 * 96 * 2**(mode - 1), #size 'Constellation_Layer_A', #name 1 #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) if not True: self.qtgui_const_sink_x_0.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.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.Tabber_grid_layout_1.addWidget(self._qtgui_const_sink_x_0_win, 0, 0, 1, 1) self.low_pass_filter_0_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate, 6e6 / 2.0, 0.5e6, firdes.WIN_HAMMING, 6.76)) self.isdbt_tmcc_decoder_0 = isdbt.tmcc_decoder(3, True) self.isdbt_time_deinterleaver_0 = isdbt.time_deinterleaver( 3, 1, 4, 12, 2, 0, 0) self.isdbt_sync_and_channel_estimation_0 = isdbt.sync_and_channel_estimation( 8192, 5617, 200) self.isdbt_symbol_demapper_0 = isdbt.symbol_demapper( 3, 1, 4, 12, 64, 0, 64) self.isdbt_subset_of_carriers_0_0_0 = isdbt.subset_of_carriers( data_carriers, 0, 0) self.isdbt_subset_of_carriers_0_0 = isdbt.subset_of_carriers( data_carriers, 0, A * 96 * 2**(mode - 1) - 1) self.isdbt_subset_of_carriers_0 = isdbt.subset_of_carriers( data_carriers, 384, 4991) self.isdbt_ofdm_sym_acquisition_0 = isdbt.ofdm_sym_acquisition( total_carriers, int(guard * total_carriers), 10) self.isdbt_frequency_deinterleaver_0 = isdbt.frequency_deinterleaver( True, 3) self.isdbt_channel_decoding_0_0 = isdbt.isdbt_channel_decoding( layer_segments=1, mode=3, constellation_size=4, rate=1, ) self.isdbt_channel_decoding_0 = isdbt.isdbt_channel_decoding( layer_segments=12, mode=3, constellation_size=64, rate=2, ) self.fft_vxx_0 = fft.fft_vcc(total_carriers, True, (window.rectangular(total_carriers)), True, 1) self.blocks_vector_to_stream_0_2_1_0 = blocks.vector_to_stream( gr.sizeof_gr_complex * 1, C * 96 * 2**(mode - 1) + 1) self.blocks_vector_to_stream_0_2_1 = blocks.vector_to_stream( gr.sizeof_gr_complex * 1, 4608) self.blocks_vector_to_stream_0_2_0 = blocks.vector_to_stream( gr.sizeof_gr_complex * 1, data_carriers) self.blocks_vector_to_stream_0_2 = blocks.vector_to_stream( gr.sizeof_gr_complex * 1, A * 96 * 2**(mode - 1)) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_stream_to_vector_0_0_0 = blocks.stream_to_vector( gr.sizeof_char * 1, 188) self.blocks_stream_to_vector_0_0 = blocks.stream_to_vector( gr.sizeof_char * 1, 188) self.blocks_null_sink_0_0_0_0 = blocks.null_sink(gr.sizeof_char * 188) self.blocks_null_sink_0_0_0 = blocks.null_sink(gr.sizeof_char * 188) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_char * 384) self.blocks_file_source_1_0 = blocks.file_source( gr.sizeof_gr_complex * 1, '/home/jordy/Descargas/569MHz_recording/569MHz_recording.dat', True) self.SYNC_0 = SYNC( guarda=guard, mode=mode, ) self.MER_FULL_SEG_0 = MER_FULL_SEG( Modulation_Scheme_A=(1 + 1j, 1 - 1j, -1 + 1j, -1 - 1j) / np.sqrt(2), Modulation_Scheme_B=( 7 + 7j, 7 + 5j, 5 + 7j, 5 + 5j, 7 + 1j, 7 + 3j, 5 + 1j, 5 + 3j, 1 + 7j, 1 + 5j, 3 + 7j, 3 + 5j, 1 + 1j, 1 + 3j, 3 + 1j, 3 + 3j, 7 - 7j, 7 - 5j, 5 - 7j, 5 - 5j, 7 - 1j, 7 - 3j, 5 - 1j, 5 - 3j, 1 - 7j, 1 - 5j, 3 - 7j, 3 - 5j, 1 - 1j, 1 - 3j, 3 - 1j, 3 - 3j, -7 + 7j, -7 + 5j, -5 + 7j, -5 + 5j, -7 + 1j, -7 + 3j, -5 + 1j, -5 + 3j, -1 + 7j, -1 + 5j, -3 + 7j, -3 + 5j, -1 + 1j, -1 + 3j, -3 + 1j, -3 + 3j, -7 - 7j, -7 - 5j, -5 - 7j, -5 - 5j, -7 - 1j, -7 - 3j, -5 - 1j, -5 - 3j, -1 - 7j, -1 - 5j, -3 - 7j, -3 - 5j, -1 - 1j, -1 - 3j, -3 - 1j, -3 - 3j) / np.sqrt(42), Modulation_Scheme_C=(3 + 3j, 3 + 1j, 1 + 3j, 1 + 1j, 3 - 3j, 3 - 1j, 1 - 3j, 1 - 1j, -3 + 3j, -3 + 1j, -1 + 3j, -1 + 1j, -3 - 3j, -3 - 1j, -1 - 3j, -1 - 1j) / np.sqrt(10), alpha=0.05, ) ################################################## # Connections ################################################## self.connect((self.MER_FULL_SEG_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.MER_FULL_SEG_0, 1), (self.qtgui_number_sink_0_1, 0)) self.connect((self.SYNC_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_file_source_1_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_stream_to_vector_0_0, 0), (self.blocks_null_sink_0_0_0, 0)) self.connect((self.blocks_stream_to_vector_0_0_0, 0), (self.blocks_null_sink_0_0_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_vector_to_stream_0_2, 0), (self.MER_FULL_SEG_0, 0)) self.connect((self.blocks_vector_to_stream_0_2, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_vector_to_stream_0_2_0, 0), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.blocks_vector_to_stream_0_2_1, 0), (self.MER_FULL_SEG_0, 1)) self.connect((self.blocks_vector_to_stream_0_2_1, 0), (self.qtgui_const_sink_x_0_1, 0)) self.connect((self.blocks_vector_to_stream_0_2_1_0, 0), (self.MER_FULL_SEG_0, 2)) self.connect((self.blocks_vector_to_stream_0_2_1_0, 0), (self.qtgui_const_sink_x_0_1_0, 0)) self.connect((self.fft_vxx_0, 0), (self.isdbt_sync_and_channel_estimation_0, 0)) self.connect((self.isdbt_channel_decoding_0, 0), (self.blocks_stream_to_vector_0_0, 0)) self.connect((self.isdbt_channel_decoding_0, 1), (self.qtgui_number_sink_0_0_0_0, 0)) self.connect((self.isdbt_channel_decoding_0, 2), (self.qtgui_number_sink_0_0_1, 0)) self.connect((self.isdbt_channel_decoding_0_0, 0), (self.blocks_stream_to_vector_0_0_0, 0)) self.connect((self.isdbt_channel_decoding_0_0, 1), (self.qtgui_number_sink_0_0_0_0_0, 0)) self.connect((self.isdbt_channel_decoding_0_0, 2), (self.qtgui_number_sink_0_0_1_0, 0)) self.connect((self.isdbt_frequency_deinterleaver_0, 0), (self.isdbt_time_deinterleaver_0, 0)) self.connect((self.isdbt_ofdm_sym_acquisition_0, 0), (self.fft_vxx_0, 0)) self.connect((self.isdbt_subset_of_carriers_0, 0), (self.blocks_vector_to_stream_0_2_1, 0)) self.connect((self.isdbt_subset_of_carriers_0_0, 0), (self.blocks_vector_to_stream_0_2, 0)) self.connect((self.isdbt_subset_of_carriers_0_0_0, 0), (self.blocks_vector_to_stream_0_2_1_0, 0)) self.connect((self.isdbt_symbol_demapper_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.isdbt_symbol_demapper_0, 1), (self.isdbt_channel_decoding_0, 0)) self.connect((self.isdbt_symbol_demapper_0, 0), (self.isdbt_channel_decoding_0_0, 0)) self.connect((self.isdbt_sync_and_channel_estimation_0, 0), (self.isdbt_tmcc_decoder_0, 0)) self.connect((self.isdbt_time_deinterleaver_0, 0), (self.blocks_vector_to_stream_0_2_0, 0)) self.connect((self.isdbt_time_deinterleaver_0, 0), (self.isdbt_subset_of_carriers_0, 0)) self.connect((self.isdbt_time_deinterleaver_0, 0), (self.isdbt_subset_of_carriers_0_0, 0)) self.connect((self.isdbt_time_deinterleaver_0, 0), (self.isdbt_subset_of_carriers_0_0_0, 0)) self.connect((self.isdbt_time_deinterleaver_0, 0), (self.isdbt_symbol_demapper_0, 0)) self.connect((self.isdbt_tmcc_decoder_0, 0), (self.isdbt_frequency_deinterleaver_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.SYNC_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.isdbt_ofdm_sym_acquisition_0, 0))
def __init__(self, fft_length, cp_length, snr, kstime, logging): ''' Maximum Likelihood OFDM synchronizer: J. van de Beek, M. Sandell, and P. O. Borjesson, "ML Estimation of Time and Frequency Offset in OFDM Systems," IEEE Trans. Signal Processing, vol. 45, no. 7, pp. 1800-1805, 1997. ''' gr.hier_block2.__init__(self, "ofdm_sync_ml", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature2(2, 2, gr.sizeof_float, gr.sizeof_char)) # Output signature self.input = blocks.add_const_cc(0) SNR = 10.0**(snr / 10.0) rho = SNR / (SNR + 1.0) symbol_length = fft_length + cp_length # ML Sync # Energy Detection from ML Sync self.connect(self, self.input) # Create a delay line self.delay = blocks.delay(gr.sizeof_gr_complex, fft_length) self.connect(self.input, self.delay) # magnitude squared blocks self.magsqrd1 = blocks.complex_to_mag_squared() self.magsqrd2 = blocks.complex_to_mag_squared() self.adder = blocks.add_ff() moving_sum_taps = [rho / 2 for i in range(cp_length)] self.moving_sum_filter = filter.fir_filter_fff(1,moving_sum_taps) self.connect(self.input,self.magsqrd1) self.connect(self.delay,self.magsqrd2) self.connect(self.magsqrd1,(self.adder,0)) self.connect(self.magsqrd2,(self.adder,1)) self.connect(self.adder,self.moving_sum_filter) # Correlation from ML Sync self.conjg = blocks.conjugate_cc(); self.mixer = blocks.multiply_cc(); movingsum2_taps = [1.0 for i in range(cp_length)] self.movingsum2 = filter.fir_filter_ccf(1,movingsum2_taps) # Correlator data handler self.c2mag = blocks.complex_to_mag() self.angle = blocks.complex_to_arg() self.connect(self.input,(self.mixer,1)) self.connect(self.delay,self.conjg,(self.mixer,0)) self.connect(self.mixer,self.movingsum2,self.c2mag) self.connect(self.movingsum2,self.angle) # ML Sync output arg, need to find maximum point of this self.diff = blocks.sub_ff() self.connect(self.c2mag,(self.diff,0)) self.connect(self.moving_sum_filter,(self.diff,1)) #ML measurements input to sampler block and detect self.f2c = blocks.float_to_complex() self.pk_detect = blocks.peak_detector_fb(0.2, 0.25, 30, 0.0005) self.sample_and_hold = blocks.sample_and_hold_ff() # use the sync loop values to set the sampler and the NCO # self.diff = theta # self.angle = epsilon self.connect(self.diff, self.pk_detect) # The DPLL corrects for timing differences between CP correlations use_dpll = 0 if use_dpll: self.dpll = gr.dpll_bb(float(symbol_length),0.01) self.connect(self.pk_detect, self.dpll) self.connect(self.dpll, (self.sample_and_hold,1)) else: self.connect(self.pk_detect, (self.sample_and_hold,1)) self.connect(self.angle, (self.sample_and_hold,0)) ################################ # correlate against known symbol # This gives us the same timing signal as the PN sync block only on the preamble # we don't use the signal generated from the CP correlation because we don't want # to readjust the timing in the middle of the packet or we ruin the equalizer settings. kstime = [k.conjugate() for k in kstime] kstime.reverse() self.kscorr = filter.fir_filter_ccc(1, kstime) self.corrmag = blocks.complex_to_mag_squared() self.div = blocks.divide_ff() # The output signature of the correlation has a few spikes because the rest of the # system uses the repeated preamble symbol. It needs to work that generically if # anyone wants to use this against a WiMAX-like signal since it, too, repeats. # The output theta of the correlator above is multiplied with this correlation to # identify the proper peak and remove other products in this cross-correlation self.threshold_factor = 0.1 self.slice = blocks.threshold_ff(self.threshold_factor, self.threshold_factor, 0) self.f2b = blocks.float_to_char() self.b2f = blocks.char_to_float() self.mul = blocks.multiply_ff() # Normalize the power of the corr output by the energy. This is not really needed # and could be removed for performance, but it makes for a cleaner signal. # if this is removed, the threshold value needs adjustment. self.connect(self.input, self.kscorr, self.corrmag, (self.div,0)) self.connect(self.moving_sum_filter, (self.div,1)) self.connect(self.div, (self.mul,0)) self.connect(self.pk_detect, self.b2f, (self.mul,1)) self.connect(self.mul, self.slice) # Set output signals # Output 0: fine frequency correction value # Output 1: timing signal self.connect(self.sample_and_hold, (self,0)) self.connect(self.slice, self.f2b, (self,1)) if logging: self.connect(self.moving_sum_filter, blocks.file_sink(gr.sizeof_float, "ofdm_sync_ml-energy_f.dat")) self.connect(self.diff, blocks.file_sink(gr.sizeof_float, "ofdm_sync_ml-theta_f.dat")) self.connect(self.angle, blocks.file_sink(gr.sizeof_float, "ofdm_sync_ml-epsilon_f.dat")) self.connect(self.corrmag, blocks.file_sink(gr.sizeof_float, "ofdm_sync_ml-corrmag_f.dat")) self.connect(self.kscorr, blocks.file_sink(gr.sizeof_gr_complex, "ofdm_sync_ml-kscorr_c.dat")) self.connect(self.div, blocks.file_sink(gr.sizeof_float, "ofdm_sync_ml-div_f.dat")) self.connect(self.mul, blocks.file_sink(gr.sizeof_float, "ofdm_sync_ml-mul_f.dat")) self.connect(self.slice, blocks.file_sink(gr.sizeof_float, "ofdm_sync_ml-slice_f.dat")) self.connect(self.pk_detect, blocks.file_sink(gr.sizeof_char, "ofdm_sync_ml-peaks_b.dat")) if use_dpll: self.connect(self.dpll, blocks.file_sink(gr.sizeof_char, "ofdm_sync_ml-dpll_b.dat")) self.connect(self.sample_and_hold, blocks.file_sink(gr.sizeof_float, "ofdm_sync_ml-sample_and_hold_f.dat")) self.connect(self.input, blocks.file_sink(gr.sizeof_gr_complex, "ofdm_sync_ml-input_c.dat"))
def __init__(self): gr.top_block.__init__(self, "Basestation 3") Qt.QWidget.__init__(self) self.setWindowTitle("Basestation 3") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "Basestation_3") self.restoreGeometry(self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 800000 self.code1 = code1 = '010110011011101100010101011111101001001110001011010001101010001' ################################################## # Blocks ################################################## self.uhd_usrp_source = uhd.usrp_source( ",".join(('serial=30AD2B6', 'serial=30AD2B6')), uhd.stream_args( cpu_format="fc32", args='peak=0.003906', channels=range(2), ), ) self.uhd_usrp_source.set_samp_rate(samp_rate) self.uhd_usrp_source.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_source.set_center_freq(2400000000, 0) self.uhd_usrp_source.set_gain(50, 0) self.uhd_usrp_source.set_antenna('RX2', 0) self.uhd_usrp_source.set_auto_dc_offset(True, 0) self.uhd_usrp_source.set_auto_iq_balance(True, 0) self.uhd_usrp_source.set_center_freq(2400000000, 1) self.uhd_usrp_source.set_gain(50, 1) self.uhd_usrp_source.set_antenna('RX2', 1) self.uhd_usrp_source.set_auto_dc_offset(True, 1) self.uhd_usrp_source.set_auto_iq_balance(True, 1) self.low_pass_filter_0_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, samp_rate, 200000, 50000, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, samp_rate, samp_rate/4, samp_rate/8, firdes.WIN_HAMMING, 6.76)) self.digital_gmsk_demod_0_0 = digital.gmsk_demod( samples_per_symbol=2, gain_mu=0.175, mu=0.5, omega_relative_limit=0.005, freq_error=0.0, verbose=False, log=False, ) self.digital_gmsk_demod_0 = digital.gmsk_demod( samples_per_symbol=2, gain_mu=0.175, mu=0.5, omega_relative_limit=0.005, freq_error=0.0, verbose=False, log=False, ) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((1, )) self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_char*1, '/home/capstone2021/Desktop/Gun software/file_receive/Text/Text_recie.txt', append=False) self.blocks_file_sink_1.set_unbuffered(True) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, '/home/capstone2021/Desktop/Gun software/file_receive/Jpg/Jpg_receive.jpg', append=False) self.blocks_file_sink_0.set_unbuffered(True) self.blks2_packet_decoder_0_0 = grc_blks2.packet_demod_b(grc_blks2.packet_decoder( access_code='', threshold=-1, callback=lambda ok, payload: self.blks2_packet_decoder_0_0.recv_pkt(ok, payload), ), ) self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b(grc_blks2.packet_decoder( access_code='', threshold=-1, callback=lambda ok, payload: self.blks2_packet_decoder_0.recv_pkt(ok, payload), ), ) ################################################## # Connections ################################################## self.connect((self.blks2_packet_decoder_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blks2_packet_decoder_0_0, 0), (self.blocks_file_sink_1, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.digital_gmsk_demod_0, 0), (self.blks2_packet_decoder_0, 0)) self.connect((self.digital_gmsk_demod_0_0, 0), (self.blks2_packet_decoder_0_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.digital_gmsk_demod_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.digital_gmsk_demod_0_0, 0)) self.connect((self.uhd_usrp_source, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.uhd_usrp_source, 1), (self.low_pass_filter_0_0, 0))
def __init__(self): gr.top_block.__init__( self, "X310 Phase Calibration, Start Time [UTC]: 2020-08-07T03:06:19.775945Z" ) Qt.QWidget.__init__(self) self.setWindowTitle( "X310 Phase Calibration, Start Time [UTC]: 2020-08-07T03:06:19.775945Z" ) 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", "x310_phase_cal") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.ts_str = ts_str = dt.strftime(dt.utcnow(), "%Y-%m-%dT%H:%M:%S.%fZ") self.phase_deg = phase_deg = 0 self.title_str = title_str = "X310 Phase Calibration, Start Time [UTC]: {:s}".format( ts_str) self.samp_rate = samp_rate = .5e6 self.rx_freq = rx_freq = 10e6 self.phase_rad = phase_rad = phase_deg * math.pi / 180.0 self.decim = decim = 10 ################################################## # Blocks ################################################## 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, 4, 0, 1, 1) for r in range(4, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._rx_freq_tool_bar = Qt.QToolBar(self) self._rx_freq_tool_bar.addWidget(Qt.QLabel('FREQ' + ": ")) self._rx_freq_line_edit = Qt.QLineEdit(str(self.rx_freq)) self._rx_freq_tool_bar.addWidget(self._rx_freq_line_edit) self._rx_freq_line_edit.returnPressed.connect(lambda: self.set_rx_freq( eng_notation.str_to_num( str(self._rx_freq_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._rx_freq_tool_bar, 4, 1, 1, 1) for r in range(4, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.uhd_usrp_source_1 = uhd.usrp_source( ",".join(("addr=192.168.10.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) self.uhd_usrp_source_1.set_clock_source('internal', 0) self.uhd_usrp_source_1.set_time_source('gpsdo', 0) self.uhd_usrp_source_1.set_subdev_spec('A:AB B:AB', 0) self.uhd_usrp_source_1.set_samp_rate(samp_rate) self.uhd_usrp_source_1.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_source_1.set_center_freq(uhd.tune_request(rx_freq), 0) self.uhd_usrp_source_1.set_gain(0, 0) self.uhd_usrp_source_1.set_antenna('A', 0) self.uhd_usrp_source_1.set_auto_dc_offset(True, 0) self.uhd_usrp_source_1.set_auto_iq_balance(True, 0) self.uhd_usrp_source_1.set_center_freq(uhd.tune_request(rx_freq), 1) self.uhd_usrp_source_1.set_gain(0, 1) self.uhd_usrp_source_1.set_antenna('A', 1) self.uhd_usrp_source_1.set_auto_dc_offset(True, 1) self.uhd_usrp_source_1.set_auto_iq_balance(True, 1) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=1, decimation=decim, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=decim, taps=None, fractional_bw=None, ) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 8192, #size samp_rate / decim, #samp_rate "", #name 2 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.010) 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(True) 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(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = ['N/S', 'E/W', '', '', '', '', '', '', '', ''] 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_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_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 9, 0, 1, 6) for r in range(9, 10): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 6): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0, 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, -360) self.qtgui_number_sink_0.set_max(i, 360) 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) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype rx_freq * 0, #fc samp_rate / decim, #bw "East/West", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.010) self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 0) self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB') 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(True) self.qtgui_freq_sink_x_0_0.set_fft_average(0.2) self.qtgui_freq_sink_x_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_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_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.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_win, 0, 4, 4, 4) for r in range(0, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 8): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype rx_freq * 0, #fc samp_rate / decim, #bw "North/South", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.010) self.qtgui_freq_sink_x_0.set_y_axis(-140, 0) 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(True) self.qtgui_freq_sink_x_0.set_fft_average(0.2) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "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_grid_layout.addWidget(self._qtgui_freq_sink_x_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._phase_deg_tool_bar = Qt.QToolBar(self) self._phase_deg_tool_bar.addWidget( Qt.QLabel('Phase Shift [deg]' + ": ")) self._phase_deg_line_edit = Qt.QLineEdit(str(self.phase_deg)) self._phase_deg_tool_bar.addWidget(self._phase_deg_line_edit) self._phase_deg_line_edit.returnPressed.connect( lambda: self.set_phase_deg( eng_notation.str_to_num( str(self._phase_deg_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._phase_deg_tool_bar) self.low_pass_filter_0_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate / decim, 5e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate / decim, 3e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float * 1) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc( (complex(math.cos(phase_rad), math.sin(phase_rad)), )) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff( (180.0 / math.pi, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( (180.0 / math.pi, )) self.blocks_complex_to_magphase_1 = blocks.complex_to_magphase(1) self.blocks_complex_to_magphase_0 = blocks.complex_to_magphase(1) self.analog_agc2_xx_1 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_1.set_max_gain(65536) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 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.rational_resampler_xxx_0_0, 0)) self.connect((self.analog_agc2_xx_1, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_complex_to_magphase_0, 1), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_complex_to_magphase_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.blocks_complex_to_magphase_1, 1), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.blocks_complex_to_magphase_1, 0), (self.blocks_null_sink_0, 1)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.qtgui_time_sink_x_0_0, 1)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.analog_agc2_xx_1, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_complex_to_magphase_1, 0)) self.connect((self.low_pass_filter_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.blocks_complex_to_magphase_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.uhd_usrp_source_1, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.uhd_usrp_source_1, 1), (self.blocks_multiply_const_vxx_1, 0))
def __init__(self, gs_name='VTGS', ip='0.0.0.0', meta_rate=.1, port='52003', record_iq=0, record_rfo=0, record_snr=0, tx_freq=1265e6, tx_offset=250e3): gr.top_block.__init__(self, "VTGS Rocksat-X 2017 Transceiver v2.0") Qt.QWidget.__init__(self) self.setWindowTitle("VTGS Rocksat-X 2017 Transceiver v2.0") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "vtgs_trx") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.gs_name = gs_name self.ip = ip self.meta_rate = meta_rate self.port = port self.record_iq = record_iq self.record_rfo = record_rfo self.record_snr = record_snr self.tx_freq = tx_freq self.tx_offset = tx_offset ################################################## # Variables ################################################## self.ts_str = ts_str = dt.strftime(dt.utcnow(), "%Y%m%d_%H%M%S.%f") + '_UTC' self.samp_rate = samp_rate = 500e3 self.baud = baud = 125e3 self.snr_fn = snr_fn = "{:s}_{:s}.snr".format(gs_name, ts_str) self.samps_per_symb = samps_per_symb = int(samp_rate / baud) self.rx_freq = rx_freq = 2395e6 self.rfo_fn = rfo_fn = "{:s}_{:s}.rfo".format(gs_name, ts_str) self.iq_fn = iq_fn = "{:s}_{:s}_{:s}k.fc32".format( gs_name, ts_str, str(int(samp_rate) / 1000)) self.alpha = alpha = 0.5 self.uplink_label = uplink_label = '' self.tx_gain = tx_gain = 25 self.tx_correct = tx_correct = 2000 self.snr_fp = snr_fp = "/captures/rocksat/{:s}".format(snr_fn) self.rx_offset = rx_offset = 250e3 self.rx_gain = rx_gain = 1 self.rx_freq_lbl = rx_freq_lbl = "{:4.3f}".format(rx_freq / 1e6) self.rrc_filter_taps = rrc_filter_taps = firdes.root_raised_cosine( 32, 1.0, 1.0 / (samps_per_symb * 32), alpha, samps_per_symb * 32) self.rfo_fp = rfo_fp = "/captures/rocksat/{:s}".format(rfo_fn) self.mult = mult = (samp_rate) / 2 / 3.141593 self.lpf_taps = lpf_taps = firdes.low_pass(1.0, samp_rate, samp_rate / 2, 1000, firdes.WIN_HAMMING, 6.76) self.lo = lo = 1833e6 self.khz_offset = khz_offset = 0 self.iq_fp = iq_fp = "/captures/rocksat/{:s}".format(iq_fn) self.bb_gain = bb_gain = .75 ################################################## # Blocks ################################################## self._tx_gain_range = Range(0, 86, 1, 25, 200) self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain, 'TX Gain', "counter_slider", float) self.top_grid_layout.addWidget(self._tx_gain_win, 10, 8, 1, 4) self._tx_correct_range = Range(-10000, 10000, 1, 2000, 200) self._tx_correct_win = RangeWidget(self._tx_correct_range, self.set_tx_correct, "tx_correct", "counter_slider", float) self.top_grid_layout.addWidget(self._tx_correct_win, 12, 8, 1, 4) self._rx_gain_range = Range(0, 86, 1, 1, 200) self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain, 'RX Gain', "counter_slider", float) self.top_grid_layout.addWidget(self._rx_gain_win, 3, 8, 1, 4) self._khz_offset_range = Range(-150, 150, 1, 0, 200) self._khz_offset_win = RangeWidget(self._khz_offset_range, self.set_khz_offset, 'Offset [kHz]', "counter_slider", float) self.top_grid_layout.addWidget(self._khz_offset_win, 4, 8, 1, 4) self._bb_gain_range = Range(0, 1, .01, .75, 200) self._bb_gain_win = RangeWidget(self._bb_gain_range, self.set_bb_gain, 'bb_gain', "counter_slider", float) self.top_grid_layout.addWidget(self._bb_gain_win, 11, 8, 1, 4) self.vtgs_mult_descrambler_0 = vtgs.mult_descrambler(17, 0x3FFFF) self.vtgs_ao40_decoder_0_0 = vtgs.ao40_decoder() self._uplink_label_tool_bar = Qt.QToolBar(self) if None: self._uplink_label_formatter = None else: self._uplink_label_formatter = lambda x: str(x) self._uplink_label_tool_bar.addWidget(Qt.QLabel('TX MSG' + ": ")) self._uplink_label_label = Qt.QLabel( str(self._uplink_label_formatter(self.uplink_label))) self._uplink_label_tool_bar.addWidget(self._uplink_label_label) self.top_grid_layout.addWidget(self._uplink_label_tool_bar, 9, 8, 1, 1) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("addr=192.168.10.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_clock_source('external', 0) self.uhd_usrp_source_0.set_time_source('external', 0) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_source_0.set_center_freq( uhd.tune_request(rx_freq - lo, rx_offset), 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(("addr=192.168.10.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_clock_source('external', 0) self.uhd_usrp_sink_0.set_time_source('external', 0) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_sink_0.set_center_freq( uhd.tune_request(tx_freq + tx_correct, tx_offset), 0) self.uhd_usrp_sink_0.set_gain(tx_gain, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self._rx_freq_lbl_tool_bar = Qt.QToolBar(self) if None: self._rx_freq_lbl_formatter = None else: self._rx_freq_lbl_formatter = lambda x: str(x) self._rx_freq_lbl_tool_bar.addWidget(Qt.QLabel('RX Freq [MHz]' + ": ")) self._rx_freq_lbl_label = Qt.QLabel( str(self._rx_freq_lbl_formatter(self.rx_freq_lbl))) self._rx_freq_lbl_tool_bar.addWidget(self._rx_freq_lbl_label) self.top_grid_layout.addWidget(self._rx_freq_lbl_tool_bar, 0, 10, 1, 2) self.rational_resampler_xxx_2 = filter.rational_resampler_ccc( interpolation=1, decimation=10, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_1 = filter.rational_resampler_ccc( interpolation=1, decimation=8, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=8, taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 4096, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw '', #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.010) self.qtgui_waterfall_sink_x_0.enable_grid(True) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not False: 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 = ['pre-d', 'post', '', '', '', '', '', '', '', ''] colors = [0, 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 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(-130, -20) 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, 5, 0, 4, 8) self.qtgui_number_sink_2 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_2.set_update_time(0.10) self.qtgui_number_sink_2.set_title("") labels = ['EVM', '', '', '', '', '', '', '', '', ''] units = ['', '', '', '', '', '', '', '', '', ''] colors = [("blue", "red"), ("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_2.set_min(i, -1) self.qtgui_number_sink_2.set_max(i, 1) self.qtgui_number_sink_2.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_2.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_2.set_label(i, labels[i]) self.qtgui_number_sink_2.set_unit(i, units[i]) self.qtgui_number_sink_2.set_factor(i, factor[i]) self.qtgui_number_sink_2.enable_autoscale(False) self._qtgui_number_sink_2_win = sip.wrapinstance( self.qtgui_number_sink_2.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_2_win, 2, 8, 1, 4) self.qtgui_number_sink_0_0_0_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_0_0_0_0.set_update_time(0.10) self.qtgui_number_sink_0_0_0_0.set_title("") labels = ['SNR', '', '', '', '', '', '', '', '', ''] units = ['dB', '', '', '', '', '', '', '', '', ''] colors = [("blue", "red"), ("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_0_0.set_min(i, 0) self.qtgui_number_sink_0_0_0_0.set_max(i, 30) self.qtgui_number_sink_0_0_0_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0_0_0.set_label( i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0_0_0.set_label(i, labels[i]) self.qtgui_number_sink_0_0_0_0.set_unit(i, units[i]) self.qtgui_number_sink_0_0_0_0.set_factor(i, factor[i]) self.qtgui_number_sink_0_0_0_0.enable_autoscale(False) self._qtgui_number_sink_0_0_0_0_win = sip.wrapinstance( self.qtgui_number_sink_0_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_0_0_0_win, 1, 8, 1, 4) self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("") labels = ['RX Freq Offset', 'SNR', '', '', '', '', '', '', '', ''] units = ['Hz', 'dB', '', '', '', '', '', '', '', ''] 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, 0, 8, 1, 2) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / 10, #bw "TX Spectrum", #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(True) 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 False: self.qtgui_freq_sink_x_1.disable_legend() if "complex" == "float" or "complex" == "msg_float": 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 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, 9, 0, 4, 8) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024 * 4, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 2 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.0010) self.qtgui_freq_sink_x_0.set_y_axis(-140, -20) 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(True) self.qtgui_freq_sink_x_0.set_fft_average(0.2) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['pre-d', 'post', '', '', '', '', '', '', '', ''] 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(2): 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, 0, 0, 5, 8) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-1, 1) 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(True) self.qtgui_const_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0.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.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.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 5, 8, 4, 4) self.pyqt_text_input_0 = pyqt.text_input() self._pyqt_text_input_0_win = self.pyqt_text_input_0 self.top_grid_layout.addWidget(self._pyqt_text_input_0_win, 9, 9, 1, 3) self.mapper_demapper_soft_0 = mapper.demapper_soft( mapper.BPSK, ([0, 1])) self.low_pass_filter_0_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate, (baud * (1 + alpha)) / 2, 1000, firdes.WIN_HAMMING, 6.76)) self.kiss_hdlc_framer_0 = kiss.hdlc_framer(preamble_bytes=64, postamble_bytes=16) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( 1, (lpf_taps), khz_offset * 1000, samp_rate) self.digital_scrambler_bb_0 = digital.scrambler_bb(0x21, 0x0, 16) self.digital_pfb_clock_sync_xxx_0_0 = digital.pfb_clock_sync_ccf( samps_per_symb, math.pi * 2 / 100, (rrc_filter_taps), 32, 16, 1.5, 1) self.digital_gmsk_mod_0 = digital.gmsk_mod( samples_per_symbol=50, bt=alpha, verbose=False, log=False, ) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc( math.pi * 2 / 100, 2, False) self.digital_costas_loop_cc_0 = digital.costas_loop_cc( math.pi * 2 / 100, 2, False) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_socket_pdu_0_2 = blocks.socket_pdu("UDP_SERVER", ip, '52002', 1024, False) self.blocks_socket_pdu_0_1 = blocks.socket_pdu("TCP_SERVER", ip, port, 1024, False) self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream( blocks.byte_t, 'packet_len') self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) self.blocks_null_sink_0_0_0 = blocks.null_sink(gr.sizeof_float * 1) self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_float * 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_nlog10_ff_0_1 = blocks.nlog10_ff(10, 1, 0) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc( (bb_gain, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((mult, )) self.blocks_moving_average_xx_0_0_1 = blocks.moving_average_ff( 100000, 0.00001, 4000) self.blocks_moving_average_xx_0_0 = blocks.moving_average_ff( 1000, 0.001, 4000) self.blocks_moving_average_xx_0 = blocks.moving_average_ff( 100000, 0.00001, 4000) self.blocks_keep_one_in_n_0_0 = blocks.keep_one_in_n( gr.sizeof_float * 1, int(samp_rate * meta_rate)) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n( gr.sizeof_float * 1, int(samp_rate / 8 * meta_rate)) self.blocks_file_sink_1_0 = blocks.file_sink(gr.sizeof_float * 1, rfo_fp, False) self.blocks_file_sink_1_0.set_unbuffered(False) self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_float * 1, snr_fp, False) self.blocks_file_sink_1.set_unbuffered(False) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex * 1, iq_fp, 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_0 = blocks.complex_to_mag_squared( 1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-1, )) self.blks2_selector_0_0_0 = grc_blks2.selector( item_size=gr.sizeof_float * 1, num_inputs=1, num_outputs=2, input_index=0, output_index=int(record_snr), ) self.blks2_selector_0_0 = grc_blks2.selector( item_size=gr.sizeof_float * 1, num_inputs=1, num_outputs=2, input_index=0, output_index=int(record_rfo), ) self.blks2_selector_0 = grc_blks2.selector( item_size=gr.sizeof_gr_complex * 1, num_inputs=1, num_outputs=2, input_index=0, output_index=int(record_iq), ) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, 125e3, 1, 0) self.analog_agc2_xx_0_0 = analog.agc2_cc(1e-3, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0_0.set_max_gain(65536) ################################################## # Connections ################################################## self.msg_connect((self.blocks_socket_pdu_0_1, 'pdus'), (self.kiss_hdlc_framer_0, 'in')) self.msg_connect((self.blocks_socket_pdu_0_2, 'pdus'), (self.kiss_hdlc_framer_0, 'in')) self.msg_connect((self.kiss_hdlc_framer_0, 'out'), (self.blocks_pdu_to_tagged_stream_0_0, 'pdus')) self.msg_connect((self.pyqt_text_input_0, 'pdus'), (self.kiss_hdlc_framer_0, 'in')) self.msg_connect((self.vtgs_ao40_decoder_0_0, 'valid_frames'), (self.blocks_socket_pdu_0_1, 'pdus')) self.connect((self.analog_agc2_xx_0_0, 0), (self.digital_costas_loop_cc_0_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blks2_selector_0, 1), (self.blocks_file_sink_0, 0)) self.connect((self.blks2_selector_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.blks2_selector_0_0, 1), (self.blocks_file_sink_1_0, 0)) self.connect((self.blks2_selector_0_0, 0), (self.blocks_null_sink_0_0, 0)) self.connect((self.blks2_selector_0_0_0, 1), (self.blocks_file_sink_1, 0)) self.connect((self.blks2_selector_0_0_0, 0), (self.blocks_null_sink_0_0_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.qtgui_number_sink_2, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_moving_average_xx_0_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_divide_xx_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0_0, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.blocks_divide_xx_0, 0), (self.blocks_nlog10_ff_0_1, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.blks2_selector_0_0_0, 0)) self.connect((self.blocks_keep_one_in_n_0_0, 0), (self.blks2_selector_0_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_keep_one_in_n_0_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blocks_moving_average_xx_0_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_moving_average_xx_0_0_1, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.blocks_moving_average_xx_0_0_1, 0), (self.qtgui_number_sink_0_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.rational_resampler_xxx_2, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.blocks_nlog10_ff_0_1, 0), (self.blocks_moving_average_xx_0_0_1, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.digital_gmsk_mod_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0), (self.digital_scrambler_bb_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.mapper_demapper_soft_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_costas_loop_cc_0_0, 1), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.digital_costas_loop_cc_0_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.digital_costas_loop_cc_0_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.digital_costas_loop_cc_0_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.vtgs_mult_descrambler_0, 0)) self.connect((self.digital_gmsk_mod_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_scrambler_bb_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_agc2_xx_0_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.digital_pfb_clock_sync_xxx_0_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.mapper_demapper_soft_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.blocks_complex_to_mag_squared_0_0, 0)) self.connect((self.rational_resampler_xxx_2, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blks2_selector_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.vtgs_mult_descrambler_0, 0), (self.vtgs_ao40_decoder_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "Multimon Flex Rtl 1") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 2.4e6 self.channel_7 = channel_7 = 931.85e6 self.channel_6 = channel_6 = 931.5e6 self.xlate_filter_taps = xlate_filter_taps = firdes.low_pass( 1, samp_rate, 125000, 25000, firdes.WIN_HAMMING, 6.76) self.sqlch = sqlch = -50 self.if_gain = if_gain = -14 self.gain = gain = 50 self.firdes_tap = firdes_tap = firdes.low_pass(1, samp_rate, 125000, 25000, firdes.WIN_HAMMING, 6.76) self.corr = corr = -14 self.center_freq_1 = center_freq_1 = sum( [channel_6, channel_7]) / float(len([channel_6, channel_7])) self.bb_gain = bb_gain = 40 ################################################## # Blocks ################################################## self.osmosdr_source_0_0 = osmosdr.source(args="numchan=" + str(1) + " " + 'rtl=1') self.osmosdr_source_0_0.set_sample_rate(samp_rate) self.osmosdr_source_0_0.set_center_freq(center_freq_1 - 100000, 0) self.osmosdr_source_0_0.set_freq_corr(corr, 0) self.osmosdr_source_0_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0_0.set_iq_balance_mode(2, 0) self.osmosdr_source_0_0.set_gain_mode(True, 0) self.osmosdr_source_0_0.set_gain(gain, 0) self.osmosdr_source_0_0.set_if_gain(if_gain, 0) self.osmosdr_source_0_0.set_bb_gain(bb_gain, 0) self.osmosdr_source_0_0.set_antenna('', 0) self.osmosdr_source_0_0.set_bandwidth(0, 0) self.low_pass_filter_0_0_0_0_1 = filter.fir_filter_ccf( 1, firdes.low_pass(1, 48e3, 6e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0_0_0_0_0_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, 48e3, 6e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.freq_xlating_fir_filter_xxx_0_0_0_0_1 = filter.freq_xlating_fir_filter_ccc( int(samp_rate / 48000), (firdes_tap), channel_6 - center_freq_1, samp_rate) self.freq_xlating_fir_filter_xxx_0_0_0_0_0_0 = filter.freq_xlating_fir_filter_ccc( int(samp_rate / 48000), (firdes_tap), channel_7 - center_freq_1, samp_rate) self.blocks_udp_sink_3_0_0_0_0 = blocks.udp_sink( gr.sizeof_short * 1, '127.0.0.1', 7306, 1472, True) self.blocks_udp_sink_3_0_0_0 = blocks.udp_sink(gr.sizeof_short * 1, '127.0.0.1', 7307, 1472, True) self.blocks_multiply_xx_0_1 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0_0_0_0_0_1 = blocks.multiply_const_vff( (0.1, )) self.blocks_multiply_const_vxx_0_0_0_0_0_0_0 = blocks.multiply_const_vff( (0.1, )) self.blocks_float_to_short_0_1_0_0_1 = blocks.float_to_short(1, 32767) self.blocks_float_to_short_0_1_0_0_0_0 = blocks.float_to_short( 1, 32767) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, -100000, 1, 0) self.analog_pwr_squelch_xx_0_0_0_0_0_1 = analog.pwr_squelch_cc( sqlch, 1, 1, True) self.analog_pwr_squelch_xx_0_0_0_0_0_0_0 = analog.pwr_squelch_cc( sqlch, 1, 1, True) self.analog_nbfm_rx_0_0_0_0_1 = analog.nbfm_rx( audio_rate=48000, quad_rate=48000, tau=75e-6, max_dev=5000, ) self.analog_nbfm_rx_0_0_0_0_0_0 = analog.nbfm_rx( audio_rate=48000, quad_rate=48000, tau=75e-6, max_dev=5000, ) ################################################## # Connections ################################################## self.connect((self.analog_nbfm_rx_0_0_0_0_0_0, 0), (self.blocks_multiply_const_vxx_0_0_0_0_0_0_0, 0)) self.connect((self.analog_nbfm_rx_0_0_0_0_1, 0), (self.blocks_multiply_const_vxx_0_0_0_0_0_1, 0)) self.connect((self.analog_pwr_squelch_xx_0_0_0_0_0_0_0, 0), (self.low_pass_filter_0_0_0_0_0_0, 0)) self.connect((self.analog_pwr_squelch_xx_0_0_0_0_0_1, 0), (self.low_pass_filter_0_0_0_0_1, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0_1, 0)) self.connect((self.blocks_float_to_short_0_1_0_0_0_0, 0), (self.blocks_udp_sink_3_0_0_0, 0)) self.connect((self.blocks_float_to_short_0_1_0_0_1, 0), (self.blocks_udp_sink_3_0_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0_0_0_0_0_0, 0), (self.blocks_float_to_short_0_1_0_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0_0_0_0_1, 0), (self.blocks_float_to_short_0_1_0_0_1, 0)) self.connect((self.blocks_multiply_xx_0_1, 0), (self.freq_xlating_fir_filter_xxx_0_0_0_0_0_0, 0)) self.connect((self.blocks_multiply_xx_0_1, 0), (self.freq_xlating_fir_filter_xxx_0_0_0_0_1, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0_0_0_0_0_0, 0), (self.analog_pwr_squelch_xx_0_0_0_0_0_0_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0_0_0_0_1, 0), (self.analog_pwr_squelch_xx_0_0_0_0_0_1, 0)) self.connect((self.low_pass_filter_0_0_0_0_0_0, 0), (self.analog_nbfm_rx_0_0_0_0_0_0, 0)) self.connect((self.low_pass_filter_0_0_0_0_1, 0), (self.analog_nbfm_rx_0_0_0_0_1, 0)) self.connect((self.osmosdr_source_0_0, 0), (self.blocks_multiply_xx_0_1, 1))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.volume = volume = 1 self.transition = transition = 1E6 self.samp_rate = samp_rate = 2E6 self.quadrature = quadrature = 500e3 self.freq = freq = 103.5e6 self.cutoff = cutoff = 100E3 self.audio_dec = audio_dec = 10 ################################################## # Blocks ################################################## _volume_sizer = wx.BoxSizer(wx.VERTICAL) self._volume_text_box = forms.text_box( parent=self.GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, label='Volume', converter=forms.float_converter(), proportion=0, ) self._volume_slider = forms.slider( parent=self.GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, minimum=0, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_volume_sizer) self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + '') self.rtlsdr_source_0.set_clock_source('external_1pps', 0) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(103.5e6, 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(True, 0) self.rtlsdr_source_0.set_gain(20, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna('', 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=48, decimation=50, taps=None, fractional_bw=None, ) self.low_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, 2E6, cutoff, transition, firdes.WIN_HAMMING, 6.76)) self._freq_text_box = forms.text_box( parent=self.GetWin(), value=self.freq, callback=self.set_freq, label='frequency', converter=forms.float_converter(), ) self.Add(self._freq_text_box) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((1, )) self.audio_sink_0 = audio.sink(48000, '', True) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=quadrature, audio_decimation=1, ) ################################################## # Connections ################################################## self.connect((self.analog_wfm_rcv_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_wfm_rcv_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.low_pass_filter_0, 0))
def __init__(self): gr.top_block.__init__(self, "Am Coherent Rx") Qt.QWidget.__init__(self) self.setWindowTitle("Am Coherent Rx") 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", "am_coherent_rx") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 250000 ################################################## # Blocks ################################################## self.volume = blocks.multiply_const_vff((20, )) 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(0, 0) self.uhd_usrp_source_0.set_gain(70, 0) self.uhd_usrp_source_0.set_antenna('RX2', 0) self.low_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate, 5000, 100, firdes.WIN_HAMMING, 6.76)) self.carrier_freq = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 100000, 1, 0) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_float * 1, '', False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.audio_sink_1 = audio.sink(samp_rate / 5, '', True) ################################################## # Connections ################################################## self.connect((self.blocks_complex_to_mag_0, 0), (self.volume, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.carrier_freq, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.low_pass_filter_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.volume, 0), (self.audio_sink_1, 0)) self.connect((self.volume, 0), (self.blocks_file_sink_0, 0))
def __init__(self): gr.top_block.__init__(self, "QAM-Decoder") Qt.QWidget.__init__(self) self.setWindowTitle("QAM-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", "qam_decoder") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.center_freq = center_freq = 145.75e6 self.lo_freq = lo_freq = 80e3 self.freq = freq = center_freq self.samp_rate = samp_rate = 2.048e6 self.qpsk = qpsk = digital.constellation_rect(([ 0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j ]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base() self.data_freq = data_freq = freq + lo_freq ################################################## # Blocks ################################################## self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + '') self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(center_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(0, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(14.4, 0) self.rtlsdr_source_0.set_if_gain(0, 0) self.rtlsdr_source_0.set_bb_gain(0, 0) self.rtlsdr_source_0.set_antenna('', 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.rational_resampler_xxx_0_0_0 = filter.rational_resampler_ccc( interpolation=1, decimation=8, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=1, decimation=10, taps=None, fractional_bw=None, ) self.qtgui_sink_x_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype center_freq, #fc samp_rate / 8, #bw "", #name True, #plotfreq True, #plotwaterfall True, #plottime True, #plotconst ) self.qtgui_sink_x_0.set_update_time(1.0 / 10) self._qtgui_sink_x_0_win = sip.wrapinstance( self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_sink_x_0_win) self.qtgui_sink_x_0.enable_rf_freq(True) self.low_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate / 8, 12000, 1000, firdes.WIN_HAMMING, 6.76)) self._freq_tool_bar = Qt.QToolBar(self) if None: self._freq_formatter = None else: self._freq_formatter = lambda x: eng_notation.num_to_str(x) self._freq_tool_bar.addWidget(Qt.QLabel('Center frequency' + ": ")) self._freq_label = Qt.QLabel(str(self._freq_formatter(self.freq))) self._freq_tool_bar.addWidget(self._freq_label) self.top_grid_layout.addWidget(self._freq_tool_bar) self.digital_qam_demod_0 = digital.qam.qam_demod( constellation_points=4, differential=True, samples_per_symbol=4, excess_bw=0.35, 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._data_freq_tool_bar = Qt.QToolBar(self) if None: self._data_freq_formatter = None else: self._data_freq_formatter = lambda x: eng_notation.num_to_str(x) self._data_freq_tool_bar.addWidget( Qt.QLabel('Data center frequency' + ": ")) self._data_freq_label = Qt.QLabel( str(self._data_freq_formatter(self.data_freq))) self._data_freq_tool_bar.addWidget(self._data_freq_label) self.top_grid_layout.addWidget(self._data_freq_tool_bar) self.blocks_multiply_xx_1 = blocks.multiply_vcc(1) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1, 'D:\\Output-data.txt', False) self.blocks_file_sink_0.set_unbuffered(False) self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b( grc_blks2.packet_decoder( access_code='', threshold=-1, callback=lambda ok, payload: self.blks2_packet_decoder_0. recv_pkt(ok, payload), ), ) self.analog_sig_source_x_1 = analog.sig_source_c( samp_rate / 8, analog.GR_COS_WAVE, -lo_freq, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.blks2_packet_decoder_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.low_pass_filter_0, 0)) self.connect((self.digital_qam_demod_0, 0), (self.blks2_packet_decoder_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.digital_qam_demod_0, 0)) self.connect((self.rational_resampler_xxx_0_0_0, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.rational_resampler_xxx_0_0_0, 0), (self.qtgui_sink_x_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.rational_resampler_xxx_0_0_0, 0))
def __init__(self, input_rate=None, demod_type='cqpsk', filter_type=None, excess_bw=_def_excess_bw, relative_freq=0, offset=0, if_rate=_def_if_rate, gain_mu=_def_gain_mu, costas_alpha=_def_costas_alpha, symbol_rate=_def_symbol_rate): """ Hierarchical block for P25 demodulation. The complex input is tuned, decimated and demodulated @param input_rate: sample rate of complex input channel @type input_rate: int """ gr.hier_block2.__init__( self, "p25_demod_cb", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(1, 1, gr.sizeof_char)) # Output signature # gr.io_signature(0, 0, 0)) # Output signature p25_demod_base.__init__(self, if_rate=if_rate, symbol_rate=symbol_rate, filter_type=filter_type) self.input_rate = input_rate self.if_rate = if_rate self.symbol_rate = symbol_rate self.connect_state = None self.aux_fm_connected = False self.offset = 0 self.sps = 0.0 self.lo_freq = 0 self.float_sink = None self.complex_sink = None self.if1 = 0 self.if2 = 0 self.t_cache = {} if filter_type == 'rrc': self.set_baseband_gain(0.61) # local osc self.lo = analog.sig_source_c(input_rate, analog.GR_SIN_WAVE, 0, 1.0, 0) self.mixer = blocks.multiply_cc() decimator_values = get_decim(input_rate) if decimator_values: self.decim, self.decim2 = decimator_values self.if1 = input_rate / self.decim self.if2 = self.if1 / self.decim2 sys.stderr.write( 'Using two-stage decimator for speed=%d, decim=%d/%d if1=%d if2=%d\n' % (input_rate, self.decim, self.decim2, self.if1, self.if2)) bpf_coeffs = filter.firdes.complex_band_pass( 1.0, input_rate, -self.if1 / 2, self.if1 / 2, self.if1 / 2, filter.firdes.WIN_HAMMING) self.t_cache[0] = bpf_coeffs fa = 6250 fb = self.if2 / 2 lpf_coeffs = filter.firdes.low_pass(1.0, self.if1, (fb + fa) / 2, fb - fa, filter.firdes.WIN_HAMMING) self.bpf = filter.fir_filter_ccc(self.decim, bpf_coeffs) self.lpf = filter.fir_filter_ccf(self.decim2, lpf_coeffs) resampled_rate = self.if2 self.bfo = analog.sig_source_c(self.if1, analog.GR_SIN_WAVE, 0, 1.0, 0) self.connect(self, self.bpf, (self.mixer, 0)) self.connect(self.bfo, (self.mixer, 1)) else: sys.stderr.write( 'Unable to use two-stage decimator for speed=%d\n' % (input_rate)) # local osc self.lo = analog.sig_source_c(input_rate, analog.GR_SIN_WAVE, 0, 1.0, 0) lpf_coeffs = filter.firdes.low_pass(1.0, input_rate, 7250, 1450, filter.firdes.WIN_HANN) decimation = int(input_rate / if_rate) self.lpf = filter.fir_filter_ccf(decimation, lpf_coeffs) resampled_rate = float(input_rate) / float( decimation) # rate at output of self.lpf self.connect(self, (self.mixer, 0)) self.connect(self.lo, (self.mixer, 1)) self.connect(self.mixer, self.lpf) if self.if_rate != resampled_rate: self.if_out = filter.pfb.arb_resampler_ccf( float(self.if_rate) / resampled_rate) self.connect(self.lpf, self.if_out) else: self.if_out = self.lpf fa = 6250 fb = fa + 625 cutoff_coeffs = filter.firdes.low_pass(1.0, self.if_rate, (fb + fa) / 2, fb - fa, filter.firdes.WIN_HANN) self.cutoff = filter.fir_filter_ccf(1, cutoff_coeffs) omega = float(self.if_rate) / float(self.symbol_rate) gain_omega = 0.1 * gain_mu * gain_mu alpha = costas_alpha beta = 0.125 * alpha * alpha fmax = 2400 # Hz fmax = 2 * pi * fmax / float(self.if_rate) self.clock = op25_repeater.gardner_costas_cc(omega, gain_mu, gain_omega, alpha, beta, fmax, -fmax) self.agc = analog.feedforward_agc_cc(16, 1.0) # Perform Differential decoding on the constellation self.diffdec = digital.diff_phasor_cc() # take angle of the difference (in radians) self.to_float = blocks.complex_to_arg() # convert from radians such that signal is in -3/-1/+1/+3 self.rescale = blocks.multiply_const_ff((1 / (pi / 4))) # fm demodulator (needed in fsk4 case) fm_demod_gain = if_rate / (2.0 * pi * _def_symbol_deviation) self.fm_demod = analog.quadrature_demod_cf(fm_demod_gain) self.connect_chain(demod_type) self.connect(self.slicer, self) self.set_relative_frequency(relative_freq)
def __init__(self): gr.top_block.__init__(self, "NFC Acquisition") Qt.QWidget.__init__(self) self.setWindowTitle("NFC Acquisition") 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", "nfc_acquisition") 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 = 2e6 self.transition = transition = samp_rate / 5 self.frequency = frequency = 13.56e6 self.filepath = filepath = '/dev/null' self.cutoff = cutoff = samp_rate / 5 ################################################## # Blocks ################################################## self._transition_range = Range(samp_rate / 1000, samp_rate / 4, 1000, samp_rate / 5, 200) self._transition_win = RangeWidget(self._transition_range, self.set_transition, 'transition', "counter_slider", float) self.top_grid_layout.addWidget(self._transition_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._frequency_tool_bar = Qt.QToolBar(self) self._frequency_tool_bar.addWidget(Qt.QLabel('frequency' + ": ")) self._frequency_line_edit = Qt.QLineEdit(str(self.frequency)) self._frequency_tool_bar.addWidget(self._frequency_line_edit) self._frequency_line_edit.returnPressed.connect( lambda: self.set_frequency( eng_notation.str_to_num(str(self._frequency_line_edit.text())) )) self.top_grid_layout.addWidget(self._frequency_tool_bar, 0, 1, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._filepath_tool_bar = Qt.QToolBar(self) self._filepath_tool_bar.addWidget(Qt.QLabel('File path' + ": ")) self._filepath_line_edit = Qt.QLineEdit(str(self.filepath)) self._filepath_tool_bar.addWidget(self._filepath_line_edit) self._filepath_line_edit.returnPressed.connect( lambda: self.set_filepath(str(str(self._filepath_line_edit.text())) )) self.top_grid_layout.addWidget(self._filepath_tool_bar, 1, 1, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._cutoff_range = Range(samp_rate / 1000, samp_rate / 4, 1000, samp_rate / 5, 200) self._cutoff_win = RangeWidget(self._cutoff_range, self.set_cutoff, 'cutoff', "counter_slider", float) self.top_grid_layout.addWidget(self._cutoff_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) self.qtgui_waterfall_sink_x_0_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype frequency, #fc samp_rate, #bw "Waterfall plot", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0_0.set_update_time(0.10) self.qtgui_waterfall_sink_x_0_0.enable_grid(False) self.qtgui_waterfall_sink_x_0_0.enable_axis_labels(True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0_0.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_x_0_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_0_win, 2, 0, 2, 1) for r in range(2, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_1_1 = qtgui.time_sink_c( 32768, #size samp_rate, #samp_rate "I/Q time plot", #name 1 #number of inputs ) self.qtgui_time_sink_x_1_1.set_update_time(0.10) self.qtgui_time_sink_x_1_1.set_y_axis(-0.5, 0.5) self.qtgui_time_sink_x_1_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1_1.enable_tags(True) self.qtgui_time_sink_x_1_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1_1.enable_autoscale(False) self.qtgui_time_sink_x_1_1.enable_grid(True) self.qtgui_time_sink_x_1_1.enable_axis_labels(True) self.qtgui_time_sink_x_1_1.enable_control_panel(False) self.qtgui_time_sink_x_1_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(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_1_1.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1_1.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_1_win = sip.wrapinstance( self.qtgui_time_sink_x_1_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_1_win, 2, 1, 2, 1) for r in range(2, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_1_0_0 = qtgui.time_sink_f( 32768, #size samp_rate, #samp_rate "Magnitude time plot", #name 1 #number of inputs ) self.qtgui_time_sink_x_1_0_0.set_update_time(0.10) self.qtgui_time_sink_x_1_0_0.set_y_axis(-0.5, 0.5) self.qtgui_time_sink_x_1_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1_0_0.enable_tags(True) self.qtgui_time_sink_x_1_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1_0_0.enable_autoscale(False) self.qtgui_time_sink_x_1_0_0.enable_grid(True) self.qtgui_time_sink_x_1_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_1_0_0.enable_control_panel(False) self.qtgui_time_sink_x_1_0_0.enable_stem_plot(False) labels = [ 'Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10' ] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ 'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue' ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_1_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_1_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_0_0_win, 4, 1, 2, 1) for r in range(4, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype frequency, #fc samp_rate, #bw "FFT plot", #name 1) self.qtgui_freq_sink_x_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB') 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(True) self.qtgui_freq_sink_x_0_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_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_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.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_win, 4, 0, 2, 1) for r in range(4, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #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(True) 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 = [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.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.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win) self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + 'driver=lime,soapy=0') self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(frequency, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_gain(0, 0) self.osmosdr_source_0.set_if_gain(16, 0) self.osmosdr_source_0.set_bb_gain(16, 0) self.osmosdr_source_0.set_antenna('', 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.low_pass_filter_0_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate, cutoff, transition, firdes.WIN_HAMMING, 6.76)) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_cc(1) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex * 1, filepath, False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_complex_to_mag_0_0 = blocks.complex_to_mag(1) ################################################## # Connections ################################################## self.connect((self.blocks_complex_to_mag_0_0, 0), (self.qtgui_time_sink_x_1_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.blocks_complex_to_mag_0_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.qtgui_time_sink_x_1_1, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.qtgui_waterfall_sink_x_0_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_multiply_const_vxx_0, 0))
def __init__(self): gr.top_block.__init__(self, "WSPR-Transmitter") Qt.QWidget.__init__(self) self.setWindowTitle("WSPR-Transmitter") 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", "wspr_transmitter") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.center_freq = center_freq = 50.293e6 self.samp_rate = samp_rate = 8e6 self.rf_gain = rf_gain = 0 self.ppm_cor = ppm_cor = 0 self.lo_freq = lo_freq = 10e3 self.if_gain = if_gain = 20 self.data_freq_0 = data_freq_0 = center_freq self.data_freq = data_freq = center_freq + 1500 self.audio_rate = audio_rate = 48000 ################################################## # Blocks ################################################## _rf_gain_check_box = Qt.QCheckBox('RF Gain enable') self._rf_gain_choices = {True: 14, False: 0} self._rf_gain_choices_inv = dict( (v, k) for k, v in self._rf_gain_choices.iteritems()) self._rf_gain_callback = lambda i: Qt.QMetaObject.invokeMethod( _rf_gain_check_box, "setChecked", Qt.Q_ARG("bool", self._rf_gain_choices_inv[i])) self._rf_gain_callback(self.rf_gain) _rf_gain_check_box.stateChanged.connect( lambda i: self.set_rf_gain(self._rf_gain_choices[bool(i)])) self.top_grid_layout.addWidget(_rf_gain_check_box) self._ppm_cor_range = Range(-3, 3, 0.1, 0, 200) self._ppm_cor_win = RangeWidget(self._ppm_cor_range, self.set_ppm_cor, 'PPM Correction', "counter_slider", float) self.top_grid_layout.addWidget(self._ppm_cor_win) self._if_gain_range = Range(0, 47, 1, 20, 200) self._if_gain_win = RangeWidget(self._if_gain_range, self.set_if_gain, 'IF Gain', "counter_slider", float) self.top_grid_layout.addWidget(self._if_gain_win) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=500, decimation=3, taps=None, fractional_bw=None, ) self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + 'hackrf=0000000000000000a27466e62362050f') self.osmosdr_sink_0.set_sample_rate(samp_rate) self.osmosdr_sink_0.set_center_freq(center_freq - lo_freq, 0) self.osmosdr_sink_0.set_freq_corr(ppm_cor, 0) self.osmosdr_sink_0.set_gain(rf_gain, 0) self.osmosdr_sink_0.set_if_gain(if_gain, 0) self.osmosdr_sink_0.set_bb_gain(0, 0) self.osmosdr_sink_0.set_antenna('', 0) self.osmosdr_sink_0.set_bandwidth(0, 0) self._data_freq_0_tool_bar = Qt.QToolBar(self) if None: self._data_freq_0_formatter = None else: self._data_freq_0_formatter = lambda x: eng_notation.num_to_str(x) self._data_freq_0_tool_bar.addWidget( Qt.QLabel('Set receiver frequency in USB mode' + ": ")) self._data_freq_0_label = Qt.QLabel( str(self._data_freq_0_formatter(self.data_freq_0))) self._data_freq_0_tool_bar.addWidget(self._data_freq_0_label) self.top_grid_layout.addWidget(self._data_freq_0_tool_bar) self._data_freq_tool_bar = Qt.QToolBar(self) if None: self._data_freq_formatter = None else: self._data_freq_formatter = lambda x: eng_notation.num_to_str(x) self._data_freq_tool_bar.addWidget( Qt.QLabel('WSPR data center frequency' + ": ")) self._data_freq_label = Qt.QLabel( str(self._data_freq_formatter(self.data_freq))) self._data_freq_tool_bar.addWidget(self._data_freq_label) self.top_grid_layout.addWidget(self._data_freq_tool_bar) self.blocks_wavfile_source_0 = blocks.wavfile_source( 'D:\\WSPR.wav', False) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.band_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.band_pass(1, audio_rate, lo_freq + 1e3, lo_freq + 2e3, 250, firdes.WIN_HAMMING, 6.76)) self.analog_sig_source_x_0 = analog.sig_source_c( audio_rate, analog.GR_COS_WAVE, lo_freq, 0.5, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.osmosdr_sink_0, 0))
def __init__(self, meta_rate=1): gr.top_block.__init__(self, "Lms6 Experiment") Qt.QWidget.__init__(self) self.setWindowTitle("Lms6 Experiment") 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", "lms6_experiment") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.meta_rate = meta_rate ################################################## # Variables ################################################## self.samp_rate = samp_rate = 50e3 self.decim = decim = 1 self.baud = baud = 4800 self.xlate_taps = xlate_taps = firdes.low_pass(1.0, samp_rate, samp_rate / 2, 1000, firdes.WIN_HAMMING, 6.76) self.variable_tag_object_0 = variable_tag_object_0 = gr.tag_utils.python_to_tag( (0, pmt.intern("key"), pmt.intern("value"), pmt.intern("src"))) self.ts_str = ts_str = dt.strftime(dt.utcnow(), "%Y%m%d_%H%M%S.%f") + '_UTC' self.sync3 = sync3 = "001110110010000000000000000000000000000000000000" self.sync2 = sync2 = "00111011001000000000000000000000" self.samps_per_symb = samps_per_symb = samp_rate / decim * 24 / 25 / baud self.offset = offset = 0 ################################################## # Blocks ################################################## self._offset_tool_bar = Qt.QToolBar(self) self._offset_tool_bar.addWidget(Qt.QLabel('OFFSET' + ": ")) self._offset_line_edit = Qt.QLineEdit(str(self.offset)) self._offset_tool_bar.addWidget(self._offset_line_edit) self._offset_line_edit.returnPressed.connect(lambda: self.set_offset( eng_notation.str_to_num( str(self._offset_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._offset_tool_bar, 3, 3, 1, 3) self.rational_resampler_xxx_1 = filter.rational_resampler_ccc( interpolation=1, decimation=4, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=1, decimation=4, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=24, decimation=25, taps=None, fractional_bw=None, ) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024 * 4, #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, 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, "hit") 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 = [0, -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_number_sink_0_0_0_0_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1) self.qtgui_number_sink_0_0_0_0_0.set_update_time(0.10) self.qtgui_number_sink_0_0_0_0_0.set_title("") labels = ['SNR', '', '', '', '', '', '', '', '', ''] units = ['dB', '', '', '', '', '', '', '', '', ''] colors = [("blue", "red"), ("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_0_0_0.set_min(i, 0) self.qtgui_number_sink_0_0_0_0_0.set_max(i, 30) self.qtgui_number_sink_0_0_0_0_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0_0_0_0.set_label( i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0_0_0_0.set_label(i, labels[i]) self.qtgui_number_sink_0_0_0_0_0.set_unit(i, units[i]) self.qtgui_number_sink_0_0_0_0_0.set_factor(i, factor[i]) self.qtgui_number_sink_0_0_0_0_0.enable_autoscale(False) self._qtgui_number_sink_0_0_0_0_0_win = sip.wrapinstance( self.qtgui_number_sink_0_0_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_0_0_0_0_win, 4, 4, 1, 1) self.qtgui_number_sink_0_0_0_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1) self.qtgui_number_sink_0_0_0_0.set_update_time(0.010) self.qtgui_number_sink_0_0_0_0.set_title("") labels = ['Freq Offset', 'Phase', 'Error', '', '', '', '', '', '', ''] units = ['Hz', '', '', '', '', '', '', '', '', ''] 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_0_0.set_min(i, -32767) self.qtgui_number_sink_0_0_0_0.set_max(i, 32767) self.qtgui_number_sink_0_0_0_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0_0_0.set_label( i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0_0_0.set_label(i, labels[i]) self.qtgui_number_sink_0_0_0_0.set_unit(i, units[i]) self.qtgui_number_sink_0_0_0_0.set_factor(i, factor[i]) self.qtgui_number_sink_0_0_0_0.enable_autoscale(False) self._qtgui_number_sink_0_0_0_0_win = sip.wrapinstance( self.qtgui_number_sink_0_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_0_0_0_win, 4, 3, 1, 1) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / decim, #bw "Filtered", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.010) self.qtgui_freq_sink_x_0_0.set_y_axis(-70, -10) self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB') 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(True) self.qtgui_freq_sink_x_0_0.set_fft_average(0.2) self.qtgui_freq_sink_x_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_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_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.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_win, 0, 3, 3, 3) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / decim, #bw "Freq compensated", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.010) self.qtgui_freq_sink_x_0.set_y_axis(-70, -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(True) self.qtgui_freq_sink_x_0.set_fft_average(0.05) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "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_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 3, 3) self.low_pass_filter_0 = filter.fir_filter_ccf( decim, firdes.low_pass(1, samp_rate, 7.5e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.kiss_nrzi_decode_0 = kiss.nrzi_decode() self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( 1, (xlate_taps), offset, samp_rate) self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc( samps_per_symb, .5, 1024, math.pi / 500) self.digital_correlate_access_code_tag_xx_0 = digital.correlate_access_code_tag_bb( sync3, 0, 'hit') self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff( samps_per_symb * (1 + 0.0), 0.25 * 0.175 * 0.175, 0.5, 0.175, 0.005) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_tagged_stream_to_pdu_1 = blocks.tagged_stream_to_pdu( blocks.byte_t, 'packet_len') self.blocks_tagged_stream_to_pdu_0_0 = blocks.tagged_stream_to_pdu( blocks.float_t, 'snr') self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu( blocks.float_t, 'rfo') self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length( gr.sizeof_char * 1, 'packet_len', 1 / 8.0) self.blocks_tagged_stream_align_0 = blocks.tagged_stream_align( gr.sizeof_char * 1, 'hit') self.blocks_tag_debug_0 = blocks.tag_debug(gr.sizeof_char * 1, '', "") self.blocks_tag_debug_0.set_display(True) self.blocks_stream_to_tagged_stream_1 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, 576, "packet_len") self.blocks_stream_to_tagged_stream_0_0 = blocks.stream_to_tagged_stream( gr.sizeof_float, 1, 1, "snr") self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_float, 1, 1, "rfo") self.blocks_socket_pdu_0_0 = blocks.socket_pdu("TCP_SERVER", '0.0.0.0', '52002', 10000, False) self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_SERVER", '0.0.0.0', '52001', 10000, False) self.blocks_pdu_filter_0 = blocks.pdu_filter(pmt.intern("hit"), pmt.from_long(0), False) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_float * 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float * 1) self.blocks_nlog10_ff_0_1 = blocks.nlog10_ff(10, 1, 0) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff( (-1 * samp_rate / (2 * math.pi), )) self.blocks_moving_average_xx_0_0_1 = blocks.moving_average_ff( 10000, 0.0001, 4000, 1) self.blocks_moving_average_xx_0 = blocks.moving_average_ff( 10000, 0.0001, 4000, 1) self.blocks_message_debug_0 = blocks.message_debug() self.blocks_keep_one_in_n_0_0 = blocks.keep_one_in_n( gr.sizeof_float * 1, int(samp_rate * meta_rate)) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n( gr.sizeof_float * 1, int(samp_rate / 4 * meta_rate)) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_gr_complex * 1, '/home/zleffke/captures/radiosonde/BBNWS_LMS6_RTLSDR_20171202_235806.395054_UTC_50k.fc32', False) self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL) self.blocks_divide_xx_0 = blocks.divide_ff(1) self.blocks_complex_to_mag_squared_0_0 = blocks.complex_to_mag_squared( 1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.audio_sink_1 = audio.sink(48000, '', True) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, samp_rate / 2, 1, 0) self.analog_nbfm_rx_0 = analog.nbfm_rx( audio_rate=int(samp_rate / decim * 24 / 25), quad_rate=int(samp_rate / decim * 24 / 25), tau=75e-6, max_dev=5e3, ) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.msg_connect((self.blocks_pdu_filter_0, 'pdus'), (self.blocks_message_debug_0, 'print_pdu')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.blocks_socket_pdu_0, 'pdus')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0, 'pdus'), (self.blocks_socket_pdu_0_0, 'pdus')) self.msg_connect((self.blocks_tagged_stream_to_pdu_1, 'pdus'), (self.blocks_pdu_filter_0, 'pdus')) self.connect((self.analog_agc2_xx_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.analog_nbfm_rx_0, 0), (self.audio_sink_1, 0)) self.connect((self.analog_nbfm_rx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_divide_xx_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0_0, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.blocks_divide_xx_0, 0), (self.blocks_nlog10_ff_0_1, 0)) self.connect((self.blocks_file_source_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.blocks_stream_to_tagged_stream_0_0, 0)) self.connect((self.blocks_keep_one_in_n_0_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_keep_one_in_n_0_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.qtgui_number_sink_0_0_0_0, 0)) self.connect((self.blocks_moving_average_xx_0_0_1, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.blocks_moving_average_xx_0_0_1, 0), (self.qtgui_number_sink_0_0_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.blocks_nlog10_ff_0_1, 0), (self.blocks_moving_average_xx_0_0_1, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.blocks_tagged_stream_multiply_length_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0_0, 0), (self.blocks_tagged_stream_to_pdu_0_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_1, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.blocks_tagged_stream_align_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.blocks_tagged_stream_align_0, 0), (self.blocks_stream_to_tagged_stream_1, 0)) self.connect((self.blocks_tagged_stream_align_0, 0), (self.blocks_tag_debug_0, 0)) self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self.blocks_tagged_stream_to_pdu_1, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.kiss_nrzi_decode_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.digital_correlate_access_code_tag_xx_0, 0), (self.blocks_tagged_stream_align_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 1), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 2), (self.blocks_null_sink_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 3), (self.blocks_null_sink_0_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.digital_fll_band_edge_cc_0, 0)) self.connect((self.kiss_nrzi_decode_0, 0), (self.digital_correlate_access_code_tag_xx_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.analog_nbfm_rx_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.blocks_complex_to_mag_squared_0_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") if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry( self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Variables ################################################## self.signal = signal = 10000 self.samp_rate = samp_rate = 1500000 self.porteuse = porteuse = 100e6 ################################################## # Blocks ################################################## self._porteuse_range = Range(87.5e6, 108e6, 0.1e6, 100e6, 200) self._porteuse_win = RangeWidget(self._porteuse_range, self.set_porteuse, "porteuse", "counter_slider", float) self.top_layout.addWidget(self._porteuse_win) 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(porteuse, 0) self.uhd_usrp_source_0.set_gain(40, 0) self.uhd_usrp_source_0.set_antenna('TX/RX', 0) self.rational_resampler_xxx_0_0_0 = filter.rational_resampler_fff( interpolation=44100, decimation=samp_rate / 6, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0_0 = filter.rational_resampler_fff( interpolation=44100, decimation=samp_rate / 6, taps=None, fractional_bw=None, ) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / 6, #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_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(True) 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.low_pass_filter_1_0 = filter.fir_filter_fff( 1, firdes.low_pass(1, samp_rate / 6, 15e3, 1.5e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf( 6, firdes.low_pass(1, samp_rate, 100e3, 10e3, firdes.WIN_HAMMING, 6.76)) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((2, )) self.blocks_add_xx_0 = blocks.add_vff(1) self.audio_sink_1 = audio.sink(44100, '', True) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=samp_rate / 6, audio_decimation=1, ) self.analog_sig_source_x_0 = analog.sig_source_f( samp_rate / 6, analog.GR_COS_WAVE, 38e3, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_wfm_rcv_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_1_0, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.rational_resampler_xxx_0_0_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_wfm_rcv_0, 0)) self.connect((self.low_pass_filter_1_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.audio_sink_1, 0)) self.connect((self.rational_resampler_xxx_0_0_0, 0), (self.audio_sink_1, 1)) self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_0, 0))