commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r4132 - in gnuradio/branches/developers/n4hy/ofdm/gnur


From: trondeau
Subject: [Commit-gnuradio] r4132 - in gnuradio/branches/developers/n4hy/ofdm/gnuradio-examples/python: . ofdm
Date: Sun, 17 Dec 2006 22:27:03 -0700 (MST)

Author: trondeau
Date: 2006-12-17 22:27:03 -0700 (Sun, 17 Dec 2006)
New Revision: 4132

Added:
   
gnuradio/branches/developers/n4hy/ofdm/gnuradio-examples/python/ofdm/ofdm_receiver.py
   
gnuradio/branches/developers/n4hy/ofdm/gnuradio-examples/python/ofdm/ofdm_test.py
Removed:
   
gnuradio/branches/developers/n4hy/ofdm/gnuradio-examples/python/ofdm_receiver.py
   gnuradio/branches/developers/n4hy/ofdm/gnuradio-examples/python/ofdm_test.py
Log:
moved OFDM example code to OFDM example dir

Copied: 
gnuradio/branches/developers/n4hy/ofdm/gnuradio-examples/python/ofdm/ofdm_receiver.py
 (from rev 4131, 
gnuradio/branches/developers/n4hy/ofdm/gnuradio-examples/python/ofdm_receiver.py)
===================================================================
--- 
gnuradio/branches/developers/n4hy/ofdm/gnuradio-examples/python/ofdm/ofdm_receiver.py
                               (rev 0)
+++ 
gnuradio/branches/developers/n4hy/ofdm/gnuradio-examples/python/ofdm/ofdm_receiver.py
       2006-12-18 05:27:03 UTC (rev 4132)
@@ -0,0 +1,98 @@
+#!/usr/bin/env python
+#
+# 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.
+# 
+
+import math
+from gnuradio import gr
+from gnuradio import audio
+from gnuradio.eng_option import eng_option
+from optparse import OptionParser
+
+class ofdm_receiver(gr.hier_block):
+    def __init__(self, fg, fft_length, symbol_length, rho):
+        self.input = gr.add_const_cc(0) # Kluge that goes away with hier_block2
+
+        self.fg = fg
+        
+        cpsize = symbol_length - fft_length;
+
+        # ML Sync
+
+        # Energy Detection from ML Sync
+
+        # Create a delay line
+        delayline = [0.0 for i in range(fft_length+1)]
+        delayline[fft_length] = 1.0
+        self.delay = gr.fir_filter_ccf(1,delayline)
+        self.fg.connect(self.input, self.delay)
+
+        # magnitude squared blocks
+        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.fg.connect(self.input,self.magsqrd1)
+        self.fg.connect(self.delay,self.magsqrd2)
+        self.fg.connect(self.magsqrd1,(self.adder,0))
+        self.fg.connect(self.magsqrd2,(self.adder,1))
+        self.fg.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)
+        
+
+        # Correlator data handler
+        self.c2mag = gr.complex_to_mag()
+        self.angle = gr.complex_to_arg()
+        self.scale = gr.multiply_const_ff(-1000.0/(2*math.pi))
+        self.fg.connect(self.input,(self.mixer,1))
+        self.fg.connect(self.delay,self.conjg,(self.mixer,0))
+        self.fg.connect(self.mixer,self.movingsum2,self.c2mag)
+        self.fg.connect(self.movingsum2,self.angle)
+             
+        # ML Sync output arg, need to find maximum point of this
+        self.diff = gr.sub_ff()
+        self.fg.connect(self.c2mag,(self.diff,0))
+        self.fg.connect(self.moving_sum_filter,(self.diff,1))
+
+        #ML measurements input to sampler block and detect
+        self.sampler = gr.ofdm_sampler(fft_length,symbol_length,1)
+
+        self.f2c1 = gr.float_to_complex()
+        self.f2c2 = gr.float_to_complex()
+
+        # Connect inputs to OFDM sampler:
+        #   1: stream to get downconverted to baseband
+        #   2: output of difference block (theta)
+        #   3: frequency error estimate (epsilon)
+        self.fg.connect(self.input, (self.sampler,0))
+        self.fg.connect(self.diff, self.f2c1,(self.sampler,1))
+        self.fg.connect(self.angle, self.f2c2,(self.sampler,2))
+
+        gr.hier_block.__init__(self, fg, self.input, self.sampler)

Copied: 
gnuradio/branches/developers/n4hy/ofdm/gnuradio-examples/python/ofdm/ofdm_test.py
 (from rev 4131, 
gnuradio/branches/developers/n4hy/ofdm/gnuradio-examples/python/ofdm_test.py)
===================================================================
--- 
gnuradio/branches/developers/n4hy/ofdm/gnuradio-examples/python/ofdm/ofdm_test.py
                           (rev 0)
+++ 
gnuradio/branches/developers/n4hy/ofdm/gnuradio-examples/python/ofdm/ofdm_test.py
   2006-12-18 05:27:03 UTC (rev 4132)
@@ -0,0 +1,194 @@
+#!/usr/bin/env python
+#
+# Copyright 2004,2005 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.
+# 
+
+from gnuradio import gr, gru
+from gnuradio import eng_notation
+from gnuradio.eng_option import eng_option
+from gnuradio.wxgui import stdgui, fftsink, waterfallsink, scopesink, form, 
slider
+from optparse import OptionParser
+import wx
+import os, sys, random, math
+
+from ofdm_receiver import ofdm_receiver
+
+class app_flow_graph(stdgui.gui_flow_graph):
+    def __init__(self, frame, panel, vbox, argv):
+        stdgui.gui_flow_graph.__init__(self)
+
+        self.frame = frame
+        self.panel = panel
+        
+        parser = OptionParser(option_class=eng_option)
+        parser.add_option("-W", "--waterfall", action="store_true", 
default=False,
+                          help="Enable waterfall display")
+        parser.add_option("-S", "--oscilloscope", action="store_true", 
default=False,
+                          help="Enable oscilloscope display")
+        parser.add_option("-I", "--audio-input", type="string", default="",
+                          help="pcm input device name.  E.g., hw:0,0 or 
/dev/dsp")
+        parser.add_option("-r", "--sample-rate", type="eng_float", 
default=48000,
+                          help="set sample rate to RATE (48000)")
+
+        (options, args) = parser.parse_args()   
+       sample_rate = int(options.sample_rate)
+        
+       if len(args) != 0:
+            parser.print_help()
+            sys.exit(1)
+
+        self.show_debug_info = True
+        
+        # parameters
+        occupied_tones = 70
+        fftsize = 128
+        cpsize = 32
+        symbol_length = fftsize + cpsize
+
+        SNR_db = 100.0
+        SNR = 10.0**(SNR_db/10.0)
+        frequency_offset = -0.0
+
+        power_in_signal = occupied_tones
+        noise_power_in_channel = power_in_signal/SNR
+        noise_power_required = noise_power_in_channel * fftsize / 
occupied_tones
+        noise_voltage = math.sqrt(noise_power_required)
+        rho = SNR / (SNR + 1.0)
+
+        print rho
+        
+        win = [1 for i in range(fftsize)]
+        #data = [1,0,0,1]* 5000
+        data = [random.randint(0,1) for i in range(100000)]
+       self.src = gr.vector_source_b(data, True)
+
+        # 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.connect(self.src, self.ofdm, self.ifft, self.cp_adder)
+
+        # Channel
+        fdiff = frequency_offset * sample_rate / fftsize
+        self.noise_adder = gr.add_cc()
+        self.noise = gr.noise_source_c(gr.GR_GAUSSIAN,noise_voltage,1)
+        self.offset = 
gr.sig_source_c((sample_rate*1.0),gr.GR_SIN_WAVE,fdiff,1.0,0.0)
+        self.mixer_offset = gr.multiply_cc()
+        self.throttle = gr.throttle(gr.sizeof_gr_complex, 5e3)
+
+        self.connect(self.offset,(self.mixer_offset,0))
+        self.connect(self.noise,(self.noise_adder,0))
+        self.connect(self.mixer_offset, self.throttle, (self.noise_adder,1))
+
+        # Put modulated signal through channel
+        #self.scope = fftsink.fft_sink_c (self, panel, fft_size=1024, 
sample_rate=sample_rate, fft_rate=30)
+        self.connect(self.cp_adder, (self.mixer_offset,1))
+
+
+        # ML Sync
+        self.ofdm_rx = ofdm_receiver(self, fftsize, symbol_length, rho)
+        
+        # OFDM Demod
+        self.fftdemod = gr.fft_vcc(fftsize,True,win)
+        self.ofdm_demod = gr.ofdm_bpsk_demapper(occupied_tones, fftsize)
+        self.unpack = gr.unpack_k_bits_bb(1)
+
+        self.connect(self.noise_adder, self.ofdm_rx, self.fftdemod, 
self.ofdm_demod, self.unpack)
+             
+        # save output
+        self.outdat = gr.file_sink(gr.sizeof_char,"output_data")
+        self.connect(self.unpack, self.outdat)
+        
+        if 0:
+            self.connect(self.noise_adder,self.throttle, self.scope)
+            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,0))
+            self.connect(self.movingsum2,self.angle,self.scale,(self.oscope,1))
+
+            self._build_gui(vbox)
+
+    def _set_status_msg(self, msg):
+        self.frame.GetStatusBar().SetStatusText(msg, 0)
+
+    def _build_gui(self, vbox):
+
+        def _form_set_freq(kv):
+            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)
+
+    def _build_subpanel(self, vbox_arg):
+        # build a secondary information panel (sometimes hidden)
+
+        # FIXME figure out how to have this be a subpanel that is always
+        # created, but has its visibility controlled by foo.Show(True/False)
+        
+        def _form_set_decim(kv):
+            return self.set_decim(kv['decim'])
+
+        if not(self.show_debug_info):
+            return
+
+        panel = self.panel
+        vbox = vbox_arg
+        myform = self.myform
+
+        #panel = wx.Panel(self.panel, -1)
+        #vbox = wx.BoxSizer(wx.VERTICAL)
+
+        hbox = wx.BoxSizer(wx.HORIZONTAL)
+        hbox.Add((5,0), 0)
+
+        myform['decim'] = form.int_field(
+            parent=panel, sizer=hbox, label="Decim",
+            callback=myform.check_input_and_call(_form_set_decim, 
self._set_status_msg))
+
+        hbox.Add((5,0), 1)
+        myform['address@hidden'] = form.static_float_field(
+            parent=panel, sizer=hbox, label="address@hidden")
+
+        hbox.Add((5,0), 1)
+        myform['dbname'] = form.static_text_field(
+            parent=panel, sizer=hbox)
+
+        hbox.Add((5,0), 1)
+        myform['baseband'] = form.static_float_field(
+            parent=panel, sizer=hbox, label="Analog BB")
+
+        hbox.Add((5,0), 1)
+        myform['ddc'] = form.static_float_field(
+            parent=panel, sizer=hbox, label="DDC")
+
+        hbox.Add((5,0), 0)
+        vbox.Add(hbox, 0, wx.EXPAND)
+
+        
+def main ():
+    app = stdgui.stdapp(app_flow_graph, "OFDM algorithm test", nstatus=1)
+    app.MainLoop()
+
+if __name__ == '__main__':
+    main ()

Deleted: 
gnuradio/branches/developers/n4hy/ofdm/gnuradio-examples/python/ofdm_receiver.py

Deleted: 
gnuradio/branches/developers/n4hy/ofdm/gnuradio-examples/python/ofdm_test.py





reply via email to

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