Exemplo n.º 1
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))
Exemplo n.º 2
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))
Exemplo n.º 3
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))
Exemplo n.º 4
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))