[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r11238 - gnuradio/branches/developers/trondeau/qt/gnur
From: |
trondeau |
Subject: |
[Commit-gnuradio] r11238 - gnuradio/branches/developers/trondeau/qt/gnuradio-examples/python/usrp2 |
Date: |
Thu, 18 Jun 2009 21:41:54 -0600 (MDT) |
Author: trondeau
Date: 2009-06-18 21:41:54 -0600 (Thu, 18 Jun 2009)
New Revision: 11238
Modified:
gnuradio/branches/developers/trondeau/qt/gnuradio-examples/python/usrp2/qt_wfm_interface.py
gnuradio/branches/developers/trondeau/qt/gnuradio-examples/python/usrp2/qt_wfm_interface.ui
gnuradio/branches/developers/trondeau/qt/gnuradio-examples/python/usrp2/usrp2_wfm_qt.py
Log:
wip: generalizing settable parameters to allow different channel bandwidths
Modified:
gnuradio/branches/developers/trondeau/qt/gnuradio-examples/python/usrp2/qt_wfm_interface.py
===================================================================
---
gnuradio/branches/developers/trondeau/qt/gnuradio-examples/python/usrp2/qt_wfm_interface.py
2009-06-19 02:18:21 UTC (rev 11237)
+++
gnuradio/branches/developers/trondeau/qt/gnuradio-examples/python/usrp2/qt_wfm_interface.py
2009-06-19 03:41:54 UTC (rev 11238)
@@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'qt_wfm_interface.ui'
#
-# Created: Thu Jun 18 22:17:45 2009
+# Created: Thu Jun 18 23:41:03 2009
# by: PyQt4 UI code generator 4.4.3
#
# WARNING! All changes made in this file will be lost!
@@ -31,12 +31,12 @@
self.channelModeBox = QtGui.QGroupBox(self.centralwidget)
self.channelModeBox.setGeometry(QtCore.QRect(10, 520, 261, 131))
self.channelModeBox.setObjectName("channelModeBox")
- self.decimLabel = QtGui.QLabel(self.channelModeBox)
- self.decimLabel.setGeometry(QtCore.QRect(10, 90, 101, 17))
- self.decimLabel.setObjectName("decimLabel")
- self.decimEdit = QtGui.QLineEdit(self.channelModeBox)
- self.decimEdit.setGeometry(QtCore.QRect(130, 90, 113, 23))
- self.decimEdit.setObjectName("decimEdit")
+ self.bandwidthabel = QtGui.QLabel(self.channelModeBox)
+ self.bandwidthabel.setGeometry(QtCore.QRect(10, 90, 101, 17))
+ self.bandwidthabel.setObjectName("bandwidthabel")
+ self.bandwidthEdit = QtGui.QLineEdit(self.channelModeBox)
+ self.bandwidthEdit.setGeometry(QtCore.QRect(130, 90, 113, 23))
+ self.bandwidthEdit.setObjectName("bandwidthEdit")
self.gainEdit = QtGui.QLineEdit(self.channelModeBox)
self.gainEdit.setGeometry(QtCore.QRect(130, 60, 113, 23))
self.gainEdit.setObjectName("gainEdit")
@@ -82,13 +82,13 @@
QtCore.QMetaObject.connectSlotsByName(InterfaceWindow)
InterfaceWindow.setTabOrder(self.closeButton, self.gainEdit)
InterfaceWindow.setTabOrder(self.gainEdit, self.freqEdit)
- InterfaceWindow.setTabOrder(self.freqEdit, self.decimEdit)
+ InterfaceWindow.setTabOrder(self.freqEdit, self.bandwidthEdit)
def retranslateUi(self, InterfaceWindow):
InterfaceWindow.setWindowTitle(QtGui.QApplication.translate("InterfaceWindow",
"MainWindow", None, QtGui.QApplication.UnicodeUTF8))
self.closeButton.setText(QtGui.QApplication.translate("InterfaceWindow",
"Close", None, QtGui.QApplication.UnicodeUTF8))
self.channelModeBox.setTitle(QtGui.QApplication.translate("InterfaceWindow",
"USRP Parameters", None, QtGui.QApplication.UnicodeUTF8))
-
self.decimLabel.setText(QtGui.QApplication.translate("InterfaceWindow", "Decim
Rate", None, QtGui.QApplication.UnicodeUTF8))
+
self.bandwidthabel.setText(QtGui.QApplication.translate("InterfaceWindow",
"Bandwidth (Hz)", None, QtGui.QApplication.UnicodeUTF8))
self.gainLabel.setText(QtGui.QApplication.translate("InterfaceWindow",
"Gain (dB)", None, QtGui.QApplication.UnicodeUTF8))
self.freqLabel.setText(QtGui.QApplication.translate("InterfaceWindow",
"Frequency", None, QtGui.QApplication.UnicodeUTF8))
self.pauseButton.setText(QtGui.QApplication.translate("InterfaceWindow",
"Pause", None, QtGui.QApplication.UnicodeUTF8))
Modified:
gnuradio/branches/developers/trondeau/qt/gnuradio-examples/python/usrp2/qt_wfm_interface.ui
===================================================================
---
gnuradio/branches/developers/trondeau/qt/gnuradio-examples/python/usrp2/qt_wfm_interface.ui
2009-06-19 02:18:21 UTC (rev 11237)
+++
gnuradio/branches/developers/trondeau/qt/gnuradio-examples/python/usrp2/qt_wfm_interface.ui
2009-06-19 03:41:54 UTC (rev 11238)
@@ -65,7 +65,7 @@
<property name="title" >
<string>USRP Parameters</string>
</property>
- <widget class="QLabel" name="decimLabel" >
+ <widget class="QLabel" name="bandwidthabel" >
<property name="geometry" >
<rect>
<x>10</x>
@@ -75,10 +75,10 @@
</rect>
</property>
<property name="text" >
- <string>Decim Rate</string>
+ <string>Bandwidth (Hz)</string>
</property>
</widget>
- <widget class="QLineEdit" name="decimEdit" >
+ <widget class="QLineEdit" name="bandwidthEdit" >
<property name="geometry" >
<rect>
<x>130</x>
@@ -213,7 +213,7 @@
<tabstop>closeButton</tabstop>
<tabstop>gainEdit</tabstop>
<tabstop>freqEdit</tabstop>
- <tabstop>decimEdit</tabstop>
+ <tabstop>bandwidthEdit</tabstop>
</tabstops>
<resources/>
<connections>
Modified:
gnuradio/branches/developers/trondeau/qt/gnuradio-examples/python/usrp2/usrp2_wfm_qt.py
===================================================================
---
gnuradio/branches/developers/trondeau/qt/gnuradio-examples/python/usrp2/usrp2_wfm_qt.py
2009-06-19 02:18:21 UTC (rev 11237)
+++
gnuradio/branches/developers/trondeau/qt/gnuradio-examples/python/usrp2/usrp2_wfm_qt.py
2009-06-19 03:41:54 UTC (rev 11238)
@@ -62,7 +62,7 @@
self.fg = fg
# Set USRP parameters
- self.set_decim(self.fg.decim())
+ self.set_bw(self.fg.usrp_bw())
self.set_freq(self.fg.freq())
self.set_gain(self.fg.gain())
self.set_volume(self.fg.volume())
@@ -76,8 +76,8 @@
self.connect(self.gui.pauseButton, QtCore.SIGNAL("clicked()"),
self.pauseFg)
- self.connect(self.gui.decimEdit, QtCore.SIGNAL("editingFinished()"),
- self.decimEditText)
+ self.connect(self.gui.bandwidthEdit,
QtCore.SIGNAL("editingFinished()"),
+ self.bwEditText)
self.connect(self.gui.freqEdit, QtCore.SIGNAL("editingFinished()"),
self.freqEditText)
self.connect(self.gui.gainEdit, QtCore.SIGNAL("editingFinished()"),
@@ -98,8 +98,8 @@
# Accessor functions for Gui to manipulate USRP
- def set_decim(self, decim):
- self.gui.decimEdit.setText(QtCore.QString("%1").arg(decim))
+ def set_bw(self, bw):
+ self.gui.bandwidthEdit.setText(QtCore.QString("%1").arg(bw))
def set_freq(self, freq):
self.gui.freqEdit.setText(QtCore.QString("%1").arg(freq))
@@ -110,10 +110,10 @@
def set_volume(self, vol):
self.gui.volumeEdit.setText(QtCore.QString("%1").arg(vol))
- def decimEditText(self):
+ def bwEditText(self):
try:
- decim = self.gui.decimEdit.text().toDouble()[0]
- self.fg.set_decim(decim)
+ bw = self.gui.bandwidthEdit.text().toDouble()[0]
+ self.fg.set_usrp_bw(bw)
except RuntimeError:
pass
@@ -174,43 +174,39 @@
self._volume = options.volume
self._usrp_freq = options.freq
self._usrp_gain = options.gain
- self._usrp_decim = 312
+ self._audio_rate = int(32e3)
# build graph
-
+
self.u = usrp2.source_32fc(options.interface, options.mac_addr)
- adc_rate = self.u.adc_rate() # 100 MS/s
+ # calculate decimation values to get USRP BW at 320 kHz
+ self.calculate_usrp_bw(320e3)
+
self.set_decim(self._usrp_decim)
- usrp_rate = adc_rate / self._usrp_decim # ~320 kS/s
- chanfilt_decim = 1
- demod_rate = usrp_rate / chanfilt_decim
- audio_decimation = 10
- audio_rate = demod_rate / audio_decimation # ~32 kHz
-
#FIXME: need named constants and text descriptions available to
(gr-)usrp2 even
#when usrp(1) module is not built. A usrp_common module, perhaps?
dbid = self.u.daughterboard_id()
print "Using RX d'board 0x%04X" % (dbid,)
- if not (dbid == 0x0001 or #usrp_dbid.BASIC_RX
- dbid == 0x0003 or #usrp_dbid.TV_RX
- dbid == 0x000c or #usrp_dbid.TV_RX_REV_2
- dbid == 0x0040): #usrp_dbid.TV_RX_REV_3
- print "This daughterboard does not cover the required frequency
range"
- print "for this application. Please use a BasicRX or TVRX
daughterboard."
- raw_input("Press ENTER to continue anyway, or Ctrl-C to exit.")
+ #if not (dbid == 0x0001 or #usrp_dbid.BASIC_RX
+ # dbid == 0x0003 or #usrp_dbid.TV_RX
+ # dbid == 0x000c or #usrp_dbid.TV_RX_REV_2
+ # dbid == 0x0040): #usrp_dbid.TV_RX_REV_3
+ # print "This daughterboard does not cover the required frequency
range"
+ # print "for this application. Please use a BasicRX or TVRX
daughterboard."
+ # raw_input("Press ENTER to continue anyway, or Ctrl-C to exit.")
- chan_filt_coeffs = optfir.low_pass (1, # gain
- usrp_rate, # sampling rate
+ chan_filt_coeffs = optfir.low_pass (1, # gain
+ self._usrp_rate, # sampling rate
80e3, # passband cutoff
115e3, # stopband cutoff
0.1, # passband ripple
60) # stopband attenuation
#print len(chan_filt_coeffs)
- chan_filt = gr.fir_filter_ccf (chanfilt_decim, chan_filt_coeffs)
+ chan_filt = gr.fir_filter_ccf (self._chanfilt_decim, chan_filt_coeffs)
- self.guts = blks2.wfm_rcv (demod_rate, audio_decimation)
+ self.guts = blks2.wfm_rcv (self._demod_rate, self._audio_decim)
self.volume_control = gr.multiply_const_ff(1)
@@ -218,7 +214,7 @@
#audio_sink = audio.sink (int (audio_rate),
# options.audio_output,
# False) # ok_to_block
- audio_sink = audio.sink (32000,
+ audio_sink = audio.sink (self._audio_rate,
options.audio_output)
@@ -247,11 +243,11 @@
fftsize = 2048
self.usrp_rx = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS,
- -usrp_rate/2.0, usrp_rate/2.0,
+ -self._usrp_rate/2.0, self._usrp_rate/2.0,
"Received Signal", True, True, False,
True, False,
use_openGL=False)
self.usrp_rx2 = qtgui.sink_f(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS,
- -usrp_rate/2.0, usrp_rate/2.0,
+ -self._usrp_rate/2.0, self._usrp_rate/2.0,
"Received Signal", True, True, False,
True, False)
# now wire it all together
@@ -264,8 +260,36 @@
self.main_box = dialog_box(usrp_rx_widget, usrp_rx2_widget, self)
self.main_box.show()
-
+
+ def calculate_usrp_bw(self, bw):
+ """
+ Calculate the different decimation rates that make the USRP BW equal
to the
+ input bandwidth parameter 'bw' and the audio bandwidth equal to the
system-
+ wide bandwidth 'self._audio_rate'
+ """
+
+ adc_rate = self.u.adc_rate()
+ d_usrp = int(adc_rate/bw)
+ bw_real = adc_rate / float(d_usrp)
+
+ d_chan = 1
+ demod_rate = bw_real / d_chan
+
+ d_audio = int(bw_real / self._audio_rate)
+ audio_rate = demod_rate / d_audio
+
+ self._usrp_decim = d_usrp
+ self._chanfilt_decim = d_chan
+ self._audio_decim = d_audio
+ self._demod_rate = demod_rate
+ self._usrp_rate = bw_real
+
+ print "USRP Decimation: ", self._usrp_decim
+ print "USRP Bandwidth: ", bw_real
+ print "Audio Decimation: ", self._audio_decim
+ print "Audio Bandwidth: ", audio_rate
+
def set_volume (self, vol):
g = self.volume_range()
self._volume = max(g[0], min(g[1], vol))
@@ -289,6 +313,9 @@
return True
return False
+ def set_usrp_bw(self, bw):
+ self.calculate_usrp_bw(bw)
+
def set_gain(self, gain):
self._usrp_gain = gain
self.u.set_gain(gain)
@@ -303,6 +330,9 @@
def freq(self):
return self._usrp_freq
+ def usrp_bw(self):
+ return self._usrp_rate
+
def gain(self):
return self._usrp_gain
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r11238 - gnuradio/branches/developers/trondeau/qt/gnuradio-examples/python/usrp2,
trondeau <=