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, deframer_insync_frames=2, viterbi_insync_frames=5, deframer_outsync_frames=5, viterbi_outsync_frames=20, viterbi_sync_check=True, viterbi_sync_threshold=0.1, deframer_sync_check=True, clock_alpha=0.005, symb_rate=293883, pll_alpha=0.005, satellite='GOES-LRIT', freq=1691.02e6, gain=23, decim=108, side="A", frames_file=os.environ['HOME'] + '/GOES-LRIT_cadu_frames.cadu', baseband_file=os.environ['HOME'] + '/GOES-LRIT_baseband.dat'): grc_wxgui.top_block_gui.__init__( self, title="LRIT Receiver from baseband file") ################################################## # Parameters ################################################## self.deframer_insync_frames = deframer_insync_frames 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.deframer_sync_check = deframer_sync_check self.clock_alpha = clock_alpha self.symb_rate = symb_rate self.pll_alpha = pll_alpha self.satellite = satellite self.freq = freq self.gain = gain self.decim = decim self.side = side self.frames_file = frames_file self.baseband_file = baseband_file ################################################## # 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 = frames_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_file_source_0 = gr.file_source( gr.sizeof_gr_complex * 1, "/home/martin/GNURadioData/lrit/goes_lrit_D108AD64MHz.sam", True) 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.gr_throttle_0 = gr.throttle(gr.sizeof_gr_complex * 1, samp_rate) 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.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.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)) self.connect((self.gr_throttle_0, 0), (self.gr_agc_xx_0, 0)) self.connect((self.gr_file_source_0, 0), (self.gr_throttle_0, 0))
def __init__(self, deframer_insync_frames=2, deframer_outsync_frames=5, deframer_sync_check=True, pll_alpha=0.005, baseband_file='/home/martin/GNURadioData/USRPSamples/AHRPT_MetOp-A_20100306_0758UTC_U2_d25.sam', satellite='MetOp', viterbi_sync_threshold=0.1, viterbi_outsync_frames=20, viterbi_insync_frames=5, frames_file=os.environ['HOME'] + '/MetOp-cadu_frames.cadu', clock_alpha=0.05, symb_rate=(3500e3/3+3500e3)/2, symb_rate_0=3*3500/4, viterbi_sync_check=True, decim=24): grc_wxgui.top_block_gui.__init__(self, title="MetOp AHRPT Receiver from baseband file") _icon_path = "/home/martin/.local/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Parameters ################################################## self.deframer_insync_frames = deframer_insync_frames self.deframer_outsync_frames = deframer_outsync_frames self.deframer_sync_check = deframer_sync_check self.pll_alpha = pll_alpha self.baseband_file = baseband_file self.satellite = satellite self.viterbi_sync_threshold = viterbi_sync_threshold self.viterbi_outsync_frames = viterbi_outsync_frames self.viterbi_insync_frames = viterbi_insync_frames self.frames_file = frames_file self.clock_alpha = clock_alpha self.symb_rate = symb_rate self.symb_rate_0 = symb_rate_0 self.viterbi_sync_check = viterbi_sync_check self.decim = decim ################################################## # Variables ################################################## self.decim_tb = decim_tb = decim self.symb_rate_tb = symb_rate_tb = symb_rate self.samp_rate = samp_rate = 100e6/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.frames_file_text_inf = frames_file_text_inf = frames_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 = baseband_file ################################################## # Blocks ################################################## self.rx_ntb = self.rx_ntb = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "Input") 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) _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) _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.wxgui_scopesink2_1 = scopesink2.scope_sink_c( self.rx_ntb.GetPage(0).GetWin(), title="QPSK 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, trig_mode=gr.gr_TRIG_MODE_AUTO, y_axis_label="Counts", ) self.rx_ntb.GetPage(0).Add(self.wxgui_scopesink2_1.win) self.wxgui_fftsink1 = fftsink2.fft_sink_c( self.rx_ntb.GetPage(0).GetWin(), baseband_freq=0, y_per_div=5, y_divs=10, ref_level=-15, 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._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._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._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) self.poesweather_metop_cadu_deframer_0 = poesweather.metop_cadu_deframer(False, 1024, 5, 25) self.gr_throttle_0 = gr.throttle(gr.sizeof_short*1, samp_rate*10) self.gr_packed_to_unpacked_xx_0 = gr.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST) self.gr_multiply_const_vxx_0 = gr.multiply_const_vcc((0.6, )) self.gr_file_source_0_0_0_0 = gr.file_source(gr.sizeof_short*1, "/home/martin/hrpt/baseband/METOP-A/2011/07/24/METOP-A_2011-07-24_122614-U2d24.sam", False) self.gr_file_sink_0 = gr.file_sink(gr.sizeof_char*1, "/home/martin/MetOp-cadu_frames.cadu") self.gr_file_sink_0.set_unbuffered(False) 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, 4) 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_agc_xx_0 = gr.agc_cc(10e-6, 1, 1.0/32767.0, 1.0) 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.fec_decode_viterbi_ahrpt_metop_cb_0 = fec.decode_viterbi_ahrpt_metop_cb(True, 0.2, 5, 50, 50) 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._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._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) self.cs2cf = gr.interleaved_short_to_complex() self._baseband_file_text_inf_static_text = forms.static_text( parent=self.rx_ntb.GetPage(0).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(0).Add(self._baseband_file_text_inf_static_text) ################################################## # Connections ################################################## self.connect((self.gr_throttle_0, 0), (self.cs2cf, 0)) self.connect((self.gr_agc_xx_0, 0), (self.wxgui_fftsink1, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.wxgui_scopesink2_1, 0)) self.connect((self.gr_agc_xx_0, 0), (self.gr_costas_loop_cc_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.cs2cf, 0), (self.gr_agc_xx_0, 0)) self.connect((self.gr_file_source_0_0_0_0, 0), (self.gr_throttle_0, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.fec_decode_viterbi_ahrpt_metop_cb_0, 0)) self.connect((self.fec_decode_viterbi_ahrpt_metop_cb_0, 0), (self.gr_packed_to_unpacked_xx_0, 0)) self.connect((self.poesweather_metop_cadu_deframer_0, 0), (self.gr_file_sink_0, 0)) self.connect((self.gr_packed_to_unpacked_xx_0, 0), (self.poesweather_metop_cadu_deframer_0, 0))