diff --git a/firmware/sampling.cpp b/firmware/sampling.cpp index 7f4703c..83755f2 100644 --- a/firmware/sampling.cpp +++ b/firmware/sampling.cpp @@ -43,7 +43,10 @@ static void SamplingThread(void*) nernstAc = f_abs(r2_opposite_phase - r_2); nernstDc = (r2_opposite_phase + r_2) / 2; - pumpCurrentSenseVoltage = 0.7f * pumpCurrentSenseVoltage + 0.3f * (result.PumpCurrentVoltage - result.VirtualGroundVoltageInt); + // Exponential moving average (aka first order lpf) + pumpCurrentSenseVoltage = + (1 - PUMP_FILTER_ALPHA) * pumpCurrentSenseVoltage + + PUMP_FILTER_ALPHA * (result.PumpCurrentVoltage - result.VirtualGroundVoltageInt); // Shift history over by one r_3 = r_2; diff --git a/firmware/wideband_config.h b/firmware/wideband_config.h index e75a3f0..f8ae900 100644 --- a/firmware/wideband_config.h +++ b/firmware/wideband_config.h @@ -23,6 +23,10 @@ // LSU sense resistor - 61.9 ohms #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) + // ******************************* // Pump controller // *******************************