From 5c071b07710d2c4e127d321faba59b2a7b1d7c8d Mon Sep 17 00:00:00 2001 From: jcorgan Date: Sun, 14 Sep 2008 18:37:08 +0000 Subject: Adds frequency accessor for Costas loop, BERT receiver displays frequency and timing offset git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@9576 221aa14e-8319-0410-a670-987f0aec2ac5 --- .../python/digital-bert/benchmark_rx.py | 22 +++++++++------ .../python/digital-bert/receive_path.py | 32 ++++++++++++---------- 2 files changed, 31 insertions(+), 23 deletions(-) (limited to 'gnuradio-examples/python/digital-bert') diff --git a/gnuradio-examples/python/digital-bert/benchmark_rx.py b/gnuradio-examples/python/digital-bert/benchmark_rx.py index 96bf7fa12..1e00dbd76 100755 --- a/gnuradio-examples/python/digital-bert/benchmark_rx.py +++ b/gnuradio-examples/python/digital-bert/benchmark_rx.py @@ -39,8 +39,8 @@ class status_thread(_threading.Thread): def run(self): while not self.done: - print "Magnitude: %5.3f Variance: %5.3f Estimated SNR: %4.1f dB BER: %g" % ( - tb.mag(), tb.var(), tb.snr(), tb.ber()) + print "Freq. Offset: %5.0f Hz Timing Offset: %5.1f ppm Estimated SNR: %4.1f dB BER: %g" % ( + tb.frequency_offset(), tb.timing_offset()*1e6, tb.snr(), tb.ber()) try: time.sleep(1.0) except KeyboardInterrupt: @@ -104,6 +104,12 @@ class rx_bpsk_block(gr.top_block): def ber(self): return self._receiver.ber() + + def frequency_offset(self): + return self._receiver.frequency_offset() + + def timing_offset(self): + return self._receiver.timing_offset() def get_options(): parser = OptionParser(option_class=eng_option) @@ -122,17 +128,17 @@ def get_options(): help="Select USRP decimation rate (default=%default)") parser.add_option("", "--excess-bw", type="eng_float", default=0.35, help="Select RRC excess bandwidth (default=%default)") - parser.add_option("", "--costas-alpha", type="eng_float", default=0.2, + parser.add_option("", "--costas-alpha", type="eng_float", default=0.05, help="set Costas loop 1st order gain, (default=%default)") - parser.add_option("", "--costas-beta", type="eng_float", default=0.01, + parser.add_option("", "--costas-beta", type="eng_float", default=0.00025, help="set Costas loop 2nd order gain, (default=%default)") - parser.add_option("", "--costas-max", type="eng_float", default=0.005, + parser.add_option("", "--costas-max", type="eng_float", default=0.05, help="set Costas loop max freq (rad/sample) (default=%default)") - parser.add_option("", "--mm-gain-mu", type="eng_float", default=0.2, + parser.add_option("", "--mm-gain-mu", type="eng_float", default=0.001, help="set M&M loop 1st order gain, (default=%default)") - parser.add_option("", "--mm-gain-omega", type="eng_float", default=0.01, + parser.add_option("", "--mm-gain-omega", type="eng_float", default=0.000001, help="set M&M loop 2nd order gain, (default=%default)") - parser.add_option("", "--mm-omega-limit", type="eng_float", default=0.005, + parser.add_option("", "--mm-omega-limit", type="eng_float", default=0.0001, help="set M&M max timing error, (default=%default)") diff --git a/gnuradio-examples/python/digital-bert/receive_path.py b/gnuradio-examples/python/digital-bert/receive_path.py index 84ff32916..e273923a4 100644 --- a/gnuradio-examples/python/digital-bert/receive_path.py +++ b/gnuradio-examples/python/digital-bert/receive_path.py @@ -41,21 +41,22 @@ class receive_path(gr.hier_block2): gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(0, 0, 0)) # Output signature - sps = int(if_rate/symbol_rate) - print "IF sample rate:", n2s(if_rate) + self._if_rate = if_rate + self._sps = int(self._if_rate/symbol_rate) + print "IF sample rate:", n2s(self._if_rate) print "Symbol rate:", n2s(symbol_rate) - print "Samples/symbol:", sps + print "Samples/symbol:", self._sps print "RRC bandwidth:", excess_bw # Create AGC to scale input to unity self._agc = gr.agc_cc(1e-5, 1.0, 1.0, 1.0) # Create RRC with specified excess bandwidth - taps = gr.firdes.root_raised_cosine(1.0, # Gain - sps, # Sampling rate - 1.0, # Symbol rate - excess_bw, # Roll-off factor - 11*sps) # Number of taps + taps = gr.firdes.root_raised_cosine(1.0, # Gain + self._sps, # Sampling rate + 1.0, # Symbol rate + excess_bw, # Roll-off factor + 11*self._sps) # Number of taps self._rrc = gr.fir_filter_ccf(1, taps) @@ -73,7 +74,7 @@ class receive_path(gr.hier_block2): # Create a M&M bit synchronization retiming block mm_mu = 0.5 - mm_omega = sps + mm_omega = self._sps print "MM gain mu:", mm_gain_mu print "MM gain omega:", mm_gain_omega @@ -103,14 +104,15 @@ class receive_path(gr.hier_block2): self.connect(self, self._agc, self._rrc, self._costas, self._mm, self._c2r, self._slicer, self._descrambler, self._ber) + def frequency_offset(self): + return self._costas.freq()*self._if_rate/(2*math.pi) + + def timing_offset(self): + return self._mm.omega()/self._sps-1.0 + def snr(self): return self._snr_probe.snr() - def signal_mean(self): - return self._snr_probe.signal_mean() - - def noise_variance(self): - return self._snr_probe.noise_variance() - def ber(self): return (1.0-self._ber.density())/3.0 + -- cgit