<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
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.<br>
<br>
Why not make an <a
href="http://en.wikipedia.org/wiki/File:R-S_mk2.gif">SR latch</a>
out of two NOR gates, such as half of a CD74AC02?<br>
<br>
To do this you would take one of these (Digikey 296-32940-5-ND, 62
cents):<br>
<br>
<a class="moz-txt-link-freetext" href="http://www.ti.com/lit/ds/symlink/cd74ac02.pdf">http://www.ti.com/lit/ds/symlink/cd74ac02.pdf</a><br>
<br>
Hook it up as follows:<br>
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.<br>
pin 14 to VCC<br>
<br>
pin 3 (input 1B) to pin 4 (output 2Y)<br>
pin 5 (input 2A) to pin 1 (output 1Y)<br>
<br>
Now the external hookup is as follows:<br>
pin 2 (input 1A) is your "R" input for reseting the latch. The
Raspberry Pi drives this.<br>
pin 6 (input 2B) is your "S" input that connects to the push
button, momentarily connecting it to VCC.<br>
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.<br>
<br>
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.<br>
<br>
If would be nice if somebody else sanity checked this. <br>
<br>
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. <br>
<br>
-Pete<br>
<br>
<div class="moz-cite-prefix">On 04/17/2014 02:34 PM, Grawburg wrote:<br>
</div>
<blockquote cite="mid:cca2beb07ed746064dd5c19ed1ab8824@myglnc.com"
type="cite">
<pre wrap="">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.
<a class="moz-txt-link-freetext" href="http://www.engineersgarage.com/electronic-circuits/understanding-jk-flip-flop-circuit">http://www.engineersgarage.com/electronic-circuits/understanding-jk-flip-flop-circuit</a>
better drawing of the circuit: <a class="moz-txt-link-freetext" href="http://www.eeweb.com/project/sudheer_gupta/working-of-jk-flip-flop-using-cd4027-circuit">http://www.eeweb.com/project/sudheer_gupta/working-of-jk-flip-flop-using-cd4027-circuit</a>
Thanks,
Brian Grawburg
</pre>
</blockquote>
<br>
</body>
</html>