Compare commits
3 Commits
b95b9dcefa
...
a76b8de994
Author | SHA1 | Date |
---|---|---|
linuswck | a76b8de994 | |
linuswck | 3410a271fd | |
linuswck | 8f38acd0f2 |
|
@ -213,13 +213,14 @@ impl Thermostat {
|
|||
}
|
||||
|
||||
pub fn power_up(&mut self) {
|
||||
self.max1968.power_up();
|
||||
if !self.max1968.is_powered_on() {
|
||||
self.max1968.power_up();
|
||||
self.pid_ctrl_ch0.reset_pid_state();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn power_down(&mut self) {
|
||||
self.max1968.power_down();
|
||||
self.pid_ctrl_ch0.reset_pid_state();
|
||||
self.set_i(ElectricCurrent::new::<ampere>(0.0));
|
||||
}
|
||||
|
||||
fn set_center_pt(&mut self, value: ElectricPotential) {
|
||||
|
@ -232,36 +233,39 @@ impl Thermostat {
|
|||
|
||||
pub fn set_i(&mut self, i_tec: ElectricCurrent) -> ElectricCurrent {
|
||||
let voltage = i_tec * 10.0 * R_SENSE + self.tec_settings.center_pt;
|
||||
let voltage = self.max1968.set_dac(voltage, self.max1968.dac_out_range);
|
||||
let _voltage = self.max1968.set_dac(voltage, self.max1968.dac_out_range);
|
||||
|
||||
self.tec_settings.i_set = (voltage - self.tec_settings.center_pt) / (10.0 * R_SENSE);
|
||||
self.tec_settings.i_set = i_tec;
|
||||
self.tec_settings.i_set
|
||||
}
|
||||
|
||||
pub fn set_max_v(&mut self, max_v: ElectricPotential) -> ElectricPotential {
|
||||
let duty = (max_v / TecSettings::MAX_V_DUTY_TO_VOLTAGE_RATE).get::<ratio>();
|
||||
let duty = self
|
||||
let _duty = self
|
||||
.max1968
|
||||
.set_pwm(PwmPinsEnum::MaxV, duty as f64, TecSettings::MAX_V_DUTY_MAX);
|
||||
self.tec_settings.max_v_set = duty as f32 * TecSettings::MAX_V_DUTY_TO_VOLTAGE_RATE;
|
||||
|
||||
self.tec_settings.max_v_set = max_v;
|
||||
self.tec_settings.max_v_set
|
||||
}
|
||||
|
||||
pub fn set_max_i_pos(&mut self, max_i_pos: ElectricCurrent) -> ElectricCurrent {
|
||||
let duty = (max_i_pos / TecSettings::MAX_I_POS_NEG_DUTY_TO_CURRENT_RATE).get::<ratio>();
|
||||
let duty = self
|
||||
let _duty = self
|
||||
.max1968
|
||||
.set_pwm(PwmPinsEnum::MaxPosI, duty as f64, TecSettings::MAX_I_POS_DUTY_MAX);
|
||||
self.tec_settings.max_i_pos_set = duty as f32 * TecSettings::MAX_I_POS_NEG_DUTY_TO_CURRENT_RATE;
|
||||
|
||||
self.tec_settings.max_i_pos_set = max_i_pos;
|
||||
self.tec_settings.max_i_pos_set
|
||||
}
|
||||
|
||||
pub fn set_max_i_neg(&mut self, max_i_neg: ElectricCurrent) -> ElectricCurrent {
|
||||
let duty = (max_i_neg / TecSettings::MAX_I_POS_NEG_DUTY_TO_CURRENT_RATE).get::<ratio>();
|
||||
let duty = self
|
||||
let _duty = self
|
||||
.max1968
|
||||
.set_pwm(PwmPinsEnum::MaxNegI, duty as f64, TecSettings::MAX_I_NEG_DUTY_MAX);
|
||||
self.tec_settings.max_i_neg_set = duty as f32 * TecSettings::MAX_I_POS_NEG_DUTY_TO_CURRENT_RATE;
|
||||
|
||||
self.tec_settings.max_i_neg_set = max_i_neg;
|
||||
self.tec_settings.max_i_neg_set
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue