Page 1 of 1

GPIO and flip flops??

Posted: Tue Sep 24, 2013 8:51 pm
by redhawk
I have been considering some experiments with the GPIO i.e. detecting push switch (door bell) or some kind of sensor trigger like incoming phone call / or phone OTH.
It's highly likely the logic levels would jump from low to high and back to low which could pose a problem if the input pin wasn't read during the high period.
To improve detection reliably I would have to code to read the GPIO input pins several times a second which to me doesn't seem practical and a waste of CPU resources.
So I was thinking instead of butchering the CPU why not poll the GPIO every 2 seconds but the input pin could have some kind of latching circuit attached like a J/K or R/S flip flop.
Once the program has acknowledged that the input pin is high I could then use one of the spare GPIO output pins to reset the latch switch.

Would such a thing be possible or has anyone achieved this??

Could anyone recommend a flip flop that would happily run on 3.3v since most seem to prefer a 5v power supply??

Richard S.

Re: GPIO and flip flops??

Posted: Tue Sep 24, 2013 9:28 pm
by FTrevorGowen
Perhaps a CMOS monostable eg. the CD4047 or equivalent might be of use since that would convert an "edge trigger" input to a pulse of known, fixed duration (eg. 10ms)? Just a thought.
Trev.

Re: GPIO and flip flops??

Posted: Tue Sep 24, 2013 9:38 pm
by PiGraham
The GPIO supports hardware interrupts so you don't need to add a latch. A very short pulse will cause an interrupt then and there. You can either deal with it immediately in the callback, or you can set a flag, and perhaps a time code, that you deal with in your main program thread.

Some info here
http://www.element14.com/community/thread/18526

Re: GPIO and flip flops??

Posted: Tue Sep 24, 2013 9:59 pm
by hampi
The PiPIC can detect long enough low signal or key pressing. The event register needs to be read with i2c from the PiPIC to find out if any of the keys (maximum 4 with pic12f675) have been pressed.

https://github.com/oh7bf/PiPIC/wiki

Re: GPIO and flip flops??

Posted: Tue Sep 24, 2013 10:23 pm
by AndrewS
There's a nice overview of the Pi's hardware interrupts at http://raspi.tv/2013/how-to-use-interru ... d-rpi-gpio

Re: GPIO and flip flops??

Posted: Wed Sep 25, 2013 11:22 am
by Burngate
redhawk wrote:..Could anyone recommend a flip flop that would happily run on 3.3v since most seem to prefer a 5v power supply??..
As far as know, 74HC devices should work happily on 3v3.
I'd be using something like 74HC08 quad NAND to make my own latch. For a door bell, I'd be powering it from its own supply.

The advantage of that is that you can come home in the middle of the night, power up your Pi, and find out if the bell was rung while you were out. Then attempting to reset the latch and looking again should tell you if they're still ringing the bell.

Re: GPIO and flip flops??

Posted: Wed Sep 25, 2013 11:44 am
by AndrewS
Burngate wrote:The advantage of that is that you can come home in the middle of the night, power up your Pi, and find out if the bell was rung while you were out. Then attempting to reset the latch and looking again should tell you if they're still ringing the bell.
I'd be worried if somebody was still ringing my doorbell in the middle of the night! :lol: