diff options
Diffstat (limited to 'gr-digital/python')
-rw-r--r-- | gr-digital/python/Makefile.am | 1 | ||||
-rw-r--r-- | gr-digital/python/bpsk.py | 81 | ||||
-rw-r--r-- | gr-digital/python/generic_mod_demod.py | 146 | ||||
-rw-r--r-- | gr-digital/python/modulation_utils2.py | 1 | ||||
-rwxr-xr-x | gr-digital/python/qa_constellation_receiver.py | 2 | ||||
-rwxr-xr-x | gr-digital/python/qa_costas_loop_cc.py | 17 | ||||
-rw-r--r-- | gr-digital/python/qa_fll_band_edge.py | 83 | ||||
-rw-r--r-- | gr-digital/python/qam.py | 4 | ||||
-rw-r--r-- | gr-digital/python/qpsk.py | 17 |
9 files changed, 244 insertions, 108 deletions
diff --git a/gr-digital/python/Makefile.am b/gr-digital/python/Makefile.am index 87752e9ae..6c61002f1 100644 --- a/gr-digital/python/Makefile.am +++ b/gr-digital/python/Makefile.am @@ -41,6 +41,7 @@ noinst_PYTHON = \ qa_correlate_access_code.py \ qa_costas_loop_cc.py \ qa_crc32.py \ + qa_fll_band_edge.py \ qa_lms_equalizer.py \ qa_mpsk_receiver.py diff --git a/gr-digital/python/bpsk.py b/gr-digital/python/bpsk.py index 51de3ce08..58a8289a5 100644 --- a/gr-digital/python/bpsk.py +++ b/gr-digital/python/bpsk.py @@ -34,7 +34,7 @@ import modulation_utils2 # Default number of points in constellation. _def_constellation_points = 2 # Whether differential coding is used. -_def_differential = True +_def_differential = False # ///////////////////////////////////////////////////////////////////////////// # BPSK constellation @@ -52,7 +52,7 @@ def bpsk_constellation(m=_def_constellation_points): class bpsk_mod(generic_mod): def __init__(self, constellation_points=_def_constellation_points, - *args, **kwargs): + differential=False, *args, **kwargs): """ Hierarchical block for RRC-filtered BPSK modulation. @@ -67,8 +67,9 @@ class bpsk_mod(generic_mod): constellation = digital_swig.constellation_bpsk() if constellation_points != 2: raise ValueError('Number of constellation points must be 2 for BPSK.') - super(bpsk_mod, self).__init__(constellation, *args, **kwargs) - + super(bpsk_mod, self).__init__(constellation=constellation, + differential=differential, *args, **kwargs) + # ///////////////////////////////////////////////////////////////////////////// # BPSK demodulator # @@ -77,7 +78,7 @@ class bpsk_mod(generic_mod): class bpsk_demod(generic_demod): def __init__(self, constellation_points=_def_constellation_points, - *args, **kwargs): + differential=False, *args, **kwargs): """ Hierarchical block for RRC-filtered BPSK modulation. @@ -92,7 +93,72 @@ class bpsk_demod(generic_demod): constellation = digital_swig.constellation_bpsk() if constellation_points != 2: raise ValueError('Number of constellation points must be 2 for BPSK.') - super(bpsk_demod, self).__init__(constellation, *args, **kwargs) + super(bpsk_demod, self).__init__(constellation=constellation, + differential=differential, *args, **kwargs) + + + +# ///////////////////////////////////////////////////////////////////////////// +# DBPSK constellation +# ///////////////////////////////////////////////////////////////////////////// + +def dbpsk_constellation(m=_def_constellation_points): + if m != _def_constellation_points: + raise ValueError("DBPSK can only have 2 constellation points.") + return digital_swig.constellation_dbpsk() + +# ///////////////////////////////////////////////////////////////////////////// +# DBPSK modulator +# ///////////////////////////////////////////////////////////////////////////// + +class dbpsk_mod(generic_mod): + + def __init__(self, constellation_points=_def_constellation_points, + differential=True, *args, **kwargs): + + """ + Hierarchical block for RRC-filtered DBPSK modulation. + + The input is a byte stream (unsigned char) and the + output is the complex modulated signal at baseband. + + See generic_mod block for list of parameters. + """ + + constellation_points = _def_constellation_points + constellation = digital_swig.constellation_bpsk() + if constellation_points != 2: + raise ValueError('Number of constellation points must be 2 for DBPSK.') + super(dbpsk_mod, self).__init__(constellation=constellation, + differential=True, + *args, **kwargs) + +# ///////////////////////////////////////////////////////////////////////////// +# DBPSK demodulator +# +# ///////////////////////////////////////////////////////////////////////////// + +class dbpsk_demod(generic_demod): + + def __init__(self, constellation_points=_def_constellation_points, + differential=True, *args, **kwargs): + + """ + Hierarchical block for RRC-filtered DBPSK modulation. + + The input is a byte stream (unsigned char) and the + output is the complex modulated signal at baseband. + + See generic_demod block for list of parameters. + """ + + constellation_points = _def_constellation_points + constellation = digital_swig.constellation_bpsk() + if constellation_points != 2: + raise ValueError('Number of constellation points must be 2 for DBPSK.') + super(dbpsk_demod, self).__init__(constellation=constellation, + differential=True, + *args, **kwargs) # # Add these to the mod/demod registry @@ -100,3 +166,6 @@ class bpsk_demod(generic_demod): modulation_utils2.add_type_1_mod('bpsk', bpsk_mod) modulation_utils2.add_type_1_demod('bpsk', bpsk_demod) modulation_utils2.add_type_1_constellation('bpsk', bpsk_constellation) +modulation_utils2.add_type_1_mod('dbpsk', dbpsk_mod) +modulation_utils2.add_type_1_demod('dbpsk', dbpsk_demod) +modulation_utils2.add_type_1_constellation('dbpsk', dbpsk_constellation) diff --git a/gr-digital/python/generic_mod_demod.py b/gr-digital/python/generic_mod_demod.py index 1b8603fea..da8e2cfd9 100644 --- a/gr-digital/python/generic_mod_demod.py +++ b/gr-digital/python/generic_mod_demod.py @@ -29,6 +29,7 @@ from gnuradio import gr from modulation_utils2 import extract_kwargs_from_options_for_class from utils import mod_codes import digital_swig +import math # default values (used in __init__ and add_options) _def_samples_per_symbol = 2 @@ -37,17 +38,16 @@ _def_verbose = False _def_log = False # Frequency correction -_def_freq_alpha = 0.010 +_def_freq_bw = 2*math.pi/100.0 # Symbol timing recovery -_def_timing_alpha = 0.100 -_def_timing_beta = 0.010 +_def_timing_bw = 2*math.pi/100.0 _def_timing_max_dev = 1.5 # Fine frequency / Phase correction -_def_phase_alpha = 0.1 +_def_phase_bw = 2*math.pi/100.0 # Number of points in constellation _def_constellation_points = 16 # Whether differential coding is used. -_def_differential = True +_def_differential = False def add_common_options(parser): """ @@ -55,10 +55,12 @@ def add_common_options(parser): """ parser.add_option("-p", "--constellation-points", type="int", default=_def_constellation_points, help="set the number of constellation points (must be a power of 2 (power of 4 for QAM) [default=%default]") - parser.add_option("", "--differential", action="store_true", dest="differential", default=True, - help="use differential encoding [default=%default]") - parser.add_option("", "--not-differential", action="store_false", dest="differential", + parser.add_option("", "--non-differential", action="store_true", + dest="differential", default=False, help="do not use differential encoding [default=%default]") + parser.add_option("", "--differential", action="store_false", + dest="differential", + help="use differential encoding [default=False]") parser.add_option("", "--mod-code", type="choice", choices=mod_codes.codes, default=mod_codes.NO_CODE, help="Select modulation code from: %s [default=%%default]" @@ -77,6 +79,7 @@ class generic_mod(gr.hier_block2): differential=_def_differential, samples_per_symbol=_def_samples_per_symbol, excess_bw=_def_excess_bw, + gray_coded=True, verbose=_def_verbose, log=_def_log): """ @@ -88,9 +91,11 @@ class generic_mod(gr.hier_block2): @param constellation: determines the modulation type @type constellation: gnuradio.digital.gr_constellation @param samples_per_symbol: samples per baud >= 2 - @type samples_per_symbol: integer + @type samples_per_symbol: float @param excess_bw: Root-raised cosine filter excess bandwidth @type excess_bw: float + @param gray_coded: turn gray coding on/off + @type gray_coded: bool @param verbose: Print information about modulator? @type verbose: bool @param log: Log modulation data to files? @@ -180,17 +185,17 @@ class generic_mod(gr.hier_block2): def _setup_logging(self): print "Modulation logging turned on." self.connect(self.bytes2chunks, - gr.file_sink(gr.sizeof_char, "tx_bytes2chunks.dat")) + gr.file_sink(gr.sizeof_char, "tx_bytes2chunks.8b")) if self._constellation.apply_pre_diff_code(): self.connect(self.symbol_mapper, - gr.file_sink(gr.sizeof_char, "tx_symbol_mapper.dat")) + gr.file_sink(gr.sizeof_char, "tx_symbol_mapper.8b")) if self._differential: self.connect(self.diffenc, - gr.file_sink(gr.sizeof_char, "tx_diffenc.dat")) + gr.file_sink(gr.sizeof_char, "tx_diffenc.8b")) self.connect(self.chunks2symbols, - gr.file_sink(gr.sizeof_gr_complex, "tx_chunks2symbols.dat")) + gr.file_sink(gr.sizeof_gr_complex, "tx_chunks2symbols.32fc")) self.connect(self.rrc_filter, - gr.file_sink(gr.sizeof_gr_complex, "tx_rrc_filter.dat")) + gr.file_sink(gr.sizeof_gr_complex, "tx_rrc_filter.32fc")) # ///////////////////////////////////////////////////////////////////////////// @@ -206,10 +211,9 @@ class generic_demod(gr.hier_block2): samples_per_symbol=_def_samples_per_symbol, differential=_def_differential, excess_bw=_def_excess_bw, - freq_alpha=_def_freq_alpha, - timing_alpha=_def_timing_alpha, - timing_max_dev=_def_timing_max_dev, - phase_alpha=_def_phase_alpha, + freq_bw=_def_freq_bw, + timing_bw=_def_timing_bw, + phase_bw=_def_phase_bw, verbose=_def_verbose, log=_def_log): """ @@ -224,14 +228,12 @@ class generic_demod(gr.hier_block2): @type samples_per_symbol: float @param excess_bw: Root-raised cosine filter excess bandwidth @type excess_bw: float - @param freq_alpha: loop filter gain for frequency recovery - @type freq_alpha: float - @param timing_alpha: loop alpha gain for timing recovery - @type timing_alpha: float - @param timing_max_dev: timing loop maximum rate deviations - @type timing_max_dev: float - @param phase_alpha: loop filter gain in phase loop - @type phase_alphas: float + @param freq_bw: loop filter lock-in bandwidth + @type freq_bw: float + @param timing_bw: timing recoery loop lock-in bandwidth + @type timing_bw: float + @param phase_bw: phase recovery loop bandwidth + @type phase_bw: float @param verbose: Print information about modulator? @type verbose: bool @param debug: Print modualtion data to files? @@ -245,12 +247,10 @@ class generic_demod(gr.hier_block2): self._constellation = constellation.base() self._samples_per_symbol = samples_per_symbol self._excess_bw = excess_bw - self._phase_alpha = phase_alpha - self._freq_alpha = freq_alpha - self._freq_beta = 0.10*self._freq_alpha - self._timing_alpha = timing_alpha - self._timing_beta = _def_timing_beta - self._timing_max_dev=timing_max_dev + self._phase_bw = phase_bw + self._freq_bw = freq_bw + self._timing_bw = timing_bw + self._timing_max_dev= _def_timing_max_dev self._differential = differential if self._samples_per_symbol < 2: @@ -258,32 +258,27 @@ class generic_demod(gr.hier_block2): arity = pow(2,self.bits_per_symbol()) + nfilts = 32 + ntaps = 11 * int(self._samples_per_symbol*nfilts) + # Automatic gain control self.agc = gr.agc2_cc(0.6e-1, 1e-3, 1, 1, 100) # Frequency correction - self.freq_recov = gr.fll_band_edge_cc(self._samples_per_symbol, self._excess_bw, - 11*int(self._samples_per_symbol), - self._freq_alpha, self._freq_beta) + self.freq_recov = digital_swig.fll_band_edge_cc(self._samples_per_symbol, self._excess_bw, + ntaps, self._freq_bw) # symbol timing recovery with RRC data filter - nfilts = 32 - ntaps = 11 * int(self._samples_per_symbol*nfilts) - taps = gr.firdes.root_raised_cosine(nfilts, nfilts, - 1.0/float(self._samples_per_symbol), - self._excess_bw, ntaps) + taps = gr.firdes.root_raised_cosine(nfilts, nfilts*self._samples_per_symbol, + 1.0, self._excess_bw, ntaps) self.time_recov = gr.pfb_clock_sync_ccf(self._samples_per_symbol, - self._timing_alpha, - taps, nfilts, nfilts/2, self._timing_max_dev) - self.time_recov.set_beta(self._timing_beta) + self._timing_bw, taps, + nfilts, nfilts//2, self._timing_max_dev) - self._phase_beta = 0.25 * self._phase_alpha * self._phase_alpha fmin = -0.25 fmax = 0.25 - self.receiver = digital_swig.constellation_receiver_cb( - self._constellation, - self._phase_alpha, self._phase_beta, + self._constellation, self._phase_bw, fmin, fmax) # Do differential decoding based on phase change of symbols @@ -322,49 +317,46 @@ class generic_demod(gr.hier_block2): print "\nDemodulator:" print "bits per symbol: %d" % self.bits_per_symbol() print "RRC roll-off factor: %.2f" % self._excess_bw - print "FLL gain: %.2e" % self._freq_alpha - print "Timing alpha gain: %.2e" % self._timing_alpha - print "Timing beta gain: %.2e" % self._timing_beta - print "Timing max dev: %.2f" % self._timing_max_dev - print "Phase track alpha: %.2e" % self._phase_alpha - print "Phase track beta: %.2e" % self._phase_beta + print "FLL bandwidth: %.2e" % self._freq_bw + print "Timing bandwidth: %.2e" % self._timing_bw + print "Phase bandwidth: %.2e" % self._phase_bw def _setup_logging(self): print "Modulation logging turned on." self.connect(self.agc, - gr.file_sink(gr.sizeof_gr_complex, "rx_agc.dat")) + gr.file_sink(gr.sizeof_gr_complex, "rx_agc.32fc")) self.connect((self.freq_recov, 0), - gr.file_sink(gr.sizeof_gr_complex, "rx_freq_recov.dat")) + gr.file_sink(gr.sizeof_gr_complex, "rx_freq_recov.32fc")) self.connect((self.freq_recov, 1), - gr.file_sink(gr.sizeof_float, "rx_freq_recov_freq.dat")) + gr.file_sink(gr.sizeof_float, "rx_freq_recov_freq.32f")) self.connect((self.freq_recov, 2), - gr.file_sink(gr.sizeof_float, "rx_freq_recov_phase.dat")) + gr.file_sink(gr.sizeof_float, "rx_freq_recov_phase.32f")) self.connect((self.freq_recov, 3), - gr.file_sink(gr.sizeof_gr_complex, "rx_freq_recov_error.dat")) + gr.file_sink(gr.sizeof_float, "rx_freq_recov_error.32f")) self.connect((self.time_recov, 0), - gr.file_sink(gr.sizeof_gr_complex, "rx_time_recov.dat")) + gr.file_sink(gr.sizeof_gr_complex, "rx_time_recov.32fc")) self.connect((self.time_recov, 1), - gr.file_sink(gr.sizeof_float, "rx_time_recov_error.dat")) + gr.file_sink(gr.sizeof_float, "rx_time_recov_error.32f")) self.connect((self.time_recov, 2), - gr.file_sink(gr.sizeof_float, "rx_time_recov_rate.dat")) + gr.file_sink(gr.sizeof_float, "rx_time_recov_rate.32f")) self.connect((self.time_recov, 3), - gr.file_sink(gr.sizeof_float, "rx_time_recov_phase.dat")) + gr.file_sink(gr.sizeof_float, "rx_time_recov_phase.32f")) self.connect((self.receiver, 0), - gr.file_sink(gr.sizeof_char, "rx_receiver.dat")) + gr.file_sink(gr.sizeof_char, "rx_receiver.8b")) self.connect((self.receiver, 1), - gr.file_sink(gr.sizeof_float, "rx_receiver_error.dat")) + gr.file_sink(gr.sizeof_float, "rx_receiver_error.32f")) self.connect((self.receiver, 2), - gr.file_sink(gr.sizeof_float, "rx_receiver_phase.dat")) + gr.file_sink(gr.sizeof_float, "rx_receiver_phase.32f")) self.connect((self.receiver, 3), - gr.file_sink(gr.sizeof_float, "rx_receiver_freq.dat")) + gr.file_sink(gr.sizeof_float, "rx_receiver_freq.32f")) if self._differential: self.connect(self.diffdec, - gr.file_sink(gr.sizeof_char, "rx_diffdec.dat")) + gr.file_sink(gr.sizeof_char, "rx_diffdec.8b")) if self._constellation.apply_pre_diff_code(): self.connect(self.symbol_mapper, - gr.file_sink(gr.sizeof_char, "rx_symbol_mapper.dat")) + gr.file_sink(gr.sizeof_char, "rx_symbol_mapper.8b")) self.connect(self.unpack, - gr.file_sink(gr.sizeof_char, "rx_unpack.dat")) + gr.file_sink(gr.sizeof_char, "rx_unpack.8b")) def add_options(parser): """ @@ -373,16 +365,12 @@ class generic_demod(gr.hier_block2): # Add options shared with modulator. add_common_options(parser) # Add options specific to demodulator. - parser.add_option("", "--freq-alpha", type="float", default=_def_freq_alpha, - help="set frequency lock loop alpha gain value [default=%default]") - parser.add_option("", "--phase-alpha", type="float", default=_def_phase_alpha, - help="set phase tracking loop alpha value [default=%default]") - parser.add_option("", "--timing-alpha", type="float", default=_def_timing_alpha, - help="set timing symbol sync loop gain alpha value [default=%default]") - parser.add_option("", "--timing-beta", type="float", default=_def_timing_beta, - help="set timing symbol sync loop gain beta value [default=%default]") - parser.add_option("", "--timing-max-dev", type="float", default=_def_timing_max_dev, - help="set timing symbol sync loop maximum deviation [default=%default]") + parser.add_option("", "--freq-bw", type="float", default=_def_freq_bw, + help="set frequency lock loop lock-in bandwidth [default=%default]") + parser.add_option("", "--phase-bw", type="float", default=_def_phase_bw, + help="set phase tracking loop lock-in bandwidth [default=%default]") + parser.add_option("", "--timing-bw", type="float", default=_def_timing_bw, + help="set timing symbol sync loop gain lock-in bandwidth [default=%default]") add_options=staticmethod(add_options) def extract_kwargs_from_options(cls, options): diff --git a/gr-digital/python/modulation_utils2.py b/gr-digital/python/modulation_utils2.py index f30055f4a..cb3a9812d 100644 --- a/gr-digital/python/modulation_utils2.py +++ b/gr-digital/python/modulation_utils2.py @@ -80,6 +80,7 @@ def extract_kwargs_from_options(function, excluded_args, options): @param options: result of command argument parsing @type options: optparse.Values """ + # Try this in C++ ;) args, varargs, varkw, defaults = inspect.getargspec(function) d = {} diff --git a/gr-digital/python/qa_constellation_receiver.py b/gr-digital/python/qa_constellation_receiver.py index cb4a0c10e..79dded8ba 100755 --- a/gr-digital/python/qa_constellation_receiver.py +++ b/gr-digital/python/qa_constellation_receiver.py @@ -37,7 +37,7 @@ random.seed(1239) # TESTING PARAMETERS # The number of symbols to test with. # We need this many to let the frequency recovery block converge. -DATA_LENGTH = 200000 +DATA_LENGTH = 10000 # Test fails if fraction of output that is correct is less than this. REQ_CORRECT = 0.8 diff --git a/gr-digital/python/qa_costas_loop_cc.py b/gr-digital/python/qa_costas_loop_cc.py index 3f5eaa141..124159dba 100755 --- a/gr-digital/python/qa_costas_loop_cc.py +++ b/gr-digital/python/qa_costas_loop_cc.py @@ -34,10 +34,9 @@ class test_costas_loop_cc(gr_unittest.TestCase): def test01 (self): # test basic functionality by setting all gains to 0 - damp = 0.0 natfreq = 0.0 order = 2 - self.test = digital_swig.costas_loop_cc(damp, natfreq, order) + self.test = digital_swig.costas_loop_cc(natfreq, order) data = 100*[complex(1,0),] self.src = gr.vector_source_c(data, False) @@ -52,10 +51,9 @@ class test_costas_loop_cc(gr_unittest.TestCase): def test02 (self): # Make sure it doesn't diverge given perfect data - damp = 0.4 natfreq = 0.25 order = 2 - self.test = digital_swig.costas_loop_cc(damp, natfreq, order) + self.test = digital_swig.costas_loop_cc(natfreq, order) data = [complex(2*random.randint(0,1)-1, 0) for i in xrange(100)] self.src = gr.vector_source_c(data, False) @@ -71,10 +69,9 @@ class test_costas_loop_cc(gr_unittest.TestCase): def test03 (self): # BPSK Convergence test with static rotation - damp = 0.4 natfreq = 0.25 order = 2 - self.test = digital_swig.costas_loop_cc(damp, natfreq, order) + self.test = digital_swig.costas_loop_cc(natfreq, order) rot = cmath.exp(0.2j) # some small rotation data = [complex(2*random.randint(0,1)-1, 0) for i in xrange(100)] @@ -97,10 +94,9 @@ class test_costas_loop_cc(gr_unittest.TestCase): def test04 (self): # QPSK Convergence test with static rotation - damp = 0.4 natfreq = 0.25 order = 4 - self.test = digital_swig.costas_loop_cc(damp, natfreq, order) + self.test = digital_swig.costas_loop_cc(natfreq, order) rot = cmath.exp(0.2j) # some small rotation data = [complex(2*random.randint(0,1)-1, 2*random.randint(0,1)-1) @@ -124,10 +120,9 @@ class test_costas_loop_cc(gr_unittest.TestCase): def test05 (self): # 8PSK Convergence test with static rotation - damp = 0.5 - natfreq = 0.5 + natfreq = 0.25 order = 8 - self.test = digital_swig.costas_loop_cc(damp, natfreq, order) + self.test = digital_swig.costas_loop_cc(natfreq, order) rot = cmath.exp(-cmath.pi/8.0j) # rotate to match Costas rotation const = psk2.psk_constellation(order) diff --git a/gr-digital/python/qa_fll_band_edge.py b/gr-digital/python/qa_fll_band_edge.py new file mode 100644 index 000000000..088eb2b68 --- /dev/null +++ b/gr-digital/python/qa_fll_band_edge.py @@ -0,0 +1,83 @@ +#!/usr/bin/env python +# +# Copyright 2011 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +from gnuradio import gr, gr_unittest +import digital_swig +import random, math + +class test_fll_band_edge_cc(gr_unittest.TestCase): + + def setUp (self): + self.tb = gr.top_block () + + def tearDown (self): + self.tb = None + + def test01 (self): + sps = 4 + rolloff = 0.35 + bw = 2*math.pi/100.0 + ntaps = 45 + + # Create pulse shape filter + rrc_taps = gr.firdes.root_raised_cosine( + sps, sps, 1.0, rolloff, ntaps) + + # The frequency offset to correct + foffset = 0.2 / (2.0*math.pi) + + # Create a set of 1's and -1's, pulse shape and interpolate to sps + data = [2.0*random.randint(0, 2) - 1.0 for i in xrange(200)] + self.src = gr.vector_source_c(data, False) + self.rrc = gr.interp_fir_filter_ccf(sps, rrc_taps) + + # Mix symbols with a complex sinusoid to spin them + self.nco = gr.sig_source_c(1, gr.GR_SIN_WAVE, foffset, 1) + self.mix = gr.multiply_cc() + + # FLL will despin the symbols to an arbitrary phase + self.fll = digital_swig.fll_band_edge_cc(sps, rolloff, ntaps, bw) + + # Create sinks for all outputs of the FLL + # we will only care about the freq and error outputs + self.vsnk_frq = gr.vector_sink_f() + self.nsnk_fll = gr.null_sink(gr.sizeof_gr_complex) + self.nsnk_phs = gr.null_sink(gr.sizeof_float) + self.nsnk_err = gr.null_sink(gr.sizeof_float) + + # Connect the blocks + self.tb.connect(self.nco, (self.mix,1)) + self.tb.connect(self.src, self.rrc, (self.mix,0)) + self.tb.connect(self.mix, self.fll, self.nsnk_fll) + self.tb.connect((self.fll,1), self.vsnk_frq) + self.tb.connect((self.fll,2), self.nsnk_phs) + self.tb.connect((self.fll,3), self.nsnk_err) + self.tb.run() + + N = 700 + dst_data = self.vsnk_frq.data()[N:] + + expected_result = len(dst_data)* [-0.20,] + self.assertComplexTuplesAlmostEqual (expected_result, dst_data, 4) + +if __name__ == '__main__': + gr_unittest.run(test_fll_band_edge_cc, "test_fll_band_edge_cc.xml") diff --git a/gr-digital/python/qam.py b/gr-digital/python/qam.py index f29291ce8..a5a2e6c2c 100644 --- a/gr-digital/python/qam.py +++ b/gr-digital/python/qam.py @@ -113,7 +113,7 @@ def make_differential_constellation(m, gray_coded): return const_map -def make_not_differential_constellation(m, gray_coded): +def make_non_differential_constellation(m, gray_coded): side = int(pow(m, 0.5)) if (not isinstance(m, int) or m < 4 or not is_power_of_four(m)): raise ValueError("m must be a power of 4 integer.") @@ -158,7 +158,7 @@ def qam_constellation(constellation_points=_def_constellation_points, if differential: points = make_differential_constellation(constellation_points, gray_coded) else: - points = make_not_differential_constellation(constellation_points, gray_coded) + points = make_non_differential_constellation(constellation_points, gray_coded) side = int(sqrt(constellation_points)) width = 2.0/(side-1) # No pre-diff code diff --git a/gr-digital/python/qpsk.py b/gr-digital/python/qpsk.py index 91e8b196f..76e5df270 100644 --- a/gr-digital/python/qpsk.py +++ b/gr-digital/python/qpsk.py @@ -23,7 +23,6 @@ QPSK modulation. Demodulation is not included since the generic_mod_demod -doesn't work for non-differential encodings. """ from gnuradio import gr @@ -33,8 +32,7 @@ import modulation_utils2 # Default number of points in constellation. _def_constellation_points = 4 -# Whether differential coding is used. -_def_differential = False +# Whether gray coding is used. _def_gray_coded = True # ///////////////////////////////////////////////////////////////////////////// @@ -53,7 +51,6 @@ def qpsk_constellation(m=_def_constellation_points): class qpsk_mod(generic_mod): def __init__(self, constellation_points=_def_constellation_points, - differential=_def_differential, gray_coded=_def_gray_coded, *args, **kwargs): @@ -70,9 +67,11 @@ class qpsk_mod(generic_mod): constellation = digital_swig.constellation_qpsk() if constellation_points != 4: raise ValueError("QPSK can only have 4 constellation points.") - if differential or not gray_coded: - raise ValueError("This QPSK mod/demod works only for gray-coded, non-differential.") - super(qpsk_mod, self).__init__(constellation, differential, gray_coded, *args, **kwargs) + if not gray_coded: + raise ValueError("This QPSK mod/demod works only for gray-coded constellations.") + super(qpsk_mod, self).__init__(constellation=constellation, + gray_coded=gray_coded, + *args, **kwargs) # ///////////////////////////////////////////////////////////////////////////// @@ -98,8 +97,8 @@ class qpsk_demod(generic_demod): constellation = digital_swig.constellation_qpsk() if constellation_points != 4: raise ValueError('Number of constellation points must be 4 for QPSK.') - super(qpsk_demod, self).__init__(constellation, *args, **kwargs) - + super(qpsk_demod, self).__init__(constellation=constellation, + *args, **kwargs) # # Add these to the mod/demod registry |