Debouncing momentary switches with Inverters?

Started by KarenColumbo, December 13, 2020, 04:29:32 AM

Previous topic - Next topic

KarenColumbo

Very predictably I'm in the "how the heck can I debounce this POS momentary switch" phase after successfully breadboarding a relay toggle circuit using a momentary switch (of the cheap and dirty variant) and a CD4049 inverter chip.
I put a 100nF cap across the poles so far.
Of 10 pushing the button actions, up to three won't show any effect. Wchich is no problem because nothing bad will happen - I just use this in the long run to switch between some aspects in my soon-to-be tube amp like tone stack caps and such.
I had a good read and - the "usual solutions" like debouncing it using a 74HC14  aside - found this interesting article: http://www.industrial-electronics.com/ind-mtr-cntrl_051.html
Since my circuit leaves three of the 4049's inverters uselessly grounded it's a bit of an overkill to snap in a second one, but I'm here for the learning experience after all.
Will this logic switcheroo actually work as intended? In above article the switch used seems to me like a toggle, not a momentary one. But what is a toggle other than a momentary that keeps its state?
As the schematics in this article are a bit ... rudimentary I guess there's some RC magic to be applied, also I remember (from another article: https://hackaday.com/2015/12/09/embed-with-elliot-debounce-your-noisy-buttons-part-i/) that the switch has to be pulled up to V+ to give the logic gate something to work with.
Is this something that can be tried and has it some chance of working out?
(Edit) It becomes clearer: In this schematic

BOTH poles of the switch are pulled up to V+ by resistance. I have 12V - would 10k suffice?
  • SUPPORTER
I see something of myself in everyone / Just at this moment of the world / As snow gathers like bolts of lace / Waltzing on a ballroom girl" - Joni Mitchell - "Hejira"

iainpunk

probably anything between 1k and 100k will do, but what you have there is a not momentary switch diagram, but a debounce for a toggle.
if you have some schmidt triggers laying around, that'd be great, (get a 5V regulator to run the digital system; the relay drivers)


cheers, Iain
friendly reminder: all holes are positive and have negative weight, despite not being there.

cheers

amptramp

Most microswitches are SPDT and the article talks about a float switch for a water tank that is almost certain to be a microswitch.  There are pushbutton adapters for microswitches that allow a human input.  These are always snap-action switches in order to have a clean transition with as little time as possible spent with the pole contact close to one side contact to avoid arcing.

There are momentary toggle switches that are spring-loaded to one side but with variations in number of poles and contact positions.  I have seen some that are centre off, momentary to one side and full-time to the other side.  They made all kinds of switches to solve all kinds of problems.

The circuit shown with inverters usually has a resistor in series with the output on the diagonal crossover lines in the picture to avoid the current pulse on the Vcc line that comes from shorting the inverter output with a switch.  NOR and NAND gate flip-flops are usually preferred because the control inputs are not affected by whatever else is going on in the circuit and do not load the output, which in the case of the inverter circuit, may feed switch bounce into the output lines even if the flip-flop state is as commanded by the switch.

KarenColumbo

Are there Schmitt Trigger packages that won't explode when ingesting 12 Volts V+?
  • SUPPORTER
I see something of myself in everyone / Just at this moment of the world / As snow gathers like bolts of lace / Waltzing on a ballroom girl" - Joni Mitchell - "Hejira"

iainpunk

friendly reminder: all holes are positive and have negative weight, despite not being there.

cheers

KarenColumbo

Ah okay, the logic IC supply should be separate, I get the (meanwhile quite obvious) hints. Damn. This is gonna be a UGE board.
  • SUPPORTER
I see something of myself in everyone / Just at this moment of the world / As snow gathers like bolts of lace / Waltzing on a ballroom girl" - Joni Mitchell - "Hejira"

iainpunk

a LM7805 and surrounding circuit can be less than 1cm2 on a PCB or proto board, it need not be huge. (remember that the in and out smoothing caps should be of different values to negate oscillations)
friendly reminder: all holes are positive and have negative weight, despite not being there.

cheers

Fancy Lime

Of course there is always the tried and true Boss Style switching with BJTs. Works up to whatever voltage the transistors are rated for, is pretty well denounced (can be adjusted by changing a single cap), can be made to consistently come up on or off upon power-up, and can drive several status LEDs on both states without extra active parts. Downside: many parts, lots of soldering. But may still be less hassle than having an inverter plus voltage regulator plus all necessary periphery.

Andy
My dry, sweaty foot had become the source of one of the most disturbing cases of chemical-based crime within my home country.

A cider a day keeps the lobster away, bucko!

anotherjim

You can use x2 any inverting function to make a Schmitt trigger.

IC1 c & d are it. R2 & R3 set the trigger threshold. 1k/10k are probably in the right ratio although I would try 10k/100k first. You can make it with CD4069, 4049 or gates like 4001 or 4011 (with inputs tied together). Doesn't have to be x2 inverters, can be x1 non-inverting such as 4050.

I think you said that you have +12v power, so no regulator needed?

Fancy Lime

Hi Andreas,

I thought about this some more and have a question. What is the inverter switching schematic you tried that did not work 3 out of 10 times? You only posted the one you intended to use instead, right?

If you look at RGs site on soft switching, you will find a CD4049 latch near the end with detailed explanations.

http://www.geofex.com/article_folders/cd4053/cd4053.htm

Have you been using that or something similar? If so, there are a couple of points to mention. These things are "triggered Schmitt Triggers"; the latching action is performed by a Schmitt Trigger itself. So there is no need to add another Schmitt Trigger for denouncing. But you do need to get the resistor and the cap values right. If this is the topology you are using, try increasing the cap value and see if that improves things. This should increase the minimum time between two consecutive switching actions. Since bounce is actually caused by multiple impulses where there should only be one, this should work as long as you always press your switch reasonably fast. If that is not enough, try increasing the vertical and decreasing the horizontal resistor. The former should again slow down the recovery of the switch that it needs to be ready to switch again. The latter increases the hysteresis of the Schmitt Trigger, meaning you need a stronger bounce to cause problems.

Last but not least, it is not usually the best idea to use different inverters on the same chip for audio one switching. They can mess with each other. Have two separate chips, they are cheap and not outrageously big. You can use the leftover inverters from the switching chip as LED drivers or for another switch. I like the CD4069 over the 4049 because it is slightly smaller. They come in 20V variants, so no need for a regulator. But do add a 1k resistor from power to the VCC pin and a 100nF cap across the power pins to stabilize the switch against power ripple. Now that I think about it, since you are using this in a relay driver circuit, you may want to make that two 1k resistors in series with a 100uF cap to ground between them and also the 100nF between the power pins. This should suffice to keep the power surge from the relay action from messing with the switch well enough. Maybe try this first before fiddling with the R and C of the switch itself.

Hope that helps although it comes, as always, straight from where the sun don't shine and has not been tested.

Andy
My dry, sweaty foot had become the source of one of the most disturbing cases of chemical-based crime within my home country.

A cider a day keeps the lobster away, bucko!

denden

checkout http://www.ganssle.com/debouncing-pt2.htm ...

I've used the process, built a circuit around a 4584B Schmitt inverter and +/- 15V supply. Based on the article you need the RC parts to to give you a 20-50ms 'settling' time. I've used 20ms in the calculations and so far the debouncing appears perfect