commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r9565 - in gnuradio/branches/developers/jcorgan/bert:


From: jcorgan
Subject: [Commit-gnuradio] r9565 - in gnuradio/branches/developers/jcorgan/bert: config gnuradio-examples/python gnuradio-examples/python/digital-bert
Date: Sat, 13 Sep 2008 00:17:25 -0600 (MDT)

Author: jcorgan
Date: 2008-09-13 00:17:22 -0600 (Sat, 13 Sep 2008)
New Revision: 9565

Added:
   
gnuradio/branches/developers/jcorgan/bert/gnuradio-examples/python/digital-bert/
   
gnuradio/branches/developers/jcorgan/bert/gnuradio-examples/python/digital-bert/Makefile.am
   
gnuradio/branches/developers/jcorgan/bert/gnuradio-examples/python/digital-bert/benchmark_rx.py
   
gnuradio/branches/developers/jcorgan/bert/gnuradio-examples/python/digital-bert/benchmark_tx.py
   
gnuradio/branches/developers/jcorgan/bert/gnuradio-examples/python/digital-bert/receive_path.py
   
gnuradio/branches/developers/jcorgan/bert/gnuradio-examples/python/digital-bert/transmit_path.py
Modified:
   gnuradio/branches/developers/jcorgan/bert/config/grc_gnuradio_examples.m4
   
gnuradio/branches/developers/jcorgan/bert/gnuradio-examples/python/Makefile.am
Log:
Add preliminary BERT transmitter and receiver example scripts for BPSK.

Modified: 
gnuradio/branches/developers/jcorgan/bert/config/grc_gnuradio_examples.m4
===================================================================
--- gnuradio/branches/developers/jcorgan/bert/config/grc_gnuradio_examples.m4   
2008-09-13 06:02:19 UTC (rev 9564)
+++ gnuradio/branches/developers/jcorgan/bert/config/grc_gnuradio_examples.m4   
2008-09-13 06:17:22 UTC (rev 9565)
@@ -34,6 +34,7 @@
        gnuradio-examples/python/dect/Makefile \
        gnuradio-examples/python/digital/Makefile \
        gnuradio-examples/python/digital_voice/Makefile \
+        gnuradio-examples/python/digital-bert/Makefile \
        gnuradio-examples/python/mp-sched/Makefile \
        gnuradio-examples/python/multi-antenna/Makefile \
        gnuradio-examples/python/multi_usrp/Makefile \

Modified: 
gnuradio/branches/developers/jcorgan/bert/gnuradio-examples/python/Makefile.am
===================================================================
--- 
gnuradio/branches/developers/jcorgan/bert/gnuradio-examples/python/Makefile.am  
    2008-09-13 06:02:19 UTC (rev 9564)
+++ 
gnuradio/branches/developers/jcorgan/bert/gnuradio-examples/python/Makefile.am  
    2008-09-13 06:17:22 UTC (rev 9565)
@@ -26,6 +26,7 @@
        audio \
        dect \
        digital \
+       digital-bert \
        digital_voice \
        mp-sched \
        multi-antenna \


Property changes on: 
gnuradio/branches/developers/jcorgan/bert/gnuradio-examples/python/digital-bert
___________________________________________________________________
Name: svn:ignore
   + Makefile
Makefile.in


Added: 
gnuradio/branches/developers/jcorgan/bert/gnuradio-examples/python/digital-bert/Makefile.am
===================================================================
--- 
gnuradio/branches/developers/jcorgan/bert/gnuradio-examples/python/digital-bert/Makefile.am
                         (rev 0)
+++ 
gnuradio/branches/developers/jcorgan/bert/gnuradio-examples/python/digital-bert/Makefile.am
 2008-09-13 06:17:22 UTC (rev 9565)
@@ -0,0 +1,33 @@
+#
+# Copyright 2008 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.
+# 
+
+include $(top_srcdir)/Makefile.common
+
+EXTRA_DIST =                   \
+       benchmark_rx.py         \
+       benchmark_tx.py         \
+       receive_path.py         \
+       transmit_path.py
+
+ourdatadir = $(exampledir)/digital-bert
+ourdata_DATA = $(EXTRA_DIST)
+
+MOSTLYCLEANFILES = *.pyc *.pyo *~

Added: 
gnuradio/branches/developers/jcorgan/bert/gnuradio-examples/python/digital-bert/benchmark_rx.py
===================================================================
--- 
gnuradio/branches/developers/jcorgan/bert/gnuradio-examples/python/digital-bert/benchmark_rx.py
                             (rev 0)
+++ 
gnuradio/branches/developers/jcorgan/bert/gnuradio-examples/python/digital-bert/benchmark_rx.py
     2008-09-13 06:17:22 UTC (rev 9565)
@@ -0,0 +1,111 @@
+#!/usr/bin/env python
+#
+# Copyright 2008 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.
+#
+
+from gnuradio import gr, eng_notation, usrp
+from optparse import OptionParser
+from gnuradio.eng_option import eng_option
+from receive_path import receive_path
+
+n2s = eng_notation.num_to_str
+
+_adc_rate = 64e6
+
+class rx_bpsk_block(gr.top_block):
+    def __init__(self, options):    
+
+       gr.top_block.__init__(self, "rx_mpsk")
+
+        if_rate = _adc_rate/options.decim_rate
+        
+        print "USRP decimation rate", options.decim_rate
+
+        # Create a USRP source at desired board, sample rate, frequency, and 
gain
+        self._setup_usrp(options.which,
+                         options.decim_rate,
+                         options.rx_subdev_spec,
+                         options.freq,
+                         options.gain)
+
+        self._receiver = receive_path(if_rate,
+                                      options.rate,
+                                      options.excess_bw)
+        
+        self.connect(self._usrp, self._receiver)
+
+        self._usrp_sink = gr.file_sink(gr.sizeof_gr_complex, 'usrp.dat')
+        self.connect(self._usrp, self._usrp_sink)
+
+
+    def _setup_usrp(self, which, decim, subdev_spec, freq, gain):
+        self._usrp = usrp.source_c(which=which, decim_rate=decim)
+       if subdev_spec is None:
+           subdev_spec = usrp.pick_rx_subdevice(self._usrp)
+       self._subdev = usrp.selected_subdev(self._usrp, subdev_spec)
+        mux = usrp.determine_rx_mux_value(self._usrp, subdev_spec)
+       self._usrp.set_mux(mux)
+       tr = self._usrp.tune(0, self._subdev, freq)
+        if not (tr):
+            print "Failed to tune to center frequency!"
+        else:
+            print "Center frequency:", n2s(freq)
+        if gain is None:
+            g = self._subdev.gain_range();
+            gain = float(g[0]+g[1])/2.0
+       self._subdev.set_gain(gain)
+        print "RX d'board:", self._subdev.side_and_name()
+        
+        
+def get_options():
+    parser = OptionParser(option_class=eng_option)
+    parser.add_option("-w", "--which", type="int", default=0,
+                      help="select which USRP (0, 1, ...) default is %default",
+                      metavar="NUM")
+    parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=None,
+                      help="select USRP Rx side A or B (default=first one with 
a daughterboard)")
+    parser.add_option("-f", "--freq", type="eng_float", default=None,
+                      help="set frequency to FREQ", metavar="FREQ")
+    parser.add_option("-g", "--gain", type="eng_float", default=None,
+                      help="set Rx gain (default is mid-point)")
+    parser.add_option("-r", "--rate", type="eng_float", default=250e3,
+                      help="Select modulation symbol rate (default=%default)")
+    parser.add_option("-d", "--decim-rate", type="int", default=8,
+                      help="Select USRP decimation rate (default=%default)")
+    parser.add_option("", "--excess-bw", type="eng_float", default=0.35,
+                      help="Select RRC excess bandwidth (default=%default)")
+                     
+    (options, args) = parser.parse_args()
+    if len(args) != 0:
+        parser.print_help()
+        sys.exit(1)
+       
+    return (options, args)
+
+
+if __name__ == "__main__":
+    (options, args) = get_options()
+
+    tb = rx_bpsk_block(options)
+
+    try:    
+        tb.run()
+    except KeyboardInterrupt:
+        pass


Property changes on: 
gnuradio/branches/developers/jcorgan/bert/gnuradio-examples/python/digital-bert/benchmark_rx.py
___________________________________________________________________
Name: svn:executable
   + *

Added: 
gnuradio/branches/developers/jcorgan/bert/gnuradio-examples/python/digital-bert/benchmark_tx.py
===================================================================
--- 
gnuradio/branches/developers/jcorgan/bert/gnuradio-examples/python/digital-bert/benchmark_tx.py
                             (rev 0)
+++ 
gnuradio/branches/developers/jcorgan/bert/gnuradio-examples/python/digital-bert/benchmark_tx.py
     2008-09-13 06:17:22 UTC (rev 9565)
@@ -0,0 +1,106 @@
+#!/usr/bin/env python
+#
+# Copyright 2008 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.
+#
+
+from gnuradio import gr, eng_notation, usrp
+from gnuradio.eng_option import eng_option
+from optparse import OptionParser
+from transmit_path import transmit_path
+
+_dac_rate = 128e6
+
+n2s = eng_notation.num_to_str
+
+class tx_bpsk_block(gr.top_block):
+    def __init__(self, options):    
+       gr.top_block.__init__(self, "tx_mpsk")
+
+        self._transmitter = transmit_path(options.sps,
+                                          options.excess_bw,
+                                          options.amplitude)
+
+        if_rate = options.rate*options.sps
+        interp = int(_dac_rate/if_rate)
+
+        print "Modulation:", n2s(options.rate), "bits/sec"
+        print "TX IF rate:", n2s(if_rate), "samples/sec"
+        print "USRP interpolation:", interp
+        print "DAC amplitude:", options.amplitude
+
+        self._setup_usrp(options.which,
+                         interp,
+                         options.tx_subdev_spec,
+                         options.freq)
+       
+       self.connect(self._transmitter, self._usrp)
+
+        
+    def _setup_usrp(self, which, interp, subdev_spec, freq):
+        self._usrp = usrp.sink_c(which=which, interp_rate=interp)
+       if subdev_spec is None:
+           subdev_spec = usrp.pick_tx_subdevice(self._usrp)
+       self._usrp.set_mux(usrp.determine_tx_mux_value(self._usrp, subdev_spec))
+       self._subdev = usrp.selected_subdev(self._usrp, subdev_spec)
+       tr = usrp.tune(self._usrp, self._subdev._which, self._subdev, freq)
+        if not (tr):
+            print "Failed to tune to center frequency!"
+        else:
+            print "Center frequency:", n2s(freq)
+        gain = float(self._subdev.gain_range()[1]) # Max TX gain
+       self._subdev.set_gain(gain)
+       self._subdev.set_enable(True)
+        print "TX d'board:", self._subdev.side_and_name()
+        
+
+def get_options():
+    parser = OptionParser(option_class=eng_option)
+    parser.add_option("-w", "--which", type="int", default=0,
+                      help="select which USRP (0, 1, ...) default is %default",
+                      metavar="NUM")
+    parser.add_option("-T", "--tx-subdev-spec", type="subdev", default=None,
+                      help="select USRP Tx side A or B (default=first one with 
a daughterboard)")
+    parser.add_option("-f", "--freq", type="eng_float", default=None,
+                      help="set frequency to FREQ", metavar="FREQ")
+    parser.add_option("-a", "--amplitude", type="eng_float", default=2000,
+                      help="set Tx amplitude (0-32767) (default=%default)")
+    parser.add_option("-r", "--rate", type="eng_float", default=250e3,
+                      help="Select modulation symbol rate (default=%default)")
+    parser.add_option("", "--sps", type="int", default=2,
+                      help="Select samples per symbol (default=%default)")
+    parser.add_option("", "--excess-bw", type="eng_float", default=0.35,
+                      help="Select RRC excess bandwidth (default=%default)")
+                     
+    (options, args) = parser.parse_args()
+    if len(args) != 0:
+        parser.print_help()
+        sys.exit(1)
+       
+    return (options, args)
+
+if __name__ == "__main__":
+    (options, args) = get_options()
+    
+    tb = tx_bpsk_block(options)
+
+    try:
+        tb.run()
+    except KeyboardInterrupt:
+        pass


Property changes on: 
gnuradio/branches/developers/jcorgan/bert/gnuradio-examples/python/digital-bert/benchmark_tx.py
___________________________________________________________________
Name: svn:executable
   + *

Added: 
gnuradio/branches/developers/jcorgan/bert/gnuradio-examples/python/digital-bert/receive_path.py
===================================================================
--- 
gnuradio/branches/developers/jcorgan/bert/gnuradio-examples/python/digital-bert/receive_path.py
                             (rev 0)
+++ 
gnuradio/branches/developers/jcorgan/bert/gnuradio-examples/python/digital-bert/receive_path.py
     2008-09-13 06:17:22 UTC (rev 9565)
@@ -0,0 +1,98 @@
+#
+# Copyright 2008 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.
+#
+
+from gnuradio import gr, eng_notation
+n2s = eng_notation.num_to_str
+
+class receive_path(gr.hier_block2):
+    def __init__(self,
+                 if_rate,       # Incoming sample rate
+                 symbol_rate,   # Original symbol rate
+                 excess_bw      # RRC excess bandwidth, typically 0.35-0.5
+                 ):
+        
+        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
+
+        sps = int(if_rate/symbol_rate)
+        print "IF sample rate:", n2s(if_rate)
+        print "Symbol rate:", n2s(symbol_rate)
+        print "Samples/symbol:", sps
+        print "RRC bandwidth:", excess_bw
+        
+        # Create AGC to scale input to unity
+        self._agc = gr.agc_cc(1e-5, 1.0, 1.0, 1.0)
+
+       # Create RRC with specified excess bandwidth
+       taps = gr.firdes.root_raised_cosine(1.0,       # Gain
+                                           sps,       # Sampling rate
+                                           1.0,       # Symbol rate
+                                           excess_bw, # Roll-off factor
+                                           11*sps)    # Number of taps
+
+       self._rrc = gr.fir_filter_ccf(1, taps)
+        
+        # Create a Costas loop frequency/phase recovery block
+        costas_alpha=0.2
+        costas_beta=costas_alpha*costas_alpha/4.0;
+        costas_max = 0.005
+
+        print "Costas alpha:", costas_alpha
+        print "Costas beta:", costas_beta
+        print "Costas max:", costas_max
+        
+        self._costas = gr.costas_loop_cc(costas_alpha,  # PLL first order gain
+                                         costas_beta,   # PLL second order gain
+                                         costas_max,    # Max frequency offset 
rad/sample
+                                         -costas_max,   # Min frequency offset 
rad/sample
+                                         2)             # BPSK
+
+        # Create a M&M bit synchronization retiming block
+        mm_mu = 0.5
+        mm_omega = sps
+        mm_gain_mu=0.2
+        mm_gain_omega = mm_gain_mu*mm_gain_mu/0.4
+        mm_omega_limit=0.005
+
+        print "MM gain mu:", mm_gain_mu
+        print "MM omega:", mm_omega
+        print "MM gain omega:", mm_gain_omega
+        print "MM omega limit:", mm_omega_limit
+        
+        self._mm = gr.clock_recovery_mm_cc(mm_omega,       # Initial 
samples/symbol
+                                           mm_gain_omega,  # Second order gain
+                                           mm_mu,          # Initial symbol 
phase
+                                           mm_gain_mu,     # First order gain
+                                           mm_omega_limit) # Maximum timing 
offset
+
+        # Slice the resulting constellation into bits.
+        # Get inphase channel and make decision about 0
+        self._c2r = gr.complex_to_real()
+        self._slicer = gr.binary_slicer_fb() 
+        
+        # Descramble BERT sequence.  A channel error will create 3 incorrect 
bits
+        self._descrambler = gr.descrambler_bb(0x8A, 0x7F, 7) # CCSDS 7-bit 
descrambler
+        self._sink = gr.file_sink(gr.sizeof_char, "descrambler.dat")
+
+        self.connect(self, self._agc, self._rrc, self._costas, self._mm, 
+                     self._c2r, self._slicer, self._descrambler, self._sink)
+

Added: 
gnuradio/branches/developers/jcorgan/bert/gnuradio-examples/python/digital-bert/transmit_path.py
===================================================================
--- 
gnuradio/branches/developers/jcorgan/bert/gnuradio-examples/python/digital-bert/transmit_path.py
                            (rev 0)
+++ 
gnuradio/branches/developers/jcorgan/bert/gnuradio-examples/python/digital-bert/transmit_path.py
    2008-09-13 06:17:22 UTC (rev 9565)
@@ -0,0 +1,62 @@
+#!/usr/bin/env python
+#
+# Copyright 2008 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.
+#
+
+from gnuradio import gr
+from math import pi, log10
+import cmath
+
+class transmit_path(gr.hier_block2):
+    """
+    This transmits a BERT sequence of bits using filtered BPSK and
+    outputs the complex baseband waveform.
+    """
+    def __init__(self,
+                 sps,          # Samples per symbol
+                 excess_bw,    # RRC filter excess bandwidth (typically 
0.35-0.5)
+                 amplitude     # DAC output level, 0-32767, typically 2000-8000
+                 ):
+
+        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
+
+        # Create BERT data bit stream  
+       self._bits = gr.vector_source_b([1,], True)      # Infinite stream of 
ones
+        self._scrambler = gr.scrambler_bb(0x8A, 0x7F, 7) # CCSDS 7-bit 
scrambler
+
+       # Map to constellation
+       self._constellation = [-1+0j, 1+0j]
+       self._mapper = gr.chunks_to_symbols_bc(self._constellation)     
+
+       # Create RRC with specified excess bandwidth
+       taps = gr.firdes.root_raised_cosine(sps*amplitude,  # Gain
+                                           sps,            # Sampling rate
+                                           1.0,            # Symbol rate
+                                           excess_bw,      # Roll-off factor
+                                           11*sps)         # Number of taps
+
+       self._rrc = gr.interp_fir_filter_ccf(sps,           # Interpolation rate
+                                            taps)          # FIR taps
+
+        # Wire block inputs and outputs
+        self.connect(self._bits, self._scrambler, self._mapper, self._rrc, 
self)
+





reply via email to

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