Driving a LED with D type Flip-Flop - Page 1
Forum section: electronics / beginners

author: caius
author_rank: Regular Contributor
timestamp: November 22, 2018, 01:26:47 pm
content: Hi,I needed a simple circuit for driving a diode LED with a D Type flip-flop like the 74LS74 so I made my own design.As you can see from circuit the LED should lit with the pressure of siwtch that pulse HIGH the CLOCK input so the negated output will be high and light the LED.It doesn't work well.I got different results using same 74LS74 from different manufacturers.Sometimes the LED will turn on, sometimes not.I tried also different TTL family and circuit works almost fine with a 74ALS74Am I wrong in something?P.S.The PRESET input come from the output of an OR gate whose inputs are two active LOW signals pulled HIGH by 10K resistors

author: glarsson
author_rank: Frequent Contributor
timestamp: November 22, 2018, 01:35:05 pm
content: Yes, you are clamping the inverted output by the LED voltage and it is not guaranteed that this voltage is seen as high by the D input. Put a resistor in series with the LED or use a gate to drive the LED and nothing else.

author: Ian.M
author_rank: Super Contributor
timestamp: November 22, 2018, 02:33:31 pm
content: Also, all the bipolar TTL families are *much* better at sinking current than sourcing it. CMOS 74xx devices are more symmetric, but there's still usually an advantage when sinking current. Therefore move the LED to the Q output and put it + a (mandatory) series resistor between the output and Vcc.

author: Zero999
author_rank: Super Contributor
timestamp: November 22, 2018, 02:39:18 pm
content: Quote from: Ian.M on November 22, 2018, 02:33:31 pmI agree. Failing that, drive the LED using a BJT, with a suitable current limiting resistors: one for the base and another for the LED.

author: caius
author_rank: Regular Contributor
timestamp: November 22, 2018, 03:36:43 pm
content: Thanks for all the advices.I already tried to move the LED to the Q output and at same time use a resistor between the output and VCC but the LED is always lit.I could use a simple gate or a transistor to drive the LED but thne I should change the design (nothing hard though ).As you can see from this other snippet of schematics the Q output is routed to a NOR gate and CLOCK inputs of two Flip-Flop

author: Ian.M
author_rank: Super Contributor
timestamp: November 22, 2018, 04:33:15 pm
content: Quote from: caius on November 22, 2018, 03:36:43 pmErr.... *NO*.<rant>Put the <triple_ expletive> resistor in *SERIES* with the <f-word> LED, then connect the series combo between Vcc and Q. Do I need also to tell you to make sure the cathode is towards Q?</rant>Sorry for just blowing up at you, but if you've just put the LED between Q and Gnd, with a pullup resistor from Q to Vcc, as your decription implies, then it certainly cant work as you expect (i.e. on when /Q is high) When Q is low and you want the LED on, its shorted out, i.e OFF! Also, Q never gets to go properly high because its clamped by the LED Vf when its on, so unless you've used a 3V Vf LED there's little hope of the downstream gates seeing a logic '1'.If I'd done that way back when I was a trainee, I would have deserved a dope-slap!Hint: A high efficiency red LED should be plenty bright at 1mA, so, depending on its nominal Vf at 1mA, and whether you are driving it from bipolar TTL (which has a higher logic '0' output level) or CMOS (which drives rail-to-rail) use a 2K7 or a 3K3 series resistor. Even the wimpiest 5V CMOS output should be able to sink 1mA and still have adequate margin below the logic '0' threshold of the next gate.

author: caius
author_rank: Regular Contributor
timestamp: November 22, 2018, 04:45:53 pm
content: A scheme would be better (plus english is not my native language)

author: glarsson
author_rank: Frequent Contributor
timestamp: November 22, 2018, 05:03:26 pm
content: A simple rule for LEDs is that there should always be a resistor in series with it, unless you know what you are doing.When I designed using TTL 30 to 40 years ago my own rules were1. Never connect a LED to an output that was used as driving an input.2. Never drive a LED between output and ground. Only between output and Vcc in series with a resistor.With the high efficient LEDs of today I guess I would have relaxed rule 2 as described earlier in this thread.

author: Richard Crowley
author_rank: Super Contributor
timestamp: November 22, 2018, 05:06:51 pm
content: Quote from: caius on November 22, 2018, 04:45:53 pmBut the proper way of doing it would be to use a simple NPN transistor to drive the LED.Hanging an LED on a logic node is not a good idea. (As mentioned by @glarsson)

author: Ian.M
author_rank: Super Contributor
timestamp: November 22, 2018, 05:30:50 pm
content: ... or use a spare inverter just to drive the LED.There's nothing wrong with driving both a logic input and a high efficiency LED from an output, provided you've read the datasheet and done the maths to make sure that when sinking the LED If, the logic level is still valid with sufficient margin, and that the junction capacitance isn't going to cause slew-rate problems.Quote from: glarsson on November 22, 2018, 05:03:26 pmBack in the day when Glarsson learnt his trade, LEDs were pretty wimpy, and barely lit up unless you drove them *HARD*, so his personal rules of thumb were essential. I've still got a few 3mm clear red LEDs from the early 70's and they are so dim you wont be dazzled at 30mA If, and if you go under about 10mA, you can easily make out the shape of the die and the shadow of the wirebond looking directly at it when on. Try that with modern high efficiency LED and you'll be blinking and seeing spots. The only time you need more than a mA or two through a modern high efficiency LED is if you are doing low duty cycle multiplexing or need it to be visible in direct sunlight.

author: glarsson
author_rank: Frequent Contributor
timestamp: November 22, 2018, 05:53:49 pm
content: Very true.Typical resistor values was 100 ohm when driving high to ground and 220 ohm when driving low from Vcc.Also, when driving from high to ground you had to watch the current through the Vcc pin. Driving six status LEDs using a hex inverter would pull 200mA from Vcc. Not acceptable. Design restrictions like this is one reason why you often find NPN transistors driving LEDs in old TTL designs. Completely different today when LED currents below 1mA is plenty.

author: caius
author_rank: Regular Contributor
timestamp: November 22, 2018, 06:46:49 pm
content: Tried all the advices with no luck (with both normal and high efficiency LEDs).The weird is that one circuit (the one that uses flip-flop 1) do work (LED is ON when switch is pressed and OFF when pressed again) while the other circuit don't /the one of flip-flop 2).I'm using the two flip-flop of a same 74LS74 to save a chip.Perhaps I have to try to use two dedicated chips.I attach schematics (pin numbers are the same but I'm using the two different flip-flop).As you can se the two circuit are identical.

author: Ian.M
author_rank: Super Contributor
timestamp: November 22, 2018, 07:39:19 pm
content: I'm not surprised it doesn't work. IILfor a LS TTL gate is -0.4mA, and VILis 0.8V. That mean that your switch input circuit has to be able to pull down to below 0.8V to reliably deliver a logic '0', and has to be able to sink 0.4mA while doing so. 2x 10K resistors in series hasn't got a snow-flake's chance in hell on a hot day of doing that, so if you are seeing *any* activity, its purely due to noise pickup!If any design using LS TTL gates has more than 470R in series with any input, its FUBARed.

author: glarsson
author_rank: Frequent Contributor
timestamp: November 22, 2018, 08:10:30 pm
content: For TTL the general rule is to use pull up resistors and connect switches to ground.TTL is good att pulling down to ground but pretty bad at pulling up. This is also reflected in how the inputs behave. Don't fight it.

author: caius
author_rank: Regular Contributor
timestamp: November 22, 2018, 09:34:29 pm
content: Quote from: glarsson on November 22, 2018, 08:10:30 pmI got better result using pull-up resistor and tie swtiches to GND, thanks.I wonder if the 0.1uF capacitor (or perhaps less capacitance) is still needed as well as the 10K resitors in series with TTL clocK input.

author: glarsson
author_rank: Frequent Contributor
timestamp: November 22, 2018, 09:43:07 pm
content: A 10k resistor is an alien creature in a TTL circuit.You will not be able to pull down a TTL input through a 10k resistor.

author: Ian.M
author_rank: Super Contributor
timestamp: November 22, 2018, 09:57:50 pm
content: You *cant* use a 10K resistor in series with a bipolar TTL input. It just wont work - see my reply #12 above.If you need a clean clock to a flipflop from a button and you are using LS TTL, there aren't many good options. Its very hard to get acceptable results from RC debouncing as the maximum practical limit for the series resistor is under 2K, so you need a *BIG* capacitor and a gate with Schmitt trigger inputs. You can use a retriggerable monostable.However the classic way to implement a debounced switch with LS TTL is to use a SR-flipflop with active low inputs, and a SPDT switch, common to ground, and the two ways to the two flipflop inputs, with pullup resistors on each. The result is an output that cant toggle until the switch moving contact has moved from one fixed contact, all the way to the other. For the SR-flipflop, you can use /SET and /CLR on a 74LS74 with D and CLK grounded, or a cross-coupled pair of NOR gates for the classic active low implementation. Don't use NAND gates as if the SR inputs are active high, and the switch grounds the inputs, it will enter an indeterminate state during contact bounce and transition.

author: caius
author_rank: Regular Contributor
timestamp: November 22, 2018, 09:58:22 pm
content: Quote from: glarsson on November 22, 2018, 09:43:07 pmYes, I'm aware of this, they are used only as pull-down/up.But with this 10K resistor in series, the circuit made with flip-flop 1 (and switch tied to VCC) is working.Maybe only luck....Besides, is the resistor between LED cathode and GND needed?I guess a 100 ohm could be fine.

author: David Hess
author_rank: Super Contributor
timestamp: November 23, 2018, 03:51:21 am
content: There are two options which work well for TTL:1. The preferred solution is to pull the LED cathode to ground with the TTL output and include a series resistance of like 470 ohms for a roughly 4 milliamp LED current.2. If the LED must be driven with a TTL high output, then a pull-up resistor to the TTL output is going to be needed. By itself, a TTL output cannot source enough current to drive an LED well. 4.7 kilohms might be a typical TTL pull-up resistor value but 1 kilohm will be needed to get even 2 milliamps through the LED.