0
\$\begingroup\$

I'm a complete amateur, I've probably gotten a million things wrong with this already. I'm using an SN74HC109 dual j-k" flip-flop chip. I'm trying to toggle the led (forgot to add a resistor in the diagram, ah, also forgot to add a line from 5V to Vcc.) with a momentary switch. When the circuit is powered, the led turns on but does not toggle when the momentary switch is pressed and released.

enter image description here

\$\endgroup\$
  • \$\begingroup\$ why is 1K not pulled low then? \$\endgroup\$ – KyranF Dec 13 '14 at 10:06
  • 1
    \$\begingroup\$ L doesnt meant "unconnected" so make sure it's held low either directly, or with a resistor (depending what the datasheet recommends) \$\endgroup\$ – KyranF Dec 13 '14 at 10:06
  • \$\begingroup\$ Maximum Low-Level input voltage with my Vcc at 5V is about 1.35V, I tried using a voltage divider, (R1-1k, R2-100) to get around 0.45V low to pin1K. LED does not light up, I've done something wrong again haven't I? \$\endgroup\$ – user2967107 Dec 13 '14 at 10:20
  • \$\begingroup\$ ?? Just pull it down to 0V with a single resistor! \$\endgroup\$ – KyranF Dec 13 '14 at 10:23
  • \$\begingroup\$ sorry, I don't understand what that means, I've tried to connect a resistor from the pin directly to ground if that's what that means. LED lights up but does not toggle. \$\endgroup\$ – user2967107 Dec 13 '14 at 10:25
1
\$\begingroup\$

Please build the following circuit:

schematic

simulate this circuit – Schematic created using CircuitLab

There are a number of things to learn from it.

1) With CMOS, ALWAYS tie unused inputs (not outputs) directly to ground or VCC. There are exceptions, with some circuits incorporating a built-in pull-up or pull-down resistor, but unless the data sheet mentions these, assume they don't exist. Leaving unused pins floating (particularly with CMOS) can produce amazingly intermittent, bizarre and maddening errors. And don't think that you can ignore the inputs of an unused part of the circuit, such as the unused flip-flop in your 74HC109. Don't even think about it. Sometimes that works, and sometimes it doesn't. Tie them all high or low.

2) C2, a 0.1 uF ceramic cap, should be connected as close as humanly possible to the ground and power pins of at least 1 IC, in this case the 74HC109. For larger circuits, particularly CMOS on a PCB with a ground plane, a minimum of 1 cap per 5 ICs is OK for CMOS, but for other logic families, or at high speeds, 1 cap per IC is a very good idea. Caps are cheap and don't take up much space, but the problems arising from not enough of them can be hard to diagnose. If you're using a solderless breadboard, do NOT use jumpers from the IC pins to the cap. Connect the cap directly to the sockets nearest the IC power and ground pins.

3) Never tie an LED directly to any low impedance output, and particularly don't tie one directly to the connection between an output and an input. On the one hand, it will try to draw too much current in the on state, and will also clamp the output to a low voltage which the input will not recognize as high. In this case, a 470 ohm resistor, combined with the LED voltage and the limited high output drive of the flip-flop will give you about 6 or 7 mA LED current when on. Just to show what I'm talking about, once you've got the circuit working, put an LED directly to ground on the flip-flop clock input, and watch what happens.

4) At microsecond to millisecond time scales, mechanical contacts such as switches and relay contacts will physically bounce as they close, and logic is fast enough to resolve those bounces into separate closures/openings. In this case, it will show up as intermittent operation of the flip-flop, depending on whether or not it got an even or odd number of contacts when you press the switch. For more complex circuits using counters or state machines you can get the most amazing errors.

\$\endgroup\$
0
\$\begingroup\$

You are clocking a flip-flop directly from a switch that has not been de-bounced. You need a de-bouncing circuit to feed the flip-flop's clock input. As others have suggested, this could be a simple R-C network, or as a better option, use an SPDT (change-over) switch and a set-reset (SR) flip-flop as a de-bouncer. A common way to do this is with cross-connected NAND gates.

Always connect the GND pin. Never leave it unconnected, even if the circuit appears to work.

\$\endgroup\$
  • 1
    \$\begingroup\$ He also needs a 10K (or so) pull-down resistor from 1CLK to ground to ensure that 1CLK is low when the switch is open. \$\endgroup\$ – Peter Bennett Dec 13 '14 at 17:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.