Connect with us

Simplest debounce for NO switch?

Discussion in 'Electronic Design' started by SA Dev, Feb 24, 2004.

Scroll to continue with content
  1. SA Dev

    SA Dev Guest

    Hi,

    I currently have a normally open switch that I need to debounce. It needs
    to be connected to a device that expects normally open, and then two wires
    shorted when the button is pressed. What is the easest/simplest way to do
    this?

    Thanks,

    SA Dev
     
  2. mikem

    mikem Guest

    What is the open-circuit voltage across the switch?

    What is the current that flows through the closed switch?

    MikeM
     
  3. SA Dev

    SA Dev Guest

    Hi Mike,
    <1 mA

    Thanks!!!

    SA Dev
     
  4. mikem

    mikem Guest

    The best way to debounce a switch is to use a form C switch, and
    cross-connected logic gates to create a Set-Reset Flip-Flop.

    In your case, you have only a form A switch. Your pullup resistor is
    something like 5K. (5v/1mA)

    I'm assuming that the voltage across the switch goes into a CMOS input
    with a logic threshold of ~2V.

    Most switches "make" multiple times for durations of 10 to 250us or so
    with "breaks" of durations of ~100us of when pushed.

    Attached is an LTSpice simulation which uses an RC network to establish
    some relevant time constants which filter out multiple transitions. This
    is not 100%; but is better than nothing. Run the simulation and look at
    Node S.

    If you have a better guess at the switch bounce behavior, then you can
    edit the PWL. The 47 Ohm resistor is there to limit the capacitor
    discharge current to prevent damaging the switch.

    MikeM, PhD EE


    --------- Cut and paste into a file called DeBounce.asc -----------
    Version 4
    SHEET 1 2164 680
    WIRE -176 240 -176 416
    WIRE -176 416 -80 416
    WIRE 96 416 96 304
    WIRE -128 64 -176 64
    WIRE -176 64 -176 160
    WIRE -48 64 -16 64
    WIRE 96 64 96 96
    WIRE 96 176 96 224
    WIRE -16 384 -16 416
    WIRE -16 416 96 416
    WIRE 48 240 -80 240
    WIRE -80 240 -80 416
    WIRE -80 416 -16 416
    WIRE -16 304 -16 288
    WIRE -16 288 0 288
    WIRE 96 64 144 64
    WIRE -16 64 96 64
    WIRE -16 416 -16 448
    WIRE -16 96 -16 64
    WIRE -16 160 -16 192
    WIRE 224 -32 96 -32
    WIRE 96 -32 96 64
    WIRE 288 -32 432 -32
    WIRE 0 288 48 288
    FLAG 144 64 s
    IOPIN 144 64 Out
    FLAG -16 192 0
    FLAG -16 448 0
    FLAG 432 -32 B
    IOPIN 432 -32 Out
    FLAG 0 288 c
    SYMBOL res 80 80 R0
    SYMATTR InstName R1
    SYMATTR Value 47
    SYMBOL Misc\\battery -176 144 R0
    WINDOW 123 0 0 Left 0
    WINDOW 39 0 0 Left 0
    SYMATTR InstName V1
    SYMATTR Value 5
    SYMBOL sw 96 208 R0
    SYMATTR InstName S1
    SYMATTR Value msw
    SYMBOL voltage -16 288 R0
    WINDOW 3 126 68 Left 0
    WINDOW 123 0 0 Left 0
    WINDOW 39 0 0 Left 0
    SYMATTR Value PWL(0 0 99u 0 100u 1 200u 1 205u 0 308u 0 310u 1 510u 1
    515u 0 718u 0 720u 1 822u 1 825u 0 928u 0 930u 1 1200u 1 1205u 0 1310u 0
    1330u 1 1425u 0 14000u 1)
    SYMATTR InstName V2
    SYMBOL res -32 48 R90
    WINDOW 0 0 56 VBottom 0
    WINDOW 3 32 56 VTop 0
    SYMATTR InstName R2
    SYMATTR Value 5k
    SYMBOL cap -32 96 R0
    SYMATTR InstName C1
    SYMATTR Value 0.22µ
    SYMBOL Digital\\buf1 224 -96 R0
    WINDOW 3 22 98 Left 0
    SYMATTR InstName A1
    SYMATTR Value Vhigh=5
    TEXT 214 402 Left 0 !.tran 3m
    TEXT 176 312 Left 0 !.model msw SW(Ron=0.1 Roff=100Meg Vt=0.5)
    TEXT 224 64 Left 0 ;Switch Debounce simulation
    TEXT 224 112 Left 0 ;Note: R2 is the pullup\n R1 limits
    discharge current\n Node S goes to the CMOS input
     
  5. mikem

    mikem Guest

    The best way to debounce a switch is to use a form C switch, and
    cross-connected logic gates to create a Set-Reset Flip-Flop.

    In your case, you have only a form A switch. Your pullup resistor is
    something like 5K. (5v/1mA)

    I'm assuming that the voltage across the switch goes into a CMOS input
    with a logic threshold of ~2V.

    Most switches "make" multiple times for durations of 10 to 250us or so
    with "breaks" of durations of ~100us of when pushed.

    Attached is an LTSpice simulation which uses an RC network to establish
    some relevant time constants which filter out multiple transitions. This
    is not 100%; but is better than nothing. Run the simulation and look at
    Node S.

    If you have a better guess at the switch bounce behavior, then you can
    edit the PWL. The 47 Ohm resistor is there to limit the capacitor
    discharge current to prevent damaging the switch.

    MikeM, PhD EE


    --------- Cut and paste into a file called DeBounce.asc -----------
    Version 4
    SHEET 1 2164 680
    WIRE -176 240 -176 416
    WIRE -176 416 -80 416
    WIRE 96 416 96 304
    WIRE -128 64 -176 64
    WIRE -176 64 -176 160
    WIRE -48 64 -16 64
    WIRE 96 64 96 96
    WIRE 96 176 96 224
    WIRE -16 384 -16 416
    WIRE -16 416 96 416
    WIRE 48 240 -80 240
    WIRE -80 240 -80 416
    WIRE -80 416 -16 416
    WIRE -16 304 -16 288
    WIRE -16 288 0 288
    WIRE 96 64 144 64
    WIRE -16 64 96 64
    WIRE -16 416 -16 448
    WIRE -16 96 -16 64
    WIRE -16 160 -16 192
    WIRE 224 -32 96 -32
    WIRE 96 -32 96 64
    WIRE 288 -32 432 -32
    WIRE 0 288 48 288
    FLAG 144 64 s
    IOPIN 144 64 Out
    FLAG -16 192 0
    FLAG -16 448 0
    FLAG 432 -32 B
    IOPIN 432 -32 Out
    FLAG 0 288 c
    SYMBOL res 80 80 R0
    SYMATTR InstName R1
    SYMATTR Value 47
    SYMBOL Misc\\battery -176 144 R0
    WINDOW 123 0 0 Left 0
    WINDOW 39 0 0 Left 0
    SYMATTR InstName V1
    SYMATTR Value 5
    SYMBOL sw 96 208 R0
    SYMATTR InstName S1
    SYMATTR Value msw
    SYMBOL voltage -16 288 R0
    WINDOW 3 126 68 Left 0
    WINDOW 123 0 0 Left 0
    WINDOW 39 0 0 Left 0
    SYMATTR Value PWL(0 0 99u 0 100u 1 200u 1 205u 0 308u 0 310u 1 510u 1
    515u 0 718u 0 720u 1 822u 1 825u 0 928u 0 930u 1 1200u 1 1205u 0 1310u 0
    1330u 1 1425u 0 14000u 1)
    SYMATTR InstName V2
    SYMBOL res -32 48 R90
    WINDOW 0 0 56 VBottom 0
    WINDOW 3 32 56 VTop 0
    SYMATTR InstName R2
    SYMATTR Value 5k
    SYMBOL cap -32 96 R0
    SYMATTR InstName C1
    SYMATTR Value 0.22µ
    SYMBOL Digital\\buf1 224 -96 R0
    WINDOW 3 22 98 Left 0
    SYMATTR InstName A1
    SYMATTR Value Vhigh=5
    TEXT 214 402 Left 0 !.tran 3m
    TEXT 176 312 Left 0 !.model msw SW(Ron=0.1 Roff=100Meg Vt=0.5)
    TEXT 224 64 Left 0 ;Switch Debounce simulation
    TEXT 224 112 Left 0 ;Note: R2 is the pullup\n R1 limits
    discharge current\n Node S goes to the CMOS input
     
  6. Tim Wescott

    Tim Wescott Guest

    -- snip --

    A simple low-pass into a gate can still bounce, unless you go into a schmidt
    trigger. This can cause many long and frustrating evenings.
     
  7. Tim Wescott

    Tim Wescott Guest

    If you have no microprocessor the electrically simplest debounce is probably
    a low-pass filter into a schmidt trigger. Beyond that there's scads of
    electronic debounce schemes to be found on the net.

    If you're feeding a microprocessor the (electrically) simplest debounce is
    to do it in software. This can be as easy as sampling the switch at an
    interval longer than the switch bounce time, with complexity increasing from
    there. The best software debounce routines will monitor the switch state,
    keeping track of the state, the last state and the time from the last
    transition, and will (a) give you a switch event right when it first
    occurrs, and (b) not give you any false events.
     
  8. CBarn24050

    CBarn24050 Guest

    a 555 and capacitor is quite reliable, a quick search should find a circuit.
     
  9. Fred

    Fred Guest

    Is there a response and recovery time spec for this.

    I recall making a circuit similar to this for electronic ignition where I
    still used the contacts. I used a diode to make the break part very fast
    with a parallel resistor for a slow "recovery". This coupled with a
    capacitive filter and a Schmitt trigger ensured a clean no bounce output.
    It worked very well.

    Your circuit is easier where the contacts make you can quickly discharge a
    capacitor through a diode and any bounce could only bleed a small current
    (through a resistor in parallel with the diode) to try to charge the
    capacitor up again.

    Attach this to a Schmitt trigger gate input and problem solved.
     
  10. SA Dev

    SA Dev Guest

    Hi Mike,
    Thanks--I appreciate the info!!!

    SA Dev
     
  11. VCC Schmitt Trigger
    + T (eg, 74HC14)
    | --- |\
    -------o o----+-----+-----------| >O-
    | | |/
    .-. |
    | | ---
    R | | --- C
    '-' |
    | |
    --------------+-----+
    |
    ===
    GND

    Make RC >> bounce time (usually around 1ms)

    created by Andy´s ASCII-Circuit v1.24.140803 Beta www.tech-chat.de

    If you are paranoid about your switches getting welded shut, you can add a
    resistor between Vcc and the button. I wouldn't bother. Good values are
    0.1uF, and 10k.

    Regards,
    Bob Monsen
     
  12. I think I'd put the resistor in. That circuit tries to do nasty things
    to the power supply.

    Best regards,
    Spehro Pefhany
     
  13. roma

    roma Guest

Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-