mirror of
https://github.com/nqrduck/nqrduck-autotm.git
synced 2024-12-30 11:28:07 +00:00
Added tuning and matching voltages to model and updated the values accordingly. Added an option for voltage sweep with predifined voltages.
This commit is contained in:
parent
7b9f680b96
commit
5457b40a65
4 changed files with 103 additions and 60 deletions
|
@ -7,6 +7,7 @@ from serial.tools.list_ports import comports
|
||||||
from PyQt6.QtTest import QTest
|
from PyQt6.QtTest import QTest
|
||||||
from PyQt6 import QtSerialPort
|
from PyQt6 import QtSerialPort
|
||||||
from PyQt6.QtCore import QThread, pyqtSignal, pyqtSlot, Qt
|
from PyQt6.QtCore import QThread, pyqtSignal, pyqtSlot, Qt
|
||||||
|
from PyQt6.QtCore import QTimer
|
||||||
from PyQt6.QtWidgets import QApplication
|
from PyQt6.QtWidgets import QApplication
|
||||||
from nqrduck.module.module_controller import ModuleController
|
from nqrduck.module.module_controller import ModuleController
|
||||||
from .model import S11Data, ElectricalLookupTable, MechanicalLookupTable, SavedPosition, Stepper
|
from .model import S11Data, ElectricalLookupTable, MechanicalLookupTable, SavedPosition, Stepper
|
||||||
|
@ -49,6 +50,7 @@ class AutoTMController(ModuleController):
|
||||||
elif self.module.model.LUT.TYPE == "Electrical":
|
elif self.module.model.LUT.TYPE == "Electrical":
|
||||||
tunning_voltage, matching_voltage = self.module.model.LUT.get_voltages(frequency)
|
tunning_voltage, matching_voltage = self.module.model.LUT.get_voltages(frequency)
|
||||||
confirmation = self.set_voltages(str(tunning_voltage), str(matching_voltage))
|
confirmation = self.set_voltages(str(tunning_voltage), str(matching_voltage))
|
||||||
|
# We need to waitfor the voltages to be set it would be nicer to have this confirmed by the ATM
|
||||||
if confirmation:
|
if confirmation:
|
||||||
reflection = self.read_reflection(frequency)
|
reflection = self.read_reflection(frequency)
|
||||||
self.module.nqrduck_signal.emit("confirm_tune_and_match", reflection)
|
self.module.nqrduck_signal.emit("confirm_tune_and_match", reflection)
|
||||||
|
@ -226,9 +228,14 @@ class AutoTMController(ModuleController):
|
||||||
text = text[1:].split("t")
|
text = text[1:].split("t")
|
||||||
matching_voltage, tuning_voltage = map(float, text)
|
matching_voltage, tuning_voltage = map(float, text)
|
||||||
LUT = self.module.model.el_lut
|
LUT = self.module.model.el_lut
|
||||||
logger.debug("Received voltage sweep result: %s %s", matching_voltage, tuning_voltage)
|
if LUT is not None:
|
||||||
LUT.add_voltages(matching_voltage, tuning_voltage)
|
if LUT.is_incomplete():
|
||||||
self.continue_or_finish_voltage_sweep(LUT)
|
logger.debug("Received voltage sweep result: %s %s", matching_voltage, tuning_voltage)
|
||||||
|
LUT.add_voltages(matching_voltage, tuning_voltage)
|
||||||
|
self.continue_or_finish_voltage_sweep(LUT)
|
||||||
|
|
||||||
|
self.module.model.tuning_voltage = tuning_voltage
|
||||||
|
self.module.model.matching_voltage = matching_voltage
|
||||||
|
|
||||||
def finish_frequency_sweep(self):
|
def finish_frequency_sweep(self):
|
||||||
"""This method is called when a frequency sweep is finished.
|
"""This method is called when a frequency sweep is finished.
|
||||||
|
@ -261,7 +268,14 @@ class AutoTMController(ModuleController):
|
||||||
LUT (LookupTable): The lookup table that is being generated.
|
LUT (LookupTable): The lookup table that is being generated.
|
||||||
"""
|
"""
|
||||||
next_frequency = LUT.get_next_frequency()
|
next_frequency = LUT.get_next_frequency()
|
||||||
command = f"s{next_frequency}"
|
# We write the first command to the serial connection
|
||||||
|
if self.module.view._ui_form.prevVoltagecheckBox.isChecked():
|
||||||
|
# Command format is s<frequency in MHz>o<optional tuning voltage>o<optional matching voltage>
|
||||||
|
# We use the currently set voltages
|
||||||
|
command = "s%so%so%s" % (next_frequency, self.module.model.tuning_voltage, self.module.model.matching_voltage)
|
||||||
|
else:
|
||||||
|
command = "s%s" % (next_frequency)
|
||||||
|
|
||||||
LUT.started_frequency = next_frequency
|
LUT.started_frequency = next_frequency
|
||||||
logger.debug("Starting next voltage sweep: %s", command)
|
logger.debug("Starting next voltage sweep: %s", command)
|
||||||
self.send_command(command)
|
self.send_command(command)
|
||||||
|
@ -493,6 +507,8 @@ class AutoTMController(ModuleController):
|
||||||
"""
|
"""
|
||||||
logger.debug("Setting voltages")
|
logger.debug("Setting voltages")
|
||||||
MAX_VOLTAGE = 5 # V
|
MAX_VOLTAGE = 5 # V
|
||||||
|
timeout_duration = 15 # timeout in seconds
|
||||||
|
|
||||||
try:
|
try:
|
||||||
tuning_voltage = tuning_voltage.replace(",", ".")
|
tuning_voltage = tuning_voltage.replace(",", ".")
|
||||||
matching_voltage = matching_voltage.replace(",", ".")
|
matching_voltage = matching_voltage.replace(",", ".")
|
||||||
|
@ -525,13 +541,20 @@ class AutoTMController(ModuleController):
|
||||||
)
|
)
|
||||||
|
|
||||||
command = "v%sv%s" % (matching_voltage, tuning_voltage)
|
command = "v%sv%s" % (matching_voltage, tuning_voltage)
|
||||||
|
|
||||||
|
start_time = time.time()
|
||||||
|
|
||||||
confirmation = self.send_command(command)
|
confirmation = self.send_command(command)
|
||||||
if confirmation:
|
if confirmation:
|
||||||
logger.debug("Voltages set successfully")
|
while matching_voltage == self.module.model.matching_voltage:
|
||||||
return True
|
QApplication.processEvents()
|
||||||
# Emit nqrduck signal that T&M was successful
|
# Check for timeout
|
||||||
# Maybe we measure the reflection first so we don't damage the PA lol
|
if time.time() - start_time > timeout_duration:
|
||||||
# The broadband module can then decide what to do with the signal
|
logger.error("Absolute move timed out")
|
||||||
|
break # or handle timeout differently
|
||||||
|
|
||||||
|
logger.debug("Voltages set successfully")
|
||||||
|
return confirmation
|
||||||
|
|
||||||
### Electrical Lookup Table ###
|
### Electrical Lookup Table ###
|
||||||
|
|
||||||
|
@ -601,7 +624,13 @@ class AutoTMController(ModuleController):
|
||||||
LUT.started_frequency = start_frequency
|
LUT.started_frequency = start_frequency
|
||||||
|
|
||||||
# We write the first command to the serial connection
|
# We write the first command to the serial connection
|
||||||
command = "s%s" % (start_frequency)
|
if self.module.view._ui_form.prevVoltagecheckBox.isChecked():
|
||||||
|
# Command format is s<frequency in MHz>o<optional tuning voltage>o<optional matching voltage>
|
||||||
|
# We use the currently set voltages
|
||||||
|
logger.debug("Starting preset Voltage sweep with voltage Tuning: %s V and Matching: %s V", self.module.model.tuning_voltage, self.module.model.matching_voltage)
|
||||||
|
command = "s%so%so%s" % (start_frequency, self.module.model.tuning_voltage, self.module.model.matching_voltage)
|
||||||
|
else:
|
||||||
|
command = "s%s" % (start_frequency)
|
||||||
|
|
||||||
# For timing of the voltage sweep
|
# For timing of the voltage sweep
|
||||||
self.module.model.voltage_sweep_start = time.time()
|
self.module.model.voltage_sweep_start = time.time()
|
||||||
|
|
|
@ -390,6 +390,9 @@ class AutoTMModel(ModuleModel):
|
||||||
|
|
||||||
self.last_reflection = None
|
self.last_reflection = None
|
||||||
|
|
||||||
|
self.tuning_voltage = None
|
||||||
|
self.matching_voltage = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def available_devices(self):
|
def available_devices(self):
|
||||||
return self._available_devices
|
return self._available_devices
|
||||||
|
|
|
@ -152,7 +152,7 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTabWidget" name="typeTab">
|
<widget class="QTabWidget" name="typeTab">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>0</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="mechTab">
|
<widget class="QWidget" name="mechTab">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
|
@ -313,11 +313,17 @@
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>Electrical</string>
|
<string>Electrical</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QGridLayout" name="gridLayout_3" rowstretch="0,0,0,0,0,0,0,0,0,0">
|
<layout class="QGridLayout" name="gridLayout_3" rowstretch="0,0,0,0,0,0,0,0,0,0,0">
|
||||||
<item row="8" column="0" colspan="2">
|
<item row="0" column="0">
|
||||||
<widget class="QPushButton" name="generateLUTButton">
|
<widget class="QLabel" name="label_9">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<weight>75</weight>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Generate LUT</string>
|
<string>Set Voltages:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -328,6 +334,16 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QDoubleSpinBox" name="matchingBox"/>
|
||||||
|
</item>
|
||||||
|
<item row="8" column="0" colspan="2">
|
||||||
|
<widget class="QPushButton" name="generateLUTButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Generate LUT</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QDoubleSpinBox" name="tuningBox"/>
|
<widget class="QDoubleSpinBox" name="tuningBox"/>
|
||||||
</item>
|
</item>
|
||||||
|
@ -344,27 +360,7 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="10" column="0" colspan="2">
|
||||||
<widget class="QLabel" name="label_3">
|
|
||||||
<property name="text">
|
|
||||||
<string>Voltage Matching</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QLabel" name="label_9">
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<weight>75</weight>
|
|
||||||
<bold>true</bold>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Set Voltages:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="9" column="0" colspan="2">
|
|
||||||
<widget class="QPushButton" name="viewelLUTButton">
|
<widget class="QPushButton" name="viewelLUTButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>View LUT</string>
|
<string>View LUT</string>
|
||||||
|
@ -378,8 +374,19 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="2" column="0">
|
||||||
<widget class="QDoubleSpinBox" name="matchingBox"/>
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>Voltage Matching</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="9" column="0">
|
||||||
|
<widget class="QCheckBox" name="prevVoltagecheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>Start from previous Voltage</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
|
|
@ -164,12 +164,22 @@ class Ui_Form(object):
|
||||||
self.elecTab.setObjectName("elecTab")
|
self.elecTab.setObjectName("elecTab")
|
||||||
self.gridLayout_3 = QtWidgets.QGridLayout(self.elecTab)
|
self.gridLayout_3 = QtWidgets.QGridLayout(self.elecTab)
|
||||||
self.gridLayout_3.setObjectName("gridLayout_3")
|
self.gridLayout_3.setObjectName("gridLayout_3")
|
||||||
self.generateLUTButton = QtWidgets.QPushButton(parent=self.elecTab)
|
self.label_9 = QtWidgets.QLabel(parent=self.elecTab)
|
||||||
self.generateLUTButton.setObjectName("generateLUTButton")
|
font = QtGui.QFont()
|
||||||
self.gridLayout_3.addWidget(self.generateLUTButton, 8, 0, 1, 2)
|
font.setBold(True)
|
||||||
|
font.setWeight(75)
|
||||||
|
self.label_9.setFont(font)
|
||||||
|
self.label_9.setObjectName("label_9")
|
||||||
|
self.gridLayout_3.addWidget(self.label_9, 0, 0, 1, 1)
|
||||||
self.label_2 = QtWidgets.QLabel(parent=self.elecTab)
|
self.label_2 = QtWidgets.QLabel(parent=self.elecTab)
|
||||||
self.label_2.setObjectName("label_2")
|
self.label_2.setObjectName("label_2")
|
||||||
self.gridLayout_3.addWidget(self.label_2, 1, 0, 1, 1)
|
self.gridLayout_3.addWidget(self.label_2, 1, 0, 1, 1)
|
||||||
|
self.matchingBox = QtWidgets.QDoubleSpinBox(parent=self.elecTab)
|
||||||
|
self.matchingBox.setObjectName("matchingBox")
|
||||||
|
self.gridLayout_3.addWidget(self.matchingBox, 2, 1, 1, 1)
|
||||||
|
self.generateLUTButton = QtWidgets.QPushButton(parent=self.elecTab)
|
||||||
|
self.generateLUTButton.setObjectName("generateLUTButton")
|
||||||
|
self.gridLayout_3.addWidget(self.generateLUTButton, 8, 0, 1, 2)
|
||||||
self.tuningBox = QtWidgets.QDoubleSpinBox(parent=self.elecTab)
|
self.tuningBox = QtWidgets.QDoubleSpinBox(parent=self.elecTab)
|
||||||
self.tuningBox.setObjectName("tuningBox")
|
self.tuningBox.setObjectName("tuningBox")
|
||||||
self.gridLayout_3.addWidget(self.tuningBox, 1, 1, 1, 1)
|
self.gridLayout_3.addWidget(self.tuningBox, 1, 1, 1, 1)
|
||||||
|
@ -180,25 +190,18 @@ class Ui_Form(object):
|
||||||
self.label_11.setFont(font)
|
self.label_11.setFont(font)
|
||||||
self.label_11.setObjectName("label_11")
|
self.label_11.setObjectName("label_11")
|
||||||
self.gridLayout_3.addWidget(self.label_11, 4, 0, 1, 1)
|
self.gridLayout_3.addWidget(self.label_11, 4, 0, 1, 1)
|
||||||
self.label_3 = QtWidgets.QLabel(parent=self.elecTab)
|
|
||||||
self.label_3.setObjectName("label_3")
|
|
||||||
self.gridLayout_3.addWidget(self.label_3, 2, 0, 1, 1)
|
|
||||||
self.label_9 = QtWidgets.QLabel(parent=self.elecTab)
|
|
||||||
font = QtGui.QFont()
|
|
||||||
font.setBold(True)
|
|
||||||
font.setWeight(75)
|
|
||||||
self.label_9.setFont(font)
|
|
||||||
self.label_9.setObjectName("label_9")
|
|
||||||
self.gridLayout_3.addWidget(self.label_9, 0, 0, 1, 1)
|
|
||||||
self.viewelLUTButton = QtWidgets.QPushButton(parent=self.elecTab)
|
self.viewelLUTButton = QtWidgets.QPushButton(parent=self.elecTab)
|
||||||
self.viewelLUTButton.setObjectName("viewelLUTButton")
|
self.viewelLUTButton.setObjectName("viewelLUTButton")
|
||||||
self.gridLayout_3.addWidget(self.viewelLUTButton, 9, 0, 1, 2)
|
self.gridLayout_3.addWidget(self.viewelLUTButton, 10, 0, 1, 2)
|
||||||
self.setvoltagesButton = QtWidgets.QPushButton(parent=self.elecTab)
|
self.setvoltagesButton = QtWidgets.QPushButton(parent=self.elecTab)
|
||||||
self.setvoltagesButton.setObjectName("setvoltagesButton")
|
self.setvoltagesButton.setObjectName("setvoltagesButton")
|
||||||
self.gridLayout_3.addWidget(self.setvoltagesButton, 3, 0, 1, 2)
|
self.gridLayout_3.addWidget(self.setvoltagesButton, 3, 0, 1, 2)
|
||||||
self.matchingBox = QtWidgets.QDoubleSpinBox(parent=self.elecTab)
|
self.label_3 = QtWidgets.QLabel(parent=self.elecTab)
|
||||||
self.matchingBox.setObjectName("matchingBox")
|
self.label_3.setObjectName("label_3")
|
||||||
self.gridLayout_3.addWidget(self.matchingBox, 2, 1, 1, 1)
|
self.gridLayout_3.addWidget(self.label_3, 2, 0, 1, 1)
|
||||||
|
self.prevVoltagecheckBox = QtWidgets.QCheckBox(parent=self.elecTab)
|
||||||
|
self.prevVoltagecheckBox.setObjectName("prevVoltagecheckBox")
|
||||||
|
self.gridLayout_3.addWidget(self.prevVoltagecheckBox, 9, 0, 1, 1)
|
||||||
self.typeTab.addTab(self.elecTab, "")
|
self.typeTab.addTab(self.elecTab, "")
|
||||||
self.verticalLayout_2.addWidget(self.typeTab)
|
self.verticalLayout_2.addWidget(self.typeTab)
|
||||||
self.rfswitchLabel = QtWidgets.QLabel(parent=Form)
|
self.rfswitchLabel = QtWidgets.QLabel(parent=Form)
|
||||||
|
@ -284,7 +287,7 @@ class Ui_Form(object):
|
||||||
self.horizontalLayout_2.setStretch(1, 1)
|
self.horizontalLayout_2.setStretch(1, 1)
|
||||||
|
|
||||||
self.retranslateUi(Form)
|
self.retranslateUi(Form)
|
||||||
self.typeTab.setCurrentIndex(0)
|
self.typeTab.setCurrentIndex(1)
|
||||||
QtCore.QMetaObject.connectSlotsByName(Form)
|
QtCore.QMetaObject.connectSlotsByName(Form)
|
||||||
|
|
||||||
def retranslateUi(self, Form):
|
def retranslateUi(self, Form):
|
||||||
|
@ -316,13 +319,14 @@ class Ui_Form(object):
|
||||||
self.mechLUTButton.setText(_translate("Form", "Generate LUT"))
|
self.mechLUTButton.setText(_translate("Form", "Generate LUT"))
|
||||||
self.viewmechLUTButton.setText(_translate("Form", "View LUT"))
|
self.viewmechLUTButton.setText(_translate("Form", "View LUT"))
|
||||||
self.typeTab.setTabText(self.typeTab.indexOf(self.mechTab), _translate("Form", "Mechanical"))
|
self.typeTab.setTabText(self.typeTab.indexOf(self.mechTab), _translate("Form", "Mechanical"))
|
||||||
self.generateLUTButton.setText(_translate("Form", "Generate LUT"))
|
|
||||||
self.label_2.setText(_translate("Form", "Voltage Tuning"))
|
|
||||||
self.label_11.setText(_translate("Form", "Generate LUT:"))
|
|
||||||
self.label_3.setText(_translate("Form", "Voltage Matching"))
|
|
||||||
self.label_9.setText(_translate("Form", "Set Voltages:"))
|
self.label_9.setText(_translate("Form", "Set Voltages:"))
|
||||||
|
self.label_2.setText(_translate("Form", "Voltage Tuning"))
|
||||||
|
self.generateLUTButton.setText(_translate("Form", "Generate LUT"))
|
||||||
|
self.label_11.setText(_translate("Form", "Generate LUT:"))
|
||||||
self.viewelLUTButton.setText(_translate("Form", "View LUT"))
|
self.viewelLUTButton.setText(_translate("Form", "View LUT"))
|
||||||
self.setvoltagesButton.setText(_translate("Form", "Set Voltages"))
|
self.setvoltagesButton.setText(_translate("Form", "Set Voltages"))
|
||||||
|
self.label_3.setText(_translate("Form", "Voltage Matching"))
|
||||||
|
self.prevVoltagecheckBox.setText(_translate("Form", "Start from previous Voltage"))
|
||||||
self.typeTab.setTabText(self.typeTab.indexOf(self.elecTab), _translate("Form", "Electrical"))
|
self.typeTab.setTabText(self.typeTab.indexOf(self.elecTab), _translate("Form", "Electrical"))
|
||||||
self.rfswitchLabel.setText(_translate("Form", "RF Switch:"))
|
self.rfswitchLabel.setText(_translate("Form", "RF Switch:"))
|
||||||
self.switchATMButton.setText(_translate("Form", "ATM"))
|
self.switchATMButton.setText(_translate("Form", "ATM"))
|
||||||
|
|
Loading…
Reference in a new issue