def __init__(self): gr.top_block.__init__(self, "Usrp Rx Hrpt Nogui") ################################################## # Variables ################################################## self.config_filename = config_filename = os.environ[ 'HOME'] + '/.gnuradio/config.conf' self._decim_config = ConfigParser.ConfigParser() self._decim_config.read(config_filename) try: decim = self._decim_config.getfloat('usrp_rx_hrpt', 'decim') except: decim = 32 self.decim = decim self.sym_rate = sym_rate = 600 * 1109 self.sample_rate = sample_rate = 64e6 / decim self.sps = sps = sample_rate / sym_rate self._side_config = ConfigParser.ConfigParser() self._side_config.read(config_filename) try: side = self._side_config.get('usrp_rx_hrpt', 'side') except: side = 'A' self.side = side self._pll_alpha_config = ConfigParser.ConfigParser() self._pll_alpha_config.read(config_filename) try: pll_alpha = self._pll_alpha_config.getfloat( 'usrp_rx_hrpt', 'pll_alpha') except: pll_alpha = 0.01 self.pll_alpha = pll_alpha self._output_filename_config = ConfigParser.ConfigParser() self._output_filename_config.read(config_filename) try: output_filename = self._output_filename_config.get( 'usrp_rx_hrpt', 'filename') except: output_filename = 'frames.hrpt' self.output_filename = output_filename self.max_clock_offset = max_clock_offset = 100e-6 self.max_carrier_offset = max_carrier_offset = 2 * math.pi * 100e3 / sample_rate self.hs = hs = int(sps / 2.0) self._gain_config = ConfigParser.ConfigParser() self._gain_config.read(config_filename) try: gain = self._gain_config.getfloat('usrp_rx_hrpt', 'gain') except: gain = 35 self.gain = gain self._freq_config = ConfigParser.ConfigParser() self._freq_config.read(config_filename) try: freq = self._freq_config.getfloat('usrp_rx_hrpt', 'freq') except: freq = 1698e6 self.freq = freq self._clock_alpha_config = ConfigParser.ConfigParser() self._clock_alpha_config.read(config_filename) try: clock_alpha = self._clock_alpha_config.getfloat( 'usrp_rx_hrpt', 'clock_alpha') except: clock_alpha = 0.01 self.clock_alpha = clock_alpha ################################################## # Blocks ################################################## self.agc = gr.agc_cc(1e-6, 1.0, 1.0, 1.0) self.decoder = noaa.hrpt_decoder(True, True) self.deframer = noaa.hrpt_deframer() self.frame_sink = gr.file_sink(gr.sizeof_short * 1, output_filename) self.gr_binary_slicer_fb_0 = gr.binary_slicer_fb() self.gr_clock_recovery_mm_xx_0 = gr.clock_recovery_mm_ff( sps / 2.0, clock_alpha**2 / 4.0, 0.5, clock_alpha, max_clock_offset) self.gr_moving_average_xx_0 = gr.moving_average_ff(hs, 1.0 / hs, 4000) self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2 / 4.0, max_carrier_offset) self.usrp_source = grc_usrp.simple_source_c(which=0, side=side, rx_ant="RXA") self.usrp_source.set_decim_rate(decim) self.usrp_source.set_frequency(freq, verbose=True) self.usrp_source.set_gain(gain) ################################################## # Connections ################################################## self.connect((self.usrp_source, 0), (self.agc, 0)) self.connect((self.agc, 0), (self.pll, 0)) self.connect((self.pll, 0), (self.gr_moving_average_xx_0, 0)) self.connect((self.gr_moving_average_xx_0, 0), (self.gr_clock_recovery_mm_xx_0, 0)) self.connect((self.gr_clock_recovery_mm_xx_0, 0), (self.gr_binary_slicer_fb_0, 0)) self.connect((self.deframer, 0), (self.frame_sink, 0)) self.connect((self.deframer, 0), (self.decoder, 0)) self.connect((self.gr_binary_slicer_fb_0, 0), (self.deframer, 0))
def __init__(self, deframer_insync_frames=2, deframer_sync_check=True, viterbi_insync_frames=5, deframer_outsync_frames=5, viterbi_outsync_frames=20, viterbi_sync_check=True, viterbi_sync_threshold=0.1, satellite='GOES-LRIT', freq=1691.02e6, gain=23, decim=108, side="A", pll_alpha=0.005, symb_rate=293883, clock_alpha=0.005): grc_wxgui.top_block_gui.__init__(self, title="USRP LRIT Receiver - check signal quality") ################################################## # Parameters ################################################## self.deframer_insync_frames = deframer_insync_frames self.deframer_sync_check = deframer_sync_check self.viterbi_insync_frames = viterbi_insync_frames self.deframer_outsync_frames = deframer_outsync_frames self.viterbi_outsync_frames = viterbi_outsync_frames self.viterbi_sync_check = viterbi_sync_check self.viterbi_sync_threshold = viterbi_sync_threshold self.satellite = satellite self.freq = freq self.gain = gain self.decim = decim self.side = side self.pll_alpha = pll_alpha self.symb_rate = symb_rate self.clock_alpha = clock_alpha ################################################## # Variables ################################################## self.decim_tb = decim_tb = decim self.symb_rate_tb = symb_rate_tb = symb_rate self.samp_rate = samp_rate = 64e6/decim_tb self.viterbi_sync_threshold_text = viterbi_sync_threshold_text = viterbi_sync_threshold self.viterbi_sync_after_text = viterbi_sync_after_text = viterbi_insync_frames self.viterbi_outofsync_after_text = viterbi_outofsync_after_text = viterbi_outsync_frames self.viterbi_node_sync_text = viterbi_node_sync_text = viterbi_sync_check self.sps = sps = samp_rate/symb_rate_tb self.satellite_text = satellite_text = satellite self.samp_rate_st = samp_rate_st = samp_rate self.pll_alpha_sl = pll_alpha_sl = pll_alpha self.gain_tb = gain_tb = gain self.freq_tb = freq_tb = freq self.frames_file_text_inf = frames_file_text_inf = 'no output file' self.deframer_sync_after_text = deframer_sync_after_text = deframer_insync_frames self.deframer_nosync_after_text = deframer_nosync_after_text = deframer_outsync_frames self.deframer_check_sync_text = deframer_check_sync_text = deframer_sync_check self.datetime_text = datetime_text = strftime("%A, %B %d %Y %H:%M:%S", localtime()) self.clock_alpha_sl = clock_alpha_sl = clock_alpha self.baseband_file_text_inf = baseband_file_text_inf = 'no output file' ################################################## # Notebooks ################################################## self.rx_ntb = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "USRP Receiver") self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "PLL demodulator and Clock sync") self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "Viterbi decoder") self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "Deframer") self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "Output") self.Add(self.rx_ntb) ################################################## # Controls ################################################## self._decim_tb_text_box = forms.text_box( parent=self.rx_ntb.GetPage(0).GetWin(), value=self.decim_tb, callback=self.set_decim_tb, label="Decimation", converter=forms.int_converter(), ) self.rx_ntb.GetPage(0).GridAdd(self._decim_tb_text_box, 1, 3, 1, 1) self._symb_rate_tb_text_box = forms.text_box( parent=self.rx_ntb.GetPage(1).GetWin(), value=self.symb_rate_tb, callback=self.set_symb_rate_tb, label="Symbol rate", converter=forms.int_converter(), ) self.rx_ntb.GetPage(1).GridAdd(self._symb_rate_tb_text_box, 2, 1, 1, 1) self._viterbi_sync_threshold_text_static_text = forms.static_text( parent=self.rx_ntb.GetPage(2).GetWin(), value=self.viterbi_sync_threshold_text, callback=self.set_viterbi_sync_threshold_text, label="Viterbi node sync threshold [BER]", converter=forms.float_converter(), ) self.rx_ntb.GetPage(2).GridAdd(self._viterbi_sync_threshold_text_static_text, 3, 0, 1, 1) self._viterbi_sync_after_text_static_text = forms.static_text( parent=self.rx_ntb.GetPage(2).GetWin(), value=self.viterbi_sync_after_text, callback=self.set_viterbi_sync_after_text, label="Valid frames for Viterbi decoder sync", converter=forms.float_converter(), ) self.rx_ntb.GetPage(2).GridAdd(self._viterbi_sync_after_text_static_text, 4, 0, 1, 1) self._viterbi_outofsync_after_text_static_text = forms.static_text( parent=self.rx_ntb.GetPage(2).GetWin(), value=self.viterbi_outofsync_after_text, callback=self.set_viterbi_outofsync_after_text, label="Invalid frames for Viterbi decoder out of sync", converter=forms.float_converter(), ) self.rx_ntb.GetPage(2).GridAdd(self._viterbi_outofsync_after_text_static_text, 5, 0, 1, 1) self._viterbi_node_sync_text_static_text = forms.static_text( parent=self.rx_ntb.GetPage(2).GetWin(), value=self.viterbi_node_sync_text, callback=self.set_viterbi_node_sync_text, label="Viterbi node sync enable", converter=forms.str_converter(), ) self.rx_ntb.GetPage(2).GridAdd(self._viterbi_node_sync_text_static_text, 2, 0, 1, 1) self._satellite_text_static_text = forms.static_text( parent=self.rx_ntb.GetPage(0).GetWin(), value=self.satellite_text, callback=self.set_satellite_text, label="Sat ", converter=forms.str_converter(), ) self.rx_ntb.GetPage(0).GridAdd(self._satellite_text_static_text, 1, 0, 1, 1) self._samp_rate_st_static_text = forms.static_text( parent=self.rx_ntb.GetPage(0).GetWin(), value=self.samp_rate_st, callback=self.set_samp_rate_st, label="Sample rate", converter=forms.float_converter(), ) self.rx_ntb.GetPage(0).GridAdd(self._samp_rate_st_static_text, 1, 4, 1, 1) _pll_alpha_sl_sizer = wx.BoxSizer(wx.VERTICAL) self._pll_alpha_sl_text_box = forms.text_box( parent=self.rx_ntb.GetPage(1).GetWin(), sizer=_pll_alpha_sl_sizer, value=self.pll_alpha_sl, callback=self.set_pll_alpha_sl, label="PLL Alpha", converter=forms.float_converter(), proportion=0, ) self._pll_alpha_sl_slider = forms.slider( parent=self.rx_ntb.GetPage(1).GetWin(), sizer=_pll_alpha_sl_sizer, value=self.pll_alpha_sl, callback=self.set_pll_alpha_sl, minimum=0.001, maximum=0.1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.rx_ntb.GetPage(1).GridAdd(_pll_alpha_sl_sizer, 1, 0, 1, 1) self._gain_tb_text_box = forms.text_box( parent=self.rx_ntb.GetPage(0).GetWin(), value=self.gain_tb, callback=self.set_gain_tb, label="RX gain [dB]", converter=forms.int_converter(), ) self.rx_ntb.GetPage(0).GridAdd(self._gain_tb_text_box, 1, 2, 1, 1) self._freq_tb_text_box = forms.text_box( parent=self.rx_ntb.GetPage(0).GetWin(), value=self.freq_tb, callback=self.set_freq_tb, label="Frequency", converter=forms.float_converter(), ) self.rx_ntb.GetPage(0).GridAdd(self._freq_tb_text_box, 1, 1, 1, 1) self._frames_file_text_inf_static_text = forms.static_text( parent=self.rx_ntb.GetPage(4).GetWin(), value=self.frames_file_text_inf, callback=self.set_frames_file_text_inf, label="Frames filename", converter=forms.str_converter(), ) self.rx_ntb.GetPage(4).GridAdd(self._frames_file_text_inf_static_text, 3, 0, 1, 1) self._deframer_sync_after_text_static_text = forms.static_text( parent=self.rx_ntb.GetPage(3).GetWin(), value=self.deframer_sync_after_text, callback=self.set_deframer_sync_after_text, label="Deframe sync after", converter=forms.float_converter(), ) self.rx_ntb.GetPage(3).GridAdd(self._deframer_sync_after_text_static_text, 3, 0, 1, 1) self._deframer_nosync_after_text_static_text = forms.static_text( parent=self.rx_ntb.GetPage(3).GetWin(), value=self.deframer_nosync_after_text, callback=self.set_deframer_nosync_after_text, label="Deframer out of sync after", converter=forms.float_converter(), ) self.rx_ntb.GetPage(3).GridAdd(self._deframer_nosync_after_text_static_text, 4, 0, 1, 1) self._deframer_check_sync_text_static_text = forms.static_text( parent=self.rx_ntb.GetPage(3).GetWin(), value=self.deframer_check_sync_text, callback=self.set_deframer_check_sync_text, label="Deframer check sync enable", converter=forms.str_converter(), ) self.rx_ntb.GetPage(3).GridAdd(self._deframer_check_sync_text_static_text, 2, 0, 1, 1) self._datetime_text_static_text = forms.static_text( parent=self.rx_ntb.GetPage(4).GetWin(), value=self.datetime_text, callback=self.set_datetime_text, label="Local time of aquisition start", converter=forms.str_converter(), ) self.rx_ntb.GetPage(4).GridAdd(self._datetime_text_static_text, 1, 0, 1, 1) _clock_alpha_sl_sizer = wx.BoxSizer(wx.VERTICAL) self._clock_alpha_sl_text_box = forms.text_box( parent=self.rx_ntb.GetPage(1).GetWin(), sizer=_clock_alpha_sl_sizer, value=self.clock_alpha_sl, callback=self.set_clock_alpha_sl, label="Clock alpha", converter=forms.float_converter(), proportion=0, ) self._clock_alpha_sl_slider = forms.slider( parent=self.rx_ntb.GetPage(1).GetWin(), sizer=_clock_alpha_sl_sizer, value=self.clock_alpha_sl, callback=self.set_clock_alpha_sl, minimum=0.001, maximum=0.1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.rx_ntb.GetPage(1).GridAdd(_clock_alpha_sl_sizer, 1, 1, 1, 1) self._baseband_file_text_inf_static_text = forms.static_text( parent=self.rx_ntb.GetPage(4).GetWin(), value=self.baseband_file_text_inf, callback=self.set_baseband_file_text_inf, label="Baseband filename", converter=forms.str_converter(), ) self.rx_ntb.GetPage(4).GridAdd(self._baseband_file_text_inf_static_text, 4, 0, 1, 1) ################################################## # Blocks ################################################## self.fec_decode_viterbi_bpsk_fb_0 = fec.decode_viterbi_bpsk_fb(viterbi_sync_check, viterbi_sync_threshold, viterbi_insync_frames, viterbi_outsync_frames, viterbi_outsync_frames*3) self.gr_agc_xx_0 = gr.agc_cc(10e-6, 1, 1.0/32767.0, 1.0) self.gr_clock_recovery_mm_xx_0 = gr.clock_recovery_mm_cc(sps, clock_alpha_sl*clock_alpha_sl/4.0, 0.5, clock_alpha_sl, 0.05) self.gr_complex_to_real_0 = gr.complex_to_real(1) self.gr_costas_loop_cc_0 = gr.costas_loop_cc(pll_alpha_sl, pll_alpha_sl*pll_alpha_sl/4.0, 0.07, -0.07, 2) self.gr_multiply_const_vxx_0 = gr.multiply_const_vcc((1, )) self.gr_null_sink_0 = gr.null_sink(gr.sizeof_char*1) self.gr_packed_to_unpacked_xx_0 = gr.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST) self.poesweather_metop_cadu_deframer_0 = poesweather.metop_cadu_deframer(True, 1024, deframer_insync_frames, deframer_outsync_frames) self.root_raised_cosine_filter_0 = gr.fir_filter_ccf(1, firdes.root_raised_cosine( 1, samp_rate, symb_rate, 0.25, int(11*samp_rate/symb_rate))) self.usrp_simple_source = grc_usrp.simple_source_c(which=0, side=side, rx_ant="RXA") self.usrp_simple_source.set_decim_rate(decim_tb) self.usrp_simple_source.set_frequency(freq_tb, verbose=True) self.usrp_simple_source.set_gain(gain_tb) self.wxgui_fftsink1 = fftsink2.fft_sink_c( self.rx_ntb.GetPage(0).GetWin(), baseband_freq=freq, y_per_div=2, y_divs=10, ref_level=12, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=30, average=True, avg_alpha=0.1, title="Not filtered spectrum", peak_hold=False, ) self.rx_ntb.GetPage(0).Add(self.wxgui_fftsink1.win) self.wxgui_fftsink2 = fftsink2.fft_sink_c( self.rx_ntb.GetPage(0).GetWin(), baseband_freq=0, y_per_div=2, y_divs=10, ref_level=12, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=30, average=True, avg_alpha=0.1, title="RRC filtered spectrum", peak_hold=False, ) self.rx_ntb.GetPage(0).Add(self.wxgui_fftsink2.win) self.wxgui_scopesink2_1 = scopesink2.scope_sink_c( self.rx_ntb.GetPage(1).GetWin(), title="BPSK constellation diagram", sample_rate=symb_rate, v_scale=0.4, v_offset=0, t_scale=1/samp_rate, ac_couple=False, xy_mode=True, num_inputs=1, ) self.rx_ntb.GetPage(1).Add(self.wxgui_scopesink2_1.win) ################################################## # Connections ################################################## self.connect((self.usrp_simple_source, 0), (self.gr_agc_xx_0, 0)) self.connect((self.gr_agc_xx_0, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.gr_complex_to_real_0, 0)) self.connect((self.fec_decode_viterbi_bpsk_fb_0, 0), (self.gr_packed_to_unpacked_xx_0, 0)) self.connect((self.gr_packed_to_unpacked_xx_0, 0), (self.poesweather_metop_cadu_deframer_0, 0)) self.connect((self.gr_complex_to_real_0, 0), (self.fec_decode_viterbi_bpsk_fb_0, 0)) self.connect((self.gr_clock_recovery_mm_xx_0, 0), (self.gr_multiply_const_vxx_0, 0)) self.connect((self.gr_costas_loop_cc_0, 0), (self.gr_clock_recovery_mm_xx_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.gr_costas_loop_cc_0, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.wxgui_scopesink2_1, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.wxgui_fftsink2, 0)) self.connect((self.gr_agc_xx_0, 0), (self.wxgui_fftsink1, 0)) self.connect((self.poesweather_metop_cadu_deframer_0, 0), (self.gr_null_sink_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="USRP HRPT Receiver") ################################################## # Variables ################################################## self.config_filename = config_filename = os.environ['HOME']+'/.gnuradio/config.conf' self._decim_config = ConfigParser.ConfigParser() self._decim_config.read(config_filename) try: decim = self._decim_config.getfloat('usrp_rx_hrpt', 'decim') except: decim = 32 self.decim = decim self.sym_rate = sym_rate = 600*1109 self.sample_rate = sample_rate = 64e6/decim self.sps = sps = sample_rate/sym_rate self._side_config = ConfigParser.ConfigParser() self._side_config.read(config_filename) try: side = self._side_config.get('usrp_rx_hrpt', 'side') except: side = 'A' self.side = side self._saved_pll_alpha_config = ConfigParser.ConfigParser() self._saved_pll_alpha_config.read(config_filename) try: saved_pll_alpha = self._saved_pll_alpha_config.getfloat('usrp_rx_hrpt', 'pll_alpha') except: saved_pll_alpha = 0.01 self.saved_pll_alpha = saved_pll_alpha self._saved_gain_config = ConfigParser.ConfigParser() self._saved_gain_config.read(config_filename) try: saved_gain = self._saved_gain_config.getfloat('usrp_rx_hrpt', 'gain') except: saved_gain = 35 self.saved_gain = saved_gain self._saved_freq_config = ConfigParser.ConfigParser() self._saved_freq_config.read(config_filename) try: saved_freq = self._saved_freq_config.getfloat('usrp_rx_hrpt', 'freq') except: saved_freq = 1698e6 self.saved_freq = saved_freq self._saved_clock_alpha_config = ConfigParser.ConfigParser() self._saved_clock_alpha_config.read(config_filename) try: saved_clock_alpha = self._saved_clock_alpha_config.getfloat('usrp_rx_hrpt', 'clock_alpha') except: saved_clock_alpha = 0.01 self.saved_clock_alpha = saved_clock_alpha self.side_text = side_text = side self.pll_alpha = pll_alpha = saved_pll_alpha self._output_filename_config = ConfigParser.ConfigParser() self._output_filename_config.read(config_filename) try: output_filename = self._output_filename_config.get('usrp_rx_hrpt', 'filename') except: output_filename = 'frames.hrpt' self.output_filename = output_filename self.max_clock_offset = max_clock_offset = 100e-6 self.max_carrier_offset = max_carrier_offset = 2*math.pi*100e3/sample_rate self.hs = hs = int(sps/2.0) self.gain = gain = saved_gain self.freq = freq = saved_freq self.decim_text = decim_text = decim self.clock_alpha = clock_alpha = saved_clock_alpha ################################################## # Notebooks ################################################## self.displays = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.displays.AddPage(grc_wxgui.Panel(self.displays), "Spectrum") self.displays.AddPage(grc_wxgui.Panel(self.displays), "Demod") self.GridAdd(self.displays, 2, 0, 1, 4) ################################################## # Controls ################################################## self._side_text_static_text = forms.static_text( parent=self.GetWin(), value=self.side_text, callback=self.set_side_text, label="USRP Side", converter=forms.str_converter(), ) self.GridAdd(self._side_text_static_text, 1, 0, 1, 1) _pll_alpha_sizer = wx.BoxSizer(wx.VERTICAL) self._pll_alpha_text_box = forms.text_box( parent=self.GetWin(), sizer=_pll_alpha_sizer, value=self.pll_alpha, callback=self.set_pll_alpha, label="PLL Alpha", converter=forms.float_converter(), proportion=0, ) self._pll_alpha_slider = forms.slider( parent=self.GetWin(), sizer=_pll_alpha_sizer, value=self.pll_alpha, callback=self.set_pll_alpha, minimum=0.0, maximum=0.5, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_pll_alpha_sizer, 0, 2, 1, 1) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label="RX Gain", converter=forms.float_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_gain_sizer, 0, 1, 1, 1) self._freq_text_box = forms.text_box( parent=self.GetWin(), value=self.freq, callback=self.set_freq, label="Frequency", converter=forms.float_converter(), ) self.GridAdd(self._freq_text_box, 0, 0, 1, 1) self._decim_text_static_text = forms.static_text( parent=self.GetWin(), value=self.decim_text, callback=self.set_decim_text, label="Decimation", converter=forms.float_converter(), ) self.GridAdd(self._decim_text_static_text, 1, 1, 1, 1) _clock_alpha_sizer = wx.BoxSizer(wx.VERTICAL) self._clock_alpha_text_box = forms.text_box( parent=self.GetWin(), sizer=_clock_alpha_sizer, value=self.clock_alpha, callback=self.set_clock_alpha, label="Clock Alpha", converter=forms.float_converter(), proportion=0, ) self._clock_alpha_slider = forms.slider( parent=self.GetWin(), sizer=_clock_alpha_sizer, value=self.clock_alpha, callback=self.set_clock_alpha, minimum=0.0, maximum=0.5, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_clock_alpha_sizer, 0, 3, 1, 1) ################################################## # Blocks ################################################## self.agc = gr.agc_cc(1e-6, 1.0, 1.0, 1.0) self.decoder = noaa.hrpt_decoder(True,True) self.deframer = noaa.hrpt_deframer() self.demod_scope = scopesink2.scope_sink_f( self.displays.GetPage(1).GetWin(), title="Post-Demod", sample_rate=sym_rate*2.0, v_scale=0.5, v_offset=0, t_scale=10.0/sym_rate, ac_couple=False, xy_mode=False, num_inputs=1, ) self.displays.GetPage(1).GridAdd(self.demod_scope.win, 0, 0, 1, 1) self.frame_sink = gr.file_sink(gr.sizeof_short*1, output_filename) self.gr_binary_slicer_fb_0 = gr.binary_slicer_fb() self.gr_clock_recovery_mm_xx_0 = gr.clock_recovery_mm_ff(sps/2.0, clock_alpha**2/4.0, 0.5, clock_alpha, max_clock_offset) self.gr_moving_average_xx_0 = gr.moving_average_ff(hs, 1.0/hs, 4000) self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2/4.0, max_carrier_offset) self.rx_fft = fftsink2.fft_sink_c( self.displays.GetPage(0).GetWin(), baseband_freq=freq, y_per_div=5, y_divs=8, ref_level=-5, ref_scale=2.0, sample_rate=sample_rate, fft_size=1024, fft_rate=15, average=True, avg_alpha=0.1, title="RX Spectrum", peak_hold=False, size=(640, 360), ) self.displays.GetPage(0).GridAdd(self.rx_fft.win, 0, 0, 1, 1) self.usrp_source = grc_usrp.simple_source_c(which=0, side=side, rx_ant="RXA") self.usrp_source.set_decim_rate(decim) self.usrp_source.set_frequency(freq, verbose=True) self.usrp_source.set_gain(gain) ################################################## # Connections ################################################## self.connect((self.gr_clock_recovery_mm_xx_0, 0), (self.gr_binary_slicer_fb_0, 0)) self.connect((self.deframer, 0), (self.frame_sink, 0)) self.connect((self.deframer, 0), (self.decoder, 0)) self.connect((self.gr_clock_recovery_mm_xx_0, 0), (self.demod_scope, 0)) self.connect((self.gr_moving_average_xx_0, 0), (self.gr_clock_recovery_mm_xx_0, 0)) self.connect((self.pll, 0), (self.gr_moving_average_xx_0, 0)) self.connect((self.agc, 0), (self.pll, 0)) self.connect((self.usrp_source, 0), (self.agc, 0)) self.connect((self.agc, 0), (self.rx_fft, 0)) self.connect((self.gr_binary_slicer_fb_0, 0), (self.deframer, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="USRP HRPT Receiver") ################################################## # Variables ################################################## self.config_filename = config_filename = 'usrp_rx_hrpt.cfg' self._decim_config = ConfigParser.ConfigParser() self._decim_config.read(config_filename) try: decim = self._decim_config.getfloat('usrp', 'decim') except: decim = 16 self.decim = decim self.sym_rate = sym_rate = 600*1109 self.sample_rate = sample_rate = 64e6/decim self.sps = sps = sample_rate/sym_rate self._side_config = ConfigParser.ConfigParser() self._side_config.read(config_filename) try: side = self._side_config.get('usrp', 'side') except: side = 'A' self.side = side self._saved_sync_alpha_config = ConfigParser.ConfigParser() self._saved_sync_alpha_config.read(config_filename) try: saved_sync_alpha = self._saved_sync_alpha_config.getfloat('demod', 'sync_alpha') except: saved_sync_alpha = 0.05 self.saved_sync_alpha = saved_sync_alpha self._saved_pll_alpha_config = ConfigParser.ConfigParser() self._saved_pll_alpha_config.read(config_filename) try: saved_pll_alpha = self._saved_pll_alpha_config.getfloat('demod', 'pll_alpha') except: saved_pll_alpha = 0.05 self.saved_pll_alpha = saved_pll_alpha self._saved_gain_config = ConfigParser.ConfigParser() self._saved_gain_config.read(config_filename) try: saved_gain = self._saved_gain_config.getfloat('usrp', 'gain') except: saved_gain = 35 self.saved_gain = saved_gain self._saved_freq_config = ConfigParser.ConfigParser() self._saved_freq_config.read(config_filename) try: saved_freq = self._saved_freq_config.getfloat('usrp', 'freq') except: saved_freq = 1698e6 self.saved_freq = saved_freq self.hs = hs = int(sps/2.0) self.sync_alpha = sync_alpha = saved_sync_alpha self.side_text = side_text = side self.pll_alpha = pll_alpha = saved_pll_alpha self._output_filename_config = ConfigParser.ConfigParser() self._output_filename_config.read(config_filename) try: output_filename = self._output_filename_config.get('output', 'filename') except: output_filename = 'frames.dat' self.output_filename = output_filename self.mf_taps = mf_taps = [-0.5/hs,]*hs+[0.5/hs,]*hs self.max_sync_offset = max_sync_offset = 0.01 self.max_carrier_offset = max_carrier_offset = 2*math.pi*100e3/sample_rate self.gain = gain = saved_gain self.freq = freq = saved_freq self.decim_text = decim_text = decim ################################################## # Controls ################################################## _sync_alpha_sizer = wx.BoxSizer(wx.VERTICAL) self._sync_alpha_text_box = forms.text_box( parent=self.GetWin(), sizer=_sync_alpha_sizer, value=self.sync_alpha, callback=self.set_sync_alpha, label="SYNC Alpha", converter=forms.float_converter(), proportion=0, ) self._sync_alpha_slider = forms.slider( parent=self.GetWin(), sizer=_sync_alpha_sizer, value=self.sync_alpha, callback=self.set_sync_alpha, minimum=0.0, maximum=0.5, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_sync_alpha_sizer, 0, 3, 1, 1) self._side_text_static_text = forms.static_text( parent=self.GetWin(), value=self.side_text, callback=self.set_side_text, label="USRP Side", converter=forms.str_converter(), ) self.GridAdd(self._side_text_static_text, 1, 0, 1, 1) _pll_alpha_sizer = wx.BoxSizer(wx.VERTICAL) self._pll_alpha_text_box = forms.text_box( parent=self.GetWin(), sizer=_pll_alpha_sizer, value=self.pll_alpha, callback=self.set_pll_alpha, label="PLL Alpha", converter=forms.float_converter(), proportion=0, ) self._pll_alpha_slider = forms.slider( parent=self.GetWin(), sizer=_pll_alpha_sizer, value=self.pll_alpha, callback=self.set_pll_alpha, minimum=0.0, maximum=0.5, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_pll_alpha_sizer, 0, 2, 1, 1) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label="RX Gain", converter=forms.float_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_gain_sizer, 0, 1, 1, 1) self._freq_text_box = forms.text_box( parent=self.GetWin(), value=self.freq, callback=self.set_freq, label="Frequency", converter=forms.float_converter(), ) self.GridAdd(self._freq_text_box, 0, 0, 1, 1) self._decim_text_static_text = forms.static_text( parent=self.GetWin(), value=self.decim_text, callback=self.set_decim_text, label="Decimation", converter=forms.float_converter(), ) self.GridAdd(self._decim_text_static_text, 1, 1, 1, 1) ################################################## # Blocks ################################################## self.agc = gr.agc_cc(1e-6, 1.0, 1.0, 1.0) self.decoder = noaa.hrpt_decoder() self.deframer = noaa.hrpt_deframer() self.frame_sink = gr.file_sink(gr.sizeof_short*1, output_filename) self.gr_fir_filter_xxx_0 = gr.fir_filter_ccc(1, (mf_taps)) self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2/4.0, max_carrier_offset) self.pll_scope = scopesink2.scope_sink_f( self.GetWin(), title="Demod Waveform", sample_rate=sample_rate, v_scale=0.5, t_scale=20.0/sample_rate, ac_couple=False, xy_mode=False, num_inputs=1, ) self.GridAdd(self.pll_scope.win, 2, 0, 1, 4) self.sync = noaa.hrpt_sync_fb(sync_alpha, sync_alpha**2/4.0, sps, max_sync_offset) self.usrp_source = grc_usrp.simple_source_c(which=0, side=side, rx_ant="RXA") self.usrp_source.set_decim_rate(decim) self.usrp_source.set_frequency(freq, verbose=True) self.usrp_source.set_gain(gain) ################################################## # Connections ################################################## self.connect((self.gr_fir_filter_xxx_0, 0), (self.pll, 0)) self.connect((self.agc, 0), (self.gr_fir_filter_xxx_0, 0)) self.connect((self.usrp_source, 0), (self.agc, 0)) self.connect((self.deframer, 0), (self.decoder, 0)) self.connect((self.pll, 0), (self.pll_scope, 0)) self.connect((self.pll, 0), (self.sync, 0)) self.connect((self.sync, 0), (self.deframer, 0)) self.connect((self.deframer, 0), (self.frame_sink, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="USRP HRPT Receiver") ################################################## # Variables ################################################## self.config_filename = config_filename = "usrp_rx_hrpt.cfg" self._decim_config = ConfigParser.ConfigParser() self._decim_config.read(config_filename) try: decim = self._decim_config.getfloat("usrp", "decim") except: decim = 16 self.decim = decim self.sym_rate = sym_rate = 600 * 1109 self.sample_rate = sample_rate = 64e6 / decim self.sps = sps = sample_rate / sym_rate self._side_config = ConfigParser.ConfigParser() self._side_config.read(config_filename) try: side = self._side_config.get("usrp", "side") except: side = "A" self.side = side self._saved_sync_alpha_config = ConfigParser.ConfigParser() self._saved_sync_alpha_config.read(config_filename) try: saved_sync_alpha = self._saved_sync_alpha_config.getfloat("demod", "sync_alpha") except: saved_sync_alpha = 0.05 self.saved_sync_alpha = saved_sync_alpha self._saved_pll_alpha_config = ConfigParser.ConfigParser() self._saved_pll_alpha_config.read(config_filename) try: saved_pll_alpha = self._saved_pll_alpha_config.getfloat("demod", "pll_alpha") except: saved_pll_alpha = 0.05 self.saved_pll_alpha = saved_pll_alpha self._saved_gain_config = ConfigParser.ConfigParser() self._saved_gain_config.read(config_filename) try: saved_gain = self._saved_gain_config.getfloat("usrp", "gain") except: saved_gain = 35 self.saved_gain = saved_gain self._saved_freq_config = ConfigParser.ConfigParser() self._saved_freq_config.read(config_filename) try: saved_freq = self._saved_freq_config.getfloat("usrp", "freq") except: saved_freq = 1698e6 self.saved_freq = saved_freq self.hs = hs = int(sps / 2.0) self.sync_alpha = sync_alpha = saved_sync_alpha self.side_text = side_text = side self.pll_alpha = pll_alpha = saved_pll_alpha self._output_filename_config = ConfigParser.ConfigParser() self._output_filename_config.read(config_filename) try: output_filename = self._output_filename_config.get("output", "filename") except: output_filename = "frames.dat" self.output_filename = output_filename self.mf_taps = mf_taps = [-0.5 / hs] * hs + [0.5 / hs] * hs self.max_sync_offset = max_sync_offset = 0.01 self.max_carrier_offset = max_carrier_offset = 2 * math.pi * 100e3 / sample_rate self.gain = gain = saved_gain self.freq = freq = saved_freq self.decim_text = decim_text = decim ################################################## # Notebooks ################################################## self.displays = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.displays.AddPage(grc_wxgui.Panel(self.displays), "RX") self.displays.AddPage(grc_wxgui.Panel(self.displays), "Demod") self.GridAdd(self.displays, 2, 0, 1, 4) ################################################## # Controls ################################################## _sync_alpha_sizer = wx.BoxSizer(wx.VERTICAL) self._sync_alpha_text_box = forms.text_box( parent=self.GetWin(), sizer=_sync_alpha_sizer, value=self.sync_alpha, callback=self.set_sync_alpha, label="SYNC Alpha", converter=forms.float_converter(), proportion=0, ) self._sync_alpha_slider = forms.slider( parent=self.GetWin(), sizer=_sync_alpha_sizer, value=self.sync_alpha, callback=self.set_sync_alpha, minimum=0.0, maximum=0.5, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_sync_alpha_sizer, 0, 3, 1, 1) self._side_text_static_text = forms.static_text( parent=self.GetWin(), value=self.side_text, callback=self.set_side_text, label="USRP Side", converter=forms.str_converter(), ) self.GridAdd(self._side_text_static_text, 1, 0, 1, 1) _pll_alpha_sizer = wx.BoxSizer(wx.VERTICAL) self._pll_alpha_text_box = forms.text_box( parent=self.GetWin(), sizer=_pll_alpha_sizer, value=self.pll_alpha, callback=self.set_pll_alpha, label="PLL Alpha", converter=forms.float_converter(), proportion=0, ) self._pll_alpha_slider = forms.slider( parent=self.GetWin(), sizer=_pll_alpha_sizer, value=self.pll_alpha, callback=self.set_pll_alpha, minimum=0.0, maximum=0.5, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_pll_alpha_sizer, 0, 2, 1, 1) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label="RX Gain", converter=forms.float_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_gain_sizer, 0, 1, 1, 1) self._freq_text_box = forms.text_box( parent=self.GetWin(), value=self.freq, callback=self.set_freq, label="Frequency", converter=forms.float_converter(), ) self.GridAdd(self._freq_text_box, 0, 0, 1, 1) self._decim_text_static_text = forms.static_text( parent=self.GetWin(), value=self.decim_text, callback=self.set_decim_text, label="Decimation", converter=forms.float_converter(), ) self.GridAdd(self._decim_text_static_text, 1, 1, 1, 1) ################################################## # Blocks ################################################## self.agc = gr.agc_cc(1e-6, 1.0, 1.0, 1.0) self.decoder = noaa.hrpt_decoder() self.deframer = noaa.hrpt_deframer() self.frame_sink = gr.file_sink(gr.sizeof_short * 1, output_filename) self.gr_fir_filter_xxx_0 = gr.fir_filter_ccc(1, (mf_taps)) self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha ** 2 / 4.0, max_carrier_offset) self.pll_scope = scopesink2.scope_sink_f( self.displays.GetPage(1).GetWin(), title="Demod Waveform", sample_rate=sample_rate, v_scale=0.5, t_scale=20.0 / sample_rate, ac_couple=False, xy_mode=False, num_inputs=1, ) self.displays.GetPage(1).GridAdd(self.pll_scope.win, 0, 0, 1, 1) self.rx_fft = fftsink2.fft_sink_c( self.displays.GetPage(0).GetWin(), baseband_freq=freq, y_per_div=5, y_divs=8, ref_level=-5, ref_scale=2.0, sample_rate=sample_rate, fft_size=1024, fft_rate=15, average=True, avg_alpha=0.1, title="RX Spectrum", peak_hold=False, ) self.displays.GetPage(0).GridAdd(self.rx_fft.win, 0, 0, 1, 1) self.rx_scope = scopesink2.scope_sink_c( self.displays.GetPage(0).GetWin(), title="RX Waveform", sample_rate=sample_rate, v_scale=0, t_scale=20.0 / sample_rate, ac_couple=False, xy_mode=False, num_inputs=1, ) self.displays.GetPage(0).GridAdd(self.rx_scope.win, 1, 0, 1, 1) self.sync = noaa.hrpt_sync_fb(sync_alpha, sync_alpha ** 2 / 4.0, sps, max_sync_offset) self.usrp_source = grc_usrp.simple_source_c(which=0, side=side, rx_ant="RXA") self.usrp_source.set_decim_rate(decim) self.usrp_source.set_frequency(freq, verbose=True) self.usrp_source.set_gain(gain) ################################################## # Connections ################################################## self.connect((self.deframer, 0), (self.frame_sink, 0)) self.connect((self.sync, 0), (self.deframer, 0)) self.connect((self.pll, 0), (self.sync, 0)) self.connect((self.pll, 0), (self.pll_scope, 0)) self.connect((self.agc, 0), (self.rx_scope, 0)) self.connect((self.agc, 0), (self.rx_fft, 0)) self.connect((self.deframer, 0), (self.decoder, 0)) self.connect((self.agc, 0), (self.gr_fir_filter_xxx_0, 0)) self.connect((self.gr_fir_filter_xxx_0, 0), (self.pll, 0)) self.connect((self.usrp_source, 0), (self.agc, 0))
def __init__(self, deframer_insync_frames=2, deframer_sync_check=True, viterbi_insync_frames=5, deframer_outsync_frames=5, viterbi_outsync_frames=20, viterbi_sync_check=True, viterbi_sync_threshold=0.1, satellite='GOES-LRIT', freq=1691.02e6, gain=23, decim=108, side="A", pll_alpha=0.005, symb_rate=293883, clock_alpha=0.005): grc_wxgui.top_block_gui.__init__( self, title="USRP LRIT Receiver - check signal quality") ################################################## # Parameters ################################################## self.deframer_insync_frames = deframer_insync_frames self.deframer_sync_check = deframer_sync_check self.viterbi_insync_frames = viterbi_insync_frames self.deframer_outsync_frames = deframer_outsync_frames self.viterbi_outsync_frames = viterbi_outsync_frames self.viterbi_sync_check = viterbi_sync_check self.viterbi_sync_threshold = viterbi_sync_threshold self.satellite = satellite self.freq = freq self.gain = gain self.decim = decim self.side = side self.pll_alpha = pll_alpha self.symb_rate = symb_rate self.clock_alpha = clock_alpha ################################################## # Variables ################################################## self.decim_tb = decim_tb = decim self.symb_rate_tb = symb_rate_tb = symb_rate self.samp_rate = samp_rate = 64e6 / decim_tb self.viterbi_sync_threshold_text = viterbi_sync_threshold_text = viterbi_sync_threshold self.viterbi_sync_after_text = viterbi_sync_after_text = viterbi_insync_frames self.viterbi_outofsync_after_text = viterbi_outofsync_after_text = viterbi_outsync_frames self.viterbi_node_sync_text = viterbi_node_sync_text = viterbi_sync_check self.sps = sps = samp_rate / symb_rate_tb self.satellite_text = satellite_text = satellite self.samp_rate_st = samp_rate_st = samp_rate self.pll_alpha_sl = pll_alpha_sl = pll_alpha self.gain_tb = gain_tb = gain self.freq_tb = freq_tb = freq self.frames_file_text_inf = frames_file_text_inf = 'no output file' self.deframer_sync_after_text = deframer_sync_after_text = deframer_insync_frames self.deframer_nosync_after_text = deframer_nosync_after_text = deframer_outsync_frames self.deframer_check_sync_text = deframer_check_sync_text = deframer_sync_check self.datetime_text = datetime_text = strftime("%A, %B %d %Y %H:%M:%S", localtime()) self.clock_alpha_sl = clock_alpha_sl = clock_alpha self.baseband_file_text_inf = baseband_file_text_inf = 'no output file' ################################################## # Notebooks ################################################## self.rx_ntb = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "USRP Receiver") self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "PLL demodulator and Clock sync") self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "Viterbi decoder") self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "Deframer") self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "Output") self.Add(self.rx_ntb) ################################################## # Controls ################################################## self._decim_tb_text_box = forms.text_box( parent=self.rx_ntb.GetPage(0).GetWin(), value=self.decim_tb, callback=self.set_decim_tb, label="Decimation", converter=forms.int_converter(), ) self.rx_ntb.GetPage(0).GridAdd(self._decim_tb_text_box, 1, 3, 1, 1) self._symb_rate_tb_text_box = forms.text_box( parent=self.rx_ntb.GetPage(1).GetWin(), value=self.symb_rate_tb, callback=self.set_symb_rate_tb, label="Symbol rate", converter=forms.int_converter(), ) self.rx_ntb.GetPage(1).GridAdd(self._symb_rate_tb_text_box, 2, 1, 1, 1) self._viterbi_sync_threshold_text_static_text = forms.static_text( parent=self.rx_ntb.GetPage(2).GetWin(), value=self.viterbi_sync_threshold_text, callback=self.set_viterbi_sync_threshold_text, label="Viterbi node sync threshold [BER]", converter=forms.float_converter(), ) self.rx_ntb.GetPage(2).GridAdd( self._viterbi_sync_threshold_text_static_text, 3, 0, 1, 1) self._viterbi_sync_after_text_static_text = forms.static_text( parent=self.rx_ntb.GetPage(2).GetWin(), value=self.viterbi_sync_after_text, callback=self.set_viterbi_sync_after_text, label="Valid frames for Viterbi decoder sync", converter=forms.float_converter(), ) self.rx_ntb.GetPage(2).GridAdd( self._viterbi_sync_after_text_static_text, 4, 0, 1, 1) self._viterbi_outofsync_after_text_static_text = forms.static_text( parent=self.rx_ntb.GetPage(2).GetWin(), value=self.viterbi_outofsync_after_text, callback=self.set_viterbi_outofsync_after_text, label="Invalid frames for Viterbi decoder out of sync", converter=forms.float_converter(), ) self.rx_ntb.GetPage(2).GridAdd( self._viterbi_outofsync_after_text_static_text, 5, 0, 1, 1) self._viterbi_node_sync_text_static_text = forms.static_text( parent=self.rx_ntb.GetPage(2).GetWin(), value=self.viterbi_node_sync_text, callback=self.set_viterbi_node_sync_text, label="Viterbi node sync enable", converter=forms.str_converter(), ) self.rx_ntb.GetPage(2).GridAdd( self._viterbi_node_sync_text_static_text, 2, 0, 1, 1) self._satellite_text_static_text = forms.static_text( parent=self.rx_ntb.GetPage(0).GetWin(), value=self.satellite_text, callback=self.set_satellite_text, label="Sat ", converter=forms.str_converter(), ) self.rx_ntb.GetPage(0).GridAdd(self._satellite_text_static_text, 1, 0, 1, 1) self._samp_rate_st_static_text = forms.static_text( parent=self.rx_ntb.GetPage(0).GetWin(), value=self.samp_rate_st, callback=self.set_samp_rate_st, label="Sample rate", converter=forms.float_converter(), ) self.rx_ntb.GetPage(0).GridAdd(self._samp_rate_st_static_text, 1, 4, 1, 1) _pll_alpha_sl_sizer = wx.BoxSizer(wx.VERTICAL) self._pll_alpha_sl_text_box = forms.text_box( parent=self.rx_ntb.GetPage(1).GetWin(), sizer=_pll_alpha_sl_sizer, value=self.pll_alpha_sl, callback=self.set_pll_alpha_sl, label="PLL Alpha", converter=forms.float_converter(), proportion=0, ) self._pll_alpha_sl_slider = forms.slider( parent=self.rx_ntb.GetPage(1).GetWin(), sizer=_pll_alpha_sl_sizer, value=self.pll_alpha_sl, callback=self.set_pll_alpha_sl, minimum=0.001, maximum=0.1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.rx_ntb.GetPage(1).GridAdd(_pll_alpha_sl_sizer, 1, 0, 1, 1) self._gain_tb_text_box = forms.text_box( parent=self.rx_ntb.GetPage(0).GetWin(), value=self.gain_tb, callback=self.set_gain_tb, label="RX gain [dB]", converter=forms.int_converter(), ) self.rx_ntb.GetPage(0).GridAdd(self._gain_tb_text_box, 1, 2, 1, 1) self._freq_tb_text_box = forms.text_box( parent=self.rx_ntb.GetPage(0).GetWin(), value=self.freq_tb, callback=self.set_freq_tb, label="Frequency", converter=forms.float_converter(), ) self.rx_ntb.GetPage(0).GridAdd(self._freq_tb_text_box, 1, 1, 1, 1) self._frames_file_text_inf_static_text = forms.static_text( parent=self.rx_ntb.GetPage(4).GetWin(), value=self.frames_file_text_inf, callback=self.set_frames_file_text_inf, label="Frames filename", converter=forms.str_converter(), ) self.rx_ntb.GetPage(4).GridAdd(self._frames_file_text_inf_static_text, 3, 0, 1, 1) self._deframer_sync_after_text_static_text = forms.static_text( parent=self.rx_ntb.GetPage(3).GetWin(), value=self.deframer_sync_after_text, callback=self.set_deframer_sync_after_text, label="Deframe sync after", converter=forms.float_converter(), ) self.rx_ntb.GetPage(3).GridAdd( self._deframer_sync_after_text_static_text, 3, 0, 1, 1) self._deframer_nosync_after_text_static_text = forms.static_text( parent=self.rx_ntb.GetPage(3).GetWin(), value=self.deframer_nosync_after_text, callback=self.set_deframer_nosync_after_text, label="Deframer out of sync after", converter=forms.float_converter(), ) self.rx_ntb.GetPage(3).GridAdd( self._deframer_nosync_after_text_static_text, 4, 0, 1, 1) self._deframer_check_sync_text_static_text = forms.static_text( parent=self.rx_ntb.GetPage(3).GetWin(), value=self.deframer_check_sync_text, callback=self.set_deframer_check_sync_text, label="Deframer check sync enable", converter=forms.str_converter(), ) self.rx_ntb.GetPage(3).GridAdd( self._deframer_check_sync_text_static_text, 2, 0, 1, 1) self._datetime_text_static_text = forms.static_text( parent=self.rx_ntb.GetPage(4).GetWin(), value=self.datetime_text, callback=self.set_datetime_text, label="Local time of aquisition start", converter=forms.str_converter(), ) self.rx_ntb.GetPage(4).GridAdd(self._datetime_text_static_text, 1, 0, 1, 1) _clock_alpha_sl_sizer = wx.BoxSizer(wx.VERTICAL) self._clock_alpha_sl_text_box = forms.text_box( parent=self.rx_ntb.GetPage(1).GetWin(), sizer=_clock_alpha_sl_sizer, value=self.clock_alpha_sl, callback=self.set_clock_alpha_sl, label="Clock alpha", converter=forms.float_converter(), proportion=0, ) self._clock_alpha_sl_slider = forms.slider( parent=self.rx_ntb.GetPage(1).GetWin(), sizer=_clock_alpha_sl_sizer, value=self.clock_alpha_sl, callback=self.set_clock_alpha_sl, minimum=0.001, maximum=0.1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.rx_ntb.GetPage(1).GridAdd(_clock_alpha_sl_sizer, 1, 1, 1, 1) self._baseband_file_text_inf_static_text = forms.static_text( parent=self.rx_ntb.GetPage(4).GetWin(), value=self.baseband_file_text_inf, callback=self.set_baseband_file_text_inf, label="Baseband filename", converter=forms.str_converter(), ) self.rx_ntb.GetPage(4).GridAdd( self._baseband_file_text_inf_static_text, 4, 0, 1, 1) ################################################## # Blocks ################################################## self.fec_decode_viterbi_bpsk_fb_0 = fec.decode_viterbi_bpsk_fb( viterbi_sync_check, viterbi_sync_threshold, viterbi_insync_frames, viterbi_outsync_frames, viterbi_outsync_frames * 3) self.gr_agc_xx_0 = gr.agc_cc(10e-6, 1, 1.0 / 32767.0, 1.0) self.gr_clock_recovery_mm_xx_0 = gr.clock_recovery_mm_cc( sps, clock_alpha_sl * clock_alpha_sl / 4.0, 0.5, clock_alpha_sl, 0.05) self.gr_complex_to_real_0 = gr.complex_to_real(1) self.gr_costas_loop_cc_0 = gr.costas_loop_cc( pll_alpha_sl, pll_alpha_sl * pll_alpha_sl / 4.0, 0.07, -0.07, 2) self.gr_multiply_const_vxx_0 = gr.multiply_const_vcc((1, )) self.gr_null_sink_0 = gr.null_sink(gr.sizeof_char * 1) self.gr_packed_to_unpacked_xx_0 = gr.packed_to_unpacked_bb( 1, gr.GR_MSB_FIRST) self.poesweather_metop_cadu_deframer_0 = poesweather.metop_cadu_deframer( True, 1024, deframer_insync_frames, deframer_outsync_frames) self.root_raised_cosine_filter_0 = gr.fir_filter_ccf( 1, firdes.root_raised_cosine(1, samp_rate, symb_rate, 0.25, int(11 * samp_rate / symb_rate))) self.usrp_simple_source = grc_usrp.simple_source_c(which=0, side=side, rx_ant="RXA") self.usrp_simple_source.set_decim_rate(decim_tb) self.usrp_simple_source.set_frequency(freq_tb, verbose=True) self.usrp_simple_source.set_gain(gain_tb) self.wxgui_fftsink1 = fftsink2.fft_sink_c( self.rx_ntb.GetPage(0).GetWin(), baseband_freq=freq, y_per_div=2, y_divs=10, ref_level=12, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=30, average=True, avg_alpha=0.1, title="Not filtered spectrum", peak_hold=False, ) self.rx_ntb.GetPage(0).Add(self.wxgui_fftsink1.win) self.wxgui_fftsink2 = fftsink2.fft_sink_c( self.rx_ntb.GetPage(0).GetWin(), baseband_freq=0, y_per_div=2, y_divs=10, ref_level=12, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=30, average=True, avg_alpha=0.1, title="RRC filtered spectrum", peak_hold=False, ) self.rx_ntb.GetPage(0).Add(self.wxgui_fftsink2.win) self.wxgui_scopesink2_1 = scopesink2.scope_sink_c( self.rx_ntb.GetPage(1).GetWin(), title="BPSK constellation diagram", sample_rate=symb_rate, v_scale=0.4, v_offset=0, t_scale=1 / samp_rate, ac_couple=False, xy_mode=True, num_inputs=1, ) self.rx_ntb.GetPage(1).Add(self.wxgui_scopesink2_1.win) ################################################## # Connections ################################################## self.connect((self.usrp_simple_source, 0), (self.gr_agc_xx_0, 0)) self.connect((self.gr_agc_xx_0, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.gr_complex_to_real_0, 0)) self.connect((self.fec_decode_viterbi_bpsk_fb_0, 0), (self.gr_packed_to_unpacked_xx_0, 0)) self.connect((self.gr_packed_to_unpacked_xx_0, 0), (self.poesweather_metop_cadu_deframer_0, 0)) self.connect((self.gr_complex_to_real_0, 0), (self.fec_decode_viterbi_bpsk_fb_0, 0)) self.connect((self.gr_clock_recovery_mm_xx_0, 0), (self.gr_multiply_const_vxx_0, 0)) self.connect((self.gr_costas_loop_cc_0, 0), (self.gr_clock_recovery_mm_xx_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.gr_costas_loop_cc_0, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.wxgui_scopesink2_1, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.wxgui_fftsink2, 0)) self.connect((self.gr_agc_xx_0, 0), (self.wxgui_fftsink1, 0)) self.connect((self.poesweather_metop_cadu_deframer_0, 0), (self.gr_null_sink_0, 0))
def __init__(self): gr.top_block.__init__(self, "Usrp Rx Hrpt Nogui") ################################################## # Variables ################################################## self.config_filename = config_filename = os.environ['HOME']+'/.gnuradio/config.conf' self._decim_config = ConfigParser.ConfigParser() self._decim_config.read(config_filename) try: decim = self._decim_config.getfloat('usrp_rx_hrpt', 'decim') except: decim = 32 self.decim = decim self.sym_rate = sym_rate = 600*1109 self.sample_rate = sample_rate = 64e6/decim self.sps = sps = sample_rate/sym_rate self._side_config = ConfigParser.ConfigParser() self._side_config.read(config_filename) try: side = self._side_config.get('usrp_rx_hrpt', 'side') except: side = 'A' self.side = side self._pll_alpha_config = ConfigParser.ConfigParser() self._pll_alpha_config.read(config_filename) try: pll_alpha = self._pll_alpha_config.getfloat('usrp_rx_hrpt', 'pll_alpha') except: pll_alpha = 0.01 self.pll_alpha = pll_alpha self._output_filename_config = ConfigParser.ConfigParser() self._output_filename_config.read(config_filename) try: output_filename = self._output_filename_config.get('usrp_rx_hrpt', 'filename') except: output_filename = 'frames.hrpt' self.output_filename = output_filename self.max_clock_offset = max_clock_offset = 100e-6 self.max_carrier_offset = max_carrier_offset = 2*math.pi*100e3/sample_rate self.hs = hs = int(sps/2.0) self._gain_config = ConfigParser.ConfigParser() self._gain_config.read(config_filename) try: gain = self._gain_config.getfloat('usrp_rx_hrpt', 'gain') except: gain = 35 self.gain = gain self._freq_config = ConfigParser.ConfigParser() self._freq_config.read(config_filename) try: freq = self._freq_config.getfloat('usrp_rx_hrpt', 'freq') except: freq = 1698e6 self.freq = freq self._clock_alpha_config = ConfigParser.ConfigParser() self._clock_alpha_config.read(config_filename) try: clock_alpha = self._clock_alpha_config.getfloat('usrp_rx_hrpt', 'clock_alpha') except: clock_alpha = 0.01 self.clock_alpha = clock_alpha ################################################## # Blocks ################################################## self.agc = gr.agc_cc(1e-6, 1.0, 1.0, 1.0) self.decoder = noaa.hrpt_decoder(True,True) self.deframer = noaa.hrpt_deframer() self.frame_sink = gr.file_sink(gr.sizeof_short*1, output_filename) self.gr_binary_slicer_fb_0 = gr.binary_slicer_fb() self.gr_clock_recovery_mm_xx_0 = gr.clock_recovery_mm_ff(sps/2.0, clock_alpha**2/4.0, 0.5, clock_alpha, max_clock_offset) self.gr_moving_average_xx_0 = gr.moving_average_ff(hs, 1.0/hs, 4000) self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2/4.0, max_carrier_offset) self.usrp_source = grc_usrp.simple_source_c(which=0, side=side, rx_ant="RXA") self.usrp_source.set_decim_rate(decim) self.usrp_source.set_frequency(freq, verbose=True) self.usrp_source.set_gain(gain) ################################################## # Connections ################################################## self.connect((self.usrp_source, 0), (self.agc, 0)) self.connect((self.agc, 0), (self.pll, 0)) self.connect((self.pll, 0), (self.gr_moving_average_xx_0, 0)) self.connect((self.gr_moving_average_xx_0, 0), (self.gr_clock_recovery_mm_xx_0, 0)) self.connect((self.gr_clock_recovery_mm_xx_0, 0), (self.gr_binary_slicer_fb_0, 0)) self.connect((self.deframer, 0), (self.frame_sink, 0)) self.connect((self.deframer, 0), (self.decoder, 0)) self.connect((self.gr_binary_slicer_fb_0, 0), (self.deframer, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__( self, title="USRP FLEX Pager Receiver (Single Channel)") ################################################## # Variables ################################################## self.config_filename = config_filename = os.environ[ "HOME"] + "/.gnuradio/config.conf" self.symbol_rate = symbol_rate = 3200 self._saved_channel_config = ConfigParser.ConfigParser() self._saved_channel_config.read(config_filename) try: saved_channel = self._saved_channel_config.getint( "gr-pager", "channel") except: saved_channel = 25 self.saved_channel = saved_channel self._saved_band_freq_config = ConfigParser.ConfigParser() self._saved_band_freq_config.read(config_filename) try: saved_band_freq = self._saved_band_freq_config.getfloat( "gr-pager", "band_center") except: saved_band_freq = 930.5125e6 self.saved_band_freq = saved_band_freq self.deviation = deviation = 4800 self.decim = decim = 20 self.adc_rate = adc_rate = 64e6 self.sample_rate = sample_rate = adc_rate / decim self.passband = passband = 2 * (deviation + symbol_rate) self.channel_rate = channel_rate = 8 * 3200 self.channel = channel = saved_channel self.band_freq = band_freq = saved_band_freq self._saved_rx_gain_config = ConfigParser.ConfigParser() self._saved_rx_gain_config.read(config_filename) try: saved_rx_gain = self._saved_rx_gain_config.getint( "gr-pager", "rx_gain") except: saved_rx_gain = 40 self.saved_rx_gain = saved_rx_gain self._saved_offset_config = ConfigParser.ConfigParser() self._saved_offset_config.read(config_filename) try: saved_offset = self._saved_offset_config.getfloat( "gr-pager", "freq_offset") except: saved_offset = 0 self.saved_offset = saved_offset self.freq = freq = band_freq + (channel - 61) * 25e3 self.channel_taps = channel_taps = firdes.low_pass( 10, sample_rate, passband / 2.0, (channel_rate - passband) / 2.0) self.rx_gain = rx_gain = saved_rx_gain self.offset = offset = saved_offset self.nchan_taps = nchan_taps = len(channel_taps) self.ma_ntaps = ma_ntaps = int(channel_rate / symbol_rate) self.freq_text = freq_text = freq self.demod_k = demod_k = 3 * channel_rate / (2 * math.pi * deviation) self.channel_decim = channel_decim = int(sample_rate / channel_rate) self.bb_interp = bb_interp = 5 self.bb_decim = bb_decim = 8 self.baseband_rate = baseband_rate = 16000 ################################################## # Notebooks ################################################## self.displays = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.displays.AddPage(grc_wxgui.Panel(self.displays), "RX Spectrum") self.displays.AddPage(grc_wxgui.Panel(self.displays), "Baseband") self.GridAdd(self.displays, 1, 0, 1, 5) ################################################## # Controls ################################################## _channel_sizer = wx.BoxSizer(wx.VERTICAL) self._channel_text_box = forms.text_box( parent=self.GetWin(), sizer=_channel_sizer, value=self.channel, callback=self.set_channel, label="Channel", converter=forms.int_converter(), proportion=0, ) self._channel_slider = forms.slider( parent=self.GetWin(), sizer=_channel_sizer, value=self.channel, callback=self.set_channel, minimum=1, maximum=120, num_steps=119, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.GridAdd(_channel_sizer, 0, 1, 1, 1) self._band_freq_text_box = forms.text_box( parent=self.GetWin(), value=self.band_freq, callback=self.set_band_freq, label="Band Freq.", converter=forms.float_converter(), ) self.GridAdd(self._band_freq_text_box, 0, 0, 1, 1) _rx_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._rx_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_rx_gain_sizer, value=self.rx_gain, callback=self.set_rx_gain, label="Analog Gain", converter=forms.int_converter(), proportion=0, ) self._rx_gain_slider = forms.slider( parent=self.GetWin(), sizer=_rx_gain_sizer, value=self.rx_gain, callback=self.set_rx_gain, minimum=0, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.GridAdd(_rx_gain_sizer, 0, 4, 1, 1) _offset_sizer = wx.BoxSizer(wx.VERTICAL) self._offset_text_box = forms.text_box( parent=self.GetWin(), sizer=_offset_sizer, value=self.offset, callback=self.set_offset, label="Freq. Offset", converter=forms.float_converter(), proportion=0, ) self._offset_slider = forms.slider( parent=self.GetWin(), sizer=_offset_sizer, value=self.offset, callback=self.set_offset, minimum=-12.5e3, maximum=12.5e3, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_offset_sizer, 0, 3, 1, 1) self._freq_text_static_text = forms.static_text( parent=self.GetWin(), value=self.freq_text, callback=self.set_freq_text, label="Ch. Freq", converter=forms.float_converter(), ) self.GridAdd(self._freq_text_static_text, 0, 2, 1, 1) ################################################## # Blocks ################################################## self.fm_demod = gr.quadrature_demod_cf(demod_k) self.gr_freq_xlating_fir_filter_xxx_0 = gr.freq_xlating_fir_filter_ccc( channel_decim, (channel_taps), band_freq - freq + offset, sample_rate) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_int * 1) self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_int * 1) self.blocks_null_sink_0_1 = blocks.null_sink(gr.sizeof_int * 1) self.blocks_null_sink_0_2 = blocks.null_sink(gr.sizeof_int * 1) self.pager_flex_deinterleave_0 = pager.flex_deinterleave() self.pager_flex_deinterleave_0_0 = pager.flex_deinterleave() self.pager_flex_deinterleave_0_1 = pager.flex_deinterleave() self.pager_flex_deinterleave_0_1_0 = pager.flex_deinterleave() self.pager_flex_sync_0 = pager.flex_sync() self.pager_slicer_fb_0 = pager.slicer_fb(1e-6) self.resampler = filter.rational_resampler_fff( interpolation=bb_interp, decimation=bb_decim, taps=([ 1.0 / ma_ntaps, ] * ma_ntaps * bb_interp), fractional_bw=None, ) self.usrp_source = grc_usrp.simple_source_c(which=0, side="A", rx_ant="RXA") self.usrp_source.set_decim_rate(decim) self.usrp_source.set_frequency(band_freq, verbose=True) self.usrp_source.set_gain(rx_gain) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.displays.GetPage(0).GetWin(), baseband_freq=band_freq, y_per_div=10, y_divs=10, ref_level=0, ref_scale=65536, sample_rate=sample_rate, fft_size=1024, fft_rate=30, average=False, avg_alpha=None, title="FLEX Spectrum", peak_hold=False, ) self.displays.GetPage(0).GridAdd(self.wxgui_fftsink2_0.win, 0, 0, 1, 1) self.wxgui_fftsink2_1 = fftsink2.fft_sink_c( self.displays.GetPage(0).GetWin(), baseband_freq=freq, y_per_div=10, y_divs=10, ref_level=0, ref_scale=65536, sample_rate=channel_rate, fft_size=1024, fft_rate=30, average=False, avg_alpha=None, title="Channel Spectrum", peak_hold=False, ) self.displays.GetPage(0).GridAdd(self.wxgui_fftsink2_1.win, 1, 0, 1, 1) self.wxgui_scopesink2_0_0 = scopesink2.scope_sink_f( self.displays.GetPage(1).GetWin(), title="Baseband", sample_rate=16e3, v_scale=1, v_offset=0, t_scale=40.0 / 16e3, ac_couple=False, xy_mode=False, num_inputs=1, ) self.displays.GetPage(1).GridAdd(self.wxgui_scopesink2_0_0.win, 0, 0, 1, 1) ################################################## # Connections ################################################## self.connect((self.gr_freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_fftsink2_1, 0)) self.connect((self.usrp_source, 0), (self.gr_freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.usrp_source, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.gr_freq_xlating_fir_filter_xxx_0, 0), (self.fm_demod, 0)) self.connect((self.resampler, 0), (self.wxgui_scopesink2_0_0, 0)) self.connect((self.fm_demod, 0), (self.resampler, 0)) self.connect((self.pager_slicer_fb_0, 0), (self.pager_flex_sync_0, 0)) self.connect((self.resampler, 0), (self.pager_slicer_fb_0, 0)) self.connect((self.pager_flex_sync_0, 1), (self.pager_flex_deinterleave_0_1_0, 0)) self.connect((self.pager_flex_sync_0, 2), (self.pager_flex_deinterleave_0_1, 0)) self.connect((self.pager_flex_sync_0, 0), (self.pager_flex_deinterleave_0, 0)) self.connect((self.pager_flex_sync_0, 3), (self.pager_flex_deinterleave_0_0, 0)) self.connect((self.pager_flex_deinterleave_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.pager_flex_deinterleave_0_1_0, 0), (self.blocks_null_sink_0_0, 0)) self.connect((self.pager_flex_deinterleave_0_1, 0), (self.blocks_null_sink_0_1, 0)) self.connect((self.pager_flex_deinterleave_0_0, 0), (self.blocks_null_sink_0_2, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="USRP LRIT Receiver") ################################################## # Variables ################################################## self.config_filename = config_filename = os.environ[ 'HOME'] + '/.gnuradio/config.conf' self._saved_decim_config = ConfigParser.ConfigParser() self._saved_decim_config.read(config_filename) try: saved_decim = self._saved_decim_config.getint( 'usrp_rx_lrit', 'decim') except: saved_decim = 160 self.saved_decim = saved_decim self.decim = decim = saved_decim self.symbol_rate = symbol_rate = 293e3 self._saved_offset_config = ConfigParser.ConfigParser() self._saved_offset_config.read(config_filename) try: saved_offset = self._saved_offset_config.getfloat( 'usrp_rx_lrit', 'offset') except: saved_offset = 0 self.saved_offset = saved_offset self._saved_gain_mu_config = ConfigParser.ConfigParser() self._saved_gain_mu_config.read(config_filename) try: saved_gain_mu = self._saved_gain_mu_config.getfloat( 'usrp_rx_lrit', 'gain_mu') except: saved_gain_mu = 0.005 self.saved_gain_mu = saved_gain_mu self._saved_gain_config = ConfigParser.ConfigParser() self._saved_gain_config.read(config_filename) try: saved_gain = self._saved_gain_config.getfloat( 'usrp_rx_lrit', 'gain') except: saved_gain = 33 self.saved_gain = saved_gain self._saved_freq_config = ConfigParser.ConfigParser() self._saved_freq_config.read(config_filename) try: saved_freq = self._saved_freq_config.getfloat( 'usrp_rx_lrit', 'freq') except: saved_freq = 1691e6 self.saved_freq = saved_freq self._saved_costas_alpha_config = ConfigParser.ConfigParser() self._saved_costas_alpha_config.read(config_filename) try: saved_costas_alpha = self._saved_costas_alpha_config.getfloat( 'usrp_rx_lrit', 'costas_alpha') except: saved_costas_alpha = 0.005 self.saved_costas_alpha = saved_costas_alpha self.sample_rate = sample_rate = 64e6 / decim self.sps = sps = sample_rate / symbol_rate self._side_config = ConfigParser.ConfigParser() self._side_config.read(config_filename) try: side = self._side_config.get('usrp_rx_lrit', 'side') except: side = 'A' self.side = side self.offset = offset = saved_offset self.gain_mu = gain_mu = saved_gain_mu self.gain = gain = saved_gain self.freq = freq = saved_freq self.costas_alpha = costas_alpha = saved_costas_alpha ################################################## # Notebooks ################################################## self.displays = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.displays.AddPage(grc_wxgui.Panel(self.displays), "USRP RX") self.displays.AddPage(grc_wxgui.Panel(self.displays), "RRC") self.displays.AddPage(grc_wxgui.Panel(self.displays), "PLL") self.displays.AddPage(grc_wxgui.Panel(self.displays), "Const") self.GridAdd(self.displays, 2, 0, 1, 3) ################################################## # Controls ################################################## self._decim_text_box = forms.text_box( parent=self.GetWin(), value=self.decim, callback=self.set_decim, label="Decim", converter=forms.int_converter(), ) self.GridAdd(self._decim_text_box, 0, 2, 1, 1) _offset_sizer = wx.BoxSizer(wx.VERTICAL) self._offset_text_box = forms.text_box( parent=self.GetWin(), sizer=_offset_sizer, value=self.offset, callback=self.set_offset, label="Offset", converter=forms.float_converter(), proportion=0, ) self._offset_slider = forms.slider( parent=self.GetWin(), sizer=_offset_sizer, value=self.offset, callback=self.set_offset, minimum=-50e3, maximum=50e3, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_offset_sizer, 0, 1, 1, 1) _gain_mu_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_mu_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_mu_sizer, value=self.gain_mu, callback=self.set_gain_mu, label="Gain Mu", converter=forms.float_converter(), proportion=0, ) self._gain_mu_slider = forms.slider( parent=self.GetWin(), sizer=_gain_mu_sizer, value=self.gain_mu, callback=self.set_gain_mu, minimum=0, maximum=0.5, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_gain_mu_sizer, 1, 2, 1, 1) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label="Gain", converter=forms.float_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=115, num_steps=115, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_gain_sizer, 1, 0, 1, 1) self._freq_text_box = forms.text_box( parent=self.GetWin(), value=self.freq, callback=self.set_freq, label="Frequency", converter=forms.float_converter(), ) self.GridAdd(self._freq_text_box, 0, 0, 1, 1) _costas_alpha_sizer = wx.BoxSizer(wx.VERTICAL) self._costas_alpha_text_box = forms.text_box( parent=self.GetWin(), sizer=_costas_alpha_sizer, value=self.costas_alpha, callback=self.set_costas_alpha, label="Costas Alpha", converter=forms.float_converter(), proportion=0, ) self._costas_alpha_slider = forms.slider( parent=self.GetWin(), sizer=_costas_alpha_sizer, value=self.costas_alpha, callback=self.set_costas_alpha, minimum=0, maximum=0.5, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_costas_alpha_sizer, 1, 1, 1, 1) ################################################## # Blocks ################################################## self.costas = gr.costas_loop_cc(costas_alpha, (costas_alpha**2.0) / 4.0, 50e-6 * sps, -50e-6 * sps, 2) self.costas_spectrum = fftsink2.fft_sink_c( self.displays.GetPage(2).GetWin(), baseband_freq=freq + offset, y_per_div=10, y_divs=10, ref_level=-15, ref_scale=2.0, sample_rate=sample_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="PLL Spectrum", peak_hold=False, ) self.displays.GetPage(2).GridAdd(self.costas_spectrum.win, 0, 0, 1, 1) self.costas_waveform = scopesink2.scope_sink_c( self.displays.GetPage(2).GetWin(), title="PLL Waveform", sample_rate=sample_rate, v_scale=0.5, v_offset=0, t_scale=20.0 / sample_rate, ac_couple=False, xy_mode=False, num_inputs=1, ) self.displays.GetPage(2).GridAdd(self.costas_waveform.win, 1, 0, 1, 1) self.gr_agc_xx_0 = gr.agc_cc(1e-6, 1.0, 1.0 / 32767.0, 1.0) self.mm_const = scopesink2.scope_sink_c( self.displays.GetPage(3).GetWin(), title="Constellation", sample_rate=symbol_rate, v_scale=0.5, v_offset=0, t_scale=20.0 / symbol_rate, ac_couple=False, xy_mode=True, num_inputs=1, ) self.displays.GetPage(3).GridAdd(self.mm_const.win, 1, 0, 1, 1) self.mm_spectrum = fftsink2.fft_sink_c( self.displays.GetPage(3).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=-15, ref_scale=2.0, sample_rate=symbol_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="Bit Sync Spectrum", peak_hold=False, ) self.displays.GetPage(3).GridAdd(self.mm_spectrum.win, 0, 0, 1, 1) self.mm_sync = gr.clock_recovery_mm_cc(sps, (gain_mu**2) / 4.0, 0.5, gain_mu, 50e-6 * sps) self.root_raised_cosine_filter_0 = gr.fir_filter_ccf( 1, firdes.root_raised_cosine(1, sample_rate, symbol_rate, 0.25, int(11 * sample_rate / symbol_rate))) self.rrc_spectrum = fftsink2.fft_sink_c( self.displays.GetPage(1).GetWin(), baseband_freq=freq + offset, y_per_div=10, y_divs=10, ref_level=-15, ref_scale=2.0, sample_rate=sample_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="RRC Spectrum", peak_hold=False, ) self.displays.GetPage(1).GridAdd(self.rrc_spectrum.win, 0, 0, 1, 1) self.rrc_waveform = scopesink2.scope_sink_c( self.displays.GetPage(1).GetWin(), title="RRC Waveform", sample_rate=sample_rate, v_scale=0.5, v_offset=0, t_scale=20.0 / sample_rate, ac_couple=False, xy_mode=False, num_inputs=1, ) self.displays.GetPage(1).GridAdd(self.rrc_waveform.win, 1, 0, 1, 1) self.rx_spectrum = fftsink2.fft_sink_c( self.displays.GetPage(0).GetWin(), baseband_freq=freq, y_per_div=10, y_divs=10, ref_level=50, ref_scale=2.0, sample_rate=sample_rate, fft_size=1024, fft_rate=30, average=False, avg_alpha=None, title="RX Spectrum", peak_hold=False, ) self.displays.GetPage(0).GridAdd(self.rx_spectrum.win, 0, 0, 1, 1) self.rx_waveform = scopesink2.scope_sink_c( self.displays.GetPage(0).GetWin(), title="RX Waveform", sample_rate=sample_rate, v_scale=0, v_offset=0, t_scale=20.0 / sample_rate, ac_couple=False, xy_mode=False, num_inputs=1, ) self.displays.GetPage(0).GridAdd(self.rx_waveform.win, 1, 0, 1, 1) self.usrp_simple_source_x_0 = grc_usrp.simple_source_c(which=0, side=side, rx_ant="RXA") self.usrp_simple_source_x_0.set_decim_rate(decim) self.usrp_simple_source_x_0.set_frequency(freq + offset, verbose=True) self.usrp_simple_source_x_0.set_gain(gain) ################################################## # Connections ################################################## self.connect((self.gr_agc_xx_0, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.usrp_simple_source_x_0, 0), (self.gr_agc_xx_0, 0)) self.connect((self.usrp_simple_source_x_0, 0), (self.rx_spectrum, 0)) self.connect((self.usrp_simple_source_x_0, 0), (self.rx_waveform, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.rrc_waveform, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.rrc_spectrum, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.costas, 0)) self.connect((self.costas, 0), (self.costas_spectrum, 0)) self.connect((self.costas, 0), (self.costas_waveform, 0)) self.connect((self.costas, 0), (self.mm_sync, 0)) self.connect((self.mm_sync, 0), (self.mm_spectrum, 0)) self.connect((self.mm_sync, 0), (self.mm_const, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="USRP FLEX Pager Receiver (Single Channel)") ################################################## # Variables ################################################## self.config_filename = config_filename = os.environ["HOME"]+"/.gnuradio/config.conf" self.symbol_rate = symbol_rate = 3200 self._saved_channel_config = ConfigParser.ConfigParser() self._saved_channel_config.read(config_filename) try: saved_channel = self._saved_channel_config.getint("gr-pager", "channel") except: saved_channel = 25 self.saved_channel = saved_channel self._saved_band_freq_config = ConfigParser.ConfigParser() self._saved_band_freq_config.read(config_filename) try: saved_band_freq = self._saved_band_freq_config.getfloat("gr-pager", "band_center") except: saved_band_freq = 930.5125e6 self.saved_band_freq = saved_band_freq self.deviation = deviation = 4800 self.decim = decim = 20 self.adc_rate = adc_rate = 64e6 self.sample_rate = sample_rate = adc_rate/decim self.passband = passband = 2*(deviation+symbol_rate) self.channel_rate = channel_rate = 8*3200 self.channel = channel = saved_channel self.band_freq = band_freq = saved_band_freq self._saved_rx_gain_config = ConfigParser.ConfigParser() self._saved_rx_gain_config.read(config_filename) try: saved_rx_gain = self._saved_rx_gain_config.getint("gr-pager", "rx_gain") except: saved_rx_gain = 40 self.saved_rx_gain = saved_rx_gain self._saved_offset_config = ConfigParser.ConfigParser() self._saved_offset_config.read(config_filename) try: saved_offset = self._saved_offset_config.getfloat("gr-pager", "freq_offset") except: saved_offset = 0 self.saved_offset = saved_offset self.freq = freq = band_freq+(channel-61)*25e3 self.channel_taps = channel_taps = firdes.low_pass(10, sample_rate, passband/2.0, (channel_rate-passband)/2.0) self.rx_gain = rx_gain = saved_rx_gain self.offset = offset = saved_offset self.nchan_taps = nchan_taps = len(channel_taps) self.ma_ntaps = ma_ntaps = int(channel_rate/symbol_rate) self.freq_text = freq_text = freq self.demod_k = demod_k = 3*channel_rate/(2*math.pi*deviation) self.channel_decim = channel_decim = int(sample_rate/channel_rate) self.bb_interp = bb_interp = 5 self.bb_decim = bb_decim = 8 self.baseband_rate = baseband_rate = 16000 ################################################## # Notebooks ################################################## self.displays = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.displays.AddPage(grc_wxgui.Panel(self.displays), "RX Spectrum") self.displays.AddPage(grc_wxgui.Panel(self.displays), "Baseband") self.GridAdd(self.displays, 1, 0, 1, 5) ################################################## # Controls ################################################## _channel_sizer = wx.BoxSizer(wx.VERTICAL) self._channel_text_box = forms.text_box( parent=self.GetWin(), sizer=_channel_sizer, value=self.channel, callback=self.set_channel, label="Channel", converter=forms.int_converter(), proportion=0, ) self._channel_slider = forms.slider( parent=self.GetWin(), sizer=_channel_sizer, value=self.channel, callback=self.set_channel, minimum=1, maximum=120, num_steps=119, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.GridAdd(_channel_sizer, 0, 1, 1, 1) self._band_freq_text_box = forms.text_box( parent=self.GetWin(), value=self.band_freq, callback=self.set_band_freq, label="Band Freq.", converter=forms.float_converter(), ) self.GridAdd(self._band_freq_text_box, 0, 0, 1, 1) _rx_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._rx_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_rx_gain_sizer, value=self.rx_gain, callback=self.set_rx_gain, label="Analog Gain", converter=forms.int_converter(), proportion=0, ) self._rx_gain_slider = forms.slider( parent=self.GetWin(), sizer=_rx_gain_sizer, value=self.rx_gain, callback=self.set_rx_gain, minimum=0, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.GridAdd(_rx_gain_sizer, 0, 4, 1, 1) _offset_sizer = wx.BoxSizer(wx.VERTICAL) self._offset_text_box = forms.text_box( parent=self.GetWin(), sizer=_offset_sizer, value=self.offset, callback=self.set_offset, label="Freq. Offset", converter=forms.float_converter(), proportion=0, ) self._offset_slider = forms.slider( parent=self.GetWin(), sizer=_offset_sizer, value=self.offset, callback=self.set_offset, minimum=-12.5e3, maximum=12.5e3, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_offset_sizer, 0, 3, 1, 1) self._freq_text_static_text = forms.static_text( parent=self.GetWin(), value=self.freq_text, callback=self.set_freq_text, label="Ch. Freq", converter=forms.float_converter(), ) self.GridAdd(self._freq_text_static_text, 0, 2, 1, 1) ################################################## # Blocks ################################################## self.fm_demod = gr.quadrature_demod_cf(demod_k) self.gr_freq_xlating_fir_filter_xxx_0 = gr.freq_xlating_fir_filter_ccc(channel_decim, (channel_taps), band_freq-freq+offset, sample_rate) self.gr_null_sink_0 = gr.null_sink(gr.sizeof_int*1) self.gr_null_sink_0_0 = gr.null_sink(gr.sizeof_int*1) self.gr_null_sink_0_1 = gr.null_sink(gr.sizeof_int*1) self.gr_null_sink_0_2 = gr.null_sink(gr.sizeof_int*1) self.pager_flex_deinterleave_0 = pager.flex_deinterleave() self.pager_flex_deinterleave_0_0 = pager.flex_deinterleave() self.pager_flex_deinterleave_0_1 = pager.flex_deinterleave() self.pager_flex_deinterleave_0_1_0 = pager.flex_deinterleave() self.pager_flex_sync_0 = pager.flex_sync() self.pager_slicer_fb_0 = pager.slicer_fb(1e-6) self.resampler = blks2.rational_resampler_fff( interpolation=bb_interp, decimation=bb_decim, taps=([1.0/ma_ntaps,]*ma_ntaps*bb_interp), fractional_bw=None, ) self.usrp_source = grc_usrp.simple_source_c(which=0, side="A", rx_ant="RXA") self.usrp_source.set_decim_rate(decim) self.usrp_source.set_frequency(band_freq, verbose=True) self.usrp_source.set_gain(rx_gain) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.displays.GetPage(0).GetWin(), baseband_freq=band_freq, y_per_div=10, y_divs=10, ref_level=0, ref_scale=65536, sample_rate=sample_rate, fft_size=1024, fft_rate=30, average=False, avg_alpha=None, title="FLEX Spectrum", peak_hold=False, ) self.displays.GetPage(0).GridAdd(self.wxgui_fftsink2_0.win, 0, 0, 1, 1) self.wxgui_fftsink2_1 = fftsink2.fft_sink_c( self.displays.GetPage(0).GetWin(), baseband_freq=freq, y_per_div=10, y_divs=10, ref_level=0, ref_scale=65536, sample_rate=channel_rate, fft_size=1024, fft_rate=30, average=False, avg_alpha=None, title="Channel Spectrum", peak_hold=False, ) self.displays.GetPage(0).GridAdd(self.wxgui_fftsink2_1.win, 1, 0, 1, 1) self.wxgui_scopesink2_0_0 = scopesink2.scope_sink_f( self.displays.GetPage(1).GetWin(), title="Baseband", sample_rate=16e3, v_scale=1, v_offset=0, t_scale=40.0/16e3, ac_couple=False, xy_mode=False, num_inputs=1, ) self.displays.GetPage(1).GridAdd(self.wxgui_scopesink2_0_0.win, 0, 0, 1, 1) ################################################## # Connections ################################################## self.connect((self.gr_freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_fftsink2_1, 0)) self.connect((self.usrp_source, 0), (self.gr_freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.usrp_source, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.gr_freq_xlating_fir_filter_xxx_0, 0), (self.fm_demod, 0)) self.connect((self.resampler, 0), (self.wxgui_scopesink2_0_0, 0)) self.connect((self.fm_demod, 0), (self.resampler, 0)) self.connect((self.pager_slicer_fb_0, 0), (self.pager_flex_sync_0, 0)) self.connect((self.resampler, 0), (self.pager_slicer_fb_0, 0)) self.connect((self.pager_flex_sync_0, 1), (self.pager_flex_deinterleave_0_1_0, 0)) self.connect((self.pager_flex_sync_0, 2), (self.pager_flex_deinterleave_0_1, 0)) self.connect((self.pager_flex_sync_0, 0), (self.pager_flex_deinterleave_0, 0)) self.connect((self.pager_flex_sync_0, 3), (self.pager_flex_deinterleave_0_0, 0)) self.connect((self.pager_flex_deinterleave_0, 0), (self.gr_null_sink_0, 0)) self.connect((self.pager_flex_deinterleave_0_1_0, 0), (self.gr_null_sink_0_0, 0)) self.connect((self.pager_flex_deinterleave_0_1, 0), (self.gr_null_sink_0_1, 0)) self.connect((self.pager_flex_deinterleave_0_0, 0), (self.gr_null_sink_0_2, 0))
def __init__(self): gr.top_block.__init__(self, "USRP HRPT Receiver") ################################################## # Variables ################################################## self.config_filename = config_filename = 'usrp_rx_hrpt.cfg' self._decim_config = ConfigParser.ConfigParser() self._decim_config.read(config_filename) try: decim = self._decim_config.getfloat('usrp', 'decim') except: decim = 16 self.decim = decim self.sym_rate = sym_rate = 600*1109 self.sample_rate = sample_rate = 64e6/decim self.sps = sps = sample_rate/sym_rate self.hs = hs = int(sps/2.0) self._sync_alpha_config = ConfigParser.ConfigParser() self._sync_alpha_config.read(config_filename) try: sync_alpha = self._sync_alpha_config.getfloat('demod', 'sync_alpha') except: sync_alpha = 0.05 self.sync_alpha = sync_alpha self._side_config = ConfigParser.ConfigParser() self._side_config.read(config_filename) try: side = self._side_config.get('usrp', 'side') except: side = 'A' self.side = side self._pll_alpha_config = ConfigParser.ConfigParser() self._pll_alpha_config.read(config_filename) try: pll_alpha = self._pll_alpha_config.getfloat('demod', 'pll_alpha') except: pll_alpha = 0.05 self.pll_alpha = pll_alpha self._output_filename_config = ConfigParser.ConfigParser() self._output_filename_config.read(config_filename) try: output_filename = self._output_filename_config.get('output', 'filename') except: output_filename = 'frames.dat' self.output_filename = output_filename self.mf_taps = mf_taps = [-0.5/hs,]*hs+[0.5/hs,]*hs self.max_sync_offset = max_sync_offset = 0.01 self.max_carrier_offset = max_carrier_offset = 2*math.pi*100e3/sample_rate self._gain_config = ConfigParser.ConfigParser() self._gain_config.read(config_filename) try: gain = self._gain_config.getfloat('usrp', 'gain') except: gain = 35 self.gain = gain self._freq_config = ConfigParser.ConfigParser() self._freq_config.read(config_filename) try: freq = self._freq_config.getfloat('usrp', 'freq') except: freq = 1698e6 self.freq = freq ################################################## # Blocks ################################################## self.agc = gr.agc_cc(1e-6, 1.0, 1.0, 1.0) self.decoder = noaa.hrpt_decoder() self.deframer = noaa.hrpt_deframer() self.frame_sink = gr.file_sink(gr.sizeof_short*1, output_filename) self.gr_fir_filter_xxx_0 = gr.fir_filter_ccc(1, (mf_taps)) self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2/4.0, max_carrier_offset) self.sync = noaa.hrpt_sync_fb(sync_alpha, sync_alpha**2/4.0, sps, max_sync_offset) self.usrp_source = grc_usrp.simple_source_c(which=0, side=side, rx_ant="RXA") self.usrp_source.set_decim_rate(decim) self.usrp_source.set_frequency(freq, verbose=True) self.usrp_source.set_gain(gain) ################################################## # Connections ################################################## self.connect((self.usrp_source, 0), (self.agc, 0)) self.connect((self.deframer, 0), (self.decoder, 0)) self.connect((self.pll, 0), (self.sync, 0)) self.connect((self.sync, 0), (self.deframer, 0)) self.connect((self.deframer, 0), (self.frame_sink, 0)) self.connect((self.agc, 0), (self.gr_fir_filter_xxx_0, 0)) self.connect((self.gr_fir_filter_xxx_0, 0), (self.pll, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="USRP HRPT Receiver") ################################################## # Variables ################################################## self.config_filename = config_filename = os.environ[ 'HOME'] + '/.gnuradio/config.conf' self._decim_config = ConfigParser.ConfigParser() self._decim_config.read(config_filename) try: decim = self._decim_config.getfloat('usrp_rx_hrpt', 'decim') except: decim = 32 self.decim = decim self.sym_rate = sym_rate = 600 * 1109 self.sample_rate = sample_rate = 64e6 / decim self.sps = sps = sample_rate / sym_rate self._side_config = ConfigParser.ConfigParser() self._side_config.read(config_filename) try: side = self._side_config.get('usrp_rx_hrpt', 'side') except: side = 'A' self.side = side self._saved_pll_alpha_config = ConfigParser.ConfigParser() self._saved_pll_alpha_config.read(config_filename) try: saved_pll_alpha = self._saved_pll_alpha_config.getfloat( 'usrp_rx_hrpt', 'pll_alpha') except: saved_pll_alpha = 0.01 self.saved_pll_alpha = saved_pll_alpha self._saved_gain_config = ConfigParser.ConfigParser() self._saved_gain_config.read(config_filename) try: saved_gain = self._saved_gain_config.getfloat( 'usrp_rx_hrpt', 'gain') except: saved_gain = 35 self.saved_gain = saved_gain self._saved_freq_config = ConfigParser.ConfigParser() self._saved_freq_config.read(config_filename) try: saved_freq = self._saved_freq_config.getfloat( 'usrp_rx_hrpt', 'freq') except: saved_freq = 1698e6 self.saved_freq = saved_freq self._saved_clock_alpha_config = ConfigParser.ConfigParser() self._saved_clock_alpha_config.read(config_filename) try: saved_clock_alpha = self._saved_clock_alpha_config.getfloat( 'usrp_rx_hrpt', 'clock_alpha') except: saved_clock_alpha = 0.01 self.saved_clock_alpha = saved_clock_alpha self.side_text = side_text = side self.pll_alpha = pll_alpha = saved_pll_alpha self._output_filename_config = ConfigParser.ConfigParser() self._output_filename_config.read(config_filename) try: output_filename = self._output_filename_config.get( 'usrp_rx_hrpt', 'filename') except: output_filename = 'frames.hrpt' self.output_filename = output_filename self.max_clock_offset = max_clock_offset = 100e-6 self.max_carrier_offset = max_carrier_offset = 2 * math.pi * 100e3 / sample_rate self.hs = hs = int(sps / 2.0) self.gain = gain = saved_gain self.freq = freq = saved_freq self.decim_text = decim_text = decim self.clock_alpha = clock_alpha = saved_clock_alpha ################################################## # Notebooks ################################################## self.displays = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.displays.AddPage(grc_wxgui.Panel(self.displays), "Spectrum") self.displays.AddPage(grc_wxgui.Panel(self.displays), "Demod") self.GridAdd(self.displays, 2, 0, 1, 4) ################################################## # Controls ################################################## self._side_text_static_text = forms.static_text( parent=self.GetWin(), value=self.side_text, callback=self.set_side_text, label="USRP Side", converter=forms.str_converter(), ) self.GridAdd(self._side_text_static_text, 1, 0, 1, 1) _pll_alpha_sizer = wx.BoxSizer(wx.VERTICAL) self._pll_alpha_text_box = forms.text_box( parent=self.GetWin(), sizer=_pll_alpha_sizer, value=self.pll_alpha, callback=self.set_pll_alpha, label="PLL Alpha", converter=forms.float_converter(), proportion=0, ) self._pll_alpha_slider = forms.slider( parent=self.GetWin(), sizer=_pll_alpha_sizer, value=self.pll_alpha, callback=self.set_pll_alpha, minimum=0.0, maximum=0.5, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_pll_alpha_sizer, 0, 2, 1, 1) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label="RX Gain", converter=forms.float_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_gain_sizer, 0, 1, 1, 1) self._freq_text_box = forms.text_box( parent=self.GetWin(), value=self.freq, callback=self.set_freq, label="Frequency", converter=forms.float_converter(), ) self.GridAdd(self._freq_text_box, 0, 0, 1, 1) self._decim_text_static_text = forms.static_text( parent=self.GetWin(), value=self.decim_text, callback=self.set_decim_text, label="Decimation", converter=forms.float_converter(), ) self.GridAdd(self._decim_text_static_text, 1, 1, 1, 1) _clock_alpha_sizer = wx.BoxSizer(wx.VERTICAL) self._clock_alpha_text_box = forms.text_box( parent=self.GetWin(), sizer=_clock_alpha_sizer, value=self.clock_alpha, callback=self.set_clock_alpha, label="Clock Alpha", converter=forms.float_converter(), proportion=0, ) self._clock_alpha_slider = forms.slider( parent=self.GetWin(), sizer=_clock_alpha_sizer, value=self.clock_alpha, callback=self.set_clock_alpha, minimum=0.0, maximum=0.5, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_clock_alpha_sizer, 0, 3, 1, 1) ################################################## # Blocks ################################################## self.agc = gr.agc_cc(1e-6, 1.0, 1.0, 1.0) self.decoder = noaa.hrpt_decoder(True, True) self.deframer = noaa.hrpt_deframer() self.demod_scope = scopesink2.scope_sink_f( self.displays.GetPage(1).GetWin(), title="Post-Demod", sample_rate=sym_rate * 2.0, v_scale=0.5, v_offset=0, t_scale=10.0 / sym_rate, ac_couple=False, xy_mode=False, num_inputs=1, ) self.displays.GetPage(1).GridAdd(self.demod_scope.win, 0, 0, 1, 1) self.frame_sink = gr.file_sink(gr.sizeof_short * 1, output_filename) self.gr_binary_slicer_fb_0 = gr.binary_slicer_fb() self.gr_clock_recovery_mm_xx_0 = gr.clock_recovery_mm_ff( sps / 2.0, clock_alpha**2 / 4.0, 0.5, clock_alpha, max_clock_offset) self.gr_moving_average_xx_0 = gr.moving_average_ff(hs, 1.0 / hs, 4000) self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2 / 4.0, max_carrier_offset) self.rx_fft = fftsink2.fft_sink_c( self.displays.GetPage(0).GetWin(), baseband_freq=freq, y_per_div=5, y_divs=8, ref_level=-5, ref_scale=2.0, sample_rate=sample_rate, fft_size=1024, fft_rate=15, average=True, avg_alpha=0.1, title="RX Spectrum", peak_hold=False, size=(640, 360), ) self.displays.GetPage(0).GridAdd(self.rx_fft.win, 0, 0, 1, 1) self.usrp_source = grc_usrp.simple_source_c(which=0, side=side, rx_ant="RXA") self.usrp_source.set_decim_rate(decim) self.usrp_source.set_frequency(freq, verbose=True) self.usrp_source.set_gain(gain) ################################################## # Connections ################################################## self.connect((self.gr_clock_recovery_mm_xx_0, 0), (self.gr_binary_slicer_fb_0, 0)) self.connect((self.deframer, 0), (self.frame_sink, 0)) self.connect((self.deframer, 0), (self.decoder, 0)) self.connect((self.gr_clock_recovery_mm_xx_0, 0), (self.demod_scope, 0)) self.connect((self.gr_moving_average_xx_0, 0), (self.gr_clock_recovery_mm_xx_0, 0)) self.connect((self.pll, 0), (self.gr_moving_average_xx_0, 0)) self.connect((self.agc, 0), (self.pll, 0)) self.connect((self.usrp_source, 0), (self.agc, 0)) self.connect((self.agc, 0), (self.rx_fft, 0)) self.connect((self.gr_binary_slicer_fb_0, 0), (self.deframer, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="USRP LRIT Receiver") ################################################## # Variables ################################################## self.config_filename = config_filename = os.environ['HOME']+'/.gnuradio/config.conf' self._saved_decim_config = ConfigParser.ConfigParser() self._saved_decim_config.read(config_filename) try: saved_decim = self._saved_decim_config.getint('usrp_rx_lrit', 'decim') except: saved_decim = 160 self.saved_decim = saved_decim self.decim = decim = saved_decim self.symbol_rate = symbol_rate = 293e3 self._saved_offset_config = ConfigParser.ConfigParser() self._saved_offset_config.read(config_filename) try: saved_offset = self._saved_offset_config.getfloat('usrp_rx_lrit', 'offset') except: saved_offset = 0 self.saved_offset = saved_offset self._saved_gain_mu_config = ConfigParser.ConfigParser() self._saved_gain_mu_config.read(config_filename) try: saved_gain_mu = self._saved_gain_mu_config.getfloat('usrp_rx_lrit', 'gain_mu') except: saved_gain_mu = 0.005 self.saved_gain_mu = saved_gain_mu self._saved_gain_config = ConfigParser.ConfigParser() self._saved_gain_config.read(config_filename) try: saved_gain = self._saved_gain_config.getfloat('usrp_rx_lrit', 'gain') except: saved_gain = 33 self.saved_gain = saved_gain self._saved_freq_config = ConfigParser.ConfigParser() self._saved_freq_config.read(config_filename) try: saved_freq = self._saved_freq_config.getfloat('usrp_rx_lrit', 'freq') except: saved_freq = 1691e6 self.saved_freq = saved_freq self._saved_costas_alpha_config = ConfigParser.ConfigParser() self._saved_costas_alpha_config.read(config_filename) try: saved_costas_alpha = self._saved_costas_alpha_config.getfloat('usrp_rx_lrit', 'costas_alpha') except: saved_costas_alpha = 0.005 self.saved_costas_alpha = saved_costas_alpha self.sample_rate = sample_rate = 64e6/decim self.sps = sps = sample_rate/symbol_rate self._side_config = ConfigParser.ConfigParser() self._side_config.read(config_filename) try: side = self._side_config.get('usrp_rx_lrit', 'side') except: side = 'A' self.side = side self.offset = offset = saved_offset self.gain_mu = gain_mu = saved_gain_mu self.gain = gain = saved_gain self.freq = freq = saved_freq self.costas_alpha = costas_alpha = saved_costas_alpha ################################################## # Notebooks ################################################## self.displays = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.displays.AddPage(grc_wxgui.Panel(self.displays), "USRP RX") self.displays.AddPage(grc_wxgui.Panel(self.displays), "RRC") self.displays.AddPage(grc_wxgui.Panel(self.displays), "PLL") self.displays.AddPage(grc_wxgui.Panel(self.displays), "Const") self.GridAdd(self.displays, 2, 0, 1, 3) ################################################## # Controls ################################################## self._decim_text_box = forms.text_box( parent=self.GetWin(), value=self.decim, callback=self.set_decim, label="Decim", converter=forms.int_converter(), ) self.GridAdd(self._decim_text_box, 0, 2, 1, 1) _offset_sizer = wx.BoxSizer(wx.VERTICAL) self._offset_text_box = forms.text_box( parent=self.GetWin(), sizer=_offset_sizer, value=self.offset, callback=self.set_offset, label="Offset", converter=forms.float_converter(), proportion=0, ) self._offset_slider = forms.slider( parent=self.GetWin(), sizer=_offset_sizer, value=self.offset, callback=self.set_offset, minimum=-50e3, maximum=50e3, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_offset_sizer, 0, 1, 1, 1) _gain_mu_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_mu_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_mu_sizer, value=self.gain_mu, callback=self.set_gain_mu, label="Gain Mu", converter=forms.float_converter(), proportion=0, ) self._gain_mu_slider = forms.slider( parent=self.GetWin(), sizer=_gain_mu_sizer, value=self.gain_mu, callback=self.set_gain_mu, minimum=0, maximum=0.5, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_gain_mu_sizer, 1, 2, 1, 1) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label="Gain", converter=forms.float_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=115, num_steps=115, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_gain_sizer, 1, 0, 1, 1) self._freq_text_box = forms.text_box( parent=self.GetWin(), value=self.freq, callback=self.set_freq, label="Frequency", converter=forms.float_converter(), ) self.GridAdd(self._freq_text_box, 0, 0, 1, 1) _costas_alpha_sizer = wx.BoxSizer(wx.VERTICAL) self._costas_alpha_text_box = forms.text_box( parent=self.GetWin(), sizer=_costas_alpha_sizer, value=self.costas_alpha, callback=self.set_costas_alpha, label="Costas Alpha", converter=forms.float_converter(), proportion=0, ) self._costas_alpha_slider = forms.slider( parent=self.GetWin(), sizer=_costas_alpha_sizer, value=self.costas_alpha, callback=self.set_costas_alpha, minimum=0, maximum=0.5, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_costas_alpha_sizer, 1, 1, 1, 1) ################################################## # Blocks ################################################## self.costas = gr.costas_loop_cc(costas_alpha, (costas_alpha**2.0)/4.0, 50e-6*sps, -50e-6*sps, 2) self.costas_spectrum = fftsink2.fft_sink_c( self.displays.GetPage(2).GetWin(), baseband_freq=freq+offset, y_per_div=10, y_divs=10, ref_level=-15, ref_scale=2.0, sample_rate=sample_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="PLL Spectrum", peak_hold=False, ) self.displays.GetPage(2).GridAdd(self.costas_spectrum.win, 0, 0, 1, 1) self.costas_waveform = scopesink2.scope_sink_c( self.displays.GetPage(2).GetWin(), title="PLL Waveform", sample_rate=sample_rate, v_scale=0.5, v_offset=0, t_scale=20.0/sample_rate, ac_couple=False, xy_mode=False, num_inputs=1, ) self.displays.GetPage(2).GridAdd(self.costas_waveform.win, 1, 0, 1, 1) self.gr_agc_xx_0 = gr.agc_cc(1e-6, 1.0, 1.0/32767.0, 1.0) self.mm_const = scopesink2.scope_sink_c( self.displays.GetPage(3).GetWin(), title="Constellation", sample_rate=symbol_rate, v_scale=0.5, v_offset=0, t_scale=20.0/symbol_rate, ac_couple=False, xy_mode=True, num_inputs=1, ) self.displays.GetPage(3).GridAdd(self.mm_const.win, 1, 0, 1, 1) self.mm_spectrum = fftsink2.fft_sink_c( self.displays.GetPage(3).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=-15, ref_scale=2.0, sample_rate=symbol_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="Bit Sync Spectrum", peak_hold=False, ) self.displays.GetPage(3).GridAdd(self.mm_spectrum.win, 0, 0, 1, 1) self.mm_sync = gr.clock_recovery_mm_cc(sps, (gain_mu**2)/4.0, 0.5, gain_mu, 50e-6*sps) self.root_raised_cosine_filter_0 = gr.fir_filter_ccf(1, firdes.root_raised_cosine( 1, sample_rate, symbol_rate, 0.25, int(11*sample_rate/symbol_rate))) self.rrc_spectrum = fftsink2.fft_sink_c( self.displays.GetPage(1).GetWin(), baseband_freq=freq+offset, y_per_div=10, y_divs=10, ref_level=-15, ref_scale=2.0, sample_rate=sample_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="RRC Spectrum", peak_hold=False, ) self.displays.GetPage(1).GridAdd(self.rrc_spectrum.win, 0, 0, 1, 1) self.rrc_waveform = scopesink2.scope_sink_c( self.displays.GetPage(1).GetWin(), title="RRC Waveform", sample_rate=sample_rate, v_scale=0.5, v_offset=0, t_scale=20.0/sample_rate, ac_couple=False, xy_mode=False, num_inputs=1, ) self.displays.GetPage(1).GridAdd(self.rrc_waveform.win, 1, 0, 1, 1) self.rx_spectrum = fftsink2.fft_sink_c( self.displays.GetPage(0).GetWin(), baseband_freq=freq, y_per_div=10, y_divs=10, ref_level=50, ref_scale=2.0, sample_rate=sample_rate, fft_size=1024, fft_rate=30, average=False, avg_alpha=None, title="RX Spectrum", peak_hold=False, ) self.displays.GetPage(0).GridAdd(self.rx_spectrum.win, 0, 0, 1, 1) self.rx_waveform = scopesink2.scope_sink_c( self.displays.GetPage(0).GetWin(), title="RX Waveform", sample_rate=sample_rate, v_scale=0, v_offset=0, t_scale=20.0/sample_rate, ac_couple=False, xy_mode=False, num_inputs=1, ) self.displays.GetPage(0).GridAdd(self.rx_waveform.win, 1, 0, 1, 1) self.usrp_simple_source_x_0 = grc_usrp.simple_source_c(which=0, side=side, rx_ant="RXA") self.usrp_simple_source_x_0.set_decim_rate(decim) self.usrp_simple_source_x_0.set_frequency(freq+offset, verbose=True) self.usrp_simple_source_x_0.set_gain(gain) ################################################## # Connections ################################################## self.connect((self.gr_agc_xx_0, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.usrp_simple_source_x_0, 0), (self.gr_agc_xx_0, 0)) self.connect((self.usrp_simple_source_x_0, 0), (self.rx_spectrum, 0)) self.connect((self.usrp_simple_source_x_0, 0), (self.rx_waveform, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.rrc_waveform, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.rrc_spectrum, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.costas, 0)) self.connect((self.costas, 0), (self.costas_spectrum, 0)) self.connect((self.costas, 0), (self.costas_waveform, 0)) self.connect((self.costas, 0), (self.mm_sync, 0)) self.connect((self.mm_sync, 0), (self.mm_spectrum, 0)) self.connect((self.mm_sync, 0), (self.mm_const, 0))