This is a child of my first problem, I am getting ghosting/bouncing on my digital input, but this question is more hardware related and specific to my problem. I have a RasPi model B.
I have read somewhere that when using interrupts, it is not possible doing a stable software debouncing and I have experienced it myself. I have setup a callback with bouncetime=350
but event though I have seen in my logfile that I was able to receive two inputs within 5ms
. I also experience that I receive "ghost inputs" - for example I have an electrical meter connected to my RasPi but I have not connected the meter to a power souce... so it should NEVER be able to give out a pulse but even though it does (a few ghost pulses per day)!? This is a clear indication that there are interference on my wires and maybe the wires are influencing eachother so this is why I am searching for a proper hardware debouncing setup.
I have four electrical meters from Kamstrup. This is the pulse adaptor documentation mentioning that one pulse is 30ms +/-10%
and I get one pulse per Watt used (1000 pulses/kWh). I have all four -
(minus) wires connected to GND
and their +
wires to GPIO 0-3 (pin 11
+12
+13
+15
) and currently no other components used. I will probably never go beyond 10kWh power usage in my house so I can get 2.8 pulses per second which is aprox a 350ms bouncetime, which I am also using in my software (including using the built-in pull-up
resistor):
GPIO.setup(11, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(12, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(13, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(15, GPIO.IN, pull_up_down=GPIO.PUD_UP)
# Create interrupt handler
GPIO.add_event_detect(11,GPIO.RISING, callback=eventHandler, bouncetime=350)
GPIO.add_event_detect(12,GPIO.RISING, callback=eventHandler, bouncetime=350)
GPIO.add_event_detect(13,GPIO.RISING, callback=eventHandler, bouncetime=350)
GPIO.add_event_detect(15,GPIO.RISING, callback=eventHandler, bouncetime=350)
My question is:
What exactly do I need to connect where, to setup a proper hardware debouncer for my digital electrical meter input?
I expect that I should connect a capacitor (100nF?) and maybe use a real resistor (10K ohm?) instead of the built-in but as I am not a hardware guy I have no clue which capacities to use and how exactly to connect it?
Can anyone help clarifying this? I have read countless webpages on hardware debouncing but still I am very much in doubt.
If anyone can suggest a ready-to-buy add-on to my RasPi model B, that can take care of this exact problem, I would be very interested too as I want to have the most trust-worthy setup as possible. A few ghost pulses per day is okay but currently I have no idea how faulty it is.
GPIO
andGND
and I want to have a hardeware debounce solution instead of using the internal stuff