commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r8929 - gnuradio/branches/features/experimental-gui


From: jcorgan
Subject: [Commit-gnuradio] r8929 - gnuradio/branches/features/experimental-gui
Date: Thu, 17 Jul 2008 16:55:36 -0600 (MDT)

Author: jcorgan
Date: 2008-07-17 16:55:32 -0600 (Thu, 17 Jul 2008)
New Revision: 8929

Added:
   gnuradio/branches/features/experimental-gui/const_streamer.py
   gnuradio/branches/features/experimental-gui/const_top_block.py
Log:
Added constellation top block.

Added: gnuradio/branches/features/experimental-gui/const_streamer.py
===================================================================
--- gnuradio/branches/features/experimental-gui/const_streamer.py               
                (rev 0)
+++ gnuradio/branches/features/experimental-gui/const_streamer.py       
2008-07-17 22:55:32 UTC (rev 8929)
@@ -0,0 +1,87 @@
+#!/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, blks2
+import simple_usrp
+
+class const_streamer(gr.hier_block2):
+    """!
+    GNU Radio hierarchical block to create a stream of constellation points at 
a 
+    particular frame size and rate.
+    """
+    def __init__(self, 
+                sample_rate,
+                 bit_rate,
+                order=2,
+                 frame_size=1024,
+                frame_rate=30,
+                costas_alpha=0.1,
+                 costas_max_freq=0.05,
+                 mm_alpha=0.005,
+                 mm_max_freq=0.05):
+       """!
+        Create a const_streamer.
+       @param sample_rate          Incoming sample rate
+        @param bit_rate             Modulated bit rate/sec
+       @param order                Constellation order (BPSK=2, QPSK=4, 
default is 2)
+        @param frame_size           Number of constellation points to plot at 
a time
+        @param frame_rate           Number of frames/sec to create (default is 
30)
+        @param costas_alpha         Costas loop 1st order gain constant 
(default is 0.1)
+        @param costas_max_freq      Costas loop maximum offset, rad/sample 
(default is 0.05)
+        @param mm_alpha             Timing loop 1st order gain constant 
(default is 0.005)
+        @param mm_max_freq          Maximum timing offset in bits/sample 
(default is 0.05)
+        """
+        
+       gr.hier_block2.__init__(self, "const_streamer",
+                               gr.io_signature(1, 1, gr.sizeof_gr_complex),    
        # Input signature
+                               gr.io_signature(1, 1, 
gr.sizeof_gr_complex*frame_size)) # Output signature
+
+       # Costas frequency/phase recovery loop
+        # Critically damped 2nd order PLL
+        costas_beta = 0.25*costas_alpha*costas_alpha
+        costas_min_freq = -costas_max_freq
+       self._costas = gr.costas_loop_cc(costas_alpha,
+                                         costas_beta,
+                                         costas_max_freq,
+                                         costas_min_freq,
+                                         order)
+        
+        # Timing recovery loop
+        # Critically damped 2nd order DLL
+        mm_freq = float(sample_rate)/bit_rate
+       mm_beta = 0.25*mm_alpha*mm_alpha
+        mu=0.5 # Center of bit
+       self._retime = gr.clock_recovery_mm_cc(mm_freq,        # omega,
+                                               mm_beta,        # gain_omega
+                                               mu,
+                                               mm_alpha,       # gain_mu,
+                                               mm_max_freq)    # omega_limit
+
+       # Scale to unity power
+       self._agc = gr.agc_cc(1e-6);
+
+       self._decim = 
blks2.stream_to_vector_decimator(item_size=gr.sizeof_gr_complex,
+                                                      sample_rate=bit_rate,
+                                                      vec_rate=frame_rate,
+                                                      vec_len=frame_size)
+           
+       self.connect(self, self._costas, self._retime, self._agc, self._decim, 
self)

Added: gnuradio/branches/features/experimental-gui/const_top_block.py
===================================================================
--- gnuradio/branches/features/experimental-gui/const_top_block.py              
                (rev 0)
+++ gnuradio/branches/features/experimental-gui/const_top_block.py      
2008-07-17 22:55:32 UTC (rev 8929)
@@ -0,0 +1,133 @@
+#!/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, blks2
+import const_streamer
+import simple_usrp
+
+class const_top_block(gr.top_block):
+    """!
+    GNU Radio top block to create a stream of constellation points at a 
+    particular frame rate from a USRP. The frames are enqueued in a 
gr.msg_queue
+    for external retrieval.
+    """
+    def __init__(self, 
+                order=2,
+                 frame_size=1024,
+                frame_rate=30,
+                which=0,
+                decim=16,
+                width_8=False,
+                no_hb=False,
+                subdev_spec=None,
+                gain=None,
+                freq=None,
+                antenna=None,
+                 bit_rate=None,
+                costas_alpha=0.1,
+                 costas_max_freq=0.05,
+                 mm_alpha=0.005,
+                 mm_max_freq=0.05
+                 ):
+       """!
+        Create a const_top_block.
+
+       @param order                Constellation order (BPSK=2, QPSK=4, 
default is 2)
+        @param frame_size           Number of constellation points to plot at 
a time
+        @param frame_rate           Number of frames/sec to create (default is 
30)
+        @param which               USRP # on USB bus (default is 0)
+        @param decim               Receive sample rate decimation (default is 
16)
+        @param width_8             Use 8-bit instead of 16-bit samples 
(default is False)
+        @param no_hb               Don't use half-band filter (default is 
False)
+        @param subdev_spec          Daughterboard selection (default is first 
found)
+        @param gain                Daughterboard RX gain (default is mid-range)
+        @param freq                Daughterboard RX frequency (default is 
mid-range)
+        @param antenna             Daughterboard RX antenna (default is 
board-default)
+        @param bit_rate             Modulated bit rate/sec (default equivalent 
to 2 samples/bit)
+        @param costas_alpha         Costas loop 1st order gain constant 
(default is 0.1)
+        @param costas_max_freq      Costas loop maximum offset, rad/sample 
(default is 0.05)
+        @param mm_alpha             Timing loop 1st order gain constant 
(default is 0.005)
+        @param mm_max_freq          Maximum timing offset in bits/sample 
(default is 0.05)
+        """
+        
+       gr.top_block.__init__(self, "const_top_block")
+
+       # Source of samples
+       self._u = simple_usrp.source_c(which=which,
+                                      decim=decim,
+                                      width_8=width_8,
+                                      no_hb=no_hb,
+                                      subdev_spec=subdev_spec,
+                                      gain=gain,
+                                      freq=freq,
+                                      antenna=antenna)
+
+       self._const = 
const_streamer.const_streamer(sample_rate=self._u.sample_rate(),
+                                                   bit_rate=bit_rate,
+                                                   order=order,
+                                                   frame_size=frame_size,
+                                                   frame_rate=frame_rate,
+                                                   costas_alpha=costas_alpha,
+                                                   
costas_max_freq=costas_max_freq,
+                                                   mm_alpha=mm_alpha,
+                                                   mm_max_freq=mm_max_freq)
+
+       if 0:
+           self._msgq = gr.msg_queue(2)
+           self._sink = gr.message_sink(gr.sizeof_gr_complex*frame_size, 
self._msgq, True)
+       else:
+           self._sink = gr.file_sink(gr.sizeof_gr_complex*frame_size, 
'const.dat')
+           
+       self.connect(self._u, self._const, self._sink)
+
+    # "Setters", which are called externally to affect flowgraph operation
+    def set_gain(self, gain):
+       return self._u.set_gain(gain)
+       
+    def set_freq(self, freq):
+       return self._u.set_freq(freq)
+       
+    def set_decim(self, decim):
+       self._u.set_decim(decim)
+       self._fft.set_sample_rate(self._u.sample_rate())
+
+    # Getters, which are called externally to get information about the 
flowgraph
+    def queue(self):
+       return self._msgq
+
+    def sample_rate(self):
+        return self._u.sample_rate()
+
+# test code
+if __name__ == "__main__":
+    tb = const_top_block(order=2,
+                         decim=64,
+                         subdev_spec=(0, 0),
+                         gain=60,
+                         freq=2.215e9,
+                         bit_rate=250e3,
+                         costas_alpha=0.2,
+                         costas_max_freq=0.06,
+                         mm_alpha=0.05,
+                         mm_max_freq=0.05);
+
+    tb.run()


Property changes on: 
gnuradio/branches/features/experimental-gui/const_top_block.py
___________________________________________________________________
Name: svn:executable
   + *





reply via email to

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