def set_width_of_transition_band(self, width_of_transition_band): self.width_of_transition_band = width_of_transition_band self.stereo_carrier__filter.set_taps( firdes.complex_band_pass( 1, self.demod_rate, -19020, -18980, self.width_of_transition_band, firdes.WIN_HAMMING, 6.76 ) ) self.RDS_sig_filter.set_taps( firdes.complex_band_pass( 1, self.demod_rate, 57000 - 1500, 57000 + 1500, self.width_of_transition_band, firdes.WIN_HAMMING, 6.76 ) )
def set_audio_rate(self, audio_rate): self.audio_rate = audio_rate self.set_samp_rate(self.audio_rate * 40) self.band_pass_filter_0_0.set_taps(firdes.complex_band_pass(1, self.audio_rate, -2800, -200, 200, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0.set_taps(firdes.complex_band_pass(1, self.audio_rate, 200, 2800, 200, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_1.set_taps(firdes.low_pass(0.5, self.audio_rate, 5000, 400, firdes.WIN_HAMMING, 6.76)) self.root_raised_cosine_filter_1.set_taps(firdes.root_raised_cosine(1, self.audio_rate, 5, 0.35, 200)) self.root_raised_cosine_filter_0.set_taps(firdes.root_raised_cosine(1, self.audio_rate, 5, 0.35, 200)) self.analog_sig_source_x_6.set_sampling_freq(self.audio_rate) self.analog_sig_source_x_5.set_sampling_freq(self.audio_rate) self.analog_sig_source_x_3.set_sampling_freq(self.audio_rate) self.analog_sig_source_x_3_0.set_sampling_freq(self.audio_rate) self.analog_sig_source_x_2.set_sampling_freq(self.audio_rate)
def set_samp_rate(self, samp_rate): self.samp_rate = samp_rate self.set_xlate_filter_taps(firdes.low_pass(1, self.samp_rate, 125000, 25000, firdes.WIN_HAMMING, 6.76)) self.fftsink.set_sample_rate(self.samp_rate) self.osmosdr_source_0.set_sample_rate(self.samp_rate) self.wxgui_waterfallsink2_0.set_sample_rate(self.samp_rate) self.band_pass_filter.set_taps(firdes.complex_band_pass(1, self.samp_rate, -self.high, -self.low, self.trans, firdes.WIN_HAMMING, 6.76))
def set_samp_rate(self, samp_rate): self.samp_rate = samp_rate self.set_samp_per_sym(self.samp_rate/self.symbol_rate) self.analog_quadrature_demod_cf_0.set_gain(self.samp_rate/(2*math.pi*self.fsk_deviation_hz/8.0)) self.band_pass_filter_0.set_taps(firdes.complex_band_pass(1, self.samp_rate, 750, 1250, 10, firdes.WIN_HAMMING, 6.76)) self.wxgui_waterfallsink2_0_0.set_sample_rate(self.samp_rate) self.wxgui_scopesink2_1.set_sample_rate(self.samp_rate)
def set_demod_rate(self, demod_rate): self.demod_rate = demod_rate self.set_max_freq(2.0 * math.pi * (80) * 1e3 / self.demod_rate) self.set_audio_rate(self.demod_rate / self.audio_decimation) self.stereo_carrier__filter.set_taps( firdes.complex_band_pass( 1, self.demod_rate, -19020, -18980, self.width_of_transition_band, firdes.WIN_HAMMING, 6.76 ) ) self.stereo_carrier_pll_recovery.set_max_freq(-2.0 * math.pi * 18990 / self.demod_rate) self.stereo_carrier_pll_recovery.set_min_freq(-2.0 * math.pi * 19010 / self.demod_rate) self.RDS_sig_filter.set_taps( firdes.complex_band_pass( 1, self.demod_rate, 57000 - 1500, 57000 + 1500, self.width_of_transition_band, firdes.WIN_HAMMING, 6.76 ) ) self.digital_mpsk_receiver_cc_0.set_omega(self.demod_rate / 2375.0)
def set_samp_rate(self, samp_rate): self.samp_rate = samp_rate self.if_filter.set_taps(firdes.low_pass(1, self.samp_rate, 75000, 25000, firdes.WIN_HAMMING, 6.76)) self.if_waterfall.set_frequency_range(100000, self.samp_rate / self.decimation) self.offset_osc_1.set_sampling_freq(self.samp_rate) self.offset_osc_2.set_sampling_freq(self.samp_rate / self.decimation) self.rf_in.set_sample_rate(self.samp_rate) self.usb_filter.set_taps(firdes.complex_band_pass(1, self.samp_rate / self.decimation, 200, 2800, 200, firdes.WIN_HAMMING, 6.76))
def set_samp_rate(self, samp_rate): self.samp_rate = samp_rate self.band_pass_filter_0.set_taps( firdes.complex_band_pass(1, self.samp_rate, 60, 255, 100, firdes.WIN_BLACKMAN, 6.76) ) self.analog_pll_freqdet_cf_0.set_loop_bandwidth(200 * 2.0 * pi / self.samp_rate) self.analog_pll_freqdet_cf_0.set_max_freq(260 * 2.0 * pi / self.samp_rate) self.analog_pll_freqdet_cf_0.set_min_freq(60 * 2.0 * pi / self.samp_rate) self.blocks_moving_average_xx_0.set_length_and_scale(self.samp_rate / 50, 25 / pi)
def set_samp_rate(self, samp_rate): self.samp_rate = samp_rate self.freq_xlating_fir_filter_xxx_0.set_taps((firdes.low_pass(1, self.samp_rate, self.channel_spacing,self.channel_trans, firdes.WIN_BLACKMAN, 6.76))) self.band_pass_filter_0.set_taps(firdes.complex_band_pass(1, self.samp_rate/50, -2500, 2500, self.trans, firdes.WIN_HAMMING, 6.76)) self.osmosdr_source_0.set_sample_rate(self.samp_rate) self.qtgui_sink_x_0.set_frequency_range(self.freq-self.freq_offset, self.samp_rate/50) self.qtgui_freq_sink_x_0.set_frequency_range(self.freq, self.samp_rate) self.qtgui_waterfall_sink_x_0.set_frequency_range(self.freq, self.samp_rate)
def set_samp_rate(self, samp_rate): self.samp_rate = samp_rate self.set_decimation(self.samp_rate / 48000) self.analog_sig_source_x_0.set_sampling_freq(self.samp_rate) self.wxgui_waterfallsink2_0.set_sample_rate(self.samp_rate / self.decimation) self.band_pass_filter_0.set_taps(firdes.complex_band_pass(1, self.samp_rate / self.decimation, 200, 2800, 200, firdes.WIN_HAMMING, 6.76)) self.analog_sig_source_x_1.set_sampling_freq(self.samp_rate / self.decimation) self.low_pass_filter_1.set_taps(firdes.low_pass(1000, self.samp_rate / 25, 200, 50, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0.set_taps(firdes.low_pass(1, self.samp_rate, 20000, 5000, firdes.WIN_HAMMING, 6.76)) self.osmosdr_source_0.set_sample_rate(self.samp_rate)
def __make_sideband_demod(self, upper): first = grfilter.fir_filter_ccc( 1, firdes.complex_band_pass(1.0, self.__demod_rate, _am_lower_cutoff_freq if upper else -_am_audio_bandwidth, _am_audio_bandwidth if upper else -_am_lower_cutoff_freq, 1000, firdes.WIN_HAMMING)) last = self.__make_dc_blocker() self.connect(first, blocks.complex_to_real(), last) return first, last
def connect_audio_stage(self, input_port): stereo_rate = self.demod_rate normalizer = TWO_PI / stereo_rate pilot_tone = 19000 pilot_low = pilot_tone * 0.9 pilot_high = pilot_tone * 1.1 def make_audio_filter(): return grfilter.fir_filter_fff( stereo_rate // self.__audio_int_rate, # decimation firdes.low_pass(1.0, stereo_rate, 15000, 5000, firdes.WIN_HAMMING), ) stereo_pilot_filter = grfilter.fir_filter_fcc( 1, firdes.complex_band_pass(1.0, stereo_rate, pilot_low, pilot_high, 300) # decimation ) # TODO magic number from gqrx stereo_pilot_pll = analog.pll_refout_cc( 0.001, normalizer * pilot_high, normalizer * pilot_low # TODO magic number from gqrx ) stereo_pilot_doubler = blocks.multiply_cc() stereo_pilot_out = blocks.complex_to_imag() difference_channel_mixer = blocks.multiply_ff() difference_channel_filter = make_audio_filter() mono_channel_filter = make_audio_filter() mixL = blocks.add_ff(1) mixR = blocks.sub_ff(1) # connections self.connect(input_port, mono_channel_filter) if self.stereo: # stereo pilot tone tracker self.connect(input_port, stereo_pilot_filter, stereo_pilot_pll) self.connect(stereo_pilot_pll, (stereo_pilot_doubler, 0)) self.connect(stereo_pilot_pll, (stereo_pilot_doubler, 1)) self.connect(stereo_pilot_doubler, stereo_pilot_out) # pick out stereo left-right difference channel (at stereo_rate) self.connect(input_port, (difference_channel_mixer, 0)) self.connect(stereo_pilot_out, (difference_channel_mixer, 1)) self.connect(difference_channel_mixer, difference_channel_filter) # recover left/right channels (at self.__audio_int_rate) self.connect(difference_channel_filter, (mixL, 1)) self.connect(difference_channel_filter, (mixR, 1)) resamplerL = self._make_resampler((mixL, 0), self.__audio_int_rate) resamplerR = self._make_resampler((mixR, 0), self.__audio_int_rate) self.connect(mono_channel_filter, (mixL, 0)) self.connect(mono_channel_filter, (mixR, 0)) self.connect_audio_output(resamplerL, resamplerR) else: resampler = self._make_resampler(mono_channel_filter, self.__audio_int_rate) self.connect_audio_output(resampler, resampler)
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 44100 ################################################## # Blocks ################################################## self.wxgui_numbersink2_0 = numbersink2.number_sink_f( self.GetWin(), unit="Hz", minval=50, maxval=280, factor=1, decimal_places=2, ref_level=0, sample_rate=samp_rate, number_rate=15, average=False, avg_alpha=None, label="Number Plot", peak_hold=False, show_gauge=True, ) self.Add(self.wxgui_numbersink2_0.win) self.blocks_moving_average_xx_0 = blocks.moving_average_ff(samp_rate / 50, 25 / pi, 200) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_float * 1, 10) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.band_pass_filter_0 = filter.fir_filter_ccc( 1, firdes.complex_band_pass(1, samp_rate, 60, 255, 100, firdes.WIN_BLACKMAN, 6.76) ) self.audio_source_0 = audio.source(samp_rate, "default", True) self.analog_pll_freqdet_cf_0 = analog.pll_freqdet_cf( 200 * 2.0 * pi / samp_rate, 260 * 2.0 * pi / samp_rate, 60 * 2.0 * pi / samp_rate ) ################################################## # Connections ################################################## self.connect((self.blocks_moving_average_xx_0, 0), (self.wxgui_numbersink2_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.analog_pll_freqdet_cf_0, 0)) self.connect((self.audio_source_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.analog_pll_freqdet_cf_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.blocks_moving_average_xx_0, 0))
def set_baseband_rate(self, baseband_rate): self.baseband_rate = baseband_rate self.set_rds_samp_rate(self.baseband_rate / self.rds_dec) self.analog_pll_refout_cc_0.set_max_freq(2 * cmath.pi * (19000+200) / self.baseband_rate) self.analog_pll_refout_cc_0.set_min_freq(2 * cmath.pi * (19000-200) / self.baseband_rate) self.band_pass_filter_0.set_taps(firdes.complex_band_pass(1, self.baseband_rate, self.pilot_tone - 0.5e3, self.pilot_tone+0.5e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0_0.set_taps(firdes.band_pass(1, self.baseband_rate, 23e3, 53e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_1.set_taps(firdes.band_pass(1, self.baseband_rate, self.stereo_subcarrier - 0.5e3, self.stereo_subcarrier + 0.5e3, 0.5e3, firdes.WIN_HAMMING, 6.76)) self.freq_xlating_fir_filter_xxx_1.set_taps((firdes.low_pass(2500,self.baseband_rate,self.rds_bandwidth,1e3,firdes.WIN_HAMMING))) self.low_pass_filter_1.set_taps(firdes.low_pass(10, self.baseband_rate, 15e3, 3e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_2.set_taps(firdes.low_pass(1, self.baseband_rate, 16e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_4.set_taps(firdes.low_pass(1, self.baseband_rate, 60e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.qtgui_freq_sink_x_0_0.set_frequency_range(0, self.baseband_rate) self.qtgui_freq_sink_x_0_1_0_0.set_frequency_range(0, self.baseband_rate) self.qtgui_time_sink_x_0.set_samp_rate(self.baseband_rate)
def set_baseband_rate(self, baseband_rate): self.baseband_rate = baseband_rate self.set_audio_decim_rate(self.baseband_rate/self.audio_decim) self.wxgui_fftsink2_0_0_0_1.set_sample_rate(self.baseband_rate) self.wxgui_fftsink2_0_0_0_1_0_0.set_sample_rate(self.baseband_rate) self.wxgui_fftsink2_0_0.set_sample_rate(self.baseband_rate) self.fir_filter_xxx_2.set_taps((firdes.complex_band_pass(1.0,self.baseband_rate,19e3-500,19e3+500,1e3,firdes.WIN_HAMMING))) self.wxgui_scopesink2_0.set_sample_rate(self.baseband_rate) self.analog_pll_refout_cc_0.set_max_freq(2 * math.pi * (19000+200) / self.baseband_rate) self.analog_pll_refout_cc_0.set_min_freq(2 * math.pi * (19000-200) / self.baseband_rate) self.fir_filter_xxx_5.set_taps((firdes.low_pass(1.0,self.baseband_rate,20e3,40e3,firdes.WIN_HAMMING))) self.fir_filter_xxx_3.set_taps((firdes.band_pass(1.0,self.baseband_rate,38e3-13e3,38e3+13e3,3e3,firdes.WIN_HAMMING))) self.fir_filter_xxx_1.set_taps((firdes.low_pass(1.0,self.baseband_rate,13e3,3e3,firdes.WIN_HAMMING))) self.wxgui_waterfallsink2_0.set_sample_rate(self.baseband_rate) self.freq_xlating_fir_filter_xxx_1.set_taps((firdes.low_pass(2500.0,self.baseband_rate,2.4e3,2e3,firdes.WIN_HAMMING)))
def __init__(self, mode, audio_rate=0, **kwargs): if mode == 'LSB': lsb = True elif mode == 'USB': lsb = False else: raise ValueError('Not an SSB mode: %r' % (mode,)) demod_rate = audio_rate SimpleAudioDemodulator.__init__(self, mode=mode, audio_rate=audio_rate, demod_rate=demod_rate, band_filter=audio_rate / 2, # unused band_filter_transition=audio_rate / 2, # unused **kwargs) input_rate = self.input_rate half_bandwidth = self.half_bandwidth = 2800 / 2 if lsb: band_mid = -200 - half_bandwidth else: band_mid = 200 + half_bandwidth self.band_filter_low = band_mid - half_bandwidth self.band_filter_high = band_mid + half_bandwidth self.band_filter_width = half_bandwidth / 5 self.sharp_filter_block = grfilter.fir_filter_ccc( 1, firdes.complex_band_pass(1.0, demod_rate, self.band_filter_low, self.band_filter_high, self.band_filter_width, firdes.WIN_HAMMING)) self.agc_block = analog.agc2_cc(reference=0.25) self.ssb_demod_block = blocks.complex_to_real(1) self.connect( self, self.band_filter_block, self.sharp_filter_block, self.rf_squelch_block, self.agc_block, self.ssb_demod_block) self.connect(self.sharp_filter_block, self.rf_probe_block) self.connect_audio_output(self.ssb_demod_block, self.ssb_demod_block)
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Ntsc Hackrf") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samples_per_line = samples_per_line = 772 self.samp_rate = samp_rate = samples_per_line * 60 * .999 * 525 / 2 self.rf_gain = rf_gain = 14 self.if_gain = if_gain = 40 self.digital_gain = digital_gain = 0.9 self.center_freq = center_freq = 186000000+1250000 ################################################## # Blocks ################################################## self.zero = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0) self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + "hackrf=0" ) self.osmosdr_sink_0.set_sample_rate(samp_rate) self.osmosdr_sink_0.set_center_freq(center_freq, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(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.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((digital_gain, )) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_float*1, "/home/ubuntu/WAHD-TV/ve3irr-testing.dat", True) self.blocks_add_xx_0 = blocks.add_vcc(1) self.band_pass_filter_0 = filter.fir_filter_ccc(1, firdes.complex_band_pass( 1, samp_rate, -2475000 + 1725000, 2475000 + 1725000, 500000, firdes.WIN_HAMMING, 6.76)) self.analog_sig_source_x_1 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 4500000, 0.1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_1, 0), (self.blocks_add_xx_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.osmosdr_sink_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.zero, 0), (self.blocks_float_to_complex_0, 1))
def __init__(self, mode, input_rate=0, context=None): assert input_rate > 0 gr.hier_block2.__init__( self, 'RTTY demodulator', gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), gr.io_signature(1, 1, gr.sizeof_float * 1), ) self.__text = u'' baud = _DEFAULT_BAUD # TODO param self.baud = baud demod_rate = 6000 # TODO optimize this value self.samp_rate = demod_rate # TODO rename self.__channel_filter = MultistageChannelFilter( input_rate=input_rate, output_rate=demod_rate, cutoff_freq=self.__filter_high, transition_width=self.__transition) # TODO optimize filter band self.__sharp_filter = grfilter.fir_filter_ccc( 1, firdes.complex_band_pass(1.0, demod_rate, self.__filter_low, self.__filter_high, self.__transition, firdes.WIN_HAMMING)) self.fsk_demod = RTTYFSKDemodulator(input_rate=demod_rate, baud=baud) self.__real = blocks.complex_to_real(vlen=1) self.__char_queue = gr.msg_queue(limit=100) self.char_sink = blocks.message_sink(gr.sizeof_char, self.__char_queue, True) self.connect( self, self.__channel_filter, self.__sharp_filter, self.fsk_demod, rtty.rtty_decode_ff(rate=demod_rate, baud=baud, polarity=False), self.char_sink) self.connect( self.__sharp_filter, self.__real, self)
def __make_audio_filter(self): '''Return a filter which selects just the RTTY signal and shifts to AF. This isn't anywhere in the digital processing chain, so doesn't need to be concerned with signal fidelity as long as it sounds good. ''' taps = firdes.complex_band_pass( gain=1.0, sampling_freq=self.__demod_rate, low_cutoff_freq=self.__low_cutoff, high_cutoff_freq=self.__high_cutoff, transition_width=self.__transition_width) af_filter = grfilter.fir_filter_ccc( decimation=1, taps=taps) return af_filter
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="FM Stereo Receiver") ################################################## # Variables ################################################## self.smux_filt_samprate = smux_filt_samprate = 256e3 self.smux_decim = smux_decim = 8 self.samp_rate = samp_rate = 2.048e6 self.right_gain = right_gain = 3 self.left_gain = left_gain = 3 self.bpf_base = bpf_base = 23e3 self.RF_Gain = RF_Gain = 45 self.CF = CF = 99.3e6 ################################################## # Blocks ################################################## self._samp_rate_text_box = forms.text_box( parent=self.GetWin(), value=self.samp_rate, callback=self.set_samp_rate, label="Sample Rate: 1.024M, 1.4M, 1.8M, 1.92M, 2.048M, 2.4M & 2. 56M", converter=forms.float_converter(), ) self.GridAdd(self._samp_rate_text_box, 1, 0, 1, 1) _right_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._right_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_right_gain_sizer, value=self.right_gain, callback=self.set_right_gain, label="R Audio Gain", converter=forms.float_converter(), proportion=0, ) self._right_gain_slider = forms.slider( parent=self.GetWin(), sizer=_right_gain_sizer, value=self.right_gain, callback=self.set_right_gain, minimum=0, maximum=5, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_right_gain_sizer, 0, 1, 1, 1) self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "BB Spectrum") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Demod Spectrum") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Stereo Spectrum") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Stereo Signal") self.GridAdd(self.notebook_0, 2, 0, 1, 2) _left_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._left_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_left_gain_sizer, value=self.left_gain, callback=self.set_left_gain, label="L Audio Gain", converter=forms.float_converter(), proportion=0, ) self._left_gain_slider = forms.slider( parent=self.GetWin(), sizer=_left_gain_sizer, value=self.left_gain, callback=self.set_left_gain, minimum=0, maximum=5, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_left_gain_sizer, 0, 0, 1, 1) _RF_Gain_sizer = wx.BoxSizer(wx.VERTICAL) self._RF_Gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_RF_Gain_sizer, value=self.RF_Gain, callback=self.set_RF_Gain, label="RF Gain", converter=forms.float_converter(), proportion=0, ) self._RF_Gain_slider = forms.slider( parent=self.GetWin(), sizer=_RF_Gain_sizer, value=self.RF_Gain, callback=self.set_RF_Gain, minimum=0, maximum=100, num_steps=45, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_RF_Gain_sizer, 1, 1, 1, 1) self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.notebook_0.GetPage(0).GetWin(), baseband_freq=0, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Baseband Waterfall", size=(800,100), ) self.notebook_0.GetPage(0).GridAdd(self.wxgui_waterfallsink2_0.win, 3, 0, 1, 2) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.notebook_0.GetPage(3).GetWin(), title="Scope Plot", sample_rate=32e3, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=2, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", size=(800,500), ) self.notebook_0.GetPage(3).Add(self.wxgui_scopesink2_0.win) self.wxgui_fftsink2_0_1 = fftsink2.fft_sink_f( self.notebook_0.GetPage(2).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=32e3, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="Difference FFT ", peak_hold=False, ) self.notebook_0.GetPage(2).Add(self.wxgui_fftsink2_0_1.win) self.wxgui_fftsink2_0_0_0 = fftsink2.fft_sink_f( self.notebook_0.GetPage(1).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate/8, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="Demodulated FFT", peak_hold=False, size=(800,800), ) self.notebook_0.GetPage(1).Add(self.wxgui_fftsink2_0_0_0.win) self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_c( self.notebook_0.GetPage(0).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="Baseband FFT", peak_hold=False, size=(800,100), ) self.notebook_0.GetPage(0).GridAdd(self.wxgui_fftsink2_0_0.win, 2, 0, 1, 2) self.wxgui_fftsink2_0 = fftsink2.fft_sink_f( self.notebook_0.GetPage(2).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=32e3, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="Sum FFT", peak_hold=False, ) self.notebook_0.GetPage(2).Add(self.wxgui_fftsink2_0.win) self.rfgain = blocks.multiply_const_vcc((RF_Gain, )) self.low_pass_filter_1_0 = filter.fir_filter_fff(smux_decim, firdes.low_pass( 1, smux_filt_samprate, 15e3, 500, firdes.WIN_HAMMING, 1)) self.low_pass_filter_0 = filter.fir_filter_ccf(2, firdes.low_pass( 2, samp_rate/4, 100e3, 500, firdes.WIN_KAISER, 6.76)) self.iir_filter_xxx_0 = filter.iir_filter_ccf((-0.00266, 0.00504, -0.00309, -0.00136, 0.00663, -0.01052, 0.01103, -0.00731, 0.00016, 0.00800, -0.01396, 0.01490, -0.00971, -0.00035, 0.01173, -0.01979, 0.02054, -0.01240, -0.00273, 0.01960, -0.03122, 0.03124, -0.01669, -0.01017, 0.04137, -0.06448, 0.06476, -0.02634, -0.07449, 0.33571, -0.00000, -0.33571, 0.07449, 0.02634, -0.06476, 0.06448, -0.04137, 0.01017, 0.01669, -0.03124, 0.03122, -0.01960, 0.00273, 0.01240, -0.02054, 0.01979, -0.01173, 0.00035, 0.00971, -0.01490, 0.01396, -0.00800, -0.00016, 0.00731, -0.01103, 0.01052, -0.00663, 0.00136, 0.00309, -0.00504, 0.00266 ), (1 , ), False) self.fir_filter_xxx_0_0 = filter.fir_filter_ccf(4, (1,1,1,1)) self.fir_filter_xxx_0_0.declare_sample_delay(0) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_multiply_xx_1_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((right_gain, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((left_gain, )) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_file_source_0_0 = blocks.file_source(gr.sizeof_gr_complex*1, "/Users/bretttt/iCloud_drive/16S/engs110/project/radio_dat/IQ_Data_STEREO1", True) self.blocks_divide_xx_1 = blocks.divide_cc(1) self.blocks_delay_2 = blocks.delay(gr.sizeof_gr_complex*1, 30) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.blocks_add_const_vxx_0 = blocks.add_const_vcc((0.1, )) self.baseband_LPF = filter.fir_filter_fff(smux_decim, firdes.low_pass( 1, smux_filt_samprate, 15e3, 500, firdes.WIN_KAISER, 6.76)) self.band_pass_filter_0_0_0 = filter.fir_filter_fcc(1, firdes.complex_band_pass( 1, smux_filt_samprate, 18000, 20000, 1000, firdes.WIN_KAISER, 1)) self.band_pass_filter_0 = filter.fir_filter_fff(1, firdes.band_pass( 1, smux_filt_samprate, bpf_base, bpf_base+30e3, 500, firdes.WIN_KAISER, 6.76)) self.audio_sink_0_0_0_0 = audio.sink(32000, "", True) self.analog_pll_refout_cc_0_0 = analog.pll_refout_cc(3.14/100, 0.152*3.14, 0.144*3.14) self.analog_fm_deemph_0_0 = analog.fm_deemph(fs=samp_rate/8, tau=75e-6) self.analog_fm_deemph_0 = analog.fm_deemph(fs=samp_rate/8, tau=75e-6) self.analog_const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0) _CF_sizer = wx.BoxSizer(wx.VERTICAL) self._CF_text_box = forms.text_box( parent=self.GetWin(), sizer=_CF_sizer, value=self.CF, callback=self.set_CF, label="Center Frequency", converter=forms.float_converter(), proportion=0, ) self._CF_slider = forms.slider( parent=self.GetWin(), sizer=_CF_sizer, value=self.CF, callback=self.set_CF, minimum=80e6, maximum=108e6, num_steps=280, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_CF_sizer, 3, 0, 1, 2) ################################################## # Connections ################################################## self.connect((self.analog_const_source_x_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.analog_fm_deemph_0, 0), (self.audio_sink_0_0_0_0, 0)) self.connect((self.analog_fm_deemph_0_0, 0), (self.audio_sink_0_0_0_0, 1)) self.connect((self.analog_pll_refout_cc_0_0, 0), (self.blocks_multiply_xx_1_0, 0)) self.connect((self.analog_pll_refout_cc_0_0, 0), (self.blocks_multiply_xx_1_0, 1)) self.connect((self.band_pass_filter_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.band_pass_filter_0_0_0, 0), (self.analog_pll_refout_cc_0_0, 0)) self.connect((self.baseband_LPF, 0), (self.blocks_add_xx_0, 0)) self.connect((self.baseband_LPF, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_divide_xx_1, 1)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_complex_to_imag_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.blocks_complex_to_imag_0, 0), (self.band_pass_filter_0_0_0, 0)) self.connect((self.blocks_complex_to_imag_0, 0), (self.baseband_LPF, 0)) self.connect((self.blocks_complex_to_imag_0, 0), (self.wxgui_fftsink2_0_0_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_delay_2, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.blocks_divide_xx_1, 0), (self.blocks_delay_2, 0)) self.connect((self.blocks_divide_xx_1, 0), (self.iir_filter_xxx_0, 0)) self.connect((self.blocks_file_source_0_0, 0), (self.rfgain, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_complex_to_imag_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.analog_fm_deemph_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.analog_fm_deemph_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.wxgui_fftsink2_0_1, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.wxgui_scopesink2_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_1_0, 0)) self.connect((self.blocks_multiply_xx_1_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.fir_filter_xxx_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.wxgui_fftsink2_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.wxgui_waterfallsink2_0, 0)) self.connect((self.fir_filter_xxx_0_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.iir_filter_xxx_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_divide_xx_1, 0)) self.connect((self.low_pass_filter_1_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.low_pass_filter_1_0, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.rfgain, 0), (self.blocks_throttle_0, 0))
def __init__(self, mode, audio_rate=0, **kwargs): if mode == 'LSB': lsb = True cw = False elif mode == 'USB': lsb = False cw = False elif mode == 'CW': lsb = False cw = True else: raise ValueError('Not an SSB mode: %r' % (mode,)) demod_rate = audio_rate SimpleAudioDemodulator.__init__(self, mode=mode, audio_rate=audio_rate, demod_rate=demod_rate, band_filter=audio_rate / 2, # note narrower filter applied later band_filter_transition=audio_rate / 2, **kwargs) input_rate = self.input_rate if cw: self.__offset = 1500 half_bandwidth = self.half_bandwidth = 500 self.band_filter_width = 120 band_mid = 0 agc_reference = 0.1 else: self.__offset = 0 half_bandwidth = self.half_bandwidth = 2800 / 2 self.band_filter_width = half_bandwidth / 5 if lsb: band_mid = -200 - half_bandwidth else: band_mid = 200 + half_bandwidth agc_reference = 0.25 self.band_filter_low = band_mid - half_bandwidth self.band_filter_high = band_mid + half_bandwidth self.sharp_filter_block = grfilter.fir_filter_ccc( 1, firdes.complex_band_pass(1.0, demod_rate, self.band_filter_low + self.__offset, self.band_filter_high + self.__offset, self.band_filter_width, firdes.WIN_HAMMING)) self.agc_block = analog.agc2_cc(reference=agc_reference) self.ssb_demod_block = blocks.complex_to_real(1) self.connect( self, self.band_filter_block, self.sharp_filter_block, self.rf_squelch_block, self.agc_block, self.ssb_demod_block) self.connect(self.sharp_filter_block, self.rf_probe_block) self.connect_audio_output(self.ssb_demod_block, self.ssb_demod_block)
def connect_audio_stage(self, input_port): stereo_rate = self.demod_rate normalizer = TWO_PI / stereo_rate pilot_tone = 19000 pilot_low = pilot_tone * 0.98 pilot_high = pilot_tone * 1.02 def make_audio_filter(): return grfilter.fir_filter_fff( stereo_rate // self.__audio_int_rate, # decimation firdes.low_pass( 1.0, stereo_rate, 15000, 5000, firdes.WIN_HAMMING)) stereo_pilot_filter = grfilter.fir_filter_fcc( 1, # decimation firdes.complex_band_pass( 1.0, stereo_rate, pilot_low, pilot_high, 300)) # TODO magic number from gqrx stereo_pilot_pll = analog.pll_refout_cc( loop_bw=0.001, max_freq=normalizer * pilot_high, min_freq=normalizer * pilot_low) stereo_pilot_doubler = blocks.multiply_cc() stereo_pilot_out = blocks.complex_to_real() difference_channel_mixer = blocks.multiply_ff() difference_channel_filter = make_audio_filter() mono_channel_filter = make_audio_filter() mixL = blocks.add_ff(1) mixR = blocks.sub_ff(1) # connections self.connect(input_port, mono_channel_filter) if self.__decode_stereo: # stereo pilot tone tracker self.connect( input_port, stereo_pilot_filter, stereo_pilot_pll) self.connect(stereo_pilot_pll, (stereo_pilot_doubler, 0)) self.connect(stereo_pilot_pll, (stereo_pilot_doubler, 1)) self.connect(stereo_pilot_doubler, stereo_pilot_out) # pick out stereo left-right difference channel (at stereo_rate) self.connect(input_port, (difference_channel_mixer, 0)) self.connect(stereo_pilot_out, (difference_channel_mixer, 1)) self.connect( difference_channel_mixer, blocks.multiply_const_ff(6), # TODO: Completely empirical fudge factor. This should not be necessary. I believe this is at least partly due to phase error in the pilot signal. difference_channel_filter) # recover left/right channels (at self.__audio_int_rate) self.connect(difference_channel_filter, (mixL, 1)) self.connect(difference_channel_filter, (mixR, 1)) self.connect(mono_channel_filter, (mixL, 0)) self.connect(mono_channel_filter, (mixR, 0)) resamplerL = self._make_resampler((mixL, 0), self.__audio_int_rate) resamplerR = self._make_resampler((mixR, 0), self.__audio_int_rate) deemphL = fm_emph.fm_deemph(self.__audio_int_rate, 75e-6) deemphR = fm_emph.fm_deemph(self.__audio_int_rate, 75e-6) self.connect(resamplerL, deemphL) self.connect(resamplerR, deemphR) self.connect_audio_output(deemphL, deemphR) else: resampler = self._make_resampler(mono_channel_filter, self.__audio_int_rate) deemph = fm_emph.fm_deemph(self.__audio_int_rate, 75e-6) self.connect(resampler, deemph) self.connect_audio_output(deemph, deemph)
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Psk31 Rx") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.center_freq = center_freq = 441000000 self.samp_rate = samp_rate = 960000 self.psk_offset = psk_offset = 1000 self.psk_center = psk_center = center_freq + 141000 self.int_rate = int_rate = 48000 self.gain = gain = 30 self.corr = corr = 0 self.audio_rate = audio_rate = 8000 ################################################## # Message Queues ################################################## blocks_message_sink_0_msgq_out = wxgui_termsink_0_msgq_in = gr.msg_queue(2) ################################################## # Blocks ################################################## _psk_offset_sizer = wx.BoxSizer(wx.VERTICAL) self._psk_offset_text_box = forms.text_box( parent=self.GetWin(), sizer=_psk_offset_sizer, value=self.psk_offset, callback=self.set_psk_offset, label="PSK offset", converter=forms.float_converter(), proportion=0, ) self._psk_offset_slider = forms.slider( parent=self.GetWin(), sizer=_psk_offset_sizer, value=self.psk_offset, callback=self.set_psk_offset, minimum=0, maximum=3000, num_steps=300, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_psk_offset_sizer, 1, 0, 1, 2) _psk_center_sizer = wx.BoxSizer(wx.VERTICAL) self._psk_center_text_box = forms.text_box( parent=self.GetWin(), sizer=_psk_center_sizer, value=self.psk_center, callback=self.set_psk_center, label="Tuning", converter=forms.float_converter(), proportion=0, ) self._psk_center_slider = forms.slider( parent=self.GetWin(), sizer=_psk_center_sizer, value=self.psk_center, callback=self.set_psk_center, minimum=center_freq + 110000, maximum=center_freq + 150000, num_steps=40, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_psk_center_sizer, 0, 0, 1, 2) self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.nb.AddPage(grc_wxgui.Panel(self.nb), "960 kHz") self.nb.AddPage(grc_wxgui.Panel(self.nb), "48 kHz") self.nb.AddPage(grc_wxgui.Panel(self.nb), "4 kHz") self.nb.AddPage(grc_wxgui.Panel(self.nb), "I/Q scope") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Constellation") self.GridAdd(self.nb, 3, 0, 1, 2) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label='gain', converter=forms.float_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=49.6, num_steps=124, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_gain_sizer, 2, 0, 1, 1) _corr_sizer = wx.BoxSizer(wx.VERTICAL) self._corr_text_box = forms.text_box( parent=self.GetWin(), sizer=_corr_sizer, value=self.corr, callback=self.set_corr, label='corr', converter=forms.float_converter(), proportion=0, ) self._corr_slider = forms.slider( parent=self.GetWin(), sizer=_corr_sizer, value=self.corr, callback=self.set_corr, minimum=-150, maximum=150, num_steps=300, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_corr_sizer, 2, 1, 1, 1) self.wxgui_waterfallsink2_2 = waterfallsink2.waterfall_sink_f( self.nb.GetPage(2).GetWin(), baseband_freq=0, dynamic_range=30, ref_level=-40, ref_scale=2.0, sample_rate=audio_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", win=window.blackmanharris, size=((800,400)), ) self.nb.GetPage(2).Add(self.wxgui_waterfallsink2_2.win) def wxgui_waterfallsink2_2_callback(x, y): self.set_psk_offset(x) self.wxgui_waterfallsink2_2.set_callback(wxgui_waterfallsink2_2_callback) self.wxgui_waterfallsink2_1 = waterfallsink2.waterfall_sink_c( self.nb.GetPage(1).GetWin(), baseband_freq=psk_center, dynamic_range=30, ref_level=-30, ref_scale=2.0, sample_rate=int_rate, fft_size=2048, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", size=((800,400)), ) self.nb.GetPage(1).Add(self.wxgui_waterfallsink2_1.win) self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.nb.GetPage(0).GetWin(), baseband_freq=center_freq, dynamic_range=30, ref_level=-20, ref_scale=2.0, sample_rate=samp_rate, fft_size=2048, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", size=((800,400)), ) self.nb.GetPage(0).Add(self.wxgui_waterfallsink2_0.win) def wxgui_waterfallsink2_0_callback(x, y): self.set_psk_center(x) self.wxgui_waterfallsink2_0.set_callback(wxgui_waterfallsink2_0_callback) self.wxgui_termsink_0 = termsink.termsink( parent=self.GetWin(), size=(500,100), msgq=wxgui_termsink_0_msgq_in, ) self.Add(self.wxgui_termsink_0) self.wxgui_scopesink2_1 = scopesink2.scope_sink_c( self.nb.GetPage(4).GetWin(), title="Scope Plot", sample_rate=31.25, v_scale=0.4, v_offset=0, t_scale=0, ac_couple=False, xy_mode=True, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(4).Add(self.wxgui_scopesink2_1.win) self.wxgui_scopesink2_0 = scopesink2.scope_sink_c( self.nb.GetPage(3).GetWin(), title="Scope Plot", sample_rate=500, v_scale=0.4, v_offset=0, t_scale=0, ac_couple=False, xy_mode=True, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(3).Add(self.wxgui_scopesink2_0.win) self.wxgui_numbersink2_0 = numbersink2.number_sink_f( self.GetWin(), unit="Hz", minval=-500 / math.pi, maxval=500 / math.pi, factor=500 / math.pi, decimal_places=1, ref_level=0, sample_rate=500, number_rate=15, average=False, avg_alpha=None, label="Carrier tracking offset", peak_hold=False, show_gauge=True, ) self.Add(self.wxgui_numbersink2_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(corr, 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(0, 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(0, 0) self.ham_varicode_rx_0 = ham.varicode_rx() self.freq_xlating_fir_filter_xxx_1 = filter.freq_xlating_fir_filter_ccc(16, (firdes.low_pass(10, audio_rate, 120, 40, firdes.WIN_HAMMING, 6.76)), psk_offset, audio_rate) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(samp_rate / int_rate, (firdes.low_pass(1, samp_rate, 12000, 12000, firdes.WIN_HAMMING, 6.76)), round(psk_center - center_freq,-3), samp_rate) self.digital_diff_phasor_cc_0 = digital.diff_phasor_cc() self.digital_costas_loop_cc_0 = digital.costas_loop_cc(5 * math.pi /100.0, 2) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_cc(16, 0.25*0.175*0.175, 0.5, 0.175, 0.005) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_message_sink_0 = blocks.message_sink(gr.sizeof_char*1, blocks_message_sink_0_msgq_out, True) self.blocks_complex_to_real_1 = blocks.complex_to_real(1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.band_pass_filter_0 = filter.fir_filter_ccc(int_rate / audio_rate, firdes.complex_band_pass( 1, int_rate, 200, 2800, 200, firdes.WIN_HAMMING, 6.76)) self.audio_sink_0 = audio.sink(audio_rate, "plughw:0,0", True) self.analog_agc_xx_0 = analog.agc_cc(1e-3, 0.1, 1.0) self.analog_agc_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_waterfallsink2_1, 0)) self.connect((self.osmosdr_source_0, 0), (self.wxgui_waterfallsink2_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.wxgui_waterfallsink2_2, 0)) self.connect((self.digital_costas_loop_cc_0, 1), (self.wxgui_numbersink2_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_1, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_diff_phasor_cc_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.ham_varicode_rx_0, 0), (self.blocks_message_sink_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.ham_varicode_rx_0, 0)) self.connect((self.blocks_complex_to_real_1, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.digital_diff_phasor_cc_0, 0), (self.blocks_complex_to_real_1, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.audio_sink_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.analog_agc_xx_0, 0)) self.connect((self.analog_agc_xx_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.analog_agc_xx_0, 0), (self.freq_xlating_fir_filter_xxx_1, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.wxgui_scopesink2_1, 0))
def set_samp_rate(self, samp_rate): self.samp_rate = samp_rate self.set_freq(self.samp_rate/4) self.fft_filter_xxx_0.set_taps((firdes.complex_band_pass(pow(10.0,self.amp/10.0),self.samp_rate,-3000,-300,100,firdes.WIN_BLACKMAN))) self.analog_sig_source_x_0.set_sampling_freq(self.samp_rate)
def set_amp(self, amp): self.amp = amp self.fft_filter_xxx_0.set_taps((firdes.complex_band_pass(pow(10.0,self.amp/10.0),self.samp_rate,-3000,-300,100,firdes.WIN_BLACKMAN))) self.analog_noise_source_x_0.set_amplitude(pow(10.0,self.amp/10.0))
def __init__(self): gr.top_block.__init__( self, "Downlink from TVAC (This should run all the time)") Qt.QWidget.__init__(self) self.setWindowTitle( "Downlink from TVAC (This should run all the time)") 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", "downlink") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.freq_offset = freq_offset = 0 self.freq = freq = 145.95e6 self.block_len_enc = block_len_enc = 1024 / 8 * 2 self.variable_qtgui_label_0 = variable_qtgui_label_0 = 0 self.variable_constellation_0 = variable_constellation_0 = digital.constellation_calcdist( ([-1, 1]), ([0, 1]), 4, 1).base() self.samp_rate_factor = samp_rate_factor = 5 self.samp_rate = samp_rate = 250000 self.rgain = rgain = 40 self.real_center_freq = real_center_freq = freq + freq_offset self.payload = payload = block_len_enc + 4 self.freq_offset_flag = freq_offset_flag = 0 ################################################## # Blocks ################################################## self._freq_offset_range = Range(-400e3, 400e3, 1.5e3, 0, 200) self._freq_offset_win = RangeWidget(self._freq_offset_range, self.set_freq_offset, 'Frequency Offset', "counter_slider", float) self.top_grid_layout.addWidget(self._freq_offset_win) self._variable_qtgui_label_0_tool_bar = Qt.QToolBar(self) if None: self._variable_qtgui_label_0_formatter = None else: self._variable_qtgui_label_0_formatter = lambda x: str(x) self._variable_qtgui_label_0_tool_bar.addWidget( Qt.QLabel("variable_qtgui_label_0" + ": ")) self._variable_qtgui_label_0_label = Qt.QLabel( str( self._variable_qtgui_label_0_formatter( self.variable_qtgui_label_0))) self._variable_qtgui_label_0_tool_bar.addWidget( self._variable_qtgui_label_0_label) self.top_grid_layout.addWidget(self._variable_qtgui_label_0_tool_bar) self._rgain_range = Range(0, 50, 1, 40, 200) self._rgain_win = RangeWidget(self._rgain_range, self.set_rgain, 'RX Gain', "counter_slider", float) self.top_grid_layout.addWidget(self._rgain_win) self._real_center_freq_tool_bar = Qt.QToolBar(self) if None: self._real_center_freq_formatter = None else: self._real_center_freq_formatter = lambda x: eng_notation.num_to_str( x) self._real_center_freq_tool_bar.addWidget( Qt.QLabel('Real center freq' + ": ")) self._real_center_freq_label = Qt.QLabel( str(self._real_center_freq_formatter(self.real_center_freq))) self._real_center_freq_tool_bar.addWidget(self._real_center_freq_label) self.top_grid_layout.addWidget(self._real_center_freq_tool_bar) self.rational_resampler_xxx_1 = filter.rational_resampler_ccc( interpolation=1, decimation=5, taps=None, fractional_bw=None, ) self.qtgui_sink_x_0_0_1 = qtgui.sink_c( 4096, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "Vor Sync", #name True, #plotfreq True, #plotwaterfall True, #plottime True, #plotconst ) self.qtgui_sink_x_0_0_1.set_update_time(1.0 / 10) self._qtgui_sink_x_0_0_1_win = sip.wrapinstance( self.qtgui_sink_x_0_0_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_sink_x_0_0_1_win) self.qtgui_sink_x_0_0_1.enable_rf_freq(False) self.qtgui_sink_x_0_0 = qtgui.sink_c( 32768, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate * samp_rate_factor, #bw "Vor Sync", #name False, #plotfreq True, #plotwaterfall True, #plottime True, #plotconst ) self.qtgui_sink_x_0_0.set_update_time(1.0 / 10) self._qtgui_sink_x_0_0_win = sip.wrapinstance( self.qtgui_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_sink_x_0_0_win) self.qtgui_sink_x_0_0.enable_rf_freq(False) self._freq_offset_flag_range = Range(0, 1, 1, 0, 200) self._freq_offset_flag_win = RangeWidget(self._freq_offset_flag_range, self.set_freq_offset_flag, 'Enable flatsat freq', "counter_slider", float) self.top_grid_layout.addWidget(self._freq_offset_flag_win) self.fir_filter_xxx_0 = filter.fir_filter_ccc(samp_rate_factor, (1, )) self.fir_filter_xxx_0.declare_sample_delay(0) self.digital_mpsk_receiver_cc_0_0 = digital.mpsk_receiver_cc( 2, 0, cmath.pi / 100.0, -0.05, 0.05, 0.25, 0.05, 4, 4, 0.005) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( variable_constellation_0) self.ccsds_softbits_msg_to_bytes_b_0 = ccsds.softbits_msg_to_bytes_b() self.ccsds_randomiser_softbits_0 = ccsds.randomiser_softbits( 0x95, 0xFF) self.ccsds_mpsk_ambiguity_resolver_f_0 = ccsds.mpsk_ambiguity_resolver_f( 2, '49E0DCC7', 32, 1, 0.8, block_len_enc, 0) self.ccsds_message_info_0 = ccsds.message_info( "Block received and sent to Nanolink: ", 20) self.ccsds_ldpc_decoder_0 = ccsds.ldpc_decoder( '/tmp/AR4JA_r12_k1024n.a', ccsds.LDPC_SYS_FRONT, ccsds.LDPC_PUNCT_BACK, 512, tuple(([]))) self.ccsds_blob_msg_sink_b_0 = ccsds.blob_msg_sink_b(256 / 2) self.blocks_wavfile_source_0 = blocks.wavfile_source( '/app/input/source.wav', True) self.blocks_udp_sink_0_1 = blocks.udp_sink(gr.sizeof_char * 1, '127.0.0.1', 5431, 256, True) self.blocks_udp_sink_0_0 = blocks.udp_sink(gr.sizeof_char * 1, '127.0.0.1', 5433, 1472, True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_char * 1) self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_message_debug_1_0_0 = blocks.message_debug() self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 0.5) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-1, )) self.band_pass_filter_0 = filter.fir_filter_ccc( 1, firdes.complex_band_pass(1, samp_rate * samp_rate_factor, -220e3, -180e3, 6e3, firdes.WIN_HAMMING, 6.76)) self.analog_sig_source_x_0_0 = analog.sig_source_c( samp_rate * samp_rate_factor, analog.GR_COS_WAVE, -freq_offset, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, -50000, 1, 0) self.analog_agc_xx_0 = analog.agc_cc(1e-4, 0.5, 1.0) self.analog_agc_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.msg_connect((self.ccsds_blob_msg_sink_b_0, 'out'), (self.blocks_message_debug_1_0_0, 'print_pdu')) self.msg_connect((self.ccsds_blob_msg_sink_b_0, 'out'), (self.ccsds_message_info_0, 'in')) self.msg_connect((self.ccsds_ldpc_decoder_0, 'out'), (self.ccsds_softbits_msg_to_bytes_b_0, 'in')) self.msg_connect((self.ccsds_mpsk_ambiguity_resolver_f_0, 'out'), (self.ccsds_randomiser_softbits_0, 'in')) self.msg_connect((self.ccsds_randomiser_softbits_0, 'out'), (self.ccsds_ldpc_decoder_0, 'in')) self.connect((self.analog_agc_xx_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.ccsds_mpsk_ambiguity_resolver_f_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.analog_agc_xx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_sink_x_0_0_1, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_sink_x_0_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_wavfile_source_0, 1), (self.blocks_float_to_complex_0, 1)) self.connect((self.ccsds_softbits_msg_to_bytes_b_0, 0), (self.blocks_null_sink_1, 0)) self.connect((self.ccsds_softbits_msg_to_bytes_b_0, 0), (self.blocks_udp_sink_0_1, 0)) self.connect((self.ccsds_softbits_msg_to_bytes_b_0, 0), (self.ccsds_blob_msg_sink_b_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_udp_sink_0_0, 0)) self.connect((self.digital_mpsk_receiver_cc_0_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.rational_resampler_xxx_1, 0), (self.digital_mpsk_receiver_cc_0_0, 0))
def __init__(self, mode, **kwargs): if mode == 'LSB': lsb = True cw = False elif mode == 'USB': lsb = False cw = False elif mode == 'CW': lsb = False cw = True else: raise ValueError('Not an SSB mode: %r' % (mode,)) demod_rate = 8000 # round number close to SSB bandwidth * 2 SimpleAudioDemodulator.__init__(self, mode=mode, audio_rate=demod_rate, demod_rate=demod_rate, band_filter=demod_rate / 2, # note narrower filter applied later band_filter_transition=demod_rate / 2, **kwargs) if cw: self.__offset = 1500 # CW beat frequency half_bandwidth = self.half_bandwidth = 500 band_filter_width = 120 band_mid = 0 agc_reference = dB(-10) agc_rate = 1e-1 else: self.__offset = 0 half_bandwidth = self.half_bandwidth = 2800 / 2 # standard SSB bandwidth band_filter_width = half_bandwidth / 5 if lsb: band_mid = -200 - half_bandwidth else: band_mid = 200 + half_bandwidth agc_reference = dB(-8) agc_rate = 8e-1 band_filter_low = band_mid - half_bandwidth band_filter_high = band_mid + half_bandwidth sharp_filter_block = grfilter.fir_filter_ccc( 1, firdes.complex_band_pass(1.0, demod_rate, band_filter_low + self.__offset, band_filter_high + self.__offset, band_filter_width, firdes.WIN_HAMMING)) self.__filter_shape = { u'low': band_filter_low, u'high': band_filter_high, u'width': band_filter_width } self.agc_block = analog.agc2_cc(reference=agc_reference) self.agc_block.set_attack_rate(agc_rate) self.agc_block.set_decay_rate(agc_rate) self.agc_block.set_max_gain(dB(_ssb_max_agc)) ssb_demod_block = blocks.complex_to_real(1) self.connect( self, self.band_filter_block, sharp_filter_block, # TODO: We would like to have an in self.rf_squelch_block, self.agc_block, ssb_demod_block) self.connect(sharp_filter_block, self.rf_probe_block) self.connect_audio_output(ssb_demod_block)
def connect_audio_stage(self, input_port): stereo_rate = self.demod_rate normalizer = TWO_PI / stereo_rate pilot_tone = 19000 pilot_low = pilot_tone * 0.9 pilot_high = pilot_tone * 1.1 def make_audio_filter(): return grfilter.fir_filter_fff( stereo_rate // self.__audio_int_rate, # decimation firdes.low_pass( 1.0, stereo_rate, 15000, 5000, firdes.WIN_HAMMING)) stereo_pilot_filter = grfilter.fir_filter_fcc( 1, # decimation firdes.complex_band_pass( 1.0, stereo_rate, pilot_low, pilot_high, 300)) # TODO magic number from gqrx stereo_pilot_pll = analog.pll_refout_cc( 0.001, # TODO magic number from gqrx normalizer * pilot_high, normalizer * pilot_low) stereo_pilot_doubler = blocks.multiply_cc() stereo_pilot_out = blocks.complex_to_imag() difference_channel_mixer = blocks.multiply_ff() difference_channel_filter = make_audio_filter() mono_channel_filter = make_audio_filter() mixL = blocks.add_ff(1) mixR = blocks.sub_ff(1) # connections self.connect(input_port, mono_channel_filter) if self.stereo: # stereo pilot tone tracker self.connect( input_port, stereo_pilot_filter, stereo_pilot_pll) self.connect(stereo_pilot_pll, (stereo_pilot_doubler, 0)) self.connect(stereo_pilot_pll, (stereo_pilot_doubler, 1)) self.connect(stereo_pilot_doubler, stereo_pilot_out) # pick out stereo left-right difference channel (at stereo_rate) self.connect(input_port, (difference_channel_mixer, 0)) self.connect(stereo_pilot_out, (difference_channel_mixer, 1)) self.connect(difference_channel_mixer, difference_channel_filter) # recover left/right channels (at self.__audio_int_rate) self.connect(difference_channel_filter, (mixL, 1)) self.connect(difference_channel_filter, (mixR, 1)) resamplerL = self._make_resampler((mixL, 0), self.__audio_int_rate) resamplerR = self._make_resampler((mixR, 0), self.__audio_int_rate) self.connect(mono_channel_filter, (mixL, 0)) self.connect(mono_channel_filter, (mixR, 0)) self.connect_audio_output(resamplerL, resamplerR) else: resampler = self._make_resampler(mono_channel_filter, self.__audio_int_rate) self.connect_audio_output(resampler, resampler)
def __init__(self): gr.top_block.__init__(self, "Lang Tx") ################################################## # Variables ################################################## plutoip = os.environ.get('PLUTO_IP') if plutoip == None: plutoip = 'pluto.local' plutoip = 'ip:' + plutoip self.ToneBurst = ToneBurst = False self.PTT = PTT = False self.Mode = Mode = 0 self.MicGain = MicGain = 5.0 self.KEY = KEY = False self.Filt_Low = Filt_Low = 300 self.Filt_High = Filt_High = 3000 self.FMMIC = FMMIC = 50 ################################################## # Blocks ################################################## self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=11, decimation=1, taps=None, fractional_bw=None, ) self.pluto_sink_0 = iio.pluto_sink(plutoip, 1000000000, 528000, 2000000, 0x800, False, 0, '', True) self.blocks_mute_xx_0_0 = blocks.mute_cc(bool(not PTT)) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_4 = blocks.multiply_const_vcc( ((Mode < 4) or (Mode == 5), )) self.blocks_multiply_const_vxx_3 = blocks.multiply_const_vcc( (Mode == 4, )) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((30, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( ((MicGain / 10.0) * (not (Mode == 2)) * (not (Mode == 3)), )) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_add_xx_2 = blocks.add_vcc(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.blocks_add_const_vxx_0 = blocks.add_const_vcc( ((0.5 * int(Mode == 5)) + (int(Mode == 2) * KEY) + (int(Mode == 3) * KEY), )) self.band_pass_filter_1 = filter.fir_filter_fff( 1, firdes.band_pass(FMMIC * 0.05, 48000, 200, 5000, 1000, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0_0 = filter.fir_filter_ccc( 1, firdes.complex_band_pass(1, 48000, Filt_Low, Filt_High, 100, firdes.WIN_HAMMING, 6.76)) self.audio_source_0 = audio.source(48000, "hw:CARD=Device,DEV=0", False) self.analog_sig_source_x_1 = analog.sig_source_f( 48000, analog.GR_COS_WAVE, 1750, 1.0 * ToneBurst, 0) self.analog_sig_source_x_0 = analog.sig_source_c( 48000, analog.GR_COS_WAVE, 0, 1, 0) self.dc_blocker_xx_0 = filter.dc_blocker_ff(4096, True) self.analog_nbfm_tx_0 = analog.nbfm_tx( audio_rate=48000, quad_rate=48000, tau=50e-6, max_dev=7500, fh=-1, ) self.analog_const_source_x_0 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, 0) self.analog_agc2_xx_1 = analog.agc2_cc(1e-1, 1e-1, 1.3 - (0.65 * (int(Mode == 5))), 1.0) self.analog_agc2_xx_1.set_max_gain(10) self.analog_agc2_ff_0 = analog.agc2_ff( 0.11490, 0.00256, 0.79 - (0.65 * (int(Mode == 4))), 3.16) self.analog_agc2_ff_0.set_max_gain(87.5) self.band_pass_filter_1_0 = filter.interp_fir_filter_ccc( 1, firdes.complex_band_pass(1, 48000, -7500, 7500, 1000, firdes.WIN_HAMMING, 6.76)) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_1, 0), (self.band_pass_filter_0_0, 0)) self.connect((self.analog_const_source_x_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.analog_nbfm_tx_0, 0), (self.band_pass_filter_1_0, 0)) self.connect((self.band_pass_filter_1_0, 0), (self.blocks_multiply_const_vxx_3, 0)) self.connect((self.dc_blocker_xx_0, 0), (self.band_pass_filter_1, 0)) self.connect((self.analog_agc2_ff_0, 0), (self.dc_blocker_xx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_sig_source_x_1, 0), (self.blocks_add_xx_0, 0)) self.connect((self.audio_source_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.audio_source_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.band_pass_filter_0_0, 0), (self.blocks_multiply_const_vxx_4, 0)) self.connect((self.band_pass_filter_1, 0), (self.analog_nbfm_tx_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.analog_agc2_ff_0, 0)) self.connect((self.blocks_add_xx_2, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_3, 0), (self.blocks_add_xx_2, 0)) self.connect((self.blocks_multiply_const_vxx_4, 0), (self.blocks_add_xx_2, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.analog_agc2_xx_1, 0)) self.connect((self.blocks_mute_xx_0_0, 0), (self.pluto_sink_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_mute_xx_0_0, 0))
def set_Filt_High(self, Filt_High): self.Filt_High = Filt_High self.band_pass_filter_0_0.set_taps( firdes.complex_band_pass(1, 48000, self.Filt_Low, self.Filt_High, 100, firdes.WIN_HAMMING, 6.76))
def __init__(self, samplerate): fir_taps = firdes.complex_band_pass(1, samplerate, -samplerate / 2, samplerate / 2, samplerate / 2) self.block = filter.freq_xlating_fir_filter_ccc( 1, (fir_taps), 0.0, samplerate)
def __init__(self): gr.top_block.__init__(self, "qo100", catch_exceptions=True) Qt.QWidget.__init__(self) self.setWindowTitle("qo100") 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", "qo100") 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.decim = decim = 11 self.vfo = vfo = 40e3 self.tx_vfo = tx_vfo = 40e3 self.samp_rate = samp_rate = decim * 48e3 self.rx0_low_cutoff = rx0_low_cutoff = 0 self.rx0_high_cutoff = rx0_high_cutoff = 3000 self.mag = mag = 0.9 self.af_gain = af_gain = 20 ################################################## # Blocks ################################################## self._vfo_msgdigctl_win = qtgui.MsgDigitalNumberControl( lbl='RX', min_freq_hz=-10e3, max_freq_hz=510e3, parent=self, thousands_separator=".", background_color="black", fontColor="white", var_callback=self.set_vfo, outputmsgname="'freq'".replace("'", "")) self._vfo_msgdigctl_win.setValue(40e3) self._vfo_msgdigctl_win.setReadOnly(False) self.vfo = self._vfo_msgdigctl_win self.top_layout.addWidget(self._vfo_msgdigctl_win) self._tx_vfo_msgdigctl_win = qtgui.MsgDigitalNumberControl( lbl='TX', min_freq_hz=-10e3, max_freq_hz=510e3, parent=self, thousands_separator=".", background_color="black", fontColor="white", var_callback=self.set_tx_vfo, outputmsgname="'freq'".replace("'", "")) self._tx_vfo_msgdigctl_win.setValue(40e3) self._tx_vfo_msgdigctl_win.setReadOnly(False) self.tx_vfo = self._tx_vfo_msgdigctl_win self.top_layout.addWidget(self._tx_vfo_msgdigctl_win) self._af_gain_range = Range(0, 200, 5, 20, 200) self._af_gain_win = RangeWidget(self._af_gain_range, self.set_af_gain, "af_gain", "counter_slider", float, QtCore.Qt.Horizontal) self.top_grid_layout.addWidget(self._af_gain_win, 29, 0, 1, 1) for r in range(29, 30): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.vfo2_to_float = blocks.complex_to_float(1) self.vfo2_signal_source = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 250e3 - 40e3, mag, 0, 0) self.vfo2_mixer = blocks.multiply_vcc(1) self.vfo2_bandpass = filter.fir_filter_ccc( decim, firdes.complex_band_pass(10, samp_rate, 0, 5000, 1000, window.WIN_HAMMING, 6.76)) self.vfo2_audio_sink = audio.sink(48000, 'pulse:rx2', False) self.vfo0_waterfall_atten = blocks.multiply_const_cc(0.01) self.vfo0_waterfall_add = blocks.add_vcc(1) self.vfo0_to_float = blocks.complex_to_float(1) self.vfo0_signal_source = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 250e3 - vfo, mag, 0, 0) self.vfo0_scope_bandpass = filter.fir_filter_ccc( 2 * decim, firdes.complex_band_pass(1, samp_rate, -12e3, 12e3, 1000, window.WIN_HAMMING, 6.76)) self.vfo0_scope = qtgui.freq_sink_c( 1024, #size window.WIN_HAMMING, #wintype 0, #fc 24e3, #bw '', #name 1, None # parent ) self.vfo0_scope.set_update_time(0.01) self.vfo0_scope.set_y_axis(-86, -40) self.vfo0_scope.set_y_label('Relative Gain', 'dB') self.vfo0_scope.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.vfo0_scope.enable_autoscale(False) self.vfo0_scope.enable_grid(True) self.vfo0_scope.set_fft_average(0.2) self.vfo0_scope.enable_axis_labels(True) self.vfo0_scope.enable_control_panel(True) self.vfo0_scope.set_fft_window_normalized(True) self.vfo0_scope.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.vfo0_scope.set_line_label(i, "Data {0}".format(i)) else: self.vfo0_scope.set_line_label(i, labels[i]) self.vfo0_scope.set_line_width(i, widths[i]) self.vfo0_scope.set_line_color(i, colors[i]) self.vfo0_scope.set_line_alpha(i, alphas[i]) self._vfo0_scope_win = sip.wrapinstance(self.vfo0_scope.qwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._vfo0_scope_win, 15, 0, 14, 1) for r in range(15, 29): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.vfo0_mixer = blocks.multiply_vcc(1) self.vfo0_bandpass = filter.fir_filter_ccc( decim, firdes.complex_band_pass(af_gain, samp_rate, rx0_low_cutoff, rx0_high_cutoff, 1000, window.WIN_HAMMING, 6.76)) self.vfo0_audio_sink = audio.sink(48000, 'pulse', False) self.tx_vfo_signal_source = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, tx_vfo - 250e3, mag, 0, 0) self.tx_to_complex = blocks.float_to_complex(1) self.tx_mixer = blocks.multiply_vcc(1) self.tx_bandpass = filter.interp_fir_filter_ccc( 1, firdes.complex_band_pass(1, 48e3, 0, 3000, 1000, window.WIN_HAMMING, 6.76)) self.tx_audio_source = audio.source(48000, 'pulse:tx0.monitor', False) self.rx_resampler = filter.rational_resampler_ccc(interpolation=decim, decimation=1, taps=[], fractional_bw=0) self.rx0_low_cutoff_setter = blocks.msg_pair_to_var( self.set_rx0_low_cutoff) self.rx0_high_cutoff_setter = blocks.msg_pair_to_var( self.set_rx0_high_cutoff) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 2048, #size window.WIN_BLACKMAN_hARRIS, #wintype 250e3, #fc samp_rate, #bw "", #name 1, #number of inputs None # parent ) self.qtgui_waterfall_sink_x_0.set_update_time(0.05) self.qtgui_waterfall_sink_x_0.enable_grid(False) self.qtgui_waterfall_sink_x_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.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(-75, -45) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0.qwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 0, 0, 14, 1) for r in range(0, 14): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.midi_block = midi_block.blk( midi_port='DJControl Compact:DJControl Compact DJControl Com') if "int" == "int": isFloat = False scaleFactor = 1 else: isFloat = True scaleFactor = 1 _low_cutoff_gauge_lg_win = qtgui.GrLevelGauge('', "default", "default", "default", 0, 3000, 100, False, 1, isFloat, scaleFactor, True, self) _low_cutoff_gauge_lg_win.setValue(0) self.low_cutoff_gauge = _low_cutoff_gauge_lg_win self.top_layout.addWidget(_low_cutoff_gauge_lg_win) self.limesdr_source = limesdr.source('', 0, '') self.limesdr_source.set_sample_rate(samp_rate) self.limesdr_source.set_center_freq(739.75e6, 0) self.limesdr_source.set_bandwidth(1.5e6, 0) self.limesdr_source.set_gain(30, 0) self.limesdr_source.set_antenna(2, 0) self.limesdr_source.calibrate(5e6, 0) self.limesdr_sink = limesdr.sink('', 0, '', '') self.limesdr_sink.set_sample_rate(samp_rate) self.limesdr_sink.set_center_freq(2400.250e6, 0) self.limesdr_sink.set_bandwidth(5e6, 0) self.limesdr_sink.set_gain(73, 0) self.limesdr_sink.set_antenna(2, 0) self.limesdr_sink.calibrate(2.5e6, 0) if "int" == "int": isFloat = False scaleFactor = 1 else: isFloat = True scaleFactor = 1 _high_cutoff_gauge_lg_win = qtgui.GrLevelGauge('', "default", "default", "default", 0, 3000, 100, False, 1, isFloat, scaleFactor, True, self) _high_cutoff_gauge_lg_win.setValue(3000) self.high_cutoff_gauge = _high_cutoff_gauge_lg_win self.top_layout.addWidget(_high_cutoff_gauge_lg_win) self.control = control.blk() self.blocks_swapiq_0 = blocks.swap_iq(1, gr.sizeof_gr_complex) ################################################## # Connections ################################################## self.msg_connect((self.control, 'rx0_high_cutoff'), (self.high_cutoff_gauge, 'value')) self.msg_connect((self.control, 'rx0_low_cutoff'), (self.low_cutoff_gauge, 'value')) self.msg_connect((self.control, 'midi_out'), (self.midi_block, 'midi_in')) self.msg_connect((self.control, 'rx0_high_cutoff'), (self.rx0_high_cutoff_setter, 'inpair')) self.msg_connect((self.control, 'rx0_low_cutoff'), (self.rx0_low_cutoff_setter, 'inpair')) self.msg_connect((self.control, 'tx_freq_out'), (self.tx_vfo, 'valuein')) self.msg_connect((self.control, 'rx_freq_out'), (self.vfo, 'valuein')) self.msg_connect((self.midi_block, 'midi_out'), (self.control, 'midi_in')) self.msg_connect((self.tx_vfo, 'valueout'), (self.control, 'tx_freq_in')) self.msg_connect((self.vfo, 'valueout'), (self.control, 'rx_freq_in')) self.connect((self.blocks_swapiq_0, 0), (self.vfo0_waterfall_atten, 0)) self.connect((self.limesdr_source, 0), (self.vfo0_mixer, 0)) self.connect((self.limesdr_source, 0), (self.vfo0_waterfall_add, 0)) self.connect((self.limesdr_source, 0), (self.vfo2_mixer, 0)) self.connect((self.rx_resampler, 0), (self.tx_mixer, 0)) self.connect((self.tx_audio_source, 0), (self.tx_to_complex, 0)) self.connect((self.tx_bandpass, 0), (self.rx_resampler, 0)) self.connect((self.tx_mixer, 0), (self.limesdr_sink, 0)) self.connect((self.tx_to_complex, 0), (self.tx_bandpass, 0)) self.connect((self.tx_vfo_signal_source, 0), (self.tx_mixer, 1)) self.connect((self.vfo0_bandpass, 0), (self.vfo0_to_float, 0)) self.connect((self.vfo0_mixer, 0), (self.vfo0_bandpass, 0)) self.connect((self.vfo0_mixer, 0), (self.vfo0_scope_bandpass, 0)) self.connect((self.vfo0_scope_bandpass, 0), (self.vfo0_scope, 0)) self.connect((self.vfo0_signal_source, 0), (self.blocks_swapiq_0, 0)) self.connect((self.vfo0_signal_source, 0), (self.vfo0_mixer, 1)) self.connect((self.vfo0_to_float, 0), (self.vfo0_audio_sink, 0)) self.connect((self.vfo0_waterfall_add, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.vfo0_waterfall_atten, 0), (self.vfo0_waterfall_add, 1)) self.connect((self.vfo2_bandpass, 0), (self.vfo2_to_float, 0)) self.connect((self.vfo2_mixer, 0), (self.vfo2_bandpass, 0)) self.connect((self.vfo2_signal_source, 0), (self.vfo2_mixer, 1)) self.connect((self.vfo2_to_float, 0), (self.vfo2_audio_sink, 0))
def __init__(self, mode, **kwargs): if mode == 'LSB': lsb = True cw = False elif mode == 'USB': lsb = False cw = False elif mode == 'CW': lsb = False cw = True else: raise ValueError('Not an SSB mode: %r' % (mode,)) demod_rate = 8000 # round number close to SSB bandwidth * 2 SimpleAudioDemodulator.__init__(self, mode=mode, audio_rate=demod_rate, demod_rate=demod_rate, band_filter=demod_rate / 2, # note narrower filter applied later band_filter_transition=demod_rate / 2, **kwargs) if cw: self.__offset = 1500 # CW beat frequency half_bandwidth = self.half_bandwidth = 500 band_filter_width = 120 band_mid = 0 agc_reference = dB(-10) agc_rate = 1e-1 else: self.__offset = 0 half_bandwidth = self.half_bandwidth = 2800 / 2 # standard SSB bandwidth band_filter_width = half_bandwidth / 5 if lsb: band_mid = -200 - half_bandwidth else: band_mid = 200 + half_bandwidth agc_reference = dB(-8) agc_rate = 8e-1 band_filter_low = band_mid - half_bandwidth band_filter_high = band_mid + half_bandwidth sharp_filter_block = grfilter.fir_filter_ccc( 1, firdes.complex_band_pass(1.0, demod_rate, band_filter_low + self.__offset, band_filter_high + self.__offset, band_filter_width, firdes.WIN_HAMMING)) self.__filter_shape = BandShape.bandpass_transition( low=band_filter_low, high=band_filter_high, transition=band_filter_width, markers={}) self.agc_block = analog.agc2_cc(reference=agc_reference) self.agc_block.set_attack_rate(agc_rate) self.agc_block.set_decay_rate(agc_rate) self.agc_block.set_max_gain(dB(_ssb_max_agc)) ssb_demod_block = blocks.complex_to_real(1) self.connect( self, self.band_filter_block, sharp_filter_block, # TODO: We would like to have a squelch which does not interfere with the AGC, but this is impossible without combining the squelch and AGC self.rf_squelch_block, self.agc_block, ssb_demod_block) self.connect(sharp_filter_block, self.rf_probe_block) self.connect_audio_output(ssb_demod_block)
def set_af_gain(self, af_gain): self.af_gain = af_gain self.vfo0_bandpass.set_taps( firdes.complex_band_pass(self.af_gain, self.samp_rate, self.rx0_low_cutoff, self.rx0_high_cutoff, 1000, window.WIN_HAMMING, 6.76))
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._variable_config_LowCO_config = ConfigParser.ConfigParser() self._variable_config_LowCO_config.read("/home/maayan4/ParkingRC/Parking_RC_config.ini") try: variable_config_LowCO = self._variable_config_LowCO_config.getfloat("BPF", "Low_CO") except: variable_config_LowCO = 150e3 self.variable_config_LowCO = variable_config_LowCO self._variable_config_HighCO_config = ConfigParser.ConfigParser() self._variable_config_HighCO_config.read("/home/maayan4/ParkingRC/Parking_RC_config.ini") try: variable_config_HighCO = self._variable_config_HighCO_config.getfloat("BPF", "High_CO") except: variable_config_HighCO = 300e3 self.variable_config_HighCO = variable_config_HighCO self.samp_rate = samp_rate = 2000000 self.omega = omega = 250 self.gain_coeff = gain_coeff = 1 self.fft_size_slider = fft_size_slider = 1024 self.fft_size1 = fft_size1 = 1024 self.decimation_coeff = decimation_coeff = 4 self.center_freq = center_freq = 433.5E6 self.Low_CO = Low_CO = variable_config_LowCO self.High_CO = High_CO = variable_config_HighCO ################################################## # Blocks ################################################## self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.nb.AddPage(grc_wxgui.Panel(self.nb), "RF") self.nb.AddPage(grc_wxgui.Panel(self.nb), "filtered") self.nb.AddPage(grc_wxgui.Panel(self.nb), "BB") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Auto Corr") self.Add(self.nb) _omega_sizer = wx.BoxSizer(wx.VERTICAL) self._omega_text_box = forms.text_box( parent=self.nb.GetPage(2).GetWin(), sizer=_omega_sizer, value=self.omega, callback=self.set_omega, label="omega", converter=forms.float_converter(), proportion=0, ) self._omega_slider = forms.slider( parent=self.nb.GetPage(2).GetWin(), sizer=_omega_sizer, value=self.omega, callback=self.set_omega, minimum=0, maximum=1000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.nb.GetPage(2).Add(_omega_sizer) _center_freq_sizer = wx.BoxSizer(wx.VERTICAL) self._center_freq_text_box = forms.text_box( parent=self.GetWin(), sizer=_center_freq_sizer, value=self.center_freq, callback=self.set_center_freq, label="Center frequency", converter=forms.float_converter(), proportion=0, ) self._center_freq_slider = forms.slider( parent=self.GetWin(), sizer=_center_freq_sizer, value=self.center_freq, callback=self.set_center_freq, minimum=433E6, maximum=435E6, num_steps=200, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_center_freq_sizer) _Low_CO_sizer = wx.BoxSizer(wx.VERTICAL) self._Low_CO_text_box = forms.text_box( parent=self.nb.GetPage(1).GetWin(), sizer=_Low_CO_sizer, value=self.Low_CO, callback=self.set_Low_CO, label="Low_CO", converter=forms.float_converter(), proportion=0, ) self._Low_CO_slider = forms.slider( parent=self.nb.GetPage(1).GetWin(), sizer=_Low_CO_sizer, value=self.Low_CO, callback=self.set_Low_CO, minimum=0, maximum=500e3, num_steps=200, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.nb.GetPage(1).Add(_Low_CO_sizer) _High_CO_sizer = wx.BoxSizer(wx.VERTICAL) self._High_CO_text_box = forms.text_box( parent=self.nb.GetPage(1).GetWin(), sizer=_High_CO_sizer, value=self.High_CO, callback=self.set_High_CO, label="High_CO", converter=forms.float_converter(), proportion=0, ) self._High_CO_slider = forms.slider( parent=self.nb.GetPage(1).GetWin(), sizer=_High_CO_sizer, value=self.High_CO, callback=self.set_High_CO, minimum=150e3, maximum=500e3, num_steps=200, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.nb.GetPage(1).Add(_High_CO_sizer) self.wxgui_scopesink2_0_0_0_0 = scopesink2.scope_sink_f( self.nb.GetPage(2).GetWin(), title="BB", sample_rate=samp_rate*gain_coeff/decimation_coeff, v_scale=0, v_offset=0, t_scale=1, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(2).GridAdd(self.wxgui_scopesink2_0_0_0_0.win, 0, 1, 1, 1) self.wxgui_scopesink2_0_0_0 = scopesink2.scope_sink_f( self.nb.GetPage(2).GetWin(), title="After MM", sample_rate=samp_rate/decimation_coeff, v_scale=0, v_offset=0, t_scale=1, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(2).GridAdd(self.wxgui_scopesink2_0_0_0.win, 0, 0, 1, 1) self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_c( self.nb.GetPage(0).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=False, avg_alpha=None, title="RF", peak_hold=False, ) self.nb.GetPage(0).Add(self.wxgui_fftsink2_0_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.nb.GetPage(1).GetWin(), baseband_freq=center_freq, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate*gain_coeff/decimation_coeff, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="Filtered", peak_hold=False, ) self.nb.GetPage(1).Add(self.wxgui_fftsink2_0.win) self.low_pass_filter_0 = filter.fir_filter_fff(1, firdes.low_pass( 1, samp_rate*gain_coeff/decimation_coeff, 5000, 3500, firdes.WIN_HAMMING, 6.76)) _fft_size_slider_sizer = wx.BoxSizer(wx.VERTICAL) self._fft_size_slider_text_box = forms.text_box( parent=self.GetWin(), sizer=_fft_size_slider_sizer, value=self.fft_size_slider, callback=self.set_fft_size_slider, label="fft_size_1", converter=forms.float_converter(), proportion=0, ) self._fft_size_slider_slider = forms.slider( parent=self.GetWin(), sizer=_fft_size_slider_sizer, value=self.fft_size_slider, callback=self.set_fft_size_slider, minimum=24, maximum=1024, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_fft_size_slider_sizer) self.digital_correlate_access_code_bb_0 = digital.correlate_access_code_bb("11111", 0) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(omega*(1+0.0), 0.25*0.175*0.175, 0.5, 0.175, 0.005) self.digital_binary_slicer_fb_1 = digital.binary_slicer_fb() self.blocks_wavfile_sink_0_0 = blocks.wavfile_sink("/home/maayan4/ParkingRC/baseband_mm.wav", 1, samp_rate/8, 8) self.blocks_wavfile_sink_0 = blocks.wavfile_sink("/home/maayan4/ParkingRC/baseband.wav", 1, samp_rate*gain_coeff/decimation_coeff, 8) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((100, )) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, "/home/maayan4/ParkingRC/ParkingRC-f4.335000e+08-s2.000000e+06-t20160513215032.cfile", False) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/home/maayan4/ParkingRC/parkRC_bytes", False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.blocks_add_const_vxx_0_0 = blocks.add_const_vff((-0.3, )) self.band_pass_filter_0 = filter.fir_filter_ccc(decimation_coeff, firdes.complex_band_pass( gain_coeff, samp_rate, Low_CO, High_CO, High_CO-Low_CO, firdes.WIN_HAMMING, 6.76)) ################################################## # Connections ################################################## self.connect((self.band_pass_filter_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.blocks_add_const_vxx_0_0, 0), (self.low_pass_filter_0, 0)) 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.blocks_throttle_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_const_vxx_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.wxgui_fftsink2_0_0, 0)) self.connect((self.digital_binary_slicer_fb_1, 0), (self.digital_correlate_access_code_bb_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.blocks_wavfile_sink_0_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_1, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.wxgui_scopesink2_0_0_0, 0)) self.connect((self.digital_correlate_access_code_bb_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.wxgui_scopesink2_0_0_0_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Chu") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1200000 self.upconverter_lo_freq = upconverter_lo_freq = 125000000 self.space_tone = space_tone = 2025 self.offset = offset = 100000 self.mark_tone = mark_tone = 2225 self.gain = gain = 10 self.decimation = decimation = samp_rate / 48000 self.chu_freq = chu_freq = 3330000 self.channel_rate = channel_rate = 4800 ################################################## # Blocks ################################################## self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.nb.AddPage(grc_wxgui.Panel(self.nb), "48 kHz") self.nb.AddPage(grc_wxgui.Panel(self.nb), "4.8 kHz") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Data scope") self.GridAdd(self.nb, 2, 0, 1, 1) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label="USB tuner gain", converter=forms.float_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=50, num_steps=125, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_gain_sizer, 1, 0, 1, 1) self._chu_freq_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.chu_freq, callback=self.set_chu_freq, label="CHU frequency", choices=[3330000, 7850000, 14670000], labels=['3.33 MHz', '7.85 MHz', '14.67 MHz'], style=wx.RA_HORIZONTAL, ) self.GridAdd(self._chu_freq_chooser, 0, 0, 1, 1) self.wxgui_waterfallsink2_1 = waterfallsink2.waterfall_sink_c( self.nb.GetPage(1).GetWin(), baseband_freq=(mark_tone + space_tone) / 2, dynamic_range=50, ref_level=-20, ref_scale=2.0, sample_rate=channel_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", ) self.nb.GetPage(1).Add(self.wxgui_waterfallsink2_1.win) self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.nb.GetPage(0).GetWin(), baseband_freq=chu_freq, dynamic_range=50, ref_level=-60, ref_scale=2.0, sample_rate=samp_rate / decimation, fft_size=2048, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", win=window.hamming, ) self.nb.GetPage(0).Add(self.wxgui_waterfallsink2_0.win) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.nb.GetPage(2).GetWin(), title="Scope Plot", sample_rate=channel_rate, v_scale=1, v_offset=0, t_scale=0.050, ac_couple=False, xy_mode=False, num_inputs=2, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(2).Add(self.wxgui_scopesink2_0.win) self.root_raised_cosine_filter_0 = filter.fir_filter_fff( 1, firdes.root_raised_cosine(1, channel_rate, 300, 0.35, 100)) 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( chu_freq - offset + upconverter_lo_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(0, 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(0, 0) self.low_pass_filter_1 = filter.fir_filter_ccf( 10, firdes.low_pass(1000, samp_rate / 25, 200, 50, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf( decimation, firdes.low_pass(1, samp_rate, 20000, 5000, firdes.WIN_HAMMING, 6.76)) self.ham_chu_decode_0 = ham.chu_decode() self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_multiply_xx_2 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 0.5) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-1, )) self.band_pass_filter_0 = filter.fir_filter_ccc( 1, firdes.complex_band_pass(1, samp_rate / decimation, 200, 2800, 200, firdes.WIN_HAMMING, 6.76)) self.audio_sink_0_0 = audio.sink(48000, "", True) self.analog_sig_source_x_1 = analog.sig_source_c( samp_rate / decimation, analog.GR_COS_WAVE, -(space_tone + mark_tone) / 2, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, -offset, 1, 0) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf( channel_rate / (3.1416 * (mark_tone - space_tone))) self.analog_pll_carriertracking_cc_0 = analog.pll_carriertracking_cc( 3.1416 / 500, 1.8, -1.8) self.analog_agc_xx_0 = analog.agc_ff(1e-1, 0.02, 1.0) self.analog_agc_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_2, 1)) self.connect((self.analog_pll_carriertracking_cc_0, 0), (self.blocks_multiply_xx_2, 0)) self.connect((self.analog_pll_carriertracking_cc_0, 0), (self.wxgui_waterfallsink2_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_pll_carriertracking_cc_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.osmosdr_source_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.wxgui_waterfallsink2_1, 0)) self.connect((self.low_pass_filter_1, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.blocks_multiply_xx_2, 0), (self.low_pass_filter_1, 0)) self.connect((self.band_pass_filter_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.analog_agc_xx_0, 0), (self.audio_sink_0_0, 0)) self.connect((self.analog_pll_carriertracking_cc_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.analog_agc_xx_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.wxgui_scopesink2_0, 1)) self.connect((self.blocks_char_to_float_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.ham_chu_decode_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.root_raised_cosine_filter_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Multi Tx") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.audio_rate = audio_rate = 48000 self.wpm = wpm = 15 self.wbfm_on = wbfm_on = True self.usb_on = usb_on = True self.samp_rate = samp_rate = audio_rate * 40 self.q_offset = q_offset = 0 self.psk_on = psk_on = True self.phase = phase = 0 self.nbfm_on = nbfm_on = True self.magnitude = magnitude = 0 self.lsb_on = lsb_on = True self.i_offset = i_offset = 0 self.gain = gain = 25 self.cw_on = cw_on = True self.center_freq = center_freq = 441000000 self.am_on = am_on = True ################################################## # Blocks ################################################## self._wbfm_on_check_box = forms.check_box( parent=self.GetWin(), value=self.wbfm_on, callback=self.set_wbfm_on, label="WBFM", true=True, false=False, ) self.GridAdd(self._wbfm_on_check_box, 4, 1, 1, 1) self._usb_on_check_box = forms.check_box( parent=self.GetWin(), value=self.usb_on, callback=self.set_usb_on, label="USB", true=True, false=False, ) self.GridAdd(self._usb_on_check_box, 4, 4, 1, 1) _q_offset_sizer = wx.BoxSizer(wx.VERTICAL) self._q_offset_text_box = forms.text_box( parent=self.GetWin(), sizer=_q_offset_sizer, value=self.q_offset, callback=self.set_q_offset, label="DC offset Q", converter=forms.float_converter(), proportion=0, ) self._q_offset_slider = forms.slider( parent=self.GetWin(), sizer=_q_offset_sizer, value=self.q_offset, callback=self.set_q_offset, minimum=-0.1, maximum=0.1, num_steps=200, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_q_offset_sizer, 3, 0, 1, 7) self._psk_on_check_box = forms.check_box( parent=self.GetWin(), value=self.psk_on, callback=self.set_psk_on, label="PSK31", true=True, false=False, ) self.GridAdd(self._psk_on_check_box, 4, 6, 1, 1) _phase_sizer = wx.BoxSizer(wx.VERTICAL) self._phase_text_box = forms.text_box( parent=self.GetWin(), sizer=_phase_sizer, value=self.phase, callback=self.set_phase, label="Phase correction", converter=forms.float_converter(), proportion=0, ) self._phase_slider = forms.slider( parent=self.GetWin(), sizer=_phase_sizer, value=self.phase, callback=self.set_phase, minimum=-0.1, maximum=0.1, num_steps=200, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_phase_sizer, 0, 0, 1, 7) self._nbfm_on_check_box = forms.check_box( parent=self.GetWin(), value=self.nbfm_on, callback=self.set_nbfm_on, label="NBFM", true=True, false=False, ) self.GridAdd(self._nbfm_on_check_box, 4, 0, 1, 1) _magnitude_sizer = wx.BoxSizer(wx.VERTICAL) self._magnitude_text_box = forms.text_box( parent=self.GetWin(), sizer=_magnitude_sizer, value=self.magnitude, callback=self.set_magnitude, label="Magnitude correction", converter=forms.float_converter(), proportion=0, ) self._magnitude_slider = forms.slider( parent=self.GetWin(), sizer=_magnitude_sizer, value=self.magnitude, callback=self.set_magnitude, minimum=-0.1, maximum=0.1, num_steps=200, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_magnitude_sizer, 1, 0, 1, 7) self._lsb_on_check_box = forms.check_box( parent=self.GetWin(), value=self.lsb_on, callback=self.set_lsb_on, label="LSB", true=True, false=False, ) self.GridAdd(self._lsb_on_check_box, 4, 3, 1, 1) _i_offset_sizer = wx.BoxSizer(wx.VERTICAL) self._i_offset_text_box = forms.text_box( parent=self.GetWin(), sizer=_i_offset_sizer, value=self.i_offset, callback=self.set_i_offset, label="DC offset I", converter=forms.float_converter(), proportion=0, ) self._i_offset_slider = forms.slider( parent=self.GetWin(), sizer=_i_offset_sizer, value=self.i_offset, callback=self.set_i_offset, minimum=-0.1, maximum=0.1, num_steps=200, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_i_offset_sizer, 2, 0, 1, 7) self._cw_on_check_box = forms.check_box( parent=self.GetWin(), value=self.cw_on, callback=self.set_cw_on, label="CW", true=True, false=False, ) self.GridAdd(self._cw_on_check_box, 4, 5, 1, 1) self._am_on_check_box = forms.check_box( parent=self.GetWin(), value=self.am_on, callback=self.set_am_on, label="AM", true=True, false=False, ) self.GridAdd(self._am_on_check_box, 4, 2, 1, 1) self.root_raised_cosine_filter_1 = filter.fir_filter_ccf( 1, firdes.root_raised_cosine(1, audio_rate, 5, 0.35, 200)) self.root_raised_cosine_filter_0 = filter.fir_filter_ccf( 1, firdes.root_raised_cosine(1, audio_rate, 5, 0.35, 200)) self.rational_resampler_xxx_3 = filter.rational_resampler_ccc( interpolation=192, decimation=1, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_2 = filter.rational_resampler_ccc( interpolation=samp_rate, decimation=audio_rate, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_1 = filter.rational_resampler_ccc( interpolation=samp_rate / audio_rate / 2, decimation=1, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=samp_rate / audio_rate / 4, decimation=1, taps=None, fractional_bw=None, ) self.osmosdr_sink_0 = osmosdr.sink(args="numchan=" + str(1) + " " + "") self.osmosdr_sink_0.set_sample_rate(samp_rate) self.osmosdr_sink_0.set_center_freq(center_freq, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(gain, 0) self.osmosdr_sink_0.set_if_gain(20, 0) self.osmosdr_sink_0.set_bb_gain(20, 0) self.osmosdr_sink_0.set_antenna("", 0) self.osmosdr_sink_0.set_bandwidth(0, 0) self.low_pass_filter_1 = filter.interp_fir_filter_ccf( 1, firdes.low_pass(0.5, audio_rate, 5000, 400, firdes.WIN_HAMMING, 6.76)) self.iqbalance_fix_cc_0 = iqbalance.fix_cc(magnitude, phase) self.digital_psk_mod_0 = digital.psk.psk_mod( constellation_points=2, mod_code="none", differential=True, samples_per_symbol=8, excess_bw=0.35, verbose=False, log=False, ) self.digital_map_bb_0 = digital.map_bb(([1, 0])) self.blocks_wavfile_source_0 = blocks.wavfile_source( "/home/serdar/HackRF-Examples/NOT-tested/multi_tx.wav", True) self.blocks_vector_source_x_2 = blocks.vector_source_b( (0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1), True, 1, []) self.blocks_vector_source_x_0 = blocks.vector_source_c( (1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0), True, 1, []) self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb( 1, gr.GR_MSB_FIRST) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex * 1, int(1.2 * audio_rate / wpm)) self.blocks_multiply_xx_6 = blocks.multiply_vcc(1) self.blocks_multiply_xx_5 = blocks.multiply_vcc(1) self.blocks_multiply_xx_4 = blocks.multiply_vcc(1) self.blocks_multiply_xx_3_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_3 = blocks.multiply_vcc(1) self.blocks_multiply_xx_2 = blocks.multiply_vcc(1) self.blocks_multiply_xx_1 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_add_xx_1 = blocks.add_vcc(1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.blocks_add_const_vxx_1 = blocks.add_const_vcc( (i_offset + 1j * q_offset, )) self.blocks_add_const_vxx_0 = blocks.add_const_vcc((0.5, )) self.band_pass_filter_0_0 = filter.interp_fir_filter_ccc( 1, firdes.complex_band_pass(1, audio_rate, -2800, -200, 200, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0 = filter.interp_fir_filter_ccc( 1, firdes.complex_band_pass(1, audio_rate, 200, 2800, 200, firdes.WIN_HAMMING, 6.76)) self.analog_wfm_tx_0 = analog.wfm_tx( audio_rate=audio_rate, quad_rate=audio_rate * 4, tau=75e-6, max_dev=75e3, ) self.analog_sig_source_x_6 = analog.sig_source_c( audio_rate, analog.GR_COS_WAVE, 22000, 1 if psk_on else 0, 0) self.analog_sig_source_x_5 = analog.sig_source_c( audio_rate, analog.GR_COS_WAVE, 20000, 1 if cw_on else 0, 0) self.analog_sig_source_x_4 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, 120000, 1.0 / 7, 0) self.analog_sig_source_x_3_0 = analog.sig_source_c( audio_rate, analog.GR_COS_WAVE, 11000, 1.8 if lsb_on else 0, 0) self.analog_sig_source_x_3 = analog.sig_source_c( audio_rate, analog.GR_COS_WAVE, 14000, 1.8 if usb_on else 0, 0) self.analog_sig_source_x_2 = analog.sig_source_c( audio_rate, analog.GR_COS_WAVE, 0, 1 if am_on else 0, 0) self.analog_sig_source_x_1 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, 0, 1.0 / 7 if wbfm_on else 0, 0) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, -100000, 1.0 / 7 if nbfm_on else 0, 0) self.analog_nbfm_tx_0 = analog.nbfm_tx( audio_rate=audio_rate, quad_rate=audio_rate * 2, tau=75e-6, max_dev=5e3, ) self.analog_const_source_x_0 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, 0) ################################################## # Connections ################################################## self.connect((self.analog_const_source_x_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.analog_nbfm_tx_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.analog_sig_source_x_2, 0), (self.blocks_multiply_xx_2, 1)) self.connect((self.analog_sig_source_x_3, 0), (self.blocks_multiply_xx_3, 1)) self.connect((self.analog_sig_source_x_3_0, 0), (self.blocks_multiply_xx_3_0, 1)) self.connect((self.analog_sig_source_x_4, 0), (self.blocks_multiply_xx_4, 1)) self.connect((self.analog_sig_source_x_5, 0), (self.blocks_multiply_xx_5, 1)) self.connect((self.analog_sig_source_x_6, 0), (self.blocks_multiply_xx_6, 1)) self.connect((self.analog_wfm_tx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.blocks_multiply_xx_3, 0)) self.connect((self.band_pass_filter_0_0, 0), (self.blocks_multiply_xx_3_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_xx_2, 0)) self.connect((self.blocks_add_const_vxx_1, 0), (self.osmosdr_sink_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.iqbalance_fix_cc_0, 0)) self.connect((self.blocks_add_xx_1, 0), (self.rational_resampler_xxx_2, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.band_pass_filter_0_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_xx_2, 0), (self.blocks_add_xx_1, 0)) self.connect((self.blocks_multiply_xx_3, 0), (self.blocks_add_xx_1, 2)) self.connect((self.blocks_multiply_xx_3_0, 0), (self.blocks_add_xx_1, 1)) self.connect((self.blocks_multiply_xx_4, 0), (self.blocks_add_xx_0, 2)) self.connect((self.blocks_multiply_xx_5, 0), (self.blocks_add_xx_1, 3)) self.connect((self.blocks_multiply_xx_6, 0), (self.blocks_add_xx_1, 4)) self.connect((self.blocks_repeat_0, 0), (self.root_raised_cosine_filter_1, 0)) self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.digital_psk_mod_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.blocks_vector_source_x_2, 0), (self.digital_map_bb_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.analog_nbfm_tx_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.analog_wfm_tx_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.digital_map_bb_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0)) self.connect((self.digital_psk_mod_0, 0), (self.rational_resampler_xxx_3, 0)) self.connect((self.iqbalance_fix_cc_0, 0), (self.blocks_add_const_vxx_1, 0)) self.connect((self.low_pass_filter_1, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.rational_resampler_xxx_2, 0), (self.blocks_multiply_xx_4, 0)) self.connect((self.rational_resampler_xxx_3, 0), (self.blocks_multiply_xx_6, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.blocks_multiply_xx_5, 0)) self.connect((self.root_raised_cosine_filter_1, 0), (self.root_raised_cosine_filter_0, 0))
def __init__(self): gr.top_block.__init__(self, "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.channel_freq = channel_freq = 915003300 self.samp_rate = samp_rate = 250000 self.fftsize = fftsize = 512 self.channel_width = channel_width = 20000 self.center_freq = center_freq = channel_freq - 50000 ################################################## # Blocks ################################################## self._channel_width_range = Range(500, 50000, 100, 20000, 200) self._channel_width_win = RangeWidget(self._channel_width_range, self.set_channel_width, "channel_width", "counter_slider", float) self.top_layout.addWidget(self._channel_width_win) self._channel_freq_range = Range(914e6, 916e6, 1000, 915003300, 200) self._channel_freq_win = RangeWidget(self._channel_freq_range, self.set_channel_freq, "channel_freq", "counter_slider", float) self.top_layout.addWidget(self._channel_freq_win) self.zeromq_push_sink_0_0 = zeromq.push_sink(gr.sizeof_float, 1, 'tcp://127.0.0.1:5558', 100, False, -1) 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(30, 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.qtgui_waterfall_sink_x_0_1 = qtgui.waterfall_sink_c( fftsize, #size firdes.WIN_BLACKMAN_hARRIS, #wintype center_freq, #fc samp_rate, #bw "Post-filter", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0_1.set_update_time(0.10) self.qtgui_waterfall_sink_x_0_1.enable_grid(False) self.qtgui_waterfall_sink_x_0_1.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0_1.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0_1.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_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0_1.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0_1.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0_1.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0_1.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_x_0_1_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_waterfall_sink_x_0_1_win) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( fftsize, #size firdes.WIN_BLACKMAN_hARRIS, #wintype center_freq, #fc samp_rate, #bw "Raw samples", #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_layout.addWidget(self._qtgui_waterfall_sink_x_0_win) self.qtgui_time_sink_x_0_1_0 = qtgui.time_sink_f( fftsize, #size samp_rate, #samp_rate "Magnitude", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_1_0.set_update_time(0.10) self.qtgui_time_sink_x_0_1_0.set_y_axis(0, 0.4) self.qtgui_time_sink_x_0_1_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_1_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_1_0.set_trigger_mode(qtgui.TRIG_MODE_AUTO, qtgui.TRIG_SLOPE_POS, 0.018, 0, 0, "") self.qtgui_time_sink_x_0_1_0.enable_autoscale(False) self.qtgui_time_sink_x_0_1_0.enable_grid(False) self.qtgui_time_sink_x_0_1_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_1_0.enable_control_panel(True) self.qtgui_time_sink_x_0_1_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_1_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_1_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_1_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_1_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_1_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_1_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_1_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_1_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_1_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_1_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_1_0_win) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.band_pass_filter_0 = filter.fir_filter_ccc(1, firdes.complex_band_pass( 1, samp_rate, channel_freq - center_freq - channel_width/2, channel_freq - center_freq + channel_width/2, 1000, firdes.WIN_HAMMING, 6.76)) ################################################## # Connections ################################################## self.connect((self.band_pass_filter_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.qtgui_waterfall_sink_x_0_1, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.qtgui_time_sink_x_0_1_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.zeromq_push_sink_0_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
def set_gain_coeff(self, gain_coeff): self.gain_coeff = gain_coeff self.band_pass_filter_0.set_taps(firdes.complex_band_pass(self.gain_coeff, self.samp_rate, self.Low_CO, self.High_CO, self.High_CO-self.Low_CO, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0.set_taps(firdes.low_pass(1, self.samp_rate*self.gain_coeff/self.decimation_coeff, 5000, 3500, firdes.WIN_HAMMING, 6.76)) self.wxgui_fftsink2_0.set_sample_rate(self.samp_rate*self.gain_coeff/self.decimation_coeff) self.wxgui_scopesink2_0_0_0_0.set_sample_rate(self.samp_rate*self.gain_coeff/self.decimation_coeff)
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.raw_samp_rate = raw_samp_rate = 2e6 self.decimation = decimation = 8 self.sym_rate = sym_rate = 2400 self.samp_rate = samp_rate = raw_samp_rate/decimation self.half_dev = half_dev = 40e3 self.freq_offset = freq_offset = 500 self.bin_width = bin_width = 10e3 ################################################## # 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(raw_samp_rate) self.uhd_usrp_source_0.set_center_freq(uhd.tune_request(450E6, 8E6), 0) self.uhd_usrp_source_0.set_gain(30, 0) self.low_pass_filter_1 = filter.fir_filter_fff(1, firdes.low_pass( 1, samp_rate, 10e3, 300, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf(decimation, firdes.low_pass( 2, raw_samp_rate, 250e3, 50e3, 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_file_sink_0 = blocks.file_sink(gr.sizeof_float*1, "samples", False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_complex_to_mag_squared_1 = blocks.complex_to_mag_squared(1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blks2_valve_0 = grc_blks2.valve(item_size=gr.sizeof_gr_complex*1, open=bool(False)) self.band_pass_filter_0_0 = filter.fir_filter_ccc(1, firdes.complex_band_pass( 1, samp_rate, -half_dev-bin_width/2+freq_offset, -half_dev+bin_width/2+freq_offset, 500, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0 = filter.fir_filter_ccc(1, firdes.complex_band_pass( 1, samp_rate, +half_dev-bin_width/2+freq_offset, +half_dev+bin_width/2+freq_offset, 500, firdes.WIN_HAMMING, 6.76)) ################################################## # Connections ################################################## self.connect((self.low_pass_filter_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.band_pass_filter_0_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.band_pass_filter_0_0, 0), (self.blocks_complex_to_mag_squared_1, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.blocks_complex_to_mag_squared_1, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.blocks_sub_xx_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blks2_valve_0, 0)) self.connect((self.blks2_valve_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.blocks_file_sink_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.blocks_null_sink_0, 0))
def set_high_frequency_cutoff(self, high_frequency_cutoff): self.high_frequency_cutoff = high_frequency_cutoff self.band_pass_filter_usb.set_taps(firdes.complex_band_pass(1, self.audio_rate, self.low_frequency_cutoff, self.high_frequency_cutoff, 200, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_lsb.set_taps(firdes.complex_band_pass(1, self.audio_rate, -self.high_frequency_cutoff, -self.low_frequency_cutoff, 200, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_am.set_taps(firdes.band_pass(1, self.audio_rate, self.low_frequency_cutoff, self.high_frequency_cutoff, 400, firdes.WIN_HAMMING, 6.76))
def set_int_rate(self, int_rate): self.int_rate = int_rate self.wxgui_waterfallsink2_1.set_sample_rate(self.int_rate) self.band_pass_filter_0.set_taps(firdes.complex_band_pass(1, self.int_rate, 200, 2800, 200, firdes.WIN_HAMMING, 6.76))
def set_channel_width(self, channel_width): self.channel_width = channel_width self.band_pass_filter_0.set_taps(firdes.complex_band_pass(1, self.samp_rate, self.channel_freq - self.center_freq - self.channel_width/2, self.channel_freq - self.center_freq + self.channel_width/2, 1000, firdes.WIN_HAMMING, 6.76))
def connect_audio_stage(self): demod_rate = self.demod_rate stereo_rate = self.post_demod_rate audio_rate = self.audio_rate normalizer = 2 * math.pi / stereo_rate pilot_tone = 19000 pilot_low = pilot_tone * 0.9 pilot_high = pilot_tone * 1.1 def make_audio_filter(): return grfilter.fir_filter_fff( 1, # decimation firdes.low_pass( 1.0, stereo_rate, 15000, 5000, firdes.WIN_HAMMING)) stereo_pilot_filter = grfilter.fir_filter_fcc( 1, # decimation firdes.complex_band_pass( 1.0, stereo_rate, pilot_low, pilot_high, 300)) # TODO magic number from gqrx stereo_pilot_pll = analog.pll_refout_cc( 0.001, # TODO magic number from gqrx normalizer * pilot_high, normalizer * pilot_low) stereo_pilot_doubler = blocks.multiply_cc() stereo_pilot_out = blocks.complex_to_imag() difference_channel_mixer = blocks.multiply_ff() difference_channel_filter = make_audio_filter() difference_real = blocks.complex_to_real(1) mono_channel_filter = make_audio_filter() resamplerL = self._make_resampler() resamplerR = self._make_resampler() mixL = blocks.add_ff(1) mixR = blocks.sub_ff(1) # connections if self.audio_filter: self.connect(self.demod_block, mono_channel_filter) mono = mono_channel_filter else: mono = self.demod_block if self.stereo: # stereo pilot tone tracker self.connect( self.demod_block, stereo_pilot_filter, stereo_pilot_pll) self.connect(stereo_pilot_pll, (stereo_pilot_doubler, 0)) self.connect(stereo_pilot_pll, (stereo_pilot_doubler, 1)) self.connect(stereo_pilot_doubler, stereo_pilot_out) # pick out stereo left-right difference channel self.connect(self.demod_block, (difference_channel_mixer, 0)) self.connect(stereo_pilot_out, (difference_channel_mixer, 1)) self.connect(difference_channel_mixer, difference_channel_filter) # recover left/right channels self.connect(difference_channel_filter, (mixL, 1)) self.connect(difference_channel_filter, (mixR, 1)) self.connect(mono, (mixL, 0), resamplerL) self.connect(mono, (mixR, 0), resamplerR) self.connect_audio_output(resamplerL, resamplerR) else: self.connect(mono, resamplerL) self.connect_audio_output(resamplerL, resamplerL)
def set_decimation(self, decimation): self.decimation = decimation self.wxgui_waterfallsink2_0.set_sample_rate(self.samp_rate / self.decimation) self.band_pass_filter_0.set_taps(firdes.complex_band_pass(1, self.samp_rate / self.decimation, 200, 2800, 200, firdes.WIN_HAMMING, 6.76)) self.analog_sig_source_x_1.set_sampling_freq(self.samp_rate / self.decimation)
def set_smux_filt_samprate(self, smux_filt_samprate): self.smux_filt_samprate = smux_filt_samprate self.band_pass_filter_0.set_taps(firdes.band_pass(1, self.smux_filt_samprate, self.bpf_base, self.bpf_base+30e3, 500, firdes.WIN_KAISER, 6.76)) self.band_pass_filter_0_0_0.set_taps(firdes.complex_band_pass(1, self.smux_filt_samprate, 18000, 20000, 1000, firdes.WIN_KAISER, 1)) self.baseband_LPF.set_taps(firdes.low_pass(1, self.smux_filt_samprate, 15e3, 500, firdes.WIN_KAISER, 6.76)) self.low_pass_filter_1_0.set_taps(firdes.low_pass(1, self.smux_filt_samprate, 15e3, 500, firdes.WIN_HAMMING, 1))
def __init__(self): gr.top_block.__init__(self, "Lang Rx") ################################################## # Variables ################################################## self.SQL = SQL = 50 self.RxOffset = RxOffset = 0 self.Mute = Mute = False self.Mode = Mode = 3 self.Filt_Low = Filt_Low = 300 self.Filt_High = Filt_High = 3000 self.FFTEn = FFTEn = 0 self.AFGain = AFGain = 20 ################################################## # Blocks ################################################## self.pluto_source_0 = iio.pluto_source('ip:pluto.local', 1000000000, 528000, 2000000, 0x800, True, True, True, "slow_attack", 64.0, '', True) self.logpwrfft_x_0 = logpwrfft.logpwrfft_c( sample_rate=48000, fft_size=512, ref_scale=2, frame_rate=15, avg_alpha=0.9, average=True, ) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( 11, (firdes.low_pass(1, 529200, 23000, 2000)), RxOffset, 528000) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float * 512) self.blocks_multiply_const_vxx_2_1 = blocks.multiply_const_vff( (Mode == 5, )) self.blocks_multiply_const_vxx_2_0 = blocks.multiply_const_vff( (Mode == 4, )) self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vff( (Mode < 4, )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff( ((AFGain / 100.0) * (not Mute), )) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_float * 512, '/tmp/langstonefft', 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_complex_to_mag_0 = blocks.complex_to_mag(1) self.blocks_add_xx_1_0 = blocks.add_vff(1) self.blocks_add_xx_1 = blocks.add_vff(1) self.blks2_selector_0 = grc_blks2.selector( item_size=gr.sizeof_float * 512, num_inputs=1, num_outputs=2, input_index=0, output_index=FFTEn, ) self.band_pass_filter_0 = filter.fir_filter_ccc( 1, firdes.complex_band_pass(1, 48000, Filt_Low, Filt_High, 100, firdes.WIN_HAMMING, 6.76)) self.audio_sink_0 = audio.sink(48000, "hw:CARD=Device,DEV=0", False) self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc( SQL - 100, 0.001, 0, False) self.analog_nbfm_rx_0 = analog.nbfm_rx( audio_rate=48000, quad_rate=48000, tau=75e-6, max_dev=5e3, ) self.analog_agc3_xx_0 = analog.agc3_cc(1e-2, 5e-7, 0.1, 1.0, 1) self.analog_agc3_xx_0.set_max_gain(1000) ################################################## # Connections ################################################## self.connect((self.analog_agc3_xx_0, 0), (self.blocks_complex_to_real_0_0, 0)) self.connect((self.analog_nbfm_rx_0, 0), (self.blocks_multiply_const_vxx_2_0, 0)) self.connect((self.analog_pwr_squelch_xx_0, 0), (self.analog_nbfm_rx_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.analog_pwr_squelch_xx_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.blocks_complex_to_real_0, 0)) 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.blocks_add_xx_1, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_add_xx_1_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_multiply_const_vxx_2_1, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_multiply_const_vxx_2, 0)) self.connect((self.blocks_complex_to_real_0_0, 0), (self.blocks_add_xx_1, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.analog_agc3_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_2, 0), (self.blocks_add_xx_1_0, 0)) self.connect((self.blocks_multiply_const_vxx_2_0, 0), (self.blocks_add_xx_1, 1)) self.connect((self.blocks_multiply_const_vxx_2_1, 0), (self.blocks_add_xx_1_0, 1)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.logpwrfft_x_0, 0)) self.connect((self.logpwrfft_x_0, 0), (self.blks2_selector_0, 0)) self.connect((self.pluto_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
def __init__(self): gr.top_block.__init__(self, "RTTY_xmt", catch_exceptions=True) Qt.QWidget.__init__(self) self.setWindowTitle("RTTY_xmt") 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", "RTTY_xmt") 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.vco_max = vco_max = 2500 self.fsk_deviation = fsk_deviation = 170 self.center = center = 2210 self.vco_offset = vco_offset = (center - (fsk_deviation / 2)) / vco_max self.usrp_rate = usrp_rate = 1000000 self.samp_rate = samp_rate = 50000 self.rf_gain = rf_gain = 9 self.rf_decim = rf_decim = 100 self.repeat = repeat = (int)(samp_rate * 0.022) self.inp_amp = inp_amp = ((center + (fsk_deviation / 2)) / vco_max) - vco_offset self.channel_filter = channel_filter = firdes.complex_band_pass( 1.0, usrp_rate, -3000, 3000, 2000, firdes.WIN_HAMMING, 6.76) self.center_freq = center_freq = 144.95e6 self.baud = baud = 1 / 0.022 ################################################## # Blocks ################################################## self._rf_gain_range = Range(0, 76, 1, 9, 200) self._rf_gain_win = RangeWidget(self._rf_gain_range, self.set_rf_gain, 'RF Gain', "counter_slider", int, QtCore.Qt.Horizontal) self.top_grid_layout.addWidget(self._rf_gain_win) self._center_freq_range = Range(144.0e6, 148.0e6, 1.0e3, 144.95e6, 200) self._center_freq_win = RangeWidget(self._center_freq_range, self.set_center_freq, 'Tuning', "counter_slider", float, QtCore.Qt.Horizontal) self.top_grid_layout.addWidget(self._center_freq_win) self.zeromq_pull_msg_source_0 = zeromq.pull_msg_source( 'tcp://127.0.0.1:50251', 100, False) 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_samp_rate(usrp_rate) self.uhd_usrp_sink_0.set_time_unknown_pps(uhd.time_spec(0)) self.uhd_usrp_sink_0.set_center_freq(center_freq, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self.uhd_usrp_sink_0.set_bandwidth(200000, 0) self.uhd_usrp_sink_0.set_gain(rf_gain, 0) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 4096, #size samp_rate, #samp_rate "", #name 1, #number of inputs None # parent ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1.5) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_NORM, qtgui.TRIG_SLOPE_NEG, 0.5, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(True) self.qtgui_time_sink_x_0.enable_stem_plot(False) labels = [ 'Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10' ] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ 'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue' ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win) self.low_pass_filter_0 = filter.fir_filter_fff( 1, firdes.low_pass(1, samp_rate, 200, 1000, firdes.WIN_HAMMING, 6.76)) self.fft_filter_xxx_0 = filter.fft_filter_ccc(1, channel_filter, 1) self.fft_filter_xxx_0.declare_sample_delay(0) self.epy_block_0_0 = epy_block_0_0.mc_sync_block() self.blocks_vco_c_0 = blocks.vco_c(samp_rate, 15708, 0.75) self.blocks_uchar_to_float_0 = blocks.uchar_to_float() self.blocks_repeat_0_0 = blocks.repeat(gr.sizeof_gr_complex * 1, (int)(usrp_rate / samp_rate)) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_char * 1, repeat) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(inp_amp) self.blocks_add_const_vxx_0 = blocks.add_const_ff(vco_offset) ################################################## # Connections ################################################## self.msg_connect((self.zeromq_pull_msg_source_0, 'out'), (self.epy_block_0_0, 'msg_in')) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_vco_c_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_uchar_to_float_0, 0)) self.connect((self.blocks_repeat_0_0, 0), (self.fft_filter_xxx_0, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_vco_c_0, 0), (self.blocks_repeat_0_0, 0)) self.connect((self.epy_block_0_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.qtgui_time_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "Multitransmit for RpiTX") Qt.QWidget.__init__(self) self.setWindowTitle("Multitransmit for RpiTX") 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", "gr_multitransmit_rpitx") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.wfm_on = wfm_on = False self.usb_on = usb_on = False self.test_tone_frequency = test_tone_frequency = 1000 self.rpitx_frequency_correction = rpitx_frequency_correction = 0 self.ptt_lock = ptt_lock = False self.ptt = ptt = False self.nfm_on = nfm_on = False self.lsb_on = lsb_on = False self.low_frequency_cutoff = low_frequency_cutoff = 200 self.high_frequency_cutoff = high_frequency_cutoff = 2500 self.enable_tone = enable_tone = False self.enable_test_tone = enable_test_tone = False self.ctcss_tone = ctcss_tone = 100 self.audio_rate = audio_rate = 48000 self.am_on = am_on = False ################################################## # Blocks ################################################## _wfm_on_check_box = Qt.QCheckBox('WFM') self._wfm_on_choices = {True: True, False: False} self._wfm_on_choices_inv = dict((v,k) for k,v in self._wfm_on_choices.iteritems()) self._wfm_on_callback = lambda i: Qt.QMetaObject.invokeMethod(_wfm_on_check_box, "setChecked", Qt.Q_ARG("bool", self._wfm_on_choices_inv[i])) self._wfm_on_callback(self.wfm_on) _wfm_on_check_box.stateChanged.connect(lambda i: self.set_wfm_on(self._wfm_on_choices[bool(i)])) self.top_grid_layout.addWidget(_wfm_on_check_box, 4,0) _usb_on_check_box = Qt.QCheckBox('USB') self._usb_on_choices = {True: True, False: False} self._usb_on_choices_inv = dict((v,k) for k,v in self._usb_on_choices.iteritems()) self._usb_on_callback = lambda i: Qt.QMetaObject.invokeMethod(_usb_on_check_box, "setChecked", Qt.Q_ARG("bool", self._usb_on_choices_inv[i])) self._usb_on_callback(self.usb_on) _usb_on_check_box.stateChanged.connect(lambda i: self.set_usb_on(self._usb_on_choices[bool(i)])) self.top_grid_layout.addWidget(_usb_on_check_box, 5,0) self._test_tone_frequency_range = Range(0, audio_rate, 1, 1000, 200) self._test_tone_frequency_win = RangeWidget(self._test_tone_frequency_range, self.set_test_tone_frequency, 'Tone Frequency', "counter", float) self.top_grid_layout.addWidget(self._test_tone_frequency_win, 11,1) self._rpitx_frequency_correction_range = Range(-24, 24, .1, 0, 200) self._rpitx_frequency_correction_win = RangeWidget(self._rpitx_frequency_correction_range, self.set_rpitx_frequency_correction, 'RpiTX Frequency Correction', "counter_slider", float) self.top_grid_layout.addWidget(self._rpitx_frequency_correction_win, 13,0) _ptt_lock_check_box = Qt.QCheckBox('PTT Lock') self._ptt_lock_choices = {True: True, False: False} self._ptt_lock_choices_inv = dict((v,k) for k,v in self._ptt_lock_choices.iteritems()) self._ptt_lock_callback = lambda i: Qt.QMetaObject.invokeMethod(_ptt_lock_check_box, "setChecked", Qt.Q_ARG("bool", self._ptt_lock_choices_inv[i])) self._ptt_lock_callback(self.ptt_lock) _ptt_lock_check_box.stateChanged.connect(lambda i: self.set_ptt_lock(self._ptt_lock_choices[bool(i)])) self.top_grid_layout.addWidget(_ptt_lock_check_box, 0,1) _ptt_push_button = Qt.QPushButton('Push To Talk') self._ptt_choices = {'Pressed': True, 'Released': False} _ptt_push_button.pressed.connect(lambda: self.set_ptt(self._ptt_choices['Pressed'])) _ptt_push_button.released.connect(lambda: self.set_ptt(self._ptt_choices['Released'])) self.top_grid_layout.addWidget(_ptt_push_button, 0,0) _nfm_on_check_box = Qt.QCheckBox('NFM') self._nfm_on_choices = {True: True, False: False} self._nfm_on_choices_inv = dict((v,k) for k,v in self._nfm_on_choices.iteritems()) self._nfm_on_callback = lambda i: Qt.QMetaObject.invokeMethod(_nfm_on_check_box, "setChecked", Qt.Q_ARG("bool", self._nfm_on_choices_inv[i])) self._nfm_on_callback(self.nfm_on) _nfm_on_check_box.stateChanged.connect(lambda i: self.set_nfm_on(self._nfm_on_choices[bool(i)])) self.top_grid_layout.addWidget(_nfm_on_check_box, 3,0) _lsb_on_check_box = Qt.QCheckBox('LSB') self._lsb_on_choices = {True: True, False: False} self._lsb_on_choices_inv = dict((v,k) for k,v in self._lsb_on_choices.iteritems()) self._lsb_on_callback = lambda i: Qt.QMetaObject.invokeMethod(_lsb_on_check_box, "setChecked", Qt.Q_ARG("bool", self._lsb_on_choices_inv[i])) self._lsb_on_callback(self.lsb_on) _lsb_on_check_box.stateChanged.connect(lambda i: self.set_lsb_on(self._lsb_on_choices[bool(i)])) self.top_grid_layout.addWidget(_lsb_on_check_box, 6,0) self._low_frequency_cutoff_range = Range(1, audio_rate/2, 1, 200, 100) self._low_frequency_cutoff_win = RangeWidget(self._low_frequency_cutoff_range, self.set_low_frequency_cutoff, 'Low Frequency Cutoff', "counter_slider", float) self.top_grid_layout.addWidget(self._low_frequency_cutoff_win, 7,0) self._high_frequency_cutoff_range = Range(1, audio_rate/2, 1, 2500, 100) self._high_frequency_cutoff_win = RangeWidget(self._high_frequency_cutoff_range, self.set_high_frequency_cutoff, 'High Frequency Cutoff', "counter_slider", float) self.top_grid_layout.addWidget(self._high_frequency_cutoff_win, 7,1) _enable_tone_check_box = Qt.QCheckBox('CTCSS Tone Enable') self._enable_tone_choices = {True: True, False: False} self._enable_tone_choices_inv = dict((v,k) for k,v in self._enable_tone_choices.iteritems()) self._enable_tone_callback = lambda i: Qt.QMetaObject.invokeMethod(_enable_tone_check_box, "setChecked", Qt.Q_ARG("bool", self._enable_tone_choices_inv[i])) self._enable_tone_callback(self.enable_tone) _enable_tone_check_box.stateChanged.connect(lambda i: self.set_enable_tone(self._enable_tone_choices[bool(i)])) self.top_grid_layout.addWidget(_enable_tone_check_box, 10,0) _enable_test_tone_check_box = Qt.QCheckBox('Test Tone') self._enable_test_tone_choices = {True: True, False: False} self._enable_test_tone_choices_inv = dict((v,k) for k,v in self._enable_test_tone_choices.iteritems()) self._enable_test_tone_callback = lambda i: Qt.QMetaObject.invokeMethod(_enable_test_tone_check_box, "setChecked", Qt.Q_ARG("bool", self._enable_test_tone_choices_inv[i])) self._enable_test_tone_callback(self.enable_test_tone) _enable_test_tone_check_box.stateChanged.connect(lambda i: self.set_enable_test_tone(self._enable_test_tone_choices[bool(i)])) self.top_grid_layout.addWidget(_enable_test_tone_check_box, 11,0) self._ctcss_tone_range = Range(67, 254.1, .1, 100, 200) self._ctcss_tone_win = RangeWidget(self._ctcss_tone_range, self.set_ctcss_tone, 'CTCSS Tone', "counter", float) self.top_grid_layout.addWidget(self._ctcss_tone_win, 10,1) _am_on_check_box = Qt.QCheckBox('AM') self._am_on_choices = {True: True, False: False} self._am_on_choices_inv = dict((v,k) for k,v in self._am_on_choices.iteritems()) self._am_on_callback = lambda i: Qt.QMetaObject.invokeMethod(_am_on_check_box, "setChecked", Qt.Q_ARG("bool", self._am_on_choices_inv[i])) self._am_on_callback(self.am_on) _am_on_check_box.stateChanged.connect(lambda i: self.set_am_on(self._am_on_choices[bool(i)])) self.top_grid_layout.addWidget(_am_on_check_box, 2,0) self.rational_resampler_wfm = filter.rational_resampler_ccc( interpolation=audio_rate, decimation=audio_rate*4, taps=None, fractional_bw=None, ) self.rational_resampler_nbfm = filter.rational_resampler_ccc( interpolation=audio_rate, decimation=audio_rate*2, taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_rpitx = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc audio_rate, #bw "rpitx signal (I/Q)", #name 1 #number of inputs ) self.qtgui_waterfall_sink_rpitx.set_update_time(0.01) self.qtgui_waterfall_sink_rpitx.enable_grid(False) self.qtgui_waterfall_sink_rpitx.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_rpitx.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_rpitx.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_rpitx.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_rpitx.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_rpitx.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_rpitx.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_rpitx.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_rpitx_win = sip.wrapinstance(self.qtgui_waterfall_sink_rpitx.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_rpitx_win, 1,1) self.qtgui_sink_transmit = qtgui.sink_c( 1024, #fftsize firdes.WIN_HAMMING, #wintype 0, #fc audio_rate, #bw "Transmitted Signal (I/Q)", #name True, #plotfreq True, #plotwaterfall True, #plottime True, #plotconst ) self.qtgui_sink_transmit.set_update_time(1.0/100) self._qtgui_sink_transmit_win = sip.wrapinstance(self.qtgui_sink_transmit.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_sink_transmit_win, 1,0) self.qtgui_sink_transmit.enable_rf_freq(False) self.low_pass_filter_nbfm = filter.fir_filter_fff(1, firdes.low_pass( 1, audio_rate, 4e3, 500, firdes.WIN_HAMMING, 6.76)) self.freq_xlating_fir_filter_rpitx = filter.freq_xlating_fir_filter_ccc(1, ([1]), -rpitx_frequency_correction*1000, 48000) self.blocks_multiply_usb = blocks.multiply_vcc(1) self.blocks_multiply_lsb = blocks.multiply_vcc(1) self.blocks_multiply_const_wfm = blocks.multiply_const_vcc((wfm_on, )) self.blocks_multiply_const_test = blocks.multiply_const_vff((enable_test_tone, )) self.blocks_multiply_const_rpitx = blocks.multiply_const_vcc((ptt or ptt_lock, )) self.blocks_multiply_const_nbfm = blocks.multiply_const_vcc((nfm_on, )) self.blocks_multiply_const_ctcss = blocks.multiply_const_vff((enable_tone, )) self.blocks_multiply_am = blocks.multiply_vcc(1) self.blocks_float_to_complex_am_ssb = blocks.float_to_complex(1) self.blocks_add_nbfm = blocks.add_vff(1) self.blocks_add_fm = blocks.add_vcc(1) self.blocks_add_const_am = blocks.add_const_vcc((.5, )) self.blocks_add_am_ssb_fm = blocks.add_vcc(1) self.blocks_add_am_ssb = blocks.add_vcc(1) self.blocks_add = blocks.add_vff(1) self.blks_tcp_sink_rpitx = grc_blks2.tcp_sink( itemsize=gr.sizeof_gr_complex*1, addr='192.168.0.x', port=8011, server=False, ) self.band_pass_filter_usb = filter.interp_fir_filter_ccc(1, firdes.complex_band_pass( 1, audio_rate, low_frequency_cutoff, high_frequency_cutoff, 200, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_lsb = filter.interp_fir_filter_ccc(1, firdes.complex_band_pass( 1, audio_rate, -high_frequency_cutoff, -low_frequency_cutoff, 200, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_am = filter.fir_filter_ccf(1, firdes.band_pass( 1, audio_rate, low_frequency_cutoff, high_frequency_cutoff, 400, firdes.WIN_HAMMING, 6.76)) self.audio_source = audio.source(48000, '', True) self.analog_wfm_tx = analog.wfm_tx( audio_rate=audio_rate, quad_rate=audio_rate * 4, tau=75e-6, max_dev=75e3, fh=-1.0, ) self.analog_sig_source_usb = analog.sig_source_c(audio_rate, analog.GR_COS_WAVE, 0, 1.8 if usb_on else 0, 0) self.analog_sig_source_test = analog.sig_source_f(audio_rate, analog.GR_SIN_WAVE, test_tone_frequency, .3, 0) self.analog_sig_source_lsb = analog.sig_source_c(audio_rate, analog.GR_COS_WAVE, 0, 1.8 if lsb_on else 0, 0) self.analog_sig_source_ctcss = analog.sig_source_f(audio_rate, analog.GR_COS_WAVE, ctcss_tone, 0.1, 0) self.analog_sig_source_am = analog.sig_source_c(audio_rate, analog.GR_COS_WAVE, 0, 1 if am_on else 0, 0) self.analog_nbfm_tx = analog.nbfm_tx( audio_rate=audio_rate, quad_rate=audio_rate*2, tau=75e-6, max_dev=5e3, fh=-1.0, ) self.analog_const_source = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0) ################################################## # Connections ################################################## self.connect((self.analog_const_source, 0), (self.blocks_float_to_complex_am_ssb, 1)) self.connect((self.analog_nbfm_tx, 0), (self.blocks_multiply_const_nbfm, 0)) self.connect((self.analog_sig_source_am, 0), (self.blocks_multiply_am, 1)) self.connect((self.analog_sig_source_ctcss, 0), (self.blocks_multiply_const_ctcss, 0)) self.connect((self.analog_sig_source_lsb, 0), (self.blocks_multiply_lsb, 1)) self.connect((self.analog_sig_source_test, 0), (self.blocks_multiply_const_test, 0)) self.connect((self.analog_sig_source_usb, 0), (self.blocks_multiply_usb, 1)) self.connect((self.analog_wfm_tx, 0), (self.blocks_multiply_const_wfm, 0)) self.connect((self.audio_source, 0), (self.blocks_add, 0)) self.connect((self.band_pass_filter_am, 0), (self.blocks_add_const_am, 0)) self.connect((self.band_pass_filter_lsb, 0), (self.blocks_multiply_lsb, 0)) self.connect((self.band_pass_filter_usb, 0), (self.blocks_multiply_usb, 0)) self.connect((self.blocks_add, 0), (self.analog_wfm_tx, 0)) self.connect((self.blocks_add, 0), (self.blocks_add_nbfm, 1)) self.connect((self.blocks_add, 0), (self.blocks_float_to_complex_am_ssb, 0)) self.connect((self.blocks_add_am_ssb, 0), (self.blocks_add_am_ssb_fm, 1)) self.connect((self.blocks_add_am_ssb_fm, 0), (self.blocks_multiply_const_rpitx, 0)) self.connect((self.blocks_add_const_am, 0), (self.blocks_multiply_am, 0)) self.connect((self.blocks_add_fm, 0), (self.blocks_add_am_ssb_fm, 0)) self.connect((self.blocks_add_nbfm, 0), (self.low_pass_filter_nbfm, 0)) self.connect((self.blocks_float_to_complex_am_ssb, 0), (self.band_pass_filter_am, 0)) self.connect((self.blocks_float_to_complex_am_ssb, 0), (self.band_pass_filter_lsb, 0)) self.connect((self.blocks_float_to_complex_am_ssb, 0), (self.band_pass_filter_usb, 0)) self.connect((self.blocks_multiply_am, 0), (self.blocks_add_am_ssb, 0)) self.connect((self.blocks_multiply_const_ctcss, 0), (self.blocks_add_nbfm, 0)) self.connect((self.blocks_multiply_const_nbfm, 0), (self.rational_resampler_nbfm, 0)) self.connect((self.blocks_multiply_const_rpitx, 0), (self.freq_xlating_fir_filter_rpitx, 0)) self.connect((self.blocks_multiply_const_rpitx, 0), (self.qtgui_sink_transmit, 0)) self.connect((self.blocks_multiply_const_test, 0), (self.blocks_add, 1)) self.connect((self.blocks_multiply_const_wfm, 0), (self.rational_resampler_wfm, 0)) self.connect((self.blocks_multiply_lsb, 0), (self.blocks_add_am_ssb, 1)) self.connect((self.blocks_multiply_usb, 0), (self.blocks_add_am_ssb, 2)) self.connect((self.freq_xlating_fir_filter_rpitx, 0), (self.blks_tcp_sink_rpitx, 0)) self.connect((self.freq_xlating_fir_filter_rpitx, 0), (self.qtgui_waterfall_sink_rpitx, 0)) self.connect((self.low_pass_filter_nbfm, 0), (self.analog_nbfm_tx, 0)) self.connect((self.rational_resampler_nbfm, 0), (self.blocks_add_fm, 0)) self.connect((self.rational_resampler_wfm, 0), (self.blocks_add_fm, 1))
def __init__(self, demod_rate, audio_decimation, deemph_tau): """ Hierarchical block for demodulating a broadcast FM signal. The input is the downconverted complex baseband signal (gr_complex). The output is two streams of the demodulated audio (float) 0=Left, 1=Right. Args: demod_rate: input sample rate of complex baseband input. (float) audio_decimation: how much to decimate demod_rate to get to audio. (integer) deemph_tau: deemphasis ime constant in seconds (75us in US, 50us in EUR). (float) """ gr.hier_block2.__init__( self, "wfm_rcv_pll", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(2, 2, gr.sizeof_float)) # Output signature if audio_decimation != int(audio_decimation): raise ValueError("audio_decimation needs to be an integer") audio_decimation = int(audio_decimation) ################################################## # Variables ################################################## self.demod_rate = demod_rate self.deemph_tau = deemph_tau self.stereo_carrier_filter_coeffs_0 = stereo_carrier_filter_coeffs_0 = firdes.band_pass( -2.0, demod_rate, 37600, 38400, 400, fft.window.WIN_HAMMING, 6.76) self.stereo_carrier_filter_coeffs = stereo_carrier_filter_coeffs = firdes.complex_band_pass( 1.0, demod_rate, 18980, 19020, 1500, fft.window.WIN_HAMMING, 6.76) self.deviation = deviation = 75000 self.audio_filter = audio_filter = firdes.low_pass( 1, demod_rate, 15000, 1500, fft.window.WIN_HAMMING, 6.76) self.audio_decim = audio_decim = audio_decimation self.audio_rate = audio_rate = demod_rate / audio_decim self.samp_delay = samp_delay = ( len(stereo_carrier_filter_coeffs) - 1) // 2 + (len(stereo_carrier_filter_coeffs_0) - 1) // 2 ################################################## # Blocks ################################################## self.fir_filter_xxx_1 = filter.fir_filter_fcc( 1, stereo_carrier_filter_coeffs) self.fir_filter_xxx_1.declare_sample_delay(0) self.fft_filter_xxx_3 = filter.fft_filter_fff( 1, stereo_carrier_filter_coeffs_0, 1) self.fft_filter_xxx_3.declare_sample_delay(0) self.fft_filter_xxx_2 = filter.fft_filter_fff(audio_decim, audio_filter, 1) self.fft_filter_xxx_2.declare_sample_delay(0) self.fft_filter_xxx_1 = filter.fft_filter_fff(audio_decim, audio_filter, 1) self.fft_filter_xxx_1.declare_sample_delay(0) self.blocks_multiply_xx_2 = blocks.multiply_vff(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf( demod_rate / (2 * math.pi * deviation)) self.analog_pll_refout_cc_0 = analog.pll_refout_cc( 0.001, 2 * math.pi * 19200 / demod_rate, 2 * math.pi * 18800 / demod_rate) self.analog_fm_deemph_0_0 = analog.fm_deemph(fs=audio_rate, tau=deemph_tau) self.analog_fm_deemph_0 = analog.fm_deemph(fs=audio_rate, tau=deemph_tau) self.blocks_delay_0 = blocks.delay(gr.sizeof_float * 1, samp_delay) ################################################## # Connections ################################################## self.connect((self.analog_fm_deemph_0, 0), (self, 0)) self.connect((self.analog_fm_deemph_0_0, 0), (self, 1)) self.connect((self.analog_pll_refout_cc_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_pll_refout_cc_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_xx_2, 0)) self.connect((self.blocks_delay_0, 0), (self.fft_filter_xxx_1, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.fir_filter_xxx_1, 0)) self.connect((self.blocks_add_xx_0, 0), (self.analog_fm_deemph_0, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.analog_fm_deemph_0_0, 0)) self.connect((self.blocks_complex_to_imag_0, 0), (self.fft_filter_xxx_3, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_complex_to_imag_0, 0)) self.connect((self.blocks_multiply_xx_2, 0), (self.fft_filter_xxx_2, 0)) # L - R path self.connect((self.fft_filter_xxx_1, 0), (self.blocks_add_xx_0, 1)) self.connect((self.fft_filter_xxx_1, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.fft_filter_xxx_2, 0), (self.blocks_add_xx_0, 0)) self.connect((self.fft_filter_xxx_2, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.fft_filter_xxx_3, 0), (self.blocks_multiply_xx_2, 1)) self.connect((self.fir_filter_xxx_1, 0), (self.analog_pll_refout_cc_0, 0)) self.connect((self, 0), (self.analog_quadrature_demod_cf_0, 0))
def set_center_freq(self, center_freq): self.center_freq = center_freq self.rtlsdr_source_0.set_center_freq(self.center_freq, 0) self.qtgui_waterfall_sink_x_0_1.set_frequency_range(self.center_freq, self.samp_rate) self.qtgui_waterfall_sink_x_0.set_frequency_range(self.center_freq, self.samp_rate) self.band_pass_filter_0.set_taps(firdes.complex_band_pass(1, self.samp_rate, self.channel_freq - self.center_freq - self.channel_width/2, self.channel_freq - self.center_freq + self.channel_width/2, 1000, firdes.WIN_HAMMING, 6.76))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Chu") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1200000 self.upconverter_lo_freq = upconverter_lo_freq = 125000000 self.space_tone = space_tone = 2025 self.offset = offset = 100000 self.mark_tone = mark_tone = 2225 self.gain = gain = 10 self.decimation = decimation = samp_rate / 48000 self.chu_freq = chu_freq = 3330000 self.channel_rate = channel_rate = 4800 ################################################## # Blocks ################################################## self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.nb.AddPage(grc_wxgui.Panel(self.nb), "48 kHz") self.nb.AddPage(grc_wxgui.Panel(self.nb), "4.8 kHz") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Data scope") self.GridAdd(self.nb, 2, 0, 1, 1) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label="USB tuner gain", converter=forms.float_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=50, num_steps=125, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_gain_sizer, 1, 0, 1, 1) self._chu_freq_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.chu_freq, callback=self.set_chu_freq, label="CHU frequency", choices=[3330000, 7850000, 14670000], labels=['3.33 MHz', '7.85 MHz', '14.67 MHz'], style=wx.RA_HORIZONTAL, ) self.GridAdd(self._chu_freq_chooser, 0, 0, 1, 1) self.wxgui_waterfallsink2_1 = waterfallsink2.waterfall_sink_c( self.nb.GetPage(1).GetWin(), baseband_freq=(mark_tone + space_tone) / 2, dynamic_range=50, ref_level=-20, ref_scale=2.0, sample_rate=channel_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", ) self.nb.GetPage(1).Add(self.wxgui_waterfallsink2_1.win) self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.nb.GetPage(0).GetWin(), baseband_freq=chu_freq, dynamic_range=50, ref_level=-60, ref_scale=2.0, sample_rate=samp_rate / decimation, fft_size=2048, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", win=window.hamming, ) self.nb.GetPage(0).Add(self.wxgui_waterfallsink2_0.win) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.nb.GetPage(2).GetWin(), title="Scope Plot", sample_rate=channel_rate, v_scale=1, v_offset=0, t_scale=0.050, ac_couple=False, xy_mode=False, num_inputs=2, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(2).Add(self.wxgui_scopesink2_0.win) self.root_raised_cosine_filter_0 = filter.fir_filter_fff(1, firdes.root_raised_cosine( 1, channel_rate, 300, 0.35, 100)) 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(chu_freq - offset + upconverter_lo_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(0, 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(0, 0) self.low_pass_filter_1 = filter.fir_filter_ccf(10, firdes.low_pass( 1000, samp_rate / 25, 200, 50, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf(decimation, firdes.low_pass( 1, samp_rate, 20000, 5000, firdes.WIN_HAMMING, 6.76)) self.ham_chu_decode_0 = ham.chu_decode() self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_multiply_xx_2 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 0.5) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-1, )) self.band_pass_filter_0 = filter.fir_filter_ccc(1, firdes.complex_band_pass( 1, samp_rate / decimation, 200, 2800, 200, firdes.WIN_HAMMING, 6.76)) self.audio_sink_0_0 = audio.sink(48000, "", True) self.analog_sig_source_x_1 = analog.sig_source_c(samp_rate / decimation, analog.GR_COS_WAVE, -(space_tone + mark_tone) / 2, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -offset, 1, 0) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(channel_rate / (3.1416*(mark_tone - space_tone))) self.analog_pll_carriertracking_cc_0 = analog.pll_carriertracking_cc(3.1416 / 500, 1.8, -1.8) self.analog_agc_xx_0 = analog.agc_ff(1e-1, 0.02, 1.0) self.analog_agc_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_2, 1)) self.connect((self.analog_pll_carriertracking_cc_0, 0), (self.blocks_multiply_xx_2, 0)) self.connect((self.analog_pll_carriertracking_cc_0, 0), (self.wxgui_waterfallsink2_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_pll_carriertracking_cc_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.osmosdr_source_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.wxgui_waterfallsink2_1, 0)) self.connect((self.low_pass_filter_1, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.blocks_multiply_xx_2, 0), (self.low_pass_filter_1, 0)) self.connect((self.band_pass_filter_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.analog_agc_xx_0, 0), (self.audio_sink_0_0, 0)) self.connect((self.analog_pll_carriertracking_cc_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.analog_agc_xx_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.wxgui_scopesink2_0, 1)) self.connect((self.blocks_char_to_float_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.ham_chu_decode_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.root_raised_cosine_filter_0, 0))
def connect_audio_stage(self, input_port): stereo_rate = self.demod_rate normalizer = TWO_PI / stereo_rate pilot_tone = 19000 pilot_low = pilot_tone * 0.98 pilot_high = pilot_tone * 1.02 def make_audio_filter(): return grfilter.fir_filter_fff( stereo_rate // self.__audio_int_rate, # decimation firdes.low_pass(1.0, stereo_rate, 15000, 5000, firdes.WIN_HAMMING)) stereo_pilot_filter = grfilter.fir_filter_fcc( 1, # decimation firdes.complex_band_pass(1.0, stereo_rate, pilot_low, pilot_high, 300)) # TODO magic number from gqrx stereo_pilot_pll = analog.pll_refout_cc( loop_bw=0.001, max_freq=normalizer * pilot_high, min_freq=normalizer * pilot_low) stereo_pilot_doubler = blocks.multiply_cc() stereo_pilot_out = blocks.complex_to_real() difference_channel_mixer = blocks.multiply_ff() difference_channel_filter = make_audio_filter() mono_channel_filter = make_audio_filter() mixL = blocks.add_ff(1) mixR = blocks.sub_ff(1) # connections self.connect(input_port, mono_channel_filter) if self.__decode_stereo: # stereo pilot tone tracker self.connect(input_port, stereo_pilot_filter, stereo_pilot_pll) self.connect(stereo_pilot_pll, (stereo_pilot_doubler, 0)) self.connect(stereo_pilot_pll, (stereo_pilot_doubler, 1)) self.connect(stereo_pilot_doubler, stereo_pilot_out) # pick out stereo left-right difference channel (at stereo_rate) self.connect(input_port, (difference_channel_mixer, 0)) self.connect(stereo_pilot_out, (difference_channel_mixer, 1)) self.connect( difference_channel_mixer, blocks.multiply_const_ff( 6 ), # TODO: Completely empirical fudge factor. This should not be necessary. I believe this is at least partly due to phase error in the pilot signal. difference_channel_filter) # recover left/right channels (at self.__audio_int_rate) self.connect(difference_channel_filter, (mixL, 1)) self.connect(difference_channel_filter, (mixR, 1)) self.connect(mono_channel_filter, (mixL, 0)) self.connect(mono_channel_filter, (mixR, 0)) resamplerL = self._make_resampler((mixL, 0), self.__audio_int_rate) resamplerR = self._make_resampler((mixR, 0), self.__audio_int_rate) deemphL = fm_emph.fm_deemph(self.__audio_int_rate, 75e-6) deemphR = fm_emph.fm_deemph(self.__audio_int_rate, 75e-6) self.connect(resamplerL, deemphL) self.connect(resamplerR, deemphR) self.connect_audio_output(deemphL, deemphR) else: resampler = self._make_resampler(mono_channel_filter, self.__audio_int_rate) deemph = fm_emph.fm_deemph(self.__audio_int_rate, 75e-6) self.connect(resampler, deemph) self.connect_audio_output(deemph, deemph)
def __init__(self, modulator, options): gr.top_block.__init__(self) self.txpath = [] use_sink = None if options.tx_freq is not None: # Work-around to get the modulation's bits_per_symbol args = modulator.extract_kwargs_from_options(options) symbol_rate = options.bitrate / modulator(**args).bits_per_symbol() self.sink = uhd_transmitter( options.args, symbol_rate, options.samples_per_symbol, options.tx_freq, options.tx_gain, options.spec, options.antenna, options.verbose, ) sample_rate = self.sink.get_sample_rate() options.samples_per_symbol = self.sink._sps use_sink = self.sink elif options.to_file is not None: sys.stderr.write(("Saving samples to '%s'.\n\n" % (options.to_file))) self.sink = gr.file_sink(gr.sizeof_gr_complex, options.to_file) self.throttle = gr.throttle(gr.sizeof_gr_complex * 1, options.file_samp_rate) self.connect(self.throttle, self.sink) use_sink = self.throttle else: sys.stderr.write("No sink defined, dumping samples to null sink.\n\n") self.sink = gr.null_sink(gr.sizeof_gr_complex) # do this after for any adjustments to the options that may # occur in the sinks (specifically the UHD sink) self.txpath.append(transmit_path(modulator, options)) self.txpath.append(transmit_path(modulator, options)) samp_rate = 0 if options.tx_freq is not None: samp_rate = self.sink.get_sample_rate() else: samp_rate = options.file_samp_rate volume = options.split_amplitude band_transition = options.band_trans_width low_transition = options.low_trans_width guard_width = options.guard_width self.low_pass_filter_qv0 = gr.interp_fir_filter_ccf( 2, firdes.low_pass(1, samp_rate, samp_rate / 4 - guard_width / 2, low_transition, firdes.WIN_HAMMING, 6.76) ) self.freq_translate_qv0 = filter.freq_xlating_fir_filter_ccc(1, (options.num_taps,), samp_rate / 4, samp_rate) self.band_pass_filter_qv0 = gr.fir_filter_ccc( 1, firdes.complex_band_pass( 1, samp_rate, -samp_rate / 2 + guard_width, 0 - guard_width, band_transition, firdes.WIN_HAMMING, 6.76 ), ) self.low_pass_filter_qv1 = gr.interp_fir_filter_ccf( 2, firdes.low_pass(1, samp_rate, samp_rate / 4 - guard_width / 2, low_transition, firdes.WIN_HAMMING, 6.76) ) self.freq_translate_qv1 = filter.freq_xlating_fir_filter_ccc(1, (options.num_taps,), -samp_rate / 4, samp_rate) self.band_pass_filter_qv1 = gr.fir_filter_ccc( 1, firdes.complex_band_pass( 1, samp_rate, 0 + guard_width, samp_rate / 2 - guard_width, band_transition, firdes.WIN_HAMMING, 6.76 ), ) self.combiner = gr.add_vcc(1) self.volume_multiply = blocks.multiply_const_vcc((volume,)) self.connect((self.txpath[0], 0), (self.low_pass_filter_qv0, 0)) self.connect((self.txpath[1], 0), (self.low_pass_filter_qv1, 0)) self.connect((self.low_pass_filter_qv0, 0), (self.freq_translate_qv0, 0)) self.connect((self.freq_translate_qv0, 0), (self.band_pass_filter_qv0, 0)) self.connect((self.low_pass_filter_qv1, 0), (self.freq_translate_qv1, 0)) self.connect((self.freq_translate_qv1, 0), (self.band_pass_filter_qv1, 0)) self.connect((self.band_pass_filter_qv0, 0), (self.combiner, 0)) self.connect((self.band_pass_filter_qv1, 0), (self.combiner, 1)) self.connect((self.combiner, 0), (self.volume_multiply, 0)) self.connect(self.volume_multiply, use_sink)
def __init__(self): gr.top_block.__init__(self, "SSB Transmitter V1 - F1ATB - MAY 2020") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 2400000 self.LSB_USB = LSB_USB = 1 self.GainRF_TX = GainRF_TX = 100 self.GainIF_TX = GainIF_TX = 300 self.GainBB_TX = GainBB_TX = 40 self.Fr_TX = Fr_TX = 145100000 ################################################## # Blocks ################################################## self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer( ('localhost', 9004), 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.rational_resampler_xxx_1 = filter.rational_resampler_ccc( interpolation=240, decimation=1, taps=None, fractional_bw=None, ) self.osmosdr_sink_0 = osmosdr.sink(args="numchan=" + str(1) + " " + '0x00664765') self.osmosdr_sink_0.set_sample_rate(samp_rate) self.osmosdr_sink_0.set_center_freq(Fr_TX, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(GainRF_TX, 0) self.osmosdr_sink_0.set_if_gain(GainIF_TX, 0) self.osmosdr_sink_0.set_bb_gain(GainBB_TX, 0) self.osmosdr_sink_0.set_antenna('', 0) self.osmosdr_sink_0.set_bandwidth(0, 0) self.hilbert_fc_0 = filter.hilbert_fc(64, firdes.WIN_HAMMING, 6.76) (self.hilbert_fc_0).set_min_output_buffer(10) (self.hilbert_fc_0).set_max_output_buffer(10) self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_short * 1, '127.0.0.1', 9005, 512, True) (self.blocks_udp_source_0).set_max_output_buffer(2048) self.blocks_short_to_float_0 = blocks.short_to_float(1, 32767) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( (LSB_USB, )) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.band_pass_filter_0 = filter.fir_filter_ccc( 1, firdes.complex_band_pass(1, samp_rate / 240, -1300 + LSB_USB * 1500, 1300 + LSB_USB * 1500, 200, firdes.WIN_HAMMING, 6.76)) ################################################## # Connections ################################################## self.connect((self.band_pass_filter_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_short_to_float_0, 0), (self.hilbert_fc_0, 0)) self.connect((self.blocks_udp_source_0, 0), (self.blocks_short_to_float_0, 0)) self.connect((self.hilbert_fc_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.osmosdr_sink_0, 0))