diff options
Diffstat (limited to 'gr-noaa/apps/usrp_rx_hrpt_nogui.py')
-rwxr-xr-x | gr-noaa/apps/usrp_rx_hrpt_nogui.py | 191 |
1 files changed, 95 insertions, 96 deletions
diff --git a/gr-noaa/apps/usrp_rx_hrpt_nogui.py b/gr-noaa/apps/usrp_rx_hrpt_nogui.py index 9917847bb..33259a231 100755 --- a/gr-noaa/apps/usrp_rx_hrpt_nogui.py +++ b/gr-noaa/apps/usrp_rx_hrpt_nogui.py @@ -1,8 +1,8 @@ #!/usr/bin/env python ################################################## # Gnuradio Python Flow Graph -# Title: USRP HRPT Receiver -# Generated: Sun Sep 27 10:13:25 2009 +# Title: Usrp Rx Hrpt Nogui +# Generated: Sun Nov 1 19:32:32 2009 ################################################## from gnuradio import eng_notation @@ -13,59 +13,58 @@ from gnuradio.gr import firdes from grc_gnuradio import usrp as grc_usrp from optparse import OptionParser import ConfigParser -import math +import math, os class usrp_rx_hrpt_nogui(gr.top_block): def __init__(self): - gr.top_block.__init__(self, "USRP HRPT Receiver") + gr.top_block.__init__(self, "Usrp Rx Hrpt Nogui") ################################################## # Variables ################################################## - self.config_filename = config_filename = 'usrp_rx_hrpt.cfg' + 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', 'decim') + try: decim = self._decim_config.getfloat('usrp_rx_hrpt', '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') + 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('demod', 'pll_alpha') + try: pll_alpha = self._pll_alpha_config.getfloat('usrp_rx_hrpt', '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') + try: output_filename = self._output_filename_config.get('usrp_rx_hrpt', '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_clock_offset = max_clock_offset = 0.1 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', 'gain') + 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', 'freq') + 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.05 + self.clock_alpha = clock_alpha ################################################## # Blocks @@ -74,9 +73,11 @@ class usrp_rx_hrpt_nogui(gr.top_block): 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.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.noaa_hrpt_bit_sync_0 = noaa.hrpt_bit_sync() 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) @@ -86,56 +87,58 @@ class usrp_rx_hrpt_nogui(gr.top_block): # 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.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.noaa_hrpt_bit_sync_0, 0), (self.deframer, 0)) + self.connect((self.gr_binary_slicer_fb_0, 0), (self.noaa_hrpt_bit_sync_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.agc, 0), (self.gr_fir_filter_xxx_0, 0)) - self.connect((self.gr_fir_filter_xxx_0, 0), (self.pll, 0)) + self.connect((self.deframer, 0), (self.decoder, 0)) def set_config_filename(self, config_filename): self.config_filename = config_filename - self._output_filename_config = ConfigParser.ConfigParser() - self._output_filename_config.read(self.config_filename) - if not self._output_filename_config.has_section('output'): - self._output_filename_config.add_section('output') - self._output_filename_config.set('output', 'filename', str(self.output_filename)) - self._output_filename_config.write(open(self.config_filename, 'w')) - self._sync_alpha_config = ConfigParser.ConfigParser() - self._sync_alpha_config.read(self.config_filename) - if not self._sync_alpha_config.has_section('demod'): - self._sync_alpha_config.add_section('demod') - self._sync_alpha_config.set('demod', 'sync_alpha', str(self.sync_alpha)) - self._sync_alpha_config.write(open(self.config_filename, 'w')) - self._pll_alpha_config = ConfigParser.ConfigParser() - self._pll_alpha_config.read(self.config_filename) - if not self._pll_alpha_config.has_section('demod'): - self._pll_alpha_config.add_section('demod') - self._pll_alpha_config.set('demod', 'pll_alpha', str(self.pll_alpha)) - self._pll_alpha_config.write(open(self.config_filename, 'w')) + self._clock_alpha_config = ConfigParser.ConfigParser() + self._clock_alpha_config.read(self.config_filename) + if not self._clock_alpha_config.has_section('usrp_rx_hrpt'): + self._clock_alpha_config.add_section('usrp_rx_hrpt') + self._clock_alpha_config.set('usrp_rx_hrpt', 'clock_alpha', str(self.clock_alpha)) + self._clock_alpha_config.write(open(self.config_filename, 'w')) self._gain_config = ConfigParser.ConfigParser() self._gain_config.read(self.config_filename) - if not self._gain_config.has_section('usrp'): - self._gain_config.add_section('usrp') - self._gain_config.set('usrp', 'gain', str(self.gain)) + if not self._gain_config.has_section('usrp_rx_hrpt'): + self._gain_config.add_section('usrp_rx_hrpt') + self._gain_config.set('usrp_rx_hrpt', 'gain', str(self.gain)) self._gain_config.write(open(self.config_filename, 'w')) self._freq_config = ConfigParser.ConfigParser() self._freq_config.read(self.config_filename) - if not self._freq_config.has_section('usrp'): - self._freq_config.add_section('usrp') - self._freq_config.set('usrp', 'freq', str(self.freq)) + if not self._freq_config.has_section('usrp_rx_hrpt'): + self._freq_config.add_section('usrp_rx_hrpt') + self._freq_config.set('usrp_rx_hrpt', 'freq', str(self.freq)) self._freq_config.write(open(self.config_filename, 'w')) self._decim_config = ConfigParser.ConfigParser() self._decim_config.read(self.config_filename) - if not self._decim_config.has_section('usrp'): - self._decim_config.add_section('usrp') - self._decim_config.set('usrp', 'decim', str(self.decim)) + if not self._decim_config.has_section('usrp_rx_hrpt'): + self._decim_config.add_section('usrp_rx_hrpt') + self._decim_config.set('usrp_rx_hrpt', 'decim', str(self.decim)) self._decim_config.write(open(self.config_filename, 'w')) + self._output_filename_config = ConfigParser.ConfigParser() + self._output_filename_config.read(self.config_filename) + if not self._output_filename_config.has_section('usrp_rx_hrpt'): + self._output_filename_config.add_section('usrp_rx_hrpt') + self._output_filename_config.set('usrp_rx_hrpt', 'filename', str(self.output_filename)) + self._output_filename_config.write(open(self.config_filename, 'w')) + self._pll_alpha_config = ConfigParser.ConfigParser() + self._pll_alpha_config.read(self.config_filename) + if not self._pll_alpha_config.has_section('usrp_rx_hrpt'): + self._pll_alpha_config.add_section('usrp_rx_hrpt') + self._pll_alpha_config.set('usrp_rx_hrpt', 'pll_alpha', str(self.pll_alpha)) + self._pll_alpha_config.write(open(self.config_filename, 'w')) self._side_config = ConfigParser.ConfigParser() self._side_config.read(self.config_filename) - if not self._side_config.has_section('usrp'): - self._side_config.add_section('usrp') - self._side_config.set('usrp', 'side', str(self.side)) + if not self._side_config.has_section('usrp_rx_hrpt'): + self._side_config.add_section('usrp_rx_hrpt') + self._side_config.set('usrp_rx_hrpt', 'side', str(self.side)) self._side_config.write(open(self.config_filename, 'w')) def set_decim(self, decim): @@ -143,9 +146,9 @@ class usrp_rx_hrpt_nogui(gr.top_block): self.set_sample_rate(64e6/self.decim) self._decim_config = ConfigParser.ConfigParser() self._decim_config.read(self.config_filename) - if not self._decim_config.has_section('usrp'): - self._decim_config.add_section('usrp') - self._decim_config.set('usrp', 'decim', str(self.decim)) + if not self._decim_config.has_section('usrp_rx_hrpt'): + self._decim_config.add_section('usrp_rx_hrpt') + self._decim_config.set('usrp_rx_hrpt', 'decim', str(self.decim)) self._decim_config.write(open(self.config_filename, 'w')) self.usrp_source.set_decim_rate(self.decim) @@ -161,38 +164,24 @@ class usrp_rx_hrpt_nogui(gr.top_block): def set_sps(self, sps): self.sps = sps self.set_hs(int(self.sps/2.0)) - - def set_hs(self, hs): - self.hs = hs - self.set_mf_taps([-0.5/self.hs,]*self.hs+[0.5/self.hs,]*self.hs) - - def set_sync_alpha(self, sync_alpha): - self.sync_alpha = sync_alpha - self._sync_alpha_config = ConfigParser.ConfigParser() - self._sync_alpha_config.read(self.config_filename) - if not self._sync_alpha_config.has_section('demod'): - self._sync_alpha_config.add_section('demod') - self._sync_alpha_config.set('demod', 'sync_alpha', str(self.sync_alpha)) - self._sync_alpha_config.write(open(self.config_filename, 'w')) - self.sync.set_alpha(self.sync_alpha) - self.sync.set_beta(self.sync_alpha**2/4.0) + self.gr_clock_recovery_mm_xx_0.set_omega(self.sps/2.0) def set_side(self, side): self.side = side self._side_config = ConfigParser.ConfigParser() self._side_config.read(self.config_filename) - if not self._side_config.has_section('usrp'): - self._side_config.add_section('usrp') - self._side_config.set('usrp', 'side', str(self.side)) + if not self._side_config.has_section('usrp_rx_hrpt'): + self._side_config.add_section('usrp_rx_hrpt') + self._side_config.set('usrp_rx_hrpt', 'side', str(self.side)) self._side_config.write(open(self.config_filename, 'w')) def set_pll_alpha(self, pll_alpha): self.pll_alpha = pll_alpha self._pll_alpha_config = ConfigParser.ConfigParser() self._pll_alpha_config.read(self.config_filename) - if not self._pll_alpha_config.has_section('demod'): - self._pll_alpha_config.add_section('demod') - self._pll_alpha_config.set('demod', 'pll_alpha', str(self.pll_alpha)) + if not self._pll_alpha_config.has_section('usrp_rx_hrpt'): + self._pll_alpha_config.add_section('usrp_rx_hrpt') + self._pll_alpha_config.set('usrp_rx_hrpt', 'pll_alpha', str(self.pll_alpha)) self._pll_alpha_config.write(open(self.config_filename, 'w')) self.pll.set_alpha(self.pll_alpha) self.pll.set_beta(self.pll_alpha**2/4.0) @@ -201,30 +190,29 @@ class usrp_rx_hrpt_nogui(gr.top_block): self.output_filename = output_filename self._output_filename_config = ConfigParser.ConfigParser() self._output_filename_config.read(self.config_filename) - if not self._output_filename_config.has_section('output'): - self._output_filename_config.add_section('output') - self._output_filename_config.set('output', 'filename', str(self.output_filename)) + if not self._output_filename_config.has_section('usrp_rx_hrpt'): + self._output_filename_config.add_section('usrp_rx_hrpt') + self._output_filename_config.set('usrp_rx_hrpt', 'filename', str(self.output_filename)) self._output_filename_config.write(open(self.config_filename, 'w')) - def set_mf_taps(self, mf_taps): - self.mf_taps = mf_taps - self.gr_fir_filter_xxx_0.set_taps((self.mf_taps)) - - def set_max_sync_offset(self, max_sync_offset): - self.max_sync_offset = max_sync_offset - self.sync.set_max_offset(self.max_sync_offset) + def set_max_clock_offset(self, max_clock_offset): + self.max_clock_offset = max_clock_offset def set_max_carrier_offset(self, max_carrier_offset): self.max_carrier_offset = max_carrier_offset self.pll.set_max_offset(self.max_carrier_offset) + def set_hs(self, hs): + self.hs = hs + self.gr_moving_average_xx_0.set_length_and_scale(self.hs, 1.0/self.hs) + def set_gain(self, gain): self.gain = gain self._gain_config = ConfigParser.ConfigParser() self._gain_config.read(self.config_filename) - if not self._gain_config.has_section('usrp'): - self._gain_config.add_section('usrp') - self._gain_config.set('usrp', 'gain', str(self.gain)) + if not self._gain_config.has_section('usrp_rx_hrpt'): + self._gain_config.add_section('usrp_rx_hrpt') + self._gain_config.set('usrp_rx_hrpt', 'gain', str(self.gain)) self._gain_config.write(open(self.config_filename, 'w')) self.usrp_source.set_gain(self.gain) @@ -232,12 +220,23 @@ class usrp_rx_hrpt_nogui(gr.top_block): self.freq = freq self._freq_config = ConfigParser.ConfigParser() self._freq_config.read(self.config_filename) - if not self._freq_config.has_section('usrp'): - self._freq_config.add_section('usrp') - self._freq_config.set('usrp', 'freq', str(self.freq)) + if not self._freq_config.has_section('usrp_rx_hrpt'): + self._freq_config.add_section('usrp_rx_hrpt') + self._freq_config.set('usrp_rx_hrpt', 'freq', str(self.freq)) self._freq_config.write(open(self.config_filename, 'w')) self.usrp_source.set_frequency(self.freq) + def set_clock_alpha(self, clock_alpha): + self.clock_alpha = clock_alpha + self._clock_alpha_config = ConfigParser.ConfigParser() + self._clock_alpha_config.read(self.config_filename) + if not self._clock_alpha_config.has_section('usrp_rx_hrpt'): + self._clock_alpha_config.add_section('usrp_rx_hrpt') + self._clock_alpha_config.set('usrp_rx_hrpt', 'clock_alpha', str(self.clock_alpha)) + self._clock_alpha_config.write(open(self.config_filename, 'w')) + self.gr_clock_recovery_mm_xx_0.set_gain_omega(self.clock_alpha**2/4.0) + self.gr_clock_recovery_mm_xx_0.set_gain_mu(self.clock_alpha) + if __name__ == '__main__': parser = OptionParser(option_class=eng_option, usage="%prog: [options]") (options, args) = parser.parse_args() |