Do I need a toggle flip flop?

Discussion in 'General Electronics Chat' started by rjjenkins, Jul 3, 2011.

  1. rjjenkins

    Thread Starter Member

    Apr 16, 2011
    102
    2
    Hello
    I've bought an remote control unit. When I press a button on a keyfob, the output on the other unit goes high and stays high. In theory, when I press the button again, the output should go low. Actually what normally happens is that the output briefly goes low and then goes high again. I think this is caused by switch bounce on the key fob. There's nothing I can do about the keyfob end, but what can I do at the other end?

    From my reading, it seems that a toggle flip flop would solve the problem. The flip flop would have a single input and the output would toggle each time the input went low and then high again. Is this right?

    However I am confused because a lot of what I read about toggle flip flops implies that they also have a clock input, which I don't want.

    I'm not at all knowledgeable (obviously) - I'm not even sure how to buy a toggle flip flop - so words of one syllable appreciated.
     
  2. tom66

    Senior Member

    May 9, 2009
    2,613
    214
    If it's switch bounce, a simple RC network could solve the problem.
     
  3. rjjenkins

    Thread Starter Member

    Apr 16, 2011
    102
    2
    Thanks, but I'm afraid I don't know what you mean. (This is the problem with being a beginner)
    In case this is relevant: the switch is in a sealed unit, there's nothing I can do about it. I can only tackle what happens at the other end.
    I THINK a J-K flip flop with both J and K held high, and using the output from my unit as the clock input will solve it. But I'm not sure.
     
  4. tom66

    Senior Member

    May 9, 2009
    2,613
    214
    As you describe the problem it seems like the switch is latching on but never switching off unless you hold down the switch, so it's probably not switch bounce, unless you can eventually get it to turn off by pressing the button many times?

    A toggle flip flop would work as would a D-type flip flop with clock being the button input and the notQ output wired to the D input of the D-type. If present, ground the S/R inputs, and leave the Q output open.
     
  5. rjjenkins

    Thread Starter Member

    Apr 16, 2011
    102
    2
    No, that's not quite right. It's turning on but hardly ever turning off, even if I hold down the switch. If I'm lucky, and I press it very quickly, it sometimes goes off. Usually, it goes off briefly and then on again. If I hold it down for longer, it sometimes toggles back and forth a few times before settling down usually to ON.

    Thanks for the advice, which I think I do understand! I'll look for a D-type flip flop chip
     
  6. tom66

    Senior Member

    May 9, 2009
    2,613
    214
    Do you have an oscilloscope to make a trace of what you are observing? If not can you borrow a friend's scope?

    From what you describe it sounds a *lot* like switch bounce. Try adding a 1k ohm resistor in series with the switch line and a 100n capacitor in parallel from the switch line to ground. If this has some effect (even if only making it easier to turn off) it is probably switch bounce.
     
  7. rjjenkins

    Thread Starter Member

    Apr 16, 2011
    102
    2
    Thanks - no I don't have access to a scope but in any case I don't think I can do anything to the switch unit since it's all sealed in. Hopefully the flip flop solution will work.
     
  8. rjjenkins

    Thread Starter Member

    Apr 16, 2011
    102
    2
    Well, the flip flop has worked to some extent. But when there are multiple switch bounces (I assume), the Q output is still liable to end up in the wrong state, but not nearly so often as before.

    Also, when I switch the whole unit on, the Q output is likely to end up high, even before I press the button, presumably because of bounce from the main switch. Any ideas how to avoid these two problems?
     
  9. tom66

    Senior Member

    May 9, 2009
    2,613
    214
    On the clock input to the chip use a 1k resistor in series and 100n ceramic capacitor or 1u electrolytic capacitor in parallel. [These parts should cost no more than $2 total.]

    If the Q output is starting in a random state after fixing this, a 100n ceramic with a 1k resistor to ground should help; the junction between the 100n and 1k being connected to the reset pin of the D-type. (The opposite way to the clock input.) This will make sure the D-type starts in a known state but I think most will anyway...
     
  10. rjjenkins

    Thread Starter Member

    Apr 16, 2011
    102
    2
    Thanks. Just to clarify: in your first paragraph, the resistor and capacitor are in parallel with each other?
     
  11. tom66

    Senior Member

    May 9, 2009
    2,613
    214
    No in first paragraph, they are like this:

    Code ( (Unknown Language)):
    1.  
    2. [FONT=Courier New]     1k resistor[/FONT]
    3.  [FONT=Courier New]Input -\/\/\/--+[/FONT][FONT=Courier New]-- To clock input
    4.                |
    5.               --- 100n
    6.               --- cap
    7.                |
    8.               ---
    9.                -
    10. [/FONT]
    Whereas for the reset pin:


    Code ( (Unknown Language)):
    1.  
    2. [FONT=Courier New]  100n cap[/FONT]
    3. [FONT=Courier New]V+ --| |--+[/FONT][FONT=Courier New]-- To reset pin
    4.           |
    5.           / 1k
    6.           \ res
    7.           /
    8.           |
    9.          ---
    10.           -
    11. [/FONT]
     
Loading...