From ec8c8e0e9d68383279b0fb51a52adf04f11fd88a Mon Sep 17 00:00:00 2001 From: Johnathan Corgan Date: Sun, 27 Sep 2009 10:15:04 -0700 Subject: General improvements in HRPT receiver Added usrp_rx_hrpt_nogui script Simplified usrp_rx_hrpt script for lower CPU usage Changed matched filtering taps to be whole symbol --- gr-noaa/apps/Makefile.am | 2 + gr-noaa/apps/demod_hrpt_file.grc | 331 +++++++------- gr-noaa/apps/demod_hrpt_file.py | 55 +-- gr-noaa/apps/usrp_rx_hrpt.grc | 560 ++++++++++++----------- gr-noaa/apps/usrp_rx_hrpt.py | 82 +--- gr-noaa/apps/usrp_rx_hrpt_nogui.grc | 869 ++++++++++++++++++++++++++++++++++++ gr-noaa/apps/usrp_rx_hrpt_nogui.py | 250 +++++++++++ 7 files changed, 1642 insertions(+), 507 deletions(-) create mode 100644 gr-noaa/apps/usrp_rx_hrpt_nogui.grc create mode 100755 gr-noaa/apps/usrp_rx_hrpt_nogui.py diff --git a/gr-noaa/apps/Makefile.am b/gr-noaa/apps/Makefile.am index 906638ff1..5cefe9d21 100644 --- a/gr-noaa/apps/Makefile.am +++ b/gr-noaa/apps/Makefile.am @@ -26,10 +26,12 @@ if PYTHON dist_bin_SCRIPTS = \ demod_hrpt_file.py \ usrp_rx_hrpt.py \ + usrp_rx_hrpt_nogui.py \ usrp_rx_lrit.py EXTRA_DIST = \ demod_hrpt_file.grc \ usrp_rx_hrpt.grc \ + usrp_rx_hrpt_nogui.grc \ usrp_rx_lrit.grc endif diff --git a/gr-noaa/apps/demod_hrpt_file.grc b/gr-noaa/apps/demod_hrpt_file.grc index 4a5e87170..16f83f780 100644 --- a/gr-noaa/apps/demod_hrpt_file.grc +++ b/gr-noaa/apps/demod_hrpt_file.grc @@ -1,6 +1,6 @@ - Wed Sep 23 11:37:25 2009 + Sun Sep 27 09:51:42 2009 options @@ -191,34 +191,22 @@ - parameter + import id - decim + import_0 _enabled True - label - Decimation - - - value - 16 - - - type - intx - - - short_id - d + import + import math _coordinate - (404, 102) + (9, 92) _rotation @@ -229,7 +217,7 @@ parameter id - pll_alpha + filename _enabled @@ -237,23 +225,23 @@ label - + Filename value - 0.05 + usrp.dat type - eng_float + string short_id - p + F _coordinate - (516, 102) + (200, 101) _rotation @@ -264,7 +252,7 @@ parameter id - sync_alpha + output _enabled @@ -272,23 +260,23 @@ label - + Output value - 0.05 + frames.dat type - eng_float + string short_id - s + o _coordinate - (601, 103) + (302, 101) _rotation @@ -296,22 +284,22 @@ - import + gr_float_to_complex id - import_0 + f2c _enabled True - import - import math + vlen + 1 _coordinate - (9, 92) + (832, 363) _rotation @@ -319,34 +307,57 @@ - parameter + virtual_sink id - filename + samples_sink _enabled True - label - Filename + stream_id + samples - value - usrp.dat + _coordinate + (1070, 376) - type - string + _rotation + 0 + + + noaa_hrpt_sync_fb - short_id - F + id + sync + + + _enabled + True + + + alpha + sync_alpha + + + beta + sync_alpha**2/4.0 + + + sps + sps + + + max_offset + max_sync_offset _coordinate - (200, 101) + (813, 455) _rotation @@ -354,10 +365,29 @@ - gr_file_source + noaa_hrpt_deframer id - file_source + deframer + + + _enabled + True + + + _coordinate + (1037, 483) + + + _rotation + 0 + + + + gr_file_sink + + id + file_sink _enabled @@ -365,23 +395,19 @@ file - filename + output type short - - repeat - False - vlen 1 _coordinate - (102, 368) + (1238, 479) _rotation @@ -389,10 +415,10 @@ - gr_short_to_float + noaa_hrpt_decoder id - s2f + decoder _enabled @@ -400,7 +426,7 @@ _coordinate - (305, 380) + (1237, 542) _rotation @@ -431,7 +457,7 @@ _coordinate - (526, 363) + (628, 363) _rotation @@ -439,45 +465,34 @@ - gr_float_to_complex + parameter id - f2c + decim _enabled True - vlen - 1 - - - _coordinate - (730, 363) - - - _rotation - 0 + label + Decimation - - - virtual_sink - id - samples_sink + value + 16 - _enabled - True + type + intx - stream_id - samples + short_id + d _coordinate - (968, 376) + (415, 101) _rotation @@ -485,22 +500,34 @@ - virtual_source + parameter id - samples_source + pll_alpha _enabled True - stream_id - samples + label + + + + value + 0.05 + + + type + eng_float + + + short_id + p _coordinate - (104, 479) + (527, 101) _rotation @@ -508,34 +535,34 @@ - gr_moving_average_xx + parameter id - matched_filter + sync_alpha _enabled True - type - complex + label + - length - hs + value + 0.05 - scale - 1.0/hs + type + eng_float - max_iter - 4000 + short_id + s _coordinate - (302, 463) + (615, 99) _rotation @@ -566,7 +593,7 @@ _coordinate - (504, 463) + (606, 463) _rotation @@ -574,34 +601,22 @@ - noaa_hrpt_sync_fb + virtual_source id - sync + samples_source _enabled True - alpha - sync_alpha - - - beta - sync_alpha**2/4.0 - - - sps - sps - - - max_offset - max_sync_offset + stream_id + samples _coordinate - (711, 455) + (164, 479) _rotation @@ -609,10 +624,10 @@ - noaa_hrpt_deframer + gr_short_to_float id - deframer + s2f _enabled @@ -620,7 +635,7 @@ _coordinate - (935, 483) + (365, 380) _rotation @@ -628,10 +643,10 @@ - gr_file_sink + gr_file_source id - file_sink + file_source _enabled @@ -639,19 +654,23 @@ file - output + filename type short + + repeat + False + vlen 1 _coordinate - (1136, 479) + (162, 368) _rotation @@ -659,18 +678,22 @@ - noaa_hrpt_decoder + variable id - decoder + mf_taps _enabled True + + value + [-0.5/hs,]*hs+[0.5/hs,]*hs + _coordinate - (1135, 542) + (829, 21) _rotation @@ -678,34 +701,30 @@ - parameter + gr_fir_filter_xxx id - output + gr_fir_filter_xxx_0 _enabled True - label - Output - - - value - frames.dat + type + ccc - type - string + decim + 1 - short_id - o + taps + mf_taps _coordinate - (302, 101) + (359, 471) _rotation @@ -730,18 +749,6 @@ 0 0 - - matched_filter - pll - 0 - 0 - - - s2f - deinterleave - 0 - 0 - deinterleave f2c @@ -754,12 +761,6 @@ 0 0 - - file_source - s2f - 0 - 0 - deframer decoder @@ -772,9 +773,27 @@ 0 0 + + gr_fir_filter_xxx_0 + pll + 0 + 0 + samples_source - matched_filter + gr_fir_filter_xxx_0 + 0 + 0 + + + s2f + deinterleave + 0 + 0 + + + file_source + s2f 0 0 diff --git a/gr-noaa/apps/demod_hrpt_file.py b/gr-noaa/apps/demod_hrpt_file.py index a1469e9e0..309a79209 100755 --- a/gr-noaa/apps/demod_hrpt_file.py +++ b/gr-noaa/apps/demod_hrpt_file.py @@ -2,7 +2,7 @@ ################################################## # Gnuradio Python Flow Graph # Title: USRP HRPT Receiver -# Generated: Wed Sep 23 11:37:25 2009 +# Generated: Sun Sep 27 09:34:15 2009 ################################################## from gnuradio import eng_notation @@ -15,17 +15,17 @@ import math class demod_hrpt_file(gr.top_block): - def __init__(self, decim=16, pll_alpha=0.05, sync_alpha=0.05, filename="usrp.dat", output="frames.dat"): + 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 - self.filename = filename - self.output = output ################################################## # Variables @@ -33,9 +33,10 @@ class demod_hrpt_file(gr.top_block): 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 - self.hs = hs = int(sps/2.0) ################################################## # Blocks @@ -46,7 +47,7 @@ class demod_hrpt_file(gr.top_block): 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.matched_filter = gr.moving_average_cc(hs, 1.0/hs, 4000) + 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) @@ -57,13 +58,19 @@ class demod_hrpt_file(gr.top_block): 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.matched_filter, 0), (self.pll, 0)) - self.connect((self.s2f, 0), (self.deinterleave, 0)) self.connect((self.deinterleave, 1), (self.f2c, 1)) self.connect((self.deinterleave, 0), (self.f2c, 0)) - self.connect((self.file_source, 0), (self.s2f, 0)) self.connect((self.deframer, 0), (self.decoder, 0)) - self.connect((self.f2c, 0), (self.matched_filter, 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 set_filename(self, filename): + self.filename = filename + + def set_output(self, output): + self.output = output def set_decim(self, decim): self.decim = decim @@ -79,12 +86,6 @@ class demod_hrpt_file(gr.top_block): self.sync.set_alpha(self.sync_alpha) self.sync.set_beta(self.sync_alpha**2/4.0) - def set_filename(self, filename): - self.filename = filename - - def set_output(self, output): - self.output = output - def set_sym_rate(self, sym_rate): self.sym_rate = sym_rate self.set_sps(self.sample_rate/self.sym_rate) @@ -98,6 +99,14 @@ class demod_hrpt_file(gr.top_block): 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_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) @@ -106,24 +115,20 @@ class demod_hrpt_file(gr.top_block): 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.matched_filter.set_length_and_scale(self.hs, 1.0/self.hs) - if __name__ == '__main__': parser = OptionParser(option_class=eng_option, usage="%prog: [options]") + parser.add_option("-F", "--filename", dest="filename", type="string", default="usrp.dat", + help="Set Filename [default=%default]") + parser.add_option("-o", "--output", dest="output", type="string", default="frames.dat", + help="Set Output [default=%default]") parser.add_option("-d", "--decim", dest="decim", type="intx", default=16, help="Set Decimation [default=%default]") parser.add_option("-p", "--pll-alpha", dest="pll_alpha", type="eng_float", default=eng_notation.num_to_str(0.05), help="Set pll_alpha [default=%default]") parser.add_option("-s", "--sync-alpha", dest="sync_alpha", type="eng_float", default=eng_notation.num_to_str(0.05), help="Set sync_alpha [default=%default]") - parser.add_option("-F", "--filename", dest="filename", type="string", default="usrp.dat", - help="Set Filename [default=%default]") - parser.add_option("-o", "--output", dest="output", type="string", default="frames.dat", - help="Set Output [default=%default]") (options, args) = parser.parse_args() - tb = demod_hrpt_file(decim=options.decim, pll_alpha=options.pll_alpha, sync_alpha=options.sync_alpha, filename=options.filename, output=options.output) + tb = demod_hrpt_file(filename=options.filename, output=options.output, decim=options.decim, pll_alpha=options.pll_alpha, sync_alpha=options.sync_alpha) tb.start() raw_input('Press Enter to quit: ') tb.stop() diff --git a/gr-noaa/apps/usrp_rx_hrpt.grc b/gr-noaa/apps/usrp_rx_hrpt.grc index 90d868769..c999a6bfd 100644 --- a/gr-noaa/apps/usrp_rx_hrpt.grc +++ b/gr-noaa/apps/usrp_rx_hrpt.grc @@ -1,6 +1,6 @@ - Wed Sep 23 11:32:00 2009 + Sun Sep 27 10:06:41 2009 options @@ -41,7 +41,7 @@ realtime_scheduling - + 1 _coordinate @@ -75,87 +75,6 @@ 0 - - gr_moving_average_xx - - id - matched_filter - - - _enabled - True - - - type - complex - - - length - hs - - - scale - 1.0/hs - - - max_iter - 4000 - - - _coordinate - (441, 723) - - - _rotation - 0 - - - - import - - id - import_0 - - - _enabled - True - - - import - import math - - - _coordinate - (11, 76) - - - _rotation - 0 - - - - variable - - id - config_filename - - - _enabled - True - - - value - 'usrp_rx_hrpt.cfg' - - - _coordinate - (12, 129) - - - _rotation - 0 - - variable @@ -867,58 +786,76 @@ - usrp_simple_source_x + variable id - usrp_source + config_filename _enabled True - type - complex + value + 'usrp_rx_hrpt.cfg' - format - + _coordinate + (12, 160) - which + _rotation 0 + + + import - decimation - decim + id + import_0 - frequency - freq + _enabled + True - lo_offset - float('inf') + import + import math - gain - gain + _coordinate + (11, 102) - side - side + _rotation + 0 + + + noaa_hrpt_pll_cf - rx_ant - RXA + id + pll - hb_filters - + _enabled + True + + + alpha + pll_alpha + + + beta + pll_alpha**2/4.0 + + + max_offset + max_carrier_offset _coordinate - (56, 699) + (664, 809) _rotation @@ -926,38 +863,34 @@ - gr_agc_xx + noaa_hrpt_sync_fb id - agc + sync _enabled True - type - complex - - - rate - 1e-6 + alpha + sync_alpha - reference - 1.0 + beta + sync_alpha**2/4.0 - gain - 1.0 + sps + sps - max_gain - 1.0 + max_offset + max_sync_offset _coordinate - (273, 715) + (865, 801) _rotation @@ -965,58 +898,68 @@ - wxgui_scopesink2 + gr_file_sink id - rx_scope + frame_sink _enabled True + + file + output_filename + type - complex + short - title - RX Waveform + vlen + 1 - samp_rate - sample_rate + _coordinate + (1283, 937) - v_scale + _rotation 0 + + + noaa_hrpt_deframer - t_scale - 20.0/sample_rate + id + deframer - ac_couple - False + _enabled + True - xy_mode - False + _coordinate + (1091, 829) - num_inputs - 1 + _rotation + 0 + + + noaa_hrpt_decoder - grid_pos - 1, 0, 1, 1 + id + decoder - notebook - displays, 0 + _enabled + True _coordinate - (439, 829) + (1281, 829) _rotation @@ -1024,10 +967,10 @@ - wxgui_fftsink2 + wxgui_scopesink2 id - rx_fft + pll_scope _enabled @@ -1035,67 +978,86 @@ type - complex + float title - RX Spectrum + Demod Waveform samp_rate sample_rate - baseband_freq - freq + v_scale + 0.5 - y_per_div - 5 + t_scale + 20.0/sample_rate - y_divs - 8 + ac_couple + False - ref_level - -5 + xy_mode + False - ref_scale - 2.0 + num_inputs + 1 - fft_size - 1024 + grid_pos + 2,0,1,4 - fft_rate - 30 + notebook + - peak_hold - False + _coordinate + (631, 632) + + + _rotation + 180 + + + + gr_agc_xx + + id + agc - average + _enabled True - avg_alpha - 0.1 + type + complex + + + rate + 1e-6 - grid_pos - 0, 0, 1, 1 + reference + 1.0 - notebook - displays, 0 + gain + 1.0 + + + max_gain + 1.0 _coordinate - (439, 465) + (269, 801) _rotation @@ -1103,10 +1065,10 @@ - wxgui_scopesink2 + gr_fir_filter_xxx id - pll_scope + gr_fir_filter_xxx_0 _enabled @@ -1114,82 +1076,77 @@ type - float - - - title - Post-PLL + ccc - samp_rate - sample_rate - - - v_scale - 0.5 + decim + 1 - t_scale - 20.0/sample_rate + taps + mf_taps - ac_couple - False + _coordinate + (418, 817) - xy_mode - False + _rotation + 0 + + + variable - num_inputs - 1 + id + mf_taps - grid_pos - 0, 0, 1, 1 + _enabled + True - notebook - displays, 1 + value + [-0.5/hs,]*hs+[0.5/hs,]*hs _coordinate - (605, 552) + (830, 154) _rotation - 180 + 0 - notebook + gr_file_source id - displays + file_source _enabled - True + False - style - wx.NB_TOP + file + 'usrp.dat' - labels - ['RX','Demod'] + type + short - grid_pos - 2, 0, 1, 4 + repeat + False - notebook - + vlen + 1 _coordinate - (15, 237) + (215, 490) _rotation @@ -1197,30 +1154,30 @@ - noaa_hrpt_pll_cf + gr_deinterleave id - pll + gr_deinterleave_0 _enabled - True + False - alpha - pll_alpha + type + float - beta - pll_alpha**2/4.0 + num_streams + 2 - max_offset - max_carrier_offset + vlen + 1 _coordinate - (632, 723) + (598, 485) _rotation @@ -1228,34 +1185,41 @@ - noaa_hrpt_sync_fb + gr_float_to_complex id - sync + gr_float_to_complex_0 _enabled - True + False - alpha - sync_alpha + vlen + 1 - beta - sync_alpha**2/4.0 + _coordinate + (801, 485) - sps - sps + _rotation + 0 + + + gr_short_to_float - max_offset - max_sync_offset + id + s2f + + + _enabled + False _coordinate - (840, 715) + (393, 502) _rotation @@ -1263,18 +1227,22 @@ - noaa_hrpt_deframer + virtual_sink id - deframer + sample_stream _enabled - True + False + + + stream_id + samples _coordinate - (1071, 743) + (1027, 498) _rotation @@ -1282,18 +1250,58 @@ - noaa_hrpt_decoder + usrp_simple_source_x id - decoder + usrp_source _enabled True + + type + complex + + + format + + + + which + 0 + + + decimation + decim + + + frequency + freq + + + lo_offset + float('inf') + + + gain + gain + + + side + side + + + rx_ant + RXA + + + hb_filters + + _coordinate - (1274, 743) + (63, 785) _rotation @@ -1301,45 +1309,55 @@ - gr_file_sink + virtual_source id - frame_sink + virtual_source_0 _enabled - True - - - file - output_filename + False - type - short - - - vlen - 1 + stream_id + samples _coordinate - (1273, 851) + (69, 671) _rotation 0 + + gr_fir_filter_xxx_0 + pll + 0 + 0 + + + agc + gr_fir_filter_xxx_0 + 0 + 0 + + + usrp_source + agc + 0 + 0 + deframer - frame_sink + decoder 0 0 - sync - deframer + pll + pll_scope 0 0 @@ -1350,44 +1368,50 @@ 0 - pll - pll_scope + sync + deframer 0 0 - agc - rx_scope + deframer + frame_sink 0 0 - agc - rx_fft + virtual_source_0 + agc 0 0 - agc - matched_filter + file_source + s2f 0 0 - matched_filter - pll + s2f + gr_deinterleave_0 0 0 - deframer - decoder + gr_deinterleave_0 + gr_float_to_complex_0 0 0 - usrp_source - agc + gr_deinterleave_0 + gr_float_to_complex_0 + 1 + 1 + + + gr_float_to_complex_0 + sample_stream 0 0 diff --git a/gr-noaa/apps/usrp_rx_hrpt.py b/gr-noaa/apps/usrp_rx_hrpt.py index 7efbecd3a..9b19d5e4f 100755 --- a/gr-noaa/apps/usrp_rx_hrpt.py +++ b/gr-noaa/apps/usrp_rx_hrpt.py @@ -2,7 +2,7 @@ ################################################## # Gnuradio Python Flow Graph # Title: USRP HRPT Receiver -# Generated: Wed Sep 23 11:32:04 2009 +# Generated: Sun Sep 27 10:06:41 2009 ################################################## from gnuradio import eng_notation @@ -10,7 +10,6 @@ from gnuradio import gr from gnuradio import noaa from gnuradio.eng_option import eng_option from gnuradio.gr import firdes -from gnuradio.wxgui import fftsink2 from gnuradio.wxgui import forms from gnuradio.wxgui import scopesink2 from grc_gnuradio import usrp as grc_usrp @@ -62,6 +61,7 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui): 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 @@ -70,21 +70,13 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui): 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.hs = hs = int(sps/2.0) 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 ################################################## @@ -189,11 +181,11 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui): self.decoder = noaa.hrpt_decoder() self.deframer = noaa.hrpt_deframer() self.frame_sink = gr.file_sink(gr.sizeof_short*1, output_filename) - self.matched_filter = gr.moving_average_cc(hs, 1.0/hs, 4000) + 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="Post-PLL", + self.GetWin(), + title="Demod Waveform", sample_rate=sample_rate, v_scale=0.5, t_scale=20.0/sample_rate, @@ -201,34 +193,7 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui): 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=30, - 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.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) @@ -238,16 +203,14 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui): ################################################## # 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.agc, 0), (self.matched_filter, 0)) - self.connect((self.matched_filter, 0), (self.pll, 0)) - self.connect((self.deframer, 0), (self.decoder, 0)) + 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 set_config_filename(self, config_filename): self.config_filename = config_filename @@ -314,8 +277,6 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui): self.sample_rate = sample_rate self.set_max_carrier_offset(2*math.pi*100e3/self.sample_rate) self.set_sps(self.sample_rate/self.sym_rate) - self.rx_scope.set_sample_rate(self.sample_rate) - self.rx_fft.set_sample_rate(self.sample_rate) self.pll_scope.set_sample_rate(self.sample_rate) def set_sps(self, sps): @@ -348,6 +309,10 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui): self.saved_freq = saved_freq self.set_freq(self.saved_freq) + 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_slider.set_value(self.sync_alpha) @@ -387,6 +352,10 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui): self._output_filename_config.set('output', '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) @@ -395,10 +364,6 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui): 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.matched_filter.set_length_and_scale(self.hs, 1.0/self.hs) - def set_gain(self, gain): self.gain = gain self._gain_slider.set_value(self.gain) @@ -421,7 +386,6 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui): self._saved_freq_config.set('usrp', 'freq', str(self.freq)) self._saved_freq_config.write(open(self.config_filename, 'w')) self.usrp_source.set_frequency(self.freq) - self.rx_fft.set_baseband_freq(self.freq) def set_decim_text(self, decim_text): self.decim_text = decim_text @@ -430,6 +394,8 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui): if __name__ == '__main__': parser = OptionParser(option_class=eng_option, usage="%prog: [options]") (options, args) = parser.parse_args() + if gr.enable_realtime_scheduling() != gr.RT_OK: + print "Error: failed to enable realtime scheduling." tb = usrp_rx_hrpt() tb.Run(True) diff --git a/gr-noaa/apps/usrp_rx_hrpt_nogui.grc b/gr-noaa/apps/usrp_rx_hrpt_nogui.grc new file mode 100644 index 000000000..fadc2d1da --- /dev/null +++ b/gr-noaa/apps/usrp_rx_hrpt_nogui.grc @@ -0,0 +1,869 @@ + + + Sun Sep 27 10:13:25 2009 + + options + + id + usrp_rx_hrpt_nogui + + + _enabled + True + + + title + USRP HRPT Receiver + + + author + + + + description + + + + window_size + 4096,4096 + + + generate_options + no_gui + + + category + Custom + + + run + True + + + realtime_scheduling + 1 + + + _coordinate + (10, 10) + + + _rotation + 0 + + + + variable + + id + max_carrier_offset + + + _enabled + True + + + value + 2*math.pi*100e3/sample_rate + + + _coordinate + (575, 19) + + + _rotation + 0 + + + + variable + + id + sym_rate + + + _enabled + True + + + value + 600*1109 + + + _coordinate + (301, 19) + + + _rotation + 0 + + + + variable + + id + sps + + + _enabled + True + + + value + sample_rate/sym_rate + + + _coordinate + (397, 19) + + + _rotation + 0 + + + + variable + + id + hs + + + _enabled + True + + + value + int(sps/2.0) + + + _coordinate + (499, 19) + + + _rotation + 0 + + + + variable + + id + sample_rate + + + _enabled + True + + + value + 64e6/decim + + + _coordinate + (198, 17) + + + _rotation + 0 + + + + variable + + id + max_sync_offset + + + _enabled + True + + + value + 0.01 + + + _coordinate + (705, 19) + + + _rotation + 0 + + + + variable + + id + config_filename + + + _enabled + True + + + value + 'usrp_rx_hrpt.cfg' + + + _coordinate + (12, 167) + + + _rotation + 0 + + + + import + + id + import_0 + + + _enabled + True + + + import + import math + + + _coordinate + (11, 112) + + + _rotation + 0 + + + + variable_config + + id + output_filename + + + _enabled + True + + + value + 'frames.dat' + + + type + string + + + config_file + config_filename + + + section + 'output' + + + option + 'filename' + + + writeback + output_filename + + + _coordinate + (1146, 122) + + + _rotation + 0 + + + + variable_config + + id + sync_alpha + + + _enabled + True + + + value + 0.05 + + + type + real + + + config_file + config_filename + + + section + 'demod' + + + option + 'sync_alpha' + + + writeback + sync_alpha + + + _coordinate + (988, 121) + + + _rotation + 0 + + + + variable_config + + id + pll_alpha + + + _enabled + True + + + value + 0.05 + + + type + real + + + config_file + config_filename + + + section + 'demod' + + + option + 'pll_alpha' + + + writeback + pll_alpha + + + _coordinate + (830, 121) + + + _rotation + 0 + + + + variable_config + + id + gain + + + _enabled + True + + + value + 35 + + + type + real + + + config_file + config_filename + + + section + 'usrp' + + + option + 'gain' + + + writeback + gain + + + _coordinate + (671, 122) + + + _rotation + 0 + + + + variable_config + + id + freq + + + _enabled + True + + + value + 1698e6 + + + type + real + + + config_file + config_filename + + + section + 'usrp' + + + option + 'freq' + + + writeback + freq + + + _coordinate + (514, 121) + + + _rotation + 0 + + + + variable_config + + id + decim + + + _enabled + True + + + value + 16 + + + type + real + + + config_file + config_filename + + + section + 'usrp' + + + option + 'decim' + + + writeback + decim + + + _coordinate + (358, 118) + + + _rotation + 0 + + + + variable_config + + id + side + + + _enabled + True + + + value + 'A' + + + type + string + + + config_file + config_filename + + + section + 'usrp' + + + option + 'side' + + + writeback + side + + + _coordinate + (201, 116) + + + _rotation + 0 + + + + noaa_hrpt_decoder + + id + decoder + + + _enabled + True + + + _coordinate + (1247, 347) + + + _rotation + 0 + + + + usrp_simple_source_x + + id + usrp_source + + + _enabled + True + + + type + complex + + + format + + + + which + 0 + + + decimation + decim + + + frequency + freq + + + lo_offset + float('inf') + + + gain + gain + + + side + side + + + rx_ant + RXA + + + hb_filters + + + + _coordinate + (29, 303) + + + _rotation + 0 + + + + variable + + id + mf_taps + + + _enabled + True + + + value + [-0.5/hs,]*hs+[0.5/hs,]*hs + + + _coordinate + (825, 19) + + + _rotation + 0 + + + + gr_agc_xx + + id + agc + + + _enabled + True + + + type + complex + + + rate + 1e-6 + + + reference + 1.0 + + + gain + 1.0 + + + max_gain + 1.0 + + + _coordinate + (246, 319) + + + _rotation + 0 + + + + noaa_hrpt_deframer + + id + deframer + + + _enabled + True + + + _coordinate + (1060, 347) + + + _rotation + 0 + + + + gr_file_sink + + id + frame_sink + + + _enabled + True + + + file + output_filename + + + type + short + + + vlen + 1 + + + _coordinate + (1251, 454) + + + _rotation + 0 + + + + noaa_hrpt_sync_fb + + id + sync + + + _enabled + True + + + alpha + sync_alpha + + + beta + sync_alpha**2/4.0 + + + sps + sps + + + max_offset + max_sync_offset + + + _coordinate + (833, 319) + + + _rotation + 0 + + + + noaa_hrpt_pll_cf + + id + pll + + + _enabled + True + + + alpha + pll_alpha + + + beta + pll_alpha**2/4.0 + + + max_offset + max_carrier_offset + + + _coordinate + (638, 327) + + + _rotation + 0 + + + + gr_fir_filter_xxx + + id + gr_fir_filter_xxx_0 + + + _enabled + True + + + type + ccc + + + decim + 1 + + + taps + mf_taps + + + _coordinate + (402, 335) + + + _rotation + 0 + + + + usrp_source + agc + 0 + 0 + + + deframer + decoder + 0 + 0 + + + pll + sync + 0 + 0 + + + sync + deframer + 0 + 0 + + + deframer + frame_sink + 0 + 0 + + + agc + gr_fir_filter_xxx_0 + 0 + 0 + + + gr_fir_filter_xxx_0 + pll + 0 + 0 + + diff --git a/gr-noaa/apps/usrp_rx_hrpt_nogui.py b/gr-noaa/apps/usrp_rx_hrpt_nogui.py new file mode 100755 index 000000000..9917847bb --- /dev/null +++ b/gr-noaa/apps/usrp_rx_hrpt_nogui.py @@ -0,0 +1,250 @@ +#!/usr/bin/env python +################################################## +# Gnuradio Python Flow Graph +# Title: USRP HRPT Receiver +# Generated: Sun Sep 27 10:13:25 2009 +################################################## + +from gnuradio import eng_notation +from gnuradio import gr +from gnuradio import noaa +from gnuradio.eng_option import eng_option +from gnuradio.gr import firdes +from grc_gnuradio import usrp as grc_usrp +from optparse import OptionParser +import ConfigParser +import math + +class usrp_rx_hrpt_nogui(gr.top_block): + + 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 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._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)) + 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)) + 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)) + self._decim_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)) + self._side_config.write(open(self.config_filename, 'w')) + + def set_decim(self, decim): + self.decim = decim + 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)) + self._decim_config.write(open(self.config_filename, 'w')) + self.usrp_source.set_decim_rate(self.decim) + + def set_sym_rate(self, sym_rate): + self.sym_rate = sym_rate + self.set_sps(self.sample_rate/self.sym_rate) + + def set_sample_rate(self, sample_rate): + self.sample_rate = sample_rate + self.set_max_carrier_offset(2*math.pi*100e3/self.sample_rate) + self.set_sps(self.sample_rate/self.sym_rate) + + 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) + + 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)) + 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)) + 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) + + def set_output_filename(self, output_filename): + 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)) + 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_carrier_offset(self, max_carrier_offset): + self.max_carrier_offset = max_carrier_offset + self.pll.set_max_offset(self.max_carrier_offset) + + 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)) + self._gain_config.write(open(self.config_filename, 'w')) + self.usrp_source.set_gain(self.gain) + + def set_freq(self, freq): + 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)) + self._freq_config.write(open(self.config_filename, 'w')) + self.usrp_source.set_frequency(self.freq) + +if __name__ == '__main__': + parser = OptionParser(option_class=eng_option, usage="%prog: [options]") + (options, args) = parser.parse_args() + if gr.enable_realtime_scheduling() != gr.RT_OK: + print "Error: failed to enable realtime scheduling." + tb = usrp_rx_hrpt_nogui() + tb.start() + raw_input('Press Enter to quit: ') + tb.stop() + -- cgit From db2f60baf542ac35151eb7084e274701861bacc5 Mon Sep 17 00:00:00 2001 From: Johnathan Corgan Date: Sun, 27 Sep 2009 13:34:20 -0700 Subject: Renamed simplified HRPT script to allow restoring original --- gr-noaa/apps/Makefile.am | 4 +- gr-noaa/apps/usrp_rx_hrpt.grc | 1418 ---------------------------------------- gr-noaa/apps/usrp_rx_hrpt.py | 401 ------------ gr-noaa/apps/usrp_rx_hrpt2.grc | 1418 ++++++++++++++++++++++++++++++++++++++++ gr-noaa/apps/usrp_rx_hrpt2.py | 401 ++++++++++++ 5 files changed, 1821 insertions(+), 1821 deletions(-) delete mode 100644 gr-noaa/apps/usrp_rx_hrpt.grc delete mode 100755 gr-noaa/apps/usrp_rx_hrpt.py create mode 100644 gr-noaa/apps/usrp_rx_hrpt2.grc create mode 100755 gr-noaa/apps/usrp_rx_hrpt2.py diff --git a/gr-noaa/apps/Makefile.am b/gr-noaa/apps/Makefile.am index 5cefe9d21..8cc7cdbeb 100644 --- a/gr-noaa/apps/Makefile.am +++ b/gr-noaa/apps/Makefile.am @@ -25,13 +25,13 @@ if PYTHON dist_bin_SCRIPTS = \ demod_hrpt_file.py \ - usrp_rx_hrpt.py \ + usrp_rx_hrpt2.py \ usrp_rx_hrpt_nogui.py \ usrp_rx_lrit.py EXTRA_DIST = \ demod_hrpt_file.grc \ - usrp_rx_hrpt.grc \ + usrp_rx_hrpt2.grc \ usrp_rx_hrpt_nogui.grc \ usrp_rx_lrit.grc endif diff --git a/gr-noaa/apps/usrp_rx_hrpt.grc b/gr-noaa/apps/usrp_rx_hrpt.grc deleted file mode 100644 index c999a6bfd..000000000 --- a/gr-noaa/apps/usrp_rx_hrpt.grc +++ /dev/null @@ -1,1418 +0,0 @@ - - - Sun Sep 27 10:06:41 2009 - - options - - id - usrp_rx_hrpt - - - _enabled - True - - - title - USRP HRPT Receiver - - - author - - - - description - - - - window_size - 4096,4096 - - - generate_options - wx_gui - - - category - Custom - - - run - True - - - realtime_scheduling - 1 - - - _coordinate - (10, 10) - - - _rotation - 0 - - - - variable - - id - max_carrier_offset - - - _enabled - True - - - value - 2*math.pi*100e3/sample_rate - - - _coordinate - (575, 19) - - - _rotation - 0 - - - - variable - - id - sym_rate - - - _enabled - True - - - value - 600*1109 - - - _coordinate - (301, 19) - - - _rotation - 0 - - - - variable - - id - sps - - - _enabled - True - - - value - sample_rate/sym_rate - - - _coordinate - (397, 19) - - - _rotation - 0 - - - - variable - - id - hs - - - _enabled - True - - - value - int(sps/2.0) - - - _coordinate - (499, 19) - - - _rotation - 0 - - - - variable - - id - sample_rate - - - _enabled - True - - - value - 64e6/decim - - - _coordinate - (198, 17) - - - _rotation - 0 - - - - variable_slider - - id - gain - - - _enabled - True - - - label - RX Gain - - - value - saved_gain - - - min - 0 - - - max - 100 - - - num_steps - 100 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - 0, 1, 1, 1 - - - notebook - - - - _coordinate - (340, 106) - - - _rotation - 0 - - - - variable_text_box - - id - freq - - - _enabled - True - - - label - Frequency - - - value - saved_freq - - - converver - float_converter - - - formatter - None - - - grid_pos - 0, 0, 1, 1 - - - notebook - - - - _coordinate - (199, 106) - - - _rotation - 0 - - - - variable_slider - - id - pll_alpha - - - _enabled - True - - - label - PLL Alpha - - - value - saved_pll_alpha - - - min - 0.0 - - - max - 0.5 - - - num_steps - 100 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - 0, 2, 1, 1 - - - notebook - - - - _coordinate - (479, 106) - - - _rotation - 0 - - - - variable_slider - - id - sync_alpha - - - _enabled - True - - - label - SYNC Alpha - - - value - saved_sync_alpha - - - min - 0.0 - - - max - 0.5 - - - num_steps - 100 - - - style - wx.SL_HORIZONTAL - - - converver - float_converter - - - grid_pos - 0, 3, 1, 1 - - - notebook - - - - _coordinate - (618, 106) - - - _rotation - 0 - - - - variable_static_text - - id - side_text - - - _enabled - True - - - label - USRP Side - - - value - side - - - converver - str_converter - - - formatter - None - - - grid_pos - 1, 0, 1, 1 - - - notebook - - - - _coordinate - (828, 20) - - - _rotation - 0 - - - - variable_config - - id - side - - - _enabled - True - - - value - 'A' - - - type - string - - - config_file - config_filename - - - section - 'usrp' - - - option - 'side' - - - writeback - side - - - _coordinate - (194, 253) - - - _rotation - 0 - - - - variable_config - - id - decim - - - _enabled - True - - - value - 16 - - - type - real - - - config_file - config_filename - - - section - 'usrp' - - - option - 'decim' - - - writeback - decim - - - _coordinate - (351, 255) - - - _rotation - 0 - - - - variable_config - - id - saved_freq - - - _enabled - True - - - value - 1698e6 - - - type - real - - - config_file - config_filename - - - section - 'usrp' - - - option - 'freq' - - - writeback - freq - - - _coordinate - (507, 258) - - - _rotation - 0 - - - - variable_config - - id - saved_gain - - - _enabled - True - - - value - 35 - - - type - real - - - config_file - config_filename - - - section - 'usrp' - - - option - 'gain' - - - writeback - gain - - - _coordinate - (664, 259) - - - _rotation - 0 - - - - variable_config - - id - saved_pll_alpha - - - _enabled - True - - - value - 0.05 - - - type - real - - - config_file - config_filename - - - section - 'demod' - - - option - 'pll_alpha' - - - writeback - pll_alpha - - - _coordinate - (823, 258) - - - _rotation - 0 - - - - variable_config - - id - saved_sync_alpha - - - _enabled - True - - - value - 0.05 - - - type - real - - - config_file - config_filename - - - section - 'demod' - - - option - 'sync_alpha' - - - writeback - sync_alpha - - - _coordinate - (981, 258) - - - _rotation - 0 - - - - variable_config - - id - output_filename - - - _enabled - True - - - value - 'frames.dat' - - - type - string - - - config_file - config_filename - - - section - 'output' - - - option - 'filename' - - - writeback - output_filename - - - _coordinate - (1139, 259) - - - _rotation - 0 - - - - variable_static_text - - id - decim_text - - - _enabled - True - - - label - Decimation - - - value - decim - - - converver - float_converter - - - formatter - None - - - grid_pos - 1, 1, 1, 1 - - - notebook - - - - _coordinate - (973, 20) - - - _rotation - 0 - - - - variable - - id - max_sync_offset - - - _enabled - True - - - value - 0.01 - - - _coordinate - (705, 19) - - - _rotation - 0 - - - - variable - - id - config_filename - - - _enabled - True - - - value - 'usrp_rx_hrpt.cfg' - - - _coordinate - (12, 160) - - - _rotation - 0 - - - - import - - id - import_0 - - - _enabled - True - - - import - import math - - - _coordinate - (11, 102) - - - _rotation - 0 - - - - noaa_hrpt_pll_cf - - id - pll - - - _enabled - True - - - alpha - pll_alpha - - - beta - pll_alpha**2/4.0 - - - max_offset - max_carrier_offset - - - _coordinate - (664, 809) - - - _rotation - 0 - - - - noaa_hrpt_sync_fb - - id - sync - - - _enabled - True - - - alpha - sync_alpha - - - beta - sync_alpha**2/4.0 - - - sps - sps - - - max_offset - max_sync_offset - - - _coordinate - (865, 801) - - - _rotation - 0 - - - - gr_file_sink - - id - frame_sink - - - _enabled - True - - - file - output_filename - - - type - short - - - vlen - 1 - - - _coordinate - (1283, 937) - - - _rotation - 0 - - - - noaa_hrpt_deframer - - id - deframer - - - _enabled - True - - - _coordinate - (1091, 829) - - - _rotation - 0 - - - - noaa_hrpt_decoder - - id - decoder - - - _enabled - True - - - _coordinate - (1281, 829) - - - _rotation - 0 - - - - wxgui_scopesink2 - - id - pll_scope - - - _enabled - True - - - type - float - - - title - Demod Waveform - - - samp_rate - sample_rate - - - v_scale - 0.5 - - - t_scale - 20.0/sample_rate - - - ac_couple - False - - - xy_mode - False - - - num_inputs - 1 - - - grid_pos - 2,0,1,4 - - - notebook - - - - _coordinate - (631, 632) - - - _rotation - 180 - - - - gr_agc_xx - - id - agc - - - _enabled - True - - - type - complex - - - rate - 1e-6 - - - reference - 1.0 - - - gain - 1.0 - - - max_gain - 1.0 - - - _coordinate - (269, 801) - - - _rotation - 0 - - - - gr_fir_filter_xxx - - id - gr_fir_filter_xxx_0 - - - _enabled - True - - - type - ccc - - - decim - 1 - - - taps - mf_taps - - - _coordinate - (418, 817) - - - _rotation - 0 - - - - variable - - id - mf_taps - - - _enabled - True - - - value - [-0.5/hs,]*hs+[0.5/hs,]*hs - - - _coordinate - (830, 154) - - - _rotation - 0 - - - - gr_file_source - - id - file_source - - - _enabled - False - - - file - 'usrp.dat' - - - type - short - - - repeat - False - - - vlen - 1 - - - _coordinate - (215, 490) - - - _rotation - 0 - - - - gr_deinterleave - - id - gr_deinterleave_0 - - - _enabled - False - - - type - float - - - num_streams - 2 - - - vlen - 1 - - - _coordinate - (598, 485) - - - _rotation - 0 - - - - gr_float_to_complex - - id - gr_float_to_complex_0 - - - _enabled - False - - - vlen - 1 - - - _coordinate - (801, 485) - - - _rotation - 0 - - - - gr_short_to_float - - id - s2f - - - _enabled - False - - - _coordinate - (393, 502) - - - _rotation - 0 - - - - virtual_sink - - id - sample_stream - - - _enabled - False - - - stream_id - samples - - - _coordinate - (1027, 498) - - - _rotation - 0 - - - - usrp_simple_source_x - - id - usrp_source - - - _enabled - True - - - type - complex - - - format - - - - which - 0 - - - decimation - decim - - - frequency - freq - - - lo_offset - float('inf') - - - gain - gain - - - side - side - - - rx_ant - RXA - - - hb_filters - - - - _coordinate - (63, 785) - - - _rotation - 0 - - - - virtual_source - - id - virtual_source_0 - - - _enabled - False - - - stream_id - samples - - - _coordinate - (69, 671) - - - _rotation - 0 - - - - gr_fir_filter_xxx_0 - pll - 0 - 0 - - - agc - gr_fir_filter_xxx_0 - 0 - 0 - - - usrp_source - agc - 0 - 0 - - - deframer - decoder - 0 - 0 - - - pll - pll_scope - 0 - 0 - - - pll - sync - 0 - 0 - - - sync - deframer - 0 - 0 - - - deframer - frame_sink - 0 - 0 - - - virtual_source_0 - agc - 0 - 0 - - - file_source - s2f - 0 - 0 - - - s2f - gr_deinterleave_0 - 0 - 0 - - - gr_deinterleave_0 - gr_float_to_complex_0 - 0 - 0 - - - gr_deinterleave_0 - gr_float_to_complex_0 - 1 - 1 - - - gr_float_to_complex_0 - sample_stream - 0 - 0 - - diff --git a/gr-noaa/apps/usrp_rx_hrpt.py b/gr-noaa/apps/usrp_rx_hrpt.py deleted file mode 100755 index 9b19d5e4f..000000000 --- a/gr-noaa/apps/usrp_rx_hrpt.py +++ /dev/null @@ -1,401 +0,0 @@ -#!/usr/bin/env python -################################################## -# Gnuradio Python Flow Graph -# Title: USRP HRPT Receiver -# Generated: Sun Sep 27 10:06:41 2009 -################################################## - -from gnuradio import eng_notation -from gnuradio import gr -from gnuradio import noaa -from gnuradio.eng_option import eng_option -from gnuradio.gr import firdes -from gnuradio.wxgui import forms -from gnuradio.wxgui import scopesink2 -from grc_gnuradio import usrp as grc_usrp -from grc_gnuradio import wxgui as grc_wxgui -from optparse import OptionParser -import ConfigParser -import math -import wx - -class usrp_rx_hrpt(grc_wxgui.top_block_gui): - - 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 set_config_filename(self, config_filename): - self.config_filename = config_filename - 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)) - self._side_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)) - self._decim_config.write(open(self.config_filename, 'w')) - self._saved_freq_config = ConfigParser.ConfigParser() - self._saved_freq_config.read(self.config_filename) - if not self._saved_freq_config.has_section('usrp'): - self._saved_freq_config.add_section('usrp') - self._saved_freq_config.set('usrp', 'freq', str(self.freq)) - self._saved_freq_config.write(open(self.config_filename, 'w')) - self._saved_gain_config = ConfigParser.ConfigParser() - self._saved_gain_config.read(self.config_filename) - if not self._saved_gain_config.has_section('usrp'): - self._saved_gain_config.add_section('usrp') - self._saved_gain_config.set('usrp', 'gain', str(self.gain)) - self._saved_gain_config.write(open(self.config_filename, 'w')) - self._saved_pll_alpha_config = ConfigParser.ConfigParser() - self._saved_pll_alpha_config.read(self.config_filename) - if not self._saved_pll_alpha_config.has_section('demod'): - self._saved_pll_alpha_config.add_section('demod') - self._saved_pll_alpha_config.set('demod', 'pll_alpha', str(self.pll_alpha)) - self._saved_pll_alpha_config.write(open(self.config_filename, 'w')) - self._saved_sync_alpha_config = ConfigParser.ConfigParser() - self._saved_sync_alpha_config.read(self.config_filename) - if not self._saved_sync_alpha_config.has_section('demod'): - self._saved_sync_alpha_config.add_section('demod') - self._saved_sync_alpha_config.set('demod', 'sync_alpha', str(self.sync_alpha)) - self._saved_sync_alpha_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('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')) - - def set_decim(self, decim): - self.decim = decim - 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)) - self._decim_config.write(open(self.config_filename, 'w')) - self.set_decim_text(self.decim) - self.usrp_source.set_decim_rate(self.decim) - - def set_sym_rate(self, sym_rate): - self.sym_rate = sym_rate - self.set_sps(self.sample_rate/self.sym_rate) - - def set_sample_rate(self, sample_rate): - self.sample_rate = sample_rate - self.set_max_carrier_offset(2*math.pi*100e3/self.sample_rate) - self.set_sps(self.sample_rate/self.sym_rate) - self.pll_scope.set_sample_rate(self.sample_rate) - - def set_sps(self, sps): - self.sps = sps - self.set_hs(int(self.sps/2.0)) - - def set_side(self, side): - self.side = side - self.set_side_text(self.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)) - self._side_config.write(open(self.config_filename, 'w')) - - def set_saved_sync_alpha(self, saved_sync_alpha): - self.saved_sync_alpha = saved_sync_alpha - self.set_sync_alpha(self.saved_sync_alpha) - - def set_saved_pll_alpha(self, saved_pll_alpha): - self.saved_pll_alpha = saved_pll_alpha - self.set_pll_alpha(self.saved_pll_alpha) - - def set_saved_gain(self, saved_gain): - self.saved_gain = saved_gain - self.set_gain(self.saved_gain) - - def set_saved_freq(self, saved_freq): - self.saved_freq = saved_freq - self.set_freq(self.saved_freq) - - 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_slider.set_value(self.sync_alpha) - self._sync_alpha_text_box.set_value(self.sync_alpha) - self._saved_sync_alpha_config = ConfigParser.ConfigParser() - self._saved_sync_alpha_config.read(self.config_filename) - if not self._saved_sync_alpha_config.has_section('demod'): - self._saved_sync_alpha_config.add_section('demod') - self._saved_sync_alpha_config.set('demod', 'sync_alpha', str(self.sync_alpha)) - self._saved_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) - - def set_side_text(self, side_text): - self.side_text = side_text - self._side_text_static_text.set_value(self.side_text) - - def set_pll_alpha(self, pll_alpha): - self.pll_alpha = pll_alpha - self._pll_alpha_slider.set_value(self.pll_alpha) - self._pll_alpha_text_box.set_value(self.pll_alpha) - self._saved_pll_alpha_config = ConfigParser.ConfigParser() - self._saved_pll_alpha_config.read(self.config_filename) - if not self._saved_pll_alpha_config.has_section('demod'): - self._saved_pll_alpha_config.add_section('demod') - self._saved_pll_alpha_config.set('demod', 'pll_alpha', str(self.pll_alpha)) - self._saved_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) - - def set_output_filename(self, output_filename): - 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)) - 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_carrier_offset(self, max_carrier_offset): - self.max_carrier_offset = max_carrier_offset - self.pll.set_max_offset(self.max_carrier_offset) - - def set_gain(self, gain): - self.gain = gain - self._gain_slider.set_value(self.gain) - self._gain_text_box.set_value(self.gain) - self._saved_gain_config = ConfigParser.ConfigParser() - self._saved_gain_config.read(self.config_filename) - if not self._saved_gain_config.has_section('usrp'): - self._saved_gain_config.add_section('usrp') - self._saved_gain_config.set('usrp', 'gain', str(self.gain)) - self._saved_gain_config.write(open(self.config_filename, 'w')) - self.usrp_source.set_gain(self.gain) - - def set_freq(self, freq): - self.freq = freq - self._freq_text_box.set_value(self.freq) - self._saved_freq_config = ConfigParser.ConfigParser() - self._saved_freq_config.read(self.config_filename) - if not self._saved_freq_config.has_section('usrp'): - self._saved_freq_config.add_section('usrp') - self._saved_freq_config.set('usrp', 'freq', str(self.freq)) - self._saved_freq_config.write(open(self.config_filename, 'w')) - self.usrp_source.set_frequency(self.freq) - - def set_decim_text(self, decim_text): - self.decim_text = decim_text - self._decim_text_static_text.set_value(self.decim_text) - -if __name__ == '__main__': - parser = OptionParser(option_class=eng_option, usage="%prog: [options]") - (options, args) = parser.parse_args() - if gr.enable_realtime_scheduling() != gr.RT_OK: - print "Error: failed to enable realtime scheduling." - tb = usrp_rx_hrpt() - tb.Run(True) - diff --git a/gr-noaa/apps/usrp_rx_hrpt2.grc b/gr-noaa/apps/usrp_rx_hrpt2.grc new file mode 100644 index 000000000..d42a9eab6 --- /dev/null +++ b/gr-noaa/apps/usrp_rx_hrpt2.grc @@ -0,0 +1,1418 @@ + + + Sun Sep 27 13:32:47 2009 + + variable + + id + max_carrier_offset + + + _enabled + True + + + value + 2*math.pi*100e3/sample_rate + + + _coordinate + (575, 19) + + + _rotation + 0 + + + + variable + + id + sym_rate + + + _enabled + True + + + value + 600*1109 + + + _coordinate + (301, 19) + + + _rotation + 0 + + + + variable + + id + sps + + + _enabled + True + + + value + sample_rate/sym_rate + + + _coordinate + (397, 19) + + + _rotation + 0 + + + + variable + + id + hs + + + _enabled + True + + + value + int(sps/2.0) + + + _coordinate + (499, 19) + + + _rotation + 0 + + + + variable + + id + sample_rate + + + _enabled + True + + + value + 64e6/decim + + + _coordinate + (198, 17) + + + _rotation + 0 + + + + variable_slider + + id + gain + + + _enabled + True + + + label + RX Gain + + + value + saved_gain + + + min + 0 + + + max + 100 + + + num_steps + 100 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + 0, 1, 1, 1 + + + notebook + + + + _coordinate + (340, 106) + + + _rotation + 0 + + + + variable_text_box + + id + freq + + + _enabled + True + + + label + Frequency + + + value + saved_freq + + + converver + float_converter + + + formatter + None + + + grid_pos + 0, 0, 1, 1 + + + notebook + + + + _coordinate + (199, 106) + + + _rotation + 0 + + + + variable_slider + + id + pll_alpha + + + _enabled + True + + + label + PLL Alpha + + + value + saved_pll_alpha + + + min + 0.0 + + + max + 0.5 + + + num_steps + 100 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + 0, 2, 1, 1 + + + notebook + + + + _coordinate + (479, 106) + + + _rotation + 0 + + + + variable_slider + + id + sync_alpha + + + _enabled + True + + + label + SYNC Alpha + + + value + saved_sync_alpha + + + min + 0.0 + + + max + 0.5 + + + num_steps + 100 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + 0, 3, 1, 1 + + + notebook + + + + _coordinate + (618, 106) + + + _rotation + 0 + + + + variable_static_text + + id + side_text + + + _enabled + True + + + label + USRP Side + + + value + side + + + converver + str_converter + + + formatter + None + + + grid_pos + 1, 0, 1, 1 + + + notebook + + + + _coordinate + (828, 20) + + + _rotation + 0 + + + + variable_config + + id + side + + + _enabled + True + + + value + 'A' + + + type + string + + + config_file + config_filename + + + section + 'usrp' + + + option + 'side' + + + writeback + side + + + _coordinate + (194, 253) + + + _rotation + 0 + + + + variable_config + + id + decim + + + _enabled + True + + + value + 16 + + + type + real + + + config_file + config_filename + + + section + 'usrp' + + + option + 'decim' + + + writeback + decim + + + _coordinate + (351, 255) + + + _rotation + 0 + + + + variable_config + + id + saved_freq + + + _enabled + True + + + value + 1698e6 + + + type + real + + + config_file + config_filename + + + section + 'usrp' + + + option + 'freq' + + + writeback + freq + + + _coordinate + (507, 258) + + + _rotation + 0 + + + + variable_config + + id + saved_gain + + + _enabled + True + + + value + 35 + + + type + real + + + config_file + config_filename + + + section + 'usrp' + + + option + 'gain' + + + writeback + gain + + + _coordinate + (664, 259) + + + _rotation + 0 + + + + variable_config + + id + saved_pll_alpha + + + _enabled + True + + + value + 0.05 + + + type + real + + + config_file + config_filename + + + section + 'demod' + + + option + 'pll_alpha' + + + writeback + pll_alpha + + + _coordinate + (823, 258) + + + _rotation + 0 + + + + variable_config + + id + saved_sync_alpha + + + _enabled + True + + + value + 0.05 + + + type + real + + + config_file + config_filename + + + section + 'demod' + + + option + 'sync_alpha' + + + writeback + sync_alpha + + + _coordinate + (981, 258) + + + _rotation + 0 + + + + variable_config + + id + output_filename + + + _enabled + True + + + value + 'frames.dat' + + + type + string + + + config_file + config_filename + + + section + 'output' + + + option + 'filename' + + + writeback + output_filename + + + _coordinate + (1139, 259) + + + _rotation + 0 + + + + variable_static_text + + id + decim_text + + + _enabled + True + + + label + Decimation + + + value + decim + + + converver + float_converter + + + formatter + None + + + grid_pos + 1, 1, 1, 1 + + + notebook + + + + _coordinate + (973, 20) + + + _rotation + 0 + + + + variable + + id + max_sync_offset + + + _enabled + True + + + value + 0.01 + + + _coordinate + (705, 19) + + + _rotation + 0 + + + + variable + + id + config_filename + + + _enabled + True + + + value + 'usrp_rx_hrpt.cfg' + + + _coordinate + (12, 160) + + + _rotation + 0 + + + + import + + id + import_0 + + + _enabled + True + + + import + import math + + + _coordinate + (11, 102) + + + _rotation + 0 + + + + noaa_hrpt_pll_cf + + id + pll + + + _enabled + True + + + alpha + pll_alpha + + + beta + pll_alpha**2/4.0 + + + max_offset + max_carrier_offset + + + _coordinate + (664, 809) + + + _rotation + 0 + + + + noaa_hrpt_sync_fb + + id + sync + + + _enabled + True + + + alpha + sync_alpha + + + beta + sync_alpha**2/4.0 + + + sps + sps + + + max_offset + max_sync_offset + + + _coordinate + (865, 801) + + + _rotation + 0 + + + + gr_file_sink + + id + frame_sink + + + _enabled + True + + + file + output_filename + + + type + short + + + vlen + 1 + + + _coordinate + (1283, 937) + + + _rotation + 0 + + + + noaa_hrpt_deframer + + id + deframer + + + _enabled + True + + + _coordinate + (1091, 829) + + + _rotation + 0 + + + + noaa_hrpt_decoder + + id + decoder + + + _enabled + True + + + _coordinate + (1281, 829) + + + _rotation + 0 + + + + wxgui_scopesink2 + + id + pll_scope + + + _enabled + True + + + type + float + + + title + Demod Waveform + + + samp_rate + sample_rate + + + v_scale + 0.5 + + + t_scale + 20.0/sample_rate + + + ac_couple + False + + + xy_mode + False + + + num_inputs + 1 + + + grid_pos + 2,0,1,4 + + + notebook + + + + _coordinate + (631, 632) + + + _rotation + 180 + + + + gr_agc_xx + + id + agc + + + _enabled + True + + + type + complex + + + rate + 1e-6 + + + reference + 1.0 + + + gain + 1.0 + + + max_gain + 1.0 + + + _coordinate + (269, 801) + + + _rotation + 0 + + + + gr_fir_filter_xxx + + id + gr_fir_filter_xxx_0 + + + _enabled + True + + + type + ccc + + + decim + 1 + + + taps + mf_taps + + + _coordinate + (418, 817) + + + _rotation + 0 + + + + variable + + id + mf_taps + + + _enabled + True + + + value + [-0.5/hs,]*hs+[0.5/hs,]*hs + + + _coordinate + (830, 154) + + + _rotation + 0 + + + + gr_file_source + + id + file_source + + + _enabled + False + + + file + 'usrp.dat' + + + type + short + + + repeat + False + + + vlen + 1 + + + _coordinate + (215, 490) + + + _rotation + 0 + + + + gr_deinterleave + + id + gr_deinterleave_0 + + + _enabled + False + + + type + float + + + num_streams + 2 + + + vlen + 1 + + + _coordinate + (598, 485) + + + _rotation + 0 + + + + gr_float_to_complex + + id + gr_float_to_complex_0 + + + _enabled + False + + + vlen + 1 + + + _coordinate + (801, 485) + + + _rotation + 0 + + + + gr_short_to_float + + id + s2f + + + _enabled + False + + + _coordinate + (393, 502) + + + _rotation + 0 + + + + virtual_sink + + id + sample_stream + + + _enabled + False + + + stream_id + samples + + + _coordinate + (1027, 498) + + + _rotation + 0 + + + + usrp_simple_source_x + + id + usrp_source + + + _enabled + True + + + type + complex + + + format + + + + which + 0 + + + decimation + decim + + + frequency + freq + + + lo_offset + float('inf') + + + gain + gain + + + side + side + + + rx_ant + RXA + + + hb_filters + + + + _coordinate + (63, 785) + + + _rotation + 0 + + + + virtual_source + + id + virtual_source_0 + + + _enabled + False + + + stream_id + samples + + + _coordinate + (69, 671) + + + _rotation + 0 + + + + options + + id + usrp_rx_hrpt2 + + + _enabled + True + + + title + USRP HRPT Receiver + + + author + + + + description + + + + window_size + 4096,4096 + + + generate_options + wx_gui + + + category + Custom + + + run + True + + + realtime_scheduling + 1 + + + _coordinate + (10, 10) + + + _rotation + 0 + + + + gr_fir_filter_xxx_0 + pll + 0 + 0 + + + agc + gr_fir_filter_xxx_0 + 0 + 0 + + + usrp_source + agc + 0 + 0 + + + deframer + decoder + 0 + 0 + + + pll + pll_scope + 0 + 0 + + + pll + sync + 0 + 0 + + + sync + deframer + 0 + 0 + + + deframer + frame_sink + 0 + 0 + + + virtual_source_0 + agc + 0 + 0 + + + file_source + s2f + 0 + 0 + + + s2f + gr_deinterleave_0 + 0 + 0 + + + gr_deinterleave_0 + gr_float_to_complex_0 + 0 + 0 + + + gr_deinterleave_0 + gr_float_to_complex_0 + 1 + 1 + + + gr_float_to_complex_0 + sample_stream + 0 + 0 + + diff --git a/gr-noaa/apps/usrp_rx_hrpt2.py b/gr-noaa/apps/usrp_rx_hrpt2.py new file mode 100755 index 000000000..319335169 --- /dev/null +++ b/gr-noaa/apps/usrp_rx_hrpt2.py @@ -0,0 +1,401 @@ +#!/usr/bin/env python +################################################## +# Gnuradio Python Flow Graph +# Title: USRP HRPT Receiver +# Generated: Sun Sep 27 13:32:48 2009 +################################################## + +from gnuradio import eng_notation +from gnuradio import gr +from gnuradio import noaa +from gnuradio.eng_option import eng_option +from gnuradio.gr import firdes +from gnuradio.wxgui import forms +from gnuradio.wxgui import scopesink2 +from grc_gnuradio import usrp as grc_usrp +from grc_gnuradio import wxgui as grc_wxgui +from optparse import OptionParser +import ConfigParser +import math +import wx + +class usrp_rx_hrpt2(grc_wxgui.top_block_gui): + + 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 set_config_filename(self, config_filename): + self.config_filename = config_filename + 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)) + self._side_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)) + self._decim_config.write(open(self.config_filename, 'w')) + self._saved_freq_config = ConfigParser.ConfigParser() + self._saved_freq_config.read(self.config_filename) + if not self._saved_freq_config.has_section('usrp'): + self._saved_freq_config.add_section('usrp') + self._saved_freq_config.set('usrp', 'freq', str(self.freq)) + self._saved_freq_config.write(open(self.config_filename, 'w')) + self._saved_gain_config = ConfigParser.ConfigParser() + self._saved_gain_config.read(self.config_filename) + if not self._saved_gain_config.has_section('usrp'): + self._saved_gain_config.add_section('usrp') + self._saved_gain_config.set('usrp', 'gain', str(self.gain)) + self._saved_gain_config.write(open(self.config_filename, 'w')) + self._saved_pll_alpha_config = ConfigParser.ConfigParser() + self._saved_pll_alpha_config.read(self.config_filename) + if not self._saved_pll_alpha_config.has_section('demod'): + self._saved_pll_alpha_config.add_section('demod') + self._saved_pll_alpha_config.set('demod', 'pll_alpha', str(self.pll_alpha)) + self._saved_pll_alpha_config.write(open(self.config_filename, 'w')) + self._saved_sync_alpha_config = ConfigParser.ConfigParser() + self._saved_sync_alpha_config.read(self.config_filename) + if not self._saved_sync_alpha_config.has_section('demod'): + self._saved_sync_alpha_config.add_section('demod') + self._saved_sync_alpha_config.set('demod', 'sync_alpha', str(self.sync_alpha)) + self._saved_sync_alpha_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('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')) + + def set_decim(self, decim): + self.decim = decim + 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)) + self._decim_config.write(open(self.config_filename, 'w')) + self.set_decim_text(self.decim) + self.usrp_source.set_decim_rate(self.decim) + + def set_sym_rate(self, sym_rate): + self.sym_rate = sym_rate + self.set_sps(self.sample_rate/self.sym_rate) + + def set_sample_rate(self, sample_rate): + self.sample_rate = sample_rate + self.set_max_carrier_offset(2*math.pi*100e3/self.sample_rate) + self.set_sps(self.sample_rate/self.sym_rate) + self.pll_scope.set_sample_rate(self.sample_rate) + + def set_sps(self, sps): + self.sps = sps + self.set_hs(int(self.sps/2.0)) + + def set_side(self, side): + self.side = side + self.set_side_text(self.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)) + self._side_config.write(open(self.config_filename, 'w')) + + def set_saved_sync_alpha(self, saved_sync_alpha): + self.saved_sync_alpha = saved_sync_alpha + self.set_sync_alpha(self.saved_sync_alpha) + + def set_saved_pll_alpha(self, saved_pll_alpha): + self.saved_pll_alpha = saved_pll_alpha + self.set_pll_alpha(self.saved_pll_alpha) + + def set_saved_gain(self, saved_gain): + self.saved_gain = saved_gain + self.set_gain(self.saved_gain) + + def set_saved_freq(self, saved_freq): + self.saved_freq = saved_freq + self.set_freq(self.saved_freq) + + 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_slider.set_value(self.sync_alpha) + self._sync_alpha_text_box.set_value(self.sync_alpha) + self._saved_sync_alpha_config = ConfigParser.ConfigParser() + self._saved_sync_alpha_config.read(self.config_filename) + if not self._saved_sync_alpha_config.has_section('demod'): + self._saved_sync_alpha_config.add_section('demod') + self._saved_sync_alpha_config.set('demod', 'sync_alpha', str(self.sync_alpha)) + self._saved_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) + + def set_side_text(self, side_text): + self.side_text = side_text + self._side_text_static_text.set_value(self.side_text) + + def set_pll_alpha(self, pll_alpha): + self.pll_alpha = pll_alpha + self._pll_alpha_slider.set_value(self.pll_alpha) + self._pll_alpha_text_box.set_value(self.pll_alpha) + self._saved_pll_alpha_config = ConfigParser.ConfigParser() + self._saved_pll_alpha_config.read(self.config_filename) + if not self._saved_pll_alpha_config.has_section('demod'): + self._saved_pll_alpha_config.add_section('demod') + self._saved_pll_alpha_config.set('demod', 'pll_alpha', str(self.pll_alpha)) + self._saved_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) + + def set_output_filename(self, output_filename): + 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)) + 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_carrier_offset(self, max_carrier_offset): + self.max_carrier_offset = max_carrier_offset + self.pll.set_max_offset(self.max_carrier_offset) + + def set_gain(self, gain): + self.gain = gain + self._gain_slider.set_value(self.gain) + self._gain_text_box.set_value(self.gain) + self._saved_gain_config = ConfigParser.ConfigParser() + self._saved_gain_config.read(self.config_filename) + if not self._saved_gain_config.has_section('usrp'): + self._saved_gain_config.add_section('usrp') + self._saved_gain_config.set('usrp', 'gain', str(self.gain)) + self._saved_gain_config.write(open(self.config_filename, 'w')) + self.usrp_source.set_gain(self.gain) + + def set_freq(self, freq): + self.freq = freq + self._freq_text_box.set_value(self.freq) + self._saved_freq_config = ConfigParser.ConfigParser() + self._saved_freq_config.read(self.config_filename) + if not self._saved_freq_config.has_section('usrp'): + self._saved_freq_config.add_section('usrp') + self._saved_freq_config.set('usrp', 'freq', str(self.freq)) + self._saved_freq_config.write(open(self.config_filename, 'w')) + self.usrp_source.set_frequency(self.freq) + + def set_decim_text(self, decim_text): + self.decim_text = decim_text + self._decim_text_static_text.set_value(self.decim_text) + +if __name__ == '__main__': + parser = OptionParser(option_class=eng_option, usage="%prog: [options]") + (options, args) = parser.parse_args() + if gr.enable_realtime_scheduling() != gr.RT_OK: + print "Error: failed to enable realtime scheduling." + tb = usrp_rx_hrpt2() + tb.Run(True) + -- cgit From 745a36295016a08bcf8e81e0246b53cd1a487716 Mon Sep 17 00:00:00 2001 From: Johnathan Corgan Date: Sun, 27 Sep 2009 13:46:00 -0700 Subject: Restored original HRPT GUI script and documented various script choices. --- gr-noaa/README | 22 +- gr-noaa/apps/Makefile.am | 2 + gr-noaa/apps/usrp_rx_hrpt.grc | 1413 +++++++++++++++++++++++++++++++++++++++++ gr-noaa/apps/usrp_rx_hrpt.py | 440 +++++++++++++ 4 files changed, 1873 insertions(+), 4 deletions(-) create mode 100644 gr-noaa/apps/usrp_rx_hrpt.grc create mode 100755 gr-noaa/apps/usrp_rx_hrpt.py diff --git a/gr-noaa/README b/gr-noaa/README index d99c0d90a..fada3550a 100644 --- a/gr-noaa/README +++ b/gr-noaa/README @@ -5,10 +5,10 @@ As the scripts are generated using GRC, GRC must be installed at runtime in order for them to operate. -HRPT Operation --------------- +HRPT OPERATION usrp_rx_hrpt.py +--------------- This GUI script will receive HRPT RF, demodulate, synchronize, and deframe HRPT minor frames into a file. The file stores a series of 11090 word, @@ -24,12 +24,26 @@ The present HRPT demodulator is only tested at decimation 16. The only other valid decimation rates are 24 and 32, which may word but with more bit errors. No other decimation rates will work. +usrp_rx_hrpt2.py +---------------- + +This GUI script uses fewer graphical displays to reduce CPU consumption on +slower machines, but otherwise operates identically to userp_rx_hrpt.py. + +usrp_rx_hrpt_nogui.py +--------------------- + +This non-GUI script operates without a display and requires that all parameters +be set in the configuration file prior to running. It has no command-line +parameters, and works identically to the GUI scripts. demod_hrpt_file.py +------------------ -This command-line only script will operate on a file generated with +This non-GUI script will operate on a file generated with usrp_rx_cfile.py and output frames in the same format as above. It does -*not* use the configuration file above. +*not* use the configuration file above; instead you must pass parameters to +it on the command line. To exit the program, press Enter. Usage: demod_hrpt_file.py: [options] diff --git a/gr-noaa/apps/Makefile.am b/gr-noaa/apps/Makefile.am index 8cc7cdbeb..b9787a92c 100644 --- a/gr-noaa/apps/Makefile.am +++ b/gr-noaa/apps/Makefile.am @@ -25,12 +25,14 @@ if PYTHON dist_bin_SCRIPTS = \ demod_hrpt_file.py \ + usrp_rx_hrpt.py \ usrp_rx_hrpt2.py \ usrp_rx_hrpt_nogui.py \ usrp_rx_lrit.py EXTRA_DIST = \ demod_hrpt_file.grc \ + usrp_rx_hrpt.grc \ usrp_rx_hrpt2.grc \ usrp_rx_hrpt_nogui.grc \ usrp_rx_lrit.grc diff --git a/gr-noaa/apps/usrp_rx_hrpt.grc b/gr-noaa/apps/usrp_rx_hrpt.grc new file mode 100644 index 000000000..d06879716 --- /dev/null +++ b/gr-noaa/apps/usrp_rx_hrpt.grc @@ -0,0 +1,1413 @@ + + + Sun Sep 27 13:37:22 2009 + + options + + id + usrp_rx_hrpt + + + _enabled + True + + + title + USRP HRPT Receiver + + + author + + + + description + + + + window_size + 4096,4096 + + + generate_options + wx_gui + + + category + Custom + + + run + True + + + realtime_scheduling + + + + _coordinate + (10, 10) + + + _rotation + 0 + + + + variable + + id + max_carrier_offset + + + _enabled + True + + + value + 2*math.pi*100e3/sample_rate + + + _coordinate + (575, 19) + + + _rotation + 0 + + + + import + + id + import_0 + + + _enabled + True + + + import + import math + + + _coordinate + (11, 76) + + + _rotation + 0 + + + + variable + + id + config_filename + + + _enabled + True + + + value + 'usrp_rx_hrpt.cfg' + + + _coordinate + (12, 129) + + + _rotation + 0 + + + + variable + + id + sym_rate + + + _enabled + True + + + value + 600*1109 + + + _coordinate + (301, 19) + + + _rotation + 0 + + + + variable + + id + sps + + + _enabled + True + + + value + sample_rate/sym_rate + + + _coordinate + (397, 19) + + + _rotation + 0 + + + + variable + + id + hs + + + _enabled + True + + + value + int(sps/2.0) + + + _coordinate + (499, 19) + + + _rotation + 0 + + + + variable + + id + sample_rate + + + _enabled + True + + + value + 64e6/decim + + + _coordinate + (198, 17) + + + _rotation + 0 + + + + variable_slider + + id + gain + + + _enabled + True + + + label + RX Gain + + + value + saved_gain + + + min + 0 + + + max + 100 + + + num_steps + 100 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + 0, 1, 1, 1 + + + notebook + + + + _coordinate + (340, 106) + + + _rotation + 0 + + + + variable_text_box + + id + freq + + + _enabled + True + + + label + Frequency + + + value + saved_freq + + + converver + float_converter + + + formatter + None + + + grid_pos + 0, 0, 1, 1 + + + notebook + + + + _coordinate + (199, 106) + + + _rotation + 0 + + + + variable_slider + + id + pll_alpha + + + _enabled + True + + + label + PLL Alpha + + + value + saved_pll_alpha + + + min + 0.0 + + + max + 0.5 + + + num_steps + 100 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + 0, 2, 1, 1 + + + notebook + + + + _coordinate + (479, 106) + + + _rotation + 0 + + + + variable_slider + + id + sync_alpha + + + _enabled + True + + + label + SYNC Alpha + + + value + saved_sync_alpha + + + min + 0.0 + + + max + 0.5 + + + num_steps + 100 + + + style + wx.SL_HORIZONTAL + + + converver + float_converter + + + grid_pos + 0, 3, 1, 1 + + + notebook + + + + _coordinate + (618, 106) + + + _rotation + 0 + + + + variable_static_text + + id + side_text + + + _enabled + True + + + label + USRP Side + + + value + side + + + converver + str_converter + + + formatter + None + + + grid_pos + 1, 0, 1, 1 + + + notebook + + + + _coordinate + (828, 20) + + + _rotation + 0 + + + + variable_config + + id + side + + + _enabled + True + + + value + 'A' + + + type + string + + + config_file + config_filename + + + section + 'usrp' + + + option + 'side' + + + writeback + side + + + _coordinate + (194, 253) + + + _rotation + 0 + + + + variable_config + + id + decim + + + _enabled + True + + + value + 16 + + + type + real + + + config_file + config_filename + + + section + 'usrp' + + + option + 'decim' + + + writeback + decim + + + _coordinate + (351, 255) + + + _rotation + 0 + + + + variable_config + + id + saved_freq + + + _enabled + True + + + value + 1698e6 + + + type + real + + + config_file + config_filename + + + section + 'usrp' + + + option + 'freq' + + + writeback + freq + + + _coordinate + (507, 258) + + + _rotation + 0 + + + + variable_config + + id + saved_gain + + + _enabled + True + + + value + 35 + + + type + real + + + config_file + config_filename + + + section + 'usrp' + + + option + 'gain' + + + writeback + gain + + + _coordinate + (664, 259) + + + _rotation + 0 + + + + variable_config + + id + saved_pll_alpha + + + _enabled + True + + + value + 0.05 + + + type + real + + + config_file + config_filename + + + section + 'demod' + + + option + 'pll_alpha' + + + writeback + pll_alpha + + + _coordinate + (823, 258) + + + _rotation + 0 + + + + variable_config + + id + saved_sync_alpha + + + _enabled + True + + + value + 0.05 + + + type + real + + + config_file + config_filename + + + section + 'demod' + + + option + 'sync_alpha' + + + writeback + sync_alpha + + + _coordinate + (981, 258) + + + _rotation + 0 + + + + variable_config + + id + output_filename + + + _enabled + True + + + value + 'frames.dat' + + + type + string + + + config_file + config_filename + + + section + 'output' + + + option + 'filename' + + + writeback + output_filename + + + _coordinate + (1139, 259) + + + _rotation + 0 + + + + variable_static_text + + id + decim_text + + + _enabled + True + + + label + Decimation + + + value + decim + + + converver + float_converter + + + formatter + None + + + grid_pos + 1, 1, 1, 1 + + + notebook + + + + _coordinate + (973, 20) + + + _rotation + 0 + + + + variable + + id + max_sync_offset + + + _enabled + True + + + value + 0.01 + + + _coordinate + (705, 19) + + + _rotation + 0 + + + + notebook + + id + displays + + + _enabled + True + + + style + wx.NB_TOP + + + labels + ['RX','Demod'] + + + grid_pos + 2, 0, 1, 4 + + + notebook + + + + _coordinate + (15, 237) + + + _rotation + 0 + + + + noaa_hrpt_sync_fb + + id + sync + + + _enabled + True + + + alpha + sync_alpha + + + beta + sync_alpha**2/4.0 + + + sps + sps + + + max_offset + max_sync_offset + + + _coordinate + (840, 715) + + + _rotation + 0 + + + + noaa_hrpt_deframer + + id + deframer + + + _enabled + True + + + _coordinate + (1071, 743) + + + _rotation + 0 + + + + noaa_hrpt_decoder + + id + decoder + + + _enabled + True + + + _coordinate + (1274, 743) + + + _rotation + 0 + + + + gr_file_sink + + id + frame_sink + + + _enabled + True + + + file + output_filename + + + type + short + + + vlen + 1 + + + _coordinate + (1273, 851) + + + _rotation + 0 + + + + variable + + id + mf_taps + + + _enabled + True + + + value + [-0.5/hs,]*hs+[0.5/hs]*hs + + + _coordinate + (792, 158) + + + _rotation + 0 + + + + noaa_hrpt_pll_cf + + id + pll + + + _enabled + True + + + alpha + pll_alpha + + + beta + pll_alpha**2/4.0 + + + max_offset + max_carrier_offset + + + _coordinate + (632, 723) + + + _rotation + 0 + + + + gr_fir_filter_xxx + + id + gr_fir_filter_xxx_0 + + + _enabled + True + + + type + ccc + + + decim + 1 + + + taps + mf_taps + + + _coordinate + (400, 731) + + + _rotation + 0 + + + + usrp_simple_source_x + + id + usrp_source + + + _enabled + True + + + type + complex + + + format + + + + which + 0 + + + decimation + decim + + + frequency + freq + + + lo_offset + float('inf') + + + gain + gain + + + side + side + + + rx_ant + RXA + + + hb_filters + + + + _coordinate + (28, 699) + + + _rotation + 0 + + + + gr_agc_xx + + id + agc + + + _enabled + True + + + type + complex + + + rate + 1e-6 + + + reference + 1.0 + + + gain + 1.0 + + + max_gain + 1.0 + + + _coordinate + (240, 715) + + + _rotation + 0 + + + + wxgui_scopesink2 + + id + rx_scope + + + _enabled + True + + + type + complex + + + title + RX Waveform + + + samp_rate + sample_rate + + + v_scale + 0 + + + t_scale + 20.0/sample_rate + + + ac_couple + False + + + xy_mode + False + + + num_inputs + 1 + + + grid_pos + 1, 0, 1, 1 + + + notebook + displays, 0 + + + _coordinate + (406, 838) + + + _rotation + 0 + + + + wxgui_fftsink2 + + id + rx_fft + + + _enabled + True + + + type + complex + + + title + RX Spectrum + + + samp_rate + sample_rate + + + baseband_freq + freq + + + y_per_div + 5 + + + y_divs + 8 + + + ref_level + -5 + + + ref_scale + 2.0 + + + fft_size + 1024 + + + fft_rate + 15 + + + peak_hold + False + + + average + True + + + avg_alpha + 0.1 + + + grid_pos + 0, 0, 1, 1 + + + notebook + displays, 0 + + + _coordinate + (406, 466) + + + _rotation + 0 + + + + wxgui_scopesink2 + + id + pll_scope + + + _enabled + True + + + type + float + + + title + Demod Waveform + + + samp_rate + sample_rate + + + v_scale + 0.5 + + + t_scale + 20.0/sample_rate + + + ac_couple + False + + + xy_mode + False + + + num_inputs + 1 + + + grid_pos + 0, 0, 1, 1 + + + notebook + displays, 1 + + + _coordinate + (605, 552) + + + _rotation + 180 + + + + deframer + frame_sink + 0 + 0 + + + sync + deframer + 0 + 0 + + + pll + sync + 0 + 0 + + + pll + pll_scope + 0 + 0 + + + agc + rx_scope + 0 + 0 + + + agc + rx_fft + 0 + 0 + + + deframer + decoder + 0 + 0 + + + agc + gr_fir_filter_xxx_0 + 0 + 0 + + + gr_fir_filter_xxx_0 + pll + 0 + 0 + + + usrp_source + agc + 0 + 0 + + diff --git a/gr-noaa/apps/usrp_rx_hrpt.py b/gr-noaa/apps/usrp_rx_hrpt.py new file mode 100755 index 000000000..ae70f25c8 --- /dev/null +++ b/gr-noaa/apps/usrp_rx_hrpt.py @@ -0,0 +1,440 @@ +#!/usr/bin/env python +################################################## +# Gnuradio Python Flow Graph +# Title: USRP HRPT Receiver +# Generated: Sun Sep 27 13:37:23 2009 +################################################## + +from gnuradio import eng_notation +from gnuradio import gr +from gnuradio import noaa +from gnuradio.eng_option import eng_option +from gnuradio.gr import firdes +from gnuradio.wxgui import fftsink2 +from gnuradio.wxgui import forms +from gnuradio.wxgui import scopesink2 +from grc_gnuradio import usrp as grc_usrp +from grc_gnuradio import wxgui as grc_wxgui +from optparse import OptionParser +import ConfigParser +import math +import wx + +class usrp_rx_hrpt(grc_wxgui.top_block_gui): + + 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 set_config_filename(self, config_filename): + self.config_filename = config_filename + 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)) + self._side_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)) + self._decim_config.write(open(self.config_filename, 'w')) + self._saved_freq_config = ConfigParser.ConfigParser() + self._saved_freq_config.read(self.config_filename) + if not self._saved_freq_config.has_section('usrp'): + self._saved_freq_config.add_section('usrp') + self._saved_freq_config.set('usrp', 'freq', str(self.freq)) + self._saved_freq_config.write(open(self.config_filename, 'w')) + self._saved_gain_config = ConfigParser.ConfigParser() + self._saved_gain_config.read(self.config_filename) + if not self._saved_gain_config.has_section('usrp'): + self._saved_gain_config.add_section('usrp') + self._saved_gain_config.set('usrp', 'gain', str(self.gain)) + self._saved_gain_config.write(open(self.config_filename, 'w')) + self._saved_pll_alpha_config = ConfigParser.ConfigParser() + self._saved_pll_alpha_config.read(self.config_filename) + if not self._saved_pll_alpha_config.has_section('demod'): + self._saved_pll_alpha_config.add_section('demod') + self._saved_pll_alpha_config.set('demod', 'pll_alpha', str(self.pll_alpha)) + self._saved_pll_alpha_config.write(open(self.config_filename, 'w')) + self._saved_sync_alpha_config = ConfigParser.ConfigParser() + self._saved_sync_alpha_config.read(self.config_filename) + if not self._saved_sync_alpha_config.has_section('demod'): + self._saved_sync_alpha_config.add_section('demod') + self._saved_sync_alpha_config.set('demod', 'sync_alpha', str(self.sync_alpha)) + self._saved_sync_alpha_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('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')) + + def set_decim(self, decim): + self.decim = decim + 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)) + self._decim_config.write(open(self.config_filename, 'w')) + self.set_decim_text(self.decim) + self.usrp_source.set_decim_rate(self.decim) + + def set_sym_rate(self, sym_rate): + self.sym_rate = sym_rate + self.set_sps(self.sample_rate/self.sym_rate) + + def set_sample_rate(self, sample_rate): + self.sample_rate = sample_rate + self.set_max_carrier_offset(2*math.pi*100e3/self.sample_rate) + self.set_sps(self.sample_rate/self.sym_rate) + self.rx_scope.set_sample_rate(self.sample_rate) + self.rx_fft.set_sample_rate(self.sample_rate) + self.pll_scope.set_sample_rate(self.sample_rate) + + def set_sps(self, sps): + self.sps = sps + self.set_hs(int(self.sps/2.0)) + + def set_side(self, side): + self.side = side + self.set_side_text(self.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)) + self._side_config.write(open(self.config_filename, 'w')) + + def set_saved_sync_alpha(self, saved_sync_alpha): + self.saved_sync_alpha = saved_sync_alpha + self.set_sync_alpha(self.saved_sync_alpha) + + def set_saved_pll_alpha(self, saved_pll_alpha): + self.saved_pll_alpha = saved_pll_alpha + self.set_pll_alpha(self.saved_pll_alpha) + + def set_saved_gain(self, saved_gain): + self.saved_gain = saved_gain + self.set_gain(self.saved_gain) + + def set_saved_freq(self, saved_freq): + self.saved_freq = saved_freq + self.set_freq(self.saved_freq) + + 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_slider.set_value(self.sync_alpha) + self._sync_alpha_text_box.set_value(self.sync_alpha) + self._saved_sync_alpha_config = ConfigParser.ConfigParser() + self._saved_sync_alpha_config.read(self.config_filename) + if not self._saved_sync_alpha_config.has_section('demod'): + self._saved_sync_alpha_config.add_section('demod') + self._saved_sync_alpha_config.set('demod', 'sync_alpha', str(self.sync_alpha)) + self._saved_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) + + def set_side_text(self, side_text): + self.side_text = side_text + self._side_text_static_text.set_value(self.side_text) + + def set_pll_alpha(self, pll_alpha): + self.pll_alpha = pll_alpha + self._pll_alpha_slider.set_value(self.pll_alpha) + self._pll_alpha_text_box.set_value(self.pll_alpha) + self._saved_pll_alpha_config = ConfigParser.ConfigParser() + self._saved_pll_alpha_config.read(self.config_filename) + if not self._saved_pll_alpha_config.has_section('demod'): + self._saved_pll_alpha_config.add_section('demod') + self._saved_pll_alpha_config.set('demod', 'pll_alpha', str(self.pll_alpha)) + self._saved_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) + + def set_output_filename(self, output_filename): + 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)) + 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_carrier_offset(self, max_carrier_offset): + self.max_carrier_offset = max_carrier_offset + self.pll.set_max_offset(self.max_carrier_offset) + + def set_gain(self, gain): + self.gain = gain + self._gain_slider.set_value(self.gain) + self._gain_text_box.set_value(self.gain) + self._saved_gain_config = ConfigParser.ConfigParser() + self._saved_gain_config.read(self.config_filename) + if not self._saved_gain_config.has_section('usrp'): + self._saved_gain_config.add_section('usrp') + self._saved_gain_config.set('usrp', 'gain', str(self.gain)) + self._saved_gain_config.write(open(self.config_filename, 'w')) + self.usrp_source.set_gain(self.gain) + + def set_freq(self, freq): + self.freq = freq + self._freq_text_box.set_value(self.freq) + self._saved_freq_config = ConfigParser.ConfigParser() + self._saved_freq_config.read(self.config_filename) + if not self._saved_freq_config.has_section('usrp'): + self._saved_freq_config.add_section('usrp') + self._saved_freq_config.set('usrp', 'freq', str(self.freq)) + self._saved_freq_config.write(open(self.config_filename, 'w')) + self.usrp_source.set_frequency(self.freq) + self.rx_fft.set_baseband_freq(self.freq) + + def set_decim_text(self, decim_text): + self.decim_text = decim_text + self._decim_text_static_text.set_value(self.decim_text) + +if __name__ == '__main__': + parser = OptionParser(option_class=eng_option, usage="%prog: [options]") + (options, args) = parser.parse_args() + tb = usrp_rx_hrpt() + tb.Run(True) + -- cgit