From 403517fdb446062f98f6c1dbad0230671ee676b1 Mon Sep 17 00:00:00 2001 From: Empire Phoenix Date: Wed, 6 May 2026 09:26:14 +0200 Subject: [PATCH] Suppress EMI noise on water flow sensor by filtering short pulses --- Software/MainBoard/rust/src/hal/water.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Software/MainBoard/rust/src/hal/water.rs b/Software/MainBoard/rust/src/hal/water.rs index 44bec81..ef74cf8 100644 --- a/Software/MainBoard/rust/src/hal/water.rs +++ b/Software/MainBoard/rust/src/hal/water.rs @@ -53,6 +53,9 @@ impl<'a> TankSensor<'a> { let one_wire_bus = OneWire::new(one_wire_pin, false); pcnt1.set_high_limit(Some(i16::MAX))?; + // Reject pulses shorter than ~12.8 µs (1023 APB cycles @ 80 MHz) to suppress EMI noise + // on the sensor cable. Real flow pulses are in the millisecond range. + pcnt1.set_filter(Some(1023)).unwrap(); let ch0 = &pcnt1.channel0; ch0.set_edge_signal(flow_sensor.peripheral_input());