Eliminating Switch Bounce with a Debounce Circuit

Поделиться
HTML-код
  • Опубликовано: 8 дек 2016
  • In video we discuss what is switch bounce and how to implement a simple and low cost debounce circuit to eliminate switch bounce.

Комментарии • 43

  • @Andreas_Hopf
    @Andreas_Hopf 5 лет назад +6

    Excellent visual no-nonsense explanation. No silly trailers, animations, music, etc. Just the content, as it should be.

  • @bob456fk6
    @bob456fk6 4 года назад +2

    This is a very good tutorial for debouncing a reed switch.
    As the reed wears, it's bounce may get worse and the software can check for abnormal readings to warn that a reed is wearing out. Reed switches typically bounce less than 1 msec when they are new.
    For a 5V supply, almost any silicon diode could be used. For a 3.3V supply, you may want to use a schottky diode for it's lower voltage drop. Someone mentioned putting a small resistor in series with the capacitor to limit the surge current when the switch closes, that's a good idea. A few hundred ohms will help. You don't want the rise time of the input to be too long because some logic circuits go crazy if the input slope is too slow. As the input voltage passes through the threshold, the input circuit may act like an amplifier and respond to noise on the input signal, thus causing extraneous transitions, just like switch bounce inside the micro chip.
    The resistor to ground, 1K in this case, can be larger if you want to use a smaller cap. It's limited by the current that flows from the digital input pin. Check the data sheet for this current value and make sure the voltage equal to the (leakage current*R_to_ground) is well below the threshold for a logic zero at the input.

  • @janhellstrom4165
    @janhellstrom4165 4 года назад +2

    Great explantion, I like your videos!
    One note, the peak current can be fairly high with a big capacitor. It would be be a good idea to include a resistor in series with the switch.

  • @ser7ser7i
    @ser7ser7i 5 лет назад +2

    What a great lesson, thank you, peace and love.

  • @greggreno
    @greggreno 3 года назад +1

    Thank you - this design eliminated the bounce for me, although I had to replace the 1uF capacitor with a 100nF ceramic capacitor to make it work well. To test, I used an ESP32 with a small OLED display to show a press counter. Every time the button was pressed, it incremented the counter. Without this circuit, it would increment the count multiple times for each button press. Now it correctly increments one time for each button press. I figure now that I have the button debounce working, it should work the same with the Inspeed Wind Speed sensor I have on order. Maybe it's overkill, but I'm also using software debounce logic to ignore extra triggers within a 10ms time span.

  • @uzairbukhari99
    @uzairbukhari99 5 лет назад +2

    Best explanation ever!

  • @YO2LYP
    @YO2LYP 7 лет назад +2

    Very useful, I bought also a anemometer, a rain gauge and a wind vane (I think this is the right name for that device pointing to wind direction). All of them are using reed relays, I"ll try the hardware method you just presented to connect to digital inputs. Thank :)

  • @rudycahyanto9865
    @rudycahyanto9865 3 года назад

    Ilmu yg bermanfaat bagi kita semua . mantap kawan 👍

  • @hubercats
    @hubercats 3 года назад +1

    Very helpful video. Thank you!

  • @bkredek
    @bkredek 4 года назад

    Subscribed! Great lesson!

  • @PiGoElectronics
    @PiGoElectronics 7 лет назад

    I would add an Schmitt-trigger inverter which outputs a nice signal. But some Schmitt-triggers inverts the output. In some cases this inverting feature is interresting. For instance, when you use an I/O Expander.

  • @shupesmerga4694
    @shupesmerga4694 4 года назад

    I'm here because of debounce in computer programming, now I feel I must study electrical switches before I fully understand debounce in computer programming.

  • @rpasco9352
    @rpasco9352 2 года назад

    Why are there no switch(es) debouncer(s)/switch(es)+debouncer(s) modules available ANYWHERE ???

  • @KonradZielinski
    @KonradZielinski 4 года назад

    That is the simplest denounce circuit I've found so far. Previously the ones I found used either a 555 timer or a Schmitt trigger. Both of which seemed like overkill to me.

  • @STEVE_C_1369
    @STEVE_C_1369 3 месяца назад +1

    I have a video controller for my computer that,externally,looks like an XBox controller.
    During the game,(Halo CE for PC), when I press the button to start the elevator,the switch often times bounces and I have to hit the button a couple times until it settles and the elevator moves.
    Im thinking about using a ceramic 0.1 microF cap in line of the feed to increase the time on duration of the connection.Sound good?

    • @ForceTronics
      @ForceTronics  3 месяца назад +1

      That sounds like it might solve your issue. But I don't know how those buttons are implemented and the circuits they control so I can't say definitively if that will solve your problem

    • @STEVE_C_1369
      @STEVE_C_1369 3 месяца назад +1

      @@ForceTronics Thanks for your reply. If we both think it may (but neither are sure right now,) I think Ill take the shot ..give it a chance.😁👍

    • @ForceTronics
      @ForceTronics  3 месяца назад +1

      @@STEVE_C_1369 Let me know how it goes!

    • @STEVE_C_1369
      @STEVE_C_1369 3 месяца назад

      @@ForceTronics Will do.

  • @mattivirta
    @mattivirta 11 месяцев назад

    i have 2 problem how i can make debounc pcb to, cnc limit switch, C and R size NO limit switch. 12V, and second problem how make promixity sensor, sense metal, need calculate spindle speed, prox 12V, data out and arduino nano need read this but need 5V max input to nano, speed 0-30K 2x/rev=60K trick to secod ? not need debounc and need convert 12V sensor data to 5V to arduino. i not understand what need do.

  • @PerchEagle
    @PerchEagle 5 лет назад

    Yes, the capacitor just worked well on the logic analyzer, without the capacitor, there's a lot of bouncing! Now pretty much the bounce problem is minimized to a good level, but the successive reads of the input which of course throttle the input count, I just want to count only 1 tick at a time.

    • @ForceTronics
      @ForceTronics  5 лет назад

      I am not exactly sure what your question or comment is here. You want to trigger off of the rising or falling edge so each pulse is only counted once

    • @PerchEagle
      @PerchEagle 5 лет назад

      @@ForceTronics Yes, exactly. The microcontroller is so fast that it count a moving object in front of the IR module 10 times in one go. I want it to count only one each time.

    • @ForceTronics
      @ForceTronics  5 лет назад

      Most microcontrollers allow you to setup an interrupt off the rising or falling edge of a pulse that way no matter how long the pulse is you only count it once. If you are using a polling method to count a pulse then you wait until you measure first a low to high transition and then a high to low transition before you count it as a pulse. If you just try to measure "highs" then you will count the same pulse multiple times

  • @patrickmclaughlin6013
    @patrickmclaughlin6013 3 года назад

    this has built in pull-down too??
    have to have a think about how to make it in pull-up ...
    I'm new to arduino so sorry if I get this confused

  • @jackchild9107
    @jackchild9107 3 года назад

    Problem here: using a 10mfd cap and a 1n914 diode, the rapid current flow that occurs when the switch is closed causes a Reset of the arduino nano. The 5v regulator is not good enough to cope with the negative spike caused by unrestricted charging of the capacitor. I also do not understand why you are using the two resistor voltage divider joined at the anode to discharge the capacitor.

  • @jakewtw74
    @jakewtw74 3 года назад

    hi, i have bounce on my xbox controller uttons. is there any debounce software code i can use to eliminate it?

  • @PiGoElectronics
    @PiGoElectronics 7 лет назад +1

    When you keep the swith pressed, no current will flow trough the diode. If you used a LED instead of the diode the LED would turn off. Which circuit would you build if you had to use a LED that goes ON when button is cept pressed?

    • @ForceTronics
      @ForceTronics  7 лет назад

      If you are just trying to turn an LED on or off then switch bounce is not an issue because the human eye wouldn't even notice it. So for an LED I would just use a switch and a current limiting resistor

    • @PiGoElectronics
      @PiGoElectronics 7 лет назад +1

      No, I wouldn't reply such if I only wished to turn on or off a LED.
      I wanne debounce but also wanne see a LED ON when button is pressed and OFF when the button released

    • @ForceTronics
      @ForceTronics  7 лет назад +1

      Ok, I see. You should be able to use the LED in place of the diode. I guess you may need to ensure that the LED doesn't have a high voltage drop that takes you below the voltage threshold level of the digital input. Its a good idea!

  • @philbob9638
    @philbob9638 6 лет назад +1

    Great explanation but I'm still confused about why the diode is necessary?

    • @ForceTronics
      @ForceTronics  6 лет назад +4

      It ensures that the capacitor only discharges through the resistor network. While the switch is bouncing, if the diode was not there the cap could start discharging when the switch bounce is in the open position

    • @philbob9638
      @philbob9638 6 лет назад

      Ok, Thanks for the reply!

    • @sondaubacvlog
      @sondaubacvlog 3 года назад

      @@ForceTronics could you make it more clear, thank you

  • @yadusolparterre
    @yadusolparterre 4 года назад

    I don't understand why you need the 1k resistance in the first place.
    Also, why have you not placed the capacitor closer to the power supply? It seems to me that the way you have done it, the current will be flowing in the opposite direction while bouncing. Isn't that a problem?

    • @hubercats
      @hubercats 3 года назад

      Hi Yad - I believe the 1K resistor is in the circuit to hold the interrupt pin at ground level when the switch is open, and to provide a path for the capacitor to discharge following a switch closure/opening cycle. Also, the input impedance of the pin is likely high enough that charge cannot bleed off via that path.

  • @bt9604
    @bt9604 5 лет назад

    What's meant by switch bouncing??

    • @ForceTronics
      @ForceTronics  5 лет назад +1

      I believe I explain it in the video. It is a phenomenon with mechanical switches that when they close fast they will go back and forth from closing and opening due to the force of closing this is called "switch bounce" and it happens in milli or micro seconds so a human does not notice but a MCU will.

    • @hanswurst9866
      @hanswurst9866 5 лет назад

      @@ForceTronics What is a MCU? :D

  • @harviecz
    @harviecz 6 лет назад +1

    Why debounce in hardware when you can debounce in software with like 6 lines of code? (or just use ready made library if you are using arduino)

    • @OkashiiKuusou
      @OkashiiKuusou 5 лет назад +1

      interrupts on button presses can't do this