diff options
author | Ben Reynwar | 2011-01-01 15:31:55 -0700 |
---|---|---|
committer | Ben Reynwar | 2011-01-01 15:31:55 -0700 |
commit | 493cd2e48eee4850f2ceef20c9dd487b93ea6b9e (patch) | |
tree | d6bdc30566e7a90f7ea3a553a0037ea9d41c3e06 | |
parent | ee21aaed629cfe9cec2e561c0e3d10374ec80e29 (diff) | |
download | gnuradio-493cd2e48eee4850f2ceef20c9dd487b93ea6b9e.tar.gz gnuradio-493cd2e48eee4850f2ceef20c9dd487b93ea6b9e.tar.bz2 gnuradio-493cd2e48eee4850f2ceef20c9dd487b93ea6b9e.zip |
Worked on generic demodulation.
10 files changed, 339 insertions, 125 deletions
diff --git a/gnuradio-core/src/lib/general/Makefile.am b/gnuradio-core/src/lib/general/Makefile.am index daa3c446e..861c82c28 100644 --- a/gnuradio-core/src/lib/general/Makefile.am +++ b/gnuradio-core/src/lib/general/Makefile.am @@ -53,7 +53,9 @@ libgeneral_la_SOURCES = \ gr_complex_to_xxx.cc \ gr_conjugate_cc.cc \ gr_copy.cc \ + gr_constellation.cc \ gr_constellation_decoder_cb.cc \ + gr_constellation_receiver_cb.cc \ gr_correlate_access_code_bb.cc \ gr_costas_loop_cc.cc \ gr_count_bits.cc \ @@ -100,7 +102,6 @@ libgeneral_la_SOURCES = \ gr_math.cc \ gr_misc.cc \ gr_mpsk_receiver_cc.cc \ - gr_constellation_receiver_cb.cc \ gr_nlog10_ff.cc \ gr_nop.cc \ gr_null_sink.cc \ @@ -207,7 +208,9 @@ grinclude_HEADERS = \ gr_complex_to_interleaved_short.h \ gr_complex_to_xxx.h \ gr_conjugate_cc.h \ + gr_constellation.h \ gr_constellation_decoder_cb.h \ + gr_constellation_receiver_cb.h \ gr_copy.h \ gr_correlate_access_code_bb.h \ gr_costas_loop_cc.h \ @@ -257,7 +260,6 @@ grinclude_HEADERS = \ gr_map_bb.h \ gr_math.h \ gr_misc.h \ - gr_constellation_receiver_cb.h \ gr_nco.h \ gr_nlog10_ff.h \ gr_nop.h \ @@ -378,7 +380,9 @@ swiginclude_HEADERS = \ gr_complex_to_interleaved_short.i \ gr_complex_to_xxx.i \ gr_conjugate_cc.i \ + gr_constellation.i \ gr_constellation_decoder_cb.i \ + gr_constellation_receiver_cb.i \ gr_copy.i \ gr_correlate_access_code_bb.i \ gr_costas_loop_cc.i \ @@ -419,7 +423,6 @@ swiginclude_HEADERS = \ gr_lms_dfe_cc.i \ gr_lms_dfe_ff.i \ gr_map_bb.i \ - gr_constellation_receiver_cb.i \ gr_nlog10_ff.i \ gr_nop.i \ gr_null_sink.i \ diff --git a/gnuradio-core/src/lib/general/general.i b/gnuradio-core/src/lib/general/general.i index f758211cc..47cc3b7fa 100644 --- a/gnuradio-core/src/lib/general/general.i +++ b/gnuradio-core/src/lib/general/general.i @@ -70,6 +70,7 @@ #include <gr_throttle.h> #include <gr_mpsk_receiver_cc.h> #include <gr_constellation_receiver_cb.h> +#include <gr_constellation.h> #include <gr_stream_mux.h> #include <gr_stream_to_streams.h> #include <gr_streams_to_stream.h> @@ -192,6 +193,7 @@ %include "gr_throttle.i" %include "gr_mpsk_receiver_cc.i" %include "gr_constellation_receiver_cb.i" +%include "gr_constellation.i" %include "gr_stream_mux.i" %include "gr_stream_to_streams.i" %include "gr_streams_to_stream.i" diff --git a/gnuradio-core/src/lib/general/gr_constellation.cc b/gnuradio-core/src/lib/general/gr_constellation.cc new file mode 100644 index 000000000..03589dee8 --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_constellation.cc @@ -0,0 +1,127 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010 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. + */ + +#include <gr_io_signature.h> +#include <gr_constellation.h> +#include <gr_math.h> +#include <gr_complex.h> + +gr_constellation_sptr +gr_make_constellation(std::vector<gr_complex> constellation) +{ + return gr_constellation_sptr(new gr_constellation (constellation)); + } + +// Base Constellation Class + +gr_constellation::gr_constellation (std::vector<gr_complex> constellation) { + d_constellation = constellation; +} + + +unsigned int get_closest_point(std::vector<gr_complex> constellation, gr_complex sample) { + + unsigned int table_size = constellation.size(); + unsigned int min_index = 0; + float min_euclid_dist; + float euclid_dist; + + min_euclid_dist = norm(sample - constellation[0]); + min_index = 0; + for (unsigned int j = 1; j < table_size; j++){ + euclid_dist = norm(sample - constellation[j]); + if (euclid_dist < min_euclid_dist){ + min_euclid_dist = euclid_dist; + min_index = j; + } + } + return min_index; +} + +// Chooses points base on shortest distance. +// Inefficient. +unsigned int gr_constellation::decision_maker(gr_complex sample) +{ + unsigned int min_index; + min_index = get_closest_point(d_constellation, sample); + return min_index; +} + +gr_constellation_sector_sptr +gr_make_constellation_sector(std::vector<gr_complex> constellation, + unsigned int real_sectors, unsigned int imag_sectors, + float width_real_sectors, float width_imag_sectors) +{ + return gr_constellation_sector_sptr(new gr_constellation_sector (constellation, real_sectors, imag_sectors, width_real_sectors, width_imag_sectors)); + } + +gr_constellation_sector::gr_constellation_sector (std::vector<gr_complex> constellation, + unsigned int real_sectors, unsigned int imag_sectors, + float width_real_sectors, float width_imag_sectors) : + gr_constellation(constellation), + n_sectors(real_sectors * imag_sectors), + n_real_sectors(real_sectors), n_imag_sectors(imag_sectors), + d_width_real_sectors(width_real_sectors), d_width_imag_sectors(width_imag_sectors) +{ + find_sector_values(); +} + +unsigned int gr_constellation_sector::decision_maker (gr_complex sample) { + unsigned int sector; + sector = get_sector(sample); + return sector_values[sector]; +} + +unsigned int gr_constellation_sector::get_sector (gr_complex sample) { + int real_sector, imag_sector; + unsigned int sector; + real_sector = int(real(sample)/d_width_real_sectors + n_real_sectors/2.0); + if (real_sector < 0) real_sector = 0; + if (real_sector >= n_real_sectors) real_sector = n_real_sectors-1; + imag_sector = int(imag(sample)/d_width_imag_sectors + n_imag_sectors/2.0); + if (imag_sector < 0) imag_sector = 0; + if (imag_sector >= n_imag_sectors) imag_sector = n_imag_sectors-1; + sector = real_sector * n_imag_sectors + imag_sector; + return sector; +} + +unsigned int gr_constellation_sector::calc_sector_value (unsigned int sector) { + unsigned int real_sector, imag_sector; + gr_complex sector_center; + unsigned int closest_point; + real_sector = float(sector)/n_imag_sectors; + imag_sector = sector - real_sector * n_imag_sectors; + sector_center = gr_complex((real_sector + 0.5 - n_real_sectors/2.0) * d_width_real_sectors, + (imag_sector + 0.5 - n_imag_sectors/2.0) * d_width_imag_sectors); + closest_point = get_closest_point(d_constellation, sector_center); + return closest_point; +} + + +void gr_constellation_sector::find_sector_values () { + unsigned int i; + sector_values.clear(); + for (i=0; i<n_sectors; i++) { + sector_values.push_back(calc_sector_value(i)); + } +} + diff --git a/gnuradio-core/src/lib/general/gr_constellation.h b/gnuradio-core/src/lib/general/gr_constellation.h new file mode 100644 index 000000000..92ae3c5e2 --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_constellation.h @@ -0,0 +1,108 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010 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. + */ + +#ifndef INCLUDED_GR_CONSTELLATION_H +#define INCLUDED_GR_CONSTELLATION_H + +#include <vector> +#include <math.h> +#include <gr_complex.h> +#include <boost/enable_shared_from_this.hpp> + +class gr_constellation; +typedef boost::shared_ptr<gr_constellation> gr_constellation_sptr; + +// public constructor +gr_constellation_sptr + gr_make_constellation (std::vector<gr_complex> constellation); + +class gr_constellation : public boost::enable_shared_from_this<gr_constellation> +{ + public: + + gr_constellation (std::vector<gr_complex> constellation); + + //! Returns the set of points in this constellation. + std::vector<gr_complex> points() { return d_constellation;} + + //! Returns the constellation point that matches best. + //! Also calculates the phase error. + virtual unsigned int decision_maker (gr_complex sample); + + unsigned int bits_per_symbol () { + return floor(log(d_constellation.size())/log(2)); + } + + gr_constellation_sptr base() { + return shared_from_this(); + } + + protected: + + std::vector<gr_complex> d_constellation; + + private: + friend gr_constellation_sptr + gr_make_constellation (std::vector<gr_complex> constellation); +}; + +class gr_constellation_sector; +typedef boost::shared_ptr<gr_constellation_sector> gr_constellation_sector_sptr; + +// public constructor +gr_constellation_sector_sptr +gr_make_constellation_sector (std::vector<gr_complex> constellation, unsigned int real_sectors, unsigned int imag_sectors, + float width_real_sectors, float width_imag_sectors); + +class gr_constellation_sector : public gr_constellation +{ + public: + + gr_constellation_sector (std::vector<gr_complex> constellation, unsigned int real_sectors, unsigned int imag_sectors, + float width_real_sectors, float width_imag_sectors); + + unsigned int decision_maker (gr_complex sample); + + protected: + + virtual unsigned int get_sector (gr_complex sample); + + virtual unsigned int calc_sector_value (unsigned int sector); + + void find_sector_values (); + + private: + + std::vector<unsigned int> sector_values; + unsigned int n_sectors; + unsigned int n_real_sectors; + unsigned int n_imag_sectors; + float d_width_real_sectors; + float d_width_imag_sectors; + + friend gr_constellation_sector_sptr + gr_make_constellation_sector (std::vector<gr_complex> constellation, unsigned int real_sectors, unsigned int imag_sectors, + float width_real_sectors, float width_imag_sectors); + +}; + +#endif diff --git a/gnuradio-core/src/lib/general/gr_constellation.i b/gnuradio-core/src/lib/general/gr_constellation.i new file mode 100644 index 000000000..bdc5436f2 --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_constellation.i @@ -0,0 +1,62 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010 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. + */ + +%template(gr_complex_vector) std::vector<gr_complex>; +%template(unsigned_int_vector) std::vector<unsigned int>; + +class gr_constellation; +typedef boost::shared_ptr<gr_constellation> gr_constellation_sptr; +%template(gr_constellation_sptr) boost::shared_ptr<gr_constellation>; +%rename(constellation) gr_make_constellation; +gr_constellation_sptr gr_make_constellation(std::vector<gr_complex> constellation); +%ignore gr_constellation; + +class gr_constellation +{ +public: + gr_constellation (std::vector<gr_complex> constellation); + std::vector<gr_complex> points(); + unsigned int decision_maker (gr_complex sample); + unsigned int bits_per_symbol (); + gr_constellation_sptr base (); +}; + +class gr_constellation_sector; +typedef boost::shared_ptr<gr_constellation_sector> gr_constellation_sector_sptr; +%template(gr_constellation_sector_sptr) boost::shared_ptr<gr_constellation_sector>; +%rename(constellation_sector) gr_make_constellation_sector; +gr_constellation_sector_sptr gr_make_constellation_sector(std::vector<gr_complex> constellation_sector, + unsigned int real_sectors, unsigned int imag_sectors, + float width_real_sectors, float width_imag_sectors); +%ignore gr_constellation_sector; + +class gr_constellation_sector : public gr_constellation +{ +public: + gr_constellation_sector (std::vector<gr_complex> constellation, + unsigned int real_sectors, unsigned int imag_sectors, + float width_real_sectors, float width_imag_sectors); + std::vector<gr_complex> points (); + unsigned int decision_maker (gr_complex sample); + unsigned int bits_per_symbol (); + gr_constellation_sptr base (); +}; diff --git a/gnuradio-core/src/lib/general/gr_constellation_receiver_cb.cc b/gnuradio-core/src/lib/general/gr_constellation_receiver_cb.cc index 93af6d078..6520b66b2 100644 --- a/gnuradio-core/src/lib/general/gr_constellation_receiver_cb.cc +++ b/gnuradio-core/src/lib/general/gr_constellation_receiver_cb.cc @@ -26,12 +26,11 @@ #include <gr_io_signature.h> #include <gr_prefs.h> +#include <gr_constellation.h> #include <gr_constellation_receiver_cb.h> #include <stdexcept> #include <gr_math.h> #include <gr_expj.h> -// For debugging -#include <iostream> #define M_TWOPI (2*M_PI) @@ -41,7 +40,7 @@ // Public constructor gr_constellation_receiver_cb_sptr -gr_make_constellation_receiver_cb(gr_constellation constell, +gr_make_constellation_receiver_cb(gr_constellation_sptr constell, float alpha, float beta, float fmin, float fmax) { @@ -49,10 +48,10 @@ gr_make_constellation_receiver_cb(gr_constellation constell, alpha, beta, fmin, fmax)); } - + static int ios[] = {sizeof(char), sizeof(float), sizeof(float), sizeof(float)}; static std::vector<int> iosig(ios, ios+sizeof(ios)/sizeof(int)); -gr_constellation_receiver_cb::gr_constellation_receiver_cb (gr_constellation constellation, +gr_constellation_receiver_cb::gr_constellation_receiver_cb (gr_constellation_sptr constellation, float alpha, float beta, float fmin, float fmax) : gr_block ("constellation_receiver_cb", @@ -61,12 +60,12 @@ gr_constellation_receiver_cb::gr_constellation_receiver_cb (gr_constellation con d_constellation(constellation), d_alpha(alpha), d_beta(beta), d_freq(0), d_max_freq(fmax), d_min_freq(fmin), d_phase(0), d_current_const_point(0) -{} +{ +} void gr_constellation_receiver_cb::phase_error_tracking(float phase_error) { - d_freq += d_beta*phase_error; // adjust frequency based on error d_phase += d_freq + d_alpha*phase_error; // adjust phase based on error @@ -82,7 +81,7 @@ gr_constellation_receiver_cb::phase_error_tracking(float phase_error) #if VERBOSE_COSTAS printf("cl: phase_error: %f phase: %f freq: %f sample: %f+j%f constellation: %f+j%f\n", phase_error, d_phase, d_freq, sample.real(), sample.imag(), - d_constellation.constellation()[d_current_const_point].real(), d_constellation.constellation()[d_current_const_point].imag()); + d_constellation->points()[d_current_const_point].real(), d_constellation->points()[d_current_const_point].imag()); #endif } @@ -112,9 +111,8 @@ gr_constellation_receiver_cb::general_work (int noutput_items, sample = in[i]; nco = gr_expj(d_phase); // get the NCO value for derotating the current sample sample = nco*sample; // get the downconverted symbol - sym_value = d_constellation.decision_maker(sample); - phase_error = -arg(sample*conj(d_constellation.constellation()[sym_value])); - //std::cout << "sym_value: " << sym_value << " sample: " << sample << "phase_error: " << phase_error << std::endl; + sym_value = d_constellation->decision_maker(sample); + phase_error = -arg(sample*conj(d_constellation->points()[sym_value])); phase_error_tracking(phase_error); // corrects phase and frequency offsets out[i] = sym_value; if(output_items.size() == 4) { @@ -125,38 +123,7 @@ gr_constellation_receiver_cb::general_work (int noutput_items, i++; } - #if 0 - printf("ninput_items: %d noutput_items: %d consuming: %d returning: %d\n", - ninput_items[0], noutput_items, i, i); - #endif - consume_each(i); return i; } -// Base Constellation Class - -gr_constellation::gr_constellation (std::vector<gr_complex> constellation) { - d_constellation = constellation; -} - -// Chooses points base on shortest distance. -// Inefficient. -unsigned int gr_constellation::decision_maker(gr_complex sample) -{ - unsigned int table_size = constellation().size(); - unsigned int min_index = 0; - float min_euclid_dist; - float euclid_dist; - - min_euclid_dist = norm(sample - constellation()[0]); - min_index = 0; - for (unsigned int j = 1; j < table_size; j++){ - euclid_dist = norm(sample - constellation()[j]); - if (euclid_dist < min_euclid_dist){ - min_euclid_dist = euclid_dist; - min_index = j; - } - } - return min_index; -} diff --git a/gnuradio-core/src/lib/general/gr_constellation_receiver_cb.h b/gnuradio-core/src/lib/general/gr_constellation_receiver_cb.h index ba38bdad6..d40d77fff 100644 --- a/gnuradio-core/src/lib/general/gr_constellation_receiver_cb.h +++ b/gnuradio-core/src/lib/general/gr_constellation_receiver_cb.h @@ -24,40 +24,17 @@ #define INCLUDED_GR_CONSTELLATION_RECEIVER_CB_H #include <gr_block.h> +#include <gr_constellation.h> #include <gr_complex.h> #include <math.h> #include <fstream> -class gr_constellation -{ - public: - - gr_constellation (std::vector<gr_complex> constellation); - - //! Returns the set of points in this constellation. - std::vector<gr_complex> constellation() { return d_constellation;} - - //! Returns the constellation point that matches best. - //! Also calculates the phase error. - unsigned int decision_maker (gr_complex sample); - - unsigned int bits_per_symbol () { - return floor(log(d_constellation.size())/log(2)); - } - - private: - - std::vector<gr_complex> d_constellation; -}; - -class gri_mmse_fir_interpolator_cc; - class gr_constellation_receiver_cb; typedef boost::shared_ptr<gr_constellation_receiver_cb> gr_constellation_receiver_cb_sptr; // public constructor gr_constellation_receiver_cb_sptr -gr_make_constellation_receiver_cb (gr_constellation constellation, +gr_make_constellation_receiver_cb (gr_constellation_sptr constellation, float alpha, float beta, float fmin, float fmax); @@ -136,7 +113,7 @@ protected: * The constructor also chooses which phase detector and decision maker to use in the work loop based on the * value of M. */ - gr_constellation_receiver_cb (gr_constellation constellation, + gr_constellation_receiver_cb (gr_constellation_sptr constellation, float alpha, float beta, float fmin, float fmax); @@ -151,7 +128,7 @@ protected: float d_freq, d_max_freq, d_min_freq; float d_phase; - gr_constellation d_constellation; + gr_constellation_sptr d_constellation; unsigned int d_current_const_point; //! delay line length. @@ -164,7 +141,7 @@ protected: unsigned int d_dl_idx; friend gr_constellation_receiver_cb_sptr - gr_make_constellation_receiver_cb (gr_constellation constell, + gr_make_constellation_receiver_cb (gr_constellation_sptr constell, float alpha, float beta, float fmin, float fmax); }; diff --git a/gnuradio-core/src/lib/general/gr_constellation_receiver_cb.i b/gnuradio-core/src/lib/general/gr_constellation_receiver_cb.i index b48322f45..2298d5099 100644 --- a/gnuradio-core/src/lib/general/gr_constellation_receiver_cb.i +++ b/gnuradio-core/src/lib/general/gr_constellation_receiver_cb.i @@ -22,24 +22,13 @@ GR_SWIG_BLOCK_MAGIC(gr,constellation_receiver_cb); -%template(gr_complex_vector) std::vector<gr_complex>; - -class gr_constellation -{ -public: - gr_constellation (std::vector<gr_complex> constellation); - std::vector<gr_complex> constellation(); - unsigned int decision_maker (gr_complex sample); - unsigned int bits_per_symbol (); -}; - -gr_constellation_receiver_cb_sptr gr_make_constellation_receiver_cb (gr_constellation constellation, +gr_constellation_receiver_cb_sptr gr_make_constellation_receiver_cb (gr_constellation_sptr constellation, float alpha, float beta, float fmin, float fmax); class gr_constellation_receiver_cb : public gr_block { private: - gr_constellation_receiver_cb (gr_contellation constellation, + gr_constellation_receiver_cb (gr_contellation_sptr constellation, float alpha, float beta, float fmin, float fmax); public: diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/generic_mod_demod.py b/gnuradio-core/src/python/gnuradio/blks2impl/generic_mod_demod.py index 69e11fcb0..60a3fc777 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/generic_mod_demod.py +++ b/gnuradio-core/src/python/gnuradio/blks2impl/generic_mod_demod.py @@ -22,7 +22,7 @@ # See gnuradio-examples/python/digital for examples """ -differential BPSK modulation and demodulation. +Generic modulation and demodulation. """ from gnuradio import gr, gru, modulation_utils2 @@ -79,7 +79,7 @@ class generic_mod(gr.hier_block2): gr.io_signature(1, 1, gr.sizeof_char), # Input signature gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature - self._constellation = constellation + self._constellation = constellation.base() self._samples_per_symbol = samples_per_symbol self._excess_bw = excess_bw @@ -96,7 +96,7 @@ class generic_mod(gr.hier_block2): self.diffenc = gr.diff_encoder_bb(arity) - self.chunks2symbols = gr.chunks_to_symbols_bc(self._constellation.constellation()) + self.chunks2symbols = gr.chunks_to_symbols_bc(self._constellation.points()) # pulse shaping filter self.rrc_taps = gr.firdes.root_raised_cosine( @@ -208,7 +208,7 @@ class generic_demod(gr.hier_block2): gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(1, 1, gr.sizeof_char)) # Output signature - self._constellation = constellation + self._constellation = constellation.base() self._samples_per_symbol = samples_per_symbol self._excess_bw = excess_bw self._phase_alpha = phase_alpha diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/qam.py b/gnuradio-core/src/python/gnuradio/blks2impl/qam.py index 9da7ca58e..22d80503b 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/qam.py +++ b/gnuradio-core/src/python/gnuradio/blks2impl/qam.py @@ -32,19 +32,6 @@ from gnuradio.blks2impl.generic_mod_demod import generic_mod, generic_demod # default values (used in __init__ and add_options) _def_constellation_points = 16 -_def_samples_per_symbol = 2 -_def_excess_bw = 0.35 -_def_verbose = False -_def_log = False - -# Frequency correction -_def_freq_alpha = 0.010 -# Symbol timing recovery -_def_timing_alpha = 0.100 -_def_timing_beta = 0.010 -_def_timing_max_dev = 1.5 -# Fine frequency / Phase correction -_def_phase_alpha = 0.1 def is_power_of_four(x): v = log(x)/log(4) @@ -146,11 +133,7 @@ def make_constellation(m): class qam_mod(generic_mod): - def __init__(self, constellation_points=_def_constellation_points, - samples_per_symbol=_def_samples_per_symbol, - excess_bw=_def_excess_bw, - verbose=_def_verbose, - log=_def_log): + def __init__(self, constellation_points=_def_constellation_points, *args, **kwargs): """ Hierarchical block for RRC-filtered QAM modulation. @@ -174,10 +157,13 @@ class qam_mod(generic_mod): raise ValueError("number of constellation points must be a power of four.") points = make_constellation(constellation_points) - constellation = gr.gr_constellation(points) + side = int(sqrt(constellation_points)) + assert(side * side == constellation_points) + width = 2.0/(side-1) + constellation = gr.constellation_sector(points, side, side, width, width) + #constellation = gr.constellation(points) - super(qam_mod, self).__init__(constellation, samples_per_symbol, - excess_bw, verbose, log) + super(qam_mod, self).__init__(constellation, *args, **kwargs) def add_options(parser): """ @@ -195,15 +181,7 @@ class qam_mod(generic_mod): class qam_demod(generic_demod): - def __init__(self, constellation_points=_def_constellation_points, - samples_per_symbol=_def_samples_per_symbol, - 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, - verbose=_def_verbose, - log=_def_log): + def __init__(self, constellation_points=_def_constellation_points, *args, **kwargs): """ Hierarchical block for RRC-filtered QAM modulation. @@ -232,12 +210,13 @@ class qam_demod(generic_demod): """ points = make_constellation(constellation_points) - constellation = gr.gr_constellation(points) + side = int(sqrt(constellation_points)) + assert(side * side == constellation_points) + width = 2.0/(side-1) + constellation = gr.constellation_sector(points, side, side, width, width) + #constellation = gr.constellation(points) - super(qam_demod, self).__init__(constellation, samples_per_symbol, - excess_bw, freq_alpha, timing_alpha, - timing_max_dev, phase_alpha, verbose, - log) + super(qam_demod, self).__init__(constellation, *args, **kwargs) def add_options(parser): """ |