diff --git a/firmware/sampling.cpp b/firmware/sampling.cpp index 1e3dc84..577a859 100644 --- a/firmware/sampling.cpp +++ b/firmware/sampling.cpp @@ -41,9 +41,13 @@ static void SamplingThread(void*) float r2_opposite_phase = (r_1 + r_3) / 2; // Compute AC (difference) and DC (average) components - nernstAc = f_abs(r2_opposite_phase - r_2); + float nernstAcLocal = f_abs(r2_opposite_phase - r_2); nernstDc = (r2_opposite_phase + r_2) / 2; + nernstAc = + (1 - ESR_SENSE_ALPHA) * nernstAc + + ESR_SENSE_ALPHA * nernstAcLocal; + // Exponential moving average (aka first order lpf) pumpCurrentSenseVoltage = (1 - PUMP_FILTER_ALPHA) * pumpCurrentSenseVoltage + diff --git a/firmware/wideband_config.h b/firmware/wideband_config.h index cfb87b6..5aa58cf 100644 --- a/firmware/wideband_config.h +++ b/firmware/wideband_config.h @@ -15,6 +15,9 @@ #define ESR_SUPPLY_R (22000) #define VM_RESISTOR_VALUE (10) +// Heater low pass filter +#define ESR_SENSE_ALPHA (0.002f) + // ******************************* // Pump current sense // ******************************* @@ -25,8 +28,8 @@ #define LSU_SENSE_R (61.9f) // Pump low pass filter alpha -// sampling at 2.5khz, alpha of 0.1 gives about 42hz bandwidth -#define PUMP_FILTER_ALPHA (0.1f) +// sampling at 2.5khz, alpha of 0.01 gives about 50hz bandwidth +#define PUMP_FILTER_ALPHA (0.02f) // ******************************* // Pump controller