Compare commits

..

13 Commits

Author SHA1 Message Date
atse 9806774382 Finish GUI 2024-04-24 12:42:29 +08:00
atse dc44f0e70c Remove unused as clause 2024-04-24 12:42:29 +08:00
Egor Savkin bae5d17d0c Add paramtree view, without updates
Signed-off-by: Egor Savkin <es@m-labs.hk>

Fix signal blocker argument -atse
2024-04-24 12:42:29 +08:00
atse fa558946c8 Fix bugs, grammar, text, and refactor into class 2024-04-24 12:42:29 +08:00
atse 7eb59828ae Change title 2024-04-24 12:42:29 +08:00
atse 8b97593bcd Stop polling drift
Just waiting for the update_s doesn't take into account the time to
execute update_params, and causes time drift.
2024-04-24 12:42:29 +08:00
atse 0349ba8767 Remove unused 'as' clause 2024-04-24 12:42:29 +08:00
atse a538dba73f Update docs 2024-04-24 12:42:29 +08:00
atse ab306d120c Finish moving over to qasync
Also:

* Add aioclient

The old client is synchronous and blocking, and the only way to achieve
true asynchronous IO is to create a new client that interfaces with
asyncio.

* Finish Nix Flake description and make the GUI available for `nix run`
2024-04-24 12:42:29 +08:00
Egor Savkin 949a95a116 Try move from Qthreads to qasync
Signed-off-by: Egor Savkin <es@m-labs.hk>
2024-04-24 12:42:29 +08:00
Egor Savkin 9d370242b1 Create client watcher, that would poll Thermostat for config
Signed-off-by: Egor Savkin <es@m-labs.hk>
2024-04-24 12:42:29 +08:00
Egor Savkin af116a4177 Create basic GUI, that would connect and control thermostat's fan
Signed-off-by: Egor Savkin <es@m-labs.hk>
2024-04-24 12:42:29 +08:00
topquark12 26469ba8fb add autotune 2024-04-24 12:42:29 +08:00
1 changed files with 24 additions and 1 deletions

View File

@ -17,6 +17,7 @@ class PIDAutotuneState(Enum):
STATE_RELAY_STEP_DOWN = 'relay step down'
STATE_SUCCEEDED = 'succeeded'
STATE_FAILED = 'failed'
STATE_READY = 'ready'
class PIDAutotune:
@ -56,6 +57,20 @@ class PIDAutotune:
self._Ku = 0
self._Pu = 0
def setParam(self, target, step, noiseband, sampletime, lookback):
self._setpoint = target
self._outputstep = step
self._out_max = step
self._out_min = -step
self._noiseband = noiseband
self._inputs = deque(maxlen=round(lookback / sampletime))
def setReady(self):
self._state = PIDAutotuneState.STATE_READY
def setOff(self):
self._state = PIDAutotuneState.STATE_OFF
def state(self):
"""Get the current state."""
return self._state
@ -81,6 +96,13 @@ class PIDAutotune:
kd = divisors[2] * self._Ku * self._Pu
return PIDAutotune.PIDParams(kp, ki, kd)
def get_tec_pid (self):
divisors = self._tuning_rules["tyreus-luyben"]
kp = self._Ku * divisors[0]
ki = divisors[1] * self._Ku / self._Pu
kd = divisors[2] * self._Ku * self._Pu
return kp, ki, kd
def run(self, input_val, time_input):
"""To autotune a system, this method must be called periodically.
@ -95,7 +117,8 @@ class PIDAutotune:
if (self._state == PIDAutotuneState.STATE_OFF
or self._state == PIDAutotuneState.STATE_SUCCEEDED
or self._state == PIDAutotuneState.STATE_FAILED):
or self._state == PIDAutotuneState.STATE_FAILED
or self._state == PIDAutotuneState.STATE_READY):
self._state = PIDAutotuneState.STATE_RELAY_STEP_UP
self._last_run_timestamp = now