def test_add_vff_one(self): src1_data = (1.0,) src2_data = (2.0,) src3_data = (3.0,) expected_result = (6.0,) op = gr.add_vff(1) self.help_ff(1, (src1_data, src2_data, src3_data), expected_result, op)
def test_add_vff_five(self): src1_data = (1.0, 2.0, 3.0, 4.0, 5.0) src2_data = (6.0, 7.0, 8.0, 9.0, 10.0) src3_data = (11.0, 12.0, 13.0, 14.0, 15.0) expected_result = (18.0, 21.0, 24.0, 27.0, 30.0) op = gr.add_vff(5) self.help_ff(5, (src1_data, src2_data, src3_data), expected_result, op)
def xInit(self, signals, noises, sinks): # ------------------------------------------------------------------------ self.sources = {} self.mutes = {} self.amps = {} #sources for signal in signals: self.sources[signal] = gr.sig_source_f( self.samprate, gr.GR_SIN_WAVE, 440, 0.25, 0) self.mutes[signal] = gr.mute_ff(True) self.amps[signal] = gr.multiply_const_ff(0.25) for noise in noises: self.sources[noise] = analog.noise_source_f( analog.GR_LAPLACIAN, 1, 0) self.mutes[noise] = gr.mute_ff(True) self.amps[noise] = gr.multiply_const_ff(0.25) #mixer if len(self.sources) > 1: self.adder = self.add = gr.add_vff(1) else: self.adder = gr.multiply_const_vff((1, )) self.level = gr.multiply_const_ff(1) #sinks self.sinks = sinks self.audiomute = gr.mute_ff(True) self.audio = audio.sink(self.samprate, "", True) self.udp = gr.null_sink(gr.sizeof_float) self.rawfile = gr.null_sink(gr.sizeof_float) self.wavefile = gr.null_sink(gr.sizeof_float)
def test_add_vff_one(self): src1_data = (1.0, ) src2_data = (2.0, ) src3_data = (3.0, ) expected_result = (6.0, ) op = gr.add_vff(1) self.help_ff(1, (src1_data, src2_data, src3_data), expected_result, op)
def xInit(self, sources): # ------------------------------------------------------------------------ self.sources = sources if not self.sources: print "AnySource.xInit: ERROR: Building flowgraph without sources." return if len(self.sources) == 1: self.mixer = gr.multiply_const_vff((1, )) else: self.mixer = gr.add_vff(1)
def __init__(self, N_id_2, decim=16, avg_halfframes=2 * 8, freq_corr=0, dump=None): gr.hier_block2.__init__( self, "PSS correlator", gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(1, 1, gr.sizeof_float), ) vec_half_frame = 30720 * 5 / decim self.taps = [] for i in range(0, 3): self.taps.append( gen_pss_td(i, N_re=2048 / decim, freq_corr=freq_corr).get_data_conj_rev()) self.corr = filter.fir_filter_ccc(1, self.taps[N_id_2]) self.mag = gr.complex_to_mag_squared() self.vec = gr.stream_to_vector(gr.sizeof_float * 1, vec_half_frame) self.deint = gr.deinterleave(gr.sizeof_float * vec_half_frame) self.add = gr.add_vff(vec_half_frame) self.argmax = gr.argmax_fs(vec_half_frame) self.null = gr.null_sink(gr.sizeof_short * 1) self.max = gr.max_ff(vec_half_frame) self.to_float = gr.short_to_float(1, 1. / decim) self.interleave = gr.interleave(gr.sizeof_float) #self.framestart = gr.add_const_ii(-160-144*5-2048*6+30720*5) self.connect(self, self.corr, self.mag, self.vec) self.connect((self.argmax, 1), self.null) #self.connect(self.argmax, self.to_float, self.to_int, self.framestart, self) self.connect(self.argmax, self.to_float, self.interleave, self) self.connect(self.max, (self.interleave, 1)) if avg_halfframes == 1: self.connect(self.vec, self.argmax) self.connect(self.vec, self.max) else: self.connect(self.vec, self.deint) self.connect(self.add, self.argmax) self.connect(self.add, self.max) for i in range(0, avg_halfframes): self.connect((self.deint, i), (self.add, i)) if dump != None: self.connect( self.mag, gr.file_sink(gr.sizeof_float, dump + "_pss_corr_f.cfile")) self.connect( self.add, gr.file_sink(gr.sizeof_float * vec_half_frame, dump + "_pss_corr_add_f.cfile"))
def __init__(self, N_id_2, decim=16, avg_halfframes=2*8, freq_corr=0, dump=None): gr.hier_block2.__init__( self, "PSS correlator", gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(1, 1, gr.sizeof_float), ) vec_half_frame = 30720*5/decim self.taps = [] for i in range(0,3): self.taps.append(gen_pss_td(i, N_re=2048/decim, freq_corr=freq_corr).get_data_conj_rev()) self.corr = filter.fir_filter_ccc(1, self.taps[N_id_2]) self.mag = gr.complex_to_mag_squared() self.vec = gr.stream_to_vector(gr.sizeof_float*1, vec_half_frame) self.deint = gr.deinterleave(gr.sizeof_float*vec_half_frame) self.add = gr.add_vff(vec_half_frame) self.argmax = gr.argmax_fs(vec_half_frame) self.null = gr.null_sink(gr.sizeof_short*1) self.max = gr.max_ff(vec_half_frame) self.to_float = gr.short_to_float(1, 1./decim) self.interleave = gr.interleave(gr.sizeof_float) #self.framestart = gr.add_const_ii(-160-144*5-2048*6+30720*5) self.connect(self, self.corr, self.mag, self.vec) self.connect((self.argmax,1), self.null) #self.connect(self.argmax, self.to_float, self.to_int, self.framestart, self) self.connect(self.argmax, self.to_float, self.interleave, self) self.connect(self.max, (self.interleave,1)) if avg_halfframes == 1: self.connect(self.vec, self.argmax) self.connect(self.vec, self.max) else: self.connect(self.vec, self.deint) self.connect(self.add, self.argmax) self.connect(self.add, self.max) for i in range(0, avg_halfframes): self.connect((self.deint, i), (self.add, i)) if dump != None: self.connect(self.mag, gr.file_sink(gr.sizeof_float, dump + "_pss_corr_f.cfile")) self.connect(self.add, gr.file_sink(gr.sizeof_float*vec_half_frame, dump + "_pss_corr_add_f.cfile"))
def __init__(self, magnitude=0, phase=0): """ Parameters: amplitude: float phase: float (degree) """ gr.hier_block2.__init__( self, "IQ Imbalance Generator", gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(1, 1, gr.sizeof_gr_complex), ) ################################################## # Parameters ################################################## self.magnitude = magnitude self.phase = phase ################################################## # Blocks ################################################## self.mag = gr.multiply_const_vff((math.pow(10, magnitude / 20.0), )) self.gr_multiply_const_vxx_0 = gr.multiply_const_vff( (math.sin(phase * math.pi / 180.0), )) self.gr_float_to_complex_0 = gr.float_to_complex(1) self.gr_complex_to_float_0 = gr.complex_to_float(1) self.gr_add_xx_0 = gr.add_vff(1) ################################################## # Connections ################################################## self.connect((self.gr_float_to_complex_0, 0), (self, 0)) self.connect((self, 0), (self.gr_complex_to_float_0, 0)) self.connect((self.gr_complex_to_float_0, 0), (self.mag, 0)) self.connect((self.mag, 0), (self.gr_float_to_complex_0, 0)) self.connect((self.gr_add_xx_0, 0), (self.gr_float_to_complex_0, 1)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.gr_add_xx_0, 0)) self.connect((self.gr_complex_to_float_0, 1), (self.gr_add_xx_0, 1)) self.connect((self.gr_complex_to_float_0, 0), (self.gr_multiply_const_vxx_0, 0))
def __init__(self, antenna="TX/RX", rx_gain=30, vor_samp_rate=250e3, com_freq_1=135.275e6, gain=21, vor_freq_1=115e6): grc_wxgui.top_block_gui.__init__(self, title="Simple Trx") ################################################## # Parameters ################################################## self.antenna = antenna self.rx_gain = rx_gain self.vor_samp_rate = vor_samp_rate self.com_freq_1 = com_freq_1 self.gain = gain self.vor_freq_1 = vor_freq_1 ################################################## # Variables ################################################## self.obs_decimation = obs_decimation = 25 self.ils_decimation = ils_decimation = 50 self.am_sample_rate = am_sample_rate = 12.5e3 self.vor_volume_slider = vor_volume_slider = 5 self.vor_ident = vor_ident = False self.vor_freq_entry_1 = vor_freq_entry_1 = vor_freq_1 self.vor_center_freq_0 = vor_center_freq_0 = (117.95e6-108.00e6)/2+117.95e6 self.system_center_freq = system_center_freq = 133.9e6 self.squelch_slider = squelch_slider = -85 self.samp_rate = samp_rate = 250e3 self.rxgain = rxgain = 15 self.phase_correction = phase_correction = 5 self.obs_sample_rate = obs_sample_rate = am_sample_rate/obs_decimation self.ils_sample_rate = ils_sample_rate = am_sample_rate/ils_decimation self.gain_slider = gain_slider = gain self.correction_gain = correction_gain = 0.8 self.com_volume_slider = com_volume_slider = 1 self.com_freq_entry_1 = com_freq_entry_1 = com_freq_1 self.com_enable = com_enable = True self.audio_select = audio_select = 0 self.audio_sample_rate = audio_sample_rate = 48e3 self.am_decimation = am_decimation = 1 ################################################## # Blocks ################################################## _vor_volume_slider_sizer = wx.BoxSizer(wx.VERTICAL) self._vor_volume_slider_text_box = forms.text_box( parent=self.GetWin(), sizer=_vor_volume_slider_sizer, value=self.vor_volume_slider, callback=self.set_vor_volume_slider, label='vor_volume_slider', converter=forms.float_converter(), proportion=0, ) self._vor_volume_slider_slider = forms.slider( parent=self.GetWin(), sizer=_vor_volume_slider_sizer, value=self.vor_volume_slider, callback=self.set_vor_volume_slider, minimum=0, maximum=10, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_vor_volume_slider_sizer, 1, 4, 1, 1) self._vor_ident_check_box = forms.check_box( parent=self.GetWin(), value=self.vor_ident, callback=self.set_vor_ident, label='vor_ident', true=1, false=0, ) self.GridAdd(self._vor_ident_check_box, 0, 3, 1, 1) self._vor_freq_entry_1_text_box = forms.text_box( parent=self.GetWin(), value=self.vor_freq_entry_1, callback=self.set_vor_freq_entry_1, label='vor_freq_entry_1', converter=forms.float_converter(), ) self.GridAdd(self._vor_freq_entry_1_text_box, 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), "RF Analyzer") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Channel FFT") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Demod Audio FFT") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Ref and Phase Scope") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Manipulated Ref and Phase") self.Add(self.notebook_0) _com_volume_slider_sizer = wx.BoxSizer(wx.VERTICAL) self._com_volume_slider_text_box = forms.text_box( parent=self.GetWin(), sizer=_com_volume_slider_sizer, value=self.com_volume_slider, callback=self.set_com_volume_slider, label='com_volume_slider', converter=forms.float_converter(), proportion=0, ) self._com_volume_slider_slider = forms.slider( parent=self.GetWin(), sizer=_com_volume_slider_sizer, value=self.com_volume_slider, callback=self.set_com_volume_slider, minimum=0, maximum=10, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_com_volume_slider_sizer, 1, 5, 1, 1) self._com_freq_entry_1_text_box = forms.text_box( parent=self.GetWin(), value=self.com_freq_entry_1, callback=self.set_com_freq_entry_1, label='com_freq_entry_1', converter=forms.float_converter(), ) self.GridAdd(self._com_freq_entry_1_text_box, 0, 0, 1, 1) self._com_enable_check_box = forms.check_box( parent=self.GetWin(), value=self.com_enable, callback=self.set_com_enable, label='com_enable', true=1, false=0, ) self.GridAdd(self._com_enable_check_box, 2, 3, 1, 1) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.notebook_0.GetPage(3).GetWin(), title="Scope Plot", sample_rate=12.5e3, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=2, trig_mode=gr.gr_TRIG_MODE_AUTO, y_axis_label="Counts", ) self.notebook_0.GetPage(3).Add(self.wxgui_scopesink2_0.win) self.wxgui_numbersink2_0 = numbersink2.number_sink_f( self.GetWin(), unit="Units", minval=-200, maxval=200, factor=1.0, decimal_places=10, ref_level=0, sample_rate=25e3/2000, number_rate=15, average=True, avg_alpha=0.02, label="Number Plot", peak_hold=False, show_gauge=True, ) self.Add(self.wxgui_numbersink2_0.win) self.wxgui_fftsink2_0_1 = 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=25e3, fft_size=1024, fft_rate=5, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.notebook_0.GetPage(0).Add(self.wxgui_fftsink2_0_1.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( 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=12.5e3, fft_size=1024, fft_rate=5, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.notebook_0.GetPage(1).Add(self.wxgui_fftsink2_0.win) self.uhd_usrp_source_0 = uhd.usrp_source( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) self.uhd_usrp_source_0.set_clock_source("internal", 0) self.uhd_usrp_source_0.set_subdev_spec("A:0 A:0", 0) self.uhd_usrp_source_0.set_samp_rate(vor_samp_rate) self.uhd_usrp_source_0.set_center_freq(uhd.tune_request(com_freq_entry_1, rf_freq=system_center_freq, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0) self.uhd_usrp_source_0.set_gain(rx_gain, 0) self.uhd_usrp_source_0.set_antenna("RX2", 0) self.uhd_usrp_source_0.set_center_freq(uhd.tune_request(vor_freq_entry_1, rf_freq=system_center_freq, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 1) self.uhd_usrp_source_0.set_gain(rx_gain, 1) self.uhd_usrp_source_0.set_antenna("RX2", 1) self.uhd_usrp_sink_0 = uhd.usrp_sink( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(250e3) self.uhd_usrp_sink_0.set_center_freq(com_freq_entry_1, 0) self.uhd_usrp_sink_0.set_gain(25, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) _squelch_slider_sizer = wx.BoxSizer(wx.VERTICAL) self._squelch_slider_text_box = forms.text_box( parent=self.GetWin(), sizer=_squelch_slider_sizer, value=self.squelch_slider, callback=self.set_squelch_slider, label='squelch_slider', converter=forms.float_converter(), proportion=0, ) self._squelch_slider_slider = forms.slider( parent=self.GetWin(), sizer=_squelch_slider_sizer, value=self.squelch_slider, callback=self.set_squelch_slider, minimum=-100, maximum=0, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_squelch_slider_sizer, 1, 0, 1, 1) self.squelch = gr.pwr_squelch_cc(squelch_slider, 0.01, 20, False) self.openavionics_joystick_interface_0 = openavionics.joystick_interface() self.openavionics_audio_ptt_0 = openavionics.audio_ptt() self.low_pass_filter_3_0 = filter.fir_filter_fff(5, firdes.low_pass( 1, 25e3, 200, 50, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_3 = filter.fir_filter_fff(5, firdes.low_pass( 1, 25e3, 200, 50, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_2 = filter.fir_filter_ccf(1, firdes.low_pass( 1, 25e3, 3e3, 500, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_1 = filter.interp_fir_filter_fff(1, firdes.low_pass( 1, 12.5e3, 3e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0_0 = filter.fir_filter_ccf(int(250e3/25e3), firdes.low_pass( 1, vor_samp_rate, 11e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf(int(250e3/12.5e3), firdes.low_pass( 1, vor_samp_rate, 10e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.gr_sig_source_x_0 = gr.sig_source_c(25e3, gr.GR_COS_WAVE, 9960, 1, 0) self.gr_quadrature_demod_cf_0 = gr.quadrature_demod_cf(1) self.gr_pwr_squelch_xx_0 = gr.pwr_squelch_ff(-50, 0.5, 1, False) self.gr_null_sink_0_0 = gr.null_sink(gr.sizeof_gr_complex*1) self.gr_multiply_xx_0_0_1 = gr.multiply_vff(1) self.gr_multiply_xx_0_0_0_0 = gr.multiply_vcc(1) self.gr_multiply_xx_0 = gr.multiply_vcc(1) self.gr_float_to_complex_0_0_0 = gr.float_to_complex(1) self.gr_float_to_complex_0 = gr.float_to_complex(1) self.gr_agc2_xx_0_0 = gr.agc2_cc(1, 1, 0.75, 1.0, 0.0) self.gr_agc2_xx_0 = gr.agc2_cc(1, 1, 0.75, 1.0, 0.0) self.gr_add_xx_0_0_0 = gr.add_vff(1) _gain_slider_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_slider_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_slider_sizer, value=self.gain_slider, callback=self.set_gain_slider, label='gain_slider', converter=forms.float_converter(), proportion=0, ) self._gain_slider_slider = forms.slider( parent=self.GetWin(), sizer=_gain_slider_sizer, value=self.gain_slider, callback=self.set_gain_slider, minimum=0, maximum=30, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_gain_slider_sizer, 1, 1, 1, 1) self.fft_tone_to_angle_0 = fft_tone_to_angle( fft_bin=12, fft_size=2000, ) self.const_source_x_0_1 = gr.sig_source_f(0, gr.GR_CONST_WAVE, 0, 0, 0.450) self.const_source_x_0_0_1 = gr.sig_source_f(0, gr.GR_CONST_WAVE, 0, 0, 0.550) self.const_source_x_0_0_0_0 = gr.sig_source_c(0, gr.GR_CONST_WAVE, 0, 0, 0.450) self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_float*1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((180.0/3.1415, )) self.blocks_add_xx_0 = blocks.add_vff(1) self.blks2_rational_resampler_xxx_2_0 = blks2.rational_resampler_fff( interpolation=250, decimation=48, taps=None, fractional_bw=None, ) self.blks2_rational_resampler_xxx_1 = blks2.rational_resampler_fff( interpolation=480, decimation=125, taps=None, fractional_bw=None, ) self.blks2_am_demod_cf_0_0 = blks2.am_demod_cf( channel_rate=25e3, audio_decim=am_decimation, audio_pass=11.5e3, audio_stop=12.250e3, ) self.blks2_am_demod_cf_0 = blks2.am_demod_cf( channel_rate=am_sample_rate, audio_decim=am_decimation, audio_pass=3e3, audio_stop=4e3, ) self.band_pass_filter_0 = gr.fir_filter_fff(2, firdes.band_pass( 1, 25000, 980, 1150, 50, firdes.WIN_HAMMING, 6.76)) self.audio_sink_0 = audio.sink(int(audio_sample_rate), "", True) self._audio_select_chooser = forms.drop_down( parent=self.GetWin(), value=self.audio_select, callback=self.set_audio_select, label='audio_select', choices=[0, 1], labels=['AM Voice','VOR Subcarrier'], ) self.GridAdd(self._audio_select_chooser, 0, 2, 1, 1) self.analog_sig_source_x_0_0 = analog.sig_source_f(48000, analog.GR_COS_WAVE, 1000, 1, 0) self.adsf_0 = blocks.multiply_const_vff((com_enable*com_volume_slider, )) self.adsf = blocks.multiply_const_vff((vor_ident*vor_volume_slider, )) ################################################## # Connections ################################################## self.connect((self.gr_float_to_complex_0, 0), (self.gr_multiply_xx_0, 0)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.audio_sink_0, 0)) self.connect((self.blks2_am_demod_cf_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.uhd_usrp_source_0, 1), (self.gr_null_sink_0_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.squelch, 0)) self.connect((self.squelch, 0), (self.gr_agc2_xx_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.gr_agc2_xx_0, 0), (self.blks2_am_demod_cf_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.wxgui_fftsink2_0_1, 0)) self.connect((self.gr_agc2_xx_0_0, 0), (self.blks2_am_demod_cf_0_0, 0)) self.connect((self.uhd_usrp_source_0, 1), (self.low_pass_filter_0_0, 0)) self.connect((self.blks2_am_demod_cf_0_0, 0), (self.gr_float_to_complex_0, 0)) self.connect((self.fft_tone_to_angle_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.wxgui_numbersink2_0, 0)) self.connect((self.fft_tone_to_angle_0, 1), (self.blocks_null_sink_0, 0)) self.connect((self.fft_tone_to_angle_0, 2), (self.blocks_null_sink_1, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.gr_agc2_xx_0_0, 0)) self.connect((self.gr_quadrature_demod_cf_0, 0), (self.low_pass_filter_3, 0)) self.connect((self.low_pass_filter_3, 0), (self.fft_tone_to_angle_0, 0)) self.connect((self.low_pass_filter_3_0, 0), (self.fft_tone_to_angle_0, 1)) self.connect((self.blks2_am_demod_cf_0_0, 0), (self.low_pass_filter_3_0, 0)) self.connect((self.blks2_am_demod_cf_0_0, 0), (self.gr_float_to_complex_0, 1)) self.connect((self.gr_multiply_xx_0, 0), (self.low_pass_filter_2, 0)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_xx_0, 1)) self.connect((self.low_pass_filter_2, 0), (self.gr_quadrature_demod_cf_0, 0)) self.connect((self.blks2_am_demod_cf_0_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.adsf, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.blks2_rational_resampler_xxx_1, 0)) self.connect((self.adsf, 0), (self.wxgui_scopesink2_0, 1)) self.connect((self.low_pass_filter_1, 0), (self.adsf_0, 0)) self.connect((self.adsf_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.adsf_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.gr_pwr_squelch_xx_0, 0)) self.connect((self.gr_pwr_squelch_xx_0, 0), (self.adsf, 0)) self.connect((self.const_source_x_0_0_0_0, 0), (self.gr_multiply_xx_0_0_0_0, 1)) self.connect((self.gr_float_to_complex_0_0_0, 0), (self.gr_multiply_xx_0_0_0_0, 0)) self.connect((self.gr_add_xx_0_0_0, 0), (self.gr_float_to_complex_0_0_0, 1)) self.connect((self.gr_add_xx_0_0_0, 0), (self.gr_float_to_complex_0_0_0, 0)) self.connect((self.const_source_x_0_0_1, 0), (self.gr_add_xx_0_0_0, 1)) self.connect((self.gr_multiply_xx_0_0_1, 0), (self.gr_add_xx_0_0_0, 0)) self.connect((self.const_source_x_0_1, 0), (self.gr_multiply_xx_0_0_1, 1)) self.connect((self.gr_multiply_xx_0_0_0_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blks2_rational_resampler_xxx_2_0, 0), (self.openavionics_audio_ptt_0, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blks2_rational_resampler_xxx_2_0, 0)) self.connect((self.openavionics_audio_ptt_0, 0), (self.gr_multiply_xx_0_0_1, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.openavionics_joystick_interface_0, "out", self.openavionics_audio_ptt_0, "in2")
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Rds Tx") _icon_path = "/home/azimout/.local/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.usrp_interp = usrp_interp = 500 self.dac_rate = dac_rate = 128e6 self.wav_rate = wav_rate = 44100 self.usrp_rate = usrp_rate = int(dac_rate / usrp_interp) self.fm_max_dev = fm_max_dev = 120e3 ################################################## # Blocks ################################################## self.band_pass_filter_0 = gr.interp_fir_filter_fff( 1, firdes.band_pass(1, usrp_rate, 54e3, 60e3, 3e3, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_1 = gr.interp_fir_filter_fff( 1, firdes.band_pass(1, usrp_rate, 23e3, 53e3, 2e3, firdes.WIN_HAMMING, 6.76)) self.blks2_rational_resampler_xxx_1 = blks2.rational_resampler_fff( interpolation=usrp_rate, decimation=wav_rate, taps=None, fractional_bw=None, ) self.blks2_rational_resampler_xxx_1_0 = blks2.rational_resampler_fff( interpolation=usrp_rate, decimation=wav_rate, taps=None, fractional_bw=None, ) self.gr_add_xx_0 = gr.add_vff(1) self.gr_add_xx_1 = gr.add_vff(1) self.gr_char_to_float_0 = gr.char_to_float() self.gr_diff_encoder_bb_0 = gr.diff_encoder_bb(2) self.gr_frequency_modulator_fc_0 = gr.frequency_modulator_fc( 2 * math.pi * fm_max_dev / usrp_rate) self.gr_map_bb_0 = gr.map_bb(([-1, 1])) self.gr_map_bb_1 = gr.map_bb(([1, 2])) self.gr_multiply_xx_0 = gr.multiply_vff(1) self.gr_multiply_xx_1 = gr.multiply_vff(1) self.gr_rds_data_encoder_0 = rds.data_encoder( "/media/dimitris/mywork/gr/dimitris/rds/trunk/src/test/rds_data.xml" ) self.gr_rds_rate_enforcer_0 = rds.rate_enforcer(256000) self.gr_sig_source_x_0 = gr.sig_source_f(usrp_rate, gr.GR_COS_WAVE, 19e3, 0.3, 0) self.gr_sub_xx_0 = gr.sub_ff(1) self.gr_unpack_k_bits_bb_0 = gr.unpack_k_bits_bb(2) self.gr_wavfile_source_0 = gr.wavfile_source( "/media/dimitris/mywork/gr/dimitris/rds/trunk/src/python/limmenso_stereo.wav", True) self.low_pass_filter_0 = gr.interp_fir_filter_fff( 1, firdes.low_pass(1, usrp_rate, 1.5e3, 2e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0_0 = gr.interp_fir_filter_fff( 1, firdes.low_pass(1, usrp_rate, 15e3, 2e3, firdes.WIN_HAMMING, 6.76)) self.usrp_simple_sink_x_0 = grc_usrp.simple_sink_c(which=0, side="A") self.usrp_simple_sink_x_0.set_interp_rate(500) self.usrp_simple_sink_x_0.set_frequency(107.2e6, verbose=True) self.usrp_simple_sink_x_0.set_gain(0) self.usrp_simple_sink_x_0.set_enable(True) self.usrp_simple_sink_x_0.set_auto_tr(True) self.wxgui_fftsink2_0 = fftsink2.fft_sink_f( self.GetWin(), baseband_freq=0, y_per_div=20, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=usrp_rate, fft_size=1024, fft_rate=30, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) ################################################## # Connections ################################################## self.connect((self.gr_sig_source_x_0, 0), (self.gr_rds_rate_enforcer_0, 1)) self.connect((self.gr_char_to_float_0, 0), (self.gr_rds_rate_enforcer_0, 0)) self.connect((self.gr_map_bb_0, 0), (self.gr_char_to_float_0, 0)) self.connect((self.gr_frequency_modulator_fc_0, 0), (self.usrp_simple_sink_x_0, 0)) self.connect((self.gr_add_xx_1, 0), (self.gr_frequency_modulator_fc_0, 0)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_add_xx_1, 1)) self.connect((self.gr_sub_xx_0, 0), (self.gr_multiply_xx_1, 2)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_xx_1, 1)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_xx_1, 0)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_xx_0, 3)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_xx_0, 2)) self.connect((self.blks2_rational_resampler_xxx_1_0, 0), (self.gr_add_xx_0, 1)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.gr_add_xx_0, 0)) self.connect((self.blks2_rational_resampler_xxx_1_0, 0), (self.gr_sub_xx_0, 1)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.gr_sub_xx_0, 0)) self.connect((self.gr_wavfile_source_0, 1), (self.blks2_rational_resampler_xxx_1_0, 0)) self.connect((self.gr_wavfile_source_0, 0), (self.blks2_rational_resampler_xxx_1, 0)) self.connect((self.gr_rds_data_encoder_0, 0), (self.gr_diff_encoder_bb_0, 0)) self.connect((self.gr_diff_encoder_bb_0, 0), (self.gr_map_bb_1, 0)) self.connect((self.gr_map_bb_1, 0), (self.gr_unpack_k_bits_bb_0, 0)) self.connect((self.gr_unpack_k_bits_bb_0, 0), (self.gr_map_bb_0, 0)) self.connect((self.gr_rds_rate_enforcer_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.gr_multiply_xx_0, 0)) self.connect((self.gr_multiply_xx_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.gr_add_xx_1, 0)) self.connect((self.gr_multiply_xx_1, 0), (self.band_pass_filter_1, 0)) self.connect((self.band_pass_filter_1, 0), (self.gr_add_xx_1, 3)) self.connect((self.gr_add_xx_1, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_xx_0, 1)) self.connect((self.gr_add_xx_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.gr_add_xx_1, 2))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Rds Tx") _icon_path = "/home/azimout/.local/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.usrp_interp = usrp_interp = 500 self.dac_rate = dac_rate = 128e6 self.wav_rate = wav_rate = 44100 self.usrp_rate = usrp_rate = int(dac_rate/usrp_interp) self.fm_max_dev = fm_max_dev = 120e3 ################################################## # Blocks ################################################## self.band_pass_filter_0 = gr.interp_fir_filter_fff(1, firdes.band_pass( 1, usrp_rate, 54e3, 60e3, 3e3, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_1 = gr.interp_fir_filter_fff(1, firdes.band_pass( 1, usrp_rate, 23e3, 53e3, 2e3, firdes.WIN_HAMMING, 6.76)) self.blks2_rational_resampler_xxx_1 = blks2.rational_resampler_fff( interpolation=usrp_rate, decimation=wav_rate, taps=None, fractional_bw=None, ) self.blks2_rational_resampler_xxx_1_0 = blks2.rational_resampler_fff( interpolation=usrp_rate, decimation=wav_rate, taps=None, fractional_bw=None, ) self.gr_add_xx_0 = gr.add_vff(1) self.gr_add_xx_1 = gr.add_vff(1) self.gr_char_to_float_0 = gr.char_to_float() self.gr_diff_encoder_bb_0 = gr.diff_encoder_bb(2) self.gr_frequency_modulator_fc_0 = gr.frequency_modulator_fc(2*math.pi*fm_max_dev/usrp_rate) self.gr_map_bb_0 = gr.map_bb(([-1,1])) self.gr_map_bb_1 = gr.map_bb(([1,2])) self.gr_multiply_xx_0 = gr.multiply_vff(1) self.gr_multiply_xx_1 = gr.multiply_vff(1) self.gr_rds_data_encoder_0 = rds.data_encoder("/media/dimitris/mywork/gr/dimitris/rds/trunk/src/test/rds_data.xml") self.gr_rds_rate_enforcer_0 = rds.rate_enforcer(256000) self.gr_sig_source_x_0 = gr.sig_source_f(usrp_rate, gr.GR_COS_WAVE, 19e3, 0.3, 0) self.gr_sub_xx_0 = gr.sub_ff(1) self.gr_unpack_k_bits_bb_0 = gr.unpack_k_bits_bb(2) self.gr_wavfile_source_0 = gr.wavfile_source("/media/dimitris/mywork/gr/dimitris/rds/trunk/src/python/limmenso_stereo.wav", True) self.low_pass_filter_0 = gr.interp_fir_filter_fff(1, firdes.low_pass( 1, usrp_rate, 1.5e3, 2e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0_0 = gr.interp_fir_filter_fff(1, firdes.low_pass( 1, usrp_rate, 15e3, 2e3, firdes.WIN_HAMMING, 6.76)) self.usrp_simple_sink_x_0 = grc_usrp.simple_sink_c(which=0, side="A") self.usrp_simple_sink_x_0.set_interp_rate(500) self.usrp_simple_sink_x_0.set_frequency(107.2e6, verbose=True) self.usrp_simple_sink_x_0.set_gain(0) self.usrp_simple_sink_x_0.set_enable(True) self.usrp_simple_sink_x_0.set_auto_tr(True) self.wxgui_fftsink2_0 = fftsink2.fft_sink_f( self.GetWin(), baseband_freq=0, y_per_div=20, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=usrp_rate, fft_size=1024, fft_rate=30, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) ################################################## # Connections ################################################## self.connect((self.gr_sig_source_x_0, 0), (self.gr_rds_rate_enforcer_0, 1)) self.connect((self.gr_char_to_float_0, 0), (self.gr_rds_rate_enforcer_0, 0)) self.connect((self.gr_map_bb_0, 0), (self.gr_char_to_float_0, 0)) self.connect((self.gr_frequency_modulator_fc_0, 0), (self.usrp_simple_sink_x_0, 0)) self.connect((self.gr_add_xx_1, 0), (self.gr_frequency_modulator_fc_0, 0)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_add_xx_1, 1)) self.connect((self.gr_sub_xx_0, 0), (self.gr_multiply_xx_1, 2)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_xx_1, 1)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_xx_1, 0)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_xx_0, 3)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_xx_0, 2)) self.connect((self.blks2_rational_resampler_xxx_1_0, 0), (self.gr_add_xx_0, 1)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.gr_add_xx_0, 0)) self.connect((self.blks2_rational_resampler_xxx_1_0, 0), (self.gr_sub_xx_0, 1)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.gr_sub_xx_0, 0)) self.connect((self.gr_wavfile_source_0, 1), (self.blks2_rational_resampler_xxx_1_0, 0)) self.connect((self.gr_wavfile_source_0, 0), (self.blks2_rational_resampler_xxx_1, 0)) self.connect((self.gr_rds_data_encoder_0, 0), (self.gr_diff_encoder_bb_0, 0)) self.connect((self.gr_diff_encoder_bb_0, 0), (self.gr_map_bb_1, 0)) self.connect((self.gr_map_bb_1, 0), (self.gr_unpack_k_bits_bb_0, 0)) self.connect((self.gr_unpack_k_bits_bb_0, 0), (self.gr_map_bb_0, 0)) self.connect((self.gr_rds_rate_enforcer_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.gr_multiply_xx_0, 0)) self.connect((self.gr_multiply_xx_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.gr_add_xx_1, 0)) self.connect((self.gr_multiply_xx_1, 0), (self.band_pass_filter_1, 0)) self.connect((self.band_pass_filter_1, 0), (self.gr_add_xx_1, 3)) self.connect((self.gr_add_xx_1, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_xx_0, 1)) self.connect((self.gr_add_xx_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.gr_add_xx_1, 2))
def __init__(self, modulator, demodulator, rx_callback, options): gr.top_block.__init__(self) sense_symbol_rate=2500000 sense_samples_per_symbol=2 sense_rx_freq=2500000000 sense_rx_gain=20 options.chbw_factor=1 global bandchoose #args = demodulator.extract_kwargs_from_options(options) self.sensesource=uhd_receiver(options.args, sense_symbol_rate, sense_samples_per_symbol, sense_rx_freq, sense_rx_gain, options.spec, options.antenna, options.verbose) 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() fa = samp_rate/4 #1000000 self.sink = uhd_transmitter(options.args, symbol_rate, options.samples_per_symbol, options.tx_freq, options.tx_gain, options.spec, options.antenna, options.verbose) options.samples_per_symbol = self.sink._sps 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) else: sys.stderr.write("No sink defined, dumping samples to null sink.\n\n") self.sink = gr.null_sink(gr.sizeof_gr_complex) self.txgate = gr.copy(gr.sizeof_gr_complex) self.sensegate = gr.copy(gr.sizeof_gr_complex) #self.msgq = gr.msg_queue() # do this after for any adjustments to the options that may # occur in the sinks (specifically the UHD sink) # do sense self.sensepath = sensing_path(options) self.tx_enabled = True self.sense_flag=False self.connect(self.sensesource, self.sensepath) # do this after for any adjustments to the options that may # occur in the sinks (specifically the UHD sink) self.txpath1 = transmit_path(modulator, options) self.txpath2 = transmit_path(modulator, options) #self.connect(self.txpath, self.sink) # Define the math operator blocks # Generate exp(jw1t) and exp(-jw1t) self.gr_multiply_xx_0 = gr.multiply_vff(1) self.gr_float_to_complex_0_0 = gr.float_to_complex(1) self.gr_float_to_complex_0 = gr.float_to_complex(1) self.const_source_x_0 = gr.sig_source_f(0, gr.GR_CONST_WAVE, 0, 0, -1) self.analog_sig_source_x_0_0 = gr.sig_source_f(samp_rate, gr.GR_SIN_WAVE, fa, 1, 0) self.analog_sig_source_x_0 = gr.sig_source_f(samp_rate, gr.GR_COS_WAVE, fa, 1, 0) # Combine signal from two subbands self.gr_multiply_xx_1 = gr.multiply_vcc(1) self.gr_multiply_xx_2 = gr.multiply_vcc(1) self.gr_c2f_1 = gr.complex_to_float(1) self.gr_c2f_2 = gr.complex_to_float(1) self.gr_add_xx_re = gr.add_vff(1) self.gr_add_xx_im = gr.add_vff(1) self.gr_f2c = gr.float_to_complex(1) self.gr_null_source_0 = gr.null_source(gr.sizeof_gr_complex*1) # output from gr_float_to_complex_0_0 is exp(-jw1t) # output from gr_float_to_complex_0 is exp(jw1t) self.connect((self.gr_multiply_xx_0, 0), (self.gr_float_to_complex_0_0, 1)) self.connect((self.analog_sig_source_x_0, 0), (self.gr_float_to_complex_0_0, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.gr_float_to_complex_0, 1)) self.connect((self.analog_sig_source_x_0, 0), (self.gr_float_to_complex_0, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.gr_multiply_xx_0, 0)) self.connect((self.const_source_x_0, 0), (self.gr_multiply_xx_0, 1)) # txpath1 * exp(-jw1t) #self.connect(self.txpath1, (self.gr_multiply_xx_1, 0)) self.connect((self.gr_float_to_complex_0_0, 0), (self.gr_multiply_xx_1, 1)) # txpath2 * exp(jw1t) #self.connect(self.txpath2, (self.gr_multiply_xx_2, 0)) self.connect((self.gr_float_to_complex_0, 0), (self.gr_multiply_xx_2, 1)) if bandchoose == 0: self.connect(self.txpath1, (self.gr_multiply_xx_1, 0)) self.connect(self.gr_null_source_0 , (self.gr_multiply_xx_2, 0)) elif bandchoose == 1: self.connect(self.gr_null_source_0 , (self.gr_multiply_xx_1, 0)) self.connect(self.txpath2, (self.gr_multiply_xx_2, 0)) else: self.connect(self.txpath1, (self.gr_multiply_xx_1, 0)) self.connect(self.txpath2, (self.gr_multiply_xx_2, 0)) self.connect((self.gr_multiply_xx_1, 0), self.gr_c2f_1) self.connect((self.gr_multiply_xx_2, 0), self.gr_c2f_2) self.connect((self.gr_c2f_1,0), (self.gr_add_xx_re,0)) self.connect((self.gr_c2f_2,0), (self.gr_add_xx_re,1)) self.connect((self.gr_c2f_1,1), (self.gr_add_xx_im,0)) self.connect((self.gr_c2f_2,1), (self.gr_add_xx_im,1)) self.connect(self.gr_add_xx_re, (self.gr_f2c,0)) self.connect(self.gr_add_xx_im, (self.gr_f2c,1)) self.connect(self.gr_f2c, self.sink)
def __init__(self, devid="type=b100", rdsfile="rds_fifo", gain=35.0, freq=101.1e6, xmlport=13777, arate=int(48e3), mute=-15.0, ftune=0, ant="J1", subdev="A:0", ahw="pulse", deemph=75.0e-6, prenames='["UWRF","89.3","950","WEVR"]', prefreqs="[88.715e6,89.3e6,950.735e6,106.317e6]", volume=1.0): grc_wxgui.top_block_gui.__init__(self, title="Simple FM (Stereo) Receiver") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Parameters ################################################## self.devid = devid self.rdsfile = rdsfile self.gain = gain self.freq = freq self.xmlport = xmlport self.arate = arate self.mute = mute self.ftune = ftune self.ant = ant self.subdev = subdev self.ahw = ahw self.deemph = deemph self.prenames = prenames self.prefreqs = prefreqs self.volume = volume ################################################## # Variables ################################################## self.pthresh = pthresh = 350 self.preselect = preselect = eval(prefreqs)[0] self.pilot_level = pilot_level = 0 self.ifreq = ifreq = freq self.stpilotdet = stpilotdet = True if (pilot_level > pthresh) else False self.stereo = stereo = True self.rf_pwr_lvl = rf_pwr_lvl = 0 self.cur_freq = cur_freq = simple_fm_helper.freq_select(ifreq,preselect) self.vol = vol = volume self.variable_static_text_0 = variable_static_text_0 = 10.0*math.log(rf_pwr_lvl+1.0e-11)/math.log(10) self.tone_med = tone_med = 5 self.tone_low = tone_low = 5 self.tone_high = tone_high = 5 self.stereo_0 = stereo_0 = stpilotdet self.st_enabled = st_enabled = 1 if (stereo == True and pilot_level > pthresh) else 0 self.squelch_probe = squelch_probe = 0 self.sq_thresh = sq_thresh = mute self.samp_rate = samp_rate = 250e3 self.rtext_0 = rtext_0 = cur_freq self.record = record = False self.rdsrate = rdsrate = 25e3 self.osmo_taps = osmo_taps = firdes.low_pass(1.0,1.00e6,95e3,20e3,firdes.WIN_HAMMING,6.76) self.mod_reset = mod_reset = 0 self.igain = igain = gain self.fine = fine = ftune self.farate = farate = arate self.dm = dm = deemph self.discrim_dc = discrim_dc = 0 self.capture_file = capture_file = "capture.wav" self.asrate = asrate = 125e3 ################################################## # Blocks ################################################## _sq_thresh_sizer = wx.BoxSizer(wx.VERTICAL) self._sq_thresh_text_box = forms.text_box( parent=self.GetWin(), sizer=_sq_thresh_sizer, value=self.sq_thresh, callback=self.set_sq_thresh, label="Mute Level", converter=forms.float_converter(), proportion=0, ) self._sq_thresh_slider = forms.slider( parent=self.GetWin(), sizer=_sq_thresh_sizer, value=self.sq_thresh, callback=self.set_sq_thresh, minimum=-30.0, maximum=-5.0, num_steps=40, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_sq_thresh_sizer, 1, 5, 1, 1) self.input_power = gr.probe_avg_mag_sqrd_c(sq_thresh, 1.0/(samp_rate/10)) self.dc_level = gr.probe_signal_f() _vol_sizer = wx.BoxSizer(wx.VERTICAL) self._vol_text_box = forms.text_box( parent=self.GetWin(), sizer=_vol_sizer, value=self.vol, callback=self.set_vol, label="Volume", converter=forms.float_converter(), proportion=0, ) self._vol_slider = forms.slider( parent=self.GetWin(), sizer=_vol_sizer, value=self.vol, callback=self.set_vol, minimum=0, maximum=11, num_steps=110, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_vol_sizer, 0, 3, 1, 1) _tone_med_sizer = wx.BoxSizer(wx.VERTICAL) self._tone_med_text_box = forms.text_box( parent=self.GetWin(), sizer=_tone_med_sizer, value=self.tone_med, callback=self.set_tone_med, label="1Khz-4Khz", converter=forms.float_converter(), proportion=0, ) self._tone_med_slider = forms.slider( parent=self.GetWin(), sizer=_tone_med_sizer, value=self.tone_med, callback=self.set_tone_med, minimum=0, maximum=10, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_tone_med_sizer, 1, 3, 1, 1) _tone_low_sizer = wx.BoxSizer(wx.VERTICAL) self._tone_low_text_box = forms.text_box( parent=self.GetWin(), sizer=_tone_low_sizer, value=self.tone_low, callback=self.set_tone_low, label="0-1Khz", converter=forms.float_converter(), proportion=0, ) self._tone_low_slider = forms.slider( parent=self.GetWin(), sizer=_tone_low_sizer, value=self.tone_low, callback=self.set_tone_low, minimum=0, maximum=10, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_tone_low_sizer, 1, 2, 1, 1) _tone_high_sizer = wx.BoxSizer(wx.VERTICAL) self._tone_high_text_box = forms.text_box( parent=self.GetWin(), sizer=_tone_high_sizer, value=self.tone_high, callback=self.set_tone_high, label="4Khz-15Khz", converter=forms.float_converter(), proportion=0, ) self._tone_high_slider = forms.slider( parent=self.GetWin(), sizer=_tone_high_sizer, value=self.tone_high, callback=self.set_tone_high, minimum=0, maximum=10, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_tone_high_sizer, 1, 4, 1, 1) def _squelch_probe_probe(): while True: val = self.input_power.unmuted() try: self.set_squelch_probe(val) except AttributeError, e: pass time.sleep(1.0/(10)) _squelch_probe_thread = threading.Thread(target=_squelch_probe_probe) _squelch_probe_thread.daemon = True _squelch_probe_thread.start() self._record_check_box = forms.check_box( parent=self.GetWin(), value=self.record, callback=self.set_record, label="Record Audio", true=True, false=False, ) self.GridAdd(self._record_check_box, 2, 2, 1, 1) self.pilot_probe = gr.probe_signal_f() _fine_sizer = wx.BoxSizer(wx.VERTICAL) self._fine_text_box = forms.text_box( parent=self.GetWin(), sizer=_fine_sizer, value=self.fine, callback=self.set_fine, label="Fine Tuning", converter=forms.float_converter(), proportion=0, ) self._fine_slider = forms.slider( parent=self.GetWin(), sizer=_fine_sizer, value=self.fine, callback=self.set_fine, minimum=-50.0e3, maximum=50.e03, num_steps=400, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_fine_sizer, 1, 0, 1, 1) def _discrim_dc_probe(): while True: val = self.dc_level.level() try: self.set_discrim_dc(val) except AttributeError, e: pass time.sleep(1.0/(2.5)) _discrim_dc_thread = threading.Thread(target=_discrim_dc_probe) _discrim_dc_thread.daemon = True _discrim_dc_thread.start() self._capture_file_text_box = forms.text_box( parent=self.GetWin(), value=self.capture_file, callback=self.set_capture_file, label="Record Filename", converter=forms.str_converter(), ) self.GridAdd(self._capture_file_text_box, 2, 0, 1, 2) self.Main = self.Main = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.Main.AddPage(grc_wxgui.Panel(self.Main), "L/R") self.Main.AddPage(grc_wxgui.Panel(self.Main), "FM Demod Spectrum") self.Add(self.Main) self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.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="Waterfall Plot", ) self.Add(self.wxgui_waterfallsink2_0.win) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.Main.GetPage(0).GetWin(), title="Audio Channels (L and R)", sample_rate=farate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=2, trig_mode=gr.gr_TRIG_MODE_AUTO, y_axis_label="Rel. Audio Level", ) self.Main.GetPage(0).Add(self.wxgui_scopesink2_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_f( self.Main.GetPage(1).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=asrate, fft_size=1024, fft_rate=6, average=True, avg_alpha=0.1, title="FM Demod Spectrum", peak_hold=False, ) self.Main.GetPage(1).Add(self.wxgui_fftsink2_0.win) self._variable_static_text_0_static_text = forms.static_text( parent=self.GetWin(), value=self.variable_static_text_0, callback=self.set_variable_static_text_0, label="RF Power ", converter=forms.float_converter(formatter=lambda x: "%4.1f" % x), ) self.GridAdd(self._variable_static_text_0_static_text, 0, 2, 1, 1) self._stereo_0_check_box = forms.check_box( parent=self.GetWin(), value=self.stereo_0, callback=self.set_stereo_0, label="Stereo Detect", true=True, false=False, ) self.GridAdd(self._stereo_0_check_box, 2, 5, 1, 1) self._stereo_check_box = forms.check_box( parent=self.GetWin(), value=self.stereo, callback=self.set_stereo, label="Stereo", true=True, false=False, ) self.GridAdd(self._stereo_check_box, 2, 4, 1, 1) self.rtl2832_source_0 = baz.rtl_source_c(defer_creation=True) self.rtl2832_source_0.set_verbose(True) self.rtl2832_source_0.set_vid(0x0) self.rtl2832_source_0.set_pid(0x0) self.rtl2832_source_0.set_tuner_name("") self.rtl2832_source_0.set_default_timeout(0) self.rtl2832_source_0.set_use_buffer(True) self.rtl2832_source_0.set_fir_coefficients(([])) if self.rtl2832_source_0.create() == False: raise Exception("Failed to create RTL2832 Source: rtl2832_source_0") self.rtl2832_source_0.set_sample_rate(1.0e6) self.rtl2832_source_0.set_frequency(cur_freq+200e3) self.rtl2832_source_0.set_auto_gain_mode(False) self.rtl2832_source_0.set_relative_gain(True) self.rtl2832_source_0.set_gain(gain) self._rtext_0_static_text = forms.static_text( parent=self.GetWin(), value=self.rtext_0, callback=self.set_rtext_0, label="CURRENT FREQUENCY>>", converter=forms.float_converter(), ) self.GridAdd(self._rtext_0_static_text, 0, 1, 1, 1) def _rf_pwr_lvl_probe(): while True: val = self.input_power.level() try: self.set_rf_pwr_lvl(val) except AttributeError, e: pass time.sleep(1.0/(2)) _rf_pwr_lvl_thread = threading.Thread(target=_rf_pwr_lvl_probe) _rf_pwr_lvl_thread.daemon = True _rf_pwr_lvl_thread.start() self._preselect_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.preselect, callback=self.set_preselect, label='preselect', choices=eval(prefreqs), labels=eval(prenames), style=wx.RA_HORIZONTAL, ) self.GridAdd(self._preselect_chooser, 0, 4, 1, 1) def _pilot_level_probe(): while True: val = self.pilot_probe.level() try: self.set_pilot_level(val) except AttributeError, e: pass time.sleep(1.0/(5)) _pilot_level_thread = threading.Thread(target=_pilot_level_probe) _pilot_level_thread.daemon = True _pilot_level_thread.start() self.low_pass_filter_3 = gr.fir_filter_fff(1, firdes.low_pass( 3, asrate/500, 10, 3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_2 = gr.fir_filter_fff(10, firdes.low_pass( 3, asrate/50, 100, 30, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_1 = gr.fir_filter_fff(10, firdes.low_pass( 3, asrate/5, 1e3, 200, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = gr.fir_filter_fff(5, firdes.low_pass( 3, asrate, 10e3, 2e3, firdes.WIN_HAMMING, 6.76)) _igain_sizer = wx.BoxSizer(wx.VERTICAL) self._igain_text_box = forms.text_box( parent=self.GetWin(), sizer=_igain_sizer, value=self.igain, callback=self.set_igain, label="RF Gain", converter=forms.float_converter(), proportion=0, ) self._igain_slider = forms.slider( parent=self.GetWin(), sizer=_igain_sizer, value=self.igain, callback=self.set_igain, minimum=0, maximum=50, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_igain_sizer, 1, 1, 1, 1) _ifreq_sizer = wx.BoxSizer(wx.VERTICAL) self._ifreq_text_box = forms.text_box( parent=self.GetWin(), sizer=_ifreq_sizer, value=self.ifreq, callback=self.set_ifreq, label="Center Frequency", converter=forms.float_converter(), proportion=0, ) self._ifreq_slider = forms.slider( parent=self.GetWin(), sizer=_ifreq_sizer, value=self.ifreq, callback=self.set_ifreq, minimum=88.1e6, maximum=108.1e6, num_steps=200, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_ifreq_sizer, 0, 0, 1, 1) self.gr_wavfile_sink_0 = gr.wavfile_sink("/dev/null" if record == False else capture_file, 2, int(farate), 16) self.gr_sub_xx_0 = gr.sub_ff(1) self.gr_single_pole_iir_filter_xx_1 = gr.single_pole_iir_filter_ff(2.5/(asrate/500), 1) self.gr_single_pole_iir_filter_xx_0 = gr.single_pole_iir_filter_ff(1.0/(asrate/3), 1) self.gr_multiply_xx_1 = gr.multiply_vff(1) self.gr_multiply_xx_0_0 = gr.multiply_vff(1) self.gr_multiply_xx_0 = gr.multiply_vff(1) self.gr_multiply_const_vxx_3 = gr.multiply_const_vff((3.16e3 if st_enabled else 0, )) self.gr_multiply_const_vxx_2 = gr.multiply_const_vff((1.0 if st_enabled else 1.414, )) self.gr_multiply_const_vxx_1_0 = gr.multiply_const_vff((0 if st_enabled else 1, )) self.gr_multiply_const_vxx_1 = gr.multiply_const_vff((0 if squelch_probe == 0 else 1.0, )) self.gr_multiply_const_vxx_0_0 = gr.multiply_const_vff((vol*1.5*10.0, )) self.gr_multiply_const_vxx_0 = gr.multiply_const_vff((vol*1.5*10.0 if st_enabled else 0, )) self.gr_keep_one_in_n_0 = gr.keep_one_in_n(gr.sizeof_float*1, int(asrate/3)) self.gr_freq_xlating_fir_filter_xxx_0 = gr.freq_xlating_fir_filter_ccc(4, (osmo_taps), 200e3+fine+(-12e3*discrim_dc), 1.0e6) self.gr_fractional_interpolator_xx_0_0 = gr.fractional_interpolator_ff(0, asrate/farate) self.gr_fractional_interpolator_xx_0 = gr.fractional_interpolator_ff(0, asrate/farate) self.gr_fft_filter_xxx_1_0_0 = gr.fft_filter_fff(1, (firdes.band_pass(tone_high/10.0,asrate,3.5e3,15.0e3,5.0e3,firdes.WIN_HAMMING)), 1) self.gr_fft_filter_xxx_1_0 = gr.fft_filter_fff(1, (firdes.band_pass(tone_med/10.0,asrate,1.0e3,4.0e3,2.0e3,firdes.WIN_HAMMING)), 1) self.gr_fft_filter_xxx_1 = gr.fft_filter_fff(1, (firdes.low_pass(tone_low/10.0,asrate,1.2e3,500,firdes.WIN_HAMMING)), 1) self.gr_fft_filter_xxx_0_0_0 = gr.fft_filter_fff(1, (firdes.band_pass(tone_high/10.0,asrate,3.5e3,13.5e3,3.5e3,firdes.WIN_HAMMING)), 1) self.gr_fft_filter_xxx_0_0 = gr.fft_filter_fff(1, (firdes.band_pass(tone_med/10.0,asrate,1.0e3,4.0e3,2.0e3,firdes.WIN_HAMMING)), 1) self.gr_fft_filter_xxx_0 = gr.fft_filter_fff(1, (firdes.low_pass(tone_low/10.0,asrate,1.2e3,500,firdes.WIN_HAMMING)), 1) self.gr_divide_xx_0 = gr.divide_ff(1) self.gr_agc_xx_1 = gr.agc_cc(1e-2, 0.35, 1.0, 5000) self.gr_add_xx_2_0 = gr.add_vff(1) self.gr_add_xx_2 = gr.add_vff(1) self.gr_add_xx_1 = gr.add_vff(1) self.gr_add_xx_0 = gr.add_vff(1) self.gr_add_const_vxx_0 = gr.add_const_vff((1.0e-7, )) self._dm_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.dm, callback=self.set_dm, label="FM Deemphasis", choices=[75.0e-6, 50.0e-6], labels=["NA", "EU"], style=wx.RA_HORIZONTAL, ) self.GridAdd(self._dm_chooser, 0, 5, 1, 1) self.blks2_wfm_rcv_0 = blks2.wfm_rcv( quad_rate=samp_rate, audio_decimation=2, ) self.blks2_fm_deemph_0_0 = blks2.fm_deemph(fs=farate, tau=deemph) self.blks2_fm_deemph_0 = blks2.fm_deemph(fs=farate, tau=deemph) self.band_pass_filter_2_0 = gr.fir_filter_fff(1, firdes.band_pass( 20, asrate, 17.5e3, 17.9e3, 250, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_2 = gr.fir_filter_fff(1, firdes.band_pass( 10, asrate, 18.8e3, 19.2e3, 350, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0_0 = gr.fir_filter_fff(1, firdes.band_pass( 1, asrate, 38e3-(15e3), 38e3+(15e3), 4.0e3, firdes.WIN_HAMMING, 6.76)) self.audio_sink_0 = audio.sink(int(farate), "" if ahw == "Default" else ahw, True) ################################################## # Connections ################################################## self.connect((self.gr_add_xx_1, 0), (self.gr_fractional_interpolator_xx_0, 0)) self.connect((self.gr_sub_xx_0, 0), (self.gr_fractional_interpolator_xx_0_0, 0)) self.connect((self.band_pass_filter_0_0, 0), (self.gr_multiply_xx_1, 0)) self.connect((self.gr_multiply_const_vxx_1_0, 0), (self.gr_add_xx_0, 0)) self.connect((self.band_pass_filter_2_0, 0), (self.gr_multiply_xx_0, 0)) self.connect((self.band_pass_filter_2_0, 0), (self.gr_multiply_xx_0, 1)) self.connect((self.gr_multiply_xx_0_0, 0), (self.gr_divide_xx_0, 0)) self.connect((self.gr_divide_xx_0, 0), (self.gr_single_pole_iir_filter_xx_0, 0)) self.connect((self.gr_multiply_xx_0, 0), (self.gr_add_const_vxx_0, 0)) self.connect((self.gr_add_const_vxx_0, 0), (self.gr_divide_xx_0, 1)) self.connect((self.gr_single_pole_iir_filter_xx_0, 0), (self.gr_keep_one_in_n_0, 0)) self.connect((self.gr_keep_one_in_n_0, 0), (self.pilot_probe, 0)) self.connect((self.band_pass_filter_2, 0), (self.gr_multiply_xx_1, 2)) self.connect((self.band_pass_filter_2, 0), (self.gr_multiply_xx_0_0, 0)) self.connect((self.gr_multiply_const_vxx_2, 0), (self.gr_add_xx_1, 0)) self.connect((self.gr_multiply_const_vxx_2, 0), (self.gr_sub_xx_0, 0)) self.connect((self.gr_multiply_const_vxx_3, 0), (self.gr_sub_xx_0, 1)) self.connect((self.gr_multiply_const_vxx_3, 0), (self.gr_add_xx_1, 1)) self.connect((self.gr_fractional_interpolator_xx_0, 0), (self.gr_multiply_const_vxx_0_0, 0)) self.connect((self.gr_fractional_interpolator_xx_0_0, 0), (self.gr_multiply_const_vxx_0, 0)) self.connect((self.band_pass_filter_2, 0), (self.gr_multiply_xx_1, 1)) self.connect((self.gr_multiply_xx_1, 0), (self.gr_fft_filter_xxx_0, 0)) self.connect((self.gr_fft_filter_xxx_1, 0), (self.gr_add_xx_2, 0)) self.connect((self.gr_fft_filter_xxx_1_0, 0), (self.gr_add_xx_2, 1)) self.connect((self.gr_fft_filter_xxx_1_0_0, 0), (self.gr_add_xx_2, 2)) self.connect((self.gr_add_xx_2, 0), (self.gr_multiply_const_vxx_2, 0)) self.connect((self.gr_add_xx_2_0, 0), (self.gr_multiply_const_vxx_3, 0)) self.connect((self.gr_fft_filter_xxx_0, 0), (self.gr_add_xx_2_0, 0)) self.connect((self.gr_fft_filter_xxx_0_0, 0), (self.gr_add_xx_2_0, 1)) self.connect((self.gr_multiply_xx_1, 0), (self.gr_fft_filter_xxx_0_0, 0)) self.connect((self.gr_fft_filter_xxx_0_0_0, 0), (self.gr_add_xx_2_0, 2)) self.connect((self.gr_multiply_xx_1, 0), (self.gr_fft_filter_xxx_0_0_0, 0)) self.connect((self.blks2_fm_deemph_0, 0), (self.gr_multiply_const_vxx_1_0, 0)) self.connect((self.blks2_fm_deemph_0, 0), (self.gr_wavfile_sink_0, 0)) self.connect((self.gr_multiply_const_vxx_1, 0), (self.gr_fft_filter_xxx_1, 0)) self.connect((self.gr_multiply_const_vxx_1, 0), (self.gr_fft_filter_xxx_1_0, 0)) self.connect((self.gr_multiply_const_vxx_1, 0), (self.gr_fft_filter_xxx_1_0_0, 0)) self.connect((self.gr_multiply_const_vxx_1, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.gr_multiply_const_vxx_0_0, 0), (self.blks2_fm_deemph_0, 0)) self.connect((self.gr_add_xx_0, 0), (self.audio_sink_0, 1)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.blks2_fm_deemph_0_0, 0)) self.connect((self.blks2_fm_deemph_0_0, 0), (self.gr_add_xx_0, 1)) self.connect((self.band_pass_filter_2, 0), (self.gr_multiply_xx_0_0, 1)) self.connect((self.gr_multiply_const_vxx_1, 0), (self.band_pass_filter_2, 0)) self.connect((self.blks2_fm_deemph_0, 0), (self.audio_sink_0, 0)) self.connect((self.gr_multiply_const_vxx_1, 0), (self.band_pass_filter_2_0, 0)) self.connect((self.gr_multiply_const_vxx_1, 0), (self.band_pass_filter_0_0, 0)) self.connect((self.gr_add_xx_0, 0), (self.gr_wavfile_sink_0, 1)) self.connect((self.blks2_fm_deemph_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.gr_add_xx_0, 0), (self.wxgui_scopesink2_0, 1)) self.connect((self.blks2_wfm_rcv_0, 0), (self.gr_multiply_const_vxx_1, 0)) self.connect((self.gr_agc_xx_1, 0), (self.blks2_wfm_rcv_0, 0)) self.connect((self.gr_freq_xlating_fir_filter_xxx_0, 0), (self.gr_agc_xx_1, 0)) self.connect((self.gr_freq_xlating_fir_filter_xxx_0, 0), (self.input_power, 0)) self.connect((self.blks2_wfm_rcv_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.low_pass_filter_1, 0), (self.low_pass_filter_2, 0)) self.connect((self.low_pass_filter_2, 0), (self.low_pass_filter_3, 0)) self.connect((self.gr_single_pole_iir_filter_xx_1, 0), (self.dc_level, 0)) self.connect((self.low_pass_filter_3, 0), (self.gr_single_pole_iir_filter_xx_1, 0)) self.connect((self.rtl2832_source_0, 0), (self.gr_freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.gr_freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_waterfallsink2_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Fm Stereo Tx") ################################################## # Variables ################################################## self.st_gain = st_gain = 10 self.samp_rate = samp_rate = 195.312e3 self.pilot_gain = pilot_gain = 80e-3 self.mpx_rate = mpx_rate = 160e3 self.Mono_gain = Mono_gain = 300e-3 self.FM_freq = FM_freq = 96.5e6 ################################################## # Blocks ################################################## _st_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._st_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_st_gain_sizer, value=self.st_gain, callback=self.set_st_gain, label='st_gain', converter=forms.float_converter(), proportion=0, ) self._st_gain_slider = forms.slider( parent=self.GetWin(), sizer=_st_gain_sizer, value=self.st_gain, callback=self.set_st_gain, minimum=0, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_st_gain_sizer) _pilot_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._pilot_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_pilot_gain_sizer, value=self.pilot_gain, callback=self.set_pilot_gain, label='pilot_gain', converter=forms.float_converter(), proportion=0, ) self._pilot_gain_slider = forms.slider( parent=self.GetWin(), sizer=_pilot_gain_sizer, value=self.pilot_gain, callback=self.set_pilot_gain, minimum=0, maximum=1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_pilot_gain_sizer) self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "FM") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "audio") self.Add(self.notebook_0) _Mono_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._Mono_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_Mono_gain_sizer, value=self.Mono_gain, callback=self.set_Mono_gain, label='Mono_gain', converter=forms.float_converter(), proportion=0, ) self._Mono_gain_slider = forms.slider( parent=self.GetWin(), sizer=_Mono_gain_sizer, value=self.Mono_gain, callback=self.set_Mono_gain, minimum=0, maximum=1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_Mono_gain_sizer) _FM_freq_sizer = wx.BoxSizer(wx.VERTICAL) self._FM_freq_text_box = forms.text_box( parent=self.GetWin(), sizer=_FM_freq_sizer, value=self.FM_freq, callback=self.set_FM_freq, label='FM_freq', converter=forms.float_converter(), proportion=0, ) self._FM_freq_slider = forms.slider( parent=self.GetWin(), sizer=_FM_freq_sizer, value=self.FM_freq, callback=self.set_FM_freq, minimum=88e6, maximum=108e6, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_FM_freq_sizer) self.wxgui_fftsink2_1 = fftsink2.fft_sink_f( self.notebook_0.GetPage(1).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.notebook_0.GetPage(1).Add(self.wxgui_fftsink2_1.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.notebook_0.GetPage(0).GetWin(), baseband_freq=FM_freq, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.notebook_0.GetPage(0).Add(self.wxgui_fftsink2_0.win) self.uhd_usrp_sink_0 = uhd.usrp_sink( device_addr="addr=192.168.10.2", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(FM_freq, 0) self.uhd_usrp_sink_0.set_gain(0, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) self.low_pass_filter_0 = gr.fir_filter_fff( 1, firdes.low_pass(Mono_gain, mpx_rate, 15000, 2000, firdes.WIN_HAMMING, 6.76)) self.gr_vector_to_streams_0 = gr.vector_to_streams( gr.sizeof_short * 1, 2) self.gr_sub_xx_0 = gr.sub_ff(1) self.gr_sig_source_x_1 = gr.sig_source_f(160000, gr.GR_SIN_WAVE, 19000, pilot_gain, 0) self.gr_sig_source_x_0 = gr.sig_source_f(160000, gr.GR_SIN_WAVE, 38000, 30e-3, 0) self.gr_short_to_float_1 = gr.short_to_float(1, 1) self.gr_short_to_float_0 = gr.short_to_float(1, 1) self.gr_multiply_xx_0 = gr.multiply_vff(1) self.gr_multiply_const_vxx_2 = gr.multiply_const_vcc((32.768e3, )) self.gr_multiply_const_vxx_1 = gr.multiply_const_vff((30e-6, )) self.gr_multiply_const_vxx_0 = gr.multiply_const_vff((30e-6, )) self.gr_frequency_modulator_fc_0 = gr.frequency_modulator_fc(980e-3) self.gr_file_source_0 = gr.file_source( gr.sizeof_short * 2, "/home/kranthi/Documents/project/FM Transceiver/FM Transmitter/test.raw", True) self.gr_add_xx_1 = gr.add_vff(1) self.gr_add_xx_0 = gr.add_vff(1) self.blks2_rational_resampler_xxx_2 = blks2.rational_resampler_fff( interpolation=4, decimation=1, taps=None, fractional_bw=None, ) self.blks2_rational_resampler_xxx_1 = blks2.rational_resampler_fff( interpolation=5, decimation=1, taps=None, fractional_bw=None, ) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_fff( interpolation=5, decimation=1, taps=None, fractional_bw=None, ) self.blks2_fm_preemph_0 = blks2.fm_preemph(fs=mpx_rate, tau=50e-6) self.band_pass_filter_0 = gr.fir_filter_fff( 1, firdes.band_pass(st_gain, mpx_rate, 23000, 53000, 2000, firdes.WIN_HAMMING, 6.76)) ################################################## # Connections ################################################## self.connect((self.gr_file_source_0, 0), (self.gr_vector_to_streams_0, 0)) self.connect((self.gr_vector_to_streams_0, 0), (self.gr_short_to_float_0, 0)) self.connect((self.gr_vector_to_streams_0, 1), (self.gr_short_to_float_1, 0)) self.connect((self.gr_short_to_float_0, 0), (self.gr_multiply_const_vxx_0, 0)) self.connect((self.gr_short_to_float_1, 0), (self.gr_multiply_const_vxx_1, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.blks2_rational_resampler_xxx_0, 0)) self.connect((self.gr_multiply_const_vxx_1, 0), (self.blks2_rational_resampler_xxx_1, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.gr_add_xx_0, 1)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.gr_sub_xx_0, 1)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.gr_sub_xx_0, 0)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.gr_add_xx_0, 0)) self.connect((self.gr_add_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_xx_0, 0)) self.connect((self.gr_sub_xx_0, 0), (self.gr_multiply_xx_0, 1)) self.connect((self.gr_multiply_xx_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.gr_sig_source_x_1, 0), (self.gr_add_xx_1, 0)) self.connect((self.band_pass_filter_0, 0), (self.gr_add_xx_1, 1)) self.connect((self.low_pass_filter_0, 0), (self.gr_add_xx_1, 2)) self.connect((self.gr_add_xx_1, 0), (self.blks2_fm_preemph_0, 0)) self.connect((self.blks2_fm_preemph_0, 0), (self.blks2_rational_resampler_xxx_2, 0)) self.connect((self.blks2_rational_resampler_xxx_2, 0), (self.gr_frequency_modulator_fc_0, 0)) self.connect((self.gr_frequency_modulator_fc_0, 0), (self.gr_multiply_const_vxx_2, 0)) self.connect((self.gr_multiply_const_vxx_2, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.gr_multiply_const_vxx_2, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.gr_multiply_const_vxx_1, 0), (self.wxgui_fftsink2_1, 0))
def __init__(self, ahw="default", freq=150.0e6, ppm=0.0, vol=1.0, ftune=0.0, xftune=0.0, srate=1.0e6, upclo=0.0, devinfo="rtl=0", agc=0, arate=48.0e3, upce=0, mthresh=-10.0, offs=50.e3, flist="", dfifo="multimode_fifo", mbw=2.0e3, deemph=75.0e-6, dmode="NFM1"): grc_wxgui.top_block_gui.__init__(self, title="Multimode Radio Receiver") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Parameters ################################################## self.ahw = ahw self.freq = freq self.ppm = ppm self.vol = vol self.ftune = ftune self.xftune = xftune self.srate = srate self.upclo = upclo self.devinfo = devinfo self.agc = agc self.arate = arate self.upce = upce self.mthresh = mthresh self.offs = offs self.flist = flist self.dfifo = dfifo self.mbw = mbw self.deemph = deemph self.dmode = dmode ################################################## # Variables ################################################## self.sc_list_str = sc_list_str = flist self.zoom = zoom = 1 self.thresh = thresh = mthresh self.scan_rate = scan_rate = 15 self.scan_power = scan_power = 0 self.sc_low = sc_low = 150e6 self.sc_listm = sc_listm = False self.sc_list = sc_list = eval("["+sc_list_str+"]") self.sc_incr = sc_incr = 12.5e3 self.sc_high = sc_high = 300e6 self.sc_ena = sc_ena = False self.samp_rate = samp_rate = int(mh.get_good_rate(devinfo,srate)) self.rf_power = rf_power = 0 self.ifreq = ifreq = freq self.zoomed_lp = zoomed_lp = (samp_rate/2.1)/zoom self.wbfm = wbfm = 200e3 self.rf_d_power = rf_d_power = 0 self.mode = mode = dmode self.logpower = logpower = math.log10(rf_power+1.0e-14)*10.0 self.cur_freq = cur_freq = mh.scan_freq_out(sc_ena,sc_low,sc_high,freq,ifreq,scan_power+1.0e-14,thresh,sc_incr,scan_rate,sc_listm,sc_list) self.bw = bw = mbw self.audio_int_rate = audio_int_rate = 40e3 self.zoom_taps = zoom_taps = firdes.low_pass(1.0,samp_rate,zoomed_lp,zoomed_lp/3,firdes.WIN_HAMMING,6.76) self.xfine = xfine = xftune self.volume = volume = vol self.variable_static_text_1 = variable_static_text_1 = cur_freq self.variable_static_text_0_0 = variable_static_text_0_0 = samp_rate self.variable_static_text_0 = variable_static_text_0 = float(int(math.log10(rf_d_power+1.0e-14)*100.0)/10.0) self.upc_offset = upc_offset = upclo self.upc = upc = upce self.ssbo = ssbo = -bw/2 if mode == "LSB" else 0.0 self.sc_list_len = sc_list_len = len(sc_list) self.rfgain = rfgain = 25 self.record_file = record_file = "recording.wav" self.record = record = False self.offset = offset = offs self.muted = muted = 0.0 if logpower >= thresh else 1 self.main_taps = main_taps = firdes.low_pass(1.0,wbfm,mh.get_mode_deviation(mode,bw)*1.05,mh.get_mode_deviation(mode,bw)/2.0,firdes.WIN_HAMMING,6.76) self.k = k = wbfm/(2*math.pi*mh.get_mode_deviation(mode,bw)) self.iagc = iagc = agc self.freq_update = freq_update = 0 self.fine = fine = ftune self.digi_rate = digi_rate = 50e3 self.aratio = aratio = int(wbfm/audio_int_rate) ################################################## # Blocks ################################################## self.rf_probe = gr.probe_avg_mag_sqrd_c(0, 0.015) self.Main = self.Main = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.Main.AddPage(grc_wxgui.Panel(self.Main), "Main Controls") self.Main.AddPage(grc_wxgui.Panel(self.Main), "Scan/Upconv Controls") self.Add(self.Main) self._zoom_chooser = forms.drop_down( parent=self.Main.GetPage(0).GetWin(), value=self.zoom, callback=self.set_zoom, label="Spectral Zoom Ratio", choices=[1, 2, 5, 10, 20, 50, 100], labels=[], ) self.Main.GetPage(0).GridAdd(self._zoom_chooser, 1, 4, 1, 1) _xfine_sizer = wx.BoxSizer(wx.VERTICAL) self._xfine_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), sizer=_xfine_sizer, value=self.xfine, callback=self.set_xfine, label="Extra Fine Tuning", converter=forms.float_converter(), proportion=0, ) self._xfine_slider = forms.slider( parent=self.Main.GetPage(0).GetWin(), sizer=_xfine_sizer, value=self.xfine, callback=self.set_xfine, minimum=-1.0e3, maximum=1.0e3, num_steps=200, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Main.GetPage(0).GridAdd(_xfine_sizer, 0, 3, 1, 1) _volume_sizer = wx.BoxSizer(wx.VERTICAL) self._volume_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, label="Volume", converter=forms.float_converter(), proportion=0, ) self._volume_slider = forms.slider( parent=self.Main.GetPage(0).GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, minimum=1.0, maximum=10.0, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Main.GetPage(0).GridAdd(_volume_sizer, 0, 0, 1, 1) self._upc_offset_text_box = forms.text_box( parent=self.Main.GetPage(1).GetWin(), value=self.upc_offset, callback=self.set_upc_offset, label="Upconv. LO Freq", converter=forms.float_converter(), ) self.Main.GetPage(1).GridAdd(self._upc_offset_text_box, 3, 2, 1, 2) self._upc_check_box = forms.check_box( parent=self.Main.GetPage(1).GetWin(), value=self.upc, callback=self.set_upc, label="Ext. Upconv.", true=1, false=0, ) self.Main.GetPage(1).GridAdd(self._upc_check_box, 3, 0, 1, 1) _rfgain_sizer = wx.BoxSizer(wx.VERTICAL) self._rfgain_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), sizer=_rfgain_sizer, value=self.rfgain, callback=self.set_rfgain, label="RF Gain", converter=forms.float_converter(), proportion=0, ) self._rfgain_slider = forms.slider( parent=self.Main.GetPage(0).GetWin(), sizer=_rfgain_sizer, value=self.rfgain, callback=self.set_rfgain, minimum=0, maximum=50, num_steps=200, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Main.GetPage(0).GridAdd(_rfgain_sizer, 2, 1, 1, 1) self._record_file_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), value=self.record_file, callback=self.set_record_file, label="Recording Filename", converter=forms.str_converter(), ) self.Main.GetPage(0).GridAdd(self._record_file_text_box, 2, 3, 1, 3) self._record_check_box = forms.check_box( parent=self.Main.GetPage(0).GetWin(), value=self.record, callback=self.set_record, label="Record", true=True, false=False, ) self.Main.GetPage(0).GridAdd(self._record_check_box, 2, 2, 1, 1) _offset_sizer = wx.BoxSizer(wx.VERTICAL) self._offset_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), sizer=_offset_sizer, value=self.offset, callback=self.set_offset, label="LO Offset", converter=forms.float_converter(), proportion=0, ) self._offset_slider = forms.slider( parent=self.Main.GetPage(0).GetWin(), sizer=_offset_sizer, value=self.offset, callback=self.set_offset, minimum=25e3, maximum=500e3, num_steps=200, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Main.GetPage(0).GridAdd(_offset_sizer, 1, 3, 1, 1) self._mode_chooser = forms.drop_down( parent=self.Main.GetPage(0).GetWin(), value=self.mode, callback=self.set_mode, label="Mode", choices=mh.get_modes_values(), labels=mh.get_modes_names(), ) self.Main.GetPage(0).GridAdd(self._mode_chooser, 0, 4, 1, 1) self._iagc_check_box = forms.check_box( parent=self.Main.GetPage(0).GetWin(), value=self.iagc, callback=self.set_iagc, label="AGC", true=1, false=0, ) self.Main.GetPage(0).GridAdd(self._iagc_check_box, 2, 0, 1, 1) def _freq_update_probe(): while True: val = self.rf_probe.level() try: self.set_freq_update(val) except AttributeError, e: pass time.sleep(1.0/(1.0/(2.5))) _freq_update_thread = threading.Thread(target=_freq_update_probe) _freq_update_thread.daemon = True _freq_update_thread.start() _fine_sizer = wx.BoxSizer(wx.VERTICAL) self._fine_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), sizer=_fine_sizer, value=self.fine, callback=self.set_fine, label="Fine Tuning", converter=forms.float_converter(), proportion=0, ) self._fine_slider = forms.slider( parent=self.Main.GetPage(0).GetWin(), sizer=_fine_sizer, value=self.fine, callback=self.set_fine, minimum=-35e3, maximum=35e3, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Main.GetPage(0).GridAdd(_fine_sizer, 0, 2, 1, 1) self.display_probe = gr.probe_avg_mag_sqrd_c(0, 0.002) _bw_sizer = wx.BoxSizer(wx.VERTICAL) self._bw_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), sizer=_bw_sizer, value=self.bw, callback=self.set_bw, label="AM/SSB Bandwidth", converter=forms.float_converter(), proportion=0, ) self._bw_slider = forms.slider( parent=self.Main.GetPage(0).GetWin(), sizer=_bw_sizer, value=self.bw, callback=self.set_bw, minimum=1.0e3, maximum=audio_int_rate/2, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Main.GetPage(0).GridAdd(_bw_sizer, 1, 2, 1, 1) self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.Main.GetPage(0).GetWin(), baseband_freq=mh.get_last_returned(freq_update), dynamic_range=40, ref_level=0, ref_scale=2.0, sample_rate=samp_rate/zoom, fft_size=1024, fft_rate=4, average=True, avg_alpha=None, title="Spectrogram", win=window.hamming, ) self.Main.GetPage(0).Add(self.wxgui_waterfallsink2_0.win) def wxgui_waterfallsink2_0_callback(x, y): self.set_freq(x) self.wxgui_waterfallsink2_0.set_callback(wxgui_waterfallsink2_0_callback) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.Main.GetPage(0).GetWin(), baseband_freq=mh.get_last_returned(freq_update), y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate/zoom, fft_size=1024, fft_rate=4, average=True, avg_alpha=0.1, title="Panorama", peak_hold=False, win=window.hamming, ) self.Main.GetPage(0).Add(self.wxgui_fftsink2_0.win) def wxgui_fftsink2_0_callback(x, y): self.set_freq(x) self.wxgui_fftsink2_0.set_callback(wxgui_fftsink2_0_callback) self._variable_static_text_1_static_text = forms.static_text( parent=self.Main.GetPage(1).GetWin(), value=self.variable_static_text_1, callback=self.set_variable_static_text_1, label="Current Scan Freq", converter=forms.float_converter(), ) self.Main.GetPage(1).GridAdd(self._variable_static_text_1_static_text, 0, 5, 1, 2) self._variable_static_text_0_0_static_text = forms.static_text( parent=self.Main.GetPage(0).GetWin(), value=self.variable_static_text_0_0, callback=self.set_variable_static_text_0_0, label="Actual srate", converter=forms.float_converter(), ) self.Main.GetPage(0).GridAdd(self._variable_static_text_0_0_static_text, 1, 5, 1, 1) self._variable_static_text_0_static_text = forms.static_text( parent=self.Main.GetPage(0).GetWin(), value=self.variable_static_text_0, callback=self.set_variable_static_text_0, label="RF Level", converter=forms.float_converter(), ) self.Main.GetPage(0).GridAdd(self._variable_static_text_0_static_text, 1, 0, 1, 1) _thresh_sizer = wx.BoxSizer(wx.VERTICAL) self._thresh_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), sizer=_thresh_sizer, value=self.thresh, callback=self.set_thresh, label="Mute Threshold", converter=forms.float_converter(), proportion=0, ) self._thresh_slider = forms.slider( parent=self.Main.GetPage(0).GetWin(), sizer=_thresh_sizer, value=self.thresh, callback=self.set_thresh, minimum=-50, maximum=10, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Main.GetPage(0).GridAdd(_thresh_sizer, 1, 1, 1, 1) def _scan_power_probe(): while True: val = self.rf_probe.level() try: self.set_scan_power(val) except AttributeError, e: pass time.sleep(1.0/(scan_rate)) _scan_power_thread = threading.Thread(target=_scan_power_probe) _scan_power_thread.daemon = True _scan_power_thread.start() self._sc_low_text_box = forms.text_box( parent=self.Main.GetPage(1).GetWin(), value=self.sc_low, callback=self.set_sc_low, label="Scan Low", converter=forms.float_converter(), ) self.Main.GetPage(1).GridAdd(self._sc_low_text_box, 0, 1, 1, 1) self._sc_listm_check_box = forms.check_box( parent=self.Main.GetPage(1).GetWin(), value=self.sc_listm, callback=self.set_sc_listm, label="Scan List Mode", true=True, false=False, ) self.Main.GetPage(1).GridAdd(self._sc_listm_check_box, 2, 0, 1, 1) self._sc_list_str_text_box = forms.text_box( parent=self.Main.GetPage(1).GetWin(), value=self.sc_list_str, callback=self.set_sc_list_str, label="Scan List", converter=forms.str_converter(), ) self.Main.GetPage(1).GridAdd(self._sc_list_str_text_box, 2, 1, 1, 5) self._sc_incr_chooser = forms.drop_down( parent=self.Main.GetPage(1).GetWin(), value=self.sc_incr, callback=self.set_sc_incr, label="Scan Increment (Hz)", choices=[5.0e3,6.25e3,10.0e3,12.5e3,15e3,25e3], labels=[], ) self.Main.GetPage(1).GridAdd(self._sc_incr_chooser, 0, 0, 1, 1) self._sc_high_text_box = forms.text_box( parent=self.Main.GetPage(1).GetWin(), value=self.sc_high, callback=self.set_sc_high, label="Scan High", converter=forms.float_converter(), ) self.Main.GetPage(1).GridAdd(self._sc_high_text_box, 0, 2, 1, 1) self._sc_ena_check_box = forms.check_box( parent=self.Main.GetPage(1).GetWin(), value=self.sc_ena, callback=self.set_sc_ena, label="Scan Enable", true=True, false=False, ) self.Main.GetPage(1).GridAdd(self._sc_ena_check_box, 0, 3, 1, 1) def _rf_power_probe(): while True: val = self.rf_probe.level() try: self.set_rf_power(val) except AttributeError, e: pass time.sleep(1.0/(10)) _rf_power_thread = threading.Thread(target=_rf_power_probe) _rf_power_thread.daemon = True _rf_power_thread.start() def _rf_d_power_probe(): while True: val = self.display_probe.level() try: self.set_rf_d_power(val) except AttributeError, e: pass time.sleep(1.0/(5)) _rf_d_power_thread = threading.Thread(target=_rf_d_power_probe) _rf_d_power_thread.daemon = True _rf_d_power_thread.start() self.osmosdr_source_c_0 = osmosdr.source_c( args="nchan=" + str(1) + " " + devinfo ) self.osmosdr_source_c_0.set_sample_rate(samp_rate) self.osmosdr_source_c_0.set_center_freq(cur_freq+offset+(upc_offset*float(upc)), 0) self.osmosdr_source_c_0.set_freq_corr(ppm, 0) self.osmosdr_source_c_0.set_gain_mode(iagc, 0) self.osmosdr_source_c_0.set_gain(25 if iagc == 1 else rfgain, 0) self.osmosdr_source_c_0.set_if_gain(20, 0) self._ifreq_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), value=self.ifreq, callback=self.set_ifreq, label="Frequency", converter=forms.float_converter(), ) self.Main.GetPage(0).GridAdd(self._ifreq_text_box, 0, 1, 1, 1) self.gr_wavfile_sink_0 = gr.wavfile_sink("/dev/null" if record == False else record_file, 1, int(audio_int_rate), 8) self.gr_quadrature_demod_cf_0 = gr.quadrature_demod_cf(k) self.gr_multiply_const_vxx_2 = gr.multiply_const_vff((1.0 if mh.get_mode_type(mode) == "FM" else 0.0, )) self.gr_multiply_const_vxx_1 = gr.multiply_const_vff((0.0 if muted else volume/4.5, )) self.gr_multiply_const_vxx_0_0_0 = gr.multiply_const_vff((0.85 if mh.get_mode_type(mode) == "AM" else 0.0, )) self.gr_multiply_const_vxx_0_0 = gr.multiply_const_vff((0.85 if mh.get_mode_type(mode) == "SSB" else 0.0, )) self.gr_multiply_const_vxx_0 = gr.multiply_const_vcc(((1.0/math.sqrt(mh.get_mode_deviation(mode,bw))*250), )) self.gr_keep_one_in_n_1 = gr.keep_one_in_n(gr.sizeof_gr_complex*1, aratio) self.gr_keep_one_in_n_0_0 = gr.keep_one_in_n(gr.sizeof_gr_complex*1, zoom) self.gr_keep_one_in_n_0 = gr.keep_one_in_n(gr.sizeof_gr_complex*1, int(wbfm/digi_rate)) self.gr_freq_xlating_fir_filter_xxx_0_1 = gr.freq_xlating_fir_filter_ccc(1, (1.0, ), (offset+fine+xfine)/(samp_rate/1.0e6), samp_rate) self.gr_fractional_interpolator_xx_0 = gr.fractional_interpolator_ff(0, audio_int_rate/arate) self.gr_file_sink_0 = gr.file_sink(gr.sizeof_gr_complex*1, "/dev/null" if mh.get_mode_type(mode) != "DIG" else dfifo) self.gr_file_sink_0.set_unbuffered(True) self.gr_fft_filter_xxx_3 = gr.fft_filter_ccc(1, (zoom_taps), 1) self.gr_fft_filter_xxx_2_0 = gr.fft_filter_fff(5, (firdes.low_pass(1.0,wbfm,14.5e3,8.5e3,firdes.WIN_HAMMING,6.76)), 1) self.gr_fft_filter_xxx_2 = gr.fft_filter_ccc(1, (main_taps), 1) self.gr_fft_filter_xxx_0 = gr.fft_filter_ccc(int(samp_rate/wbfm), (firdes.low_pass(1.0,samp_rate,98.5e3,66e3,firdes.WIN_HAMMING,6.76)), 1) self.gr_feedforward_agc_cc_0 = gr.feedforward_agc_cc(1024, 0.75) self.gr_complex_to_real_0 = gr.complex_to_real(1) self.gr_complex_to_mag_squared_0 = gr.complex_to_mag_squared(1) self.gr_add_xx_0 = gr.add_vff(1) self.blks2_fm_deemph_0 = blks2.fm_deemph(fs=audio_int_rate, tau=deemph) self.audio_sink_0 = audio.sink(int(arate), ahw, True) ################################################## # Connections ################################################## self.connect((self.gr_multiply_const_vxx_0_0, 0), (self.gr_add_xx_0, 1)) self.connect((self.gr_fractional_interpolator_xx_0, 0), (self.gr_multiply_const_vxx_1, 0)) self.connect((self.gr_multiply_const_vxx_1, 0), (self.audio_sink_0, 0)) self.connect((self.gr_multiply_const_vxx_1, 0), (self.audio_sink_0, 1)) self.connect((self.gr_feedforward_agc_cc_0, 0), (self.gr_complex_to_mag_squared_0, 0)) self.connect((self.osmosdr_source_c_0, 0), (self.gr_freq_xlating_fir_filter_xxx_0_1, 0)) self.connect((self.gr_multiply_const_vxx_0_0_0, 0), (self.gr_add_xx_0, 2)) self.connect((self.gr_feedforward_agc_cc_0, 0), (self.gr_complex_to_real_0, 0)) self.connect((self.gr_complex_to_real_0, 0), (self.gr_multiply_const_vxx_0_0, 0)) self.connect((self.gr_multiply_const_vxx_2, 0), (self.gr_add_xx_0, 0)) self.connect((self.gr_complex_to_mag_squared_0, 0), (self.gr_multiply_const_vxx_0_0_0, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.display_probe, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.rf_probe, 0)) self.connect((self.gr_add_xx_0, 0), (self.gr_fractional_interpolator_xx_0, 0)) self.connect((self.gr_add_xx_0, 0), (self.gr_wavfile_sink_0, 0)) self.connect((self.gr_freq_xlating_fir_filter_xxx_0_1, 0), (self.gr_fft_filter_xxx_0, 0)) self.connect((self.gr_keep_one_in_n_0, 0), (self.gr_file_sink_0, 0)) self.connect((self.gr_freq_xlating_fir_filter_xxx_0_1, 0), (self.gr_fft_filter_xxx_3, 0)) self.connect((self.gr_fft_filter_xxx_3, 0), (self.gr_keep_one_in_n_0_0, 0)) self.connect((self.gr_keep_one_in_n_0_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.gr_keep_one_in_n_0_0, 0), (self.wxgui_waterfallsink2_0, 0)) self.connect((self.blks2_fm_deemph_0, 0), (self.gr_multiply_const_vxx_2, 0)) self.connect((self.gr_quadrature_demod_cf_0, 0), (self.gr_fft_filter_xxx_2_0, 0)) self.connect((self.gr_fft_filter_xxx_2, 0), (self.gr_keep_one_in_n_0, 0)) self.connect((self.gr_fft_filter_xxx_2, 0), (self.gr_multiply_const_vxx_0, 0)) self.connect((self.gr_fft_filter_xxx_0, 0), (self.gr_fft_filter_xxx_2, 0)) self.connect((self.gr_keep_one_in_n_1, 0), (self.gr_feedforward_agc_cc_0, 0)) self.connect((self.gr_fft_filter_xxx_2, 0), (self.gr_keep_one_in_n_1, 0)) self.connect((self.gr_fft_filter_xxx_2, 0), (self.gr_quadrature_demod_cf_0, 0)) self.connect((self.gr_fft_filter_xxx_2_0, 0), (self.blks2_fm_deemph_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Scrambler") _icon_path = "/home/pfb/.local/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.gr_add_xx_0 = gr.add_vff(1) self.gr_char_to_float_0 = gr.char_to_float() self.gr_interp_fir_filter_xxx_0 = gr.interp_fir_filter_fff(4, (24, )) self.gr_multiply_xx_0 = gr.multiply_vff(1) self.gr_scrambler_bb_0 = gr.scrambler_bb(0x8A, 0x7F, 7) self.gr_throttle_0 = gr.throttle(gr.sizeof_char*1, samp_rate) self.gr_vector_source_x_0 = gr.vector_source_b((0, 0, 0), True, 1) self.gr_vector_source_x_0_0 = gr.vector_source_f((-0.5, ), True, 1) self.gr_vector_source_x_0_0_0 = gr.vector_source_f((2.0, ), True, 1) self.wxgui_fftsink2_0 = fftsink2.fft_sink_f( self.GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=50, ref_scale=2.0, sample_rate=samp_rate * 2, fft_size=4096, fft_rate=30, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.GetWin(), title="Scope Plot", sample_rate=samp_rate, v_scale=1, v_offset=0, t_scale=.0005, ac_couple=False, xy_mode=False, num_inputs=1, ) self.Add(self.wxgui_scopesink2_0.win) ################################################## # Connections ################################################## self.connect((self.gr_scrambler_bb_0, 0), (self.gr_char_to_float_0, 0)) self.connect((self.gr_vector_source_x_0, 0), (self.gr_throttle_0, 0)) self.connect((self.gr_throttle_0, 0), (self.gr_scrambler_bb_0, 0)) self.connect((self.gr_char_to_float_0, 0), (self.gr_add_xx_0, 1)) self.connect((self.gr_add_xx_0, 0), (self.gr_multiply_xx_0, 1)) self.connect((self.gr_vector_source_x_0_0, 0), (self.gr_add_xx_0, 0)) self.connect((self.gr_vector_source_x_0_0_0, 0), (self.gr_multiply_xx_0, 0)) self.connect((self.gr_multiply_xx_0, 0), (self.gr_interp_fir_filter_xxx_0, 0)) self.connect((self.gr_interp_fir_filter_xxx_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.gr_interp_fir_filter_xxx_0, 0), (self.wxgui_scopesink2_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Fm Stereo Tx") ################################################## # Variables ################################################## self.st_gain = st_gain = 10 self.samp_rate = samp_rate = 195.312e3 self.pilot_gain = pilot_gain = 80e-3 self.mpx_rate = mpx_rate = 160e3 self.Mono_gain = Mono_gain = 300e-3 self.FM_freq = FM_freq = 96.5e6 ################################################## # Blocks ################################################## _st_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._st_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_st_gain_sizer, value=self.st_gain, callback=self.set_st_gain, label='st_gain', converter=forms.float_converter(), proportion=0, ) self._st_gain_slider = forms.slider( parent=self.GetWin(), sizer=_st_gain_sizer, value=self.st_gain, callback=self.set_st_gain, minimum=0, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_st_gain_sizer) _pilot_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._pilot_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_pilot_gain_sizer, value=self.pilot_gain, callback=self.set_pilot_gain, label='pilot_gain', converter=forms.float_converter(), proportion=0, ) self._pilot_gain_slider = forms.slider( parent=self.GetWin(), sizer=_pilot_gain_sizer, value=self.pilot_gain, callback=self.set_pilot_gain, minimum=0, maximum=1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_pilot_gain_sizer) self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "FM") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "audio") self.Add(self.notebook_0) _Mono_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._Mono_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_Mono_gain_sizer, value=self.Mono_gain, callback=self.set_Mono_gain, label='Mono_gain', converter=forms.float_converter(), proportion=0, ) self._Mono_gain_slider = forms.slider( parent=self.GetWin(), sizer=_Mono_gain_sizer, value=self.Mono_gain, callback=self.set_Mono_gain, minimum=0, maximum=1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_Mono_gain_sizer) _FM_freq_sizer = wx.BoxSizer(wx.VERTICAL) self._FM_freq_text_box = forms.text_box( parent=self.GetWin(), sizer=_FM_freq_sizer, value=self.FM_freq, callback=self.set_FM_freq, label='FM_freq', converter=forms.float_converter(), proportion=0, ) self._FM_freq_slider = forms.slider( parent=self.GetWin(), sizer=_FM_freq_sizer, value=self.FM_freq, callback=self.set_FM_freq, minimum=88e6, maximum=108e6, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_FM_freq_sizer) self.wxgui_fftsink2_1 = fftsink2.fft_sink_f( self.notebook_0.GetPage(1).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.notebook_0.GetPage(1).Add(self.wxgui_fftsink2_1.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.notebook_0.GetPage(0).GetWin(), baseband_freq=FM_freq, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.notebook_0.GetPage(0).Add(self.wxgui_fftsink2_0.win) self.uhd_usrp_sink_0 = uhd.usrp_sink( device_addr="addr=192.168.10.2", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(FM_freq, 0) self.uhd_usrp_sink_0.set_gain(0, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) self.low_pass_filter_0 = gr.fir_filter_fff(1, firdes.low_pass( Mono_gain, mpx_rate, 15000, 2000, firdes.WIN_HAMMING, 6.76)) self.gr_vector_to_streams_0 = gr.vector_to_streams(gr.sizeof_short*1, 2) self.gr_sub_xx_0 = gr.sub_ff(1) self.gr_sig_source_x_1 = gr.sig_source_f(160000, gr.GR_SIN_WAVE, 19000, pilot_gain, 0) self.gr_sig_source_x_0 = gr.sig_source_f(160000, gr.GR_SIN_WAVE, 38000, 30e-3, 0) self.gr_short_to_float_1 = gr.short_to_float(1, 1) self.gr_short_to_float_0 = gr.short_to_float(1, 1) self.gr_multiply_xx_0 = gr.multiply_vff(1) self.gr_multiply_const_vxx_2 = gr.multiply_const_vcc((32.768e3, )) self.gr_multiply_const_vxx_1 = gr.multiply_const_vff((30e-6, )) self.gr_multiply_const_vxx_0 = gr.multiply_const_vff((30e-6, )) self.gr_frequency_modulator_fc_0 = gr.frequency_modulator_fc(980e-3) self.gr_file_source_0 = gr.file_source(gr.sizeof_short*2, "/home/kranthi/Documents/project/FM Transceiver/FM Transmitter/test.raw", True) self.gr_add_xx_1 = gr.add_vff(1) self.gr_add_xx_0 = gr.add_vff(1) self.blks2_rational_resampler_xxx_2 = blks2.rational_resampler_fff( interpolation=4, decimation=1, taps=None, fractional_bw=None, ) self.blks2_rational_resampler_xxx_1 = blks2.rational_resampler_fff( interpolation=5, decimation=1, taps=None, fractional_bw=None, ) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_fff( interpolation=5, decimation=1, taps=None, fractional_bw=None, ) self.blks2_fm_preemph_0 = blks2.fm_preemph(fs=mpx_rate, tau=50e-6) self.band_pass_filter_0 = gr.fir_filter_fff(1, firdes.band_pass( st_gain, mpx_rate, 23000, 53000, 2000, firdes.WIN_HAMMING, 6.76)) ################################################## # Connections ################################################## self.connect((self.gr_file_source_0, 0), (self.gr_vector_to_streams_0, 0)) self.connect((self.gr_vector_to_streams_0, 0), (self.gr_short_to_float_0, 0)) self.connect((self.gr_vector_to_streams_0, 1), (self.gr_short_to_float_1, 0)) self.connect((self.gr_short_to_float_0, 0), (self.gr_multiply_const_vxx_0, 0)) self.connect((self.gr_short_to_float_1, 0), (self.gr_multiply_const_vxx_1, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.blks2_rational_resampler_xxx_0, 0)) self.connect((self.gr_multiply_const_vxx_1, 0), (self.blks2_rational_resampler_xxx_1, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.gr_add_xx_0, 1)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.gr_sub_xx_0, 1)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.gr_sub_xx_0, 0)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.gr_add_xx_0, 0)) self.connect((self.gr_add_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_xx_0, 0)) self.connect((self.gr_sub_xx_0, 0), (self.gr_multiply_xx_0, 1)) self.connect((self.gr_multiply_xx_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.gr_sig_source_x_1, 0), (self.gr_add_xx_1, 0)) self.connect((self.band_pass_filter_0, 0), (self.gr_add_xx_1, 1)) self.connect((self.low_pass_filter_0, 0), (self.gr_add_xx_1, 2)) self.connect((self.gr_add_xx_1, 0), (self.blks2_fm_preemph_0, 0)) self.connect((self.blks2_fm_preemph_0, 0), (self.blks2_rational_resampler_xxx_2, 0)) self.connect((self.blks2_rational_resampler_xxx_2, 0), (self.gr_frequency_modulator_fc_0, 0)) self.connect((self.gr_frequency_modulator_fc_0, 0), (self.gr_multiply_const_vxx_2, 0)) self.connect((self.gr_multiply_const_vxx_2, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.gr_multiply_const_vxx_2, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.gr_multiply_const_vxx_1, 0), (self.wxgui_fftsink2_1, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Scrambler") _icon_path = "/home/pfb/.local/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.gr_add_xx_0 = gr.add_vff(1) self.gr_char_to_float_0 = gr.char_to_float() self.gr_interp_fir_filter_xxx_0 = gr.interp_fir_filter_fff(4, (24, )) self.gr_multiply_xx_0 = gr.multiply_vff(1) self.gr_scrambler_bb_0 = gr.scrambler_bb(0x8A, 0x7F, 7) self.gr_throttle_0 = gr.throttle(gr.sizeof_char * 1, samp_rate) self.gr_vector_source_x_0 = gr.vector_source_b((0, 0, 0), True, 1) self.gr_vector_source_x_0_0 = gr.vector_source_f((-0.5, ), True, 1) self.gr_vector_source_x_0_0_0 = gr.vector_source_f((2.0, ), True, 1) self.wxgui_fftsink2_0 = fftsink2.fft_sink_f( self.GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=50, ref_scale=2.0, sample_rate=samp_rate * 2, fft_size=4096, fft_rate=30, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.GetWin(), title="Scope Plot", sample_rate=samp_rate, v_scale=1, v_offset=0, t_scale=.0005, ac_couple=False, xy_mode=False, num_inputs=1, ) self.Add(self.wxgui_scopesink2_0.win) ################################################## # Connections ################################################## self.connect((self.gr_scrambler_bb_0, 0), (self.gr_char_to_float_0, 0)) self.connect((self.gr_vector_source_x_0, 0), (self.gr_throttle_0, 0)) self.connect((self.gr_throttle_0, 0), (self.gr_scrambler_bb_0, 0)) self.connect((self.gr_char_to_float_0, 0), (self.gr_add_xx_0, 1)) self.connect((self.gr_add_xx_0, 0), (self.gr_multiply_xx_0, 1)) self.connect((self.gr_vector_source_x_0_0, 0), (self.gr_add_xx_0, 0)) self.connect((self.gr_vector_source_x_0_0_0, 0), (self.gr_multiply_xx_0, 0)) self.connect((self.gr_multiply_xx_0, 0), (self.gr_interp_fir_filter_xxx_0, 0)) self.connect((self.gr_interp_fir_filter_xxx_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.gr_interp_fir_filter_xxx_0, 0), (self.wxgui_scopesink2_0, 0))
def __init__(self, antenna="TX/RX", rx_gain=30, vor_samp_rate=250e3, com_freq_1=135.275e6, gain=21, vor_freq_1=115e6): grc_wxgui.top_block_gui.__init__(self, title="Simple Trx") ################################################## # Parameters ################################################## self.antenna = antenna self.rx_gain = rx_gain self.vor_samp_rate = vor_samp_rate self.com_freq_1 = com_freq_1 self.gain = gain self.vor_freq_1 = vor_freq_1 ################################################## # Variables ################################################## self.obs_decimation = obs_decimation = 25 self.ils_decimation = ils_decimation = 50 self.am_sample_rate = am_sample_rate = 12.5e3 self.vor_volume_slider = vor_volume_slider = 5 self.vor_ident = vor_ident = False self.vor_freq_entry_1 = vor_freq_entry_1 = vor_freq_1 self.vor_center_freq_0 = vor_center_freq_0 = (117.95e6 - 108.00e6) / 2 + 117.95e6 self.system_center_freq = system_center_freq = 133.9e6 self.squelch_slider = squelch_slider = -85 self.samp_rate = samp_rate = 250e3 self.rxgain = rxgain = 15 self.phase_correction = phase_correction = 5 self.obs_sample_rate = obs_sample_rate = am_sample_rate / obs_decimation self.ils_sample_rate = ils_sample_rate = am_sample_rate / ils_decimation self.gain_slider = gain_slider = gain self.correction_gain = correction_gain = 0.8 self.com_volume_slider = com_volume_slider = 1 self.com_freq_entry_1 = com_freq_entry_1 = com_freq_1 self.com_enable = com_enable = True self.audio_select = audio_select = 0 self.audio_sample_rate = audio_sample_rate = 48e3 self.am_decimation = am_decimation = 1 ################################################## # Blocks ################################################## _vor_volume_slider_sizer = wx.BoxSizer(wx.VERTICAL) self._vor_volume_slider_text_box = forms.text_box( parent=self.GetWin(), sizer=_vor_volume_slider_sizer, value=self.vor_volume_slider, callback=self.set_vor_volume_slider, label='vor_volume_slider', converter=forms.float_converter(), proportion=0, ) self._vor_volume_slider_slider = forms.slider( parent=self.GetWin(), sizer=_vor_volume_slider_sizer, value=self.vor_volume_slider, callback=self.set_vor_volume_slider, minimum=0, maximum=10, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_vor_volume_slider_sizer, 1, 4, 1, 1) self._vor_ident_check_box = forms.check_box( parent=self.GetWin(), value=self.vor_ident, callback=self.set_vor_ident, label='vor_ident', true=1, false=0, ) self.GridAdd(self._vor_ident_check_box, 0, 3, 1, 1) self._vor_freq_entry_1_text_box = forms.text_box( parent=self.GetWin(), value=self.vor_freq_entry_1, callback=self.set_vor_freq_entry_1, label='vor_freq_entry_1', converter=forms.float_converter(), ) self.GridAdd(self._vor_freq_entry_1_text_box, 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), "RF Analyzer") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Channel FFT") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Demod Audio FFT") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Ref and Phase Scope") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Manipulated Ref and Phase") self.Add(self.notebook_0) _com_volume_slider_sizer = wx.BoxSizer(wx.VERTICAL) self._com_volume_slider_text_box = forms.text_box( parent=self.GetWin(), sizer=_com_volume_slider_sizer, value=self.com_volume_slider, callback=self.set_com_volume_slider, label='com_volume_slider', converter=forms.float_converter(), proportion=0, ) self._com_volume_slider_slider = forms.slider( parent=self.GetWin(), sizer=_com_volume_slider_sizer, value=self.com_volume_slider, callback=self.set_com_volume_slider, minimum=0, maximum=10, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_com_volume_slider_sizer, 1, 5, 1, 1) self._com_freq_entry_1_text_box = forms.text_box( parent=self.GetWin(), value=self.com_freq_entry_1, callback=self.set_com_freq_entry_1, label='com_freq_entry_1', converter=forms.float_converter(), ) self.GridAdd(self._com_freq_entry_1_text_box, 0, 0, 1, 1) self._com_enable_check_box = forms.check_box( parent=self.GetWin(), value=self.com_enable, callback=self.set_com_enable, label='com_enable', true=1, false=0, ) self.GridAdd(self._com_enable_check_box, 2, 3, 1, 1) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.notebook_0.GetPage(3).GetWin(), title="Scope Plot", sample_rate=12.5e3, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=2, trig_mode=gr.gr_TRIG_MODE_AUTO, y_axis_label="Counts", ) self.notebook_0.GetPage(3).Add(self.wxgui_scopesink2_0.win) self.wxgui_numbersink2_0 = numbersink2.number_sink_f( self.GetWin(), unit="Units", minval=-200, maxval=200, factor=1.0, decimal_places=10, ref_level=0, sample_rate=25e3 / 2000, number_rate=15, average=True, avg_alpha=0.02, label="Number Plot", peak_hold=False, show_gauge=True, ) self.Add(self.wxgui_numbersink2_0.win) self.wxgui_fftsink2_0_1 = 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=25e3, fft_size=1024, fft_rate=5, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.notebook_0.GetPage(0).Add(self.wxgui_fftsink2_0_1.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( 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=12.5e3, fft_size=1024, fft_rate=5, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.notebook_0.GetPage(1).Add(self.wxgui_fftsink2_0.win) self.uhd_usrp_source_0 = uhd.usrp_source( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) self.uhd_usrp_source_0.set_clock_source("internal", 0) self.uhd_usrp_source_0.set_subdev_spec("A:0 A:0", 0) self.uhd_usrp_source_0.set_samp_rate(vor_samp_rate) self.uhd_usrp_source_0.set_center_freq( uhd.tune_request(com_freq_entry_1, rf_freq=system_center_freq, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0) self.uhd_usrp_source_0.set_gain(rx_gain, 0) self.uhd_usrp_source_0.set_antenna("RX2", 0) self.uhd_usrp_source_0.set_center_freq( uhd.tune_request(vor_freq_entry_1, rf_freq=system_center_freq, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 1) self.uhd_usrp_source_0.set_gain(rx_gain, 1) self.uhd_usrp_source_0.set_antenna("RX2", 1) self.uhd_usrp_sink_0 = uhd.usrp_sink( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(250e3) self.uhd_usrp_sink_0.set_center_freq(com_freq_entry_1, 0) self.uhd_usrp_sink_0.set_gain(25, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) _squelch_slider_sizer = wx.BoxSizer(wx.VERTICAL) self._squelch_slider_text_box = forms.text_box( parent=self.GetWin(), sizer=_squelch_slider_sizer, value=self.squelch_slider, callback=self.set_squelch_slider, label='squelch_slider', converter=forms.float_converter(), proportion=0, ) self._squelch_slider_slider = forms.slider( parent=self.GetWin(), sizer=_squelch_slider_sizer, value=self.squelch_slider, callback=self.set_squelch_slider, minimum=-100, maximum=0, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_squelch_slider_sizer, 1, 0, 1, 1) self.squelch = gr.pwr_squelch_cc(squelch_slider, 0.01, 20, False) self.openavionics_joystick_interface_0 = openavionics.joystick_interface( ) self.openavionics_audio_ptt_0 = openavionics.audio_ptt() self.low_pass_filter_3_0 = filter.fir_filter_fff( 5, firdes.low_pass(1, 25e3, 200, 50, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_3 = filter.fir_filter_fff( 5, firdes.low_pass(1, 25e3, 200, 50, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_2 = filter.fir_filter_ccf( 1, firdes.low_pass(1, 25e3, 3e3, 500, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_1 = filter.interp_fir_filter_fff( 1, firdes.low_pass(1, 12.5e3, 3e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0_0 = filter.fir_filter_ccf( int(250e3 / 25e3), firdes.low_pass(1, vor_samp_rate, 11e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf( int(250e3 / 12.5e3), firdes.low_pass(1, vor_samp_rate, 10e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.gr_sig_source_x_0 = gr.sig_source_c(25e3, gr.GR_COS_WAVE, 9960, 1, 0) self.gr_quadrature_demod_cf_0 = gr.quadrature_demod_cf(1) self.gr_pwr_squelch_xx_0 = gr.pwr_squelch_ff(-50, 0.5, 1, False) self.gr_null_sink_0_0 = gr.null_sink(gr.sizeof_gr_complex * 1) self.gr_multiply_xx_0_0_1 = gr.multiply_vff(1) self.gr_multiply_xx_0_0_0_0 = gr.multiply_vcc(1) self.gr_multiply_xx_0 = gr.multiply_vcc(1) self.gr_float_to_complex_0_0_0 = gr.float_to_complex(1) self.gr_float_to_complex_0 = gr.float_to_complex(1) self.gr_agc2_xx_0_0 = gr.agc2_cc(1, 1, 0.75, 1.0, 0.0) self.gr_agc2_xx_0 = gr.agc2_cc(1, 1, 0.75, 1.0, 0.0) self.gr_add_xx_0_0_0 = gr.add_vff(1) _gain_slider_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_slider_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_slider_sizer, value=self.gain_slider, callback=self.set_gain_slider, label='gain_slider', converter=forms.float_converter(), proportion=0, ) self._gain_slider_slider = forms.slider( parent=self.GetWin(), sizer=_gain_slider_sizer, value=self.gain_slider, callback=self.set_gain_slider, minimum=0, maximum=30, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_gain_slider_sizer, 1, 1, 1, 1) self.fft_tone_to_angle_0 = fft_tone_to_angle( fft_bin=12, fft_size=2000, ) self.const_source_x_0_1 = gr.sig_source_f(0, gr.GR_CONST_WAVE, 0, 0, 0.450) self.const_source_x_0_0_1 = gr.sig_source_f(0, gr.GR_CONST_WAVE, 0, 0, 0.550) self.const_source_x_0_0_0_0 = gr.sig_source_c(0, gr.GR_CONST_WAVE, 0, 0, 0.450) self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_float * 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float * 1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( (180.0 / 3.1415, )) self.blocks_add_xx_0 = blocks.add_vff(1) self.blks2_rational_resampler_xxx_2_0 = blks2.rational_resampler_fff( interpolation=250, decimation=48, taps=None, fractional_bw=None, ) self.blks2_rational_resampler_xxx_1 = blks2.rational_resampler_fff( interpolation=480, decimation=125, taps=None, fractional_bw=None, ) self.blks2_am_demod_cf_0_0 = blks2.am_demod_cf( channel_rate=25e3, audio_decim=am_decimation, audio_pass=11.5e3, audio_stop=12.250e3, ) self.blks2_am_demod_cf_0 = blks2.am_demod_cf( channel_rate=am_sample_rate, audio_decim=am_decimation, audio_pass=3e3, audio_stop=4e3, ) self.band_pass_filter_0 = gr.fir_filter_fff( 2, firdes.band_pass(1, 25000, 980, 1150, 50, firdes.WIN_HAMMING, 6.76)) self.audio_sink_0 = audio.sink(int(audio_sample_rate), "", True) self._audio_select_chooser = forms.drop_down( parent=self.GetWin(), value=self.audio_select, callback=self.set_audio_select, label='audio_select', choices=[0, 1], labels=['AM Voice', 'VOR Subcarrier'], ) self.GridAdd(self._audio_select_chooser, 0, 2, 1, 1) self.analog_sig_source_x_0_0 = analog.sig_source_f( 48000, analog.GR_COS_WAVE, 1000, 1, 0) self.adsf_0 = blocks.multiply_const_vff( (com_enable * com_volume_slider, )) self.adsf = blocks.multiply_const_vff( (vor_ident * vor_volume_slider, )) ################################################## # Connections ################################################## self.connect((self.gr_float_to_complex_0, 0), (self.gr_multiply_xx_0, 0)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.audio_sink_0, 0)) self.connect((self.blks2_am_demod_cf_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.uhd_usrp_source_0, 1), (self.gr_null_sink_0_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.squelch, 0)) self.connect((self.squelch, 0), (self.gr_agc2_xx_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.gr_agc2_xx_0, 0), (self.blks2_am_demod_cf_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.wxgui_fftsink2_0_1, 0)) self.connect((self.gr_agc2_xx_0_0, 0), (self.blks2_am_demod_cf_0_0, 0)) self.connect((self.uhd_usrp_source_0, 1), (self.low_pass_filter_0_0, 0)) self.connect((self.blks2_am_demod_cf_0_0, 0), (self.gr_float_to_complex_0, 0)) self.connect((self.fft_tone_to_angle_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.wxgui_numbersink2_0, 0)) self.connect((self.fft_tone_to_angle_0, 1), (self.blocks_null_sink_0, 0)) self.connect((self.fft_tone_to_angle_0, 2), (self.blocks_null_sink_1, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.gr_agc2_xx_0_0, 0)) self.connect((self.gr_quadrature_demod_cf_0, 0), (self.low_pass_filter_3, 0)) self.connect((self.low_pass_filter_3, 0), (self.fft_tone_to_angle_0, 0)) self.connect((self.low_pass_filter_3_0, 0), (self.fft_tone_to_angle_0, 1)) self.connect((self.blks2_am_demod_cf_0_0, 0), (self.low_pass_filter_3_0, 0)) self.connect((self.blks2_am_demod_cf_0_0, 0), (self.gr_float_to_complex_0, 1)) self.connect((self.gr_multiply_xx_0, 0), (self.low_pass_filter_2, 0)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_xx_0, 1)) self.connect((self.low_pass_filter_2, 0), (self.gr_quadrature_demod_cf_0, 0)) self.connect((self.blks2_am_demod_cf_0_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.adsf, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.blks2_rational_resampler_xxx_1, 0)) self.connect((self.adsf, 0), (self.wxgui_scopesink2_0, 1)) self.connect((self.low_pass_filter_1, 0), (self.adsf_0, 0)) self.connect((self.adsf_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.adsf_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.gr_pwr_squelch_xx_0, 0)) self.connect((self.gr_pwr_squelch_xx_0, 0), (self.adsf, 0)) self.connect((self.const_source_x_0_0_0_0, 0), (self.gr_multiply_xx_0_0_0_0, 1)) self.connect((self.gr_float_to_complex_0_0_0, 0), (self.gr_multiply_xx_0_0_0_0, 0)) self.connect((self.gr_add_xx_0_0_0, 0), (self.gr_float_to_complex_0_0_0, 1)) self.connect((self.gr_add_xx_0_0_0, 0), (self.gr_float_to_complex_0_0_0, 0)) self.connect((self.const_source_x_0_0_1, 0), (self.gr_add_xx_0_0_0, 1)) self.connect((self.gr_multiply_xx_0_0_1, 0), (self.gr_add_xx_0_0_0, 0)) self.connect((self.const_source_x_0_1, 0), (self.gr_multiply_xx_0_0_1, 1)) self.connect((self.gr_multiply_xx_0_0_0_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blks2_rational_resampler_xxx_2_0, 0), (self.openavionics_audio_ptt_0, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blks2_rational_resampler_xxx_2_0, 0)) self.connect((self.openavionics_audio_ptt_0, 0), (self.gr_multiply_xx_0_0_1, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.openavionics_joystick_interface_0, "out", self.openavionics_audio_ptt_0, "in2")