[TriEmbed] CD4027 Flip Flop & My Traffic Light Project
Pete Soper
pete at soper.us
Thu Apr 17 15:09:09 CDT 2014
You don't want a toggle function, do you? That circuit sets Q to one
state with the first press and inverts with the second switch press, and
so on until the cows come home. That's very different from what you
described Monday evening.
Why not make an SR latch <http://en.wikipedia.org/wiki/File:R-S_mk2.gif>
out of two NOR gates, such as half of a CD74AC02?
To do this you would take one of these (Digikey 296-32940-5-ND, 62 cents):
http://www.ti.com/lit/ds/symlink/cd74ac02.pdf
Hook it up as follows:
pins 7, 8, 9, 11, and 12 to ground. That is, the chip ground and the
four unused inputs are tied to ground. It's good form to avoid leaving
CMOS input gates floating.
pin 14 to VCC
pin 3 (input 1B) to pin 4 (output 2Y)
pin 5 (input 2A) to pin 1 (output 1Y)
Now the external hookup is as follows:
pin 2 (input 1A) is your "R" input for reseting the latch. The
Raspberry Pi drives this.
pin 6 (input 2B) is your "S" input that connects to the push button,
momentarily connecting it to VCC.
pin 1 will be your "Q" (noninverted) output: high when the "set"
input has been driven high. This will active your "right turn light" and
also be sensed by the RPI.
It's undefined what happens if the RPI holds the reset line high for any
length of time while somebody is holding the button down. In your shoes
I would hook Q and Q bar through leds and current limit resistors to
ground, hook pushbuttons to both S and R and press those buttons
randomly for a few minutes and confirm the thing can't get into a bad
state. In particular you want to know that if both S and R are driven
high then when one button is released the correct output is high (and
the smoke hasn't jumped out of the chip). I'm 99% sure the only
consequence of the RPI and the pushbutton driving both S and R high is
that both Q and Q bar will be low. So what I'm saying is that in the
intended context when the button is pushed, the "right turn" light (I
think that's what you called it) will be latched on, and if, at the
moment the RPI resets the latch the button is pressed, then (assuming
the RPI output is long since returned to low) when then button is
released the "right turn" light will be on again. That seems intuitively
correct.
If would be nice if somebody else sanity checked this.
But I did study the data sheet and it appears that with a 3.3 volt
supply the logic level requirements will be compatible with the
Raspberry Pi.
-Pete
On 04/17/2014 02:34 PM, Grawburg wrote:
> If I understand the schematic and datasheet correctly for the CD4027 JK flip flop, and a suggested circuit, I can. . . 1. Operate with 3.3VDC
> 2. In the drawing the pushbutton controls an LED. I can make this one of the inputs of my MCP23017 instead.
>
>
> http://www.engineersgarage.com/electronic-circuits/understanding-jk-flip-flop-circuit
> better drawing of the circuit: http://www.eeweb.com/project/sudheer_gupta/working-of-jk-flip-flop-using-cd4027-circuit
>
>
> Thanks,
> Brian Grawburg
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.triembed.org/pipermail/triembed_triembed.org/attachments/20140417/80e3187f/attachment.htm>
More information about the TriEmbed
mailing list