thermostat: Reduce DAC calibration time
- 13 out of 18 bit of DAC is used to calibrate the output with 12bit ADC - Calibration with more than 13 bit does not improve the accuracy
This commit is contained in:
parent
c5efc6ca57
commit
7be35fe7f0
|
@ -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::<volt>(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();
|
||||
|
|
Loading…
Reference in New Issue