[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r4101 - in gnuradio/branches/developers/n4hy/ofdm: gnu
From: |
n4hy |
Subject: |
[Commit-gnuradio] r4101 - in gnuradio/branches/developers/n4hy/ofdm: gnuradio-core/src/lib/general gnuradio-examples/python |
Date: |
Sat, 16 Dec 2006 10:23:21 -0700 (MST) |
Author: n4hy
Date: 2006-12-16 10:23:21 -0700 (Sat, 16 Dec 2006)
New Revision: 4101
Added:
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.cc
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.h
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.i
Modified:
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/Makefile.am
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/general.i
gnuradio/branches/developers/n4hy/ofdm/gnuradio-examples/python/ofdm_test.py
Log:
Cyclic Prefix computation added to ofdm and test code modified
Modified:
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/Makefile.am
===================================================================
---
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/Makefile.am
2006-12-16 08:50:57 UTC (rev 4100)
+++
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/Makefile.am
2006-12-16 17:23:21 UTC (rev 4101)
@@ -162,6 +162,7 @@
gr_nop.cc \
gr_null_sink.cc \
gr_null_source.cc \
+ gr_ofdm_cyclic_prefixer.cc \
gr_ofdm_mapper_bcv.cc \
gr_ofdm_bpsk_mapper.cc \
gr_pa_2x2_phase_combiner.cc \
@@ -292,6 +293,7 @@
gr_nop.h \
gr_null_sink.h \
gr_null_source.h \
+ gr_ofdm_cyclic_prefixer.h \
gr_ofdm_mapper_bcv.h \
gr_ofdm_bpsk_mapper.h \
gr_pa_2x2_phase_combiner.h \
@@ -424,6 +426,7 @@
gr_nop.i \
gr_null_sink.i \
gr_null_source.i \
+ gr_ofdm_cyclic_prefixer.i \
gr_ofdm_mapper_bcv.i \
gr_ofdm_bpsk_mapper.i \
gr_pa_2x2_phase_combiner.i \
Modified:
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/general.i
===================================================================
---
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/general.i
2006-12-16 08:50:57 UTC (rev 4100)
+++
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/general.i
2006-12-16 17:23:21 UTC (rev 4101)
@@ -91,6 +91,7 @@
#include <gr_probe_avg_mag_sqrd_c.h>
#include <gr_probe_avg_mag_sqrd_f.h>
#include <gr_probe_signal_f.h>
+#include <gr_ofdm_cyclic_prefixer.h>
#include <gr_ofdm_bpsk_mapper.h>
#include <gr_costas_loop_cc.h>
#include <gr_pa_2x2_phase_combiner.h>
@@ -185,6 +186,7 @@
%include "gr_probe_avg_mag_sqrd_c.i"
%include "gr_probe_avg_mag_sqrd_f.i"
%include "gr_probe_signal_f.i"
+%include "gr_ofdm_cyclic_prefixer.i"
%include "gr_ofdm_bpsk_mapper.i"
%include "gr_costas_loop_cc.i"
%include "gr_pa_2x2_phase_combiner.i"
Added:
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.cc
===================================================================
---
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.cc
(rev 0)
+++
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.cc
2006-12-16 17:23:21 UTC (rev 4101)
@@ -0,0 +1,69 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2006 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 2, 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_cyclic_prefixer.h>
+#include <gr_io_signature.h>
+
+gr_ofdm_cyclic_prefixer_sptr
+gr_make_ofdm_cyclic_prefixer (size_t input_size, size_t output_size)
+{
+ return gr_ofdm_cyclic_prefixer_sptr (new gr_ofdm_cyclic_prefixer
(input_size, output_size));
+}
+
+gr_ofdm_cyclic_prefixer::gr_ofdm_cyclic_prefixer (size_t input_size, size_t
output_size)
+ : gr_sync_interpolator ("ofdm_cyclic_prefixer",
+ gr_make_io_signature (1, 1,
input_size*sizeof(gr_complex)),
+ gr_make_io_signature (1, 1, sizeof(gr_complex)),
+ output_size),
+ d_input_size(input_size),
+ d_output_size(output_size)
+
+{
+}
+
+int
+gr_ofdm_cyclic_prefixer::work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ gr_complex *iptr, *optr;
+ gr_complex *in = (gr_complex *) input_items[0];
+ gr_complex *out = (gr_complex *) output_items[0];
+ size_t cp_size = d_output_size - d_input_size;
+ unsigned int i=0;
+
+ optr = &out[cp_size];
+ for(i=0; i < d_input_size; i++,optr++) {
+ *optr = in[i];
+ }
+
+ iptr = &in[d_input_size - cp_size];
+ for(i=0; i < cp_size; i++, iptr++) {
+ out[i] = *iptr;
+ }
+
+ return d_output_size;
+}
Added:
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.h
===================================================================
---
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.h
(rev 0)
+++
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.h
2006-12-16 17:23:21 UTC (rev 4101)
@@ -0,0 +1,58 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2005,2006 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 2, 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_CYCLIC_PREFIXER_H
+#define INCLUDED_GR_OFDM_CYCLIC_PREFIXER_H
+
+#include <gr_sync_interpolator.h>
+#include <stdio.h>
+
+class gr_ofdm_cyclic_prefixer;
+typedef boost::shared_ptr<gr_ofdm_cyclic_prefixer>
gr_ofdm_cyclic_prefixer_sptr;
+
+gr_ofdm_cyclic_prefixer_sptr
+gr_make_ofdm_cyclic_prefixer (size_t input_size, size_t output_size);
+
+
+/*!
+ * \brief adds a cyclic prefix vector to an input size long ofdm
+ * symbol(vector) and converts vector to a stream output_size long.
+ * \ingroup block
+ */
+class gr_ofdm_cyclic_prefixer : public gr_sync_interpolator
+{
+ friend gr_ofdm_cyclic_prefixer_sptr
+ gr_make_ofdm_cyclic_prefixer (size_t input_size, size_t output_size);
+
+ protected:
+ gr_ofdm_cyclic_prefixer (size_t input_size, size_t output_size);
+
+ public:
+ int work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ private:
+ size_t d_input_size;
+ size_t d_output_size;
+};
+
+#endif /* INCLUDED_GR_OFDM_CYCLIC_PREFIXER_H */
Added:
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.i
===================================================================
---
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.i
(rev 0)
+++
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.i
2006-12-16 17:23:21 UTC (rev 4101)
@@ -0,0 +1,34 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006 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 2, 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.
+ */
+
+GR_SWIG_BLOCK_MAGIC(gr,ofdm_cyclic_prefixer)
+
+gr_ofdm_cyclic_prefixer_sptr
+gr_make_ofdm_cyclic_prefixer (size_t input_size, size_t output_size);
+
+class gr_ofdm_cyclic_prefixer : public gr_sync_decimator
+{
+ protected:
+ gr_ofdm_cyclic_prefixer (size_t input_size, size_t output_size);
+
+ public:
+};
Modified:
gnuradio/branches/developers/n4hy/ofdm/gnuradio-examples/python/ofdm_test.py
===================================================================
---
gnuradio/branches/developers/n4hy/ofdm/gnuradio-examples/python/ofdm_test.py
2006-12-16 08:50:57 UTC (rev 4100)
+++
gnuradio/branches/developers/n4hy/ofdm/gnuradio-examples/python/ofdm_test.py
2006-12-16 17:23:21 UTC (rev 4101)
@@ -55,29 +55,97 @@
self.show_debug_info = True
- #build the graph
- if options.waterfall:
- self.scope = \
- waterfallsink.waterfall_sink_c (self, panel, fft_size=1024,
sample_rate=sample_rate)
- elif options.oscilloscope:
- self.scope = scopesink.scope_sink_f(self, panel,
sample_rate=sample_rate)
- else:
- self.scope = fftsink.fft_sink_c (self, panel, fft_size=1024,
sample_rate=sample_rate, fft_rate=30)
+ # parameters
+ fftsize = 1024
+ occupied_tones = 300
+ symbol_length = 1024+128
- win = [1 for i in range(128)]
- data = [random.randint(0,1) for i in range(1000)]
+ cpsize = symbol_length - fftsize
+ print "CPSize"
+ print cpsize
+
+ win = [1 for i in range(fftsize)]
+ data = [random.randint(0,1) for i in range(100000)]
self.src = gr.vector_source_b(data, True)
- self.ofdm = gr.ofdm_bpsk_mapper(70, 128)
- self.ifft = gr.fft_vcc(128, False, win)
- self.v2s = gr.vector_to_stream(gr.sizeof_gr_complex,128)
- self.nullsink = gr.null_sink(gr.sizeof_gr_complex)
- self.connect(self.src, self.ofdm, self.ifft, self.v2s, self.scope)
+ # Modulator
+ self.ofdm = gr.ofdm_bpsk_mapper(occupied_tones, fftsize)
+ self.ifft = gr.fft_vcc(fftsize, False, win)
+ self.cp_adder = gr.ofdm_cyclic_prefixer(fftsize,symbol_length)
+ self.debugfile = gr.file_sink(gr.sizeof_gr_complex,"debug_out")
+ self.connect(self.cp_adder,self.debugfile)
+
+ #count_seq = range(10000)
+ #self.count_src = gr.vector_source_c(count_seq,True)
+ #self.s2v = gr.stream_to_vector(gr.sizeof_gr_complex,256)
+ #self.connect(self.count_src, self.s2v, self.cp_adder,
+ # self.throttle, self.debugfile) #, self.throttle) #,
self.scope)
+
+ self.throttle = gr.throttle(gr.sizeof_gr_complex, 1e5)
+ self.scope = fftsink.fft_sink_c (self, panel, fft_size=1024,
sample_rate=sample_rate, fft_rate=30)
+
+ self.connect(self.src, self.ofdm, self.ifft, self.cp_adder,
self.throttle, self.scope)
+
+ # ML Sync
+ SNR = 1e8
+ rho = SNR / (SNR + 1.0)
+
+ # Energy Detection from ML Sync
+
+ #moving_sum_taps = [0.0 for i in range(symbol_length)]
+ #for i in range(cpsize):
+ # moving_sum_taps[i] = 0.5
+ #for i in range(fftsize,symbol_length):
+ # moving_sum_taps[i] = 0.5
+ #self.moving_sum_filter = gr.fir_filter_fff(1,moving_sum_taps)
+ #print moving_sum_taps
+ #self.complex_to_magsq = gr.complex_to_mag_squared();
+
#self.connect(self.throttle,self.complex_to_magsq,self.moving_sum_filter)
+
+ delayline = [0.0 for i in range(fftsize+1)]
+ delayline[fftsize] = 1.0
+ self.delay = gr.fir_filter_ccf(1,delayline)
+ self.connect(self.throttle,self.delay)
+
+ self.magsqrd1 = gr.complex_to_mag_squared()
+ self.magsqrd2 = gr.complex_to_mag_squared()
+ self.adder = gr.add_ff()
+
+ moving_sum_taps = [rho/2 for i in range(cpsize)]
+ self.moving_sum_filter = gr.fir_filter_fff(1,moving_sum_taps)
+
+ self.connect(self.throttle,self.magsqrd1)
+ self.connect(self.delay,self.magsqrd2)
+ self.connect(self.magsqrd1,(self.adder,0))
+ self.connect(self.magsqrd2,(self.adder,1))
+ self.connect(self.adder,self.moving_sum_filter)
+
+ # Correlation from ML Sync
+ self.conjg = gr.conjugate_cc();
+ self.mixer = gr.multiply_cc();
+
+ movingsum2_taps = [1.0 for i in range(cpsize)]
+ self.movingsum2 = gr.fir_filter_ccf(1,movingsum2_taps)
+
+ self.c2mag = gr.complex_to_mag()
+
+ self.connect(self.throttle,(self.mixer,1))
+ self.connect(self.delay,self.conjg,(self.mixer,0))
+ self.connect(self.mixer,self.movingsum2,self.c2mag)
+
+ # ML Sync output arg, need to find maximum point of this
+ self.diff = gr.sub_ff()
+ self.connect(self.c2mag,(self.diff,0))
+ self.connect(self.moving_sum_filter,(self.diff,1))
+
+ self.oscope = scopesink.scope_sink_f(self, panel,
sample_rate=sample_rate)
+ self.connect(self.moving_sum_filter,(self.oscope,0))
+ self.connect(self.c2mag,(self.oscope,1))
+ self.connect(self.diff,(self.oscope,2))
+
self._build_gui(vbox)
- # set initial values
-
def _set_status_msg(self, msg):
self.frame.GetStatusBar().SetStatusText(msg, 0)
@@ -87,6 +155,7 @@
return self.set_freq(kv['freq'])
vbox.Add(self.scope.win, 10, wx.EXPAND)
+ vbox.Add(self.oscope.win, 10, wx.EXPAND)
#self._build_subpanel(vbox)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r4101 - in gnuradio/branches/developers/n4hy/ofdm: gnuradio-core/src/lib/general gnuradio-examples/python,
n4hy <=