0
\$\begingroup\$

I'd like to convert a momentary switch in a toggle switch using a D-Type flip flop from an SN74HC74AN.

For this reason I've created and simulated a circuit like this:

enter image description here

All works fine on the Multisim Simulation.

Then I've created a real prototype on a breadboard like this:

enter image description here

But, in this case, when I press the momentary switch button nothing happens and the LED remains ON.

I know that the CLK input must be triggered but, on the sn74hc74an datasheet I read:

"Dual D-type positive-edge-triggered flip-flops with clear and preset"

I've also added a 3.9 nF capacitor on the input side but got the same results.

Where am I wrong?

Update.

Eventually I found the right solution.

The issue was related to non triggered signal sent to the 74HC74 inputs pin. Using Schmitt-Trigger Inverters like CD40106B CMOS all works as expeted.

The builded circuit is this and works like a charm. enter image description here

\$\endgroup\$
3
  • \$\begingroup\$ It's hard to see if the switch is in correct orientation or 90 degrees wrong. Have you measured with a multimeter what is the button output voltage to chip input and whether pushing the button changes the voltage? \$\endgroup\$
    – Justme
    Mar 22, 2022 at 18:46
  • \$\begingroup\$ On schematics, don't use four-way net junctions. From a distance, the junction dot may not be visible. That happens more these days when A3/A4 schematics are viewed on smartphones and tablets. Here, instead place R1 above S1. That's then clear, whatever the zoom level. With documentation, it's written/drawn once but read hundreds of times so that extra time spent on clarity is very worthwhile. Reduces possibility of any further daft errors, which makes everyone's life easier. \$\endgroup\$
    – TonyM
    May 3, 2022 at 13:46
  • \$\begingroup\$ @Justme Hi. When the momentary switch S1 is pressed the voltage drops from 5V to 0V and, when the the high-low threshold of the Hex Schmitt-Trigger Inverters is reached we have a rising signal on the clock input of the SNx4HC74 Dual D-Type Positive-Edge-Triggered \$\endgroup\$
    – M4Biz
    May 3, 2022 at 16:50

2 Answers 2

2
\$\begingroup\$

The device is triggered on the rising edge so I wouold flip your input circuit where the switch pulls the input high. Your preset and clear both need to be tied to +. Then tie the inputs of the other gate to ground or + it doesn't matter. At that point it should work. Your capacitor not shown value may have to be adjusted. TonyM also is giving you a good circuit but remember to terminate the unused flip-flop.

\$\endgroup\$
3
\$\begingroup\$

There are some clear design faults in your circuit: floating inputs and no switch debounce. Fixing them will most likely make the circuit work. If not, they will make it possible to debug it further.

Floating inputs

The /1PR and /1CLR inputs on DFF1 are floating. They typically float high but may well not. If they go active, they will stop the DFF responding to the CLK input.

Connect them to the VCC supply rail, preferably through a resistor (e.g. 10K) but a direct connection is fine. Do this for all unused inputs on the 74HC74, including DFF2.

Switch debouncing

The switch contacts will bounce together multiple times when the switch is pressed and released. You won't get the perfect clean action that you might see in simulation, as the example waveform below shows.

enter image description here

Switch debouncing is already well documented on the internet so you can find out about it there and the various solution circuits. Typical debounce periods to allow are 5..10 ms but look at the specs' for your switch.

In short, you can debounce the switch by adding a capacitor in parallel with the switch that, in conjunction with your 10K pull-up, creates an RC circuit that greatly slows the rise time of the DFF1 CLK input. However, this very slow rise time will be outside of the spec' for the 74HC74 CLK input. Although it will work, and has done in such circuits for decades, it's not the ideal design choice.

You also change your switch to a changeover switch and make a debounce circuit using DFF2 in the 74HC74, as shown here.

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
5
  • \$\begingroup\$ Hi TonyM. Sorry for very high delay. I've tried to do what you've suggested. Connecting 1CLR and 1PR to Vcc rail, the result is that the LED on Q start OFF and than when I press the momentary switch button it goes ON and remain ON even if I press many times the button. Connecting even all unused inputs to VCC rail it seems to works better and many times (but not ever) the LED switch from ON to OFF and viceversa. Connecting all unused inputs to GND I've burned the IC (I've see about 0,6 A drained). Now I've replaced the IC but I'm scared to connect unused inputs to VCC. \$\endgroup\$
    – M4Biz
    Mar 29, 2022 at 14:41
  • \$\begingroup\$ @M4Biz, (a) Are you sure you didn't connect an unused output to GND/VCC? That'd damage the IC. It's only inputs that mustn't be floating otherwise it can draw extra current and behave incorrectly. (b) Have you debounced your switch input? \$\endgroup\$
    – TonyM
    Mar 29, 2022 at 15:03
  • \$\begingroup\$ Hi I've used R= 1k and C = 10u to debounce switch. I'm not 100% shure that I've damaged the IC when I've connected unused inputs to GND (not to VCC) but usually I don't believe to coincidences. \$\endgroup\$
    – M4Biz
    Mar 29, 2022 at 15:14
  • \$\begingroup\$ @M4Biz, connecting inputs to rails is fine, there's millions of them connected and fine like that. No need to believe/disbelieve anything, engineering's not a faith, it's based on facts and data or the lack of it. But you can't just pick a favourite rail, you need to tie each input to its inactive level. Here, that's VCC for all. As noted, you have a very slow rise time with the RC. Use the second DFF with a changeover switch, if you can, much more reliable. We'll go to this chat from here on as it's not a forum. \$\endgroup\$
    – TonyM
    Mar 29, 2022 at 17:31
  • 1
    \$\begingroup\$ Hi. As I've said I found the issue when I've connected all unused pins to GND. Thanks for you support \$\endgroup\$
    – M4Biz
    Mar 30, 2022 at 11:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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