Eliminating Switch Bounce with a Debounce Circuit

  Рет қаралды 30,030

ForceTronics

ForceTronics

Күн бұрын

Пікірлер: 43
@Andreas_Hopf
@Andreas_Hopf 5 жыл бұрын
Excellent visual no-nonsense explanation. No silly trailers, animations, music, etc. Just the content, as it should be.
@bob456fk6
@bob456fk6 5 жыл бұрын
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 5 жыл бұрын
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.
@greggreno
@greggreno 3 жыл бұрын
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.
@rudycahyanto9865
@rudycahyanto9865 4 жыл бұрын
Ilmu yg bermanfaat bagi kita semua . mantap kawan 👍
@ser7ser7i
@ser7ser7i 5 жыл бұрын
What a great lesson, thank you, peace and love.
@YO2LYP
@YO2LYP 8 жыл бұрын
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 :)
@uzairbukhari99
@uzairbukhari99 5 жыл бұрын
Best explanation ever!
@hubercats
@hubercats 3 жыл бұрын
Very helpful video. Thank you!
@PiGoElectronics
@PiGoElectronics 8 жыл бұрын
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.
@KonradZielinski
@KonradZielinski 5 жыл бұрын
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.
@rpasco9352
@rpasco9352 2 жыл бұрын
Why are there no switch(es) debouncer(s)/switch(es)+debouncer(s) modules available ANYWHERE ???
@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
@bkredek
@bkredek 4 жыл бұрын
Subscribed! Great lesson!
@PerchEagle
@PerchEagle 6 жыл бұрын
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 6 жыл бұрын
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 6 жыл бұрын
@@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 6 жыл бұрын
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
@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.
@STEVE_C_1369
@STEVE_C_1369 6 ай бұрын
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 6 ай бұрын
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 6 ай бұрын
@@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 6 ай бұрын
@@STEVE_C_1369 Let me know how it goes!
@STEVE_C_1369
@STEVE_C_1369 6 ай бұрын
@@ForceTronics Will do.
@PiGoElectronics
@PiGoElectronics 8 жыл бұрын
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 8 жыл бұрын
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 8 жыл бұрын
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 8 жыл бұрын
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!
@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.
@jakewtww
@jakewtww 4 жыл бұрын
hi, i have bounce on my xbox controller uttons. is there any debounce software code i can use to eliminate it?
@mattivirta
@mattivirta Жыл бұрын
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.
@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.
@philbob9638
@philbob9638 7 жыл бұрын
Great explanation but I'm still confused about why the diode is necessary?
@ForceTronics
@ForceTronics 7 жыл бұрын
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 7 жыл бұрын
Ok, Thanks for the reply!
@sondaubacvlog
@sondaubacvlog 3 жыл бұрын
@@ForceTronics could you make it more clear, thank you
@bt9604
@bt9604 6 жыл бұрын
What's meant by switch bouncing??
@ForceTronics
@ForceTronics 6 жыл бұрын
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 жыл бұрын
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 жыл бұрын
interrupts on button presses can't do this
Rotary Encoder (KY-040) Debounce Circuit Tutorial
15:03
ForceTronics
Рет қаралды 19 М.
How to Fight a Gross Man 😡
00:19
Alan Chikin Chow
Рет қаралды 18 МЛН
Multimeters -  The Complete Guide
59:01
DroneBot Workshop
Рет қаралды 58 М.
EEVblog #600 - OpAmps Tutorial - What is an Operational Amplifier?
49:32
Chip Tips #1: Debouncing
18:38
Robert Baruch
Рет қаралды 32 М.
Digital Electronics: Debouncing a Push Button Switch (SPST)
14:12
Derek Molloy
Рет қаралды 150 М.
✔ Multitask Arduino with State Machines (& Switch Debouncing)
30:42
Normal Universe - Chris Guichet
Рет қаралды 69 М.
The RS-232 protocol
26:10
Ben Eater
Рет қаралды 858 М.
Rotary Encoders and Microcontrollers (e.g. Arduino) - My Way …
25:13
Robert's Smorgasbord
Рет қаралды 4 М.