Changeset 8962

Show
Ignore:
Timestamp:
07/21/08 14:23:01
Author:
jblum
Message:

constellation usrp gui shows

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gnuradio/branches/features/experimental-gui/const_controller.py

    r8932 r8962  
    8383        # caller, result in the correct top block methods being invoked. 
    8484        self.add_listener('decim',        self.set_decim) 
    85         self.add_listener('gain',         lambda x: self._tb.set_gain(x)
    86         self.add_listener('freq',         lambda x: self._tb.set_freq(x)
    87         self.add_listener('costas_alpha', lambda x: self._tb.set_costas_alpha(x)
    88         self.add_listener('costas_max',   lambda x: self._tb.set_costas_max(x)
     85        self.add_listener('gain',         self._tb.set_gain
     86        self.add_listener('freq',         self._tb.set_freq
     87        #self.add_listener('costas_alpha', self._tb.set_costas_alpha
     88        #self.add_listener('costas_max',   self._tb.set_costas_max
    8989         
    9090        # Set providers for application properties 
    91         self.set_provider('sample_rate', lambda: self._tb.sample_rate()) 
     91        self.set_provider('sample_rate', self._tb.sample_rate) 
     92         
     93        #temp!!! 
     94        self['costas_alpha'] = .5 
     95        self['costas_beta'] = .5 
    9296         
    9397        # The controller is a thread.  This is not required but convenient here. 
  • gnuradio/branches/features/experimental-gui/const_gui.py

    r8932 r8962  
    2020# 
    2121 
    22 # This requires GRC installed (temporary for demo purposes) 
    2322from wxgui_app import wxgui_app 
    2423from const_window import const_window 
     
    3534 
    3635        self._win = const_window(parent=self.GetWin(), 
    37                                  controller=controller, 
    38                                  size=(600, 300), 
    39                                  title=title) 
    40          
     36                                controller=controller, 
     37                                size=(600, 300), 
     38                                title=title, 
     39                                msg_key='const', 
     40                                alpha_key='costas_alpha', 
     41                                beta_key='costas_beta', 
     42                                gain_mu_key='costas_alpha', 
     43                                gain_omega_key='costas_beta', 
     44                            ) 
     45     
    4146        self.Add(self._win) 
    4247 
  • gnuradio/branches/features/experimental-gui/const_streamer.py

    r8932 r8962  
    3030    """ 
    3131    def __init__(self,  
    32                 sample_rate, 
     32                sample_rate, 
    3333                 bit_rate, 
    34                 order=2, 
     34                order=2, 
    3535                 frame_size=1024, 
    36                 frame_rate=30, 
    37                 costas_alpha=0.1, 
     36                frame_rate=30, 
     37                costas_alpha=0.1, 
    3838                 costas_max=0.05, 
    3939                 mm_alpha=0.005, 
    4040                 mm_max=0.05): 
    41        """! 
     41        """! 
    4242        Create a const_streamer. 
    43        @param sample_rate          Incoming sample rate 
     43        @param sample_rate          Incoming sample rate 
    4444        @param bit_rate             Modulated bit rate/sec 
    45        @param order                Constellation order (BPSK=2, QPSK=4, default is 2) 
     45        @param order                    Constellation order (BPSK=2, QPSK=4, default is 2) 
    4646        @param frame_size           Number of constellation points to plot at a time 
    4747        @param frame_rate           Number of frames/sec to create (default is 30) 
     
    5252        """ 
    5353         
    54        gr.hier_block2.__init__(self, "const_streamer", 
    55                                gr.io_signature(1, 1, gr.sizeof_gr_complex),            # Input signature 
    56                                gr.io_signature(1, 1, gr.sizeof_gr_complex*frame_size)) # Output signature 
     54        gr.hier_block2.__init__(self, "const_streamer", 
     55                                gr.io_signature(1, 1, gr.sizeof_gr_complex),            # Input signature 
     56                                gr.io_signature(1, 1, gr.sizeof_gr_complex*frame_size)) # Output signature 
    5757 
    58        # Costas frequency/phase recovery loop 
     58        # Costas frequency/phase recovery loop 
    5959        # Critically damped 2nd order PLL 
    6060        costas_beta = 0.25*costas_alpha*costas_alpha 
    6161        costas_min = -costas_max 
    62        self._costas = gr.costas_loop_cc(costas_alpha, 
     62        self._costas = gr.costas_loop_cc(costas_alpha, 
    6363                                         costas_beta, 
    6464                                         costas_max, 
     
    6969        # Critically damped 2nd order DLL 
    7070        mm_freq = float(sample_rate)/bit_rate 
    71        mm_beta = 0.25*mm_alpha*mm_alpha 
     71        mm_beta = 0.25*mm_alpha*mm_alpha 
    7272        mu=0.5 # Center of bit 
    73        self._retime = gr.clock_recovery_mm_cc(mm_freq,   # omega, 
     73        self._retime = gr.clock_recovery_mm_cc(mm_freq,   # omega, 
    7474                                               mm_beta,   # gain_omega 
    7575                                               mu, 
     
    7777                                               mm_max)    # omega_limit 
    7878 
    79        # Scale to unity power 
    80        self._agc = gr.agc_cc(1e-6); 
     79        # Scale to unity power 
     80        self._agc = gr.agc_cc(1e-6); 
    8181 
    82        self._decim = blks2.stream_to_vector_decimator(item_size=gr.sizeof_gr_complex, 
    83                                                       sample_rate=bit_rate, 
    84                                                       vec_rate=frame_rate, 
    85                                                       vec_len=frame_size) 
    86             
    87        self.connect(self, self._costas, self._retime, self._agc, self._decim, self) 
     82        self._decim = blks2.stream_to_vector_decimator(item_size=gr.sizeof_gr_complex, 
     83                                                       sample_rate=bit_rate, 
     84                                                       vec_rate=frame_rate, 
     85                                                       vec_len=frame_size) 
     86             
     87        self.connect(self, self._costas, self._retime, self._agc, self._decim, self) 
  • gnuradio/branches/features/experimental-gui/const_top_block.py

    r8933 r8962  
    3232    """ 
    3333    def __init__(self,  
    34                 order=2, 
     34                order=2, 
    3535                 frame_size=1024, 
    36                 frame_rate=30, 
    37                 which=0, 
    38                 decim=16, 
    39                 width_8=False, 
    40                 no_hb=False, 
    41                 subdev_spec=None, 
    42                 gain=None, 
    43                 freq=None, 
    44                 antenna=None, 
     36                frame_rate=30, 
     37                which=0, 
     38                decim=16, 
     39                width_8=False, 
     40                no_hb=False, 
     41                subdev_spec=None, 
     42                gain=None, 
     43                freq=None, 
     44                antenna=None, 
    4545                 bit_rate=None, 
    46                 costas_alpha=0.1, 
     46                costas_alpha=0.1, 
    4747                 costas_max=0.05, 
    4848                 mm_alpha=0.005, 
    4949                 mm_max=0.05 
    5050                 ): 
    51        """! 
     51        """! 
    5252        Create a const_top_block. 
    5353 
    54        @param order                Constellation order (BPSK=2, QPSK=4, default is 2) 
     54        @param order                    Constellation order (BPSK=2, QPSK=4, default is 2) 
    5555        @param frame_size           Number of constellation points to plot at a time 
    5656        @param frame_rate           Number of frames/sec to create (default is 30) 
    57         @param which               USRP # on USB bus (default is 0) 
    58         @param decim               Receive sample rate decimation (default is 16) 
    59         @param width_8             Use 8-bit instead of 16-bit samples (default is False) 
    60         @param no_hb               Don't use half-band filter (default is False) 
     57        @param which                    USRP # on USB bus (default is 0) 
     58        @param decim                    Receive sample rate decimation (default is 16) 
     59        @param width_8                    Use 8-bit instead of 16-bit samples (default is False) 
     60        @param no_hb                    Don't use half-band filter (default is False) 
    6161        @param subdev_spec          Daughterboard selection (default is first found) 
    62         @param gain                Daughterboard RX gain (default is mid-range) 
    63         @param freq                Daughterboard RX frequency (default is mid-range) 
    64         @param antenna             Daughterboard RX antenna (default is board-default) 
     62        @param gain                    Daughterboard RX gain (default is mid-range) 
     63        @param freq                    Daughterboard RX frequency (default is mid-range) 
     64        @param antenna                    Daughterboard RX antenna (default is board-default) 
    6565        @param bit_rate             Modulated bit rate/sec (default equivalent to 2 samples/bit) 
    6666        @param costas_alpha         Costas loop 1st order gain constant (default is 0.1) 
     
    7070        """ 
    7171         
    72        gr.top_block.__init__(self, "const_top_block") 
     72        gr.top_block.__init__(self, "const_top_block") 
    7373 
    74        # Source of samples 
    75        self._u = simple_usrp.source_c(which=which, 
    76                                       decim=decim, 
    77                                       width_8=width_8, 
    78                                       no_hb=no_hb, 
    79                                       subdev_spec=subdev_spec, 
    80                                       gain=gain, 
    81                                       freq=freq, 
    82                                       antenna=antenna) 
     74        # Source of samples 
     75        self._u = simple_usrp.source_c(which=which, 
     76                                       decim=decim, 
     77                                       width_8=width_8, 
     78                                       no_hb=no_hb, 
     79                                       subdev_spec=subdev_spec, 
     80                                       gain=gain, 
     81                                       freq=freq, 
     82                                       antenna=antenna) 
    8383 
    84        # TODO: make this a configuration matched filter 
    85        # for now assume square pulses 
    86        self._filt = gr.fir_filter_ccf(1, [1.0,]*int(self._u.sample_rate()/bit_rate)) 
     84        # TODO: make this a configuration matched filter 
     85        # for now assume square pulses 
     86        self._filt = gr.fir_filter_ccf(1, [1.0,]*int(self._u.sample_rate()/bit_rate)) 
    8787 
    88        self._const = const_streamer.const_streamer(sample_rate=self._u.sample_rate(), 
    89                                                    bit_rate=bit_rate, 
    90                                                    order=order, 
    91                                                    frame_size=frame_size, 
    92                                                    frame_rate=frame_rate, 
    93                                                    costas_alpha=costas_alpha, 
    94                                                    costas_max=costas_max, 
    95                                                    mm_alpha=mm_alpha, 
    96                                                    mm_max=mm_max) 
     88        self._const = const_streamer.const_streamer(sample_rate=self._u.sample_rate(), 
     89                                                    bit_rate=bit_rate, 
     90                                                    order=order, 
     91                                                    frame_size=frame_size, 
     92                                                    frame_rate=frame_rate, 
     93                                                    costas_alpha=costas_alpha, 
     94                                                    costas_max=costas_max, 
     95                                                    mm_alpha=mm_alpha, 
     96                                                    mm_max=mm_max) 
    9797 
    98        self._msgq = gr.msg_queue(2) 
    99        self._sink = gr.message_sink(gr.sizeof_gr_complex*frame_size, self._msgq, True) 
    100                     
    101        self.connect(self._u, self._filt, self._const, self._sink) 
     98        self._msgq = gr.msg_queue(2) 
     99        self._sink = gr.message_sink(gr.sizeof_gr_complex*frame_size, self._msgq, True) 
     100                     
     101        self.connect(self._u, self._filt, self._const, self._sink) 
    102102 
    103103    # "Setters", which are called externally to affect flowgraph operation 
    104104    def set_gain(self, gain): 
    105        return self._u.set_gain(gain) 
    106          
     105        return self._u.set_gain(gain) 
     106         
    107107    def set_freq(self, freq): 
    108        return self._u.set_freq(freq) 
    109          
     108        return self._u.set_freq(freq) 
     109         
    110110    def set_decim(self, decim): 
    111        self._u.set_decim(decim) 
    112        self._const.set_sample_rate(self._u.sample_rate()) 
     111        self._u.set_decim(decim) 
     112        self._const.set_sample_rate(self._u.sample_rate()) 
    113113 
    114114    # Getters, which are called externally to get information about the flowgraph 
    115115    def queue(self): 
    116        return self._msgq 
     116            return self._msgq 
    117117 
    118118    def sample_rate(self): 
  • gnuradio/branches/features/experimental-gui/fft_controller.py

    r8893 r8962  
    7777        # caller, result in the correct top block methods being invoked. 
    7878        self.add_listener('decim',     self.set_decim) 
    79         self.add_listener('gain',      lambda x: self._tb.set_gain(x)
    80         self.add_listener('freq',      lambda x: self._tb.set_freq(x)
    81         self.add_listener('avg_alpha', lambda x: self._tb.set_avg_alpha(x)
    82         self.add_listener('average',   lambda x: self._tb.set_average(x)
     79        self.add_listener('gain',      self._tb.set_gain
     80        self.add_listener('freq',      self._tb.set_freq
     81        self.add_listener('avg_alpha', self._tb.set_avg_alpha
     82        self.add_listener('average',   self._tb.set_average
    8383 
    8484        # Set providers for application properties 
    85         self.set_provider('sample_rate', lambda: self._tb.sample_rate()
    86         self.set_provider('average', lambda: self._tb.average()
    87         self.set_provider('avg_alpha', lambda: self._tb.avg_alpha()
     85        self.set_provider('sample_rate', self._tb.sample_rate
     86        self.set_provider('average', self._tb.average
     87        self.set_provider('avg_alpha', self._tb.avg_alpha
    8888         
    8989        # The controller is a thread.  This is not required but convenient here. 
  • gnuradio/branches/features/experimental-gui/grc_constsink_test.py

    r8906 r8962  
    7070                ) 
    7171                self.gr_chunks_to_symbols_xx = gr.chunks_to_symbols_bc(const, 1) 
    72                 self.gr_interp_fir_filter_xxx = gr.interp_fir_filter_ccc(samples_per_symbol, ([1]*samples_per_symbol)) 
     72                self.gr_fir_filter_xxx = gr.fir_filter_ccc(1, ([1]*samples_per_symbol)) 
     73                self.gr_repeat = gr.repeat(gr.sizeof_gr_complex*1, samples_per_symbol) 
    7374                self.gr_throttle = gr.throttle(gr.sizeof_gr_complex*1, samp_rate) 
    7475                self.random_source_x = gr.vector_source_b(numpy.random.randint(0, 4, 1000), True) 
     
    9596                self.connect((self.random_source_x, 0), (self.gr_chunks_to_symbols_xx, 0)) 
    9697                self.connect((self.gr_chunks_to_symbols_xx, 0), (self.gr_throttle, 0)) 
    97                 self.connect((self.gr_interp_fir_filter_xxx, 0), (self.blks2_channel_model, 0)) 
    9898                self.connect((self.blks2_channel_model, 0), (self.wxgui_constellationsink2, 0)) 
    99                 self.connect((self.gr_throttle, 0), (self.gr_interp_fir_filter_xxx, 0)) 
     99                self.connect((self.gr_throttle, 0), (self.gr_repeat, 0)) 
     100                self.connect((self.gr_repeat, 0), (self.gr_fir_filter_xxx, 0)) 
     101                self.connect((self.gr_fir_filter_xxx, 0), (self.blks2_channel_model, 0)) 
     102 
     103        def set_const(self, const): 
     104                self.const = const 
    100105 
    101106        def set_freq_off(self, freq_off): 
     
    114119        def set_samples_per_symbol(self, samples_per_symbol): 
    115120                self.samples_per_symbol = samples_per_symbol 
    116                 self.gr_interp_fir_filter_xxx.set_taps(([1]*self.samples_per_symbol)) 
     121                self.gr_fir_filter_xxx.set_taps(([1]*self.samples_per_symbol)) 
    117122 
    118123if __name__ == '__main__': 
  • gnuradio/branches/features/experimental-gui/plotter.py

    r8814 r8962  
    7373                if not self._gl_init_flag: 
    7474                        glClearColor(*BACKGROUND_COLOR_SPEC) 
    75                         glEnableClientState(GL_VERTEX_ARRAY
     75                        self._gl_init(
    7676                        self._gl_init_flag = True 
    7777                #check for a change in window size 
     
    9797                """ 
    9898                self.semaphore = threading.Semaphore(1) 
    99                 self.grid_compiled_list_id = wx.NewId() 
    10099                self.channels = dict() 
    101100                #store title and unit strings 
     
    110109                self.set_y_grid(-1, 1, 1) 
    111110                _plotter_base.__init__(self, parent) 
     111                 
     112        def _gl_init(self): 
     113                """! 
     114                Run gl initialization tasks. 
     115                """ 
     116                glEnableClientState(GL_VERTEX_ARRAY) 
     117                self.grid_compiled_list_id = glGenLists(1) 
    112118 
    113119        def set_legend(self, legend): 
     
    241247                                points_4 = numpy.array(zip(points, points, points, points)) 
    242248                                points_4 = points_4 + .01*numpy.array([ 
    243                                                 ((self.x_max-self.x_min), 0),  
    244                                                 (-(self.x_max-self.x_min), 0),  
    245                                                 (0, (self.y_max-self.y_min)),  
    246                                                 (0, -(self.y_max-self.y_min)), 
     249                                                (self.x_max-self.x_min, 0),  
     250                                                (self.x_min-self.x_max, 0),  
     251                                                (0, self.y_max-self.y_min),  
     252                                                (0, self.y_min-self.y_max), 
    247253                                        ] 
    248254                                ) 
  • gnuradio/branches/features/experimental-gui/usrp_const.py

    r8932 r8962  
    110110    # do with the controller properties. 
    111111    # 
    112     #gui = const_gui(controller) 
    113     #gui.run() 
     112    gui = const_gui(controller) 
     113    gui.run() 
    114114 
    115115    # TEMPORARY 
    116     f = open('const.dat', 'wb') 
    117     def writer(frame): 
    118        f.write(frame) 
    119     controller.add_listener('const', writer) 
     116    #f = open('const.dat', 'wb') 
     117    #def writer(frame): 
     118    #   f.write(frame) 
     119    #controller.add_listener('const', writer) 
    120120 
    121     controller.on_init() 
    122     try: 
    123         raw_input("Press return to stop.") 
    124     except KeyboardInterrupt: 
    125         pass 
     121    #controller.on_init() 
     122    #try: 
     123        #raw_input("Press return to stop.") 
     124    #except KeyboardInterrupt: 
     125        #pass 
    126126         
    127     controller.on_exit() 
     127    #controller.on_exit()