Commit Graph

232 Commits

Author SHA1 Message Date
Egor Savkin afdab2f025 Make hwrev to be settings provider
Signed-off-by: Egor Savkin <es@m-labs.hk>
2023-03-22 17:14:28 +08:00
Egor Savkin 2c9436a0b3 Move HWRev to separate file, address PR comments, emit warning on the using PWM on unsupported fans
Signed-off-by: Egor Savkin <es@m-labs.hk>
2023-02-16 13:37:17 +08:00
Egor Savkin 83d5c28a67 Disable fan auto mode by default for Thermostat v2.2
Signed-off-by: Egor Savkin <es@m-labs.hk>
2023-02-07 12:04:59 +08:00
Egor Savkin 069e178966 Change PWM freq to 25kHz
Signed-off-by: Egor Savkin <es@m-labs.hk>
2023-02-02 10:52:22 +08:00
Egor Savkin e6d928ef4e Fix PR comments
Signed-off-by: Egor Savkin <es@m-labs.hk>
2023-01-10 15:13:37 +08:00
Egor Savkin a645bfb6e8 Remove all tacho/status related logic
Signed-off-by: Egor Savkin <es@m-labs.hk>
2023-01-05 15:30:07 +08:00
Egor Savkin 33070abd81 Make commands more consistent
Signed-off-by: Egor Savkin <es@m-labs.hk>
2023-01-05 13:04:21 +08:00
Egor Savkin 21fc244eac Fan status via quadratic regression
* statuses: detect slow fan via quadratic regression and halts (hard stops) with constant threshold
* remove unsafe channels' copy and make FanCtrl own the channels
* scale fan values so that they would fit 0.05-1.0 PWM at all times
* rename fan-restore to fcurve-restore
* style, names and docs adjustments

Signed-off-by: Egor Savkin <es@m-labs.hk>
2023-01-05 11:57:21 +08:00
Egor Savkin 630635486e Polish minor issues
Signed-off-by: Egor Savkin <es@m-labs.hk>
2022-12-23 13:23:18 +08:00
Egor Savkin ea2eb51b27 Add fan warnings
Signed-off-by: Egor Savkin <es@m-labs.hk>
2022-12-23 13:13:33 +08:00
Egor Savkin 58650d37f1 Refactor and coefficients implemented
Move all the fan logic to the separate file. Add controls for controlling curve.

Signed-off-by: Egor Savkin <es@m-labs.hk>
2022-12-22 17:28:08 +08:00
Egor Savkin 66143d2373 Implemented auto fan control
Signed-off-by: Egor Savkin <es@m-labs.hk>
2022-12-21 14:59:49 +08:00
Egor Savkin 583d06a78b Make fan cmd show the stats
Signed-off-by: Egor Savkin <es@m-labs.hk>
2022-12-20 12:58:00 +08:00
Egor Savkin d117c784d9 Draft hw rev support and fan command
Signed-off-by: Egor Savkin <es@m-labs.hk>
2022-12-19 17:15:33 +08:00
Egor Savkin 4223f7a4ad Draft tacho support
Signed-off-by: Egor Savkin <es@m-labs.hk>
2022-12-15 16:47:52 +08:00
Egor Savkin 30350a3651 Draft support fan pwm settings
Signed-off-by: Egor Savkin <es@m-labs.hk>
2022-12-14 17:25:29 +08:00
mwojcik 1b2f2f3888 update code to use stm32f4xx-hal 0.10.1 API 2022-03-02 17:21:17 +08:00
topquark12 26ad2f0119 rewrite PID
Rewrite of PID according to https://hackmd.io/IACbwcOTSt6Adj3_F9bKuw PID implementation.

To migrate:
- TEC+/- pin polarity has to be reversed.
- Some saved settings might be wiped upon flashing of new firmware, back up settings before upgrade
- Min / Max integral parameters no longer exist
- kp, ki, kd will likely need to be retuned

The software has been tested on hardware with good temperature control stability.

Reviewed-on: M-Labs/thermostat#68
Co-authored-by: topquark12 <aw@m-labs.hk>
Co-committed-by: topquark12 <aw@m-labs.hk>
2022-02-24 20:16:47 +08:00
topquark12 e6a5c31db6 main.rs refactor to reduce length (#60)
Move command handling to command_handler.rs to shorten main.rs

Reviewed-on: M-Labs/thermostat#60
Co-authored-by: topquark12 <aw@m-labs.hk>
Co-committed-by: topquark12 <aw@m-labs.hk>
2021-06-07 10:07:05 +08:00
topquark12 a5d8661b10 main: fix handling of incomplete data received (#55)
Reviewed-on: M-Labs/thermostat#55
Co-Authored-By: topquark12 <aw@m-labs.hk>
Co-Committed-By: topquark12 <aw@m-labs.hk>
2021-01-29 16:18:07 +08:00
topquark12 7cb0ed70be Reset all TCP sockets before MCU reset (#53)
Co-Authored-By: topquark12 <aw@m-labs.hk>
Co-Committed-By: topquark12 <aw@m-labs.hk>
2021-01-26 17:45:14 +08:00
topquark12 16844a1dc1 dac: fix inconsistent current output behavior due to repeated sampling of noisy vref 2021-01-25 13:51:50 +08:00
Sebastien Bourdeauducq 8eb3cc4307 dfu: style 2021-01-18 16:59:13 +08:00
topquark12 f3661ac8e3 dfu: refactor 2021-01-18 16:45:01 +08:00
topquark12 c4e3be1d05 fix pid.rs test, exclude dfu from test 2021-01-16 11:04:24 +08:00
topquark12 cf3ace4d2d flash_store: get addresses from linker
Reviewed-on: M-Labs/thermostat#49
Co-Authored-By: topquark12 <aw@m-labs.hk>
Co-Committed-By: topquark12 <aw@m-labs.hk>
2021-01-13 17:30:12 +08:00
topquark12 f6802635a4 add command to reboot into DFU
Co-Authored-By: topquark12 <aw@m-labs.hk>
Co-Committed-By: topquark12 <aw@m-labs.hk>
2021-01-13 11:59:06 +08:00
topquark12 9e4d06fdbc clarify comment 2021-01-11 16:24:43 +08:00
topquark12 3433881d0f remove dead code 2021-01-11 14:10:50 +08:00
topquark12 193d54a0a6 pid: anti-windup when compliance voltage reached 2021-01-11 14:00:52 +08:00
topquark12 3067b356c5 channels: add methods to retrieve actual voltage and current of TEC 2021-01-08 16:18:20 +08:00
topquark12 3ba2cc9ddc channels: voltage measurement refalect actual voltage across TEC 2021-01-08 15:52:35 +08:00
topquark12 1539b624bd pid: more sensible default parameters 2021-01-08 11:31:33 +08:00
topquark12 5c84b7438b Integral rescaling 2021-01-08 11:25:01 +08:00
topquark12 cc0126636c report save success
save does not hang, it just did not report save success. Closes #33

Reviewed-on: M-Labs/thermostat#44
Co-Authored-By: topquark12 <aw@m-labs.hk>
Co-Committed-By: topquark12 <aw@m-labs.hk>
2021-01-07 18:01:43 +08:00
topquark12 e94601f54f pid: fix derivative calculation
Reviewed-on: M-Labs/thermostat#40
Co-Authored-By: topquark12 <aw@m-labs.hk>
Co-Committed-By: topquark12 <aw@m-labs.hk>
2020-12-29 17:09:03 +08:00
topquark12 8c9e12587f fix simulation math, provided simulation control loop is stable and passes test, reaching simulation cycle limit before settling fails test 2020-12-28 17:38:10 +08:00
topquark12 7c013ff4a4 PID fixes
Flipped error calculation method to correct behavior of kP and kI terms.

Added anti integral windup to integral handling.

Changed how the i and integral term is calculated, to prevent old kI settings from affecting the current i term calculation when kI is being tuned. Especially noticable when kI is set from a non-zero value to zero.
Co-Authored-By: topquark12 <aw@m-labs.hk>
Co-Committed-By: topquark12 <aw@m-labs.hk>
2020-12-26 11:47:21 +08:00
Sebastien Bourdeauducq 50a1b9f52d pid: partial -> proportional 2020-12-26 11:01:40 +08:00
Astro 9852b32646 command_parser, main: implement ShowCommand::Ipv4
Fixes Gitea issue #30
2020-12-20 20:44:10 +01:00
Astro 22b0c9fcad main: don't re- set_ipv4_config every tick 2020-12-20 20:43:20 +01:00
Astro e13ed37271 pid: fix tests 2020-12-20 20:24:24 +01:00
Astro b176fc2788 pid: doc parameters 2020-12-18 16:29:53 +01:00
Astro b717ac5495 pid: update default gain parameters 2020-12-18 16:27:47 +01:00
Astro e9e46b29cf pid: integrate time_delta to free gain parameters from sampling period
Fixes Gitea issue #22
2020-12-18 15:40:05 +01:00
Astro b7e6cdbec2 pytec: measure interval 2020-12-16 22:14:21 +01:00
Astro b2f455b2cf config: save/store pid_engaged
Fixes Gitea issue #17
2020-12-13 02:33:59 +01:00
Astro ecc00a6aeb init_log: delint 2020-12-13 02:24:29 +01:00
Astro 97813f917d flash_store: get to a working state 2020-12-13 01:17:03 +01:00
Astro 880a887c40 new flash-based ipv4 config with additional mask_len, gateway 2020-12-12 23:44:16 +01:00