Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Flip-flops won't flip

Status
Not open for further replies.

carbonzit

Active Member
... or flop. Arrrrrrrrgh ... I'm trying to test the circuit I posted here. Can't get a damn thing to work. I tried just one lousy flip-flop; can't make it go.

The FF is a 4013 (marked TC4013: CMOS, I assume). I'm using a breadboard. Yes, yes, I know all about breadboard problems. But for chrissakes, I've seen plenty of simple circuits like this breadboarded that worked. This isn't a microwave circuit.

I'm just trying to verify the FF operation. I have the output (Q) connected to the base of a NPN transistor (2n3904), to which is connected a LED through a resistor. That part works, and tells me whether I have a high or low on Q.

Problem is, no matter what I do, I cannot control the FF. The output is always high, and I can neither set nor reset it. The only time I can get it to "quiet down" is if I tie practically every input (D, S, R, clk) to ground. Then the LED goes dark. But then, of course, I can't do anything with it, since all the inputs are grounded. (To try to activate R and S, I'm using a switch connected to V+ through 1KΩ. My V+ supply is about 5 volts, actually a little more, and well filtered.)

This device just seems to be extraordinarily sensitive to noise, or induced voltage, or something. Is this to be expected? should I be using a non-CMOS gate instead?

Very frustrating ...
 
Last edited:
Are you sure you have connected /Q to D and that R & S are the correct state to enable a change in the state of Q with each clock pulse?
 
Your here link does not work.

But it sounds like you have violated the prime directive of CMOS circuits "DO NOT LEAVE ANY INPUT FLOATING!". If I had my choice that would be printed on the front page of all CMOS data sheets.

You stated "(switch connected to V+ through 1kΩ)". But is the switch output floating with no connection when it's not switched to V+? CMOS requires a definite high or low on its inputs. If left floating the input level is indeterminate, not 0, and, since it is high impedance, will float to some arbitrary value, thus giving the results you have observed. You must tie all inputs to either ground or V+ or use a resistor to do that. For example you can tie a large value resistor (≥10kΩ) to ground from the switch output to insure that the switch output is either 1 or 0.
 
Last edited:
OK, I got somewhere: tied every input on the chip (including the other unused FF) to ground, except R & S, which I tied to Vdd through 1kΩ. Then I connected my two pushbuttons from these pins to ground. When I powered the chip up with both buttons held closed, I was able to set and reset it by releasing one button at a time.

Your suggestion of using large-value Rs sounds good. Maybe now is the time to ask about pull-up resistors, something I've never properly understood. Is this a situation where one would want to use pull-ups? or is that only on outputs? how would I implement that here?
 
Pullup resistors are used between an input or output and V+ as needed. It's used whenever you want that node to be logic high, but you can still pull it low with a switch to ground (mechanical, transistor, or open collector output) if needed.

You can use it in your circuit as needed if you want any inputs to stay normally high (logic one). You don't normally need them on CMOS outputs.

The way to do the set and reset with the PBs is to put the resistors from the inputs to ground as a pulldown. Then connect the PBs between the inputs and V+. Pushing the buttons will the put a logic one on their respective inputs. Otherwise the outputs stay at logic zero.
 
The way to do the set and reset with the PBs is to put the resistors from the inputs to ground as a pulldown. Then connect the PBs between the inputs and V+. Pushing the buttons will the put a logic one on their respective inputs. Otherwise the outputs stay at logic zero.

Heh; that's 'zactly what I ended up doing, and it worked fine. Used 22k resistors (that's what I had). Thanks to you.

So before you answered I prepared this sketch to ask you a couple more questions about this:

**broken link removed**

I omitted R1, and just had R2 betwixt gate pin and ground.

In general, what's good practice with CMOS inputs? (Yeah, I know, it depends ...) Just looking for general guidelines here.

By the way, my little test circuit works; chases a LED around a loop. Not very exciting, I know, but it's my first logic circuit ever! so it's just a little bit exciting.

But, of course there's a major problem, which would be a show-stopper for those circuits I drew for other people: the lights are very flaky. Sometimes they go in sequence, but more often they skip around drunkenly.

Can you say "switch bounce"?

So how do I deal with that? Do I really need a one-shot? Would Schmitt triggers help? Is there a simple wave-shaper I can make, just a capacitor or three? I know this is a topic unto itself, and I will do a search here, but since this problem has reared its ugly head here I thought I'd bring it up.

===== Later, in a different part of the forest: ======

Lotsa stuff here. I found this picture in a good PDF someone posted (including all the math needed to size R & Cs):

**broken link removed**

More parts than I had hoped for, including yet another gate. Anyone have experience with this arrangement? I'm sure it works; I'm just wondering if there might be something simpler that would work well enough. (This is not going inside the Space Shuttle.)
 
Last edited:
I have used schmitt triggers for debouncing logic, it's hard to tell exactly what you need without seeing the actual circuit.
 
Just Schmitt triggers? There's a link to the circuit in the first post (I fixed it). I'm just using a pushbutton to cycle a bunch of flip-flops through their clock inputs.
 
Just Schmitt triggers? There's a link to the circuit in the first post (I fixed it). I'm just using a pushbutton to cycle a bunch of flip-flops through their clock inputs.

hi CZ,
A bit of bed time reading for you.:)
 

Attachments

  • debouncing.pdf
    333.3 KB · Views: 469
  • CMOSschmitt.pdf
    148.4 KB · Views: 194
Thanks, Eric. I've been reading that debouncing doc (that's where the picture came from). Great stuff! I wanted to thank you for that.

So what is your experience with hardware debouncing?

CMOSschmitt.pdf (148.4 KB, 0 views)

(light bulb going off over head)
So it's the hysteresis that makes a Schmitt work, to clean up all those nasty false switch closures. Aha. I think I'll get me some of those and try them out.
 
Last edited:
Thanks, Eric. I've been reading that debouncing doc (that's where the picture came from). Great stuff! I wanted to thank you for that.

So what is your experience with hardware debouncing?

hi,
I would advise hardware de-bouncing of all mechanical type switches, especially when the switch is used a clock source.
A switch may give a clean signal sometimes and not others and they can get more bouncy as they age.

The basic debounce circuit is a couple of resistors and a capacitor driving into a Schmitt gate.

The Schmitt is important after the debounce filter as it will sharpen up the slow edges from the filter, you dont want a slow rising edge as a clock as this can cause multiple clocking in some circuits
 
One thing about that RC debouncing circuit (picture posted earlier here) that's bothering me. While I have no problem believing this will debounce a switch, won't it generate an unwanted pulse at power-up as the capacitor charges (assuming a normally-open switch)? or is this not a problem?

Also, this does generate a logic high when the switch is closed, right?
 
Last edited:
One thing about that RC debouncing circuit (picture posted earlier here) that's bothering me. While I have no problem believing this will debounce a switch, won't it generate an unwanted pulse at power-up as the capacitor chargers (assuming a normally-open switch)? or is this not a problem?

Also, this does generate a logic high when the switch is closed, right?

hi,
It would create a power on pulse, but any decent designed circuit would have a 'master' power on reset circuit that would be longer than any transient pulse.
 
Continuing on with debouncing, I tried using a 555 monostable to generate the clock pulse, as per this configuration from the 555 datasheet:

**broken link removed**

This is better, but still highly unsatisfactory. It often skips 2 or more states. In fact, at one point it was even amusing, and I thought it might be worth building as kind of a frustrating game: "try to hit the button to light the next light up". Oops, skipped! You lose!

(I connected RESET to Vcc and tried several different RC combos; even with long delays, it wasn't reliable.)

So is there a good 555 solution to this problem (generating one reliable pulse from a pushbutton)? Or is Schmitt the way to go here?
 
hi,
I have never had to use a 555 timer configured as a monostable to debounce a mechanical switch.
Sometimes a simple R/C filter on the switch will do, if the switch is really noisy an R/C filter into a Schmitt will be required.

If the switch operated a 'critical' control circuit I would use a R/C and a Schmitt latch.
 
Continuing on with debouncing, I tried using a 555 monostable to generate the clock pulse, as per this configuration from the 555 datasheet:
What is the period of the monostable?
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top