Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add auto pause checkbox feature to stop RF output after sweep #173

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions NanoVNASaver/Hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ def writeSerial(self, command):
def setSweep(self, start, stop):
self.writeSerial("sweep " + str(start) + " " + str(stop) + " 101")

def pauseSweep(self):
self.writeSerial("pause")


class InvalidVNA(VNA):
name = "Invalid"
Expand All @@ -201,6 +204,9 @@ def __init__(self):

def setSweep(self, start, stop):
return

def pauseSweep(self):
return

def resetSweep(self, start, stop):
return
Expand Down Expand Up @@ -353,6 +359,9 @@ def setSweep(self, start, stop):
self.writeSerial("sweep " + str(start) + " " + str(stop) + " 101")
sleep(1)

def pauseSweep(self):
self.writeSerial("pause")


class NanoVNA_H(NanoVNA):
name = "NanoVNA-H"
Expand Down
7 changes: 7 additions & 0 deletions NanoVNASaver/NanoVNASaver.py
Original file line number Diff line number Diff line change
Expand Up @@ -2050,11 +2050,14 @@ def __init__(self, app: NanoVNASaver):
self.single_sweep_radiobutton = QtWidgets.QRadioButton("Single sweep")
self.continuous_sweep_radiobutton = QtWidgets.QRadioButton("Continuous sweep")
self.averaged_sweep_radiobutton = QtWidgets.QRadioButton("Averaged sweep")
self.auto_pause_sweep_checkbox = QtWidgets.QCheckBox("Pause hardware stimulus after completion")

settings_layout.addWidget(self.single_sweep_radiobutton)
self.single_sweep_radiobutton.setChecked(True)
settings_layout.addWidget(self.continuous_sweep_radiobutton)
settings_layout.addWidget(self.averaged_sweep_radiobutton)
settings_layout.addWidget(self.auto_pause_sweep_checkbox)
self.auto_pause_sweep_checkbox.setChecked(False)

self.averages = QtWidgets.QLineEdit("3")
self.truncates = QtWidgets.QLineEdit("0")
Expand All @@ -2066,6 +2069,7 @@ def __init__(self, app: NanoVNASaver):

self.continuous_sweep_radiobutton.toggled.connect(
lambda: self.app.worker.setContinuousSweep(self.continuous_sweep_radiobutton.isChecked()))
self.auto_pause_sweep_checkbox.toggled.connect(self.updateAutoPauseSweep)
self.averaged_sweep_radiobutton.toggled.connect(self.updateAveraging)
self.averages.textEdited.connect(self.updateAveraging)
self.truncates.textEdited.connect(self.updateAveraging)
Expand Down Expand Up @@ -2162,6 +2166,9 @@ def updateAveraging(self):
self.app.worker.setAveraging(self.averaged_sweep_radiobutton.isChecked(),
self.averages.text(),
self.truncates.text())

def updateAutoPauseSweep(self):
self.app.worker.setAutoPauseSweep(self.auto_pause_sweep_checkbox.isChecked())


class BandsWindow(QtWidgets.QWidget):
Expand Down
14 changes: 14 additions & 0 deletions NanoVNASaver/SweepWorker.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def __init__(self, app: NanoVNASaver):
self.stopped = False
self.running = False
self.continuousSweep = False
self.autoPauseSweep = False
self.averaging = False
self.averages = 3
self.truncates = 0
Expand Down Expand Up @@ -179,6 +180,9 @@ def run(self):
self.vna.resetSweep(RFTools.parseFrequency(self.app.sweepStartInput.text()),
RFTools.parseFrequency(self.app.sweepEndInput.text()))

if self.autoPauseSweep:
self.vna.pauseSweep()

self.percentage = 100
logger.debug("Sending \"finished\" signal")
self.signals.finished.emit()
Expand Down Expand Up @@ -329,6 +333,8 @@ def readSegment(self, start, stop):
# S21
values21 = self.readData("data 1")

if self.autoPauseSweep:
self.vna.pauseSweep()
return frequencies, values11, values21

def readData(self, data):
Expand Down Expand Up @@ -371,6 +377,8 @@ def readData(self, data):
raise NanoVNAValueException("Failed reading " + str(data) + " " + str(count) + " times.\n" +
"Data outside expected valid ranges, or in an unexpected format.\n\n" +
"You can disable data validation on the device settings screen.")
if self.autoPauseSweep:
self.vna.pauseSweep()
return returndata

def readFreq(self):
Expand Down Expand Up @@ -399,6 +407,9 @@ def readFreq(self):
raise NanoVNAValueException("Failed reading frequencies " + str(count) + " times.")
else:
returnfreq.append(int(f))

if self.autoPauseSweep:
self.vna.pauseSweep()
return returnfreq

def setContinuousSweep(self, continuous_sweep: bool):
Expand All @@ -411,6 +422,9 @@ def setAveraging(self, averaging: bool, averages: str, truncates: str):
self.truncates = int(truncates)
except ValueError:
return

def setAutoPauseSweep(self, auto_pause_sweep: bool):
self.autoPauseSweep = auto_pause_sweep

def setVNA(self, vna):
self.vna = vna
Expand Down