Flip Flop Trouble

Thread Starter

IssacSutt

Joined Jan 6, 2017
45
I am currently a hobbiest in electronics, (I'm only 17, almost 18), but I plan to deeply pursue a career in the field of electronics engineering one day. Most of the time I design many circuits through simulation and do not ever get much time to breadboard them, so I dont have much "hands on" experience; because being a family of 7, I rarely get that chance... anyhow, this time I planned to prototype a specific digital circuit, beginning by checking the functionality of the dual positive edge triggered JK Flip Flops with preset and clear that I had ordered from Mouser. But I couldn't seem to get it to perform properly in "toggle" mode, I had the CLK input tied to ground through a resistor so that I could toggle it by pulsing it only on and off +5v high, but the output of Q was unpredictable, normally when input CLK is pulsed 1,0,1,0, Q should pulse only twice: 1, 0, but instead it sometimes toggles on the 2nd and 3rd leading positive edge. Any ideas why this is happening, and how to fix this??? - thanks!
 

ScottWang

Joined Aug 23, 2012
7,499
Good boy, welcome to AAC ... :)

Your problem could be the key bounce caused that.
Could you upload the schematic(circuit) and labels the ic number, and please compress it as 800x600 jpg or gif (if draw by computer)which you are using to test?
 

AnalogKid

Joined Aug 1, 2013
12,076
When switch contacts come together, the don't just make contact and hold it. They bounce off against each other, and can generate dozens of make and break cycles in a few milliseconds. So the random flipflop outputs are actually the result of the flipflop toggling too fast for you to see. Put a capacitor across the resistor. When the switch contacts first touch the cap will charge up to a high enough voltage that the chip input will see a steady signal while the contacts bounce. Since we know nothing about your switch or your resistor value, all we can do is guess. A safe starting point for the resistor-capacitor network is:
R x C = 50 ms
So if your resistor is 1000 ohms, connect a 50 uF capacitor in parallel with it and see if that stabilizes the circuit performance. If so, increase the resistor or decrease the cap until things quit working correctly and calculate the time constant for that case.

What is the complete part number of the JK device? Knowing that gives you a range of acceptable resistor values.

ak
 

Thread Starter

IssacSutt

Joined Jan 6, 2017
45
ScottWang, I do not have the aid of a computer software just yet, (although I have used multisim in a course before), so instead I use a beautiful "everycircuit" app on my phone to simulate everything I design -although because it is a mobile app, it does have some limitations. Here is a link- http://everycircuit.com/circuit/5708895289081856
Hopefully it works, I used D type Flip Flops in the simulation. The circuit is basically a shift register with logic for a specific binary sequence. It was supposed to tie into my cars security system through a power transistor and a relay, but I could never find the car door relay -they hide it pretty well. Anyhow, the inputs were going to be tied to 3 of the sheet metal plates on my car, or 3 screws, and use a high amplifier to sense the weak current from your finger when you touch 2 plates at a time -thus sending either a value of 1 or 0, and of course if you enter the correct sequence, then you unlock the car or whatever it's used for. But during my short prototyping of just the JK in toggle mode, I couldn't even get that to work properly.
 

ScottWang

Joined Aug 23, 2012
7,499
@IssacSutt.
If you are talking about the real car then this thread will be move to the Automotive Electronics.

So you simulated in D flip Flop is ok, but when you made the real prototype with JK Flip-Flop, but it didn't work?

If you using D Flip-Flip then you can try this debounce circuit.


http://www.trainelectronics.com/LED_Articles_2007/LED_103/images/schematic_4013.gif

If you using JK Flip-Flip then you can try this debounce circuit.


Source page.

The better way is to post your circuit and take some photos for your system and compress them to as 800x600 jpg or 1024x768 jpg.
 

Thread Starter

IssacSutt

Joined Jan 6, 2017
45
Correct ABSF. Yeah i'll need to add Invertor gates acrosst each J and K inputs in order for it to function as a D Flip Flop.

Ok ScottWang, but how come the debounce circuits are different?

This is the datasheet, (should be attached below), for the JK flip flops I'm using.
 

Attachments

Last edited by a moderator:

WBahn

Joined Mar 31, 2012
32,745
Correct ABSF. Yeah i'll need to add Invertor gates acrosst each J and K inputs in order for it to function as a D Flip Flop.

Ok ScottWang, but how come the debounce circuits are different?
There are multiple ways to debounce a circuit. The goal is to make the circuit insensitive to all but the first transition of a switching event. This can be done in hardware using a latch or in software using a timer or several other ways.
 

Thread Starter

IssacSutt

Joined Jan 6, 2017
45
Thanks Wbahn. At first I thought thats what occurred, but then I wasn't too sure that it could be bouncing off the contacts like that, because I just used a jumper wire, not a switch... so I had originally added a 22uF capacitor in parallel with a 1kOhm resistor from input CLK to ground (but that just made it stay on), so I might just do a little research on denouncing circuits or test some of my own ideas when I get the chance. Thanks for all the advice ScottWang, absf, cruts how,

*Crutschow* -sorry for the typpo
...and Wbahn.
 

MrChips

Joined Oct 2, 2009
34,673
If you have a 74HC109 or any dual flip-flop with /PRESET and /CLEAR you can use the spare flip-flop to debounce your push button.

You will need a SPDT push button for this.

Connect 1kΩ pullup resistors on /PRESET and /CLEAR inputs.
Connect J, K and CLK to GND.
Connect the pushbutton outer pins to /PRESET and /CLEAR inputs.
Connect the center pin of the pushbutton to GND.

The Q output of the flip-flop is your debounced clock.

(I suppose a circuit schematic would help - to come.)
 

dl324

Joined Mar 30, 2015
18,238
I dont have much "hands on" experience
Welcome to the hobby!

Since you don't have much experience, I'd like to point out that, even though CMOS have ESD protection, you can still damage devices. You should get a grounded mat and be aware of things that can build up static charges.

Do you have any test equipment yet?
 

Thread Starter

IssacSutt

Joined Jan 6, 2017
45
Thanks guys, I'm sure I'll figure something out, I just needed to know what was causing the problem.
-I greatly appreciate all your help
 

crutschow

Joined Mar 14, 2008
38,376
I wasn't too sure that it could be bouncing off the contacts like that, because I just used a jumper wire, not a switch..
Touching a jumper wire to get a pulse will bounce, just like relay contacts.
It's virtually impossible to make a mechanical electrical connection by any means without generating multiple pulses from bounce.
One exception is mercury-wetted reed relays, where a small amount of mercury on the contacts maintains the connection during the bounce time.
 

MrChips

Joined Oct 2, 2009
34,673
Here are three examples of switch debounce circuits.
The first and second circuits are more reliable than the third. However, they need SPDT push buttons which are not as common place as SPST switches.

Switch-Debounce.png
 
Top