forked from M-Labs/thermostat
Show all current values in mA
Since the max and min is known as (-3A, 3A) on the thermostat TEC ports, there is no need to use other SI prefix units.
This commit is contained in:
parent
5af14c26ea
commit
2e8b26eb60
@ -218,20 +218,20 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
"""Thermostat parameters that are particular to a channel"""
|
||||
THERMOSTAT_PARAMETERS = [[
|
||||
{'name': 'Temperature', 'type': 'float', 'siPrefix': True, 'suffix': '°C', 'decimals': 6, 'readonly': True},
|
||||
{'name': 'Current through TEC', 'type': 'float', 'siPrefix': True, 'suffix': 'A', 'decimals': 4, 'readonly': True},
|
||||
{'name': 'Current through TEC', 'type': 'float', 'suffix': 'mA', 'decimals': 6, 'readonly': True},
|
||||
{'name': 'Output Config', 'expanded': True, 'type': 'group', 'children': [
|
||||
{'name': 'Control Method', 'type': 'mutex', 'limits': {'Constant Current': False, 'Temperature PID': True},
|
||||
'param': [('pwm', ch, 'pid')], 'children': [
|
||||
{'name': 'Set Current', 'type': 'float', 'value': 0, 'step': 0.1, 'limits': (-3, 3), 'siPrefix': True, 'triggerOnShow': True,
|
||||
'suffix': 'A', 'param': [('pwm', ch, 'i_set')]},
|
||||
{'name': 'Set Current', 'type': 'float', 'value': 0, 'step': 100, 'limits': (-3000, 3000), 'triggerOnShow': True,
|
||||
'decimals': 6, 'suffix': 'mA', 'param': [('pwm', ch, 'i_set')]},
|
||||
{'name': 'Set Temperature', 'type': 'float', 'value': 25, 'step': 0.1, 'limits': (-273, 300), 'siPrefix': True,
|
||||
'suffix': '°C', 'param': [('pid', ch, 'target')]},
|
||||
]},
|
||||
{'name': 'Limits', 'expanded': False, 'type': 'group', 'children': [
|
||||
{'name': 'Max Current', 'type': 'float', 'value': 0, 'step': 0.1, 'limits': (0, 3), 'siPrefix': True,
|
||||
'suffix': 'A', 'param': [('pwm', ch, 'max_i_pos'), ('pid', ch, 'output_max')]},
|
||||
{'name': 'Min Current', 'type': 'float', 'value': 0, 'step': 0.1, 'limits': (-3, 0), 'siPrefix': True,
|
||||
'suffix': 'A', 'param': [('pwm', ch, 'max_i_neg', '-'), ('pid', ch, 'output_min')]},
|
||||
{'name': 'Max Current', 'type': 'float', 'value': 0, 'step': 100, 'decimals': 6, 'limits': (0, 3000),
|
||||
'suffix': 'mA', 'param': [('pwm', ch, 'max_i_pos'), ('pid', ch, 'output_max')]},
|
||||
{'name': 'Min Current', 'type': 'float', 'value': 0, 'step': 100, 'decimals': 6, 'limits': (-3000, 0),
|
||||
'suffix': 'mA', 'param': [('pwm', ch, 'max_i_neg', '-'), ('pid', ch, 'output_min')]},
|
||||
{'name': 'Max Absolute Voltage', 'type': 'float', 'value': 0, 'step': 0.1, 'limits': (0, 5), 'siPrefix': True,
|
||||
'suffix': 'V', 'param': [('pwm', ch, 'max_v')]},
|
||||
]}
|
||||
@ -253,7 +253,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
{'name': 'Kd', 'type': 'float', 'step': 0.1, 'suffix': 's', 'param': [('pid', ch, 'kd')]},
|
||||
{'name': 'PID Auto Tune', 'expanded': False, 'type': 'group', 'children': [
|
||||
{'name': 'Target Temperature', 'type': 'float', 'value': 20, 'step': 0.1, 'siPrefix': True, 'suffix': '°C'},
|
||||
{'name': 'Test Current', 'type': 'float', 'value': 1, 'step': 0.1, 'limits': (-3, 3), 'siPrefix': True, 'suffix': 'A'},
|
||||
{'name': 'Test Current', 'type': 'float', 'value': 1000, 'decimals': 6, 'step': 100, 'limits': (-3000, 3000), 'suffix': 'mA'},
|
||||
{'name': 'Temperature Swing', 'type': 'float', 'value': 1.5, 'step': 0.1, 'siPrefix': True, 'prefix': '±', 'suffix': '°C'},
|
||||
{'name': 'Run', 'type': 'action', 'tip': 'Run'},
|
||||
]},
|
||||
@ -671,9 +671,14 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
if inner_param.name() == 'Control Method' and not data:
|
||||
return
|
||||
for thermostat_param in inner_param.opts["param"]:
|
||||
if len(thermostat_param) == 4: # The only instance is for negative data
|
||||
set_param_args = (*thermostat_param[:3], -data)
|
||||
elif inner_param.name() == 'Postfilter Rate':
|
||||
if 'Current' in inner_param.name():
|
||||
data /= 1000 # Given in mA
|
||||
if len(thermostat_param) == 4:
|
||||
if thermostat_param[3] == '-':
|
||||
data = -data
|
||||
thermostat_param = thermostat_param[:3]
|
||||
|
||||
if inner_param.name() == 'Postfilter Rate':
|
||||
set_param_args = (*thermostat_param, *data)
|
||||
elif inner_param.name() == 'Control Method':
|
||||
set_param_args = thermostat_param
|
||||
@ -716,7 +721,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
case PIDAutotuneState.STATE_OFF:
|
||||
self.autotuners[ch].setParam(
|
||||
param.parent().child('Target Temperature').value(),
|
||||
param.parent().child('Test Current').value(),
|
||||
param.parent().child('Test Current').value() / 1000,
|
||||
param.parent().child('Temperature Swing').value(),
|
||||
self.report_refresh_spin.value(),
|
||||
3)
|
||||
@ -798,10 +803,10 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
with QSignalBlocker(self.params[channel]):
|
||||
self.params[channel].child("Output Config", "Control Method").setValue(settings["pid_engaged"])
|
||||
self.channel_graphs[channel].t_line.setVisible(settings["pid_engaged"])
|
||||
self.params[channel].child("Output Config", "Control Method", "Set Current").setValue(settings["i_set"])
|
||||
self.params[channel].child("Output Config", "Control Method", "Set Current").setValue(settings["i_set"] * 1000)
|
||||
if settings['temperature'] is not None and settings['tec_i'] is not None:
|
||||
self.params[channel].child("Temperature").setValue(settings['temperature'])
|
||||
self.params[channel].child("Current through TEC").setValue(settings['tec_i'])
|
||||
self.params[channel].child("Current through TEC").setValue(settings['tec_i'] * 1000)
|
||||
|
||||
@pyqtSlot(list)
|
||||
def update_thermistor(self, sh_data):
|
||||
@ -820,8 +825,8 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
||||
channel = pwm_params["channel"]
|
||||
with QSignalBlocker(self.params[channel]):
|
||||
self.params[channel].child("Output Config", "Limits", "Max Absolute Voltage").setValue(pwm_params["max_v"]["value"])
|
||||
self.params[channel].child("Output Config", "Limits", "Max Current").setValue(pwm_params["max_i_pos"]["value"])
|
||||
self.params[channel].child("Output Config", "Limits", "Min Current").setValue(-pwm_params["max_i_neg"]["value"])
|
||||
self.params[channel].child("Output Config", "Limits", "Max Current").setValue(pwm_params["max_i_pos"]["value"] * 1000)
|
||||
self.params[channel].child("Output Config", "Limits", "Min Current").setValue(-pwm_params["max_i_neg"]["value"] * 1000)
|
||||
|
||||
for limit in "max_i_pos", "max_i_neg", "max_v":
|
||||
if pwm_params[limit]["value"] == 0.0:
|
||||
|
Loading…
Reference in New Issue
Block a user