Bouncing switch problem

Discussion in 'The Projects Forum' started by cce1911, Mar 25, 2014.

  1. cce1911

    Thread Starter Member

    Jun 11, 2013
    41
    0
    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.
     
  2. AnalogKid

    Distinguished Member

    Aug 1, 2013
    4,532
    1,249
    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
     
  3. crutschow

    Expert

    Mar 14, 2008
    13,003
    3,232
    Here are some examples of debounce circuits.
     
  4. bertz

    Member

    Nov 11, 2013
    238
    31
  5. AnalogKid

    Distinguished Member

    Aug 1, 2013
    4,532
    1,249
    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
     
  6. cce1911

    Thread Starter Member

    Jun 11, 2013
    41
    0
    Thanks for the input guys. I'm reviewing the suggested material now.
     
  7. cce1911

    Thread Starter Member

    Jun 11, 2013
    41
    0
    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.
     
  8. tracecom

    AAC Fanatic!

    Apr 16, 2010
    3,869
    1,393
    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.
     
  9. crutschow

    Expert

    Mar 14, 2008
    13,003
    3,232
    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).
     
  10. cce1911

    Thread Starter Member

    Jun 11, 2013
    41
    0
    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?
     
  11. AnalogKid

    Distinguished Member

    Aug 1, 2013
    4,532
    1,249
    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
     
  12. crutschow

    Expert

    Mar 14, 2008
    13,003
    3,232
  13. cce1911

    Thread Starter Member

    Jun 11, 2013
    41
    0
    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.
     
  14. crutschow

    Expert

    Mar 14, 2008
    13,003
    3,232
    Do you have a 556 model? Otherwise, other than pin-out, two 555s should simulate the same as one 556.
     
  15. cce1911

    Thread Starter Member

    Jun 11, 2013
    41
    0
    Yes, I have a 556 model for LTSpice.
     
  16. cce1911

    Thread Starter Member

    Jun 11, 2013
    41
    0
    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?
     
  17. crutschow

    Expert

    Mar 14, 2008
    13,003
    3,232
    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.
     
  18. cce1911

    Thread Starter Member

    Jun 11, 2013
    41
    0
    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: Mar 31, 2014
  19. crutschow

    Expert

    Mar 14, 2008
    13,003
    3,232
    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).
     
  20. cce1911

    Thread Starter Member

    Jun 11, 2013
    41
    0
    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?
     
Loading...