Bouncing switch problem

Thread Starter

cce1911

Joined Jun 11, 2013
41
I have a problem controlling a bouncing switch. When an impact occurs, the switch bounces causing multiple contacts. I'm trying to design a circuit that will trigger on the first bounce, cause a TTL output of a fixed amount of time (e.g. 40ms) and ignore any additional bounces during that time period. Another impact event at 50ms would repeat the output.

Attached is a diagram of my circuit and an LTSpice model. My input is a pulse function with a stepped input that simulates the bouncing switch. My challenge is how to get the circuit to ignore the additional bounces? Any suggestions would be appreciated.
 

Attachments

AnalogKid

Joined Aug 1, 2013
10,987
A few things...

First, you don't need the diode. With a DC voltage cource, a switch is a rectifier.

Second, you do need a resistor in series with the base. As drawn, the entire battery power is crashing through the base to GND. If you build it, it will smoke.

Third, what you have will work, sorta. Putting a resistor in series with the base lets the capacitor charge up higher than Vbe, and then discharge during the open parts of the bouncing to keep the transistor on. But if you hold the switch closed for a while before releasing, the output stays down for all of that time. Your 40 ms timer doesn't start until after you release the switch. This type of circuit sometimes is called a pulse stretcher.

What you really want is a true monostable, or one-shot. With this circuit, the output pulse width starts on the first edge of the input, and terminates after its timing period even if the input still is on. With a 3V supply you can do this with LVCMOS logic gates, traditionally two NAND gates or two NOR gates. Or it can be done with two transistors. The essential thing is two active devices, either both inverting or both non-inverting.

http://en.wikipedia.org/wiki/Multivibrator

ak
 

AnalogKid

Joined Aug 1, 2013
10,987
The Utah paper is very nice, but has an error. In Figure 1, both resistors should go to Vcc. I think that was the intent, but the drawing is ambiguous and does not conform to industry standards. It isn't until the next page that you see that a down arrow is not GND.

ak
 

Thread Starter

cce1911

Joined Jun 11, 2013
41
So I have reviewed the links provided, but I'm not sure my problem is the classic case of switch bouncing. In my scenario, a person is not pressing and then releasing a button.

My switch is an impact sensor which is a normally open, cantilever switch. When the sensor is physically accelerated to a certain G level, the cantilever bends and makes contact. Consider dropping a hammer onto a steel plate. The impact force generates a transient response similar to a damped sinusoidal function.

As the G forces rise and fall, the sensor makes and breaks contact multiple times until the G forces are no longer large enough to close the switch. What I want to do is take the leading edge of the first contact and turn that into a 40 ms TTL input into a micro-controller (Arduino), but ignore the subsequent contact events that occur over the next 100-150 miliseconds.
 

tracecom

Joined Apr 16, 2010
3,944
Is there no way to accomplish this in software? Most μCs provide a "button" function that does exactly what you want.

I can post a hardware no-bounce circuit if you want.
 

crutschow

Joined Mar 14, 2008
34,285
You could use two 555 timers (or one 556). Wire the first as a one-shot to give a 200ms pulse (or however long to you want to ignore subsequent pulses). Connect the output of this through an inverter (transistor or logic) and RC differentiator (RC of 1ms or so) to trigger the second 555 wired as a 40ms one-shot to go to the micro.

Note that 555's trigger on the falling edge of the input so the output from the sensor must be negative going (or inverted if necessary).
 

Thread Starter

cce1911

Joined Jun 11, 2013
41
Crutschow, I went down that path when I was trying to solve this problem with a piezo sensor, but I got in over my head real quick.

Can you point me to an example circuit?
 

AnalogKid

Joined Aug 1, 2013
10,987
http://www.electronics-tutorials.ws/waveforms/monostable.html

About half way down this page is a schematic for the classic TTL monostable. The input and output polarities match your original circuit. Unlike real TTL, the transition voltage for CMOS is very loosely defined and wanders with temperature. Still, this circuit should meet the requirements you've given us with a little adjusting. The output period is approx 0.7 x R x C. For 40 ms I'd start with 4.7 uF and 18K, and adjust from there.

Some people worry about the capacitor driving the U2 inputs above Vcc at the end of the timing cycle. To avoid this you can put a shottkey diode in parallel with Rt, with the cathode tied to Vcc.

ak
 

Thread Starter

cce1911

Joined Jun 11, 2013
41
Crutschow, YES! This looks like what I need!

Let me study it and see if I can get the spice model working with a 556 dual.
Thank you for your help.
 

Thread Starter

cce1911

Joined Jun 11, 2013
41
Crutschow, I realize that the 555 triggers on the falling side of the input pulse, but I can't seem to model that correctly. If I tweak your pulse:
PULSE(0 5 20ms 0 0 10ms 20ms 7)

The 555 triggers at t=0

How do you simulate that?
 

crutschow

Joined Mar 14, 2008
34,285
Crutschow, I realize that the 555 triggers on the falling side of the input pulse, but I can't seem to model that correctly. If I tweak your pulse:
PULSE(0 5 20ms 0 0 10ms 20ms 7)

The 555 triggers at t=0

How do you simulate that?
I don't quite understand you question. :confused: My simulation used a PULSE(5 0 20ms 0 0 10ms 20ms 7) so that it triggers on the first falling edge which is the start of the pulse). If you need it to trigger on the rising edge then you need to add a inverter at the input.

Did you also select the "Start External DC Supply Voltages at 0V" box (startup in the .tran simulation). Otherwise the sudden application of power will sometimes trigger the 555 a the start of the simulation.
 

Thread Starter

cce1911

Joined Jun 11, 2013
41
I don't quite understand you question. :confused: My simulation used a PULSE(5 0 20ms 0 0 10ms 20ms 7) so that it triggers on the first falling edge which is the start of the pulse). If you need it to trigger on the rising edge then you need to add a inverter at the input.

Did you also select the "Start External DC Supply Voltages at 0V" box (startup in the .tran simulation). Otherwise the sudden application of power will sometimes trigger the 555 a the start of the simulation.
When I unchecked the "Start External DC Supply Voltages at 0V" option I got the results I expected.

What component would you suggest for the inverter?

Finally, as I study your model, I'm not sure how to reset it for the next event.
 
Last edited:

crutschow

Joined Mar 14, 2008
34,285
................................
What component would you suggest for the inverter?

Finally, as I study your model, I'm not sure how to reset it for the next event.
The inverter is the transistor circuit between the first and second 555.

You don't have to reset it. It's ready for the next pulse after the first 555 times out (a little over 200ms in my design).
 

Thread Starter

cce1911

Joined Jun 11, 2013
41
Thanks for the input guys. I have the circuit working great on my scope. (see the attachment) When I impact the sensor, I get a nice 30ms pulse output at 5 vdc. However, when I hook the output up to an input pin on my Netduino board, it does not cause an interrupt. If I hook my oscope up, while the output is wired to the Netduino board, it only shows a 150mv pulse.

What am I missing here? Do I need to be using a relay of some sort to get more current into the board?
 

Attachments

Top