commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r7246 - in gnuradio/branches/developers/trondeau/ofdm2


From: trondeau
Subject: [Commit-gnuradio] r7246 - in gnuradio/branches/developers/trondeau/ofdm2: gnuradio-core/src/lib/general gnuradio-core/src/python/gnuradio/blks2impl gnuradio-examples/python/ofdm
Date: Sun, 23 Dec 2007 10:44:30 -0700 (MST)

Author: trondeau
Date: 2007-12-23 10:44:30 -0700 (Sun, 23 Dec 2007)
New Revision: 7246

Added:
   
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_frame_acquisition.cc
   
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_frame_acquisition.h
   
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_frame_acquisition.i
Removed:
   
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_correlator.cc
   
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_correlator.h
   
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_correlator.i
Modified:
   
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/lib/general/Makefile.am
   
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/lib/general/general.i
   
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/python/gnuradio/blks2impl/ofdm.py
   
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/python/gnuradio/blks2impl/ofdm_receiver.py
   
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-examples/python/ofdm/gr_plot_ofdm.py
   
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-examples/python/ofdm/plot_ofdm.m
Log:
changing name of ofdm_correlator to ofdm_frame_acquisition to better reflect 
its purpose.

Modified: 
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/lib/general/Makefile.am
===================================================================
--- 
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/lib/general/Makefile.am
       2007-12-23 17:35:18 UTC (rev 7245)
+++ 
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/lib/general/Makefile.am
       2007-12-23 17:44:30 UTC (rev 7246)
@@ -96,7 +96,7 @@
        gr_nop.cc                       \
        gr_null_sink.cc                 \
        gr_null_source.cc               \
-       gr_ofdm_correlator.cc           \
+       gr_ofdm_frame_acquisition.cc    \
         gr_ofdm_cyclic_prefixer.cc      \
         gr_ofdm_demapper_vcb.cc         \
         gr_ofdm_mapper_bcv.cc           \
@@ -240,7 +240,7 @@
        gr_nop.h                        \
        gr_null_sink.h                  \
        gr_null_source.h                \
-       gr_ofdm_correlator.h            \
+       gr_ofdm_frame_acquisition.h     \
         gr_ofdm_cyclic_prefixer.h       \
         gr_ofdm_demapper_vcb.h          \
         gr_ofdm_mapper_bcv.h            \
@@ -385,7 +385,7 @@
        gr_nop.i                        \
        gr_null_sink.i                  \
        gr_null_source.i                \
-       gr_ofdm_correlator.i            \
+       gr_ofdm_frame_acquisition.i     \
         gr_ofdm_cyclic_prefixer.i       \
         gr_ofdm_demapper_vcb.i          \
         gr_ofdm_mapper_bcv.i            \

Modified: 
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/lib/general/general.i
===================================================================
--- 
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/lib/general/general.i
 2007-12-23 17:35:18 UTC (rev 7245)
+++ 
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/lib/general/general.i
 2007-12-23 17:44:30 UTC (rev 7246)
@@ -93,7 +93,7 @@
 #include <gr_probe_avg_mag_sqrd_cf.h>
 #include <gr_probe_avg_mag_sqrd_f.h>
 #include <gr_probe_signal_f.h>
-#include <gr_ofdm_correlator.h>
+#include <gr_ofdm_frame_acquisition.h>
 #include <gr_ofdm_cyclic_prefixer.h>
 #include <gr_ofdm_bpsk_demapper.h>
 #include <gr_ofdm_mapper_bcv.h>
@@ -202,7 +202,7 @@
 %include "gr_probe_avg_mag_sqrd_cf.i"
 %include "gr_probe_avg_mag_sqrd_f.i"
 %include "gr_probe_signal_f.i"
-%include "gr_ofdm_correlator.i"
+%include "gr_ofdm_frame_acquisition.i"
 %include "gr_ofdm_cyclic_prefixer.i"
 %include "gr_ofdm_bpsk_demapper.i"
 %include "gr_ofdm_mapper_bcv.i"

Deleted: 
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_correlator.cc

Deleted: 
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_correlator.h

Deleted: 
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_correlator.i

Copied: 
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_frame_acquisition.cc
 (from rev 7059, 
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_correlator.cc)
===================================================================
--- 
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_frame_acquisition.cc
                              (rev 0)
+++ 
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_frame_acquisition.cc
      2007-12-23 17:44:30 UTC (rev 7246)
@@ -0,0 +1,231 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006, 2007 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gr_ofdm_frame_acquisition.h>
+#include <gr_io_signature.h>
+#include <gr_expj.h>
+
+#define VERBOSE 0
+#define M_TWOPI (2*M_PI)
+#define MAX_NUM_SYMBOLS 1000
+
+gr_ofdm_frame_acquisition_sptr
+gr_make_ofdm_frame_acquisition (unsigned int occupied_carriers, unsigned int 
fft_length, 
+                               unsigned int cplen,
+                               const std::vector<gr_complex> &known_symbol1, 
+                               const std::vector<gr_complex> &known_symbol2,
+                               unsigned int max_fft_shift_len)
+{
+  return gr_ofdm_frame_acquisition_sptr (new gr_ofdm_frame_acquisition 
(occupied_carriers, fft_length, cplen,
+                                                                       
known_symbol1, known_symbol2,
+                                                                       
max_fft_shift_len));
+}
+
+gr_ofdm_frame_acquisition::gr_ofdm_frame_acquisition (unsigned 
occupied_carriers, unsigned int fft_length, 
+                                                     unsigned int cplen,
+                                                     const 
std::vector<gr_complex> &known_symbol1, 
+                                                     const 
std::vector<gr_complex> &known_symbol2,
+                                                     unsigned int 
max_fft_shift_len)
+  : gr_block ("ofdm_frame_acquisition",
+             gr_make_io_signature (1, 1, sizeof(gr_complex)*fft_length),
+             gr_make_io_signature2 (2, 2, 
sizeof(gr_complex)*occupied_carriers, sizeof(char))),
+    d_occupied_carriers(occupied_carriers),
+    d_fft_length(fft_length),
+    d_cplen(cplen),
+    d_freq_shift_len(max_fft_shift_len),
+    d_known_symbol1(known_symbol1),
+    d_known_symbol2(known_symbol2),
+    d_coarse_freq(0),
+    d_phase_count(0)
+{
+  d_diff_corr_factor.resize(d_occupied_carriers);
+  d_hestimate.resize(d_occupied_carriers);
+
+  std::vector<gr_complex>::iterator i1, i2;
+
+  unsigned int i = 0, j = 0;
+  gr_complex one(1.0, 0.0);
+  for(i1 = d_known_symbol1.begin(), i2 = d_known_symbol2.begin(); i1 != 
d_known_symbol1.end(); i1++, i2++) {
+    d_diff_corr_factor[i] = one / ((*i1) * conj(*i2));
+    i++;
+  }
+  
+  d_phase_lut = new gr_complex[(2*d_freq_shift_len+1) * MAX_NUM_SYMBOLS];
+  for(i = 0; i <= 2*d_freq_shift_len; i++) {
+    for(j = 0; j < MAX_NUM_SYMBOLS; j++) {
+      d_phase_lut[j + i*MAX_NUM_SYMBOLS] =  
gr_expj(-M_TWOPI*d_cplen/d_fft_length*(i-d_freq_shift_len)*j);
+    }
+  }
+}
+
+gr_ofdm_frame_acquisition::~gr_ofdm_frame_acquisition(void)
+{
+  delete [] d_phase_lut;
+}
+
+void
+gr_ofdm_frame_acquisition::forecast (int noutput_items, gr_vector_int 
&ninput_items_required)
+{
+  unsigned ninputs = ninput_items_required.size ();
+  for (unsigned i = 0; i < ninputs; i++)
+    ninput_items_required[i] = 2;
+}
+
+gr_complex
+gr_ofdm_frame_acquisition::coarse_freq_comp(int freq_delta, int symbol_count)
+{
+  //  return 
gr_complex(cos(-M_TWOPI*freq_delta*d_cplen/d_fft_length*symbol_count),
+  //       sin(-M_TWOPI*freq_delta*d_cplen/d_fft_length*symbol_count));
+
+  return gr_expj(-M_TWOPI*freq_delta*d_cplen/d_fft_length*symbol_count);
+
+  //assert(d_freq_shift_len + freq_delta >= 0);
+  //assert(symbol_count <= MAX_NUM_SYMBOLS);
+
+  //return d_phase_lut[MAX_NUM_SYMBOLS * (d_freq_shift_len + freq_delta) + 
symbol_count];
+}
+
+bool
+gr_ofdm_frame_acquisition::correlate(const gr_complex *previous, const 
gr_complex *current, 
+                                    int zeros_on_left)
+{
+  unsigned int i = 0;
+  int search_delta = 0;
+  bool found = false;
+
+  gr_complex h_sqrd = gr_complex(0.0,0.0);
+  float power = 0.0F;
+
+  while(!found && ((unsigned)abs(search_delta) <= d_freq_shift_len)) {
+    h_sqrd = gr_complex(0.0,0.0);
+    power = 0.0F;
+
+    for(i = 0; i < d_occupied_carriers; i++) {
+      h_sqrd = h_sqrd + previous[i+zeros_on_left+search_delta] * 
+       
conj(coarse_freq_comp(search_delta,1)*current[i+zeros_on_left+search_delta]) * 
+       d_diff_corr_factor[i];
+      
+      power = power + norm(current[i+zeros_on_left+search_delta]); // No need 
to do coarse freq here
+    }
+    
+#if VERBOSE
+    printf("bin %d\th_sqrd = ( %f, %f )\t power = %f\t real(h)/p = %f\t angle 
= %f\n", 
+          search_delta, h_sqrd.real(), h_sqrd.imag(), power, 
h_sqrd.real()/power, arg(h_sqrd)); 
+#endif      
+    // FIXME: Look at h_sqrd.read() > power
+    if((h_sqrd.real() > 0.82*power) && (h_sqrd.real() < 1.1 * power)) {
+      found = true;
+      //printf("search delta: %d\n", search_delta);
+      d_coarse_freq = search_delta;
+      d_phase_count = 1;
+      //d_snr_est = 10*log10(power/(power-h_sqrd.real()));
+
+      // check for low noise power; sets maximum SNR at 100 dB
+      if(fabs(h_sqrd.imag()) <= 1e-12) {
+       d_snr_est = 100.0;
+      }
+      else {
+       d_snr_est = 10*log10(fabs(h_sqrd.real()/h_sqrd.imag()));
+      }
+
+#if VERBOSE
+      printf("CORR: Found, bin %d\tSNR Est %f dB\tcorr power fraction %f\n", 
+             search_delta, d_snr_est, h_sqrd.real()/power);
+#endif
+
+      // 
search_delta,10*log10(h_sqrd.real()/fabs(h_sqrd.imag())),h_sqrd.real()/power);
+      break;
+    }
+    else {
+      if(search_delta <= 0)
+       search_delta = (-search_delta) + 2;
+      else
+       search_delta = -search_delta;
+    }
+  }
+  return found;
+}
+
+void
+gr_ofdm_frame_acquisition::calculate_equalizer(const gr_complex *previous, 
const gr_complex *current, 
+                                       int zeros_on_left)
+{
+  unsigned int i=0;
+
+  for(i = 0; i < d_occupied_carriers; i++) {
+    // FIXME possibly add small epsilon in divisor to protect from div 0
+    //d_hestimate[i] = 0.5F * (d_known_symbol1[i] / previous[i+zeros_on_left] +
+    //                     d_known_symbol2[i] / 
(coarse_freq_comp(d_coarse_freq,1)*
+    //                                           
current[i+zeros_on_left+d_coarse_freq]));
+    d_hestimate[i] = 0.5F * (d_known_symbol1[i] / 
previous[i+zeros_on_left+d_coarse_freq] +
+                            d_known_symbol2[i] / 
(coarse_freq_comp(d_coarse_freq,1)*
+                                                  
current[i+zeros_on_left+d_coarse_freq]));
+  }
+#if VERBOSE
+  fprintf(stderr, "\n");
+#endif
+}
+
+int
+gr_ofdm_frame_acquisition::general_work(int noutput_items,
+                                       gr_vector_int &ninput_items,
+                                       gr_vector_const_void_star &input_items,
+                                       gr_vector_void_star &output_items)
+{
+  const gr_complex *in = (const gr_complex *)input_items[0];
+  const gr_complex *previous = &in[0];
+  const gr_complex *current = &in[d_fft_length];
+
+  gr_complex *out = (gr_complex *) output_items[0];
+  char *sig = (char *) output_items[1];
+  
+  unsigned int i=0;
+
+  int unoccupied_carriers = d_fft_length - d_occupied_carriers;
+  int zeros_on_left = (int)ceil(unoccupied_carriers/2.0);
+
+  bool corr = correlate(previous, current, zeros_on_left);
+  if(corr) {
+    calculate_equalizer(previous, current, zeros_on_left);
+    sig[0] = 1;
+  }
+  else {
+    sig[0] = 0;
+  }
+
+  for(i = 0; i < d_occupied_carriers; i++) {
+    out[i] = 
d_hestimate[i]*coarse_freq_comp(d_coarse_freq,d_phase_count)*current[i+zeros_on_left+d_coarse_freq];
+  }
+  
+
+  d_phase_count++;
+  if(d_phase_count == MAX_NUM_SYMBOLS) {
+    d_phase_count = 1;
+  }
+
+  consume_each(1);
+  return 1;
+}

Copied: 
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_frame_acquisition.h
 (from rev 7059, 
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_correlator.h)
===================================================================
--- 
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_frame_acquisition.h
                               (rev 0)
+++ 
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_frame_acquisition.h
       2007-12-23 17:44:30 UTC (rev 7246)
@@ -0,0 +1,121 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006, 2007 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_OFDM_FRAME_ACQUISITION_H
+#define INCLUDED_GR_OFDM_FRAME_ACQUISITION_H
+
+
+#include <gr_block.h>
+#include <vector>
+
+class gr_ofdm_frame_acquisition;
+typedef boost::shared_ptr<gr_ofdm_frame_acquisition> 
gr_ofdm_frame_acquisition_sptr;
+
+gr_ofdm_frame_acquisition_sptr 
+gr_make_ofdm_frame_acquisition (unsigned int occupied_carriers, unsigned int 
fft_length,
+                               unsigned int cplen,
+                               const std::vector<gr_complex> &known_symbol1, 
+                               const std::vector<gr_complex> &known_symbol2,
+                               unsigned int max_fft_shift_len=10);
+
+/*!
+ * \brief take a vector of complex constellation points in from an FFT
+ * and performs a correlation and equalization.
+ * \inblock blocks
+ *
+ * This block takes the output of an FFT of a received OFDM symbol and finds 
the 
+ * start of a frame based on two known symbols. It also looks at the 
surrounding
+ * bins in the FFT output for the correlation in case there is a large 
frequency
+ * shift in the data. This block assumes that the fine frequency shift has 
already
+ * been corrected and that the samples fall in the middle of one FFT bin.
+ *
+ * It then uses one of those known
+ * symbols to estimate the channel response over all subcarriers and does a 
simple 
+ * 1-tap equalization on all subcarriers. This corrects for the phase and 
amplitude
+ * distortion caused by the channel.
+ */
+
+class gr_ofdm_frame_acquisition : public gr_block
+{
+  /*! 
+   * \brief Build an OFDM correlator and equalizer.
+   * \param occupied_carriers   The number of subcarriers with data in the 
received symbol
+   * \param fft_length          The size of the FFT vector (occupied_carriers 
+ unused carriers)
+   * \param known_symbol1       A vector of complex numbers representing a 
known symbol at the
+   *                            start of a frame (usually a BPSK PN sequence)
+   * \param known_symbol2       A vector of complex numbers representing a 
known symbol at the
+   *                            start of a frame after known_symbol1 (usually 
a BPSK PN sequence). 
+   *                            Both of these start symbols are differentially 
correlated to compensate
+   *                            for phase changes between symbols. 
+   * \param max_fft_shift_len   Set's the maximum distance you can look 
between bins for correlation
+   */
+  friend gr_ofdm_frame_acquisition_sptr
+  gr_make_ofdm_frame_acquisition (unsigned int occupied_carriers, unsigned int 
fft_length,
+                                 unsigned int cplen,
+                                 const std::vector<gr_complex> &known_symbol1, 
+                                 const std::vector<gr_complex> &known_symbol2,
+                                 unsigned int max_fft_shift_len);
+  
+protected:
+  gr_ofdm_frame_acquisition (unsigned int occupied_carriers, unsigned int 
fft_length,
+                            unsigned int cplen,
+                            const std::vector<gr_complex> &known_symbol1, 
+                            const std::vector<gr_complex> &known_symbol2,
+                            unsigned int max_fft_shift_len);
+  
+ private:
+  unsigned char slicer(gr_complex x);
+  bool correlate(const gr_complex *previous, const gr_complex *current, int 
zeros_on_left);
+  void calculate_equalizer(const gr_complex *previous, 
+                          const gr_complex *current, int zeros_on_left);
+  gr_complex coarse_freq_comp(int freq_delta, int count);
+  
+  unsigned int d_occupied_carriers;  // !< \brief number of subcarriers with 
data
+  unsigned int d_fft_length;         // !< \brief length of FFT vector
+  unsigned int d_cplen;              // !< \brief length of cyclic prefix in 
samples
+  unsigned int d_freq_shift_len;     // !< \brief number of surrounding bins 
to look at for correlation
+  std::vector<gr_complex> d_known_symbol1, d_known_symbol2; // !< \brief known 
symbols at start of frame
+  std::vector<gr_complex> d_diff_corr_factor; // !< \brief factor used in 
correlation
+  std::vector<gr_complex> d_hestimate;  // !< channel estimate
+  signed int d_coarse_freq;             // !< \brief search distance in number 
of bins
+  unsigned int d_phase_count;           // !< \brief accumulator for coarse 
freq correction
+  float d_snr_est;                      // !< an estimation of the signal to 
noise ratio
+
+  gr_complex *d_phase_lut;  // !< look-up table for coarse frequency 
compensation
+
+  void forecast(int noutput_items, gr_vector_int &ninput_items_required);
+
+ public:
+  /*!
+   * \brief Return an estimate of the SNR of the channel
+   */
+  float snr() { return d_snr_est; }
+
+  ~gr_ofdm_frame_acquisition(void);
+  int general_work(int noutput_items,
+                  gr_vector_int &ninput_items,
+                  gr_vector_const_void_star &input_items,
+                  gr_vector_void_star &output_items);
+};
+
+
+#endif

Copied: 
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_frame_acquisition.i
 (from rev 7059, 
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_correlator.i)
===================================================================
--- 
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_frame_acquisition.i
                               (rev 0)
+++ 
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_frame_acquisition.i
       2007-12-23 17:44:30 UTC (rev 7246)
@@ -0,0 +1,51 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006, 2007 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 <vector>
+
+GR_SWIG_BLOCK_MAGIC(gr,ofdm_frame_acquisition);
+
+gr_ofdm_frame_acquisition_sptr 
+gr_make_ofdm_frame_acquisition (unsigned int occupied_carriers, 
+                               unsigned int fft_length,
+                               unsigned int cplen,
+                               const std::vector<gr_complex> &known_symbol1, 
+                               const std::vector<gr_complex> &known_symbol2,
+                               unsigned int max_fft_shift_len=4);
+
+class gr_ofdm_frame_acquisition : public gr_sync_decimator
+{
+ protected:
+  gr_ofdm_frame_acquisition (unsigned int occupied_carriers,
+                            unsigned int fft_length,
+                            unsigned int cplen,
+                            const std::vector<gr_complex> &known_symbol1, 
+                            const std::vector<gr_complex> &known_symbol2,
+                            unsigned int max_fft_shift_len);
+
+ public:
+  float snr() { return d_snr_est; }
+  int general_work(int noutput_items,
+                  gr_vector_int &ninput_items,
+                  gr_vector_const_void_star &input_items,
+                  gr_vector_void_star &output_items);
+};

Modified: 
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/python/gnuradio/blks2impl/ofdm.py
===================================================================
--- 
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/python/gnuradio/blks2impl/ofdm.py
     2007-12-23 17:35:18 UTC (rev 7245)
+++ 
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/python/gnuradio/blks2impl/ofdm.py
     2007-12-23 17:44:30 UTC (rev 7246)
@@ -249,9 +249,9 @@
         self.connect(self.ofdm_recv.chan_filt, self)
 
         if options.log:
-            self.connect(self.ofdm_demod, gr.file_sink(gr.sizeof_gr_complex, 
"ofdm_frame_sink_c.dat"))
+            self.connect(self.ofdm_demod, 
gr.file_sink(gr.sizeof_gr_complex*self._occupied_tones, 
"ofdm_frame_sink_c.dat"))
         else:
-            self.connect(self.ofdm_demod, gr.null_sink(gr.sizeof_gr_complex))
+            self.connect(self.ofdm_demod, 
gr.null_sink(gr.sizeof_gr_complex*self._occupied_tones))
 
         if options.verbose:
             self._print_verbage()

Modified: 
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/python/gnuradio/blks2impl/ofdm_receiver.py
===================================================================
--- 
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/python/gnuradio/blks2impl/ofdm_receiver.py
    2007-12-23 17:35:18 UTC (rev 7245)
+++ 
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-core/src/python/gnuradio/blks2impl/ofdm_receiver.py
    2007-12-23 17:44:30 UTC (rev 7246)
@@ -81,16 +81,17 @@
             self.ofdm_sync = ofdm_sync_pnac(fft_length, cp_length, ks[0])
                         
         self.fft_demod = gr.fft_vcc(fft_length, True, win, True)
-        self.ofdm_corr = gr.ofdm_correlator(occupied_tones, fft_length,
-                                            cp_length, ks[1], ks[2])
+        self.ofdm_frame_acq = gr.ofdm_frame_acquisition(occupied_tones, 
fft_length,
+                                                        cp_length, ks[1], 
ks[2])
 
         self.connect(self, self.chan_filt)
-        self.connect(self.chan_filt, self.ofdm_sync, self.fft_demod, 
self.ofdm_corr)
-        self.connect((self.ofdm_corr,0), (self,0))
-        self.connect((self.ofdm_corr,1), (self,1))
+        self.connect(self.chan_filt, self.ofdm_sync, self.fft_demod, 
self.ofdm_frame_acq)
+        self.connect((self.ofdm_frame_acq,0), (self,0))
+        self.connect((self.ofdm_frame_acq,1), (self,1))
 
         if logging:
             self.connect(self.chan_filt, gr.file_sink(gr.sizeof_gr_complex, 
"chan_filt_c.dat"))
             self.connect(self.fft_demod, 
gr.file_sink(gr.sizeof_gr_complex*fft_length, "fft_out_c.dat"))
-            self.connect(self.ofdm_corr, 
gr.file_sink(gr.sizeof_gr_complex*occupied_tones, "ofdm_corr_out_c.dat"))
-            self.connect((self.ofdm_corr,1), gr.file_sink(1, 
"found_corr_b.dat"))
+            self.connect(self.ofdm_frame_acq,
+                         gr.file_sink(gr.sizeof_gr_complex*occupied_tones, 
"ofdm_frame_acq_c.dat"))
+            self.connect((self.ofdm_frame_acq,1), gr.file_sink(1, 
"found_corr_b.dat"))

Modified: 
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-examples/python/ofdm/gr_plot_ofdm.py
===================================================================
--- 
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-examples/python/ofdm/gr_plot_ofdm.py
   2007-12-23 17:35:18 UTC (rev 7245)
+++ 
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-examples/python/ofdm/gr_plot_ofdm.py
   2007-12-23 17:44:30 UTC (rev 7246)
@@ -33,10 +33,12 @@
 
 class draw_constellation:
     def __init__(self, options):
-        corr_file = "ofdm_corr_out_c.dat"
-        fft_file  = "fft_out_c.dat"
+        derot_file = "ofdm_frame_sink_c.dat"
+        acq_file = "ofdm_frame_acq_c.dat"
+        fft_file = "fft_out_c.dat"
 
-        self.h_corr_file = open(corr_file, "r")
+        self.h_derot_file = open(derot_file, "r")
+        self.h_acq_file = open(acq_file, "r")
         self.h_fft_file = open(fft_file, "r")
 
         self.occ_tones = options.occ_tones
@@ -76,18 +78,21 @@
     def get_data(self):
         self.text_sym.set_text("Symbol: %d" % (self.symbol))
 
-        corr_data = scipy.fromfile(self.h_corr_file, dtype=scipy.complex64, 
count=self.occ_tones)
+        derot_data = scipy.fromfile(self.h_derot_file, dtype=scipy.complex64, 
count=self.occ_tones)
+        acq_data = scipy.fromfile(self.h_acq_file, dtype=scipy.complex64, 
count=self.occ_tones)
         fft_data = scipy.fromfile(self.h_fft_file, dtype=scipy.complex64, 
count=self.fft_size)
-        if(len(corr_data) == 0):
+        if(len(acq_data) == 0):
             print "End of File"
         else:
-            self.corr_data_reals = [r.real for r in corr_data]
-            self.corr_data_imags = [i.imag for i in corr_data]
+            self.acq_data_reals = [r.real for r in acq_data]
+            self.acq_data_imags = [i.imag for i in acq_data]
+            self.derot_data_reals = [r.real for r in derot_data]
+            self.derot_data_imags = [i.imag for i in derot_data]
 
             self.unequalized_angle = [math.atan2(x.imag, x.real) for x in 
fft_data]
-            self.equalized_angle = [math.atan2(x.imag, x.real) for x in 
corr_data]
+            self.equalized_angle = [math.atan2(x.imag, x.real) for x in 
acq_data]
 
-            self.time = [i*(1/self.sample_rate) for i in range(len(corr_data))]
+            self.time = [i*(1/self.sample_rate) for i in range(len(acq_data))]
             ffttime = [i*(1/self.sample_rate) for i in range(len(fft_data))]
 
             self.freq = self.get_freq(ffttime, self.sample_rate)
@@ -102,7 +107,7 @@
         return freq
 
     def make_plots(self):
-        self.h_corr_file.seek(16*self.symbol*self.occ_tones, 1)
+        self.h_acq_file.seek(16*self.symbol*self.occ_tones, 1)
         self.h_fft_file.seek(16*self.symbol*self.fft_size, 1)
 
         self.get_data()
@@ -112,7 +117,8 @@
         self.sp_const.set_title(("Constellation"), 
fontsize=self.title_font_size, fontweight="bold")
         self.sp_const.set_xlabel("Inphase", fontsize=self.label_font_size, 
fontweight="bold")
         self.sp_const.set_ylabel("Qaudrature", fontsize=self.label_font_size, 
fontweight="bold")
-        self.plot_const = plot(self.corr_data_reals, self.corr_data_imags, 
'bo')
+        self.plot_const = plot(self.acq_data_reals, self.acq_data_imags, 'bo')
+        self.plot_const += plot(self.derot_data_reals, self.derot_data_imags, 
'ro')
         self.sp_const.axis([-2, 2, -2, 2])
 
         # Subplot: unequalized angle
@@ -149,10 +155,11 @@
         self.sp_uneq.set_ylim([-4, 4])
 
         #self.sp_iq.axis([min(self.time), max(self.time),
-        #                 1.5*min([min(self.corr_data_reals), 
min(self.corr_data_imags)]),
-        #                 1.5*max([max(self.corr_data_reals), 
max(self.corr_data_imags)])])
+        #                 1.5*min([min(self.acq_data_reals), 
min(self.acq_data_imags)]),
+        #                 1.5*max([max(self.acq_data_reals), 
max(self.acq_data_imags)])])
 
-        self.plot_const[0].set_data([self.corr_data_reals, 
self.corr_data_imags])
+        self.plot_const[0].set_data([self.acq_data_reals, self.acq_data_imags])
+        self.plot_const[1].set_data([self.derot_data_reals, 
self.derot_data_imags])
         self.sp_const.axis([-2, 2, -2, 2])
 
         self.plot_fft[0].set_data([self.freq, self.fft_data])
@@ -195,11 +202,11 @@
     def step_backward(self):
         # Step back in file position
         self.symbol -= 1
-        if(self.h_corr_file.tell() >= 16*self.occ_tones):
-            self.h_corr_file.seek(-16*self.occ_tones, 1)
+        if(self.h_acq_file.tell() >= 16*self.occ_tones):
+            self.h_acq_file.seek(-16*self.occ_tones, 1)
         else:
             self.symbol = 0
-            self.h_corr_file.seek(-self.h_corr_file.tell(),1)
+            self.h_acq_file.seek(-self.h_acq_file.tell(),1)
 
         if(self.h_fft_file.tell() >= 16*self.fft_size):
             self.h_fft_file.seek(-16*self.fft_size, 1)

Modified: 
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-examples/python/ofdm/plot_ofdm.m
===================================================================
--- 
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-examples/python/ofdm/plot_ofdm.m
       2007-12-23 17:35:18 UTC (rev 7245)
+++ 
gnuradio/branches/developers/trondeau/ofdm2/gnuradio-examples/python/ofdm/plot_ofdm.m
       2007-12-23 17:44:30 UTC (rev 7246)
@@ -1,6 +1,6 @@
 function plot_ofdm(fft_size, occ_tones)
 
-ofdm = read_complex_binary('ofdm_corr_out_c.dat');
+ofdm = read_complex_binary('ofdm_frame_acq_c.dat');
 ofdm_split = split_vect(ofdm, occ_tones);
 
 ofdm_derot = read_complex_binary('ofdm_frame_sink_c.dat');





reply via email to

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