Compare commits

..

21 Commits

Author SHA1 Message Date
5574559ac6 ctrl_panel: Reformat SpinBox text always if valid
The parameter SpinBoxes previously would only update if the interpreted
value was changed, missing cases where the text would have changed but
the value stays the same, e.g. removing trailing decimal zeros.
2024-08-16 14:05:44 +08:00
e160a6f514 ctrl_panel: Move postfilter into its own group 2024-08-16 14:05:44 +08:00
ae9bd1a859 ctrl_panel: Use new locking mechanism from Kirdy 2024-08-16 14:05:44 +08:00
0f768f30e8 ctrl_panel: Fix editing fields with unit "°C"
A faulty regular expression within PyQtGraph causes any Parameter with a
suffix that doesn't begin with an alphanumeric character (as matched
with \w) to act abnormally. For instance, entering "100 °C" into the
input boxes gets interpreted as 10 °C.

Patch the FLOAT_REGEX in PyQtGraph to simply match for any character in
the suffix group.
2024-08-16 14:05:44 +08:00
07095d77c8 ctrl_panel: More appropriate steps and fixes 2024-08-16 14:05:44 +08:00
4a7d7abf3a ctrl_panel: Put plotted values into readings group
For more intuitiveness to first-time users
2024-08-16 14:05:44 +08:00
b9cf60f2df ctrl_panel: Fix max_v to only have unit "V"
As most users do not need to limit TEC voltage with accuracy of less
than 1mV.
2024-08-16 14:05:44 +08:00
3ffa939970 ctrl_panel: Bold "Control Method" text 2024-08-16 14:05:44 +08:00
87ba107ce5 ctrl_panel: Indicate active parameter of control
Instead of hiding the inactive control parameter, underline and bold the
active control parameter title, e.g. "Set Current" when control method
is constant current, and "Setpoint" when it is temperature PID.
2024-08-16 14:05:44 +08:00
319fb9cf9e ctrl_panel: Limits fixes
* PID Autotune test current should be positive

* max_v should be 4 V not 5 V

* r0 should not be negative
2024-08-16 14:05:44 +08:00
f7c266539b ctrl_panel: Code cleanup
* Remove unnecessary duplication of `THERMOSTAT_PARAMETERS`

* i -> ch

* Separate ParameterTree and Parameter initiation

* Remove extra "channel" option to root parameters, as the "value"
option is already the channel number
2024-08-16 14:05:44 +08:00
df9715b3ef ctrl_panel: PID Auto Tune -> PID Autotune 2024-08-16 14:05:44 +08:00
82279f15da ctrl_panel: Stop crushing spinboxes
It might not be the case on some themes, but on the default Qt theme the
spinbox are a bit too short for the containing numbers. See
https://github.com/pyqtgraph/pyqtgraph/issues/701.
2024-08-16 14:05:44 +08:00
fff42bfa4c ctrl_panel: Pin down units for editable fields
User input always has the same order of magnitude, so allowing multiple
siPrefixes would be unwanted complexity. Don't allow them to be changed.

The Parameter option "noUnitEditing" is added to do so by the following
measures:

1. Don't validate for changed siPrefix (if pinned) and suffix, which
avoids their removal.

2. Avoid getting the cursor embedded within the unit.
2024-08-16 14:05:44 +08:00
d3b93b1263 ctrl_panel: Remove need for "mA" hack
Remove all instances of mA scaling scattered all around the code and
specify it in the parameter tree with a single source of truth.

Done by adding the option "pinSiPrefix" for all Parameters of type `int`
or `float`, and using it for current Parameters with unit "mA".
2024-08-16 14:05:44 +08:00
4309f9044c ctrl_panel: Appropriate units for measured current
Allow the readonly display of current to vary its SI prefix in the unit,
since as a display entry it won't have the unit adjustment problem.
2024-08-13 12:38:32 +08:00
81418d0a55 ctrl_panel: Improve postfilter description 2024-08-13 12:38:32 +08:00
7fb933faa2 ctrl_panel: Add and improve tooltips and titles
For users' better understanding of what the parameters do
2024-08-13 12:38:29 +08:00
437c9cec34 ctrl_panel: Refer to Parameters by concise names
For displayed string representations, use the `title` key, or for
`ListParameter`s, use the dictionary mapping method instead.
2024-07-19 15:49:19 +08:00
7829ce6adf ctrl_panel: Config -> Settings 2024-07-19 15:49:16 +08:00
0f14212622 Format JSON 2024-07-19 15:48:57 +08:00
2 changed files with 122 additions and 87 deletions

View File

@ -42,10 +42,14 @@
"Constant Current": "constant_current",
"Temperature PID": "temperature_pid"
},
"thermostat:set_param": {
"topic": "pwm",
"field": "pid"
},
"activaters": [
null,
[
"pwm",
"ch",
"pid"
]
],
"tip": "Select control method of output",
"children": [
{
@ -64,10 +68,11 @@
"siPrefix": true,
"noUnitEditing": true,
"compactHeight": false,
"thermostat:set_param": {
"topic": "pwm",
"field": "i_set"
},
"param": [
"pwm",
"ch",
"i_set"
],
"tip": "The set current through TEC",
"lock": false
},
@ -85,10 +90,11 @@
"suffix": "°C",
"noUnitEditing": true,
"compactHeight": false,
"thermostat:set_param": {
"topic": "pid",
"field": "target"
},
"param": [
"pid",
"ch",
"target"
],
"tip": "The temperature setpoint of the TEC",
"lock": false
}
@ -117,10 +123,11 @@
"suffix": "A",
"noUnitEditing": true,
"compactHeight": false,
"thermostat:set_param": {
"topic": "pwm",
"field": "max_i_pos"
},
"param": [
"pwm",
"ch",
"max_i_pos"
],
"tip": "The maximum cooling (+ve) current through the output pins",
"lock": false
},
@ -140,10 +147,11 @@
2
],
"compactHeight": false,
"thermostat:set_param": {
"topic": "pwm",
"field": "max_i_neg"
},
"param": [
"pwm",
"ch",
"max_i_neg"
],
"tip": "The maximum heating (-ve) current through the output pins",
"lock": false
},
@ -161,10 +169,11 @@
"suffix": "V",
"noUnitEditing": true,
"compactHeight": false,
"thermostat:set_param": {
"topic": "pwm",
"field": "max_v"
},
"param": [
"pwm",
"ch",
"max_v"
],
"tip": "The maximum voltage (in both directions) across the output pins",
"lock": false
}
@ -193,10 +202,11 @@
"suffix": "°C",
"noUnitEditing": true,
"compactHeight": false,
"thermostat:set_param": {
"topic": "s-h",
"field": "t0"
},
"param": [
"s-h",
"ch",
"t0"
],
"tip": "The base temperature",
"lock": false
},
@ -212,10 +222,11 @@
"suffix": "Ω",
"noUnitEditing": true,
"compactHeight": false,
"thermostat:set_param": {
"topic": "s-h",
"field": "r0"
},
"param": [
"s-h",
"ch",
"r0"
],
"tip": "The resistance of the thermistor at base temperature T₀",
"lock": false
},
@ -229,10 +240,11 @@
"noUnitEditing": true,
"decimals": 4,
"compactHeight": false,
"thermostat:set_param": {
"topic": "s-h",
"field": "b"
},
"param": [
"s-h",
"ch",
"b"
],
"tip": "The Beta Parameter",
"lock": false
}
@ -249,10 +261,11 @@
"title": "50/60 Hz Rejection Filter",
"type": "list",
"value": 16.67,
"thermostat:set_param": {
"topic": "postfilter",
"field": "rate"
},
"param": [
"postfilter",
"ch",
"rate"
],
"limits": {
"16.67 SPS": 16.67,
"20 SPS": 20.0,
@ -278,10 +291,11 @@
"type": "float",
"step": 0.1,
"compactHeight": false,
"thermostat:set_param": {
"topic": "pid",
"field": "kp"
},
"param": [
"pid",
"ch",
"kp"
],
"tip": "Proportional gain",
"lock": false
},
@ -293,10 +307,11 @@
"suffix": "Hz",
"noUnitEditing": true,
"compactHeight": false,
"thermostat:set_param": {
"topic": "pid",
"field": "ki"
},
"param": [
"pid",
"ch",
"ki"
],
"tip": "Integral gain",
"lock": false
},
@ -308,10 +323,11 @@
"suffix": "s",
"noUnitEditing": true,
"compactHeight": false,
"thermostat:set_param": {
"topic": "pid",
"field": "kd"
},
"param": [
"pid",
"ch",
"kd"
],
"tip": "Differential gain",
"lock": false
},
@ -337,10 +353,11 @@
"suffix": "A",
"noUnitEditing": true,
"compactHeight": false,
"thermostat:set_param": {
"topic": "pid",
"field": "output_min"
},
"param": [
"pid",
"ch",
"output_min"
],
"tip": "Minimum PID output",
"lock": false
},
@ -359,10 +376,11 @@
"suffix": "A",
"noUnitEditing": true,
"compactHeight": false,
"thermostat:set_param": {
"topic": "pid",
"field": "output_max"
},
"param": [
"pid",
"ch",
"output_max"
],
"tip": "Maximum PID output",
"lock": false
}
@ -385,7 +403,10 @@
"suffix": "°C",
"noUnitEditing": true,
"compactHeight": false,
"pid_autotune": "target_temp",
"pid_autotune": [
"target_temp",
"ch"
],
"tip": "The target temperature to autotune for"
},
{
@ -404,7 +425,10 @@
"suffix": "A",
"noUnitEditing": true,
"compactHeight": false,
"pid_autotune": "test_current",
"pid_autotune": [
"test_current",
"ch"
],
"tip": "The testing current when autotuning"
},
{
@ -417,7 +441,10 @@
"suffix": "K",
"noUnitEditing": true,
"compactHeight": false,
"pid_autotune": "temp_swing",
"pid_autotune": [
"temp_swing",
"ch"
],
"tip": "The temperature swing around the target"
},
{
@ -430,7 +457,10 @@
"noUnitEditing": true,
"suffix": "s",
"compactHeight": false,
"pid_autotune": "lookback",
"pid_autotune": [
"lookback",
"ch"
],
"tip": "Amount of time referenced for tuning"
},
{

View File

@ -266,32 +266,37 @@ class MainWindow(QtWidgets.QMainWindow):
for inner_param, change, data in changes:
if change == "value":
new_value = data
if "thermostat:set_param" in inner_param.opts:
thermostat_param = inner_param.opts["thermostat:set_param"]
if inner_param.opts.get("param", None) is not None:
thermostat_param = inner_param.opts["param"]
if thermostat_param[1] == "ch":
thermostat_param[1] = ch
# Handle thermostat command irregularities
match inner_param.name(), new_value:
case "rate", None:
thermostat_param = thermostat_param.copy()
thermostat_param["field"] = "off"
new_value = ""
case "control_method", "constant_current":
thermostat_param = thermostat_param.copy()
thermostat_param["field"] = "i_set"
new_value = inner_param.child("i_set").value()
case "control_method", "temperature_pid":
new_value = ""
if inner_param.name() == "rate" and data is None:
set_param_args = (*thermostat_param[:2], "off")
else:
set_param_args = (*thermostat_param, data)
param.child(*param.childPath(inner_param)).setOpts(lock=True)
await self.client.set_param(*set_param_args)
param.child(*param.childPath(inner_param)).setOpts(lock=False)
inner_param.setOpts(lock=True)
await self.client.set_param(
channel=ch, value=new_value, **thermostat_param
)
inner_param.setOpts(lock=False)
if inner_param.opts.get("pid_autotune", None) is not None:
autotuner_param = inner_param.opts["pid_autotune"][0]
if inner_param.opts["pid_autotune"][1] != "ch":
ch = inner_param.opts["pid_autotune"][1]
self.autotuners.set_params(autotuner_param, ch, data)
if "pid_autotune" in inner_param.opts:
auto_tuner_param = inner_param.opts["pid_autotune"]
self.autotuners.set_params(auto_tuner_param, ch, new_value)
if inner_param.opts.get("activaters", None) is not None:
activater = inner_param.opts["activaters"][
inner_param.reverse[0].index(data) # ListParameter.reverse = list of codename values
]
if activater is not None:
if activater[1] == "ch":
activater[1] = ch
await self.client.set_param(*activater)
else:
await self.client.set_param(
"pwm", ch, "i_set", inner_param.child("i_set").value()
)
@asyncSlot()
async def pid_autotune_request(self, ch=0):