diff options
-rw-r--r-- | gr-digital/lib/digital_fll_band_edge_cc.cc | 72 | ||||
-rw-r--r-- | gr-digital/lib/digital_fll_band_edge_cc.h | 48 | ||||
-rw-r--r-- | gr-digital/swig/digital_fll_band_edge_cc.i | 20 |
3 files changed, 112 insertions, 28 deletions
diff --git a/gr-digital/lib/digital_fll_band_edge_cc.cc b/gr-digital/lib/digital_fll_band_edge_cc.cc index 4c4f5fbf2..70cb54351 100644 --- a/gr-digital/lib/digital_fll_band_edge_cc.cc +++ b/gr-digital/lib/digital_fll_band_edge_cc.cc @@ -75,18 +75,12 @@ digital_fll_band_edge_cc::digital_fll_band_edge_cc (float samps_per_sym, float r } d_filter_size = filter_size; - // Initialize loop bandwidth - if(bandwidth < 0) { - throw std::out_of_range ("digital_fll_band_edge_cc: invalid bandwidth. Must be >= 0."); - } - d_loop_bw = bandwidth; - // base this on the number of samples per symbol d_max_freq = M_TWOPI * (2.0/samps_per_sym); d_min_freq = -M_TWOPI * (2.0/samps_per_sym); // Set the damping factor for a critically damped system - d_damping = sqrt(2.0)/2.0; + d_damping = sqrtf(2.0f)/2.0f; // Set the bandwidth, which will then call update_gains() set_loop_bandwidth(bandwidth); @@ -103,6 +97,12 @@ digital_fll_band_edge_cc::~digital_fll_band_edge_cc () { } + +/******************************************************************* + SET FUNCTIONS +*******************************************************************/ + + void digital_fll_band_edge_cc::set_loop_bandwidth(float bw) { @@ -173,48 +173,92 @@ digital_fll_band_edge_cc::set_filter_size(int filter_size) design_filter(d_sps, d_rolloff, d_filter_size); } +void +digital_fll_band_edge_cc::set_frequency(float freq) +{ + if(freq > d_max_freq) + d_freq = d_min_freq; + else if(freq < d_min_freq) + d_freq = d_max_freq; + else + d_freq = freq; +} + +void +digital_fll_band_edge_cc::set_phase(float phase) +{ + d_phase = phase; + while(d_phase>M_TWOPI) + d_phase -= M_TWOPI; + while(d_phase<-M_TWOPI) + d_phase += M_TWOPI; +} + + +/******************************************************************* + GET FUNCTIONS +*******************************************************************/ + + float -digital_fll_band_edge_cc::get_loop_bandwidth() +digital_fll_band_edge_cc::get_loop_bandwidth() const { return d_loop_bw; } float -digital_fll_band_edge_cc::get_damping_factor() +digital_fll_band_edge_cc::get_damping_factor() const { return d_damping; } float -digital_fll_band_edge_cc::get_alpha() +digital_fll_band_edge_cc::get_alpha() const { return d_alpha; } float -digital_fll_band_edge_cc::get_beta() +digital_fll_band_edge_cc::get_beta() const { return d_beta; } float -digital_fll_band_edge_cc::get_samples_per_symbol() +digital_fll_band_edge_cc::get_samples_per_symbol() const { return d_sps; } float -digital_fll_band_edge_cc::get_rolloff() +digital_fll_band_edge_cc::get_rolloff() const { return d_rolloff; } int -digital_fll_band_edge_cc:: get_filter_size() +digital_fll_band_edge_cc:: get_filter_size() const { return d_filter_size; } +float +digital_fll_band_edge_cc::get_frequency() const +{ + return d_freq; +} + +float +digital_fll_band_edge_cc::get_phase() const +{ + return d_phase; +} + + +/******************************************************************* +*******************************************************************/ + + void digital_fll_band_edge_cc::update_gains() { diff --git a/gr-digital/lib/digital_fll_band_edge_cc.h b/gr-digital/lib/digital_fll_band_edge_cc.h index f59b9becd..496289d90 100644 --- a/gr-digital/lib/digital_fll_band_edge_cc.h +++ b/gr-digital/lib/digital_fll_band_edge_cc.h @@ -236,6 +236,30 @@ public: */ void set_filter_size(int filter_size); + /*! + * \brief Set the FLL's frequency. + * + * Set's the FLL's frequency. While this is normally updated by the + * inner loop of the algorithm, it could be useful to manually initialize, + * set, or reset this under certain circumstances. + * + * \param freq (float) new frequency + * + */ + void set_frequency(float freq); + + /*! + * \brief Set the FLL's phase. + * + * Set's the FLL's phase. While this is normally updated by the + * inner loop of the algorithm, it could be useful to manually initialize, + * set, or reset this under certain circumstances. + * + * \param phase (float) new phase + * + */ + void set_phase(float phase); + /******************************************************************* GET FUNCTIONS *******************************************************************/ @@ -243,37 +267,47 @@ public: /*! * \brief Returns the loop bandwidth */ - float get_loop_bandwidth(); + float get_loop_bandwidth() const; /*! * \brief Returns the loop damping factor */ - float get_damping_factor(); + float get_damping_factor() const; /*! * \brief Returns the loop gain alpha */ - float get_alpha(); + float get_alpha() const; /*! * \brief Returns the loop gain beta */ - float get_beta(); + float get_beta() const; /*! * \brief Returns the number of sampler per symbol used for the filter */ - float get_samples_per_symbol(); + float get_samples_per_symbol() const; /*! * \brief Returns the rolloff factor used for the filter */ - float get_rolloff(); + float get_rolloff() const; /*! * \brief Returns the number of taps of the filter */ - int get_filter_size(); + int get_filter_size() const; + + /*! + * \brief Get the FLL's frequency estimate + */ + float get_frequency() const; + + /*! + * \brief Get the FLL's phase estimate + */ + float get_phase() const; /*! * Print the taps to screen. diff --git a/gr-digital/swig/digital_fll_band_edge_cc.i b/gr-digital/swig/digital_fll_band_edge_cc.i index cb5f2395d..f022bc7e1 100644 --- a/gr-digital/swig/digital_fll_band_edge_cc.i +++ b/gr-digital/swig/digital_fll_band_edge_cc.i @@ -43,12 +43,18 @@ class digital_fll_band_edge_cc : public gr_sync_block void set_samples_per_symbol(float sps); void set_rolloff(float rolloff); void set_filter_size(int filter_size); - float get_loop_bandwidth(); - float get_damping_factor(); - float get_alpha(); - float get_beta(); - float get_samples_per_symbol(); - float get_rolloff(); - int get_filter_size(); + void set_frequency(float freq); + void set_phase(float phase); + + float get_loop_bandwidth() const; + float get_damping_factor() const; + float get_alpha() const; + float get_beta() const; + float get_samples_per_symbol() const; + float get_rolloff() const; + int get_filter_size() const; + float get_frequency() const; + float get_phase() const; + void print_taps(); }; |