commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r4768 - gnuradio/branches/developers/jcorgan/channel/g


From: jcorgan
Subject: [Commit-gnuradio] r4768 - gnuradio/branches/developers/jcorgan/channel/gnuradio-examples/python/hier/sounder
Date: Sat, 17 Mar 2007 15:49:59 -0600 (MDT)

Author: jcorgan
Date: 2007-03-17 15:49:59 -0600 (Sat, 17 Mar 2007)
New Revision: 4768

Modified:
   
gnuradio/branches/developers/jcorgan/channel/gnuradio-examples/python/hier/sounder/sounder_rx.py
   
gnuradio/branches/developers/jcorgan/channel/gnuradio-examples/python/hier/sounder/sounder_tx.py
   
gnuradio/branches/developers/jcorgan/channel/gnuradio-examples/python/hier/sounder/usrp_sounder_rx.py
   
gnuradio/branches/developers/jcorgan/channel/gnuradio-examples/python/hier/sounder/usrp_sounder_tx.py
   
gnuradio/branches/developers/jcorgan/channel/gnuradio-examples/python/hier/sounder/usrp_source.py
Log:
Merged -r4683:4693 from jcorgan/sounder into jcorgan/channel.

Modified: 
gnuradio/branches/developers/jcorgan/channel/gnuradio-examples/python/hier/sounder/sounder_rx.py
===================================================================
--- 
gnuradio/branches/developers/jcorgan/channel/gnuradio-examples/python/hier/sounder/sounder_rx.py
    2007-03-17 21:45:40 UTC (rev 4767)
+++ 
gnuradio/branches/developers/jcorgan/channel/gnuradio-examples/python/hier/sounder/sounder_rx.py
    2007-03-17 21:49:59 UTC (rev 4768)
@@ -28,51 +28,50 @@
 
 class sounder_rx(gr.hier_block2):
     """
-    Creates a top-level channel sounder block with the given parameters.
+    Creates a channel sounder receiver block with the given parameters.
     """
 
-    def __init__(self, subdev_spec, freq, cal, verbose, max_delay, chip_rate, 
gain):
+    def __init__(self, chip_rate, max_delay, tc, output_rate, verbose):
 
         # Call hierarchical block constructor
         # Top-level blocks have no inputs or outputs
         gr.hier_block2.__init__(self,
-                                "sounder_rx",           # Block typename
-                                gr.io_signature(0,0,0), # Input signature
-                                gr.io_signature(0,0,0)) # Output signature
-        self._freq = freq
-        self._cal = cal
-        self._verbose = verbose
-        self._max_delay = max_delay
+                                "sounder_rx",                                # 
Block typename
+                                gr.io_signature(1, 1, gr.sizeof_gr_complex), # 
Input signature
+                                gr.io_signature(0,0,0))                      # 
Output signature
 
-        self._u = usrp_source_c(0, subdev_spec, gain, chip_rate, self._freq, 
self._cal, verbose)
-        self.define_component("usrp", self._u)
-
-        self._chip_rate = self._u._if_rate
-        self._resolution = 1.0/self._chip_rate
-
+        self._max_delay = max_delay
+        self._chip_rate = chip_rate
+        self._tc = tc
+        self._output_rate = output_rate
+        self._verbose = verbose
         min_chips = int(math.ceil(2.0*self._max_delay * self._chip_rate))
         degree = int(math.ceil(math.log(min_chips)/math.log(2)))
         self._length = 2**degree-1
-        self._seq_per_sec = self._chip_rate/self._length
-        self._tap = 0.0001
+        self._rep_rate = self._chip_rate/float(self._length)
+        self._decim = int(self._rep_rate/self._output_rate)
+        self._output_rate = self._rep_rate
+        self._tap = 1.0-2.0/(self._tc*self._rep_rate+1.0)
 
         if self._verbose:
-            print "Actual chip rate is", n2s(self._chip_rate), "chips/sec"
-            print "Resolution is", n2s(self._resolution), "sec"
-            print "Using specified maximum delay spread of", self._max_delay, 
"sec"
             print "Mininum sequence length needed is", n2s(min_chips), "chips"
             print "Using PN sequence of degree", degree, "length", self._length
-            print "Sequences per second is", self._seq_per_sec
-            print "IIR tap is", self._tap
+            print "Sequence repetition rate is", n2s(self._rep_rate), "per sec"
+            print "Smoothing time constant is", n2s(self._tc), "sec"
+            print "IIR tap is", n2s(self._tap)
+            print "Using sequence decimation of", self._decim
+            print "Sequence output rate is", n2s(self._rep_rate/self._decim)
         
         self.define_component("s2v", gr.stream_to_vector(gr.sizeof_gr_complex, 
self._length))
         self.define_component("fft", gr.fft_vcc(self._length, True, ())) # No 
window needed
         self.define_component("avg", gr.single_pole_iir_filter_cc(self._tap, 
self._length))
-        self.define_component("keep", 
gr.keep_one_in_n(gr.sizeof_gr_complex*self._length, int(self._seq_per_sec)))
+        self.define_component("decim", 
gr.keep_one_in_n(gr.sizeof_gr_complex*self._length, self._decim))
         self.define_component("sink", 
gr.file_sink(gr.sizeof_gr_complex*self._length, "FFT.dat"))
 
-        self.connect("usrp", 0, "s2v", 0)
+        # Ultimately this will be
+        # self.connect("self s2v fft avg decim sink")
+        self.connect("self", 0, "s2v", 0)
         self.connect("s2v", 0, "fft", 0)
         self.connect("fft", 0, "avg", 0)
-        self.connect("avg", 0, "keep", 0)
-        self.connect("keep", 0, "sink", 0)
+        self.connect("avg", 0, "decim", 0)
+        self.connect("decim", 0, "sink", 0)

Modified: 
gnuradio/branches/developers/jcorgan/channel/gnuradio-examples/python/hier/sounder/sounder_tx.py
===================================================================
--- 
gnuradio/branches/developers/jcorgan/channel/gnuradio-examples/python/hier/sounder/sounder_tx.py
    2007-03-17 21:45:40 UTC (rev 4767)
+++ 
gnuradio/branches/developers/jcorgan/channel/gnuradio-examples/python/hier/sounder/sounder_tx.py
    2007-03-17 21:49:59 UTC (rev 4768)
@@ -21,50 +21,34 @@
 # 
 
 from gnuradio import gr, usrp, eng_notation
-from usrp_sink import usrp_sink_c
 import math
 
 n2s = eng_notation.num_to_str
 
 class sounder_tx(gr.hier_block2):
     """
-    Creates a top-level channel sounder block with the given parameters.
+    Creates a channel sounder generator with the given parameters.
     """
 
-    def __init__(self, subdev_spec, freq, cal, verbose, max_delay, chip_rate, 
amplitude):
-
-        # Call hierarchical block constructor
-        # Top-level blocks have no inputs or outputs
+    def __init__(self, max_delay, chip_rate, verbose):
         gr.hier_block2.__init__(self,
-                                "sounder_tx",           # Block typename
-                                gr.io_signature(0,0,0), # Input signature
-                                gr.io_signature(0,0,0)) # Output signature
-        self._freq = freq
-        self._cal = cal
-        self._verbose = verbose
+                                "sounder_tx",                          # Block 
typename
+                                gr.io_signature(0,0,0),                # Input 
signature
+                                gr.io_signature(1, 1, gr.sizeof_char)) # 
Output signature
+
         self._max_delay = max_delay
+        self._chip_rate = chip_rate
+        self._verbose = verbose
 
-        self._u = usrp_sink_c(0, subdev_spec, chip_rate, self._freq, 
self._cal, verbose)
-        self._chip_rate = self._u._if_rate
-        self._resolution = 1.0/self._chip_rate
-
         min_chips = int(math.ceil(2.0*self._max_delay * self._chip_rate))
         degree = int(math.ceil(math.log(min_chips)/math.log(2)))
         self._length = 2**degree-1
 
-        self._glfsr = gr.glfsr_source_b(degree)
-        self._mapper = gr.chunks_to_symbols_bc((-amplitude+0j, amplitude+0j), 
1)
         
         if self._verbose:
-            print "Actual chip rate is", n2s(self._chip_rate), "chips/sec"
-            print "Resolution is", n2s(self._resolution), "sec"
-            print "Using specified maximum delay spread of", self._max_delay, 
"sec"
             print "Mininum sequence length needed is", n2s(min_chips), "chips"
             print "Using PN sequence of degree", degree, "length", self._length
-            print "Output amplitude is", amplitude
             
-        self.define_component("glfsr", self._glfsr)
-        self.define_component("mapper", self._mapper)
-        self.define_component("usrp", self._u)
-        self.connect("glfsr", 0, "mapper", 0)
-        self.connect("mapper", 0, "usrp", 0)
+        # Connect PN source to block output
+        self.define_component("glfsr", gr.glfsr_source_b(degree))
+        self.connect("glfsr", 0, "self", 0)

Modified: 
gnuradio/branches/developers/jcorgan/channel/gnuradio-examples/python/hier/sounder/usrp_sounder_rx.py
===================================================================
--- 
gnuradio/branches/developers/jcorgan/channel/gnuradio-examples/python/hier/sounder/usrp_sounder_rx.py
       2007-03-17 21:45:40 UTC (rev 4767)
+++ 
gnuradio/branches/developers/jcorgan/channel/gnuradio-examples/python/hier/sounder/usrp_sounder_rx.py
       2007-03-17 21:49:59 UTC (rev 4768)
@@ -22,13 +22,19 @@
 
 from gnuradio import gr, eng_notation
 from gnuradio.eng_option import eng_option
+from gnuradio.wxgui import stdgui2, fftsink2, waterfallsink2, form, slider
 from optparse import OptionParser
+from usrp_source import usrp_source_c
 from sounder_rx import sounder_rx
+import wx
+import sys
 
-def main():
+n2s = eng_notation.num_to_str
+
+class usrp_sounder_rx(stdgui2.std_top_block):
+    def __init__(self, frame, panel, vbox, argv):
+        stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv)
        parser = OptionParser(option_class=eng_option)
-
-       # Receive path options
         parser.add_option("-R", "--rx-subdev-spec", type="subdev", 
default=None,
                           help="select USRP Rx side A or B (default=first 
found)")
         parser.add_option("-f", "--freq", type="eng_float", default=0.0,
@@ -43,27 +49,63 @@
                          help="set sounder chip rate (default=%default)")
        parser.add_option("-g", "--gain", type="eng_float", default=None,
                          help="set output amplitude (default=%default)")
+       parser.add_option("", "--tc", type="eng_float", default=1.0,
+                         help="set smoothing time constant in seconds 
(default=%default)")
+       parser.add_option("", "--update-rate", type="eng_float", default=1.0,
+                         help="set output update rate per second 
(default=%default)")
         (options, args) = parser.parse_args()
-
        if len(args) != 0:
             parser.print_help()
             sys.exit(1)
 
-       # Create an instance of a hierarchical block
-       top_block = sounder_rx(options.rx_subdev_spec, options.freq, 
options.cal,
-                              options.verbose, options.max_delay, 
options.chip_rate,
-                              options.gain)
-                             
-       # Create an instance of a runtime, passing it the top block
-       # to process
-       runtime = gr.runtime(top_block)
+        self._options = options
+        self._frame = frame
+        self._panel = panel
+        
+        self._setup_usrp()
+        self._setup_receiver()
+        self._setup_display()
+        self._setup_topology()
+        self._print_verbiage()
+        
+    def _setup_usrp(self):
+        self._u = usrp_source_c(0,
+                                self._options.rx_subdev_spec,
+                                self._options.gain,
+                                self._options.chip_rate,
+                                self._options.freq,
+                                self._options.cal,
+                                self._options.verbose)
+        self._options.chip_rate = self._u._if_rate
+        
+    def _setup_receiver(self):
+        self._receiver = sounder_rx(self._options.chip_rate,
+                                    self._options.max_delay,
+                                    self._options.tc,
+                                    self._options.update_rate,
+                                    self._options.verbose)
 
-       try:    
-            # Run forever
-            runtime.run()
-       except KeyboardInterrupt:
-            # Ctrl-C exits
-            pass
+    def _setup_topology(self):
+        self.define_component("usrp", self._u)
+       self.define_component("rx",   self._receiver)
+        self.define_component("waterfall", self._waterfall)
+       self.connect("usrp", 0, "rx", 0)
+        self.connect("usrp", 0, "waterfall", 0)
+        
+    def _setup_display(self):
+        self._waterfall = waterfallsink2.waterfall_sink_c(self._panel,
+                                                          
fft_size=self._receiver._length,
+                                                          
sample_rate=self._options.chip_rate)
 
+    def _print_verbiage(self):
+       if self._options.verbose:
+            print "Chip rate is", n2s(self._options.chip_rate), "chips/sec"
+            print "Resolution is", n2s(1.0/self._options.chip_rate), "sec"
+            print "Using specified maximum delay spread of", 
self._options.max_delay, "sec"
+
+def main():
+        app = stdgui2.stdapp(usrp_sounder_rx, "USRP Channel Sounder", 
nstatus=1)
+        app.MainLoop()
+
 if __name__ == '__main__':
     main ()

Modified: 
gnuradio/branches/developers/jcorgan/channel/gnuradio-examples/python/hier/sounder/usrp_sounder_tx.py
===================================================================
--- 
gnuradio/branches/developers/jcorgan/channel/gnuradio-examples/python/hier/sounder/usrp_sounder_tx.py
       2007-03-17 21:45:40 UTC (rev 4767)
+++ 
gnuradio/branches/developers/jcorgan/channel/gnuradio-examples/python/hier/sounder/usrp_sounder_tx.py
       2007-03-17 21:49:59 UTC (rev 4768)
@@ -23,8 +23,44 @@
 from gnuradio import gr, eng_notation
 from gnuradio.eng_option import eng_option
 from optparse import OptionParser
+from usrp_sink import usrp_sink_c
 from sounder_tx import sounder_tx
 
+n2s = eng_notation.num_to_str
+
+class usrp_sounder_tx(gr.hier_block2):
+    def __init__(self, subdev_spec, freq, cal, verbose, max_delay, chip_rate, 
amplitude):
+
+        # Call hierarchical block constructor
+        # Top-level blocks have no inputs or outputs
+        gr.hier_block2.__init__(self,
+                                "usrp_sounder_tx",      # Block typename
+                                gr.io_signature(0,0,0), # Input signature
+                                gr.io_signature(0,0,0)) # Output signature
+
+        self._freq = freq
+        self._cal = cal
+        self._verbose = verbose
+        self._max_delay = max_delay
+       self._amplitude = amplitude
+       
+        self._u = usrp_sink_c(0, subdev_spec, chip_rate, self._freq, 
self._cal, self._verbose)
+       self.define_component("usrp", self._u)
+        self._chip_rate = self._u._if_rate
+       self.define_component("pn", sounder_tx(self._max_delay, 
self._chip_rate, self._verbose))
+       self.define_component("mapper", gr.chunks_to_symbols_bc((-amplitude+0j, 
amplitude+0j), 1))
+
+        if self._verbose:
+            print "Chip rate is", n2s(self._chip_rate), "chips/sec"
+            print "Resolution is", n2s(1.0/self._chip_rate), "sec"
+            print "Using specified maximum delay spread of", self._max_delay, 
"sec"
+            print "Output amplitude is", amplitude
+
+       # Ultimately this will be
+       # self.connect("pn mapper usrp")
+       self.connect("pn", 0, "mapper", 0)
+       self.connect("mapper", 0, "usrp", 0)
+
 def main():
        parser = OptionParser(option_class=eng_option)
 
@@ -41,7 +77,7 @@
                          help="set maximum delay spread (default=%default)")
        parser.add_option("-r", "--chip-rate", type="eng_float", default=8e6,
                          help="set sounder chip rate (default=%default)")
-       parser.add_option("-g", "--amplitude", type="eng_float", 
default=32000.0,
+       parser.add_option("-g", "--amplitude", type="eng_float", default=8000.0,
                          help="set output amplitude (default=%default)")
         (options, args) = parser.parse_args()
 
@@ -50,9 +86,9 @@
             sys.exit(1)
 
        # Create an instance of a hierarchical block
-       top_block = sounder_tx(options.tx_subdev_spec, options.freq, 
options.cal,
-                              options.verbose, options.max_delay, 
options.chip_rate,
-                              options.amplitude)
+       top_block = usrp_sounder_tx(options.tx_subdev_spec, options.freq, 
options.cal,
+                                   options.verbose, options.max_delay, 
options.chip_rate,
+                                   options.amplitude)
                              
        # Create an instance of a runtime, passing it the top block
        # to process

Modified: 
gnuradio/branches/developers/jcorgan/channel/gnuradio-examples/python/hier/sounder/usrp_source.py
===================================================================
--- 
gnuradio/branches/developers/jcorgan/channel/gnuradio-examples/python/hier/sounder/usrp_source.py
   2007-03-17 21:45:40 UTC (rev 4767)
+++ 
gnuradio/branches/developers/jcorgan/channel/gnuradio-examples/python/hier/sounder/usrp_source.py
   2007-03-17 21:49:59 UTC (rev 4768)
@@ -93,7 +93,9 @@
            gain = (g[0]+g[1])/2.0
         self._gain = gain
         self._subdev.set_gain(self._gain)
-
+        if self._verbose:
+            print "USRP gain set to", self._gain
+            
     def set_calibration(self, calibration):
         self._cal = calibration
         if self._verbose:





reply via email to

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