Under extreme circumstances, optfir might never produce an answer (atten>300), so...
[debian/gnuradio] / gnuradio-core / src / python / gnuradio / blks2impl / ofdm_sync_pn.py
index 0ec22ccedbef52ca4422e54d5db9264d2289ce3f..05b1de2e19a48ff5b00e8f63609df07f3fad970b 100644 (file)
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 #
-# Copyright 2007 Free Software Foundation, Inc.
+# Copyright 2007,2008 Free Software Foundation, Inc.
 # 
 # This file is part of GNU Radio
 # 
@@ -35,16 +35,10 @@ class ofdm_sync_pn(gr.hier_block2):
         
        gr.hier_block2.__init__(self, "ofdm_sync_pn",
                                gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature
-                               gr.io_signature2(2, 2, gr.sizeof_gr_complex*fft_length, gr.sizeof_char)) # Output signature
+                                gr.io_signature2(2, 2, gr.sizeof_float, gr.sizeof_char)) # Output signature
 
-        # FIXME: when converting to hier_block2's, the output signature
-        # should be the output of the divider (the normalized peaks) and
-        # the angle value out of the sample and hold block
-            
         self.input = gr.add_const_cc(0)
 
-        symbol_length = fft_length + cp_length
-
         # PN Sync
 
         # Create a delay line
@@ -80,24 +74,14 @@ class ofdm_sync_pn(gr.hier_block2):
 
         self.sample_and_hold = gr.sample_and_hold_ff()
 
-        # Mix the signal with an NCO controlled by the sync loop
-        nco_sensitivity = -2.0/fft_length
-        self.nco = gr.frequency_modulator_fc(nco_sensitivity)
-        self.sigmix = gr.multiply_cc()
-
         #ML measurements input to sampler block and detect
-        #self.sub1 = gr.add_const_ff(-1)
-        #self.pk_detect = gr.peak_detector_fb(0.20, 0.20, 30, 0.001)
-        self.pk_detect = gr.peak_detector2_fb(9)
-        #self.pk_detect = gr.threshold_detector_fb(0.5)
-        self.regen = gr.regenerate_bb(symbol_length)
-
-        # FIXME: If sampler doesn't get proper input, it can completely
-        # stall the flowgraph.
-        self.sampler = gr.ofdm_sampler(fft_length,symbol_length)
+        self.sub1 = gr.add_const_ff(-1)
+        self.pk_detect = gr.peak_detector_fb(0.20, 0.20, 30, 0.001)
+        #self.pk_detect = gr.peak_detector2_fb(9)
 
         self.connect(self, self.input)
         
+        # Calculate the frequency offset from the correlation of the preamble
         self.connect(self.input, self.delay)
         self.connect(self.input, (self.corr,0))
         self.connect(self.delay, self.conjg)
@@ -106,12 +90,8 @@ class ofdm_sync_pn(gr.hier_block2):
         self.connect(self.moving_sum_filter, self.c2mag)
         self.connect(self.moving_sum_filter, self.angle)
         self.connect(self.angle, (self.sample_and_hold,0))
-        self.connect(self.sample_and_hold, self.nco)
-
-        self.connect(self.input, (self.sigmix,0))
-        self.connect(self.nco, (self.sigmix,1))
-        self.connect(self.sigmix, (self.sampler,0))
 
+        # Get the power of the input signal to normalize the output of the correlation
         self.connect(self.input, self.inputmag2, self.inputmovingsum)
         self.connect(self.inputmovingsum, (self.square,0))
         self.connect(self.inputmovingsum, (self.square,1))
@@ -123,14 +103,14 @@ class ofdm_sync_pn(gr.hier_block2):
         self.matched_filter = gr.fir_filter_fff(1,matched_filter_taps)
         self.connect(self.normalize, self.matched_filter)
         
-        #self.connect(self.matched_filter, self.sub1, self.pk_detect)
-        self.connect(self.matched_filter, self.pk_detect)
-        self.connect(self.pk_detect, self.regen)
-        self.connect(self.regen, (self.sampler,1))
+        self.connect(self.matched_filter, self.sub1, self.pk_detect)
+        #self.connect(self.matched_filter, self.pk_detect)
         self.connect(self.pk_detect, (self.sample_and_hold,1))
 
-        # Set output from sampler
-        self.connect(self.sampler, (self,0))
+        # Set output signals
+        #    Output 0: fine frequency correction value
+        #    Output 1: timing signal
+        self.connect(self.sample_and_hold, (self,0))
         self.connect(self.pk_detect, (self,1))
 
         if logging:
@@ -138,10 +118,6 @@ class ofdm_sync_pn(gr.hier_block2):
             self.connect(self.normalize, gr.file_sink(gr.sizeof_float, "ofdm_sync_pn-theta_f.dat"))
             self.connect(self.angle, gr.file_sink(gr.sizeof_float, "ofdm_sync_pn-epsilon_f.dat"))
             self.connect(self.pk_detect, gr.file_sink(gr.sizeof_char, "ofdm_sync_pn-peaks_b.dat"))
-            self.connect(self.regen, gr.file_sink(gr.sizeof_char, "ofdm_sync_pn-regen_b.dat"))
-            self.connect(self.sigmix, gr.file_sink(gr.sizeof_gr_complex, "ofdm_sync_pn-sigmix_c.dat"))
-            self.connect(self.sampler, gr.file_sink(gr.sizeof_gr_complex*fft_length, "ofdm_sync_pn-sampler_c.dat"))
             self.connect(self.sample_and_hold, gr.file_sink(gr.sizeof_float, "ofdm_sync_pn-sample_and_hold_f.dat"))
-            self.connect(self.nco, gr.file_sink(gr.sizeof_gr_complex, "ofdm_sync_pn-nco_c.dat"))
             self.connect(self.input, gr.file_sink(gr.sizeof_gr_complex, "ofdm_sync_pn-input_c.dat"))