commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r11512 - in gnuradio/branches/developers/eb/vrt: gr-ut


From: jblum
Subject: [Commit-gnuradio] r11512 - in gnuradio/branches/developers/eb/vrt: gr-utils/src/python gr-vrt/src vrt/include/vrt vrt/lib
Date: Tue, 28 Jul 2009 17:01:05 -0600 (MDT)

Author: jblum
Date: 2009-07-28 17:01:05 -0600 (Tue, 28 Jul 2009)
New Revision: 11512

Modified:
   gnuradio/branches/developers/eb/vrt/gr-utils/src/python/qr_fft.py
   gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_quadradio_source_32fc.cc
   gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_quadradio_source_32fc.h
   gnuradio/branches/developers/eb/vrt/vrt/include/vrt/quadradio.h
   gnuradio/branches/developers/eb/vrt/vrt/lib/quadradio.cc
Log:
added control for 2 attenuators, commented out 10db control

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-07-28 03:55:41 UTC (rev 11511)
+++ gnuradio/branches/developers/eb/vrt/gr-utils/src/python/qr_fft.py   
2009-07-28 23:01:05 UTC (rev 11512)
@@ -203,16 +203,18 @@
         hbox.Add((5,0), 0)
         vbox.Add(hbox, 0, wx.EXPAND)
         ##### db control stuff #####
-        self.subscribe('db_ctrl_atten', self.u.set_attenuation)
-        self.subscribe('db_ctrl_10db', self.u.set_10dB_atten)
+        self.subscribe('db_ctrl_atten0', self.u.set_attenuation0)
+        self.subscribe('db_ctrl_atten1', self.u.set_attenuation1)
+        #self.subscribe('db_ctrl_10db', self.u.set_10dB_atten)
         self.subscribe('db_ctrl_adcgain', self.u.set_adc_gain)
         self.subscribe('db_ctrl_diggain', self.u.set_digital_gain)
         self.subscribe('db_ctrl_dcoffset', self.u.set_dc_offset_comp)
         self.subscribe('db_ctrl_bandsel', self.u.set_band_select)
         self.subscribe('db_ctrl_type', self.u.select_rx_antenna)
         self.subscribe('db_test_signal', self.u.set_test_signal)
-        self['db_ctrl_atten'] = 0
-        self['db_ctrl_10db'] = False
+        self['db_ctrl_atten0'] = 0
+        self['db_ctrl_atten1'] = 0
+        #self['db_ctrl_10db'] = False
         self['db_ctrl_adcgain'] = False
         self['db_ctrl_dcoffset'] = False
         self['db_ctrl_diggain'] = 0.0
@@ -223,9 +225,9 @@
         hbox.AddSpacer(10)
         #create slider for atten
         forms.static_text(
-            label='Attenuation',
+            label='Attenuation (0)',
             ps=self,
-            key='db_ctrl_atten',
+            key='db_ctrl_atten0',
             sizer=hbox,
             parent=panel,
             proportion=0,
@@ -234,7 +236,7 @@
         hbox.AddSpacer(20)
         forms.slider(
             ps=self,
-            key='db_ctrl_atten',
+            key='db_ctrl_atten0',
             minimum=0,
             maximum=31,
             step_size=1,
@@ -244,16 +246,39 @@
             proportion=2,
         )
         hbox.AddSpacer(10)
-        #create checkbox for 10dB att
-        forms.check_box(
-            label='10dB Attenuation',
+        #create slider for atten
+        forms.static_text(
+            label='Attenuation (1)',
             ps=self,
-            key='db_ctrl_10db',
+            key='db_ctrl_atten1',
             sizer=hbox,
             parent=panel,
-            proportion=1,
+            proportion=0,
+            converter=forms.int_converter()
         )
+        hbox.AddSpacer(20)
+        forms.slider(
+            ps=self,
+            key='db_ctrl_atten1',
+            minimum=0,
+            maximum=31,
+            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)
         hbox2 = wx.BoxSizer(wx.HORIZONTAL)
         hbox2.AddSpacer(10)

Modified: 
gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_quadradio_source_32fc.cc
===================================================================
--- gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_quadradio_source_32fc.cc 
2009-07-28 03:55:41 UTC (rev 11511)
+++ gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_quadradio_source_32fc.cc 
2009-07-28 23:01:05 UTC (rev 11512)
@@ -90,11 +90,11 @@
   return d_qr->set_band_select(band);
 }
 
-void 
-vrt_quadradio_source_32fc::set_10dB_atten(bool on)
-{
-  return d_qr->set_10dB_atten(on);
-}
+//void 
+//vrt_quadradio_source_32fc::set_10dB_atten(bool on)
+//{
+//  return d_qr->set_10dB_atten(on);
+//}
 
 bool 
 vrt_quadradio_source_32fc::select_rx_antenna(const std::string &ant)
@@ -103,11 +103,17 @@
 }
 
 bool 
-vrt_quadradio_source_32fc::set_attenuation(int attenuation)
+vrt_quadradio_source_32fc::set_attenuation0(int attenuation)
 {
-  return d_qr->set_attenuation(attenuation);
+  return d_qr->set_attenuation0(attenuation);
 }
 
+bool 
+vrt_quadradio_source_32fc::set_attenuation1(int attenuation)
+{
+  return d_qr->set_attenuation1(attenuation);
+}
+
 void
 vrt_quadradio_source_32fc::set_adc_gain(bool on){
   d_qr->set_adc_gain(on);
@@ -157,11 +163,12 @@
 #define IQ_IMBAL_REG_NO 162
 
 //helper function to set the iq imbalance register with a tap
-static int get_iq_imbal_reg(bool real, int index, float tap){
-  int val = static_cast<int>(round(tap));
-  val &= 0x1fff; //lower 25 bits for tap
+static int get_iq_imbal_reg(bool real, bool init, float tap){
+  int val = int(round(tap));
+  val &= 0x1ffffff; //lower 25 bits for tap
   val |= (real?0:1) << 30; //30th bit for filter type
-  val |= (index?0:1) << 31; //31st bit for initialization
+  val |= (init?1:0) << 31; //31st bit for initialization
+  printf("Reg %d Val %x\n", IQ_IMBAL_REG_NO, val);
   return val;
 }
 
@@ -169,11 +176,13 @@
 vrt_quadradio_source_32fc::set_iq_imbal_taps(const std::vector<gr_complex> 
taps){
   int i = 0;
   /* set the real part of the taps */
+  get_iq_imbal_reg(true, true, 0);
   for (i = 0; i < IQ_IMBAL_NUM_TAPS; i++){
-      set_setting_reg(IQ_IMBAL_REG_NO, get_iq_imbal_reg(true, i, 
taps[i].real()));
+      set_setting_reg(IQ_IMBAL_REG_NO, get_iq_imbal_reg(true, false, 
taps[IQ_IMBAL_NUM_TAPS-i-1].real()));
   }
+  get_iq_imbal_reg(false, true, 0);
   /* set the imaginary part of the taps */
   for (i = 0; i < IQ_IMBAL_NUM_TAPS; i++){
-      set_setting_reg(IQ_IMBAL_REG_NO, get_iq_imbal_reg(false, i, 
taps[i].imag()));
+      set_setting_reg(IQ_IMBAL_REG_NO, get_iq_imbal_reg(false, false, 
taps[IQ_IMBAL_NUM_TAPS-i-1].imag()));
   }
 }

Modified: 
gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_quadradio_source_32fc.h
===================================================================
--- gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_quadradio_source_32fc.h  
2009-07-28 03:55:41 UTC (rev 11511)
+++ gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_quadradio_source_32fc.h  
2009-07-28 23:01:05 UTC (rev 11512)
@@ -80,7 +80,7 @@
   /*!
    * \brief Turn the 10 dB attenuation on/off.
    */
-  void set_10dB_atten(bool on);
+  //void set_10dB_atten(bool on);
 
   /*!
    * \brief Set the antenna type to the main rf or calibrator.
@@ -92,7 +92,8 @@
    * \brief Set the attenuation.
    * \param attenuation 0 to 31 in dB
    */
-  bool set_attenuation(int attenuation);
+  bool set_attenuation0(int attenuation);
+  bool set_attenuation1(int attenuation);
 
   void set_iq_imbal_taps(const std::vector<gr_complex> taps);
 

Modified: gnuradio/branches/developers/eb/vrt/vrt/include/vrt/quadradio.h
===================================================================
--- gnuradio/branches/developers/eb/vrt/vrt/include/vrt/quadradio.h     
2009-07-28 03:55:41 UTC (rev 11511)
+++ gnuradio/branches/developers/eb/vrt/vrt/include/vrt/quadradio.h     
2009-07-28 23:01:05 UTC (rev 11512)
@@ -55,7 +55,8 @@
     
     int                   d_band_select;              // band select setting
     int                   d_rx_antenna;               // antenna type rf/cal
-    int                   d_attenuation;              // attenuation setting
+    int                   d_attenuation0;             // attenuation setting
+    int                   d_attenuation1;             // attenuation setting
     bool          d_10dB_atten;               // 10dB attenuation on/of
 
     static bool
@@ -93,9 +94,10 @@
     /* convenience methods that ultimately write the dboard pins */
     bool set_center_freq(double target_freq);
     bool set_band_select(const std::string &band);
-    void set_10dB_atten(bool on);
+    //void set_10dB_atten(bool on);
+    bool set_attenuation0(int attenuation);
     bool select_rx_antenna(const std::string &ant);
-    bool set_attenuation(int attenuation);
+    bool set_attenuation1(int attenuation);
     
     /* convenience methods that ultimately call set_hsadc_conf */
     void set_adc_gain(bool on);

Modified: gnuradio/branches/developers/eb/vrt/vrt/lib/quadradio.cc
===================================================================
--- gnuradio/branches/developers/eb/vrt/vrt/lib/quadradio.cc    2009-07-28 
03:55:41 UTC (rev 11511)
+++ gnuradio/branches/developers/eb/vrt/vrt/lib/quadradio.cc    2009-07-28 
23:01:05 UTC (rev 11512)
@@ -49,7 +49,7 @@
 
 vrt::quadradio::quadradio(const std::string &ip, size_t rx_bufsize)
   : d_ctrl_fd(0), d_data_fd(0), d_data_port(0),
-  d_band_select(0), d_rx_antenna(0), d_attenuation(0), d_10dB_atten(true)
+  d_band_select(0), d_rx_antenna(0), d_attenuation0(0), 
d_attenuation1(0)//d_10dB_atten(true)
 {
   if (!open(ip.c_str()))
     throw std::runtime_error("vrt::quadradio: failed to open " + ip + "\n");
@@ -105,11 +105,11 @@
     return true;
 }
 
-void
-vrt::quadradio::set_10dB_atten(bool on){
-    d_10dB_atten = on;
-    update_dboard_pins();
-}
+//void
+//vrt::quadradio::set_10dB_atten(bool on){
+//    d_10dB_atten = on;
+//    update_dboard_pins();
+//}
 
 bool
 vrt::quadradio::select_rx_antenna(const std::string &ant){
@@ -121,26 +121,43 @@
 }
 
 bool
-vrt::quadradio::set_attenuation(int attenuation){
+vrt::quadradio::set_attenuation0(int attenuation){
     if (attenuation < 0 || attenuation > 31) return false;
-    d_attenuation = attenuation;
+    d_attenuation0 = attenuation;
     update_dboard_pins();
     return true;
 }
 
+bool
+vrt::quadradio::set_attenuation1(int attenuation){
+    if (attenuation < 0 || attenuation > 31) return false;
+    d_attenuation1 = attenuation;
+    update_dboard_pins();
+    return true;
+}
+
 void
 vrt::quadradio::update_dboard_pins(void){
+    //reverse 5 bits in attenuation0
+    int attenuation0_rev = 0;
+    for (int i = 0; i < 5; i++){
+        attenuation0_rev += (d_attenuation0 & (1<<i))?(1 << (5-i-1)):0;
+    }
+    //printf("Atten0 %x, Atten0 Rev %x\n", d_attenuation0, attenuation0_rev);
     int db_ctrl = \
-        ((~d_attenuation & 0x1f) << 2) | \
+        ((~attenuation0_rev & 0x1f) << 10) | \
+        ((~d_attenuation1 & 0x1f) << 2) | \
         ((d_band_select  & 0x3)  << 7) | \
         ((d_rx_antenna & 0x1)  << 9);
-    if (d_10dB_atten){ //take band + 1 for alternative band
-        db_ctrl |= (d_band_select+1) & 0x3;
-    }else{ //take current band for 10dB attenuation
-        db_ctrl |= (d_band_select) & 0x3;
-    }
+    //if (d_10dB_atten){ //take band + 1 for alternative band
+    //    db_ctrl |= (d_band_select+1) & 0x3;
+    //}else{ //take current band for 10dB attenuation
+    //    db_ctrl |= (d_band_select) & 0x3;
+    //}
     /*printf("Setting dboard pins:\nband_sel %d, rx_ant %d, 10dB(on/off) %d, 
atten %d, bits %x\n",
         d_band_select, d_rx_antenna, d_10dB_atten, d_attenuation, db_ctrl);*/
+    /*printf("Setting dboard pins:\nband_sel %d, rx_ant %d, atten0 %d, atten1 
%d, bits %x\n",
+        d_band_select, d_rx_antenna, d_attenuation0, d_attenuation1, 
db_ctrl);*/
     write_dboard_pins(db_ctrl);
 }
 





reply via email to

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