diff options
author | trondeau <trondeau@221aa14e-8319-0410-a670-987f0aec2ac5> | 2008-04-15 17:06:46 +0000 |
---|---|---|
committer | trondeau <trondeau@221aa14e-8319-0410-a670-987f0aec2ac5> | 2008-04-15 17:06:46 +0000 |
commit | 3a2f0b7e9fedaa29dbce47fe5d0b61ac8135aefb (patch) | |
tree | db9a83d20a2b89f58a56f213092327c732529742 | |
parent | 87b7f14e965c86fbc024bc586cce0d73a3962785 (diff) |
Adjusting structure a bit to redistribute responsibilities. This does not change the behavior or performance at all. The sync. block only calculates the frequency and timing signals and now outputs the fine frequency adjustment signal from output 0 and the timing signal for the start of the packet from output 1.
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@8198 221aa14e-8319-0410-a670-987f0aec2ac5
3 files changed, 49 insertions, 49 deletions
diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/ofdm.py b/gnuradio-core/src/python/gnuradio/blks2impl/ofdm.py index cc260d8d7c..2663f7cf87 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/ofdm.py +++ b/gnuradio-core/src/python/gnuradio/blks2impl/ofdm.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2006,2007 Free Software Foundation, Inc. +# Copyright 2006,2007,2008 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -197,10 +197,11 @@ class ofdm_demod(gr.hier_block2): self._snr = options.snr # Use freq domain to get doubled-up known symbol for correlation in time domain + zeros_on_left = int(math.ceil((self._fft_length - self._occupied_tones)/2.0)) ksfreq = known_symbols_4512_3[0:self._occupied_tones] for i in range(len(ksfreq)): - if(i&1): - ksfreq[i] = 0 + if((zeros_on_left + i) & 1): + ksfreq[i] = 0 # hard-coded known symbols preambles = (ksfreq,) diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/ofdm_receiver.py b/gnuradio-core/src/python/gnuradio/blks2impl/ofdm_receiver.py index e6796d341c..0170c92d76 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/ofdm_receiver.py +++ b/gnuradio-core/src/python/gnuradio/blks2impl/ofdm_receiver.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2006, 2007 Free Software Foundation, Inc. +# Copyright 2006, 2007, 2008 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -62,7 +62,7 @@ class ofdm_receiver(gr.hier_block2): gr.hier_block2.__init__(self, "ofdm_receiver", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature2(2, 2, gr.sizeof_gr_complex*occupied_tones, gr.sizeof_char)) # Output signature - + bw = (float(occupied_tones) / float(fft_length)) / 2.0 tb = bw*0.08 chan_coeffs = gr.firdes.low_pass (1.0, # gain @@ -75,39 +75,56 @@ class ofdm_receiver(gr.hier_block2): win = [1 for i in range(fft_length)] zeros_on_left = int(math.ceil((fft_length - occupied_tones)/2.0)) - zeros_on_right = fft_length - occupied_tones - zeros_on_left - ks0 = zeros_on_left*[0.0,] - ks0.extend(ks[0]) - ks0.extend(zeros_on_right*[0.0,]) + ks0 = fft_length*[0,] + ks0[zeros_on_left : zeros_on_left + occupied_tones] = ks[0] + ks0 = fft.ifftshift(ks0) ks0time = fft.ifft(ks0) # ADD SCALING FACTOR ks0time = ks0time.tolist() - + SYNC = "pn" if SYNC == "ml": - self.ofdm_sync = ofdm_sync_ml(fft_length, cp_length, snr, logging) + nco_sensitivity = -1.0/fft_length # correct for fine frequency + self.ofdm_sync = ofdm_sync_ml(fft_length, cp_length, snr, ks0time, logging) elif SYNC == "pn": + nco_sensitivity = -2.0/fft_length # correct for fine frequency self.ofdm_sync = ofdm_sync_pn(fft_length, cp_length, logging) elif SYNC == "pnac": + nco_sensitivity = -2.0/fft_length # correct for fine frequency self.ofdm_sync = ofdm_sync_pnac(fft_length, cp_length, ks0time) elif SYNC == "fixed": + nco_sensitivity = -2.0/fft_length # correct for fine frequency self.ofdm_sync = ofdm_sync_fixed(fft_length, cp_length, logging) - + + # Set up blocks + + self.nco = gr.frequency_modulator_fc(nco_sensitivity) # generate a signal proportional to frequency error of sync block + self.sigmix = gr.multiply_cc() + self.sampler = gr.ofdm_sampler(fft_length, fft_length+cp_length) self.fft_demod = gr.fft_vcc(fft_length, True, win, True) self.ofdm_frame_acq = gr.ofdm_frame_acquisition(occupied_tones, fft_length, cp_length, ks[0]) - self.connect(self, self.chan_filt) - self.connect(self.chan_filt, self.ofdm_sync) - self.connect((self.ofdm_sync,0), self.fft_demod, (self.ofdm_frame_acq,0)) - self.connect((self.ofdm_sync,1), (self.ofdm_frame_acq,1)) - self.connect((self.ofdm_frame_acq,0), (self,0)) - self.connect((self.ofdm_frame_acq,1), (self,1)) + self.connect(self, self.chan_filt) # filter the input channel + self.connect(self.chan_filt, self.ofdm_sync) # into the synchronization alg. + self.connect((self.ofdm_sync,0), self.nco, (self.sigmix,1)) # use sync freq. offset output to derotate input signal + self.connect(self.chan_filt, (self.sigmix,0)) # signal to be derotated + self.connect(self.sigmix, (self.sampler,0)) # sample off timing signal detected in sync alg + self.connect((self.ofdm_sync,1), (self.sampler,1)) # timing signal to sample at + + self.connect((self.sampler,0), self.fft_demod) # send derotated sampled signal to FFT + self.connect(self.fft_demod, (self.ofdm_frame_acq,0)) # find frame start and equalize signal + self.connect((self.sampler,1), (self.ofdm_frame_acq,1)) # send timing signal to signal frame start + self.connect((self.ofdm_frame_acq,0), (self,0)) # finished with fine/coarse freq correction, + self.connect((self.ofdm_frame_acq,1), (self,1)) # frame and symbol timing, and equalization 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.chan_filt, gr.file_sink(gr.sizeof_gr_complex, "ofdm_receiver-chan_filt_c.dat")) + self.connect(self.fft_demod, gr.file_sink(gr.sizeof_gr_complex*fft_length, "ofdm_receiver-fft_out_c.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")) + gr.file_sink(gr.sizeof_gr_complex*occupied_tones, "ofdm_receiver-frame_acq_c.dat")) + self.connect((self.ofdm_frame_acq,1), gr.file_sink(1, "ofdm_receiver-found_corr_b.dat")) + self.connect(self.sampler, gr.file_sink(gr.sizeof_gr_complex*fft_length, "ofdm_receiver-sampler_c.dat")) + self.connect(self.sigmix, gr.file_sink(gr.sizeof_gr_complex, "ofdm_receiver-sigmix_c.dat")) + self.connect(self.nco, gr.file_sink(gr.sizeof_gr_complex, "ofdm_receiver-nco_c.dat")) diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/ofdm_sync_pn.py b/gnuradio-core/src/python/gnuradio/blks2impl/ofdm_sync_pn.py index 1c3ecabd68..05b1de2e19 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/ofdm_sync_pn.py +++ b/gnuradio-core/src/python/gnuradio/blks2impl/ofdm_sync_pn.py @@ -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*fft_length)) # 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,20 +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.sampler = gr.ofdm_sampler(fft_length,symbol_length) - 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) @@ -102,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)) @@ -121,21 +105,19 @@ class ofdm_sync_pn(gr.hier_block2): self.connect(self.matched_filter, self.sub1, self.pk_detect) #self.connect(self.matched_filter, self.pk_detect) - self.connect(self.pk_detect, (self.sampler,1)) self.connect(self.pk_detect, (self.sample_and_hold,1)) - # Set output from sampler - self.connect((self.sampler,0), (self,0)) - self.connect((self.sampler,1), (self,1)) + # 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: self.connect(self.matched_filter, gr.file_sink(gr.sizeof_float, "ofdm_sync_pn-mf_f.dat")) 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.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")) |