momentary switch + relay debouncing

Started by Dimitree, October 07, 2019, 04:22:48 AM

Previous topic - Next topic

Dimitree

I built a simple PCB based on the circuit proposed by R.G. on how to drive an electronic switch, but instead I used it to drive a relay with a soft touch momentary switch.
This is the schematic:



I used CD40106 because I thought Schmitt Trigger would perform better, and I added a "remote" input.
At the moment it doens't work really well, since sometimes when I press the switch I get burst of fast on/off, so I think the circuit is not actually debouncing my switch (maybe because the switch I used is really poor).
Is there a way to increase the amount of debouncing? or maybe the problem is elsewhere, like for example the remote input that doesn't have a pull resistor so it floating and maybe causing the burst?

patrick398

I've been fiddling around something similar using a 4013 and found that a 10k in series with the switch and then a 10k and 1uf to ground worked well

duck_arse

you must pull that remote input up, try 100k to supply +.
" I will say no more "

R.G.

Fix the remote input first.

The two-inverter flipflop is very, very reliable. It works on the principle of the capacitor storing the "next" input for the first inverter, and that capacitor being able to overwhelm the feedback resistor from the second inverter. The capacitor gets charged to the correct level for the "next" state. When you connect it to the input of the first inverter, the output of the second inverter tries to pull the input to the old state, but the capacitor wins for a few microseconds. In those few microseconds, the first inverter, then the second inverter flip state, and the feedback resistor goes from opposing the new state to helping it.
The momentary switch has to let go for this to work. It only needs to "make" for a few microseconds. If it keeps bouncing for a long time, it makes the first stage oscillate. So check your momentary switch too.
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

Dimitree

I added a pullup resistor and the huge boucing is gone.
but, is still not really reliable, since sometimes the switch triggers twice (so it actually change state really fast and then come back to its original state).
so could I change the capacitor or resistor value to get a better transition?

R.G.

OK, that's better.

Given what you've found, I think there are possibly other problems. First, if it's still double or multiple triggering, your remote switch is bouncing really, really badly. Second, a pullup on the remote switch isn't really an answer, it's a band-aid over a problem. This circuit requires a floating switch. Third, you might be having sever RF pickup problems.

So, first: The debounce time on that circuit is controlled by the series resistor and capacitor to ground. I use a 100K and a 0.1uF, which gives a time constant of t=R*C= 100K*100nF = 0.01S. CMOS commonly has a switching "middle zone" of about 1/3 of the supply, so the RC lets the signals traverse that in about 1/2 of the time constant. When the switch is first "made", it flips the first inverter in about 1uS, and the second inverter flips in about another microsecond. So after about two microseconds, the thing is latched in the new state. However, the RC now has to charge the timing cap to the new state, and that takes about 2/3 of the power supply voltage, so roughly 20mS is needed to charge it the other way. If your switch bounces for really, really long, it might do a second bounce in the indeterminate region, and give you a second trip. This is unusual for switches I've tried, including momentary footswitches.

For production pedals, I use a tactile switch for the remote switch, and they have low bounce. The first thing I would do is try a different remote switch, ideally a lower bouncing (that is, in general smaller) switch. If you have a keyboard style tactile switch, so much the better. That may just fix things entirely. In general, switches are EVIL. :icon_biggrin:

Second, a pullup on the remote switch makes it harder for the circuit to "flip" in one direction. This circuit really requires a floating switch. You >might< be able to put a 0.001uf capacitor across the switch and help it, though. This would suppress some of the bouncing of a really bouncy switch.

Third, the circuit might in some cases pick up radio interference if it's in the middle of a flip and the radio interference was really bad. A small cap across the remote switch >might< help this, or shielding the wires to the remote.

I suggest trying the 1000nF across the remote switch and removing the pullup.Then let us know what happens.

I've given you the time-constant information. It's all in that resistor/capacitor hanging off the first inverter's output. Making that bigger - bigger R, bigger C - makes the thing slower. But try other things first.   
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

amptramp

One solution would be to find an MC14490 hex contact bounce eliminator.

https://www.onsemi.com/pub/Collateral/MC14490-D.PDF

Each channel has a 4-bit shift register and it debounces a switch by clocking the switch status through the register and only changing state when all register outputs are in the same state.  There is an onboard oscillator that is used to provide timing and it can be driven from an external source or a capacitor can be used to set the frequency.

The only problem I see with this IC is the initialization state is indeterminate but you could clone the circuitry using a register that has an asynchronous reset input.

R.G.

Well, one small problem, maybe. Mouser wants $6.19 for a MC14490, $0.63 for a PIC10F320 (my next choice, debounces two switch contacts at a time, but needs a $0.10 zener for power and a transistor to actually do the high voltage 9V output(s), $0.41 for a CD4069 and $0.42 for a CD4049. The last two need several Rs and Cs in addition. The math says "I know a way to save $5.00".

The cheapest way is with a Boss/Ibanez transistor flipflop, but that's a bit of wiring.
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

Dimitree

just to clarify, the bounce happens on the "main" switch, not the "remote" switch. I actually removed the diode that connects the remote input to the rest of the circuit..just to understand if it was the culprit.
So obvioulsy at this point the bounce happens because of the bad quality of the momentary foot switch that I'm using, indeed it trigger the relay twice when the foot movement is not really firm.. I think I can live with that..
I don't think it's an RFI problem, it's not random, and by the way the layout is well done I'd say, using SMD components, ground plane, neat and clean