forked from M-Labs/thermostat
abs_max_tec_i -> max_abs_i_measured
This commit is contained in:
parent
370c7d8ad4
commit
9de872f469
@ -280,10 +280,10 @@ The thermostat implements a PID control loop for each of the TEC channels, more
|
||||
## Fan control
|
||||
|
||||
Fan control commands are available for thermostat revisions with an integrated fan system:
|
||||
1. `fan` - show fan stats: `fan_pwm`, `abs_max_tec_i`, `auto_mode`, `k_a`, `k_b`, `k_c`.
|
||||
1. `fan` - show fan stats: `fan_pwm`, `max_abs_i_measured`, `auto_mode`, `k_a`, `k_b`, `k_c`.
|
||||
2. `fan auto` - enable auto speed controller mode, where fan speed is controlled by the fan curve `fcurve`.
|
||||
3. `fan <value>` - set the fan power with the value from `1` to `100` and disable auto mode. There is no way to completely disable the fan.
|
||||
Please note that power doesn't correlate with the actual speed linearly.
|
||||
4. `fcurve <a> <b> <c>` - set coefficients of the controlling curve `a*x^2 + b*x + c`, where `x` is `abs_max_tec_i/MAX_TEC_I`, a normalized value in range [0,1],
|
||||
4. `fcurve <a> <b> <c>` - set coefficients of the controlling curve `a*x^2 + b*x + c`, where `x` is `max_abs_i_measured/MAX_TEC_I`, a normalized value in range [0,1],
|
||||
i.e. the (linear) proportion of current output capacity used, on the channel with the largest current flow. The controlling curve is also clamped to [0,1].
|
||||
5. `fcurve default` - restore fan curve coefficients to defaults: `a = 1.0, b = 0.0, c = 0.0`.
|
||||
|
@ -576,8 +576,8 @@ impl Channels {
|
||||
serde_json_core::to_vec(&summaries)
|
||||
}
|
||||
|
||||
pub fn current_abs_max_tec_i(&mut self) -> ElectricCurrent {
|
||||
max_by(self.get_tec_i(0).abs(), self.get_tec_i(1).abs(), |a, b| {
|
||||
pub fn max_abs_i_measured(&mut self) -> ElectricCurrent {
|
||||
a.partial_cmp(b).unwrap_or(core::cmp::Ordering::Equal)
|
||||
})
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ pub struct FanCtrl {
|
||||
k_a: f32,
|
||||
k_b: f32,
|
||||
k_c: f32,
|
||||
abs_max_tec_i: f32,
|
||||
max_abs_i_measured: f32,
|
||||
hw_settings: HWSettings,
|
||||
}
|
||||
|
||||
@ -34,7 +34,7 @@ impl FanCtrl {
|
||||
k_a: hw_settings.fan_k_a,
|
||||
k_b: hw_settings.fan_k_b,
|
||||
k_c: hw_settings.fan_k_c,
|
||||
abs_max_tec_i: 0f32,
|
||||
max_abs_i_measured: 0f32,
|
||||
hw_settings,
|
||||
};
|
||||
if fan_ctrl.fan_auto {
|
||||
@ -43,10 +43,10 @@ impl FanCtrl {
|
||||
fan_ctrl
|
||||
}
|
||||
|
||||
pub fn cycle(&mut self, abs_max_tec_i: ElectricCurrent) {
|
||||
self.abs_max_tec_i = abs_max_tec_i.get::<ampere>() as f32;
|
||||
pub fn cycle(&mut self, max_abs_i_measured: ElectricCurrent) {
|
||||
self.max_abs_i_measured = max_abs_i_measured.get::<ampere>() as f32;
|
||||
if self.fan_auto && self.hw_settings.fan_available {
|
||||
let scaled_current = self.abs_max_tec_i / MAX_TEC_I.get::<ampere>() as f32;
|
||||
let scaled_current = self.max_abs_i_measured / MAX_TEC_I.get::<ampere>() as f32;
|
||||
// do not limit upper bound, as it will be limited in the set_pwm()
|
||||
let pwm = (MAX_USER_FAN_PWM
|
||||
* (scaled_current * (scaled_current * self.k_a + self.k_b) + self.k_c))
|
||||
@ -59,7 +59,7 @@ impl FanCtrl {
|
||||
if self.hw_settings.fan_available {
|
||||
let summary = FanSummary {
|
||||
fan_pwm: self.get_pwm(),
|
||||
abs_max_tec_i: self.abs_max_tec_i,
|
||||
abs_max_tec_i: self.max_abs_i_measured,
|
||||
auto_mode: self.fan_auto,
|
||||
k_a: self.k_a,
|
||||
k_b: self.k_b,
|
||||
|
@ -196,7 +196,7 @@ fn main() -> ! {
|
||||
server.for_each(|_, session| session.set_report_pending(channel.into()));
|
||||
}
|
||||
|
||||
fan_ctrl.cycle(channels.current_abs_max_tec_i());
|
||||
fan_ctrl.cycle(channels.max_abs_i_measured());
|
||||
|
||||
if channels.pid_engaged() {
|
||||
leds.g3.on();
|
||||
|
Loading…
Reference in New Issue
Block a user