diff --git a/src/thermostat/thermostat.rs b/src/thermostat/thermostat.rs index e4fbe13..d6d6440 100644 --- a/src/thermostat/thermostat.rs +++ b/src/thermostat/thermostat.rs @@ -302,12 +302,12 @@ impl Thermostat{ /// VREF measurement can introduce significant noise at the current output, degrading the stabilily performance of the /// thermostat. pub fn calibrate_dac_value(&mut self) { - const STEPS: i32 = 18; - let target_voltage = self.max1968.adc_read(AdcReadTarget::VREF, 64); + const DAC_BIT: u32 = 18; + const ADC_BIT: u32 = 12; + let target_voltage = self.max1968.adc_read(AdcReadTarget::VREF, 512); let mut start_value = 1; let mut best_error = ElectricPotential::new::(100.0); - for step in (0..STEPS).rev() { - debug!("TEC VREF Calibrating: Step {}/{}", step, STEPS); + for step in (DAC_BIT-ADC_BIT-1..DAC_BIT).rev() { let mut prev_value = start_value; for value in (start_value..=ad5680::MAX_VALUE).step_by(1 << step) { self.max1968.phy.dac.set(value).unwrap();