diff --git a/README.md b/README.md index b0b5d1a..0979001 100644 --- a/README.md +++ b/README.md @@ -271,8 +271,6 @@ with the following keys. | `tec_u_meas` | Volts | Measurement of the voltage across the TEC | | `pid_output` | Amperes | PID control output | -Note: With Thermostat v2 and below, the voltage and current readouts `i_tec` and `tec_i` are disabled and null due to faulty hardware that introduces a lot of noise in the signal. - ## PID Tuning The thermostat implements a PID control loop for each of the TEC channels, more details on setting up the PID control loop can be found [here](./doc/PID%20tuning.md). diff --git a/src/channels.rs b/src/channels.rs index 488a8d6..3db38a6 100644 --- a/src/channels.rs +++ b/src/channels.rs @@ -20,7 +20,6 @@ use crate::{ command_handler::JsonBuffer, pins::{self, Channel0VRef, Channel1VRef}, steinhart_hart, - hw_rev, }; pub const CHANNELS: usize = 2; @@ -33,18 +32,17 @@ pub const MAX_TEC_I: f64 = 3.0; const DAC_OUT_V_MAX: f64 = 3.0; // TODO: -pub -pub struct Channels<'a> { +pub struct Channels { channel0: Channel, channel1: Channel, pub adc: ad7172::Adc, /// stm32f4 integrated adc pins_adc: pins::PinsAdc, pub pwm: pins::PwmPins, - hwrev: &'a hw_rev::HWRev, } -impl<'a> Channels<'a> { - pub fn new(pins: pins::Pins, hwrev: &'a hw_rev::HWRev) -> Self { +impl Channels { + pub fn new(pins: pins::Pins) -> Self { let mut adc = ad7172::Adc::new(pins.adc_spi, pins.adc_nss).unwrap(); // Feature not used adc.set_sync_enable(false).unwrap(); @@ -62,7 +60,7 @@ impl<'a> Channels<'a> { let channel1 = Channel::new(pins.channel1, adc_calibration1); let pins_adc = pins.pins_adc; let pwm = pins.pwm; - let mut channels = Channels { channel0, channel1, adc, pins_adc, pwm, hwrev }; + let mut channels = Channels { channel0, channel1, adc, pins_adc, pwm }; for channel in 0..CHANNELS { channels.calibrate_dac_value(channel); channels.set_i(channel, ElectricCurrent::new::(0.0)); @@ -448,8 +446,8 @@ impl<'a> Channels<'a> { fn report(&mut self, channel: usize) -> Report { let i_set = self.get_i(channel); - let i_tec = if self.hwrev.major > 2 {Some(self.read_itec(channel))} else {None}; - let tec_i = if self.hwrev.major > 2 {Some(self.get_tec_i(channel))} else {None}; + let i_tec = self.read_itec(channel); + let tec_i = self.get_tec_i(channel); let dac_value = self.get_dac(channel); let state = self.channel_state(channel); let pid_output = ElectricCurrent::new::(state.pid.y1); @@ -562,8 +560,8 @@ pub struct Report { i_set: ElectricCurrent, dac_value: ElectricPotential, dac_feedback: ElectricPotential, - i_tec: Option, - tec_i: Option, + i_tec: ElectricPotential, + tec_i: ElectricCurrent, tec_u_meas: ElectricPotential, pid_output: ElectricCurrent, } diff --git a/src/main.rs b/src/main.rs index 30f9cd8..353a161 100644 --- a/src/main.rs +++ b/src/main.rs @@ -138,7 +138,7 @@ fn main() -> ! { let mut store = flash_store::store(dp.FLASH); - let mut channels = Channels::new(pins, &hwrev); + let mut channels = Channels::new(pins); for c in 0..CHANNELS { match store.read_value::(CHANNEL_CONFIG_KEY[c]) { Ok(Some(config)) =>