thermostat: pid_state rename variables
This commit is contained in:
parent
bc7bf9a6e7
commit
ff3d9b790a
|
@ -23,11 +23,11 @@ const VREF_SENS: f64 = 3.3 / 2.0;
|
||||||
pub struct PidState {
|
pub struct PidState {
|
||||||
pub adc_data: Option<u32>,
|
pub adc_data: Option<u32>,
|
||||||
pub adc_calibration: ad7172::ChannelCalibration,
|
pub adc_calibration: ad7172::ChannelCalibration,
|
||||||
pub adc_time: Instant,
|
pub sample_ts: Instant,
|
||||||
pub adc_interval: Duration,
|
pub sampling_interval: Duration,
|
||||||
/// i_set 0A center point
|
/// i_set 0A center point
|
||||||
pub center: ElectricPotential,
|
pub center_point: ElectricPotential,
|
||||||
pub dac_value: ElectricPotential,
|
pub dac_volt: ElectricPotential,
|
||||||
pub pid_engaged: bool,
|
pub pid_engaged: bool,
|
||||||
pub pid: pid::Controller,
|
pub pid: pid::Controller,
|
||||||
pub sh: sh::Parameters,
|
pub sh: sh::Parameters,
|
||||||
|
@ -45,11 +45,11 @@ impl Default for PidState {
|
||||||
PidState {
|
PidState {
|
||||||
adc_data: None,
|
adc_data: None,
|
||||||
adc_calibration: ad7172::ChannelCalibration::default(),
|
adc_calibration: ad7172::ChannelCalibration::default(),
|
||||||
adc_time: Instant::from_secs(0),
|
sample_ts: Instant::from_secs(0),
|
||||||
// default: 10 Hz
|
// default: 10 Hz
|
||||||
adc_interval: Duration::from_millis(100),
|
sampling_interval: Duration::from_millis(100),
|
||||||
center: ElectricPotential::new::<volt>(1.5),
|
center_point: ElectricPotential::new::<volt>(1.5),
|
||||||
dac_value: ElectricPotential::new::<volt>(0.0),
|
dac_volt: ElectricPotential::new::<volt>(0.0),
|
||||||
pid_engaged: false,
|
pid_engaged: false,
|
||||||
pid: pid::Controller::new(pid::Parameters::default()),
|
pid: pid::Controller::new(pid::Parameters::default()),
|
||||||
sh: sh::Parameters::default(),
|
sh: sh::Parameters::default(),
|
||||||
|
@ -69,8 +69,8 @@ impl PidState {
|
||||||
} else {
|
} else {
|
||||||
Some(adc_data)
|
Some(adc_data)
|
||||||
};
|
};
|
||||||
self.adc_interval = now - self.adc_time;
|
self.sampling_interval = now - self.sample_ts;
|
||||||
self.adc_time = now;
|
self.sample_ts = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Update PID state on ADC input, calculate new DAC output
|
/// Update PID state on ADC input, calculate new DAC output
|
||||||
|
@ -81,12 +81,12 @@ impl PidState {
|
||||||
Some(pid_output)
|
Some(pid_output)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_adc_time(&self) -> Time {
|
pub fn get_sample_ts(&self) -> Time {
|
||||||
Time::new::<millisecond>(self.adc_time.total_millis() as f64)
|
Time::new::<millisecond>(self.sample_ts.total_millis() as f64)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_adc_interval(&self) -> Time {
|
pub fn get_sampling_interval(&self) -> Time {
|
||||||
Time::new::<millisecond>(self.adc_interval.total_millis() as f64)
|
Time::new::<millisecond>(self.sampling_interval.total_millis() as f64)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_adc(&self) -> Option<ElectricPotential> {
|
pub fn get_adc(&self) -> Option<ElectricPotential> {
|
||||||
|
|
Loading…
Reference in New Issue