0
\$\begingroup\$

THIS SIMULATION DONOT WORK

ABOVE SIMULATION IS NOT WORKING

THIS SIMULATION DONOT WORK, ONLY DIFFRENCE IS ABSENSE OF PULSE GENERATOR

ABOVE SIMLATION IS WORKING

My simulation donot work if I manually turn switch on and off for clock even though I have used pull down resistors but when I use pulse generator for clock input , it works fine and correctly.

\$\endgroup\$
2
  • \$\begingroup\$ What are you simulating this with? Are those actual 7476s? If so your pull-down may be far too large for old style TTL. \$\endgroup\$
    – Trevor_G
    Dec 5, 2017 at 21:05
  • \$\begingroup\$ As Trevor suggested, just swap R1 and the switch, so that R1 becomes a pull-up and the switch closing grounds the input. \$\endgroup\$
    – peterG
    Dec 5, 2017 at 22:39

1 Answer 1

0
\$\begingroup\$

You have a couple of problems to deal with when feeding a physical switch into a circuit like this.

The first is switch bounce. When you close (or open) a switch, you can't depend on getting a single clean transition from low to high (or vice versa). Rather, as the switch closes it'll actually transition from low to high and back to low for some time--on the order of milliseconds or so. So, what you normally want to do is as soon as you see a pulse from the switch, you set a timeout and ignore all input from that switch for the next few milliseconds or so (exact time rarely matters a lot).

Secondly, you have a metastability problem. Since the switch is asynchronous to you circuit, it doesn't necessarily meet the setup and hold times required by your flip flops. To keep this from causing a problem, you typically want to run it through a synchronizer circuit, which typically consists of a couple of flip flops:

schematic

simulate this circuit – Schematic created using CircuitLab

In theory, even with this you could still run into a metastability problem, but the chances are reduced to a level that's typically quite acceptable (note: this isn't the only way to deal with metastability issues either--if you look around, you'll find others).

\$\endgroup\$
2
  • \$\begingroup\$ He is not using real switches yet though..this is all in the simulator. \$\endgroup\$
    – Trevor_G
    Dec 5, 2017 at 20:43
  • 1
    \$\begingroup\$ @Trevor: Which raises the question of whether the simulator he's using attempts to simulate switch bounce and/or metastability (and offhand, I have no idea either way on that). \$\endgroup\$ Dec 5, 2017 at 21:51

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.