On Sun, 25 Feb 2018 12:32:49 -0800 (PST), ewholz@gmail.com declaimed the
following:
>Well thanks for this scholarly reply. I have implemented a test program using
an interrupt on a GPIO pin - but have noticed that I was getting "interrupts"
when the door was not being opened or closed. I have since discovered
(complemnts of the internet)
that Linux interrupts here and there, and thus may cause the bogus messages I
was getting. The python program does take up some resources, but the Pi is
used only for door open/close events. I have concluded after reading your
treatise, that an interrupt implementation is not really practical for my "bush
league" program, and
checking, saving, and comparing the newState and lastState is plenty good
enough.
>
An interrupt handler, tied to a specific interrupt, should only be
getting activated by that particular interrupt. If other system interrupts
are also triggering it, there would seem to be something wrong in the
interrupt system.
After all, Linux uses a clock interrupt to handle time-slicing of
programs -- suspending the active program and giving time to some other.
Out of curiosity, how well de-bounced is the door sensor? Even a
magnetic reed switch will be subject to bouncing during transitions between
open and closed, and an interrupt handler on that sensor will see many
transitions.
http://raspi.tv/2013/how-to-use-interrupts-with-python-on-the-raspberry-pi-and-
rpi-gpio-part-2
"""
You may also notice, depending on how cleanly you press the second button,
that sometimes you get more than one message for just one button press.
This is called “switch bounce”.
"""
and
"""
Update – RPi.GPIO 0.5.2 onwards includes this debounce algorithm
Ben has included the above debounce algorithm in 0.5.2 onwards. This
article was originally written for 0.5.1. So the above debounce code has
been superseded by adding bouncetime=xxx, where xxx is a time in
milliseconds. e.g.
GPIO.add_event_detect(channel, GPIO.RISING, callback=my_callback,
bouncetime=200)
"""
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)
|