gui: add transconductance cfg to the pd_mon_form

This commit is contained in:
2025-03-24 12:30:29 +08:00
parent 10f79615e8
commit 3125e7cff0
2 changed files with 335 additions and 27 deletions
+43 -15
View File
@@ -733,6 +733,12 @@ class MainWindow(QtWidgets.QMainWindow):
self.cfg_pd_mon_form.settable_pwr_range_display_lbl.setText(f" 0 - {siConvert(ld_settings['ld_pwr_limit']['max'], pwr_unit):.4f}")
self.cfg_pd_mon_form.cfg_pwr_limit_spinbox.setMaximum(siConvert(ld_settings['ld_pwr_limit']['max'], pwr_unit))
transconductance_unit = self.cfg_pd_mon_form.resulting_pd_transconductance_lbl.unit
self.cfg_pd_mon_form.resulting_pd_transconductance_reading.setText(f"{siConvert(ld_settings['pd_mon_params']['transconductance'], transconductance_unit)}")
pd_current_unit = self.cfg_pd_mon_form.cfg_dark_current_spinbox.unit
self.cfg_pd_mon_form.allowed_photodiode_current_range_reading.setText(f" 0 - {siConvert(ld_settings['ld_pwr_limit']['max']*ld_settings['pd_mon_params']['responsitivity'], pd_current_unit):.4f}")
responsitivity_unit = self.cfg_pd_mon_form.cfg_responsitivity_spinbox.unit
self.cfg_pd_mon_form.cfg_responsitivity_reading.setText(f"{siConvert(ld_settings['pd_mon_params']['responsitivity'], responsitivity_unit):.4f}")
@@ -858,24 +864,46 @@ class MainWindow(QtWidgets.QMainWindow):
settings = await self.kirdy.device.get_settings_summary()
set_spinbox_value(self.cfg_pd_mon_form.cfg_pwr_limit_spinbox, settings['laser']['ld_pwr_limit']['max'])
self.kirdy_handler.dispatch_task_to_kirdy(self.kirdy.laser.set_ld_pwr_limit(settings['laser']['ld_pwr_limit']['max']))
self.cfg_pd_mon_form.apply_pwr_limit_max_btn.clicked.connect(apply_ld_pwr_limit_max)
ld_pwr_limit_unit = self.params[0].child('Photodiode Monitor Config', 'LD Power Limit').opts["unit"]
ld_pwr_limit_text = self.cfg_pd_mon_form.cfg_pwr_limit_lbl.text()
self.cfg_pd_mon_form.cfg_pwr_limit_lbl.setText(ld_pwr_limit_text.replace(":", f" ({ld_pwr_limit_unit}):"))
self.cfg_pd_mon_form.cfg_pwr_limit_spinbox.unit = ld_pwr_limit_unit
settable_pwr_limit_text = self.cfg_pd_mon_form.settable_pwr_range_lbl.text()
self.cfg_pd_mon_form.settable_pwr_range_lbl.setText(settable_pwr_limit_text.replace(":", f" ({ld_pwr_limit_unit}):"))
self.cfg_pd_mon_form.cfg_pwr_limit_spinbox.unit = self.params[0].child('Photodiode Monitor Config', 'LD Power Limit').opts["unit"]
self.cfg_pd_mon_form.cfg_responsitivity_spinbox.unit = self.params[0].child('Photodiode Monitor Config', 'Responsitivity').opts["unit"]
self.cfg_pd_mon_form.cfg_dark_current_spinbox.unit = self.params[0].child('Photodiode Monitor Config', 'Dark Current').opts["unit"]
self.cfg_pd_mon_form.cfg_pd_fb_resistance_spinbox.unit = "Ω"
self.cfg_pd_mon_form.allowed_photodiode_current_range_lbl.unit = self.params[0].child('Readings', 'PD Current').opts["unit"]
self.cfg_pd_mon_form.resulting_pd_transconductance_lbl.unit = "uS"
pd_responsitivity_unit = self.params[0].child('Photodiode Monitor Config', 'Responsitivity').opts["unit"]
pd_responsitivity_text = self.cfg_pd_mon_form.cfg_responsitivity_lbl.text()
self.cfg_pd_mon_form.cfg_responsitivity_lbl.setText(pd_responsitivity_text.replace(":", f" ({pd_responsitivity_unit}):"))
self.cfg_pd_mon_form.cfg_responsitivity_spinbox.unit = pd_responsitivity_unit
def _append_unit_to_lbl(lbl, unit):
lbl.setText(lbl.text().replace(":", f" ({unit}):"))
_append_unit_to_lbl(self.cfg_pd_mon_form.cfg_pwr_limit_lbl, self.cfg_pd_mon_form.cfg_pwr_limit_spinbox.unit)
_append_unit_to_lbl(self.cfg_pd_mon_form.settable_pwr_range_lbl, self.cfg_pd_mon_form.cfg_pwr_limit_spinbox.unit)
_append_unit_to_lbl(self.cfg_pd_mon_form.cfg_responsitivity_lbl, self.cfg_pd_mon_form.cfg_responsitivity_spinbox.unit)
_append_unit_to_lbl(self.cfg_pd_mon_form.cfg_dark_current_lbl, self.cfg_pd_mon_form.cfg_dark_current_spinbox.unit)
_append_unit_to_lbl(self.cfg_pd_mon_form.allowed_photodiode_current_range_lbl, self.cfg_pd_mon_form.allowed_photodiode_current_range_lbl.unit)
_append_unit_to_lbl(self.cfg_pd_mon_form.resulting_pd_transconductance_lbl, self.cfg_pd_mon_form.resulting_pd_transconductance_lbl.unit)
_append_unit_to_lbl(self.cfg_pd_mon_form.cfg_pd_fb_resistance_lbl, self.cfg_pd_mon_form.cfg_pd_fb_resistance_spinbox.unit)
pd_dark_current_unit = self.params[0].child('Photodiode Monitor Config', 'Dark Current').opts["unit"]
pd_dark_current_text = self.cfg_pd_mon_form.cfg_dark_current_lbl.text()
self.cfg_pd_mon_form.cfg_dark_current_lbl.setText(pd_dark_current_text.replace(":", f" ({pd_dark_current_unit}):"))
self.cfg_pd_mon_form.cfg_dark_current_spinbox.unit = pd_dark_current_unit
@asyncSlot(bool)
async def apply_transconductance(_):
fin_gain = self.cfg_pd_mon_form.cfg_pd_fin_gain_spinbox.value()
fb_resistance = self.cfg_pd_mon_form.cfg_pd_fb_resistance_spinbox.value()
self.kirdy_handler.dispatch_task_to_kirdy(self.kirdy.device.set_pd_mon_fin_gain(fin_gain))
self.kirdy_handler.dispatch_task_to_kirdy(self.kirdy.device.set_pd_mon_transconductance(1.0 / fb_resistance))
self.cfg_pd_mon_form.apply_pd_transconductance_btn.clicked.connect(apply_transconductance)
@pyqtSlot(float)
def update_transconductance_lbl(_):
current_transconductance = siEval(f"{self.cfg_pd_mon_form.resulting_pd_transconductance_reading.text()} {self.cfg_pd_mon_form.resulting_pd_transconductance_lbl.unit}")
responsitivity = siEval(f"{self.cfg_pd_mon_form.cfg_responsitivity_spinbox.value()} {self.cfg_pd_mon_form.cfg_responsitivity_spinbox.unit}")
pwr_limit = siEval(f"{self.cfg_pd_mon_form.settable_pwr_range_display_lbl.text().replace("0 - ", "")} {self.cfg_pd_mon_form.cfg_pwr_limit_spinbox.unit}")
new_transconductance = self.cfg_pd_mon_form.cfg_pd_fin_gain_spinbox.value() / siEval(f"{self.cfg_pd_mon_form.cfg_pd_fb_resistance_spinbox.value()} {self.cfg_pd_mon_form.cfg_pd_fb_resistance_spinbox.unit}")
current_range = new_transconductance * pwr_limit * responsitivity / board_transconductance
self.cfg_pd_mon_form.resulting_pd_transconductance_value.setText(f"{siConvert(new_transconductance, self.cfg_pd_mon_form.resulting_pd_transconductance_lbl.unit)}")
self.cfg_pd_mon_form.allowed_photodiode_current_range_value.setText(f"0 - {siConvert(current_range, self.cfg_pd_mon_form.allowed_photodiode_current_range_lbl.unit)}")
self.cfg_pd_mon_form.cfg_pd_fin_gain_spinbox.valueChanged.connect(update_transconductance_lbl)
self.cfg_pd_mon_form.cfg_pd_fb_resistance_spinbox.valueChanged.connect(update_transconductance_lbl)
def _set_up_adc_filter_form(self):
@pyqtSlot(bool)
+292 -12
View File
@@ -6,20 +6,20 @@
<rect>
<x>0</x>
<y>0</y>
<width>500</width>
<height>520</height>
<width>660</width>
<height>795</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>500</width>
<height>520</height>
<width>660</width>
<height>795</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>500</width>
<height>520</height>
<width>660</width>
<height>795</height>
</size>
</property>
<property name="windowTitle">
@@ -30,11 +30,11 @@
<rect>
<x>10</x>
<y>10</y>
<width>481</width>
<height>500</height>
<width>641</width>
<height>772</height>
</rect>
</property>
<layout class="QVBoxLayout" name="cfg_pd_mon_form_layout" stretch="0,2,2,2,2,2,1">
<layout class="QVBoxLayout" name="cfg_pd_mon_form_layout" stretch="3,2,2,3,2,2,2,1">
<item>
<widget class="QLabel" name="title_lbl">
<property name="font">
@@ -102,6 +102,286 @@
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="cfg_pd_transconductance_layout_2">
<item>
<widget class="QLabel" name="cfg_pd_transconductance_lbl_2">
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string> Step 3: (Optional) Configure Transimpedance Amplifier Circuit Parameters</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6" stretch="1,12">
<item>
<spacer name="horizontalSpacer_13">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="cfg_pd_transconductance_lbl">
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>Leave them unchanged if the TIA Circuit is NOT Modified</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4" stretch="5,2,2">
<item>
<spacer name="horizontalSpacer_10">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string> Values</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_8">
<property name="text">
<string>Current Settings</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="cfg_pd_fin_gain_layout" stretch="5,2,2">
<item>
<widget class="QLabel" name="cfg_pd_fin_gain_lbl">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>TIA Final Stage Gain:</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="cfg_pd_fin_gain_spinbox">
<property name="decimals">
<number>8</number>
</property>
<property name="maximum">
<double>1.000000000000000</double>
</property>
<property name="singleStep">
<double>0.001000000000000</double>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_11">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="pd_fb_resistance_layout" stretch="5,2,2">
<item>
<widget class="QLabel" name="cfg_pd_fb_resistance_lbl">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>TIA Feedback Resistance:</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="cfg_pd_fb_resistance_spinbox">
<property name="decimals">
<number>4</number>
</property>
<property name="minimum">
<double>0.000100000000000</double>
</property>
<property name="maximum">
<double>1000000.000000000000000</double>
</property>
<property name="singleStep">
<double>0.001000000000000</double>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_12">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="resulting_pd_transconductance_layout" stretch="5,2,2">
<property name="spacing">
<number>12</number>
</property>
<item>
<widget class="QLabel" name="resulting_pd_transconductance_lbl">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Resulting TIA Transconductance:</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="resulting_pd_transconductance_value">
<property name="text">
<string>0.0000</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="resulting_pd_transconductance_reading">
<property name="text">
<string>0.0000</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="allowed_photodiode_current_range_layout" stretch="5,2,2">
<property name="spacing">
<number>12</number>
</property>
<item>
<widget class="QLabel" name="allowed_photodiode_current_range_lbl">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Allowed Photodiode Current Range:</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="allowed_photodiode_current_range_value">
<property name="minimumSize">
<size>
<width>0</width>
<height>28</height>
</size>
</property>
<property name="text">
<string>(PD Current Range)</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="allowed_photodiode_current_range_reading">
<property name="minimumSize">
<size>
<width>0</width>
<height>28</height>
</size>
</property>
<property name="text">
<string>(PD Current Range)</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="apply_pd_transconductance_layout_2" stretch="5,4">
<item>
<spacer name="horizontalSpacer_9">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="apply_pd_transconductance_btn">
<property name="text">
<string>Apply</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="cfg_pd_params_layout">
<item>
@@ -112,7 +392,7 @@
</font>
</property>
<property name="text">
<string> Step 3: Configure Photodiode Parameters</string>
<string> Step 4: Configure Photodiode Parameters</string>
</property>
</widget>
</item>
@@ -271,7 +551,7 @@
</font>
</property>
<property name="text">
<string> Step 4: Configure Laser Diode Power Limit</string>
<string> Step 5: Configure Laser Diode Power Limit</string>
</property>
</widget>
</item>
@@ -423,7 +703,7 @@
</font>
</property>
<property name="text">
<string> Step 5: Turn On Laser Power</string>
<string> Step 6: Turn On Laser Power</string>
</property>
</widget>
</item>