commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r11083 - gnuradio/branches/developers/eb/vrt/gr-utils/


From: matt
Subject: [Commit-gnuradio] r11083 - gnuradio/branches/developers/eb/vrt/gr-utils/src/python
Date: Thu, 21 May 2009 18:02:11 -0600 (MDT)

Author: matt
Date: 2009-05-21 18:02:10 -0600 (Thu, 21 May 2009)
New Revision: 11083

Modified:
   gnuradio/branches/developers/eb/vrt/gr-utils/src/python/qr_fft.py
Log:
controls for the attenuators and switches


Modified: gnuradio/branches/developers/eb/vrt/gr-utils/src/python/qr_fft.py
===================================================================
--- gnuradio/branches/developers/eb/vrt/gr-utils/src/python/qr_fft.py   
2009-05-21 16:21:10 UTC (rev 11082)
+++ gnuradio/branches/developers/eb/vrt/gr-utils/src/python/qr_fft.py   
2009-05-22 00:02:10 UTC (rev 11083)
@@ -20,20 +20,22 @@
 # Boston, MA 02110-1301, USA.
 # 
 
+from grc_gnuradio.wxgui import forms
 from gnuradio import gr, gru
 from gnuradio import vrt
 from gnuradio import eng_notation
 from gnuradio.eng_option import eng_option
 from gnuradio.wxgui import stdgui2, fftsink2, waterfallsink2, scopesink2, 
form, slider
+from gnuradio.gr import pubsub
 from optparse import OptionParser
 import wx
 import sys
 import numpy
 
-class app_top_block(stdgui2.std_top_block):
+class app_top_block(stdgui2.std_top_block, pubsub.pubsub):
     def __init__(self, frame, panel, vbox, argv):
         stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv)
-
+        pubsub.pubsub.__init__(self)
         self.frame = frame
         self.panel = panel
         
@@ -71,7 +73,7 @@
         #self.u.set_decim(options.decim)
         
         #input_rate = self.u.adc_rate() / self.u.decim()
-        input_rate = int(25e6)
+        input_rate = int(120e6/8)
         
         if options.waterfall:
             self.scope = \
@@ -197,8 +199,90 @@
 
         hbox.Add((5,0), 0)
         vbox.Add(hbox, 0, wx.EXPAND)
+        ##### db control stuff #####
+        self['db_ctrl_atten'] = 0
+        self['db_ctrl_10db'] = False
+        self['db_ctrl_bandsel'] = 3
+        self['db_ctrl_type'] = 0
+        for key in ('db_ctrl_atten', 'db_ctrl_10db', 'db_ctrl_bandsel', 
'db_ctrl_type'):
+            self.subscribe(key, self.update_db_ctrl)
+        self.update_db_ctrl() #init
+        hbox = wx.BoxSizer(wx.HORIZONTAL)
+        hbox.AddSpacer(10)
+        #create slider for atten
+        forms.static_text(
+            label='Attenuation',
+            ps=self,
+            key='db_ctrl_atten',
+            sizer=hbox,
+            parent=panel,
+            proportion=0,
+            converter=forms.int_converter()
+        )
+        hbox.AddSpacer(20)
+        forms.slider(
+            ps=self,
+            key='db_ctrl_atten',
+            minimum=0,
+            maximum=(2**5)-1,
+            step_size=1,
+            cast=int,
+            sizer=hbox,
+            parent=panel,
+            proportion=2,
+        )
+        hbox.AddSpacer(10)
+        #create checkbox for 10dB att
+        forms.check_box(
+            label='10dB Attenuation',
+            ps=self,
+            key='db_ctrl_10db',
+            sizer=hbox,
+            parent=panel,
+            proportion=1,
+        )
+        hbox.AddSpacer(10)
+        vbox.Add(hbox, 0, wx.EXPAND)
+        hbox = wx.BoxSizer(wx.HORIZONTAL)
+        hbox.AddSpacer(10)
+        #create radio buttons for band sel
+        forms.radio_buttons(
+            label='Band Select',
+            ps=self,
+            key='db_ctrl_bandsel',
+            choices=[3, 1, 2, 0],
+            labels=['A', 'B', 'C', 'D'],
+            sizer=hbox,
+            parent=panel,
+            proportion=2,
+        )
+        hbox.AddSpacer(10)
+        #create radio buttons for type
+        forms.radio_buttons(
+            label='RF Input',
+            ps=self,
+            key='db_ctrl_type',
+            choices=[0, 1],
+            labels=['Main RF', 'Calibrator'],
+            sizer=hbox,
+            parent=panel,
+            proportion=1,
+        )
+        hbox.AddSpacer(10)
+        vbox.Add(hbox, 0, wx.EXPAND)
 
-        
+    def update_db_ctrl(self, *args):
+        db_ctrl = \
+            ((0x1f ^ (self['db_ctrl_atten'] & 0x1f)) << 2) | \
+            ((self['db_ctrl_bandsel'] & 0x3) << 7) | \
+            ((self['db_ctrl_type'] & 0x1) << 9)
+        if self['db_ctrl_10db']: #take band sel + 1 for alternative
+            db_ctrl |= (self['db_ctrl_bandsel']+1) & 0x3
+        else: #take current band sel
+            db_ctrl |= (self['db_ctrl_bandsel']) & 0x3
+        #print 'Setting db ctrl %.3x'%db_ctrl
+        self.u.write_dboard_pins(db_ctrl)
+
     def set_freq(self, target_freq):
         """
         Set the center frequency we're interested in.
@@ -239,7 +323,8 @@
         ok = self.u.set_decim(decim)
         if not ok:
             print "set_decim failed"
-        input_rate = self.u.adc_rate() / self.u.decim()
+        #input_rate = self.u.adc_rate() / self.u.decim()
+        input_rate = 120e6/8
         self.scope.set_sample_rate(input_rate)
         if self.show_debug_info:  # update displayed values
             self.myform['decim'].set_value(self.u.decim())





reply via email to

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