User avatar
redhawk
Posts: 3465
Joined: Sun Mar 04, 2012 2:13 pm
Location: ::1

GPIO and flip flops??

Tue Sep 24, 2013 8:51 pm

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.

User avatar
FTrevorGowen
Forum Moderator
Forum Moderator
Posts: 5621
Joined: Mon Mar 04, 2013 6:12 pm
Location: Bristol, U.K.
Contact: Website

Re: GPIO and flip flops??

Tue Sep 24, 2013 9:28 pm

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.
Still running Raspbian Jessie or Stretch on some older Pi's (an A, B1, 2xB2, B+, P2B, 3xP0, P0W, 2xP3A+, P3B+, P3B, B+, and a A+) but Buster on the P4B's. See: https://www.cpmspectrepi.uk/raspberry_pi/raspiidx.htm

PiGraham
Posts: 3935
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: GPIO and flip flops??

Tue Sep 24, 2013 9:38 pm

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

hampi
Posts: 223
Joined: Fri May 31, 2013 11:29 am
Contact: Website

Re: GPIO and flip flops??

Tue Sep 24, 2013 9:59 pm

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

User avatar
AndrewS
Posts: 3625
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
Contact: Website

Re: GPIO and flip flops??

Tue Sep 24, 2013 10:23 pm

There's a nice overview of the Pi's hardware interrupts at http://raspi.tv/2013/how-to-use-interru ... d-rpi-gpio

User avatar
Burngate
Posts: 6302
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: GPIO and flip flops??

Wed Sep 25, 2013 11:22 am

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.

User avatar
AndrewS
Posts: 3625
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
Contact: Website

Re: GPIO and flip flops??

Wed Sep 25, 2013 11:44 am

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:

Return to “Interfacing (DSI, CSI, I2C, etc.)”