diff options
author | trondeau | 2007-06-10 18:16:11 +0000 |
---|---|---|
committer | trondeau | 2007-06-10 18:16:11 +0000 |
commit | a663f5b481679d8a352c668825cee92f548f3fcc (patch) | |
tree | 9286d4480cd964413b6e87aa6656d9e90e43ab13 /gnuradio-examples | |
parent | 616296d9e9e091360101f7f68b0c03ec1a6e382d (diff) | |
download | gnuradio-a663f5b481679d8a352c668825cee92f548f3fcc.tar.gz gnuradio-a663f5b481679d8a352c668825cee92f548f3fcc.tar.bz2 gnuradio-a663f5b481679d8a352c668825cee92f548f3fcc.zip |
Merging OFDM features branch r5661:5759 into trunk. OFDM works over the air with BPSK and QPSK modulations on subcarriers. Passes make distcheck.
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@5761 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'gnuradio-examples')
-rwxr-xr-x | gnuradio-examples/python/ofdm/benchmark_ofdm.py | 16 | ||||
-rwxr-xr-x | gnuradio-examples/python/ofdm/benchmark_ofdm_rx.py | 32 | ||||
-rwxr-xr-x | gnuradio-examples/python/ofdm/benchmark_ofdm_tx.py | 30 | ||||
-rw-r--r-- | gnuradio-examples/python/ofdm/ofdm_sync_pn.m | 21 | ||||
-rwxr-xr-x | gnuradio-examples/python/ofdm/plot_ofdm.m | 65 | ||||
-rw-r--r-- | gnuradio-examples/python/ofdm/receive_path.py | 14 | ||||
-rw-r--r-- | gnuradio-examples/python/ofdm/transmit_path.py | 17 |
7 files changed, 132 insertions, 63 deletions
diff --git a/gnuradio-examples/python/ofdm/benchmark_ofdm.py b/gnuradio-examples/python/ofdm/benchmark_ofdm.py index 53f4bd0bf..3c4f172c2 100755 --- a/gnuradio-examples/python/ofdm/benchmark_ofdm.py +++ b/gnuradio-examples/python/ofdm/benchmark_ofdm.py @@ -24,7 +24,6 @@ from gnuradio import gr, blks from gnuradio import eng_notation from gnuradio.eng_option import eng_option from optparse import OptionParser -from gnuradio.blksimpl import ofdm_pkt import random, time, struct, sys, math, os @@ -77,10 +76,11 @@ class my_graph(gr.flow_graph): 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.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")) + + 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")) # ///////////////////////////////////////////////////////////////////////////// # main @@ -121,7 +121,7 @@ def main(): parser.add_option("-M", "--megabytes", type="eng_float", default=1.0, help="set megabytes to transmit [default=%default]") parser.add_option("-r", "--sample-rate", type="eng_float", default=1e5, - help="set sample rate to RATE (%default)") + help="limit sample rate to RATE in throttle (%default)") parser.add_option("", "--snr", type="eng_float", default=30, help="set the SNR of the channel in dB [default=%default]") parser.add_option("", "--frequency-offset", type="eng_float", default=0, @@ -137,8 +137,8 @@ def main(): transmit_path.add_options(parser, expert_grp) receive_path.add_options(parser, expert_grp) - ofdm_pkt.mod_ofdm_pkts.add_options(parser, expert_grp) - ofdm_pkt.demod_ofdm_pkts.add_options(parser, expert_grp) + blks.ofdm_mod.add_options(parser, expert_grp) + blks.ofdm_demod.add_options(parser, expert_grp) (options, args) = parser.parse_args () diff --git a/gnuradio-examples/python/ofdm/benchmark_ofdm_rx.py b/gnuradio-examples/python/ofdm/benchmark_ofdm_rx.py index f8ebb820d..6ab8e1572 100755 --- a/gnuradio-examples/python/ofdm/benchmark_ofdm_rx.py +++ b/gnuradio-examples/python/ofdm/benchmark_ofdm_rx.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2005, 2006 Free Software Foundation, Inc. +# Copyright 2006, 2007 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -20,17 +20,17 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr, gru, modulation_utils +from gnuradio import gr, blks 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, math +import random, time, struct, sys # from current dir from receive_path import receive_path -import ofdm, fusb_options +import fusb_options class usrp_graph(gr.flow_graph): def __init__(self, callback, options): @@ -118,9 +118,6 @@ class usrp_graph(gr.flow_graph): Adds usrp-specific options to the Options Parser """ add_freq_option(normal) - if not normal.has_option("--bitrate"): - normal.add_option("-r", "--bitrate", type="eng_float", default=None, - help="specify bitrate. samples-per-symbol and interp/decim will be derived.") normal.add_option("-R", "--rx-subdev-spec", type="subdev", default=None, help="select USRP Rx side A or B") normal.add_option("", "--rx-gain", type="eng_float", default=None, metavar="GAIN", @@ -129,8 +126,6 @@ class usrp_graph(gr.flow_graph): help="print min and max Rx gain available on selected daughterboard") normal.add_option("-v", "--verbose", action="store_true", default=False) - expert.add_option("-S", "--samples-per-symbol", type="int", default=None, - help="set samples/symbol [default=%default]") expert.add_option("", "--rx-freq", type="eng_float", default=None, help="set Rx frequency to FREQ [default=%default]", metavar="FREQ") expert.add_option("-d", "--decim", type="intx", default=32, @@ -175,14 +170,27 @@ def main(): n_right += 1 print "ok: %r \t pktno: %d \t n_rcvd: %d \t n_right: %d" % (ok, pktno, n_rcvd, n_right) + if 0: + printlst = list() + for x in payload[2:]: + t = hex(ord(x)).replace('0x', '') + if(len(t) == 1): + t = '0' + t + printlst.append(t) + printable = ''.join(printlst) + + print printable + print "\n" + parser = OptionParser(option_class=eng_option, conflict_handler="resolve") expert_grp = parser.add_option_group("Expert") - parser.add_option("-r", "--sample-rate", type="eng_float", default=1e5, - help="set sample rate to RATE (%default)") + parser.add_option("","--discontinuous", action="store_true", default=False, + help="enable discontinuous") usrp_graph.add_options(parser, expert_grp) receive_path.add_options(parser, expert_grp) - ofdm.ofdm_mod.add_options(parser, expert_grp) + blks.ofdm_mod.add_options(parser, expert_grp) + blks.ofdm_demod.add_options(parser, expert_grp) fusb_options.add_options(expert_grp) (options, args) = parser.parse_args () diff --git a/gnuradio-examples/python/ofdm/benchmark_ofdm_tx.py b/gnuradio-examples/python/ofdm/benchmark_ofdm_tx.py index bda638053..9bdd5ecbb 100755 --- a/gnuradio-examples/python/ofdm/benchmark_ofdm_tx.py +++ b/gnuradio-examples/python/ofdm/benchmark_ofdm_tx.py @@ -20,18 +20,18 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr, gru, modulation_utils +from gnuradio import gr, blks 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, math +import time, struct, sys # from current dir from transmit_path import transmit_path from pick_bitrate import pick_tx_bitrate -import ofdm, fusb_options +import fusb_options class usrp_graph(gr.flow_graph): def __init__(self, options): @@ -39,7 +39,6 @@ class usrp_graph(gr.flow_graph): self._tx_freq = options.tx_freq # tranmitter's center frequency self._tx_subdev_spec = options.tx_subdev_spec # daughterboard to use - self._bitrate = options.bitrate # desired bit rate self._interp = options.interp # interpolating rate for the USRP (prelim) self._fusb_block_size = options.fusb_block_size # usb info for USRP self._fusb_nblocks = options.fusb_nblocks # usb info for USRP @@ -82,7 +81,7 @@ class usrp_graph(gr.flow_graph): # Set the USRP for maximum transmit gain # (Note that on the RFX cards this is a nop.) - self.set_gain(self.subdev.gain_range()[0]) + self.set_gain(self.subdev.gain_range()[1]) # enable Auto Transmit/Receive switching self.set_auto_tr(True) @@ -126,15 +125,10 @@ class usrp_graph(gr.flow_graph): Adds usrp-specific options to the Options Parser """ add_freq_option(normal) - if not normal.has_option('--bitrate'): - normal.add_option("-r", "--bitrate", type="eng_float", default=None, - help="specify bitrate. samples-per-symbol and interp/decim will be derived.") normal.add_option("-T", "--tx-subdev-spec", type="subdev", default=None, help="select USRP Tx side A or B") normal.add_option("-v", "--verbose", action="store_true", default=False) - expert.add_option("-S", "--samples-per-symbol", type="int", default=None, - help="set samples/symbol [default=%default]") expert.add_option("", "--tx-freq", type="eng_float", default=None, help="set transmit frequency to FREQ [default=%default]", metavar="FREQ") expert.add_option("-i", "--interp", type="intx", default=64, @@ -181,21 +175,17 @@ def main(): help="set packet size [default=%default]") parser.add_option("-M", "--megabytes", type="eng_float", default=1.0, help="set megabytes to transmit [default=%default]") - parser.add_option("-r", "--sample-rate", type="eng_float", default=1e5, - help="set sample rate to RATE (%default)") + parser.add_option("","--discontinuous", action="store_true", default=False, + help="enable discontinuous mode") usrp_graph.add_options(parser, expert_grp) transmit_path.add_options(parser, expert_grp) - ofdm.ofdm_mod.add_options(parser, expert_grp) + blks.ofdm_mod.add_options(parser, expert_grp) + blks.ofdm_demod.add_options(parser, expert_grp) fusb_options.add_options(expert_grp) (options, args) = parser.parse_args () - if(options.mtu < options.size): - sys.stderr.write("MTU (%.0f) must be larger than the packet size (%.0f)\n" - % (options.mtu, options.size)) - sys.exit(1) - # build the graph fg = usrp_graph(options) @@ -215,8 +205,8 @@ def main(): send_pkt(struct.pack('!H', pktno) + (pkt_size - 2) * chr(pktno & 0xff)) n += pkt_size sys.stderr.write('.') - #if options.discontinuous and pktno % 5 == 4: - # time.sleep(1) + if options.discontinuous and pktno % 5 == 1: + time.sleep(1) pktno += 1 send_pkt(eof=True) diff --git a/gnuradio-examples/python/ofdm/ofdm_sync_pn.m b/gnuradio-examples/python/ofdm/ofdm_sync_pn.m new file mode 100644 index 000000000..d93c0ca92 --- /dev/null +++ b/gnuradio-examples/python/ofdm/ofdm_sync_pn.m @@ -0,0 +1,21 @@ +mf = read_float_binary('ofdm_sync_pn-mf_f.dat'); +theta_pn = read_float_binary('ofdm_sync_pn-theta_f.dat'); +peaks_pn = read_char_binary('ofdm_sync_pn-peaks_b.dat'); +regen_pn = read_char_binary('ofdm_sync_pn-regen_b.dat'); +angle_pn = read_float_binary('ofdm_sync_pn-epsilon_f.dat'); + +plot(mf, 'k') +hold +plot(theta_pn, 'g'); +plot(peaks_pn, 'r'); +plot(regen_pn, 'b'); +xlim([100, 50000]); +ylim([0, 1]) +i = find(peaks_pn); +i(100:200) +hold off + +ipeaks = find(peaks_pn); +dpeaks = diff(ipeaks); +hist(dpeaks, 30) +set(gca, 'FontSize', 30, 'FontWeight', 'Bold'); diff --git a/gnuradio-examples/python/ofdm/plot_ofdm.m b/gnuradio-examples/python/ofdm/plot_ofdm.m new file mode 100755 index 000000000..87eae3a11 --- /dev/null +++ b/gnuradio-examples/python/ofdm/plot_ofdm.m @@ -0,0 +1,65 @@ +function plot_ofdm(fft_size, occ_tones) + +ofdm = read_complex_binary('ofdm_corr_out_c.dat'); +ofdm_split = split_vect(ofdm, occ_tones); + +fftc = read_complex_binary('fft_out_c.dat'); +fftc_split = split_vect(fftc, fft_size); + +figure(1) +set(gcf, 'Position', [50 50 1000 600]); + +a = size(ofdm_split); +if nargin == 3 + maxcount = count; + if maxcount > a(1) + error('plot_ofdm:tolong', 'Requested count size exceeds size of vectors'); + end +else + maxcount = a(1); +end + +for i = 1:20000 + 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'); + axis([-1.5, 1.5, -1.5, 1.5]) + 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'); + 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); + + 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); + + Y = 20*log10(abs(y) ./ max(abs(y))); + 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); + + % 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))) + pause + +end diff --git a/gnuradio-examples/python/ofdm/receive_path.py b/gnuradio-examples/python/ofdm/receive_path.py index 0e44ffde0..67a71204a 100644 --- a/gnuradio-examples/python/ofdm/receive_path.py +++ b/gnuradio-examples/python/ofdm/receive_path.py @@ -43,9 +43,8 @@ class receive_path(gr.hier_block): self._rx_callback = rx_callback # this callback is fired when there's a packet available # receiver - self.ofdm_receiver = \ - blks.demod_ofdm_pkts(fg, options, - callback=self._rx_callback) + self.ofdm_rx = \ + blks.ofdm_demod(fg, options, callback=self._rx_callback) # Carrier Sensing Blocks #alpha = 0.001 @@ -57,7 +56,7 @@ class receive_path(gr.hier_block): if self._verbose: self._print_verbage() - gr.hier_block.__init__(self, fg, self.ofdm_receiver, None) + gr.hier_block.__init__(self, fg, self.ofdm_rx, None) def carrier_sensed(self): """ @@ -98,9 +97,4 @@ class receive_path(gr.hier_block): """ Prints information about the receive path """ - print "Using RX d'board %s" % (self.subdev.side_and_name(),) - print "Rx gain: %g" % (self.gain,) - print "modulation: %s" % (self._demod_class.__name__) - print "bitrate: %sb/s" % (eng_notation.num_to_str(self._bitrate)) - print "samples/symbol: %3d" % (self._samples_per_symbol) - print "decim: %3d" % (self._decim) + pass diff --git a/gnuradio-examples/python/ofdm/transmit_path.py b/gnuradio-examples/python/ofdm/transmit_path.py index e684c442c..2576c2f48 100644 --- a/gnuradio-examples/python/ofdm/transmit_path.py +++ b/gnuradio-examples/python/ofdm/transmit_path.py @@ -41,11 +41,8 @@ class transmit_path(gr.hier_block): self._verbose = options.verbose self._tx_amplitude = options.tx_amplitude # digital amplitude sent to USRP - self.ofdm_transmitter = \ - blks.mod_ofdm_pkts(fg, - options, - msgq_limit=4, - pad_for_usrp=False) + self.ofdm_tx = \ + blks.ofdm_mod(fg, options, msgq_limit=4, pad_for_usrp=False) self.amp = gr.multiply_const_cc(1) self.set_tx_amplitude(self._tx_amplitude) @@ -55,7 +52,7 @@ class transmit_path(gr.hier_block): self._print_verbage() # Create and setup transmit path flow graph - fg.connect(self.ofdm_transmitter, self.amp) + fg.connect(self.ofdm_tx, self.amp) gr.hier_block.__init__(self, fg, None, self.amp) def set_tx_amplitude(self, ampl): @@ -70,14 +67,8 @@ class transmit_path(gr.hier_block): """ Calls the transmitter method to send a packet """ - return self.ofdm_transmitter.send_pkt(payload, eof) + return self.ofdm_tx.send_pkt(payload, eof) - def bitrate(self): - return self._bitrate - - def samples_per_symbol(self): - return self._samples_per_symbol - def add_options(normal, expert): """ Adds transmitter-specific options to the Options Parser |