Suppress EMI noise on water flow sensor by filtering short pulses
This commit is contained in:
@@ -53,6 +53,9 @@ impl<'a> TankSensor<'a> {
|
|||||||
let one_wire_bus = OneWire::new(one_wire_pin, false);
|
let one_wire_bus = OneWire::new(one_wire_pin, false);
|
||||||
|
|
||||||
pcnt1.set_high_limit(Some(i16::MAX))?;
|
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;
|
let ch0 = &pcnt1.channel0;
|
||||||
ch0.set_edge_signal(flow_sensor.peripheral_input());
|
ch0.set_edge_signal(flow_sensor.peripheral_input());
|
||||||
|
|||||||
Reference in New Issue
Block a user