GNU Radio 3.6.5 C++ API

digital_ofdm_frame_acquisition.h

Go to the documentation of this file.
00001 /* -*- c++ -*- */
00002 /*
00003  * Copyright 2006,2007,2011 Free Software Foundation, Inc.
00004  * 
00005  * This file is part of GNU Radio
00006  * 
00007  * GNU Radio is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 3, or (at your option)
00010  * any later version.
00011  * 
00012  * GNU Radio is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  * 
00017  * You should have received a copy of the GNU General Public License
00018  * along with GNU Radio; see the file COPYING.  If not, write to
00019  * the Free Software Foundation, Inc., 51 Franklin Street,
00020  * Boston, MA 02110-1301, USA.
00021  */
00022 
00023 #ifndef INCLUDED_DIGITAL_OFDM_FRAME_ACQUISITION_H
00024 #define INCLUDED_DIGITAL_OFDM_FRAME_ACQUISITION_H
00025 
00026 #include <digital_api.h>
00027 #include <gr_block.h>
00028 #include <vector>
00029 
00030 class digital_ofdm_frame_acquisition;
00031 typedef boost::shared_ptr<digital_ofdm_frame_acquisition> digital_ofdm_frame_acquisition_sptr;
00032 
00033 digital_ofdm_frame_acquisition_sptr 
00034 DIGITAL_API digital_make_ofdm_frame_acquisition (unsigned int occupied_carriers, unsigned int fft_length,
00035                                 unsigned int cplen,
00036                                 const std::vector<gr_complex> &known_symbol, 
00037                                 unsigned int max_fft_shift_len=10);
00038 
00039 /*!
00040  * \brief take a vector of complex constellation points in from an FFT
00041  * and performs a correlation and equalization.
00042  * \ingroup ofdm_blk
00043  *
00044  * This block takes the output of an FFT of a received OFDM symbol and finds the 
00045  * start of a frame based on two known symbols. It also looks at the surrounding
00046  * bins in the FFT output for the correlation in case there is a large frequency
00047  * shift in the data. This block assumes that the fine frequency shift has already
00048  * been corrected and that the samples fall in the middle of one FFT bin.
00049  *
00050  * It then uses one of those known
00051  * symbols to estimate the channel response over all subcarriers and does a simple 
00052  * 1-tap equalization on all subcarriers. This corrects for the phase and amplitude
00053  * distortion caused by the channel.
00054  */
00055 
00056 class DIGITAL_API digital_ofdm_frame_acquisition : public gr_block
00057 {
00058   /*! 
00059    * \brief Build an OFDM correlator and equalizer.
00060    * \param occupied_carriers   The number of subcarriers with data in the received symbol
00061    * \param fft_length          The size of the FFT vector (occupied_carriers + unused carriers)
00062    * \param cplen               The length of the cycle prefix
00063    * \param known_symbol        A vector of complex numbers representing a known symbol at the
00064    *                            start of a frame (usually a BPSK PN sequence)
00065    * \param max_fft_shift_len   Set's the maximum distance you can look between bins for correlation
00066    */
00067   friend DIGITAL_API digital_ofdm_frame_acquisition_sptr
00068   digital_make_ofdm_frame_acquisition (unsigned int occupied_carriers, unsigned int fft_length,
00069                                   unsigned int cplen,
00070                                   const std::vector<gr_complex> &known_symbol, 
00071                                   unsigned int max_fft_shift_len);
00072   
00073 protected:
00074   digital_ofdm_frame_acquisition (unsigned int occupied_carriers, unsigned int fft_length,
00075                              unsigned int cplen,
00076                              const std::vector<gr_complex> &known_symbol, 
00077                              unsigned int max_fft_shift_len);
00078   
00079  private:
00080   unsigned char slicer(gr_complex x);
00081   void correlate(const gr_complex *symbol, int zeros_on_left);
00082   void calculate_equalizer(const gr_complex *symbol, int zeros_on_left);
00083   gr_complex coarse_freq_comp(int freq_delta, int count);
00084   
00085   unsigned int d_occupied_carriers;  // !< \brief number of subcarriers with data
00086   unsigned int d_fft_length;         // !< \brief length of FFT vector
00087   unsigned int d_cplen;              // !< \brief length of cyclic prefix in samples
00088   unsigned int d_freq_shift_len;     // !< \brief number of surrounding bins to look at for correlation
00089   std::vector<gr_complex> d_known_symbol; // !< \brief known symbols at start of frame
00090   std::vector<float> d_known_phase_diff; // !< \brief factor used in correlation from known symbol
00091   std::vector<float> d_symbol_phase_diff; // !< \brief factor used in correlation from received symbol
00092   std::vector<gr_complex> d_hestimate;  // !< channel estimate
00093   int d_coarse_freq;             // !< \brief search distance in number of bins
00094   unsigned int d_phase_count;           // !< \brief accumulator for coarse freq correction
00095   float d_snr_est;                      // !< an estimation of the signal to noise ratio
00096 
00097   gr_complex *d_phase_lut;  // !< look-up table for coarse frequency compensation
00098 
00099   void forecast(int noutput_items, gr_vector_int &ninput_items_required);
00100 
00101  public:
00102   /*!
00103    * \brief Return an estimate of the SNR of the channel
00104    */
00105   float snr() { return d_snr_est; }
00106 
00107   ~digital_ofdm_frame_acquisition(void);
00108   int general_work(int noutput_items,
00109                    gr_vector_int &ninput_items,
00110                    gr_vector_const_void_star &input_items,
00111                    gr_vector_void_star &output_items);
00112 };
00113 
00114 
00115 #endif