summaryrefslogtreecommitdiff
path: root/gr-noaa/apps/demod_hrpt_file.py
diff options
context:
space:
mode:
authorJohnathan Corgan2009-10-31 09:28:44 -0700
committerJohnathan Corgan2009-11-01 19:45:34 -0800
commitae5b4ed2ce8c4a0903eea1b264da5393a179c9fe (patch)
tree73e40e054dbc3fd063b2ce2edcb01e937c333717 /gr-noaa/apps/demod_hrpt_file.py
parentedf412a8ef283d08135a1c5f9c1b4f51b771ec37 (diff)
downloadgnuradio-ae5b4ed2ce8c4a0903eea1b264da5393a179c9fe.tar.gz
gnuradio-ae5b4ed2ce8c4a0903eea1b264da5393a179c9fe.tar.bz2
gnuradio-ae5b4ed2ce8c4a0903eea1b264da5393a179c9fe.zip
gr-noaa: Switched to 'double rate BPSK' HRPT synchronization
Added hrpt_bit_sync block Using MM clock sync at double data rate Created file_rx_hrpt GRC app Updated demod_rx_hrpt GRC app Updated usrp_rx_hrpt GRC Updated usrp_rx_hrpt_nogui app Deleted usrp_rx_hrpt2 GRC app Deleted hrpt_sync_fb block
Diffstat (limited to 'gr-noaa/apps/demod_hrpt_file.py')
-rwxr-xr-xgr-noaa/apps/demod_hrpt_file.py110
1 files changed, 56 insertions, 54 deletions
diff --git a/gr-noaa/apps/demod_hrpt_file.py b/gr-noaa/apps/demod_hrpt_file.py
index d55351868..846723185 100755
--- a/gr-noaa/apps/demod_hrpt_file.py
+++ b/gr-noaa/apps/demod_hrpt_file.py
@@ -1,8 +1,8 @@
#!/usr/bin/env python
##################################################
# Gnuradio Python Flow Graph
-# Title: USRP HRPT Receiver
-# Generated: Sun Oct 4 08:40:03 2009
+# Title: Demod Hrpt File
+# Generated: Sun Nov 1 18:39:07 2009
##################################################
from gnuradio import eng_notation
@@ -11,21 +11,22 @@ from gnuradio import noaa
from gnuradio.eng_option import eng_option
from gnuradio.gr import firdes
from optparse import OptionParser
-import math
+import math, os
class demod_hrpt_file(gr.top_block):
- 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")
+ def __init__(self, decim=16, pll_alpha=0.05, clock_alpha=0.05, sync_alpha=0.05, input_filename="usrp.dat", output_filename="frames.dat"):
+ gr.top_block.__init__(self, "Demod Hrpt File")
##################################################
# Parameters
##################################################
- self.filename = filename
- self.output = output
self.decim = decim
self.pll_alpha = pll_alpha
+ self.clock_alpha = clock_alpha
self.sync_alpha = sync_alpha
+ self.input_filename = input_filename
+ self.output_filename = output_filename
##################################################
# Variables
@@ -33,44 +34,38 @@ 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_clock_offset = max_clock_offset = 0.1
self.max_carrier_offset = max_carrier_offset = 2*math.pi*100e3/sample_rate
+ self.hs = hs = int(sps/2.0)
##################################################
# Blocks
##################################################
- self.decoder = noaa.hrpt_decoder()
- self.deframer = noaa.hrpt_deframer()
- self.deinterleave = gr.deinterleave(gr.sizeof_float*1)
- self.f2c = gr.float_to_complex(1)
- self.file_sink = gr.file_sink(gr.sizeof_short*1, output)
- self.file_source = gr.file_source(gr.sizeof_short*1, filename, False)
- self.gr_fir_filter_xxx_0 = gr.fir_filter_ccc(1, (mf_taps))
+ self.agc = gr.agc_cc(1e-5, 1.0, 1.0/32768.0, 1.0)
+ self.cs2cf = gr.interleaved_short_to_complex()
+ self.file_source = gr.file_source(gr.sizeof_short*1, input_filename, False)
+ self.gr_binary_slicer_fb_0 = gr.binary_slicer_fb()
+ self.gr_clock_recovery_mm_xx_0 = gr.clock_recovery_mm_ff(sps/2.0, clock_alpha**2/4.0, 0.5, clock_alpha, max_clock_offset)
+ self.gr_file_sink_0 = gr.file_sink(gr.sizeof_short*1, output_filename)
+ self.gr_moving_average_xx_0 = gr.moving_average_ff(hs, 1.0/hs, 4000)
+ self.noaa_hrpt_bit_sync_0 = noaa.hrpt_bit_sync()
+ self.noaa_hrpt_decoder_0 = noaa.hrpt_decoder()
+ self.noaa_hrpt_deframer_0 = noaa.hrpt_deframer()
self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2/4.0, max_carrier_offset)
- self.s2f = gr.short_to_float()
- self.sync = noaa.hrpt_sync_fb(sync_alpha, sync_alpha**2/4.0, sps, max_sync_offset)
##################################################
# Connections
##################################################
- self.connect((self.deframer, 0), (self.file_sink, 0))
- self.connect((self.sync, 0), (self.deframer, 0))
- self.connect((self.pll, 0), (self.sync, 0))
- self.connect((self.deinterleave, 1), (self.f2c, 1))
- self.connect((self.deinterleave, 0), (self.f2c, 0))
- self.connect((self.deframer, 0), (self.decoder, 0))
- self.connect((self.gr_fir_filter_xxx_0, 0), (self.pll, 0))
- self.connect((self.f2c, 0), (self.gr_fir_filter_xxx_0, 0))
- self.connect((self.s2f, 0), (self.deinterleave, 0))
- self.connect((self.file_source, 0), (self.s2f, 0))
-
- def set_filename(self, filename):
- self.filename = filename
-
- def set_output(self, output):
- self.output = output
+ self.connect((self.file_source, 0), (self.cs2cf, 0))
+ self.connect((self.gr_clock_recovery_mm_xx_0, 0), (self.gr_binary_slicer_fb_0, 0))
+ self.connect((self.gr_moving_average_xx_0, 0), (self.gr_clock_recovery_mm_xx_0, 0))
+ self.connect((self.pll, 0), (self.gr_moving_average_xx_0, 0))
+ self.connect((self.gr_binary_slicer_fb_0, 0), (self.noaa_hrpt_bit_sync_0, 0))
+ self.connect((self.cs2cf, 0), (self.agc, 0))
+ self.connect((self.agc, 0), (self.pll, 0))
+ self.connect((self.noaa_hrpt_deframer_0, 0), (self.gr_file_sink_0, 0))
+ self.connect((self.noaa_hrpt_deframer_0, 0), (self.noaa_hrpt_decoder_0, 0))
+ self.connect((self.noaa_hrpt_bit_sync_0, 0), (self.noaa_hrpt_deframer_0, 0))
def set_decim(self, decim):
self.decim = decim
@@ -81,10 +76,19 @@ class demod_hrpt_file(gr.top_block):
self.pll.set_alpha(self.pll_alpha)
self.pll.set_beta(self.pll_alpha**2/4.0)
+ def set_clock_alpha(self, clock_alpha):
+ self.clock_alpha = clock_alpha
+ self.gr_clock_recovery_mm_xx_0.set_gain_omega(self.clock_alpha**2/4.0)
+ self.gr_clock_recovery_mm_xx_0.set_gain_mu(self.clock_alpha)
+
def set_sync_alpha(self, sync_alpha):
self.sync_alpha = sync_alpha
- self.sync.set_alpha(self.sync_alpha)
- self.sync.set_beta(self.sync_alpha**2/4.0)
+
+ def set_input_filename(self, input_filename):
+ self.input_filename = input_filename
+
+ def set_output_filename(self, output_filename):
+ self.output_filename = output_filename
def set_sym_rate(self, sym_rate):
self.sym_rate = sym_rate
@@ -98,36 +102,34 @@ class demod_hrpt_file(gr.top_block):
def set_sps(self, sps):
self.sps = sps
self.set_hs(int(self.sps/2.0))
+ self.gr_clock_recovery_mm_xx_0.set_omega(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)
+ def set_max_clock_offset(self, max_clock_offset):
+ self.max_clock_offset = max_clock_offset
def set_max_carrier_offset(self, max_carrier_offset):
self.max_carrier_offset = max_carrier_offset
self.pll.set_max_offset(self.max_carrier_offset)
+ def set_hs(self, hs):
+ self.hs = hs
+ self.gr_moving_average_xx_0.set_length_and_scale(self.hs, 1.0/self.hs)
+
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]")
+ help="Set decim [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("-a", "--clock-alpha", dest="clock_alpha", type="eng_float", default=eng_notation.num_to_str(0.05),
+ help="Set clock_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", "--input-filename", dest="input_filename", type="string", default="usrp.dat",
+ help="Set usrp.dat [default=%default]")
+ parser.add_option("-o", "--output-filename", dest="output_filename", type="string", default="frames.dat",
+ help="Set frames.dat [default=%default]")
(options, args) = parser.parse_args()
- tb = demod_hrpt_file(filename=options.filename, output=options.output, decim=options.decim, pll_alpha=options.pll_alpha, sync_alpha=options.sync_alpha)
+ tb = demod_hrpt_file(decim=options.decim, pll_alpha=options.pll_alpha, clock_alpha=options.clock_alpha, sync_alpha=options.sync_alpha, input_filename=options.input_filename, output_filename=options.output_filename)
tb.run()