Compare commits
2 Commits
8c8ed12522
...
c214e4182d
Author | SHA1 | Date |
---|---|---|
linuswck | c214e4182d | |
linuswck | fb69ae3306 |
|
@ -160,7 +160,6 @@ fn main() -> ! {
|
|||
thermostat.update_pid();
|
||||
if thermostat.get_temp_mon_status().over_temp_alarm {
|
||||
laser.power_down();
|
||||
thermostat.set_pid_engaged(false);
|
||||
thermostat.power_down();
|
||||
}
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ pub struct TempMon {
|
|||
state: State,
|
||||
count: u32,
|
||||
is_set_point_changed: bool,
|
||||
is_limit_changed: bool,
|
||||
}
|
||||
|
||||
impl Default for TempMon {
|
||||
|
@ -48,6 +49,7 @@ impl Default for TempMon {
|
|||
count: 0,
|
||||
// stable_temp_count: 0,
|
||||
is_set_point_changed: false,
|
||||
is_limit_changed: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -68,6 +70,7 @@ impl TempMon {
|
|||
|
||||
pub fn set_upper_limit(&mut self, upper_limit: ThermodynamicTemperature) {
|
||||
self.upper_limit = upper_limit;
|
||||
self.is_limit_changed = true;
|
||||
}
|
||||
|
||||
pub fn get_upper_limit(&mut self) -> ThermodynamicTemperature {
|
||||
|
@ -76,6 +79,7 @@ impl TempMon {
|
|||
|
||||
pub fn set_lower_limit(&mut self, lower_limit: ThermodynamicTemperature) {
|
||||
self.lower_limit = lower_limit;
|
||||
self.is_limit_changed = true;
|
||||
}
|
||||
|
||||
pub fn get_lower_limit(&mut self) -> ThermodynamicTemperature {
|
||||
|
@ -129,11 +133,9 @@ impl TempMon {
|
|||
}
|
||||
}
|
||||
State::PidStartUp | State::PidStable => {
|
||||
let is_over_temp: bool;
|
||||
if self.state == State::PidStartUp {
|
||||
is_over_temp = temp > self.upper_limit || temp < self.lower_limit;
|
||||
} else {
|
||||
is_over_temp = (temp.value - self.set_point.value).abs() > 0.5;
|
||||
let mut is_over_temp = temp > self.upper_limit || temp < self.lower_limit;
|
||||
if self.state != State::PidStartUp {
|
||||
is_over_temp = is_over_temp || (temp.value - self.set_point.value).abs() > 0.5;
|
||||
}
|
||||
|
||||
let is_within_spec: bool = (temp.value - self.set_point.value).abs() < 0.001;
|
||||
|
@ -163,6 +165,12 @@ impl TempMon {
|
|||
} else if self.is_set_point_changed {
|
||||
self.is_set_point_changed = false;
|
||||
self.state = State::PidStartUp;
|
||||
} else if self.is_limit_changed {
|
||||
self.is_limit_changed = false;
|
||||
if is_over_temp {
|
||||
self.state = State::PidStartUp;
|
||||
self.count = 0;
|
||||
}
|
||||
} else if self.status.status == TempStatusEnum::Stable {
|
||||
self.state = State::PidStable;
|
||||
} else if !pid_engaged {
|
||||
|
|
Loading…
Reference in New Issue