diff options
author | trondeau <trondeau@221aa14e-8319-0410-a670-987f0aec2ac5> | 2008-01-02 17:35:35 +0000 |
---|---|---|
committer | trondeau <trondeau@221aa14e-8319-0410-a670-987f0aec2ac5> | 2008-01-02 17:35:35 +0000 |
commit | ce16514534e5d7ebbc4fe46e2b09a25ccc5fdafd (patch) | |
tree | 2d9ae1179cb26f213125accabaea8eb05d63f109 /gnuradio-examples/python | |
parent | 481636b7be1462dc9f1909ac4700002af63dc8c0 (diff) |
Merging ofdm2 branch -r7047:7321 into trunk. This updates the OFDM code to hier_block2 in blks2impl and removed from blksimpl. The new code
implements a decision feedback sync loop to lock the phase/freq, removes two unnecessary premables and performs frame sync and equalization off
single preamble symbol. Also adds/updates Python plotting tools and a branchless clip algorithm in gr_math.h.
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@7324 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'gnuradio-examples/python')
-rwxr-xr-x | gnuradio-examples/python/ofdm/benchmark_ofdm.py | 44 | ||||
-rwxr-xr-x | gnuradio-examples/python/ofdm/benchmark_ofdm_rx.py | 24 | ||||
-rwxr-xr-x | gnuradio-examples/python/ofdm/benchmark_ofdm_tx.py | 28 | ||||
-rwxr-xr-x | gnuradio-examples/python/ofdm/gr_plot_ofdm.py | 268 | ||||
-rwxr-xr-x | gnuradio-examples/python/ofdm/plot_ofdm.m | 67 | ||||
-rw-r--r-- | gnuradio-examples/python/ofdm/receive_path.py | 19 | ||||
-rw-r--r-- | gnuradio-examples/python/ofdm/transmit_path.py | 17 |
7 files changed, 377 insertions, 90 deletions
diff --git a/gnuradio-examples/python/ofdm/benchmark_ofdm.py b/gnuradio-examples/python/ofdm/benchmark_ofdm.py index 690c57d600..5861da16c7 100755 --- a/gnuradio-examples/python/ofdm/benchmark_ofdm.py +++ b/gnuradio-examples/python/ofdm/benchmark_ofdm.py @@ -20,7 +20,7 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr, blks +from gnuradio import gr, blks2 from gnuradio import eng_notation from gnuradio.eng_option import eng_option from optparse import OptionParser @@ -32,9 +32,9 @@ from transmit_path import transmit_path from receive_path import receive_path -class my_graph(gr.flow_graph): +class my_top_block(gr.top_block): def __init__(self, callback, options): - gr.flow_graph.__init__(self) + gr.top_block.__init__(self) if not options.channel_off: SNR = 10.0**(options.snr/10.0) @@ -67,22 +67,24 @@ class my_graph(gr.flow_graph): z = [0,] self.zeros = gr.vector_source_c(z, True) - self.txpath = transmit_path(self, options) + self.txpath = transmit_path(options) - self.mux = gr.stream_mux(gr.sizeof_gr_complex, stream_size) + #self.mux = gr.stream_mux(gr.sizeof_gr_complex, stream_size) self.throttle = gr.throttle(gr.sizeof_gr_complex, options.sample_rate) - self.channel = blks.channel_model(self, noise_voltage, frequency_offset, - options.clockrate_ratio, taps) - self.rxpath = receive_path(self, callback, options) + self.channel = blks2.channel_model(noise_voltage, frequency_offset, + options.clockrate_ratio, taps) + self.rxpath = receive_path(callback, options) - self.connect(self.zeros, (self.mux,0)) - self.connect(self.txpath, (self.mux,1)) - self.connect(self.mux, self.throttle, self.channel, self.rxpath) - + #self.connect(self.zeros, (self.mux,0)) + #self.connect(self.txpath, (self.mux,1)) + #self.connect(self.mux, self.throttle, self.channel, self.rxpath) + #self.connect(self.mux, self.throttle, self.rxpath) + self.connect(self.txpath, self.throttle, self.channel, self.rxpath) + if options.log: self.connect(self.txpath, gr.file_sink(gr.sizeof_gr_complex, "txpath.dat")) - self.connect(self.mux, gr.file_sink(gr.sizeof_gr_complex, "mux.dat")) - self.connect(self.channel, gr.file_sink(gr.sizeof_gr_complex, "channel.dat")) + #self.connect(self.mux, gr.file_sink(gr.sizeof_gr_complex, "mux.dat")) + #self.connect(self.channel, gr.file_sink(gr.sizeof_gr_complex, "channel.dat")) # ///////////////////////////////////////////////////////////////////////////// # main @@ -95,7 +97,7 @@ def main(): n_right = 0 def send_pkt(payload='', eof=False): - return fg.txpath.send_pkt(payload, eof) + return tb.txpath.send_pkt(payload, eof) def rx_callback(ok, payload): global n_rcvd, n_right @@ -139,19 +141,19 @@ def main(): transmit_path.add_options(parser, expert_grp) receive_path.add_options(parser, expert_grp) - blks.ofdm_mod.add_options(parser, expert_grp) - blks.ofdm_demod.add_options(parser, expert_grp) + blks2.ofdm_mod.add_options(parser, expert_grp) + blks2.ofdm_demod.add_options(parser, expert_grp) (options, args) = parser.parse_args () # build the graph - fg = my_graph(rx_callback, options) + tb = my_top_block(rx_callback, options) r = gr.enable_realtime_scheduling() # if r != gr.RT_OK: # print "Warning: failed to enable realtime scheduling" - - fg.start() # start flow graph + + tb.start() # start flow graph # generate and send packets nbytes = int(1e6 * options.megabytes) @@ -173,7 +175,7 @@ def main(): pktno += 1 send_pkt(eof=True) - fg.wait() # wait for it to finish + tb.wait() # wait for it to finish if __name__ == '__main__': diff --git a/gnuradio-examples/python/ofdm/benchmark_ofdm_rx.py b/gnuradio-examples/python/ofdm/benchmark_ofdm_rx.py index a8c20d3906..cb9649a6c8 100755 --- a/gnuradio-examples/python/ofdm/benchmark_ofdm_rx.py +++ b/gnuradio-examples/python/ofdm/benchmark_ofdm_rx.py @@ -20,21 +20,21 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr, blks +from gnuradio import gr, blks2 from gnuradio import usrp from gnuradio import eng_notation from gnuradio.eng_option import eng_option from optparse import OptionParser -import random, time, struct, sys +import struct, sys # from current dir from receive_path import receive_path import fusb_options -class usrp_graph(gr.flow_graph): +class my_top_block(gr.top_block): def __init__(self, callback, options): - gr.flow_graph.__init__(self) + gr.top_block.__init__(self) self._rx_freq = options.rx_freq # receiver's center frequency self._rx_gain = options.rx_gain # receiver's gain @@ -61,10 +61,10 @@ class usrp_graph(gr.flow_graph): self.set_auto_tr(True) # enable Auto Transmit/Receive switching # Set up receive path - self.rxpath = receive_path(self, callback, options) + self.rxpath = receive_path(callback, options) self.connect(self.u, self.rxpath) - + def _setup_usrp_source(self): self.u = usrp.source_c (fusb_block_size=self._fusb_block_size, fusb_nblocks=self._fusb_nblocks) @@ -187,23 +187,23 @@ def main(): parser.add_option("","--discontinuous", action="store_true", default=False, help="enable discontinuous") - usrp_graph.add_options(parser, expert_grp) + my_top_block.add_options(parser, expert_grp) receive_path.add_options(parser, expert_grp) - blks.ofdm_mod.add_options(parser, expert_grp) - blks.ofdm_demod.add_options(parser, expert_grp) + blks2.ofdm_mod.add_options(parser, expert_grp) + blks2.ofdm_demod.add_options(parser, expert_grp) fusb_options.add_options(expert_grp) (options, args) = parser.parse_args () # build the graph - fg = usrp_graph(rx_callback, options) + tb = my_top_block(rx_callback, options) r = gr.enable_realtime_scheduling() if r != gr.RT_OK: print "Warning: failed to enable realtime scheduling" - fg.start() # start flow graph - fg.wait() # wait for it to finish + tb.start() # start flow graph + tb.wait() # wait for it to finish if __name__ == '__main__': try: diff --git a/gnuradio-examples/python/ofdm/benchmark_ofdm_tx.py b/gnuradio-examples/python/ofdm/benchmark_ofdm_tx.py index a9d1e00e6c..fb41ab1293 100755 --- a/gnuradio-examples/python/ofdm/benchmark_ofdm_tx.py +++ b/gnuradio-examples/python/ofdm/benchmark_ofdm_tx.py @@ -20,7 +20,7 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr, blks +from gnuradio import gr, blks2 from gnuradio import usrp from gnuradio import eng_notation from gnuradio.eng_option import eng_option @@ -33,9 +33,9 @@ from transmit_path import transmit_path from pick_bitrate import pick_tx_bitrate import fusb_options -class usrp_graph(gr.flow_graph): +class my_top_block(gr.top_block): def __init__(self, options): - gr.flow_graph.__init__(self) + gr.top_block.__init__(self) self._tx_freq = options.tx_freq # tranmitter's center frequency self._tx_subdev_spec = options.tx_subdev_spec # daughterboard to use @@ -53,10 +53,10 @@ class usrp_graph(gr.flow_graph): # copy the final answers back into options for use by modulator #options.bitrate = self._bitrate - self.txpath = transmit_path(self, options) + self.txpath = transmit_path(options) self.connect(self.txpath, self.u) - + def _setup_usrp_sink(self): """ Creates a USRP sink, determines the settings for best bitrate, @@ -167,7 +167,7 @@ def add_freq_option(parser): def main(): def send_pkt(payload='', eof=False): - return fg.txpath.send_pkt(payload, eof) + return tb.txpath.send_pkt(payload, eof) parser = OptionParser(option_class=eng_option, conflict_handler="resolve") expert_grp = parser.add_option_group("Expert") @@ -178,23 +178,23 @@ def main(): parser.add_option("","--discontinuous", action="store_true", default=False, help="enable discontinuous mode") - usrp_graph.add_options(parser, expert_grp) + my_top_block.add_options(parser, expert_grp) transmit_path.add_options(parser, expert_grp) - blks.ofdm_mod.add_options(parser, expert_grp) - blks.ofdm_demod.add_options(parser, expert_grp) + blks2.ofdm_mod.add_options(parser, expert_grp) + blks2.ofdm_demod.add_options(parser, expert_grp) fusb_options.add_options(expert_grp) (options, args) = parser.parse_args () # build the graph - fg = usrp_graph(options) - + tb = my_top_block(options) + r = gr.enable_realtime_scheduling() if r != gr.RT_OK: print "Warning: failed to enable realtime scheduling" - fg.start() # start flow graph - + tb.start() # start flow graph + # generate and send packets nbytes = int(1e6 * options.megabytes) n = 0 @@ -210,7 +210,7 @@ def main(): pktno += 1 send_pkt(eof=True) - fg.wait() # wait for it to finish + tb.wait() # wait for it to finish if __name__ == '__main__': try: diff --git a/gnuradio-examples/python/ofdm/gr_plot_ofdm.py b/gnuradio-examples/python/ofdm/gr_plot_ofdm.py new file mode 100755 index 0000000000..0bca41037c --- /dev/null +++ b/gnuradio-examples/python/ofdm/gr_plot_ofdm.py @@ -0,0 +1,268 @@ +#!/usr/bin/env python +# +# Copyright 2007 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 3, 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 scipy, pylab, math +import struct, sys +from pylab import * +from matplotlib.font_manager import fontManager, FontProperties +from optparse import OptionParser +from scipy import fftpack +from math import log10 + +matplotlib.interactive(True) +matplotlib.use('TkAgg') + +class draw_constellation: + def __init__(self, options): + derot_file = "ofdm_frame_sink_c.dat" + acq_file = "ofdm_frame_acq_c.dat" + fft_file = "fft_out_c.dat" + + self.h_derot_file = open(derot_file, "r") + self.h_acq_file = open(acq_file, "r") + self.h_fft_file = open(fft_file, "r") + + self.occ_tones = options.occ_tones + self.fft_size = options.fft_size + self.symbol = options.start + self.sample_rate = options.sample_rate + + self.axis_font_size = 16 + self.label_font_size = 18 + self.title_font_size = 20 + self.text_size = 22 + + # Setup PLOT + self.fig = figure(1, figsize=(14, 9), facecolor='w') + rcParams['xtick.labelsize'] = self.axis_font_size + rcParams['ytick.labelsize'] = self.axis_font_size + + self.text_sym = figtext(0.05, 0.95, ("Symbol: %s" % self.symbol), weight="heavy", size=self.text_size) + + self.make_plots() + + self.button_left_axes = self.fig.add_axes([0.45, 0.01, 0.05, 0.05], frameon=True) + self.button_left = Button(self.button_left_axes, "<") + self.button_left_callback = self.button_left.on_clicked(self.button_left_click) + + self.button_right_axes = self.fig.add_axes([0.50, 0.01, 0.05, 0.05], frameon=True) + self.button_right = Button(self.button_right_axes, ">") + self.button_right_callback = self.button_right.on_clicked(self.button_right_click) + + self.xlim = self.sp_eq.get_xlim() + + self.manager = get_current_fig_manager() + #connect('draw_event', self.zoom) + connect('key_press_event', self.click) + show() + + def get_data(self): + self.text_sym.set_text("Symbol: %d" % (self.symbol)) + + derot_data = scipy.fromfile(self.h_derot_file, dtype=scipy.complex64, count=self.occ_tones) + acq_data = scipy.fromfile(self.h_acq_file, dtype=scipy.complex64, count=self.occ_tones) + fft_data = scipy.fromfile(self.h_fft_file, dtype=scipy.complex64, count=self.fft_size) + if(len(acq_data) == 0): + print "End of File" + else: + self.acq_data_reals = [r.real for r in acq_data] + self.acq_data_imags = [i.imag for i in acq_data] + self.derot_data_reals = [r.real for r in derot_data] + self.derot_data_imags = [i.imag for i in derot_data] + + self.unequalized_angle = [math.atan2(x.imag, x.real) for x in fft_data] + self.equalized_angle = [math.atan2(x.imag, x.real) for x in acq_data] + self.derot_equalized_angle = [math.atan2(x.imag, x.real) for x in derot_data] + + self.time = [i*(1/self.sample_rate) for i in range(len(acq_data))] + ffttime = [i*(1/self.sample_rate) for i in range(len(fft_data))] + + self.freq = self.get_freq(ffttime, self.sample_rate) + + for i in range(len(fft_data)): + if(abs(fft_data[i]) == 0.0): + fft_data[i] = complex(1e-6,1e-6) + self.fft_data = [20*log10(abs(f)) for f in fft_data] + + def get_freq(self, time, sample_rate, T=1): + N = len(time) + Fs = 1.0 / (max(time) - min(time)) + Fn = 0.5 * sample_rate + freq = [-Fn + i*Fs for i in range(N)] + return freq + + def make_plots(self): + self.h_acq_file.seek(8*self.symbol*self.occ_tones, 0) + self.h_fft_file.seek(8*self.symbol*self.fft_size, 0) + self.h_derot_file.seek(8*self.symbol*self.occ_tones, 0) + + self.get_data() + + # Subplot: constellation of rotated symbols + self.sp_const = self.fig.add_subplot(4,1,1, position=[0.15, 0.55, 0.3, 0.35]) + self.sp_const.set_title(("Constellation"), fontsize=self.title_font_size, fontweight="bold") + self.sp_const.set_xlabel("Inphase", fontsize=self.label_font_size, fontweight="bold") + self.sp_const.set_ylabel("Qaudrature", fontsize=self.label_font_size, fontweight="bold") + self.plot_const = plot(self.acq_data_reals, self.acq_data_imags, 'bo') + self.plot_const += plot(self.derot_data_reals, self.derot_data_imags, 'ro') + self.sp_const.axis([-2, 2, -2, 2]) + + # Subplot: unequalized angle + self.sp_uneq = self.fig.add_subplot(4,2,1, position=[0.575, 0.55, 0.3, 0.35]) + self.sp_uneq.set_title(("Unequalized Angle"), fontsize=self.title_font_size, fontweight="bold") + self.sp_uneq.set_xlabel("Time (s)", fontsize=self.label_font_size, fontweight="bold") + self.sp_uneq.set_ylabel("Angle", fontsize=self.label_font_size, fontweight="bold") + uneqscale = range(len(self.unequalized_angle)) + self.plot_uneq = plot(uneqscale, self.unequalized_angle, 'bo') + + # Subplot: equalized angle + self.sp_eq = self.fig.add_subplot(4,1,2, position=[0.15, 0.1, 0.3, 0.35]) + self.sp_eq.set_title(("Equalized Angle"), fontsize=self.title_font_size, fontweight="bold") + self.sp_eq.set_xlabel("Time (s)", fontsize=self.label_font_size, fontweight="bold") + self.sp_eq.set_ylabel("Angle", fontsize=self.label_font_size, fontweight="bold") + eqscale = range(len(self.equalized_angle)) + self.plot_eq = plot(eqscale, self.equalized_angle, 'bo') + self.plot_eq += plot(eqscale, self.derot_equalized_angle, 'ro', markersize=4) + + # Subplot: FFT + self.sp_fft = self.fig.add_subplot(4,2,2, position=[0.575, 0.1, 0.3, 0.35]) + self.sp_fft.set_title(("FFT"), fontsize=self.title_font_size, fontweight="bold") + self.sp_fft.set_xlabel("Frequency (MHz)", fontsize=self.label_font_size, fontweight="bold") + self.sp_fft.set_ylabel("Power (dBm)", fontsize=self.label_font_size, fontweight="bold") + self.plot_fft = plot(self.freq, self.fft_data, '-bo') + + draw() + + def update_plots(self): + eqscale = range(len(self.equalized_angle)) + uneqscale = range(len(self.unequalized_angle)) + self.plot_eq[0].set_data([eqscale, self.equalized_angle]) + self.plot_eq[1].set_data([eqscale, self.derot_equalized_angle]) + self.plot_uneq[0].set_data([uneqscale, self.unequalized_angle]) + self.sp_eq.set_ylim([-4, 4]) + self.sp_uneq.set_ylim([-4, 4]) + + #self.sp_iq.axis([min(self.time), max(self.time), + # 1.5*min([min(self.acq_data_reals), min(self.acq_data_imags)]), + # 1.5*max([max(self.acq_data_reals), max(self.acq_data_imags)])]) + + self.plot_const[0].set_data([self.acq_data_reals, self.acq_data_imags]) + self.plot_const[1].set_data([self.derot_data_reals, self.derot_data_imags]) + self.sp_const.axis([-2, 2, -2, 2]) + + self.plot_fft[0].set_data([self.freq, self.fft_data]) + + draw() + + def zoom(self, event): + newxlim = self.sp_eq.get_xlim() + if(newxlim != self.xlim): + self.xlim = newxlim + r = self.reals[int(ceil(self.xlim[0])) : int(ceil(self.xlim[1]))] + i = self.imags[int(ceil(self.xlim[0])) : int(ceil(self.xlim[1]))] + + self.plot_const[0].set_data(r, i) + self.sp_const.axis([-2, 2, -2, 2]) + self.manager.canvas.draw() + draw() + + def click(self, event): + forward_valid_keys = [" ", "down", "right"] + backward_valid_keys = ["up", "left"] + + if(find(event.key, forward_valid_keys)): + self.step_forward() + + elif(find(event.key, backward_valid_keys)): + self.step_backward() + + def button_left_click(self, event): + self.step_backward() + + def button_right_click(self, event): + self.step_forward() + + def step_forward(self): + self.symbol += 1 + self.get_data() + self.update_plots() + + def step_backward(self): + # Step back in file position + self.symbol -= 1 + if(self.h_acq_file.tell() >= 16*self.occ_tones): + self.h_acq_file.seek(-16*self.occ_tones, 1) + else: + self.symbol = 0 + self.h_acq_file.seek(-self.h_acq_file.tell(),1) + + + if(self.h_derot_file.tell() >= 16*self.occ_tones): + self.h_derot_file.seek(-16*self.occ_tones, 1) + else: + self.symbol = 0 + self.h_derot_file.seek(-self.h_derot_file.tell(),1) + + + if(self.h_fft_file.tell() >= 16*self.fft_size): + self.h_fft_file.seek(-16*self.fft_size, 1) + else: + self.symbol = 0 + self.h_fft_file.seek(-self.h_fft_file.tell(),1) + + self.get_data() + self.update_plots() + + + +#FIXME: there must be a way to do this with a Python builtin +def find(item_in, list_search): + for l in list_search: + if item_in == l: + return True + return False + +def main(): + usage="%prog: [options]" + + parser = OptionParser(conflict_handler="resolve", usage=usage) + parser.add_option("", "--fft-size", type="int", default=512, + help="Specify the size of the FFT [default=%default]") + parser.add_option("", "--occ-tones", type="int", default=200, + help="Specify the number of occupied tones [default=%default]") + parser.add_option("-s", "--start", type="int", default=0, + help="Specify the starting symbol to plot [default=%default]") + parser.add_option("-R", "--sample-rate", type="float", default=1.0, + help="Set the sampler rate of the data [default=%default]") + + (options, args) = parser.parse_args () + + dc = draw_constellation(options) + +if __name__ == "__main__": + try: + main() + except KeyboardInterrupt: + pass + + + diff --git a/gnuradio-examples/python/ofdm/plot_ofdm.m b/gnuradio-examples/python/ofdm/plot_ofdm.m index 87eae3a116..2a649b5f55 100755 --- a/gnuradio-examples/python/ofdm/plot_ofdm.m +++ b/gnuradio-examples/python/ofdm/plot_ofdm.m @@ -1,13 +1,22 @@ function plot_ofdm(fft_size, occ_tones) -ofdm = read_complex_binary('ofdm_corr_out_c.dat'); +ofdm = read_complex_binary('ofdm_frame_acq_c.dat'); ofdm_split = split_vect(ofdm, occ_tones); +ofdm_derot = read_complex_binary('ofdm_frame_sink_c.dat'); +ofdm_derot_split = split_vect(ofdm_derot, occ_tones); + fftc = read_complex_binary('fft_out_c.dat'); fftc_split = split_vect(fftc, fft_size); +size(ofdm_split) +size(ofdm_derot_split) +disp "DEROTATED SPLIT" +ofdm_derot(1:100) + + figure(1) -set(gcf, 'Position', [50 50 1000 600]); +#set(gcf, 'Position', [50 50 1000 600]); a = size(ofdm_split); if nargin == 3 @@ -19,47 +28,47 @@ else maxcount = a(1); end -for i = 1:20000 +for i = 1:size(ofdm_split)[0] x = ofdm_split(i,:); y = fftc_split(i+1,:); - subplot(2,2,1) - plot(real(x), imag(x), 'bo') - set(gca, 'FontSize', 30, 'FontWeight', 'Bold'); + subplot(2,2,1); + plot(real(x), imag(x), 'bo'); + #set(gca, 'FontSize', 30, 'FontWeight', 'Bold'); axis([-1.5, 1.5, -1.5, 1.5]) - title('I&Q Constellation', 'FontSize', 36); - xlabel('Inphase', 'FontSize', 32); - ylabel('Quadrature', 'FontSize', 32); + #title('I&Q Constellation', 'FontSize', 36); + #xlabel('Inphase', 'FontSize', 32); + #ylabel('Quadrature', 'FontSize', 32); - subplot(2,2,3) - plot(angle(x*j), 'bo') - set(gca, 'FontSize', 30, 'FontWeight', 'Bold'); + subplot(2,2,3); + plot(angle(x*j), 'bo'); + #set(gca, 'FontSize', 30, 'FontWeight', 'Bold'); axis([0, occ_tones, -3.5, 3.5]) - title('Equalized Symbol Angle', 'FontSize', 36); - xlabel('Bin Number (Occ. Tones)', 'FontSize', 32); - ylabel('Symbol Angle', 'FontSize', 32); + #title('Equalized Symbol Angle', 'FontSize', 36); + #xlabel('Bin Number (Occ. Tones)', 'FontSize', 32); + #ylabel('Symbol Angle', 'FontSize', 32); - subplot(2,2,2) - plot(angle(y*j), 'bo') - set(gca, 'FontSize', 30, 'FontWeight', 'Bold'); + subplot(2,2,2); + plot(angle(y*j), 'bo'); + #set(gca, 'FontSize', 30, 'FontWeight', 'Bold'); axis([0, fft_size, -3.5, 3.5]) - title('Unequalized Symbol Angle', 'FontSize', 36); - xlabel('Bin Number (FFT Size)', 'FontSize', 32); - ylabel('Symbol Angle', 'FontSize', 32); + #title('Unequalized Symbol Angle', 'FontSize', 36); + #xlabel('Bin Number (FFT Size)', 'FontSize', 32); + #ylabel('Symbol Angle', 'FontSize', 32); Y = 20*log10(abs(y) ./ max(abs(y))); - subplot(2,2,4) - plot(Y, 'b-') - set(gca, 'FontSize', 30, 'FontWeight', 'Bold'); + subplot(2,2,4); + plot(Y, 'b-'); + #set(gca, 'FontSize', 30, 'FontWeight', 'Bold'); axis([0, fft_size, -50, 1]); - title('Frequency Domain of Unequalized Rx', 'FontSize', 36); - xlabel('Bin Number (FFT Size)', 'FontSize', 32); - ylabel('Power (dB)', 'FontSize', 32); + #title('Frequency Domain of Unequalized Rx', 'FontSize', 36); + #xlabel('Bin Number (FFT Size)', 'FontSize', 32); + #ylabel('Power (dB)', 'FontSize', 32); - % N = 20*log10(var(abs(x)-1)) + #N = 20*log10(var(abs(x)-1)); disp(sprintf('Symbol Number: %d\n', i)) -% disp(sprintf('\tFreq Error: %f\n', anglesh_pn(1+(i-1)*fft_size))) + #disp(sprintf('\tFreq Error: %f\n', anglesh_pn(1+(i-1)*fft_size))) pause end diff --git a/gnuradio-examples/python/ofdm/receive_path.py b/gnuradio-examples/python/ofdm/receive_path.py index 2ebaad8838..b758bc4d0c 100644 --- a/gnuradio-examples/python/ofdm/receive_path.py +++ b/gnuradio-examples/python/ofdm/receive_path.py @@ -20,7 +20,7 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr, gru, blks +from gnuradio import gr, gru, blks2 from gnuradio import usrp from gnuradio import eng_notation import copy @@ -33,8 +33,13 @@ from pick_bitrate import pick_rx_bitrate # receive path # ///////////////////////////////////////////////////////////////////////////// -class receive_path(gr.hier_block): - def __init__(self, fg, rx_callback, options): +class receive_path(gr.hier_block2): + def __init__(self, rx_callback, options): + + gr.hier_block2.__init__(self, "receive_path", + gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature + gr.io_signature(0, 0, 0)) # Output signature + options = copy.copy(options) # make a copy so we can destructively modify @@ -44,20 +49,20 @@ class receive_path(gr.hier_block): # receiver self.ofdm_rx = \ - blks.ofdm_demod(fg, options, callback=self._rx_callback) + blks2.ofdm_demod(options, callback=self._rx_callback) # Carrier Sensing Blocks alpha = 0.001 thresh = 30 # in dB, will have to adjust self.probe = gr.probe_avg_mag_sqrd_c(thresh,alpha) - fg.connect(self.ofdm_rx.ofdm_recv.chan_filt, self.probe) + + self.connect(self, self.ofdm_rx) + self.connect(self.ofdm_rx, self.probe) # Display some information about the setup if self._verbose: self._print_verbage() - gr.hier_block.__init__(self, fg, self.ofdm_rx, None) - def carrier_sensed(self): """ Return True if we think carrier is present. diff --git a/gnuradio-examples/python/ofdm/transmit_path.py b/gnuradio-examples/python/ofdm/transmit_path.py index f15845b007..44c7331b05 100644 --- a/gnuradio-examples/python/ofdm/transmit_path.py +++ b/gnuradio-examples/python/ofdm/transmit_path.py @@ -19,7 +19,7 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr, gru, blks +from gnuradio import gr, gru, blks2 from gnuradio import usrp from gnuradio import eng_notation @@ -30,19 +30,23 @@ import sys # transmit path # ///////////////////////////////////////////////////////////////////////////// -class transmit_path(gr.hier_block): - def __init__(self, fg, options): +class transmit_path(gr.hier_block2): + def __init__(self, options): ''' See below for what options should hold ''' + gr.hier_block2.__init__(self, "transmit_path", + gr.io_signature(0, 0, 0), # Input signature + gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature + options = copy.copy(options) # make a copy so we can destructively modify - self._verbose = options.verbose + self._verbose = options.verbose # turn verbose mode on/off self._tx_amplitude = options.tx_amplitude # digital amplitude sent to USRP self.ofdm_tx = \ - blks.ofdm_mod(fg, options, msgq_limit=4, pad_for_usrp=False) + blks2.ofdm_mod(options, msgq_limit=4, pad_for_usrp=False) self.amp = gr.multiply_const_cc(1) self.set_tx_amplitude(self._tx_amplitude) @@ -52,8 +56,7 @@ class transmit_path(gr.hier_block): self._print_verbage() # Create and setup transmit path flow graph - fg.connect(self.ofdm_tx, self.amp) - gr.hier_block.__init__(self, fg, None, self.amp) + self.connect(self.ofdm_tx, self.amp, self) def set_tx_amplitude(self, ampl): """ |