commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 24/57: digital: use FFT filters for the cor


From: git
Subject: [Commit-gnuradio] [gnuradio] 24/57: digital: use FFT filters for the correlate_and_sync block.
Date: Wed, 21 May 2014 03:10:26 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

trondeau pushed a commit to branch master
in repository gnuradio.

commit 0b89872a91af16139a0ea7ea9a52723306209eff
Author: Tom Rondeau <address@hidden>
Date:   Fri Apr 18 17:26:18 2014 -0400

    digital: use FFT filters for the correlate_and_sync block.
    
    The known word is interpolated by sps, so it will almost always be a fairly 
large filter here. Using the FFT filter dramatically reduces the cost of this 
block.
---
 gr-digital/lib/correlate_and_sync_cc_impl.cc | 17 ++++++++++++-----
 gr-digital/lib/correlate_and_sync_cc_impl.h  | 16 +++++++---------
 2 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/gr-digital/lib/correlate_and_sync_cc_impl.cc 
b/gr-digital/lib/correlate_and_sync_cc_impl.cc
index fb3b99c..80aee56 100644
--- a/gr-digital/lib/correlate_and_sync_cc_impl.cc
+++ b/gr-digital/lib/correlate_and_sync_cc_impl.cc
@@ -74,8 +74,7 @@ namespace gr {
 
       d_center_first_symbol = (padding.size() + 0.5) * d_sps;
 
-      //d_filter = new kernel::fft_filter_ccc(1, d_symbols);
-      d_filter = new kernel::fir_filter_ccc(1, d_symbols);
+      d_filter = new kernel::fft_filter_ccc(1, d_symbols);
 
       set_history(d_filter->ntaps());
 
@@ -118,8 +117,7 @@ namespace gr {
       memcpy(out, in, sizeof(gr_complex)*noutput_items);
 
       // Calculate the correlation with the known symbol
-      //d_filter->filter(noutput_items, in, corr);
-      d_filter->filterN(corr, in, noutput_items);
+      d_filter->filter(noutput_items, in, corr);
 
       // Find the magnitude squared of the correlation
       std::vector<float> corr_mag(noutput_items);
@@ -139,9 +137,18 @@ namespace gr {
           double center = nom / den;
           center = (center - 2.0);
 
-          int index = i;
+          // Adjust the results of the fft filter by moving back the
+          // length of the filter offset by the number of sps.
+          int index = i - d_symbols.size() + d_sps + 1;
 
+          // Calculate the phase offset of the incoming signal; always
+          // adjust it based on the proper rotation of the expected
+          // known word; rotate by pi is the real part is < 0 since
+          // the atan doesn't understand the ambiguity.
           float phase = fast_atan2f(corr[index].imag(), corr[index].real());
+          if(corr[index].real() < 0.0)
+            phase += M_PI;
+
           add_item_tag(0, nitems_written(0) + index, pmt::intern("phase_est"),
                        pmt::from_double(phase), pmt::intern(alias()));
           add_item_tag(0, nitems_written(0) + index, pmt::intern("time_est"),
diff --git a/gr-digital/lib/correlate_and_sync_cc_impl.h 
b/gr-digital/lib/correlate_and_sync_cc_impl.h
index e9cc983..d95ec51 100644
--- a/gr-digital/lib/correlate_and_sync_cc_impl.h
+++ b/gr-digital/lib/correlate_and_sync_cc_impl.h
@@ -1,19 +1,19 @@
 /* -*- c++ -*- */
-/* 
+/*
  * Copyright 2013 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,
@@ -24,7 +24,6 @@
 #define INCLUDED_DIGITAL_CORRELATE_AND_SYNC_CC_IMPL_H
 
 #include <gnuradio/digital/correlate_and_sync_cc.h>
-#include <gnuradio/filter/fir_filter.h>
 #include <gnuradio/filter/fft_filter.h>
 
 using namespace gr::filter;
@@ -39,11 +38,10 @@ namespace gr {
       unsigned int d_sps;
       float d_center_first_symbol;
       float d_thresh;
-      kernel::fir_filter_ccc  *d_filter;
-      //kernel::fft_filter_ccc  *d_filter;
+      kernel::fft_filter_ccc  *d_filter;
 
       int d_last_index;
-      
+
     public:
       correlate_and_sync_cc_impl(const std::vector<gr_complex> &symbols,
                                  const std::vector<float> &filter,



reply via email to

[Prev in Thread] Current Thread [Next in Thread]