From beda7c83ae4513b0ba4f6902f4eb0945245d3fe7 Mon Sep 17 00:00:00 2001
From: trondeau
Date: Fri, 17 Jul 2009 02:25:57 +0000
Subject: Adding a check box to cancel DC offset
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@11451 221aa14e-8319-0410-a670-987f0aec2ac5
---
gr-qtgui/src/python/usrp2_display.py | 52 ++++++++++++++++++++++----
gr-qtgui/src/python/usrp_display_qtgui.py | 37 +++++++++++++++---
gr-qtgui/src/python/usrp_display_qtgui.ui | 62 +++++++++++++++++++++++++++++++
3 files changed, 139 insertions(+), 12 deletions(-)
diff --git a/gr-qtgui/src/python/usrp2_display.py b/gr-qtgui/src/python/usrp2_display.py
index a145569d5..46ebfe94a 100755
--- a/gr-qtgui/src/python/usrp2_display.py
+++ b/gr-qtgui/src/python/usrp2_display.py
@@ -61,6 +61,8 @@ class main_window(QtGui.QMainWindow):
# Add the qtsnk widgets to the layout box
self.gui.sinkLayout.addWidget(snk)
+ self.gui.dcGainEdit.setText(QtCore.QString("%1").arg(0.001))
+
# Connect up some signals
self.connect(self.gui.pauseButton, QtCore.SIGNAL("clicked()"),
self.pauseFg)
@@ -77,6 +79,11 @@ class main_window(QtGui.QMainWindow):
self.saveData)
self.gui.actionSaveData.setShortcut(QtGui.QKeySequence.Save)
+ self.connect(self.gui.dcGainEdit, QtCore.SIGNAL("editingFinished()"),
+ self.dcGainEditText)
+ self.connect(self.gui.dcCancelCheckBox, QtCore.SIGNAL("clicked(bool)"),
+ self.dcCancelClicked)
+
def pauseFg(self):
if(self.gui.pauseButton.text() == "Pause"):
self.fg.stop()
@@ -145,6 +152,14 @@ class main_window(QtGui.QMainWindow):
if(len(fileName)):
self.fg.save_to_file(str(fileName))
+ def dcGainEditText(self):
+ gain = float(self.gui.dcGainEdit.text())
+ self.fg.set_dc_gain(gain)
+
+ def dcCancelClicked(self, state):
+ self.dcGainEditText()
+ self.fg.cancel_dc(state)
+
class my_top_block(gr.top_block):
@@ -201,6 +216,12 @@ class my_top_block(gr.top_block):
self.amp = gr.multiply_const_cc(0.0)
self.set_amplifier_gain(100)
+ # Create a single-pole IIR filter to remove DC
+ # but don't connect it yet
+ self.dc_gain = 0.001
+ self.dc = gr.single_pole_iir_filter_cc(self.dc_gain)
+ self.dc_sub = gr.sub_cc()
+
self.connect(self.u, self.amp, self.snk)
if self.show_debug_info:
@@ -224,16 +245,13 @@ class my_top_block(gr.top_block):
def save_to_file(self, name):
- # Pause the flow graph
- self.stop()
- self.wait()
+ self.lock()
# Add file sink to save data
self.file_sink = gr.file_sink(gr.sizeof_gr_complex, name)
self.connect(self.amp, self.file_sink)
- # Restart flow graph
- self.start()
+ self.unlock()
def set_gain(self, gain):
self._gain = gain
@@ -259,8 +277,28 @@ class my_top_block(gr.top_block):
pass
def set_amplifier_gain(self, amp):
- self._amp_value = amp
- self.amp.set_k(self._amp_value)
+ self._amp_value = amp
+ self.amp.set_k(self._amp_value)
+
+ def set_dc_gain(self, gain):
+ self.dc.set_taps(gain)
+
+ def cancel_dc(self, state):
+ self.lock()
+
+ if(state):
+ self.disconnect(self.u, self.amp)
+ self.connect(self.u, (self.dc_sub,0))
+ self.connect(self.u, self.dc, (self.dc_sub,1))
+ self.connect(self.dc_sub, self.amp)
+ else:
+ self.disconnect(self.dc_sub, self.amp)
+ self.disconnect(self.dc, (self.dc_sub,1))
+ self.disconnect(self.u, self.dc)
+ self.disconnect(self.u, (self.dc_sub,0))
+ self.connect(self.u, self.amp)
+
+ self.unlock()
def main ():
tb = my_top_block()
diff --git a/gr-qtgui/src/python/usrp_display_qtgui.py b/gr-qtgui/src/python/usrp_display_qtgui.py
index 326a823b0..4c9de3a53 100644
--- a/gr-qtgui/src/python/usrp_display_qtgui.py
+++ b/gr-qtgui/src/python/usrp_display_qtgui.py
@@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'usrp_display_qtgui.ui'
#
-# Created: Sun Jul 5 13:05:46 2009
+# Created: Thu Jul 16 22:06:24 2009
# by: PyQt4 UI code generator 4.4.3
#
# WARNING! All changes made in this file will be lost!
@@ -82,12 +82,37 @@ class Ui_MainWindow(object):
self.amplifierEdit.setObjectName("amplifierEdit")
self.formLayout.setWidget(3, QtGui.QFormLayout.FieldRole, self.amplifierEdit)
self.horizontalLayout_2.addWidget(self.groupBox)
- spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
- self.horizontalLayout_2.addItem(spacerItem)
+ self.frame_2 = QtGui.QFrame(self.centralwidget)
+ self.frame_2.setMinimumSize(QtCore.QSize(200, 0))
+ self.frame_2.setFrameShape(QtGui.QFrame.StyledPanel)
+ self.frame_2.setFrameShadow(QtGui.QFrame.Raised)
+ self.frame_2.setObjectName("frame_2")
+ self.verticalLayoutWidget = QtGui.QWidget(self.frame_2)
+ self.verticalLayoutWidget.setGeometry(QtCore.QRect(10, -1, 191, 151))
+ self.verticalLayoutWidget.setObjectName("verticalLayoutWidget")
+ self.verticalLayout_3 = QtGui.QVBoxLayout(self.verticalLayoutWidget)
+ self.verticalLayout_3.setObjectName("verticalLayout_3")
+ self.dcCancelCheckBox = QtGui.QCheckBox(self.verticalLayoutWidget)
+ self.dcCancelCheckBox.setObjectName("dcCancelCheckBox")
+ self.verticalLayout_3.addWidget(self.dcCancelCheckBox)
+ self.horizontalLayout = QtGui.QHBoxLayout()
+ self.horizontalLayout.setObjectName("horizontalLayout")
+ self.dcGainLabel = QtGui.QLabel(self.verticalLayoutWidget)
+ self.dcGainLabel.setObjectName("dcGainLabel")
+ self.horizontalLayout.addWidget(self.dcGainLabel)
+ self.dcGainEdit = QtGui.QLineEdit(self.verticalLayoutWidget)
+ self.dcGainEdit.setObjectName("dcGainEdit")
+ self.horizontalLayout.addWidget(self.dcGainEdit)
+ self.verticalLayout_3.addLayout(self.horizontalLayout)
+ spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
+ self.verticalLayout_3.addItem(spacerItem)
+ self.horizontalLayout_2.addWidget(self.frame_2)
+ spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
+ self.horizontalLayout_2.addItem(spacerItem1)
self.verticalLayout = QtGui.QVBoxLayout()
self.verticalLayout.setObjectName("verticalLayout")
- spacerItem1 = QtGui.QSpacerItem(20, 80, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed)
- self.verticalLayout.addItem(spacerItem1)
+ spacerItem2 = QtGui.QSpacerItem(20, 80, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed)
+ self.verticalLayout.addItem(spacerItem2)
self.pauseButton = QtGui.QPushButton(self.centralwidget)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
@@ -156,6 +181,8 @@ class Ui_MainWindow(object):
self.gainLabel.setText(QtGui.QApplication.translate("MainWindow", "RF Gain", None, QtGui.QApplication.UnicodeUTF8))
self.bandwidthLabel.setText(QtGui.QApplication.translate("MainWindow", "Bandwidth", None, QtGui.QApplication.UnicodeUTF8))
self.amplifierLabel.setText(QtGui.QApplication.translate("MainWindow", "Amplifier", None, QtGui.QApplication.UnicodeUTF8))
+ self.dcCancelCheckBox.setText(QtGui.QApplication.translate("MainWindow", "Cancel DC", None, QtGui.QApplication.UnicodeUTF8))
+ self.dcGainLabel.setText(QtGui.QApplication.translate("MainWindow", "DC Canceller Gain", None, QtGui.QApplication.UnicodeUTF8))
self.pauseButton.setText(QtGui.QApplication.translate("MainWindow", "Pause", None, QtGui.QApplication.UnicodeUTF8))
self.closeButton.setText(QtGui.QApplication.translate("MainWindow", "Close", None, QtGui.QApplication.UnicodeUTF8))
self.menuFile.setTitle(QtGui.QApplication.translate("MainWindow", "&File", None, QtGui.QApplication.UnicodeUTF8))
diff --git a/gr-qtgui/src/python/usrp_display_qtgui.ui b/gr-qtgui/src/python/usrp_display_qtgui.ui
index d490e0530..e88ca9dce 100644
--- a/gr-qtgui/src/python/usrp_display_qtgui.ui
+++ b/gr-qtgui/src/python/usrp_display_qtgui.ui
@@ -145,6 +145,68 @@
+ -
+
+
+
+ 200
+ 0
+
+
+
+ QFrame::StyledPanel
+
+
+ QFrame::Raised
+
+
+
+
+ 10
+ -1
+ 191
+ 151
+
+
+
+
-
+
+
+ Cancel DC
+
+
+
+ -
+
+
-
+
+
+ DC Canceller Gain
+
+
+
+ -
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+
+
+
+
-
--
cgit