def __init__(self, decim=32, sync_check=False, satellite='METEOR-M-1', baseband_file=os.environ['HOME'] + '/METEOR-M-1.dat', frames_file=os.environ['HOME'] + '/METEOR-M-1.hrpt'): gr.top_block.__init__(self, "Meteor M N1 HRPT Baseband To Frames") ################################################## # Parameters ################################################## self.decim = decim self.sync_check = sync_check self.satellite = satellite self.baseband_file = baseband_file self.frames_file = frames_file ################################################## # Variables ################################################## self.sym_rate = sym_rate = 600*1109 self.sample_rate = sample_rate = 64e6/decim self.sps = sps = sample_rate/sym_rate self.config_filename = config_filename = os.environ['HOME']+'/.gnuradio/mn1_hrpt.conf' 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("satname", 'pll_alpha') except: saved_pll_alpha = 0.01 self.saved_pll_alpha = saved_pll_alpha 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("satname", 'clock_alpha') except: saved_clock_alpha = 0.01 self.saved_clock_alpha = saved_clock_alpha 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) ################################################## # Blocks ################################################## self.agc = gr.agc_cc(1e-6, 1.0, 1.0, 1.0) self.frame_sink = gr.file_sink(gr.sizeof_short*1, frames_file) self.frame_sink.set_unbuffered(False) 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, saved_clock_alpha**2/4.0, 0.5, saved_clock_alpha, max_clock_offset) self.gr_file_source_0 = gr.file_source(gr.sizeof_short*1, baseband_file, False) self.gr_interleaved_short_to_complex_0 = gr.interleaved_short_to_complex() self.gr_moving_average_xx_0 = gr.moving_average_ff(hs, 1.0/hs, 4000) self.pll = noaa.hrpt_pll_cf(saved_pll_alpha, saved_pll_alpha**2/4.0, max_carrier_offset) self.poesweather_mn1_hrpt_deframer_0 = poesweather.mn1_hrpt_deframer(sync_check) self.throttle = gr.throttle(gr.sizeof_short*1, sample_rate*10) ################################################## # Connections ################################################## self.connect((self.gr_clock_recovery_mm_xx_0, 0), (self.gr_binary_slicer_fb_0, 0)) self.connect((self.gr_file_source_0, 0), (self.throttle, 0)) self.connect((self.throttle, 0), (self.gr_interleaved_short_to_complex_0, 0)) self.connect((self.gr_interleaved_short_to_complex_0, 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_binary_slicer_fb_0, 0), (self.poesweather_mn1_hrpt_deframer_0, 0)) self.connect((self.poesweather_mn1_hrpt_deframer_0, 0), (self.frame_sink, 0))
def __init__(self, filename="usrp.dat", output="frames.dat", decim=16, pll_alpha=0.05, sync_alpha=0.05): gr.top_block.__init__(self, "USRP HRPT Receiver") ################################################## # Parameters ################################################## self.filename = filename self.output = output self.decim = decim self.pll_alpha = pll_alpha self.sync_alpha = sync_alpha ################################################## # Variables ################################################## 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.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 ################################################## # Blocks ################################################## self.decoder = noaa.hrpt_decoder() self.deframer = noaa.hrpt_deframer() self.deinterleave = gr.deinterleave(gr.sizeof_float*1) self.f2c = gr.float_to_complex(1) self.file_sink = gr.file_sink(gr.sizeof_short*1, output) self.file_source = gr.file_source(gr.sizeof_short*1, filename, False) 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.s2f = gr.short_to_float() self.sync = noaa.hrpt_sync_fb(sync_alpha, sync_alpha**2/4.0, sps, max_sync_offset) ################################################## # Connections ################################################## self.connect((self.deframer, 0), (self.file_sink, 0)) self.connect((self.sync, 0), (self.deframer, 0)) self.connect((self.pll, 0), (self.sync, 0)) self.connect((self.deinterleave, 1), (self.f2c, 1)) self.connect((self.deinterleave, 0), (self.f2c, 0)) self.connect((self.deframer, 0), (self.decoder, 0)) self.connect((self.gr_fir_filter_xxx_0, 0), (self.pll, 0)) self.connect((self.f2c, 0), (self.gr_fir_filter_xxx_0, 0)) self.connect((self.s2f, 0), (self.deinterleave, 0)) self.connect((self.file_source, 0), (self.s2f, 0))
def __init__(self, input_filename="usrp.dat", output_filename="frames.dat", decim=32, pll_alpha=0.01, clock_alpha=0.01): gr.top_block.__init__(self, "Hrpt Demod") ################################################## # Parameters ################################################## self.input_filename = input_filename self.output_filename = output_filename self.decim = decim self.pll_alpha = pll_alpha self.clock_alpha = clock_alpha ################################################## # Variables ################################################## self.sym_rate = sym_rate = 600*1109 self.sample_rate = sample_rate = 4e6 self.sps = sps = sample_rate/sym_rate 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) ################################################## # Blocks ################################################## self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2/4.0, max_carrier_offset) self.noaa_hrpt_deframer_0 = noaa.hrpt_deframer() self.gr_moving_average_xx_0 = gr.moving_average_ff(hs, 1.0/hs, 4000) self.gr_file_sink_0 = gr.file_sink(gr.sizeof_short*1, output_filename) self.gr_file_sink_0.set_unbuffered(False) self.file_source = gr.file_source(gr.sizeof_short*1, input_filename, False) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(sps/2.0, clock_alpha**2/4.0, 0.5, clock_alpha, max_clock_offset) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.decoder = noaa.hrpt_decoder(True,False) self.cs2cf = gr.interleaved_short_to_complex() self.agc = gr.agc_cc(1e-5, 1.0, 1.0/32768.0, 1.0) ################################################## # Connections ################################################## self.connect((self.file_source, 0), (self.cs2cf, 0)) self.connect((self.pll, 0), (self.gr_moving_average_xx_0, 0)) self.connect((self.cs2cf, 0), (self.agc, 0)) self.connect((self.agc, 0), (self.pll, 0)) self.connect((self.noaa_hrpt_deframer_0, 0), (self.gr_file_sink_0, 0)) self.connect((self.noaa_hrpt_deframer_0, 0), (self.decoder, 0)) self.connect((self.gr_moving_average_xx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.noaa_hrpt_deframer_0, 0))
def __init__(self, sync_check=False, decim=32, freq=1698e6, gain=35, side="A", frames_file=os.environ['HOME'] + '/NOAA-XX.hrpt', satellite='NOAA-XX'): gr.top_block.__init__(self, "USRP NOAA HRPT Receiver") ################################################## # Parameters ################################################## self.sync_check = sync_check self.decim = decim self.freq = freq self.gain = gain self.side = side self.frames_file = frames_file self.satellite = satellite ################################################## # Variables ################################################## self.sym_rate = sym_rate = 600*1109 self.samp_rate = samp_rate = 64e6/decim self.sps = sps = samp_rate/sym_rate self.config_filename = config_filename = os.environ['HOME']+'/.gnuradio/noaa_hrpt.conf' 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("satname", 'pll_alpha') except: saved_pll_alpha = 0.005 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("satname", 'gain') except: saved_gain = gain self.saved_gain = saved_gain 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("satname", 'clock_alpha') except: saved_clock_alpha = 0.001 self.saved_clock_alpha = saved_clock_alpha self.max_clock_offset = max_clock_offset = 0.1 self.max_carrier_offset = max_carrier_offset = 2*math.pi*100e3/samp_rate self.hs = hs = int(sps/2.0) ################################################## # Blocks ################################################## self.agc = gr.agc_cc(1e-5, 1.0, 1.0/32768.0, 1.0) 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, saved_clock_alpha**2/4.0, 0.5, saved_clock_alpha, max_clock_offset) self.gr_file_sink_0_0 = gr.file_sink(gr.sizeof_short*1, frames_file) self.gr_file_sink_0_0.set_unbuffered(False) self.gr_interleaved_short_to_complex_0 = gr.interleaved_short_to_complex() self.gr_moving_average_xx_0 = gr.moving_average_ff(hs, 1.0/hs, 4000) self.noaa_hrpt_decoder_0 = noaa.hrpt_decoder(True,False) self.pll = noaa.hrpt_pll_cf(saved_pll_alpha, saved_pll_alpha**2/4.0, max_carrier_offset) self.poesweather_noaa_hrpt_deframer_0 = poesweather.noaa_hrpt_deframer(sync_check) self.usrp_simple_source_x_0 = grc_usrp.simple_source_s(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, verbose=True) self.usrp_simple_source_x_0.set_gain(gain) ################################################## # Connections ################################################## self.connect((self.gr_interleaved_short_to_complex_0, 0), (self.agc, 0)) self.connect((self.usrp_simple_source_x_0, 0), (self.gr_interleaved_short_to_complex_0, 0)) self.connect((self.gr_clock_recovery_mm_xx_0, 0), (self.gr_binary_slicer_fb_0, 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.poesweather_noaa_hrpt_deframer_0, 0), (self.gr_file_sink_0_0, 0)) self.connect((self.poesweather_noaa_hrpt_deframer_0, 0), (self.noaa_hrpt_decoder_0, 0)) self.connect((self.gr_binary_slicer_fb_0, 0), (self.poesweather_noaa_hrpt_deframer_0, 0))
def __init__(self, baseband_file=os.environ['HOME'] + '/NOAA-XX.dat', satellite='NOAA-XX', decim=32, frames_file=os.environ['HOME'] + '/NOAA-XX.hrpt', sync_check=False): gr.top_block.__init__(self, "NOAA HRPT Baseband To Frames") ################################################## # Parameters ################################################## self.baseband_file = baseband_file self.satellite = satellite self.decim = decim self.frames_file = frames_file self.sync_check = sync_check ################################################## # Variables ################################################## self.sym_rate = sym_rate = 600*1109 self.sample_rate = sample_rate = 64e6/decim self.sps = sps = sample_rate/sym_rate self.config_filename = config_filename = os.environ['HOME']+'/.gnuradio/noaa_hrpt.conf' 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("satname", 'pll_alpha') except: saved_pll_alpha = 0.01 self.saved_pll_alpha = saved_pll_alpha 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("satname", 'clock_alpha') except: saved_clock_alpha = 0.01 self.saved_clock_alpha = saved_clock_alpha 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) ################################################## # Blocks ################################################## self.agc = gr.agc_cc(1e-6, 1.0, 1.0, 1.0) self.decoder = noaa.hrpt_decoder(True,False) self.frame_sink = gr.file_sink(gr.sizeof_short*1, frames_file) self.frame_sink.set_unbuffered(False) 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, saved_clock_alpha**2/4.0, 0.5, saved_clock_alpha, max_clock_offset) self.gr_file_source_0 = gr.file_source(gr.sizeof_short*1, baseband_file, False) self.gr_interleaved_short_to_complex_0 = gr.interleaved_short_to_complex() self.gr_moving_average_xx_0 = gr.moving_average_ff(hs, 1.0/hs, 4000) self.pll = noaa.hrpt_pll_cf(saved_pll_alpha, saved_pll_alpha**2/4.0, max_carrier_offset) self.poesweather_noaa_hrpt_deframer_0 = poesweather.noaa_hrpt_deframer(sync_check) self.throttle = gr.throttle(gr.sizeof_short*1, sample_rate*10) ################################################## # Connections ################################################## self.connect((self.gr_clock_recovery_mm_xx_0, 0), (self.gr_binary_slicer_fb_0, 0)) self.connect((self.gr_binary_slicer_fb_0, 0), (self.poesweather_noaa_hrpt_deframer_0, 0)) self.connect((self.poesweather_noaa_hrpt_deframer_0, 0), (self.decoder, 0)) self.connect((self.poesweather_noaa_hrpt_deframer_0, 0), (self.frame_sink, 0)) self.connect((self.gr_file_source_0, 0), (self.throttle, 0)) self.connect((self.throttle, 0), (self.gr_interleaved_short_to_complex_0, 0)) self.connect((self.gr_interleaved_short_to_complex_0, 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))
def __init__(self, pll_alpha=0.005, satellite='NOAA18', decim=50, gain=25, clock_alpha=0.005, freq=1707e6, deframer_sync_check=True, deframer_insync_frames=2, deframer_outsync_frames=5, symb_rate=600 * 1109, baseband_file=os.environ['HOME'] + '/noaa_hrpt_baseband.dat', frames_file=os.environ['HOME'] + '/noaa_hrpt_frames.hmf'): grc_wxgui.top_block_gui.__init__(self, title="USRP2 NOAA HRPT Receiver") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Parameters ################################################## self.pll_alpha = pll_alpha self.satellite = satellite self.decim = decim self.gain = gain self.clock_alpha = clock_alpha self.freq = freq self.deframer_sync_check = deframer_sync_check self.deframer_insync_frames = deframer_insync_frames self.deframer_outsync_frames = deframer_outsync_frames self.symb_rate = symb_rate self.baseband_file = baseband_file self.frames_file = frames_file ################################################## # 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.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.max_clock_offset = max_clock_offset = 0.1 self.max_carrier_offset = max_carrier_offset = 2 * math.pi * 100e3 / samp_rate self.hs = hs = int(sps / 2.0) 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 = baseband_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), "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._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(3).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(3).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(2).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(2).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(2).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(2).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(2).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(2).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(3).GetWin(), value=self.datetime_text, callback=self.set_datetime_text, label="Local time of aquisition start", converter=forms.str_converter(), ) self.rx_ntb.GetPage(3).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(3).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(3).GridAdd( self._baseband_file_text_inf_static_text, 4, 0, 1, 1) ################################################## # Blocks ################################################## self.gr_agc_xx_0 = gr.agc_cc(10e-6, 1, 1.0 / 32767.0, 1.0) 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_file_sink_0_0 = gr.file_sink(gr.sizeof_short * 1, frames_file) self.gr_file_sink_0_0.set_unbuffered(False) self.gr_file_sink_0_1 = gr.file_sink(gr.sizeof_short * 2, baseband_file) self.gr_file_sink_0_1.set_unbuffered(False) self.gr_float_to_complex_0 = gr.float_to_complex(1) self.gr_moving_average_xx_0 = gr.moving_average_ff(hs, 1.0 / hs, 4000) self.gr_short_to_float_0 = gr.short_to_float() self.gr_short_to_float_0_0 = gr.short_to_float() self.gr_vector_to_streams_0 = gr.vector_to_streams( gr.sizeof_short * 1, 2) self.noaa_hrpt_decoder_0 = noaa.hrpt_decoder(True, False) self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2 / 4.0, max_carrier_offset) self.poesweather_univ_hrpt_deframer_0 = poesweather.univ_hrpt_deframer( deframer_sync_check, 11090, deframer_insync_frames, deframer_outsync_frames) self.usrp2_source_xxxx2_0 = usrp2.source_16sc() self.usrp2_source_xxxx2_0.set_decim(decim_tb) self.usrp2_source_xxxx2_0.set_center_freq(freq_tb) self.usrp2_source_xxxx2_0.set_gain(gain_tb) self.wxgui_fftsink1 = fftsink2.fft_sink_c( self.rx_ntb.GetPage(0).GetWin(), baseband_freq=freq, y_per_div=5, y_divs=10, ref_level=65, 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) ################################################## # Connections ################################################## self.connect((self.gr_float_to_complex_0, 0), (self.wxgui_fftsink1, 0)) self.connect((self.poesweather_univ_hrpt_deframer_0, 0), (self.noaa_hrpt_decoder_0, 0)) self.connect((self.gr_binary_slicer_fb_0, 0), (self.poesweather_univ_hrpt_deframer_0, 0)) self.connect((self.poesweather_univ_hrpt_deframer_0, 0), (self.gr_file_sink_0_0, 0)) self.connect((self.gr_clock_recovery_mm_xx_0, 0), (self.gr_binary_slicer_fb_0, 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_agc_xx_0, 0), (self.pll, 0)) self.connect((self.gr_float_to_complex_0, 0), (self.gr_agc_xx_0, 0)) self.connect((self.gr_vector_to_streams_0, 0), (self.gr_short_to_float_0, 0)) self.connect((self.gr_vector_to_streams_0, 1), (self.gr_short_to_float_0_0, 0)) self.connect((self.usrp2_source_xxxx2_0, 0), (self.gr_vector_to_streams_0, 0)) self.connect((self.usrp2_source_xxxx2_0, 0), (self.gr_file_sink_0_1, 0)) self.connect((self.gr_short_to_float_0_0, 0), (self.gr_float_to_complex_0, 1)) self.connect((self.gr_short_to_float_0, 0), (self.gr_float_to_complex_0, 0))
def __init__(self, input_filename="usrp.dat", decim=32): grc_wxgui.top_block_gui.__init__(self, title="USRP HRPT Receiver") ################################################## # Parameters ################################################## self.input_filename = input_filename self.decim = decim ################################################## # Variables ################################################## self.sym_rate = sym_rate = 600 * 1109 self.sample_rate = sample_rate = 64e6 / decim self.config_filename = config_filename = os.environ[ 'HOME'] + '/.gnuradio/config.conf' self.sps = sps = sample_rate / sym_rate 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_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.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.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, 1, 0, 1, 2) ################################################## # Controls ################################################## _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, 0, 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, 1, 1, 1) ################################################## # Blocks ################################################## self.agc = gr.agc_cc(1e-6, 1.0, 1.0, 1.0) self.decoder = noaa.hrpt_decoder(True, False) 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_file_source_0 = gr.file_source(gr.sizeof_short * 1, input_filename, False) self.gr_interleaved_short_to_complex_0 = gr.interleaved_short_to_complex( ) 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=0, 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.throttle = gr.throttle(gr.sizeof_short * 1, 2 * sample_rate) ################################################## # 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.agc, 0), (self.rx_fft, 0)) self.connect((self.gr_interleaved_short_to_complex_0, 0), (self.agc, 0)) self.connect((self.throttle, 0), (self.gr_interleaved_short_to_complex_0, 0)) self.connect((self.gr_file_source_0, 0), (self.throttle, 0)) self.connect((self.gr_binary_slicer_fb_0, 0), (self.deframer, 0))
def __init__(self, pll_alpha=0.005, satellite='NOAA18', decim=50, gain=25, clock_alpha=0.005, freq=1707e6, deframer_sync_check=True, deframer_insync_frames=2, deframer_outsync_frames=5, symb_rate=600*1109, baseband_file=os.environ['HOME'] + '/noaa_hrpt_baseband.dat', frames_file=os.environ['HOME'] + '/noaa_hrpt_frames.hmf'): grc_wxgui.top_block_gui.__init__(self, title="USRP2 NOAA HRPT Receiver") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Parameters ################################################## self.pll_alpha = pll_alpha self.satellite = satellite self.decim = decim self.gain = gain self.clock_alpha = clock_alpha self.freq = freq self.deframer_sync_check = deframer_sync_check self.deframer_insync_frames = deframer_insync_frames self.deframer_outsync_frames = deframer_outsync_frames self.symb_rate = symb_rate self.baseband_file = baseband_file self.frames_file = frames_file ################################################## # 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.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.max_clock_offset = max_clock_offset = 0.1 self.max_carrier_offset = max_carrier_offset = 2*math.pi*100e3/samp_rate self.hs = hs = int(sps/2.0) 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 = baseband_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), "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._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(3).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(3).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(2).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(2).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(2).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(2).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(2).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(2).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(3).GetWin(), value=self.datetime_text, callback=self.set_datetime_text, label="Local time of aquisition start", converter=forms.str_converter(), ) self.rx_ntb.GetPage(3).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(3).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(3).GridAdd(self._baseband_file_text_inf_static_text, 4, 0, 1, 1) ################################################## # Blocks ################################################## self.gr_agc_xx_0 = gr.agc_cc(10e-6, 1, 1.0/32767.0, 1.0) 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_file_sink_0_0 = gr.file_sink(gr.sizeof_short*1, frames_file) self.gr_file_sink_0_0.set_unbuffered(False) self.gr_file_sink_0_1 = gr.file_sink(gr.sizeof_short*2, baseband_file) self.gr_file_sink_0_1.set_unbuffered(False) self.gr_float_to_complex_0 = gr.float_to_complex(1) self.gr_moving_average_xx_0 = gr.moving_average_ff(hs, 1.0/hs, 4000) self.gr_short_to_float_0 = gr.short_to_float() self.gr_short_to_float_0_0 = gr.short_to_float() self.gr_vector_to_streams_0 = gr.vector_to_streams(gr.sizeof_short*1, 2) self.noaa_hrpt_decoder_0 = noaa.hrpt_decoder(True,False) self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2/4.0, max_carrier_offset) self.poesweather_univ_hrpt_deframer_0 = poesweather.univ_hrpt_deframer(deframer_sync_check, 11090, deframer_insync_frames, deframer_outsync_frames) self.usrp2_source_xxxx2_0 = usrp2.source_16sc() self.usrp2_source_xxxx2_0.set_decim(decim_tb) self.usrp2_source_xxxx2_0.set_center_freq(freq_tb) self.usrp2_source_xxxx2_0.set_gain(gain_tb) self.wxgui_fftsink1 = fftsink2.fft_sink_c( self.rx_ntb.GetPage(0).GetWin(), baseband_freq=freq, y_per_div=5, y_divs=10, ref_level=65, 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) ################################################## # Connections ################################################## self.connect((self.gr_float_to_complex_0, 0), (self.wxgui_fftsink1, 0)) self.connect((self.poesweather_univ_hrpt_deframer_0, 0), (self.noaa_hrpt_decoder_0, 0)) self.connect((self.gr_binary_slicer_fb_0, 0), (self.poesweather_univ_hrpt_deframer_0, 0)) self.connect((self.poesweather_univ_hrpt_deframer_0, 0), (self.gr_file_sink_0_0, 0)) self.connect((self.gr_clock_recovery_mm_xx_0, 0), (self.gr_binary_slicer_fb_0, 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_agc_xx_0, 0), (self.pll, 0)) self.connect((self.gr_float_to_complex_0, 0), (self.gr_agc_xx_0, 0)) self.connect((self.gr_vector_to_streams_0, 0), (self.gr_short_to_float_0, 0)) self.connect((self.gr_vector_to_streams_0, 1), (self.gr_short_to_float_0_0, 0)) self.connect((self.usrp2_source_xxxx2_0, 0), (self.gr_vector_to_streams_0, 0)) self.connect((self.usrp2_source_xxxx2_0, 0), (self.gr_file_sink_0_1, 0)) self.connect((self.gr_short_to_float_0_0, 0), (self.gr_float_to_complex_0, 1)) self.connect((self.gr_short_to_float_0, 0), (self.gr_float_to_complex_0, 0))
def __init__(self, decim=32, freq=1698e6, gain=35, side="A", frames_file=os.environ['HOME'] + '/NOAA-XX.hrpt', baseband_file=os.environ['HOME'] + '/NOAA-XX.dat', satellite='NOAA-XX', sync_check=False): gr.top_block.__init__(self, "USRP NOAA HRPT Receiver") ################################################## # Parameters ################################################## self.decim = decim self.freq = freq self.gain = gain self.side = side self.frames_file = frames_file self.baseband_file = baseband_file self.satellite = satellite self.sync_check = sync_check ################################################## # Variables ################################################## self.sym_rate = sym_rate = 600 * 1109 self.samp_rate = samp_rate = 64e6 / decim self.sps = sps = samp_rate / sym_rate self.config_filename = config_filename = os.environ[ 'HOME'] + '/.gnuradio/noaa_hrpt.conf' 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( "satname", 'pll_alpha') except: saved_pll_alpha = 0.005 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("satname", 'gain') except: saved_gain = gain self.saved_gain = saved_gain 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( "satname", 'clock_alpha') except: saved_clock_alpha = 0.001 self.saved_clock_alpha = saved_clock_alpha self.max_clock_offset = max_clock_offset = 0.1 self.max_carrier_offset = max_carrier_offset = 2 * math.pi * 100e3 / samp_rate self.hs = hs = int(sps / 2.0) ################################################## # Blocks ################################################## self.agc = gr.agc_cc(1e-5, 1.0, 1.0 / 32768.0, 1.0) 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, saved_clock_alpha**2 / 4.0, 0.5, saved_clock_alpha, max_clock_offset) self.gr_file_sink_0 = gr.file_sink(gr.sizeof_short * 1, baseband_file) self.gr_file_sink_0.set_unbuffered(False) self.gr_file_sink_0_0 = gr.file_sink(gr.sizeof_short * 1, frames_file) self.gr_file_sink_0_0.set_unbuffered(False) self.gr_interleaved_short_to_complex_0 = gr.interleaved_short_to_complex( ) self.gr_moving_average_xx_0 = gr.moving_average_ff(hs, 1.0 / hs, 4000) self.noaa_hrpt_decoder_0 = noaa.hrpt_decoder(True, False) self.pll = noaa.hrpt_pll_cf(saved_pll_alpha, saved_pll_alpha**2 / 4.0, max_carrier_offset) self.poesweather_noaa_hrpt_deframer_0 = poesweather.noaa_hrpt_deframer( sync_check) self.usrp_simple_source_x_0 = grc_usrp.simple_source_s(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, verbose=True) self.usrp_simple_source_x_0.set_gain(gain) ################################################## # Connections ################################################## self.connect((self.gr_clock_recovery_mm_xx_0, 0), (self.gr_binary_slicer_fb_0, 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.poesweather_noaa_hrpt_deframer_0, 0), (self.gr_file_sink_0_0, 0)) self.connect((self.poesweather_noaa_hrpt_deframer_0, 0), (self.noaa_hrpt_decoder_0, 0)) self.connect((self.gr_binary_slicer_fb_0, 0), (self.poesweather_noaa_hrpt_deframer_0, 0)) self.connect((self.usrp_simple_source_x_0, 0), (self.gr_file_sink_0, 0)) self.connect((self.gr_interleaved_short_to_complex_0, 0), (self.agc, 0)) self.connect((self.usrp_simple_source_x_0, 0), (self.gr_interleaved_short_to_complex_0, 0))
def __init__(self, frames_file=os.environ['HOME'] + '/NOAA-XX.hrpt', decim=32, satellite='NOAA-XX', baseband_file=os.environ['HOME'] + '/NOAA-XX.dat', sync_check=False): grc_wxgui.top_block_gui.__init__(self, title="NOAA HRPT Baseband To Frames") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Parameters ################################################## self.frames_file = frames_file self.decim = decim self.satellite = satellite self.baseband_file = baseband_file self.sync_check = sync_check ################################################## # Variables ################################################## self.sym_rate = sym_rate = 600 * 1109 self.sample_rate = sample_rate = 64e6 / decim self.config_filename = config_filename = os.environ[ 'HOME'] + '/.gnuradio/noaa_hrpt.conf' self.sps = sps = sample_rate / sym_rate 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( "satname", 'pll_alpha') except: saved_pll_alpha = 0.01 self.saved_pll_alpha = saved_pll_alpha 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( "satname", 'clock_alpha') except: saved_clock_alpha = 0.01 self.saved_clock_alpha = saved_clock_alpha self.sync_check_txt = sync_check_txt = sync_check self.satname_txt = satname_txt = satellite self.pll_alpha = pll_alpha = saved_pll_alpha 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.frames_file_txt = frames_file_txt = frames_file self.decim_txt = decim_txt = decim self.clock_alpha = clock_alpha = saved_clock_alpha self.baseband_file_txt = baseband_file_txt = baseband_file ################################################## # Notebooks ################################################## self.displays = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.displays.AddPage(grc_wxgui.Panel(self.displays), "NOAA HRPT Spectrum") self.displays.AddPage(grc_wxgui.Panel(self.displays), "Information") self.Add(self.displays) ################################################## # Controls ################################################## self._sync_check_txt_static_text = forms.static_text( parent=self.GetWin(), value=self.sync_check_txt, callback=self.set_sync_check_txt, label="Sync check", converter=forms.int_converter(), ) self.GridAdd(self._sync_check_txt_static_text, 0, 3, 1, 1) self._satname_txt_static_text = forms.static_text( parent=self.GetWin(), value=self.satname_txt, callback=self.set_satname_txt, label="Satellite", converter=forms.str_converter(), ) self.GridAdd(self._satname_txt_static_text, 0, 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, 1, 0, 1, 1) self._frames_file_txt_static_text = forms.static_text( parent=self.displays.GetPage(1).GetWin(), value=self.frames_file_txt, callback=self.set_frames_file_txt, label="Frames output filename", converter=forms.str_converter(), ) self.displays.GetPage(1).GridAdd(self._frames_file_txt_static_text, 2, 0, 1, 1) self._decim_txt_static_text = forms.static_text( parent=self.GetWin(), value=self.decim_txt, callback=self.set_decim_txt, label="Decimation", converter=forms.str_converter(), ) self.GridAdd(self._decim_txt_static_text, 0, 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, 1, 1, 1, 1) self._baseband_file_txt_static_text = forms.static_text( parent=self.displays.GetPage(1).GetWin(), value=self.baseband_file_txt, callback=self.set_baseband_file_txt, label="Baseband filename", converter=forms.str_converter(), ) self.displays.GetPage(1).GridAdd(self._baseband_file_txt_static_text, 1, 0, 1, 1) ################################################## # Blocks ################################################## self.agc = gr.agc_cc(1e-6, 1.0, 1.0, 1.0) self.decoder = noaa.hrpt_decoder(True, False) self.frame_sink = gr.file_sink(gr.sizeof_short * 1, "/home/jerry/NOAA-XX.hrpt") self.frame_sink.set_unbuffered(False) 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_file_source_0 = gr.file_source( gr.sizeof_short * 1, "/home/jerry/hrpt/baseband/NOAA-18/2011-01-07T132821-NOAA-18.dat", False) self.gr_interleaved_short_to_complex_0 = gr.interleaved_short_to_complex( ) 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.poesweather_noaa_hrpt_deframer_0 = poesweather.noaa_hrpt_deframer( sync_check) self.rx_fft = fftsink2.fft_sink_c( self.displays.GetPage(0).GetWin(), baseband_freq=0, y_per_div=5, y_divs=10, ref_level=45, ref_scale=2.0, sample_rate=sample_rate, fft_size=1024, fft_rate=30, average=True, avg_alpha=0.1, title="NOAA HRPT Spectrum", peak_hold=False, ) self.displays.GetPage(0).Add(self.rx_fft.win) self.throttle = gr.throttle(gr.sizeof_short * 1, sample_rate * 10) ################################################## # Connections ################################################## self.connect((self.gr_interleaved_short_to_complex_0, 0), (self.agc, 0)) self.connect((self.throttle, 0), (self.gr_interleaved_short_to_complex_0, 0)) self.connect((self.gr_file_source_0, 0), (self.throttle, 0)) self.connect((self.agc, 0), (self.rx_fft, 0)) self.connect((self.poesweather_noaa_hrpt_deframer_0, 0), (self.frame_sink, 0)) self.connect((self.poesweather_noaa_hrpt_deframer_0, 0), (self.decoder, 0)) self.connect((self.gr_binary_slicer_fb_0, 0), (self.poesweather_noaa_hrpt_deframer_0, 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))
def __init__(self, satellite='NOAA-XX', gain=35, freq=1698e6, sync_check=False, side="A:0", rate=2e6, frames_file=os.environ['HOME'] + '/data/noaa/frames/NOAA-XX.hrpt', baseband_file=os.environ['HOME'] + '/data/noaa/baseband/NOAA-XX.dat'): grc_wxgui.top_block_gui.__init__(self, title="Enhanced NOAA HRPT Receiver") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Parameters ################################################## self.satellite = satellite self.gain = gain self.freq = freq self.sync_check = sync_check self.side = side self.rate = rate self.frames_file = frames_file self.baseband_file = baseband_file ################################################## # Variables ################################################## self.sym_rate = sym_rate = 600 * 1109 self.samp_rate = samp_rate = rate self.config_filename = config_filename = os.environ[ 'HOME'] + '/.gnuradio/noaa_hrpt.conf' self.sps = sps = samp_rate / sym_rate 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( satellite, 'pll_alpha') except: saved_pll_alpha = 0.005 self.saved_pll_alpha = saved_pll_alpha 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( satellite, 'clock_alpha') except: saved_clock_alpha = 0.001 self.saved_clock_alpha = saved_clock_alpha self.sync_check_txt = sync_check_txt = sync_check self.side_text = side_text = side self._saved_gain_config = ConfigParser.ConfigParser() self._saved_gain_config.read(config_filename) try: saved_gain = self._saved_gain_config.getfloat(satellite, 'gain') except: saved_gain = gain self.saved_gain = saved_gain self.satellite_text = satellite_text = satellite self.sample_rate_text = sample_rate_text = samp_rate self.rate_tb = rate_tb = rate self.pll_alpha = pll_alpha = saved_pll_alpha self.max_clock_offset = max_clock_offset = 0.1 self.max_carrier_offset = max_carrier_offset = 2 * math.pi * 100e3 / samp_rate self.hs = hs = int(sps / 2.0) self.gain_slider = gain_slider = gain self.freq_tb = freq_tb = freq self.frames_outfile_text = frames_outfile_text = frames_file self.datetime_text = datetime_text = strftime("%A, %B %d %Y %H:%M:%S", localtime()) self.clock_alpha = clock_alpha = saved_clock_alpha ################################################## # Blocks ################################################## _gain_slider_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_slider_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_slider_sizer, value=self.gain_slider, callback=self.set_gain_slider, label="Gain", converter=forms.int_converter(), proportion=0, ) self._gain_slider_slider = forms.slider( parent=self.GetWin(), sizer=_gain_slider_sizer, value=self.gain_slider, callback=self.set_gain_slider, minimum=0, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.GridAdd(_gain_slider_sizer, 2, 0, 1, 1) self.displays = self.displays = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.displays.AddPage(grc_wxgui.Panel(self.displays), "RX NOAA HRPT") self.displays.AddPage(grc_wxgui.Panel(self.displays), "Information") self.Add(self.displays) _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.001, maximum=0.1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_clock_alpha_sizer, 2, 2, 1, 1) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.displays.GetPage(0).GetWin(), baseband_freq=0, y_per_div=5, y_divs=10, ref_level=-70, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=True, avg_alpha=0.4, title="NOAA HRPT FFT Spectrum", peak_hold=False, ) self.displays.GetPage(0).Add(self.wxgui_fftsink2_0.win) self.uhd_usrp_source_0 = uhd.usrp_source( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_subdev_spec(side, 0) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(freq, 0) self.uhd_usrp_source_0.set_gain(gain_slider, 0) self._sync_check_txt_static_text = forms.static_text( parent=self.GetWin(), value=self.sync_check_txt, callback=self.set_sync_check_txt, label="Continuous sync check", converter=forms.str_converter(), ) self.GridAdd(self._sync_check_txt_static_text, 0, 2, 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, 0, 0, 1, 1) self._satellite_text_static_text = forms.static_text( parent=self.GetWin(), value=self.satellite_text, callback=self.set_satellite_text, label="Satellite", converter=forms.str_converter(), ) self.GridAdd(self._satellite_text_static_text, 0, 1, 1, 1) self._sample_rate_text_static_text = forms.static_text( parent=self.displays.GetPage(1).GetWin(), value=self.sample_rate_text, callback=self.set_sample_rate_text, label="Sample rate", converter=forms.float_converter(), ) self.displays.GetPage(1).GridAdd(self._sample_rate_text_static_text, 3, 0, 1, 1) self._rate_tb_text_box = forms.text_box( parent=self.GetWin(), value=self.rate_tb, callback=self.set_rate_tb, label="Sample rate", converter=forms.float_converter(), ) self.GridAdd(self._rate_tb_text_box, 1, 0, 1, 1) self.poesweather_noaa_hrpt_deframer_0 = poesweather.noaa_hrpt_deframer( False) _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.005, maximum=0.5, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_pll_alpha_sizer, 2, 1, 1, 1) self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2 / 4.0, max_carrier_offset) self._freq_tb_text_box = forms.text_box( parent=self.GetWin(), value=self.freq_tb, callback=self.set_freq_tb, label="Frequency", converter=forms.float_converter(), ) self.GridAdd(self._freq_tb_text_box, 1, 1, 1, 1) self._frames_outfile_text_static_text = forms.static_text( parent=self.displays.GetPage(1).GetWin(), value=self.frames_outfile_text, callback=self.set_frames_outfile_text, label="Frames filename", converter=forms.str_converter(), ) self.displays.GetPage(1).GridAdd(self._frames_outfile_text_static_text, 4, 0, 1, 1) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff( sps / 2.0, clock_alpha**2 / 4.0, 0.5, clock_alpha, max_clock_offset) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self._datetime_text_static_text = forms.static_text( parent=self.displays.GetPage(1).GetWin(), value=self.datetime_text, callback=self.set_datetime_text, label="Acquisition start", converter=forms.str_converter(), ) self.displays.GetPage(1).GridAdd(self._datetime_text_static_text, 2, 0, 1, 1) self.blocks_moving_average_xx_0 = blocks.moving_average_ff( hs, 1.0 / hs, 4000) self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_short * 1, baseband_file) self.blocks_file_sink_1.set_unbuffered(False) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_short * 1, frames_file) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_complex_to_interleaved_short_0 = blocks.complex_to_interleaved_short( ) self.analog_agc_xx_0 = analog.agc_cc(1e-5, 1.0, 1.0 / 32768.0, 1.0) ################################################## # Connections ################################################## self.connect((self.analog_agc_xx_0, 0), (self.pll, 0)) self.connect((self.pll, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.analog_agc_xx_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.poesweather_noaa_hrpt_deframer_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.poesweather_noaa_hrpt_deframer_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_complex_to_interleaved_short_0, 0)) self.connect((self.blocks_complex_to_interleaved_short_0, 0), (self.blocks_file_sink_1, 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, deframer_insync_frames=2, deframer_outsync_frames=5, deframer_sync_check=True, pll_alpha=0.005, satellite="NOAAxx", decim=50, symb_rate=600 * 1109, baseband_file="/home/martin/GNURadioData/hrpt/baseband/HRPT_NOAA19_2010-09-10_12-35-34_UTC_U2_d50.sam", frames_file=os.environ["HOME"] + "/noaa_hrpt_frames.hmf", clock_alpha=0.005, ): grc_wxgui.top_block_gui.__init__(self, title="NOAA HRPT Receiver from baseband file") ################################################## # 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.satellite = satellite self.decim = decim self.symb_rate = symb_rate self.baseband_file = baseband_file self.frames_file = frames_file 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 = 100e6 / decim_tb 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.max_clock_offset = max_clock_offset = 0.1 self.max_carrier_offset = max_carrier_offset = 2 * math.pi * 100e3 / samp_rate self.hs = hs = int(sps / 2.0) 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 ################################################## # Notebooks ################################################## self.rx_ntb = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "Input baseband") 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), "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._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._frames_file_text_inf_static_text = forms.static_text( parent=self.rx_ntb.GetPage(3).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(3).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(2).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(2).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(2).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(2).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(2).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(2).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(3).GetWin(), value=self.datetime_text, callback=self.set_datetime_text, label="Local time of aquisition start", converter=forms.str_converter(), ) self.rx_ntb.GetPage(3).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(3).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(3).GridAdd(self._baseband_file_text_inf_static_text, 4, 0, 1, 1) ################################################## # Blocks ################################################## self.cs2cf = gr.interleaved_short_to_complex() self.gr_agc_xx_0_0 = gr.agc_cc(10e-6, 1, 1.0 / 32767.0, 1.0) 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_file_sink_0_0 = gr.file_sink(gr.sizeof_short * 1, frames_file) self.gr_file_source_0 = gr.file_source(gr.sizeof_short * 1, baseband_file, False) self.gr_moving_average_xx_0 = gr.moving_average_ff(hs, 1.0 / hs, 4000) self.gr_throttle_0 = gr.throttle(gr.sizeof_short * 1, samp_rate * 2) self.noaa_hrpt_decoder_0 = noaa.hrpt_decoder(True, False) self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha ** 2 / 4.0, max_carrier_offset) self.poesweather_univ_hrpt_deframer_0 = poesweather.univ_hrpt_deframer( deframer_sync_check, 11090, deframer_insync_frames, deframer_outsync_frames ) 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=50, 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) ################################################## # Connections ################################################## self.connect((self.gr_file_source_0, 0), (self.gr_throttle_0, 0)) self.connect((self.gr_throttle_0, 0), (self.cs2cf, 0)) self.connect((self.poesweather_univ_hrpt_deframer_0, 0), (self.noaa_hrpt_decoder_0, 0)) self.connect((self.gr_binary_slicer_fb_0, 0), (self.poesweather_univ_hrpt_deframer_0, 0)) self.connect((self.poesweather_univ_hrpt_deframer_0, 0), (self.gr_file_sink_0_0, 0)) self.connect((self.gr_clock_recovery_mm_xx_0, 0), (self.gr_binary_slicer_fb_0, 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.cs2cf, 0), (self.gr_agc_xx_0_0, 0)) self.connect((self.gr_agc_xx_0_0, 0), (self.pll, 0)) self.connect((self.cs2cf, 0), (self.wxgui_fftsink1, 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): gr.top_block.__init__(self, "USRP HRPT Receiver") ################################################## # Variables ################################################## self.sym_rate = sym_rate = 600 * 1109 self.sample_rate = sample_rate = 4e6 self.sps = sps = sample_rate / sym_rate self.config_filename = config_filename = os.environ["HOME"] + "/.gnuradio/config.conf" 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 self._addr_config = ConfigParser.ConfigParser() self._addr_config.read(config_filename) try: addr = self._addr_config.get("usrp_rx_hrpt", "addr") except: addr = "" self.addr = addr ################################################## # Blocks ################################################## self.uhd_usrp_source_0 = uhd.usrp_source(device_addr=addr, io_type=uhd.io_type.COMPLEX_FLOAT32, num_channels=1) self.uhd_usrp_source_0.set_samp_rate(sample_rate) self.uhd_usrp_source_0.set_center_freq(freq, 0) self.uhd_usrp_source_0.set_gain(0, 0) self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha ** 2 / 4.0, max_carrier_offset) self.gr_moving_average_xx_0 = gr.moving_average_ff(hs, 1.0 / hs, 4000) self.frame_sink = gr.file_sink(gr.sizeof_short * 1, output_filename) self.frame_sink.set_unbuffered(False) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff( sps / 2.0, clock_alpha ** 2 / 4.0, 0.5, clock_alpha, max_clock_offset ) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.deframer = noaa.hrpt_deframer() self.decoder = noaa.hrpt_decoder(True, True) self.agc = gr.agc_cc(1e-6, 1.0, 1.0, 1.0) ################################################## # Connections ################################################## self.connect((self.gr_moving_average_xx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.pll, 0), (self.gr_moving_average_xx_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.agc, 0)) self.connect((self.agc, 0), (self.pll, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.deframer, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.deframer, 0), (self.decoder, 0)) self.connect((self.deframer, 0), (self.frame_sink, 0))
def __init__(self): gr.top_block.__init__(self, "USRP HRPT Receiver") ################################################## # Variables ################################################## self.sym_rate = sym_rate = 600 * 1109 self.sample_rate = sample_rate = 4e6 self.sps = sps = sample_rate / sym_rate self.config_filename = config_filename = os.environ[ 'HOME'] + '/.gnuradio/config.conf' 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 self._addr_config = ConfigParser.ConfigParser() self._addr_config.read(config_filename) try: addr = self._addr_config.get('usrp_rx_hrpt', 'addr') except: addr = "" self.addr = addr ################################################## # Blocks ################################################## self.uhd_usrp_source_0 = uhd.usrp_source( device_addr=addr, io_type=uhd.io_type.COMPLEX_FLOAT32, num_channels=1, ) self.uhd_usrp_source_0.set_samp_rate(sample_rate) self.uhd_usrp_source_0.set_center_freq(freq, 0) self.uhd_usrp_source_0.set_gain(0, 0) self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2 / 4.0, max_carrier_offset) self.gr_moving_average_xx_0 = gr.moving_average_ff(hs, 1.0 / hs, 4000) self.frame_sink = gr.file_sink(gr.sizeof_short * 1, output_filename) self.frame_sink.set_unbuffered(False) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff( sps / 2.0, clock_alpha**2 / 4.0, 0.5, clock_alpha, max_clock_offset) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.deframer = noaa.hrpt_deframer() self.decoder = noaa.hrpt_decoder(True, True) self.agc = gr.agc_cc(1e-6, 1.0, 1.0, 1.0) ################################################## # Connections ################################################## self.connect((self.gr_moving_average_xx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.pll, 0), (self.gr_moving_average_xx_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.agc, 0)) self.connect((self.agc, 0), (self.pll, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.deframer, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.deframer, 0), (self.decoder, 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, satellite='NOAA-XX', gain=35, freq=1698e6, sync_check=False, side="A:0", rate=2e6, frames_file=os.environ['HOME'] + '/data/noaa/frames/NOAA-XX.hrpt', baseband_file=os.environ['HOME'] + '/data/noaa/baseband/NOAA-XX.dat'): grc_wxgui.top_block_gui.__init__(self, title="Enhanced NOAA HRPT Receiver") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Parameters ################################################## self.satellite = satellite self.gain = gain self.freq = freq self.sync_check = sync_check self.side = side self.rate = rate self.frames_file = frames_file self.baseband_file = baseband_file ################################################## # Variables ################################################## self.sym_rate = sym_rate = 600*1109 self.samp_rate = samp_rate = rate self.config_filename = config_filename = os.environ['HOME']+'/.gnuradio/noaa_hrpt.conf' self.sps = sps = samp_rate/sym_rate 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(satellite, 'pll_alpha') except: saved_pll_alpha = 0.005 self.saved_pll_alpha = saved_pll_alpha 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(satellite, 'clock_alpha') except: saved_clock_alpha = 0.001 self.saved_clock_alpha = saved_clock_alpha self.sync_check_txt = sync_check_txt = sync_check self.side_text = side_text = side self._saved_gain_config = ConfigParser.ConfigParser() self._saved_gain_config.read(config_filename) try: saved_gain = self._saved_gain_config.getfloat(satellite, 'gain') except: saved_gain = gain self.saved_gain = saved_gain self.satellite_text = satellite_text = satellite self.sample_rate_text = sample_rate_text = samp_rate self.rate_tb = rate_tb = rate self.pll_alpha = pll_alpha = saved_pll_alpha self.max_clock_offset = max_clock_offset = 0.1 self.max_carrier_offset = max_carrier_offset = 2*math.pi*100e3/samp_rate self.hs = hs = int(sps/2.0) self.gain_slider = gain_slider = gain self.freq_tb = freq_tb = freq self.frames_outfile_text = frames_outfile_text = frames_file self.datetime_text = datetime_text = strftime("%A, %B %d %Y %H:%M:%S", localtime()) self.clock_alpha = clock_alpha = saved_clock_alpha ################################################## # Blocks ################################################## _gain_slider_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_slider_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_slider_sizer, value=self.gain_slider, callback=self.set_gain_slider, label="Gain", converter=forms.int_converter(), proportion=0, ) self._gain_slider_slider = forms.slider( parent=self.GetWin(), sizer=_gain_slider_sizer, value=self.gain_slider, callback=self.set_gain_slider, minimum=0, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.GridAdd(_gain_slider_sizer, 2, 0, 1, 1) self.displays = self.displays = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.displays.AddPage(grc_wxgui.Panel(self.displays), "RX NOAA HRPT") self.displays.AddPage(grc_wxgui.Panel(self.displays), "Information") self.Add(self.displays) _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.001, maximum=0.1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_clock_alpha_sizer, 2, 2, 1, 1) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.displays.GetPage(0).GetWin(), baseband_freq=0, y_per_div=5, y_divs=10, ref_level=-70, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=True, avg_alpha=0.4, title="NOAA HRPT FFT Spectrum", peak_hold=False, ) self.displays.GetPage(0).Add(self.wxgui_fftsink2_0.win) self.uhd_usrp_source_0 = uhd.usrp_source( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_subdev_spec(side, 0) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(freq, 0) self.uhd_usrp_source_0.set_gain(gain_slider, 0) self._sync_check_txt_static_text = forms.static_text( parent=self.GetWin(), value=self.sync_check_txt, callback=self.set_sync_check_txt, label="Continuous sync check", converter=forms.str_converter(), ) self.GridAdd(self._sync_check_txt_static_text, 0, 2, 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, 0, 0, 1, 1) self._satellite_text_static_text = forms.static_text( parent=self.GetWin(), value=self.satellite_text, callback=self.set_satellite_text, label="Satellite", converter=forms.str_converter(), ) self.GridAdd(self._satellite_text_static_text, 0, 1, 1, 1) self._sample_rate_text_static_text = forms.static_text( parent=self.displays.GetPage(1).GetWin(), value=self.sample_rate_text, callback=self.set_sample_rate_text, label="Sample rate", converter=forms.float_converter(), ) self.displays.GetPage(1).GridAdd(self._sample_rate_text_static_text, 3, 0, 1, 1) self._rate_tb_text_box = forms.text_box( parent=self.GetWin(), value=self.rate_tb, callback=self.set_rate_tb, label="Sample rate", converter=forms.float_converter(), ) self.GridAdd(self._rate_tb_text_box, 1, 0, 1, 1) self.poesweather_noaa_hrpt_deframer_0 = poesweather.noaa_hrpt_deframer(False) _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.005, maximum=0.5, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_pll_alpha_sizer, 2, 1, 1, 1) self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2/4.0, max_carrier_offset) self._freq_tb_text_box = forms.text_box( parent=self.GetWin(), value=self.freq_tb, callback=self.set_freq_tb, label="Frequency", converter=forms.float_converter(), ) self.GridAdd(self._freq_tb_text_box, 1, 1, 1, 1) self._frames_outfile_text_static_text = forms.static_text( parent=self.displays.GetPage(1).GetWin(), value=self.frames_outfile_text, callback=self.set_frames_outfile_text, label="Frames filename", converter=forms.str_converter(), ) self.displays.GetPage(1).GridAdd(self._frames_outfile_text_static_text, 4, 0, 1, 1) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(sps/2.0, clock_alpha**2/4.0, 0.5, clock_alpha, max_clock_offset) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self._datetime_text_static_text = forms.static_text( parent=self.displays.GetPage(1).GetWin(), value=self.datetime_text, callback=self.set_datetime_text, label="Acquisition start", converter=forms.str_converter(), ) self.displays.GetPage(1).GridAdd(self._datetime_text_static_text, 2, 0, 1, 1) self.blocks_moving_average_xx_0 = blocks.moving_average_ff(hs, 1.0/hs, 4000) self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_short*1, baseband_file) self.blocks_file_sink_1.set_unbuffered(False) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_short*1, frames_file) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_complex_to_interleaved_short_0 = blocks.complex_to_interleaved_short() self.analog_agc_xx_0 = analog.agc_cc(1e-5, 1.0, 1.0/32768.0, 1.0) ################################################## # Connections ################################################## self.connect((self.analog_agc_xx_0, 0), (self.pll, 0)) self.connect((self.pll, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.analog_agc_xx_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.poesweather_noaa_hrpt_deframer_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.poesweather_noaa_hrpt_deframer_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_complex_to_interleaved_short_0, 0)) self.connect((self.blocks_complex_to_interleaved_short_0, 0), (self.blocks_file_sink_1, 0))
def __init__(self): gr.top_block.__init__(self, "USRP HRPT Receiver") ################################################## # Variables ################################################## self.sym_rate = sym_rate = 600*1109 self.sample_rate = sample_rate = 4e6 self.sps = sps = sample_rate/sym_rate self.config_filename = config_filename = os.environ['HOME']+'/.gnuradio/config.conf' 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.throttle = gr.throttle(gr.sizeof_short*1, 2*sample_rate) self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2/4.0, max_carrier_offset) self.gr_moving_average_xx_0 = gr.moving_average_ff(hs, 1.0/hs, 4000) self.gr_interleaved_short_to_complex_0 = gr.interleaved_short_to_complex() self.gr_file_source_0 = gr.file_source(gr.sizeof_short*1, "input_filename", False) self.frame_sink = gr.file_sink(gr.sizeof_short*1, output_filename) self.frame_sink.set_unbuffered(False) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(sps/2.0, clock_alpha**2/4.0, 0.5, clock_alpha, max_clock_offset) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.deframer = noaa.hrpt_deframer() self.decoder = noaa.hrpt_decoder(True,True) self.agc = gr.agc_cc(1e-6, 1.0, 1.0, 1.0) ################################################## # Connections ################################################## self.connect((self.gr_moving_average_xx_0, 0), (self.digital_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.deframer, 0), (self.decoder, 0)) self.connect((self.deframer, 0), (self.frame_sink, 0)) self.connect((self.gr_interleaved_short_to_complex_0, 0), (self.agc, 0)) self.connect((self.throttle, 0), (self.gr_interleaved_short_to_complex_0, 0)) self.connect((self.gr_file_source_0, 0), (self.throttle, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.digital_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 = 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, freq=1698e6, rate=2e6, frames_file=os.environ['HOME'] + '/data/noaa/frames/NOAA-XX.hrpt', rtlsdr="rtl=0", ifgain=20, satellite='NOAA-XX', sync_check=False, rfgain=40): grc_wxgui.top_block_gui.__init__(self, title="Enhanced NOAA HRPT Receiver using USB DVB-T Dongles") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Parameters ################################################## self.freq = freq self.rate = rate self.frames_file = frames_file self.rtlsdr = rtlsdr self.ifgain = ifgain self.satellite = satellite self.sync_check = sync_check self.rfgain = rfgain ################################################## # Variables ################################################## self.sym_rate = sym_rate = 600*1109 self.samp_rate = samp_rate = rate self.config_filename = config_filename = os.environ['HOME']+'/.gnuradio/rtlsdr_noaa_hrpt.conf' self.sps = sps = samp_rate/sym_rate 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(satellite, 'pll_alpha') except: saved_pll_alpha = 0.005 self.saved_pll_alpha = saved_pll_alpha 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(satellite, 'clock_alpha') except: saved_clock_alpha = 0.001 self.saved_clock_alpha = saved_clock_alpha self.sync_check_cb = sync_check_cb = sync_check self._saved_rf_gain_config = ConfigParser.ConfigParser() self._saved_rf_gain_config.read(config_filename) try: saved_rf_gain = self._saved_rf_gain_config.getfloat(satellite, 'rf-gain') except: saved_rf_gain = rfgain self.saved_rf_gain = saved_rf_gain self._saved_if_gain_config = ConfigParser.ConfigParser() self._saved_if_gain_config.read(config_filename) try: saved_if_gain = self._saved_if_gain_config.getfloat(satellite, 'if-gain') except: saved_if_gain = ifgain self.saved_if_gain = saved_if_gain self.satellite_text = satellite_text = satellite self.sample_rate_text = sample_rate_text = samp_rate self.rf_gain_slider = rf_gain_slider = rfgain self.rate_tb = rate_tb = rate self.pll_alpha = pll_alpha = saved_pll_alpha self.max_clock_offset = max_clock_offset = 0.1 self.max_carrier_offset = max_carrier_offset = 2*math.pi*100e3/samp_rate self.if_gain_slider = if_gain_slider = ifgain self.hs = hs = int(sps/2.0) self.freq_tb = freq_tb = freq self.frames_outfile_text = frames_outfile_text = frames_file self.datetime_text = datetime_text = strftime("%A, %B %d %Y %H:%M:%S", localtime()) self.clock_alpha = clock_alpha = saved_clock_alpha ################################################## # Blocks ################################################## _rf_gain_slider_sizer = wx.BoxSizer(wx.VERTICAL) self._rf_gain_slider_text_box = forms.text_box( parent=self.GetWin(), sizer=_rf_gain_slider_sizer, value=self.rf_gain_slider, callback=self.set_rf_gain_slider, label="RF Gain", converter=forms.int_converter(), proportion=0, ) self._rf_gain_slider_slider = forms.slider( parent=self.GetWin(), sizer=_rf_gain_slider_sizer, value=self.rf_gain_slider, callback=self.set_rf_gain_slider, minimum=0, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.GridAdd(_rf_gain_slider_sizer, 2, 0, 1, 1) _if_gain_slider_sizer = wx.BoxSizer(wx.VERTICAL) self._if_gain_slider_text_box = forms.text_box( parent=self.GetWin(), sizer=_if_gain_slider_sizer, value=self.if_gain_slider, callback=self.set_if_gain_slider, label="IF Gain", converter=forms.int_converter(), proportion=0, ) self._if_gain_slider_slider = forms.slider( parent=self.GetWin(), sizer=_if_gain_slider_sizer, value=self.if_gain_slider, callback=self.set_if_gain_slider, minimum=0, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.GridAdd(_if_gain_slider_sizer, 2, 1, 1, 1) self.displays = self.displays = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.displays.AddPage(grc_wxgui.Panel(self.displays), "RX NOAA HRPT") self.displays.AddPage(grc_wxgui.Panel(self.displays), "Information") self.Add(self.displays) _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.001, maximum=0.1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_clock_alpha_sizer, 2, 3, 1, 1) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.displays.GetPage(0).GetWin(), baseband_freq=0, y_per_div=5, y_divs=10, ref_level=-30, ref_scale=2.0, sample_rate=samp_rate, fft_size=512, fft_rate=5, average=True, avg_alpha=0.4, title="NOAA HRPT FFT Spectrum", peak_hold=False, ) self.displays.GetPage(0).Add(self.wxgui_fftsink2_0.win) self._sync_check_cb_check_box = forms.check_box( parent=self.GetWin(), value=self.sync_check_cb, callback=self.set_sync_check_cb, label="Continuous sync check", true=True, false=False, ) self.GridAdd(self._sync_check_cb_check_box, 1, 2, 1, 1) self._satellite_text_static_text = forms.static_text( parent=self.GetWin(), value=self.satellite_text, callback=self.set_satellite_text, label="Satellite", converter=forms.str_converter(), ) self.GridAdd(self._satellite_text_static_text, 0, 1, 1, 1) self._sample_rate_text_static_text = forms.static_text( parent=self.displays.GetPage(1).GetWin(), value=self.sample_rate_text, callback=self.set_sample_rate_text, label="Sample rate", converter=forms.float_converter(), ) self.displays.GetPage(1).GridAdd(self._sample_rate_text_static_text, 3, 0, 1, 1) self._rate_tb_text_box = forms.text_box( parent=self.GetWin(), value=self.rate_tb, callback=self.set_rate_tb, label="Sample rate", converter=forms.float_converter(), ) self.GridAdd(self._rate_tb_text_box, 1, 0, 1, 1) self.poesweather_noaa_hrpt_deframer_0 = poesweather.noaa_hrpt_deframer(False) _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.005, maximum=0.5, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_pll_alpha_sizer, 2, 2, 1, 1) self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2/4.0, max_carrier_offset) self.osmosdr_source_c_0 = osmosdr.source_c( args="nchan=" + str(1) + " " + rtlsdr ) self.osmosdr_source_c_0.set_sample_rate(samp_rate) self.osmosdr_source_c_0.set_center_freq(freq, 0) self.osmosdr_source_c_0.set_freq_corr(0, 0) self.osmosdr_source_c_0.set_iq_balance_mode(0, 0) self.osmosdr_source_c_0.set_gain_mode(0, 0) self.osmosdr_source_c_0.set_gain(rf_gain_slider, 0) self.osmosdr_source_c_0.set_if_gain(if_gain_slider, 0) self._freq_tb_text_box = forms.text_box( parent=self.GetWin(), value=self.freq_tb, callback=self.set_freq_tb, label="Frequency", converter=forms.float_converter(), ) self.GridAdd(self._freq_tb_text_box, 1, 1, 1, 1) self._frames_outfile_text_static_text = forms.static_text( parent=self.displays.GetPage(1).GetWin(), value=self.frames_outfile_text, callback=self.set_frames_outfile_text, label="Frames filename", converter=forms.str_converter(), ) self.displays.GetPage(1).GridAdd(self._frames_outfile_text_static_text, 4, 0, 1, 1) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(sps/2.0, clock_alpha**2/4.0, 0.5, clock_alpha, max_clock_offset) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self._datetime_text_static_text = forms.static_text( parent=self.displays.GetPage(1).GetWin(), value=self.datetime_text, callback=self.set_datetime_text, label="Acquisition start", converter=forms.str_converter(), ) self.displays.GetPage(1).GridAdd(self._datetime_text_static_text, 2, 0, 1, 1) self.blocks_moving_average_xx_0 = blocks.moving_average_ff(hs, 1.0/hs, 4000) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_short*1, frames_file) self.blocks_file_sink_0.set_unbuffered(False) self.analog_agc_xx_0 = analog.agc_cc(1e-5, 1.0, 1.0/32768.0, 1.0) ################################################## # Connections ################################################## self.connect((self.analog_agc_xx_0, 0), (self.pll, 0)) self.connect((self.pll, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.poesweather_noaa_hrpt_deframer_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.poesweather_noaa_hrpt_deframer_0, 0)) self.connect((self.osmosdr_source_c_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.osmosdr_source_c_0, 0), (self.analog_agc_xx_0, 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, freq=1698e6, rate=2e6, frames_file=os.environ['HOME'] + '/data/noaa/frames/NOAA-XX.hrpt', rtlsdr="rtl=0", ifgain=20, satellite='NOAA-XX', sync_check=False, rfgain=40): grc_wxgui.top_block_gui.__init__( self, title="Enhanced NOAA HRPT Receiver using USB DVB-T Dongles") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Parameters ################################################## self.freq = freq self.rate = rate self.frames_file = frames_file self.rtlsdr = rtlsdr self.ifgain = ifgain self.satellite = satellite self.sync_check = sync_check self.rfgain = rfgain ################################################## # Variables ################################################## self.sym_rate = sym_rate = 600 * 1109 self.samp_rate = samp_rate = rate self.config_filename = config_filename = os.environ[ 'HOME'] + '/.gnuradio/rtlsdr_noaa_hrpt.conf' self.sps = sps = samp_rate / sym_rate 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( satellite, 'pll_alpha') except: saved_pll_alpha = 0.005 self.saved_pll_alpha = saved_pll_alpha 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( satellite, 'clock_alpha') except: saved_clock_alpha = 0.001 self.saved_clock_alpha = saved_clock_alpha self.sync_check_cb = sync_check_cb = sync_check self._saved_rf_gain_config = ConfigParser.ConfigParser() self._saved_rf_gain_config.read(config_filename) try: saved_rf_gain = self._saved_rf_gain_config.getfloat( satellite, 'rf-gain') except: saved_rf_gain = rfgain self.saved_rf_gain = saved_rf_gain self._saved_if_gain_config = ConfigParser.ConfigParser() self._saved_if_gain_config.read(config_filename) try: saved_if_gain = self._saved_if_gain_config.getfloat( satellite, 'if-gain') except: saved_if_gain = ifgain self.saved_if_gain = saved_if_gain self.satellite_text = satellite_text = satellite self.sample_rate_text = sample_rate_text = samp_rate self.rf_gain_slider = rf_gain_slider = rfgain self.rate_tb = rate_tb = rate self.pll_alpha = pll_alpha = saved_pll_alpha self.max_clock_offset = max_clock_offset = 0.1 self.max_carrier_offset = max_carrier_offset = 2 * math.pi * 100e3 / samp_rate self.if_gain_slider = if_gain_slider = ifgain self.hs = hs = int(sps / 2.0) self.freq_tb = freq_tb = freq self.frames_outfile_text = frames_outfile_text = frames_file self.datetime_text = datetime_text = strftime("%A, %B %d %Y %H:%M:%S", localtime()) self.clock_alpha = clock_alpha = saved_clock_alpha ################################################## # Blocks ################################################## _rf_gain_slider_sizer = wx.BoxSizer(wx.VERTICAL) self._rf_gain_slider_text_box = forms.text_box( parent=self.GetWin(), sizer=_rf_gain_slider_sizer, value=self.rf_gain_slider, callback=self.set_rf_gain_slider, label="RF Gain", converter=forms.int_converter(), proportion=0, ) self._rf_gain_slider_slider = forms.slider( parent=self.GetWin(), sizer=_rf_gain_slider_sizer, value=self.rf_gain_slider, callback=self.set_rf_gain_slider, minimum=0, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.GridAdd(_rf_gain_slider_sizer, 2, 0, 1, 1) _if_gain_slider_sizer = wx.BoxSizer(wx.VERTICAL) self._if_gain_slider_text_box = forms.text_box( parent=self.GetWin(), sizer=_if_gain_slider_sizer, value=self.if_gain_slider, callback=self.set_if_gain_slider, label="IF Gain", converter=forms.int_converter(), proportion=0, ) self._if_gain_slider_slider = forms.slider( parent=self.GetWin(), sizer=_if_gain_slider_sizer, value=self.if_gain_slider, callback=self.set_if_gain_slider, minimum=0, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.GridAdd(_if_gain_slider_sizer, 2, 1, 1, 1) self.displays = self.displays = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.displays.AddPage(grc_wxgui.Panel(self.displays), "RX NOAA HRPT") self.displays.AddPage(grc_wxgui.Panel(self.displays), "Information") self.Add(self.displays) _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.001, maximum=0.1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_clock_alpha_sizer, 2, 3, 1, 1) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.displays.GetPage(0).GetWin(), baseband_freq=0, y_per_div=5, y_divs=10, ref_level=-30, ref_scale=2.0, sample_rate=samp_rate, fft_size=512, fft_rate=5, average=True, avg_alpha=0.4, title="NOAA HRPT FFT Spectrum", peak_hold=False, ) self.displays.GetPage(0).Add(self.wxgui_fftsink2_0.win) self._sync_check_cb_check_box = forms.check_box( parent=self.GetWin(), value=self.sync_check_cb, callback=self.set_sync_check_cb, label="Continuous sync check", true=True, false=False, ) self.GridAdd(self._sync_check_cb_check_box, 1, 2, 1, 1) self._satellite_text_static_text = forms.static_text( parent=self.GetWin(), value=self.satellite_text, callback=self.set_satellite_text, label="Satellite", converter=forms.str_converter(), ) self.GridAdd(self._satellite_text_static_text, 0, 1, 1, 1) self._sample_rate_text_static_text = forms.static_text( parent=self.displays.GetPage(1).GetWin(), value=self.sample_rate_text, callback=self.set_sample_rate_text, label="Sample rate", converter=forms.float_converter(), ) self.displays.GetPage(1).GridAdd(self._sample_rate_text_static_text, 3, 0, 1, 1) self._rate_tb_text_box = forms.text_box( parent=self.GetWin(), value=self.rate_tb, callback=self.set_rate_tb, label="Sample rate", converter=forms.float_converter(), ) self.GridAdd(self._rate_tb_text_box, 1, 0, 1, 1) self.poesweather_noaa_hrpt_deframer_0 = poesweather.noaa_hrpt_deframer( False) _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.005, maximum=0.5, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_pll_alpha_sizer, 2, 2, 1, 1) self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2 / 4.0, max_carrier_offset) self.osmosdr_source_c_0 = osmosdr.source_c(args="nchan=" + str(1) + " " + rtlsdr) self.osmosdr_source_c_0.set_sample_rate(samp_rate) self.osmosdr_source_c_0.set_center_freq(freq, 0) self.osmosdr_source_c_0.set_freq_corr(0, 0) self.osmosdr_source_c_0.set_iq_balance_mode(0, 0) self.osmosdr_source_c_0.set_gain_mode(0, 0) self.osmosdr_source_c_0.set_gain(rf_gain_slider, 0) self.osmosdr_source_c_0.set_if_gain(if_gain_slider, 0) self._freq_tb_text_box = forms.text_box( parent=self.GetWin(), value=self.freq_tb, callback=self.set_freq_tb, label="Frequency", converter=forms.float_converter(), ) self.GridAdd(self._freq_tb_text_box, 1, 1, 1, 1) self._frames_outfile_text_static_text = forms.static_text( parent=self.displays.GetPage(1).GetWin(), value=self.frames_outfile_text, callback=self.set_frames_outfile_text, label="Frames filename", converter=forms.str_converter(), ) self.displays.GetPage(1).GridAdd(self._frames_outfile_text_static_text, 4, 0, 1, 1) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff( sps / 2.0, clock_alpha**2 / 4.0, 0.5, clock_alpha, max_clock_offset) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self._datetime_text_static_text = forms.static_text( parent=self.displays.GetPage(1).GetWin(), value=self.datetime_text, callback=self.set_datetime_text, label="Acquisition start", converter=forms.str_converter(), ) self.displays.GetPage(1).GridAdd(self._datetime_text_static_text, 2, 0, 1, 1) self.blocks_moving_average_xx_0 = blocks.moving_average_ff( hs, 1.0 / hs, 4000) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_short * 1, frames_file) self.blocks_file_sink_0.set_unbuffered(False) self.analog_agc_xx_0 = analog.agc_cc(1e-5, 1.0, 1.0 / 32768.0, 1.0) ################################################## # Connections ################################################## self.connect((self.analog_agc_xx_0, 0), (self.pll, 0)) self.connect((self.pll, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.poesweather_noaa_hrpt_deframer_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.poesweather_noaa_hrpt_deframer_0, 0)) self.connect((self.osmosdr_source_c_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.osmosdr_source_c_0, 0), (self.analog_agc_xx_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, frames_file=os.environ['HOME'] + '/NOAA-XX.hrpt', decim=32, satellite='NOAA-XX', baseband_file=os.environ['HOME'] + '/NOAA-XX.dat', sync_check=False): grc_wxgui.top_block_gui.__init__(self, title="NOAA HRPT Baseband To Frames") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Parameters ################################################## self.frames_file = frames_file self.decim = decim self.satellite = satellite self.baseband_file = baseband_file self.sync_check = sync_check ################################################## # Variables ################################################## self.sym_rate = sym_rate = 600*1109 self.sample_rate = sample_rate = 64e6/decim self.config_filename = config_filename = os.environ['HOME']+'/.gnuradio/noaa_hrpt.conf' self.sps = sps = sample_rate/sym_rate 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("satname", 'pll_alpha') except: saved_pll_alpha = 0.01 self.saved_pll_alpha = saved_pll_alpha 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("satname", 'clock_alpha') except: saved_clock_alpha = 0.01 self.saved_clock_alpha = saved_clock_alpha self.sync_check_txt = sync_check_txt = sync_check self.satname_txt = satname_txt = satellite self.pll_alpha = pll_alpha = saved_pll_alpha 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.frames_file_txt = frames_file_txt = frames_file self.decim_txt = decim_txt = decim self.clock_alpha = clock_alpha = saved_clock_alpha self.baseband_file_txt = baseband_file_txt = baseband_file ################################################## # Notebooks ################################################## self.displays = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.displays.AddPage(grc_wxgui.Panel(self.displays), "NOAA HRPT Spectrum") self.displays.AddPage(grc_wxgui.Panel(self.displays), "Information") self.Add(self.displays) ################################################## # Controls ################################################## self._sync_check_txt_static_text = forms.static_text( parent=self.GetWin(), value=self.sync_check_txt, callback=self.set_sync_check_txt, label="Sync check", converter=forms.int_converter(), ) self.GridAdd(self._sync_check_txt_static_text, 0, 3, 1, 1) self._satname_txt_static_text = forms.static_text( parent=self.GetWin(), value=self.satname_txt, callback=self.set_satname_txt, label="Satellite", converter=forms.str_converter(), ) self.GridAdd(self._satname_txt_static_text, 0, 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, 1, 0, 1, 1) self._frames_file_txt_static_text = forms.static_text( parent=self.displays.GetPage(1).GetWin(), value=self.frames_file_txt, callback=self.set_frames_file_txt, label="Frames output filename", converter=forms.str_converter(), ) self.displays.GetPage(1).GridAdd(self._frames_file_txt_static_text, 2, 0, 1, 1) self._decim_txt_static_text = forms.static_text( parent=self.GetWin(), value=self.decim_txt, callback=self.set_decim_txt, label="Decimation", converter=forms.str_converter(), ) self.GridAdd(self._decim_txt_static_text, 0, 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, 1, 1, 1, 1) self._baseband_file_txt_static_text = forms.static_text( parent=self.displays.GetPage(1).GetWin(), value=self.baseband_file_txt, callback=self.set_baseband_file_txt, label="Baseband filename", converter=forms.str_converter(), ) self.displays.GetPage(1).GridAdd(self._baseband_file_txt_static_text, 1, 0, 1, 1) ################################################## # Blocks ################################################## self.agc = gr.agc_cc(1e-6, 1.0, 1.0, 1.0) self.decoder = noaa.hrpt_decoder(True,False) self.frame_sink = gr.file_sink(gr.sizeof_short*1, "/home/jerry/NOAA-XX.hrpt") self.frame_sink.set_unbuffered(False) 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_file_source_0 = gr.file_source(gr.sizeof_short*1, "/home/jerry/hrpt/baseband/NOAA-18/2011-01-07T132821-NOAA-18.dat", False) self.gr_interleaved_short_to_complex_0 = gr.interleaved_short_to_complex() 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.poesweather_noaa_hrpt_deframer_0 = poesweather.noaa_hrpt_deframer(sync_check) self.rx_fft = fftsink2.fft_sink_c( self.displays.GetPage(0).GetWin(), baseband_freq=0, y_per_div=5, y_divs=10, ref_level=45, ref_scale=2.0, sample_rate=sample_rate, fft_size=1024, fft_rate=30, average=True, avg_alpha=0.1, title="NOAA HRPT Spectrum", peak_hold=False, ) self.displays.GetPage(0).Add(self.rx_fft.win) self.throttle = gr.throttle(gr.sizeof_short*1, sample_rate*10) ################################################## # Connections ################################################## self.connect((self.gr_interleaved_short_to_complex_0, 0), (self.agc, 0)) self.connect((self.throttle, 0), (self.gr_interleaved_short_to_complex_0, 0)) self.connect((self.gr_file_source_0, 0), (self.throttle, 0)) self.connect((self.agc, 0), (self.rx_fft, 0)) self.connect((self.poesweather_noaa_hrpt_deframer_0, 0), (self.frame_sink, 0)) self.connect((self.poesweather_noaa_hrpt_deframer_0, 0), (self.decoder, 0)) self.connect((self.gr_binary_slicer_fb_0, 0), (self.poesweather_noaa_hrpt_deframer_0, 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))
def __init__(self, decim=50, satellite='Meteor-M-N1', frames_file=os.environ['HOME'] + '/MN1_hrpt_frames.hmf', baseband_file="/home/martin/GNURadioData/hrpt/baseband/HRPT_Meteor-M-N1_2011-02-27_09-30-46_UTC_U2_d50.sam", symb_rate=600*1109, clock_alpha=0.050, pll_alpha=0.05, deframer_outsync_frames=100, deframer_insync_frames=3, deframer_sync_check=False): grc_wxgui.top_block_gui.__init__(self, title="Meteor M-N1 HRPT 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.decim = decim self.satellite = satellite self.frames_file = frames_file self.baseband_file = baseband_file self.symb_rate = symb_rate self.clock_alpha = clock_alpha self.pll_alpha = pll_alpha self.deframer_outsync_frames = deframer_outsync_frames self.deframer_insync_frames = deframer_insync_frames self.deframer_sync_check = deframer_sync_check ################################################## # 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.sps = sps = samp_rate/symb_rate_tb self.v = v = True 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.max_clock_offset = max_clock_offset = 0.1 self.max_carrier_offset = max_carrier_offset = 2*math.pi*100e3/samp_rate self.hs = hs = int(sps/2.0) 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 baseband") 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), "Deframer") self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "Output") self.Add(self.rx_ntb) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.GetWin(), title="Scope Plot", sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=gr.gr_TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Add(self.wxgui_scopesink2_0.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=50, 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._v_check_box = forms.check_box( parent=self.GetWin(), value=self.v, callback=self.set_v, label="Open", true=True, false=False, ) self.Add(self._v_check_box) 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_meteor_cadu_deframer_0 = poesweather.meteor_cadu_deframer(deframer_sync_check, 256, deframer_insync_frames, deframer_outsync_frames) _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.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2/4.0, max_carrier_offset) self.gr_throttle_0 = gr.throttle(gr.sizeof_short*1, samp_rate*10) self.gr_multiply_const_vxx_0 = gr.multiply_const_vff((-1, )) self.gr_moving_average_xx_0 = gr.moving_average_ff(hs, 1.0/hs, 4000) self.gr_file_source_0_0 = gr.file_source(gr.sizeof_short*1, "/home/martin/hrpt/baseband/METEOR-M-1/2011/07/24/METEOR-M-1_2011-07-24T113448_U2d50.sam", False) self.gr_file_sink_0_0_0 = gr.file_sink(gr.sizeof_char*1, "frames.mn1") self.gr_file_sink_0_0_0.set_unbuffered(False) 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_binary_slicer_fb_0 = gr.binary_slicer_fb() self.gr_agc_xx_0_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(3).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(3).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(2).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(2).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(2).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(2).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(2).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(2).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(3).GetWin(), value=self.datetime_text, callback=self.set_datetime_text, label="Local time of aquisition start", converter=forms.str_converter(), ) self.rx_ntb.GetPage(3).GridAdd(self._datetime_text_static_text, 1, 0, 1, 1) self.cs2cf = gr.interleaved_short_to_complex() _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(3).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(3).GridAdd(self._baseband_file_text_inf_static_text, 4, 0, 1, 1) ################################################## # Connections ################################################## self.connect((self.gr_throttle_0, 0), (self.cs2cf, 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.cs2cf, 0), (self.gr_agc_xx_0_0, 0)) self.connect((self.gr_agc_xx_0_0, 0), (self.pll, 0)) self.connect((self.cs2cf, 0), (self.wxgui_fftsink1, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.gr_binary_slicer_fb_0, 0)) self.connect((self.gr_clock_recovery_mm_xx_0, 0), (self.gr_multiply_const_vxx_0, 0)) self.connect((self.poesweather_meteor_cadu_deframer_0, 0), (self.gr_file_sink_0_0_0, 0)) self.connect((self.gr_binary_slicer_fb_0, 0), (self.poesweather_meteor_cadu_deframer_0, 0)) self.connect((self.gr_file_source_0_0, 0), (self.gr_throttle_0, 0)) self.connect((self.gr_clock_recovery_mm_xx_0, 0), (self.wxgui_scopesink2_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="USRP HRPT Receiver") ################################################## # Variables ################################################## self.sym_rate = sym_rate = 600 * 1109 self.sample_rate = sample_rate = 4e6 self.config_filename = config_filename = os.environ[ 'HOME'] + '/.gnuradio/config.conf' self.sps = sps = sample_rate / sym_rate 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._addr_config = ConfigParser.ConfigParser() self._addr_config.read(config_filename) try: addr = self._addr_config.get('usrp_rx_hrpt', 'addr') except: addr = "" self.addr = addr self.rate_text = rate_text = sample_rate 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.clock_alpha = clock_alpha = saved_clock_alpha self.addr_text = addr_text = addr ################################################## # Blocks ################################################## 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.displays = 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) _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) self.uhd_usrp_source_0 = uhd.usrp_source( device_addr=addr, io_type=uhd.io_type.COMPLEX_FLOAT32, num_channels=1, ) self.uhd_usrp_source_0.set_samp_rate(sample_rate) self.uhd_usrp_source_0.set_center_freq(freq, 0) self.uhd_usrp_source_0.set_gain(0, 0) 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._rate_text_static_text = forms.static_text( parent=self.GetWin(), value=self.rate_text, callback=self.set_rate_text, label="Baseband Rate", converter=forms.float_converter(), ) self.GridAdd(self._rate_text_static_text, 1, 1, 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) self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2 / 4.0, max_carrier_offset) self.gr_moving_average_xx_0 = gr.moving_average_ff(hs, 1.0 / hs, 4000) _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.frame_sink = gr.file_sink(gr.sizeof_short * 1, output_filename) self.frame_sink.set_unbuffered(False) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff( sps / 2.0, clock_alpha**2 / 4.0, 0.5, clock_alpha, max_clock_offset) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() 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, trig_mode=gr.gr_TRIG_MODE_AUTO, y_axis_label="Counts", ) self.displays.GetPage(1).GridAdd(self.demod_scope.win, 0, 0, 1, 1) self.deframer = noaa.hrpt_deframer() self.decoder = noaa.hrpt_decoder(True, True) self.agc = gr.agc_cc(1e-6, 1.0, 1.0, 1.0) self._addr_text_static_text = forms.static_text( parent=self.GetWin(), value=self.addr_text, callback=self.set_addr_text, label="USRP Addr", converter=forms.str_converter(), ) self.GridAdd(self._addr_text_static_text, 1, 0, 1, 1) ################################################## # Connections ################################################## self.connect((self.deframer, 0), (self.frame_sink, 0)) self.connect((self.deframer, 0), (self.decoder, 0)) self.connect((self.agc, 0), (self.pll, 0)) self.connect((self.agc, 0), (self.rx_fft, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.agc, 0)) self.connect((self.pll, 0), (self.gr_moving_average_xx_0, 0)) self.connect((self.gr_moving_average_xx_0, 0), (self.demod_scope, 0)) self.connect((self.gr_moving_average_xx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.deframer, 0))
def __init__(self, side="A", gain=35, decim=32, sync_check=False, satellite='METEOR-M-1', frames_file=os.environ['HOME'] + '/METEOR-M-1.hrpt', freq=1700e6): grc_wxgui.top_block_gui.__init__(self, title="USRP NOAA HRPT Receiver") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Parameters ################################################## self.side = side self.gain = gain self.decim = decim self.sync_check = sync_check self.satellite = satellite self.frames_file = frames_file self.freq = freq ################################################## # Variables ################################################## self.sym_rate = sym_rate = 600*1109 self.samp_rate = samp_rate = 64e6/decim self.config_filename = config_filename = os.environ['HOME']+'/.gnuradio/mn1_hrpt.conf' self.sps = sps = samp_rate/sym_rate 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("satname", 'pll_alpha') except: saved_pll_alpha = 0.005 self.saved_pll_alpha = saved_pll_alpha 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("satname", 'clock_alpha') except: saved_clock_alpha = 0.001 self.saved_clock_alpha = saved_clock_alpha self.sync_check_txt = sync_check_txt = sync_check self.side_text = side_text = side self._saved_gain_config = ConfigParser.ConfigParser() self._saved_gain_config.read(config_filename) try: saved_gain = self._saved_gain_config.getfloat("satname", 'gain') except: saved_gain = gain self.saved_gain = saved_gain self.satellite_text = satellite_text = satellite self.sample_rate_text = sample_rate_text = samp_rate self.pll_alpha = pll_alpha = saved_pll_alpha self.max_clock_offset = max_clock_offset = 0.1 self.max_carrier_offset = max_carrier_offset = 2*math.pi*100e3/samp_rate self.hs = hs = int(sps/2.0) self.gain_slider = gain_slider = gain self.freq_tb = freq_tb = freq self.frames_outfile_text = frames_outfile_text = frames_file self.decim_tb = decim_tb = decim self.datetime_text = datetime_text = strftime("%A, %B %d %Y %H:%M:%S", localtime()) 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), "RX Meteor M N1 HRPT") self.displays.AddPage(grc_wxgui.Panel(self.displays), "Information") self.Add(self.displays) ################################################## # Controls ################################################## self._sync_check_txt_static_text = forms.static_text( parent=self.GetWin(), value=self.sync_check_txt, callback=self.set_sync_check_txt, label="Sync check", converter=forms.float_converter(), ) self.GridAdd(self._sync_check_txt_static_text, 0, 2, 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, 0, 0, 1, 1) self._satellite_text_static_text = forms.static_text( parent=self.GetWin(), value=self.satellite_text, callback=self.set_satellite_text, label="Satellite", converter=forms.str_converter(), ) self.GridAdd(self._satellite_text_static_text, 0, 1, 1, 1) self._sample_rate_text_static_text = forms.static_text( parent=self.displays.GetPage(1).GetWin(), value=self.sample_rate_text, callback=self.set_sample_rate_text, label="Sample rate", converter=forms.float_converter(), ) self.displays.GetPage(1).GridAdd(self._sample_rate_text_static_text, 3, 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.005, maximum=0.5, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_pll_alpha_sizer, 2, 1, 1, 1) _gain_slider_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_slider_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_slider_sizer, value=self.gain_slider, callback=self.set_gain_slider, label="Gain", converter=forms.int_converter(), proportion=0, ) self._gain_slider_slider = forms.slider( parent=self.GetWin(), sizer=_gain_slider_sizer, value=self.gain_slider, callback=self.set_gain_slider, minimum=0, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.GridAdd(_gain_slider_sizer, 2, 0, 1, 1) self._freq_tb_text_box = forms.text_box( parent=self.GetWin(), value=self.freq_tb, callback=self.set_freq_tb, label="Frequency", converter=forms.float_converter(), ) self.GridAdd(self._freq_tb_text_box, 1, 1, 1, 1) self._frames_outfile_text_static_text = forms.static_text( parent=self.displays.GetPage(1).GetWin(), value=self.frames_outfile_text, callback=self.set_frames_outfile_text, label="Frames filename", converter=forms.str_converter(), ) self.displays.GetPage(1).GridAdd(self._frames_outfile_text_static_text, 4, 0, 1, 1) self._decim_tb_text_box = forms.text_box( parent=self.GetWin(), value=self.decim_tb, callback=self.set_decim_tb, label="Decimation", converter=forms.int_converter(), ) self.GridAdd(self._decim_tb_text_box, 1, 0, 1, 1) self._datetime_text_static_text = forms.static_text( parent=self.displays.GetPage(1).GetWin(), value=self.datetime_text, callback=self.set_datetime_text, label="Acquisition start", converter=forms.str_converter(), ) self.displays.GetPage(1).GridAdd(self._datetime_text_static_text, 2, 0, 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.001, maximum=0.1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_clock_alpha_sizer, 2, 2, 1, 1) ################################################## # Blocks ################################################## self.agc = gr.agc_cc(1e-5, 1.0, 1.0/32768.0, 1.0) 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_file_sink_0_0 = gr.file_sink(gr.sizeof_short*1, frames_file) self.gr_file_sink_0_0.set_unbuffered(False) self.gr_interleaved_short_to_complex_0 = gr.interleaved_short_to_complex() self.gr_moving_average_xx_0 = gr.moving_average_ff(hs, 1.0/hs, 4000) self.gr_rms_xx_0 = gr.rms_cf(0.2) self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2/4.0, max_carrier_offset) self.poesweather_mn1_hrpt_deframer_0 = poesweather.mn1_hrpt_deframer(sync_check) self.usrp_simple_source_x_0 = grc_usrp.simple_source_s(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, verbose=True) self.usrp_simple_source_x_0.set_gain(gain) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.displays.GetPage(0).GetWin(), baseband_freq=0, y_per_div=5, y_divs=10, ref_level=45, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=30, average=True, avg_alpha=0.1, title="Meteor M N1 HRPT FFT Spectrum", peak_hold=False, ) self.displays.GetPage(0).Add(self.wxgui_fftsink2_0.win) self.wxgui_numbersink2_0 = numbersink2.number_sink_f( self.GetWin(), unit="Units", minval=0, maxval=5000, factor=1.0, decimal_places=4, ref_level=0, sample_rate=samp_rate, number_rate=15, average=True, avg_alpha=0.07, label="S-Meter", peak_hold=False, show_gauge=True, ) self.Add(self.wxgui_numbersink2_0.win) ################################################## # Connections ################################################## self.connect((self.gr_binary_slicer_fb_0, 0), (self.poesweather_mn1_hrpt_deframer_0, 0)) self.connect((self.usrp_simple_source_x_0, 0), (self.gr_interleaved_short_to_complex_0, 0)) self.connect((self.gr_interleaved_short_to_complex_0, 0), (self.agc, 0)) self.connect((self.gr_clock_recovery_mm_xx_0, 0), (self.gr_binary_slicer_fb_0, 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_interleaved_short_to_complex_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.gr_interleaved_short_to_complex_0, 0), (self.gr_rms_xx_0, 0)) self.connect((self.gr_rms_xx_0, 0), (self.wxgui_numbersink2_0, 0)) self.connect((self.poesweather_mn1_hrpt_deframer_0, 0), (self.gr_file_sink_0_0, 0))
def __init__( self, deframer_insync_frames=2, deframer_outsync_frames=5, deframer_sync_check=True, pll_alpha=0.005, satellite='NOAAxx', decim=50, symb_rate=600 * 1109, baseband_file="/home/martin/GNURadioData/hrpt/baseband/HRPT_NOAA19_2010-09-10_12-35-34_UTC_U2_d50.sam", frames_file=os.environ['HOME'] + '/noaa_hrpt_frames.hmf', clock_alpha=0.005): grc_wxgui.top_block_gui.__init__( self, title="NOAA HRPT Receiver from baseband file") ################################################## # 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.satellite = satellite self.decim = decim self.symb_rate = symb_rate self.baseband_file = baseband_file self.frames_file = frames_file 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 = 100e6 / decim_tb 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.max_clock_offset = max_clock_offset = 0.1 self.max_carrier_offset = max_carrier_offset = 2 * math.pi * 100e3 / samp_rate self.hs = hs = int(sps / 2.0) 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 ################################################## # Notebooks ################################################## self.rx_ntb = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "Input baseband") 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), "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._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._frames_file_text_inf_static_text = forms.static_text( parent=self.rx_ntb.GetPage(3).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(3).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(2).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(2).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(2).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(2).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(2).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(2).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(3).GetWin(), value=self.datetime_text, callback=self.set_datetime_text, label="Local time of aquisition start", converter=forms.str_converter(), ) self.rx_ntb.GetPage(3).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(3).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(3).GridAdd( self._baseband_file_text_inf_static_text, 4, 0, 1, 1) ################################################## # Blocks ################################################## self.cs2cf = gr.interleaved_short_to_complex() self.gr_agc_xx_0_0 = gr.agc_cc(10e-6, 1, 1.0 / 32767.0, 1.0) 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_file_sink_0_0 = gr.file_sink(gr.sizeof_short * 1, frames_file) self.gr_file_source_0 = gr.file_source(gr.sizeof_short * 1, baseband_file, False) self.gr_moving_average_xx_0 = gr.moving_average_ff(hs, 1.0 / hs, 4000) self.gr_throttle_0 = gr.throttle(gr.sizeof_short * 1, samp_rate * 2) self.noaa_hrpt_decoder_0 = noaa.hrpt_decoder(True, False) self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2 / 4.0, max_carrier_offset) self.poesweather_univ_hrpt_deframer_0 = poesweather.univ_hrpt_deframer( deframer_sync_check, 11090, deframer_insync_frames, deframer_outsync_frames) 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=50, 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) ################################################## # Connections ################################################## self.connect((self.gr_file_source_0, 0), (self.gr_throttle_0, 0)) self.connect((self.gr_throttle_0, 0), (self.cs2cf, 0)) self.connect((self.poesweather_univ_hrpt_deframer_0, 0), (self.noaa_hrpt_decoder_0, 0)) self.connect((self.gr_binary_slicer_fb_0, 0), (self.poesweather_univ_hrpt_deframer_0, 0)) self.connect((self.poesweather_univ_hrpt_deframer_0, 0), (self.gr_file_sink_0_0, 0)) self.connect((self.gr_clock_recovery_mm_xx_0, 0), (self.gr_binary_slicer_fb_0, 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.cs2cf, 0), (self.gr_agc_xx_0_0, 0)) self.connect((self.gr_agc_xx_0_0, 0), (self.pll, 0)) self.connect((self.cs2cf, 0), (self.wxgui_fftsink1, 0))
def __init__(self, side="A", gain=35, decim=32, sync_check=False, satellite='METEOR-M-1', frames_file=os.environ['HOME'] + '/METEOR-M-1.hrpt', freq=1700e6): grc_wxgui.top_block_gui.__init__(self, title="USRP NOAA HRPT Receiver") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Parameters ################################################## self.side = side self.gain = gain self.decim = decim self.sync_check = sync_check self.satellite = satellite self.frames_file = frames_file self.freq = freq ################################################## # Variables ################################################## self.sym_rate = sym_rate = 600 * 1109 self.samp_rate = samp_rate = 64e6 / decim self.config_filename = config_filename = os.environ[ 'HOME'] + '/.gnuradio/mn1_hrpt.conf' self.sps = sps = samp_rate / sym_rate 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( "satname", 'pll_alpha') except: saved_pll_alpha = 0.005 self.saved_pll_alpha = saved_pll_alpha 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( "satname", 'clock_alpha') except: saved_clock_alpha = 0.001 self.saved_clock_alpha = saved_clock_alpha self.sync_check_txt = sync_check_txt = sync_check self.side_text = side_text = side self._saved_gain_config = ConfigParser.ConfigParser() self._saved_gain_config.read(config_filename) try: saved_gain = self._saved_gain_config.getfloat("satname", 'gain') except: saved_gain = gain self.saved_gain = saved_gain self.satellite_text = satellite_text = satellite self.sample_rate_text = sample_rate_text = samp_rate self.pll_alpha = pll_alpha = saved_pll_alpha self.max_clock_offset = max_clock_offset = 0.1 self.max_carrier_offset = max_carrier_offset = 2 * math.pi * 100e3 / samp_rate self.hs = hs = int(sps / 2.0) self.gain_slider = gain_slider = gain self.freq_tb = freq_tb = freq self.frames_outfile_text = frames_outfile_text = frames_file self.decim_tb = decim_tb = decim self.datetime_text = datetime_text = strftime("%A, %B %d %Y %H:%M:%S", localtime()) 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), "RX Meteor M N1 HRPT") self.displays.AddPage(grc_wxgui.Panel(self.displays), "Information") self.Add(self.displays) ################################################## # Controls ################################################## self._sync_check_txt_static_text = forms.static_text( parent=self.GetWin(), value=self.sync_check_txt, callback=self.set_sync_check_txt, label="Sync check", converter=forms.float_converter(), ) self.GridAdd(self._sync_check_txt_static_text, 0, 2, 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, 0, 0, 1, 1) self._satellite_text_static_text = forms.static_text( parent=self.GetWin(), value=self.satellite_text, callback=self.set_satellite_text, label="Satellite", converter=forms.str_converter(), ) self.GridAdd(self._satellite_text_static_text, 0, 1, 1, 1) self._sample_rate_text_static_text = forms.static_text( parent=self.displays.GetPage(1).GetWin(), value=self.sample_rate_text, callback=self.set_sample_rate_text, label="Sample rate", converter=forms.float_converter(), ) self.displays.GetPage(1).GridAdd(self._sample_rate_text_static_text, 3, 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.005, maximum=0.5, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_pll_alpha_sizer, 2, 1, 1, 1) _gain_slider_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_slider_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_slider_sizer, value=self.gain_slider, callback=self.set_gain_slider, label="Gain", converter=forms.int_converter(), proportion=0, ) self._gain_slider_slider = forms.slider( parent=self.GetWin(), sizer=_gain_slider_sizer, value=self.gain_slider, callback=self.set_gain_slider, minimum=0, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.GridAdd(_gain_slider_sizer, 2, 0, 1, 1) self._freq_tb_text_box = forms.text_box( parent=self.GetWin(), value=self.freq_tb, callback=self.set_freq_tb, label="Frequency", converter=forms.float_converter(), ) self.GridAdd(self._freq_tb_text_box, 1, 1, 1, 1) self._frames_outfile_text_static_text = forms.static_text( parent=self.displays.GetPage(1).GetWin(), value=self.frames_outfile_text, callback=self.set_frames_outfile_text, label="Frames filename", converter=forms.str_converter(), ) self.displays.GetPage(1).GridAdd(self._frames_outfile_text_static_text, 4, 0, 1, 1) self._decim_tb_text_box = forms.text_box( parent=self.GetWin(), value=self.decim_tb, callback=self.set_decim_tb, label="Decimation", converter=forms.int_converter(), ) self.GridAdd(self._decim_tb_text_box, 1, 0, 1, 1) self._datetime_text_static_text = forms.static_text( parent=self.displays.GetPage(1).GetWin(), value=self.datetime_text, callback=self.set_datetime_text, label="Acquisition start", converter=forms.str_converter(), ) self.displays.GetPage(1).GridAdd(self._datetime_text_static_text, 2, 0, 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.001, maximum=0.1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_clock_alpha_sizer, 2, 2, 1, 1) ################################################## # Blocks ################################################## self.agc = gr.agc_cc(1e-5, 1.0, 1.0 / 32768.0, 1.0) 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_file_sink_0_0 = gr.file_sink(gr.sizeof_short * 1, frames_file) self.gr_file_sink_0_0.set_unbuffered(False) self.gr_interleaved_short_to_complex_0 = gr.interleaved_short_to_complex( ) self.gr_moving_average_xx_0 = gr.moving_average_ff(hs, 1.0 / hs, 4000) self.gr_rms_xx_0 = gr.rms_cf(0.2) self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2 / 4.0, max_carrier_offset) self.poesweather_mn1_hrpt_deframer_0 = poesweather.mn1_hrpt_deframer( sync_check) self.usrp_simple_source_x_0 = grc_usrp.simple_source_s(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, verbose=True) self.usrp_simple_source_x_0.set_gain(gain) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.displays.GetPage(0).GetWin(), baseband_freq=0, y_per_div=5, y_divs=10, ref_level=45, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=30, average=True, avg_alpha=0.1, title="Meteor M N1 HRPT FFT Spectrum", peak_hold=False, ) self.displays.GetPage(0).Add(self.wxgui_fftsink2_0.win) self.wxgui_numbersink2_0 = numbersink2.number_sink_f( self.GetWin(), unit="Units", minval=0, maxval=5000, factor=1.0, decimal_places=4, ref_level=0, sample_rate=samp_rate, number_rate=15, average=True, avg_alpha=0.07, label="S-Meter", peak_hold=False, show_gauge=True, ) self.Add(self.wxgui_numbersink2_0.win) ################################################## # Connections ################################################## self.connect((self.gr_binary_slicer_fb_0, 0), (self.poesweather_mn1_hrpt_deframer_0, 0)) self.connect((self.usrp_simple_source_x_0, 0), (self.gr_interleaved_short_to_complex_0, 0)) self.connect((self.gr_interleaved_short_to_complex_0, 0), (self.agc, 0)) self.connect((self.gr_clock_recovery_mm_xx_0, 0), (self.gr_binary_slicer_fb_0, 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_interleaved_short_to_complex_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.gr_interleaved_short_to_complex_0, 0), (self.gr_rms_xx_0, 0)) self.connect((self.gr_rms_xx_0, 0), (self.wxgui_numbersink2_0, 0)) self.connect((self.poesweather_mn1_hrpt_deframer_0, 0), (self.gr_file_sink_0_0, 0))
def __init__( self, decim=50, satellite='Meteor-M-N1', frames_file=os.environ['HOME'] + '/MN1_hrpt_frames.hmf', baseband_file="/home/martin/GNURadioData/hrpt/baseband/HRPT_Meteor-M-N1_2011-02-27_09-30-46_UTC_U2_d50.sam", symb_rate=600 * 1109, clock_alpha=0.050, pll_alpha=0.05, deframer_outsync_frames=100, deframer_insync_frames=3, deframer_sync_check=False): grc_wxgui.top_block_gui.__init__( self, title="Meteor M-N1 HRPT 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.decim = decim self.satellite = satellite self.frames_file = frames_file self.baseband_file = baseband_file self.symb_rate = symb_rate self.clock_alpha = clock_alpha self.pll_alpha = pll_alpha self.deframer_outsync_frames = deframer_outsync_frames self.deframer_insync_frames = deframer_insync_frames self.deframer_sync_check = deframer_sync_check ################################################## # 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.sps = sps = samp_rate / symb_rate_tb self.v = v = True 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.max_clock_offset = max_clock_offset = 0.1 self.max_carrier_offset = max_carrier_offset = 2 * math.pi * 100e3 / samp_rate self.hs = hs = int(sps / 2.0) 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 baseband") 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), "Deframer") self.rx_ntb.AddPage(grc_wxgui.Panel(self.rx_ntb), "Output") self.Add(self.rx_ntb) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.GetWin(), title="Scope Plot", sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=gr.gr_TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Add(self.wxgui_scopesink2_0.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=50, 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._v_check_box = forms.check_box( parent=self.GetWin(), value=self.v, callback=self.set_v, label="Open", true=True, false=False, ) self.Add(self._v_check_box) 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_meteor_cadu_deframer_0 = poesweather.meteor_cadu_deframer( deframer_sync_check, 256, deframer_insync_frames, deframer_outsync_frames) _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.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2 / 4.0, max_carrier_offset) self.gr_throttle_0 = gr.throttle(gr.sizeof_short * 1, samp_rate * 10) self.gr_multiply_const_vxx_0 = gr.multiply_const_vff((-1, )) self.gr_moving_average_xx_0 = gr.moving_average_ff(hs, 1.0 / hs, 4000) self.gr_file_source_0_0 = gr.file_source( gr.sizeof_short * 1, "/home/martin/hrpt/baseband/METEOR-M-1/2011/07/24/METEOR-M-1_2011-07-24T113448_U2d50.sam", False) self.gr_file_sink_0_0_0 = gr.file_sink(gr.sizeof_char * 1, "frames.mn1") self.gr_file_sink_0_0_0.set_unbuffered(False) 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_binary_slicer_fb_0 = gr.binary_slicer_fb() self.gr_agc_xx_0_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(3).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(3).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(2).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(2).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(2).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(2).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(2).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(2).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(3).GetWin(), value=self.datetime_text, callback=self.set_datetime_text, label="Local time of aquisition start", converter=forms.str_converter(), ) self.rx_ntb.GetPage(3).GridAdd(self._datetime_text_static_text, 1, 0, 1, 1) self.cs2cf = gr.interleaved_short_to_complex() _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(3).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(3).GridAdd( self._baseband_file_text_inf_static_text, 4, 0, 1, 1) ################################################## # Connections ################################################## self.connect((self.gr_throttle_0, 0), (self.cs2cf, 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.cs2cf, 0), (self.gr_agc_xx_0_0, 0)) self.connect((self.gr_agc_xx_0_0, 0), (self.pll, 0)) self.connect((self.cs2cf, 0), (self.wxgui_fftsink1, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.gr_binary_slicer_fb_0, 0)) self.connect((self.gr_clock_recovery_mm_xx_0, 0), (self.gr_multiply_const_vxx_0, 0)) self.connect((self.poesweather_meteor_cadu_deframer_0, 0), (self.gr_file_sink_0_0_0, 0)) self.connect((self.gr_binary_slicer_fb_0, 0), (self.poesweather_meteor_cadu_deframer_0, 0)) self.connect((self.gr_file_source_0_0, 0), (self.gr_throttle_0, 0)) self.connect((self.gr_clock_recovery_mm_xx_0, 0), (self.wxgui_scopesink2_0, 0))