The Best Possible Cheap and Easy Switch Debounce and Noise Immunity Technique - Simply Put

แชร์
ฝัง
  • เผยแพร่เมื่อ 16 มิ.ย. 2024
  • All you need to debounce a switch is a resistor and a capacitor, but even though it works generally just fine, it isn't as good as I'd like it. By attaching that debouncer to a 555 timer you not only sharpen the signal's rise and fall to the point that it's almost impossible for any microcontroller to misread it, you also gain strong noise immunity because of the timer's 2/3 and 1/3 Vcc activation thresholds, making any physical switch as crisp and clean as a microcontroller-generated signal itself.
    Digital Logic Playlist: • Digital Logic
    You can join me on Discord as well! -- / discord
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 82

  • @joelstyer5792
    @joelstyer5792 ปีที่แล้ว +12

    A nice technique and I too am a big believer in adding the resistor on the switch. Eventually, the massive currents, even as brief as they are, will pit the plating on the switch contacts. I typically use 100 ohm but anything from 10 ohm to about 1/10th the pullup (or pull down) resistor will work fine. I've seen 220 ohm used a lot too.
    But as others have pointed out below, I feel the Hex Schmitt Trigger IC makes more sense in many environments. I have been using it for almost five decades in industrial designs as well as hobby use for myself. You get up to six channels or can use any leftover inverters to invert the switch signal or even use them as general-purpose inverters in other parts of the circuit (they are a tad slower than a typical inverter using the same process however). And in the case of a CMOS Schmitt trigger, power consumption is very low, and they work well with 3.3V (and lower) logic. And they are very inexpensive, probably in the same cost area as a single 555 and likely cheaper than CMOS variants of the 555. On a CMOS IC like the 40106 or 74HC14, the very high input impedance allows for larger resistors and smaller capacitors. The same may apply to a CMOS 555. The Schmitt trigger also has a rail-to-rail output but of course a much lower logic low output current than the 555. And you only need a power supply bypass cap to use it (in addition to the 2R and 1C for each switch).
    I do of course agree that many times you have to use what you have, but for me, the Hex Schmitt Trigger is a required part to keep on hand in quantity. It is perhaps the most used logic part I have designed in for the past 40 years. In the hex format and the 1 ,2 and 3 gate Tiny Logic versions. It also makes for a very simple RC oscillator as well. But if the choice is available, I prefer to do debouncing in software when possible.
    One other thing to mention, switch bouncing will usually get much worse as a switch ages. While a new switch may complete bouncing within 10mS, a worn one might be 20 or 30mS. Beyond that, they are usually unusable. In an industrial product, switches get abused and evaluating product repairs has allowed me some great insight into just how noisy switches can get, which in turns has allowed me to fine tune debouncing over the years.
    Too often I see the RC or RRC circuit used with the switch fed into a standard (i.e. non Schmitt Trigger) input. While it may work in some cases, it is not a good practice. Most chips have a minimum rise time on the inputs (again, except for Schmitt Trigger inputs). Doing so can cause instability, can cause the input stage to oscillate or ring and can lead to excessive current consumption that can damage the input transistors in the chip. So, using a technique like shown will definitely make for a more robust circuit design and I would not consider that overkill.
    It is always good to hear a technique explained well with great examples of what is happening. I thought the explanations were very clear and concise. My only disagreement is the "Best Possible" part as I feel all the advantages of the Schmitt Trigger IC are better. My opinion of course. But it is still a great video!

  • @arthurharrison1345
    @arthurharrison1345 ปีที่แล้ว +4

    Many 555s make poor denouncers because, ironically, they may have ringing in the output switching transitions that will cause false triggering. The best debouncer is a switch with a
    pull-up (or pull-down) resistor, followed by a R-C integrator, followed by a hysteretic inverter such as one section of a CD40106 Schmitt trigger.

  • @Corei5n
    @Corei5n 10 วันที่ผ่านมา

    Omg, tysm for this vid, I was struggling with a push button bouncing a lot and this saved me :))

  • @marshallhaynes8658
    @marshallhaynes8658 3 ปีที่แล้ว

    Great Video! Very informative on first viewing, and I keep coming back for the simplified image near the beginning. Helpful stuff.

  • @dosbrodinhos
    @dosbrodinhos 2 ปีที่แล้ว

    Thank you for such detailed explanation!!! Now I understood the capacitor’s role ! Big shout from Brazil 🇧🇷

  • @GeekDetour
    @GeekDetour 3 ปีที่แล้ว

    Wow man, I’ve learned a lot today with this vídeo - thanks!!!

  • @francoisdastardly4405
    @francoisdastardly4405 ปีที่แล้ว +2

    Excellent explanation. I'm using 555 ic debouncer for many years in industrial heavy noise environments.

  • @parapos
    @parapos 4 ปีที่แล้ว +2

    great video, thank you.

  • @metalman5798
    @metalman5798 2 ปีที่แล้ว +2

    Love the way you are straight up with your knowledge and no bullshit and always want better first video of yours and I am not even to the point of owning an oscilloscope or anything more than a analog not so multi meter and I have a lot of things to study and learn but I have never been so informed about things that I was not aware I was curious about to this point but I’m liked and subscribed and hit the bell for all notifications and I can’t wait to get all of your research in such an amazing way to never waste our time with non logical things that make us feel like these are not happy times but you are definitely a breathe of fresh air in a muddled environment of TH-cam information air seems logical you shall be seeing me as I you! Thank you!

  • @NicholasRadina
    @NicholasRadina ปีที่แล้ว

    Excellent! Thank you!

  • @mad_circuits
    @mad_circuits 4 ปีที่แล้ว +10

    Great video! You just invented the Schmitt Trigger! :-) Just kidding. The 555 timer is able to act as a Schmitt Trigger, yes. But you can also use one (or two) inverters with Schmitt Triggers as available in 74HC14 or CD40106, by combining two inverters you have one single buffer behavior. In that ICs there are 6 of those available each.

    • @simplyput2796
      @simplyput2796  4 ปีที่แล้ว +9

      Yep, the schmitt trigger is something I investigated, but I'm a big fan of "easy to remember catch-all and simple" subcircuits, and the great thing about the timer is it's a single component with no accessories needed, and can even be reconfigured in some ways (such as changing comparison voltage range, and switching between active-low and active-high) STILL with no additional components. "Best" means different things to a hobbyist v. a professional.

    • @markcummings150
      @markcummings150 2 ปีที่แล้ว +5

      I’ve always used Schmitt trigger inverters as you suggested, but I totally overlooked the humble 555 which may be a bit smaller device if you’ve only got one switch to debounce. On the 74c14 you just bung it through a second inverter to get your non-inverted output back if that’s what you need. Size also depends on how many extra passives you need for a 555 vs. a 74c14.

    • @keiichicom7891
      @keiichicom7891 ปีที่แล้ว

      Does that really work:two Schmitt trigger inverters in a row or shouldn't you do this 74HC14-->74HC04 instead for a buffer?

  • @suzysheer66
    @suzysheer66 2 ปีที่แล้ว

    Thank you for the reminder, i used the 555 to clean up a 60hz signal, more then 2 decades ago. Old tech for the win!

  • @ericgroen253
    @ericgroen253 2 ปีที่แล้ว

    A very clear explanation! Keeping it simple and understandable.

  • @leandrosouza6188
    @leandrosouza6188 2 ปีที่แล้ว

    Cool. Thanks from Brazil.

  • @Karl_Levine
    @Karl_Levine 3 ปีที่แล้ว +1

    This is f****ng great. You're great! 👍

  • @ZookeeperJohnG
    @ZookeeperJohnG 2 ปีที่แล้ว

    Well explained!

  • @noname-gp6hk
    @noname-gp6hk ปีที่แล้ว

    Damn dude, thanks for the advice. This just solved a problem I was working on.

  • @k.chriscaldwell4141
    @k.chriscaldwell4141 2 ปีที่แล้ว

    Superb. Thanks.

  • @jessstuart7495
    @jessstuart7495 2 ปีที่แล้ว +1

    Schmitt trigger inverters are made to interface slow rising or slow falling signals to digital systems and have built-in hysteresis for better noise immunity at the logic thresholds. I use them for my switch debouncers.

  • @grzesiek1x
    @grzesiek1x ปีที่แล้ว +1

    for a shift register I recently created that simple solution with only capacitor and resistor is definetelly not enough! It counts at least a few pulses! To check I hooked it up into the pulse generator with very clean CMOS signal and it worked perfectly so I am looking for reaaaaaly precise solution at least similar to my keyboard I am writing it on ..

  • @keithking1985
    @keithking1985 4 ปีที่แล้ว

    putting this in my favorites

  • @RandallStephens397
    @RandallStephens397 ปีที่แล้ว

    I love your Data poster

  • @makerspace533
    @makerspace533 7 หลายเดือนก่อน

    The extra chip is not 3 cents. It's another point of failure, the cost of procurement, the cost of assembly, and the cost of board space. This can add up to quite a bit when you bring a product into production.

  • @joseponce6250
    @joseponce6250 ปีที่แล้ว

    thanks

  • @endspiel
    @endspiel 4 ปีที่แล้ว

    thx for this

  • @SteveRaynerMakes
    @SteveRaynerMakes ปีที่แล้ว

    A fantastic idea to slow things right down. It made it really easy to see what was happening. Is this the same idea as using a schmit trigger inverter?

  • @bertrandlapointe6479
    @bertrandlapointe6479 2 ปีที่แล้ว +1

    Pretty creative. I can hear many asking about why not using Schmitt triggers which might be valid question but if you have only one or 2 inputs to deal with , why not using 555. Many spares in the toolkit.

  • @vegansynths7757
    @vegansynths7757 ปีที่แล้ว

    Hahahahahahahahahahahahaha!!!! minute 10:30 best quote: "cuz that is just plain gross." You are fantastic. Truly.

  • @alvinp.schmitt5424
    @alvinp.schmitt5424 ปีที่แล้ว

    I like you. You are my type of guy and thanks for the debounce. In the future is there a barber found there?

  • @RicardoPenders
    @RicardoPenders 4 ปีที่แล้ว +4

    You can also use a schmitt trigger to debounce, it does the same as your example with the 555 chip

    • @simplyput2796
      @simplyput2796  4 ปีที่แล้ว

      Yep, but I like this because it's a little more flexible and configurable, plus easy to have a box of them lying around. Plus, you can just implement the 555 circuitry yourself externally, which I do to create a tri-state detecting output display board (to be shown in a future video).

    • @davidjones9730
      @davidjones9730 4 ปีที่แล้ว +1

      Simply Put ‘Implement externally’ can you explain what you mean? I used quad Schmitt triggers chips can debounce 4 switches with one chip.
      Like your videos, very clear explanations, thanks.

  • @dentakuweb
    @dentakuweb 4 ปีที่แล้ว +2

    I like using Schmitt trigger inverters for debouncing. You will get 6 of them in one 7414 or 40106 and it's simpler than setting up a 555.

    • @simplyput2796
      @simplyput2796  4 ปีที่แล้ว

      True, but 555s are cheap and incredibly flexible, and one of the first things a hobbyist will acquire a box of, whereas I still don't even own a schmitt trigger chip (eventually I will, of course). And they're fun!

    • @dentakuweb
      @dentakuweb 4 ปีที่แล้ว

      @@simplyput2796 Look around on some old electronic and you will probably find a 7414 because they're very common.
      They're also perfect for making very simple oscillators. All you need is a capacitor and a resistor/potentiometer.

  • @kaybhee6
    @kaybhee6 2 ปีที่แล้ว +1

    keen..... what about main power ac switch bounce,,, power supply ,,etc

  • @markchristophergemzon1052
    @markchristophergemzon1052 3 ปีที่แล้ว

    Thanks for this quick and informative lesson. Helped me solve my problem. Hmm, what is with the hole in your headphones?

    • @stevegoodjob5902
      @stevegoodjob5902 2 ปีที่แล้ว

      That's a trade mark! Which I approve 👍🏻

  • @axelanderson2030
    @axelanderson2030 8 หลายเดือนก่อน

    you are like electronics wizard lmao thanks for the videos
    btw your headphones have holes in them where the earcups should be

  • @garydirkse9900
    @garydirkse9900 ปีที่แล้ว

    Great video. Schmitt triggers and monos are good however, one engineer said two inverters, cross coupled input to output can eliminate the pull up/down resistor. Ofcourse, I have yet to find where I left his design. Often RC differentiators are used on timer trigger inputs. You could show us some spikes on that pretty Oscope.

    • @makerspace533
      @makerspace533 7 หลายเดือนก่อน

      That only works if you have a SPDT switch.

  • @dalenassar9152
    @dalenassar9152 2 ปีที่แล้ว

    At about timestamp 3:55 when you add the resistor, aren't you creating a voltage divider whenever the switch is closed, thus bringing the logic low level output a wee bit high?

  • @sadface7457
    @sadface7457 4 ปีที่แล้ว +1

    Initially, I though the debound signal was caused by the conservation of momentum and the coefficient of restitution between the surfaces. Though after some contemplation it would appear that the noise comes from dielectric breakdown between contacts, as the switch closes there are tiny arcs between them. The sparking allows the switch temporarily discharge, which decreases the field as charge is depletes.

    • @simplyput2796
      @simplyput2796  4 ปีที่แล้ว +3

      Oh that's definitely a chunk of it, but there're a whole host of things that can cause a goofy signal. Use two alligator clips as a switch, hold them tightly together, and then rub them together without breaking contact, and you'll get a horrible waveform. Contact bouncing is the electronic equivalent of a seizure.

  • @keithking1985
    @keithking1985 4 ปีที่แล้ว

    im really glad you made this video because iv came across this problem before giving me false positives when trying to turn things off and on.. can't remember what it was doing it on it was before i started learning this stuff. by the way that pure genius using the trigger & the threshold pins on the 555. . YOU SHOULD DONATE YOUR BRAIN TO SCIENCE..((& how doesn't have a 555 in their parts box)).. oh & ya know how you said that made you happy!! it made me HAPPY TOO. class idea, & class video : )
    P.S. ya hook up pin 8 & 1 on the 555 to power it yeah?? "I know the answer is yes but i have a habit of doubting myself alot". which i should stop doing!! thanks again best you-tuber without a doubt ; )

    • @simplyput2796
      @simplyput2796  4 ปีที่แล้ว

      You'd have to refer to your datasheet. I'd never trust one universal "this is always pin X no matter what" no matter how old the chip design is.

    • @keithking1985
      @keithking1985 4 ปีที่แล้ว

      @@simplyput2796 is that the 555 datasheet your referring to???

    • @simplyput2796
      @simplyput2796  4 ปีที่แล้ว

      Yes, look at the top of your chip and note down the actual part number (NE555P for the ones I have) and look up the specific datasheet (e.g., google "ne555p datasheet pdf") to double check. You never know when you'll end up with some random chinese knockoff that moved the pins around.

    • @keithking1985
      @keithking1985 4 ปีที่แล้ว

      @@simplyput2796 thanks for that bud!! my 555's are "NE555P" too.. ill do that anymore!! look up the datasheet for any chip i get and not take it for granted that it is just generic!! so thanks again, your the best : )
      P.S. whats your first name by the way( you don't have to let me know if you don't want, or if you prefer to keep privet. i would understand that & i wouldn't take it bad if that's the case)

  • @garydirkse9900
    @garydirkse9900 ปีที่แล้ว

    Found the info on the hyper quick, 10 ns, debouncer using 74LS inverters. must test and comment again with credit for design engineer and editor etc. later

  • @adrianw2972
    @adrianw2972 ปีที่แล้ว

    Hex Schmitt? Cheaper, more in a package, also with built in hysteresis, probably has lower power needs too.
    Interesting though, and a good tutorial on contact mechanics/behaviour.
    Personally, I denounce in code, never seen an issue.

  • @arpitsahni7262
    @arpitsahni7262 3 ปีที่แล้ว +1

    Can we use Schmitt trigger here?

  • @winsrrow8125
    @winsrrow8125 2 ปีที่แล้ว

    So... Why don't use a schmitt trigger chip directly? If i remember correctly the cd40106 its a inverting 6 schmitt trigger chip, and works well as far as i tested.

  • @AnimilesYT
    @AnimilesYT 2 ปีที่แล้ว

    Do I need a 555 timer for every button? I want to create something in a limited space, so I'm not sure if I have the space for a lot of those timers ':)

  • @radovanthefoley
    @radovanthefoley 2 ปีที่แล้ว

    Golden! Answer to my challenge: barebone rotary encoder in combination with arduiono interrupt. Only latching and pretty decent deadzone in between could save me. Many thanks!!!

    • @Cassiusisback
      @Cassiusisback ปีที่แล้ว

      read out data pin on rising and falling of the clk pin. if the data pin changed value between rising and falling clock, it was a valid input, otherwise it was just a bounce. no hardware needed.
      if(digitalRead(enc_check_pin)==HIGH)
      last_encoder_count=1;
      else
      last_encoder_count=0;
      while (digitalRead(pulse_pin)==LOW)
      {
      //wait for clock rising again
      }
      switch (last_encoder_count + digitalRead(enc_check_pin)) //1 means valid, 0 or 2 means bounce
      {
      case 1:
      if(last_encoder_count == 0)
      encoder_count++;
      else
      encoder_count--;
      break;

      default:
      break;
      }

    • @adrianw2972
      @adrianw2972 ปีที่แล้ว

      Noooooo! Do not denounce, getting it right for all speeds does not work!
      The correct way is to create an inturupt driven state machine. Since the output pattern can (in an ideal world) only change in a known order, denouncing is automatic as the output pattern is as expected or not.
      Even cheap and nasty rotary encoders can work beautifully!

  • @rapterkingofthebrozone7490
    @rapterkingofthebrozone7490 3 ปีที่แล้ว

    Thank you for the thorough explanation. I was curious how to calculate the Farad value for the capacitor? Would a 1uF or a 10uF capacitor be better?

    • @ericgroen253
      @ericgroen253 2 ปีที่แล้ว +3

      the value of the capacitor can be multiplied by the value of the resistor. It is called the RC time. IE:
      10uF x 100K ohm (0,000010 F x 100000 Ohm) = an RC of 1 second
      After 1 RC (also known as Tau) the Capacitor has lost 63% of its value.
      Or loaded up to 63% of its value, depending on the way of the circuit.
      In this manner 1 second.
      If you change the R or C value, therefore the RC time, the time in which the 63% point is reached, can be changed.

    • @prvashisht
      @prvashisht ปีที่แล้ว +1

      @@ericgroen253 Thanks. How is the 63% values meaningful here? Something like an element's half life or just an arbitrary number?

    • @SilverRyuu
      @SilverRyuu 8 หลายเดือนก่อน +1

      ​@prvashisht Late response, but maybe someone in the future will find this useful. Knowing that the current in a capacitor is equal to C*dv/dt you can solve the differential equation for an RC circuit and find that both charging or discharging a cap is an exponential function. The math works out so that you get something like V(t) = Ve^(-t/(RC)) for a discharging capacitor and where V is the voltage at t = 0. Plugging in RC for t will give you Ve^-1, and e^-1 is approximately 0.36. So after time RC (also called tau) you're left with 0.36 of your initial voltage or a 63/64% decrease in Voltage

    • @ericgroen253
      @ericgroen253 7 หลายเดือนก่อน

      @@prvashisht It is science... Every RC time, the actual value is dropped by 63%. So 63% of 63% of 63% of 63% of 63% is near to 0.
      (Sorry for the late response)

  • @holymoly2353
    @holymoly2353 4 ปีที่แล้ว +2

    How can you have a video about hysteresis without mentioning the word hysteresis? Looks like I'm going to get me some 555s to play with... Thanks for the great vid.

    • @simplyput2796
      @simplyput2796  4 ปีที่แล้ว +1

      Because the actual word hysteresis is way more complex and complicated than just this concept, and I have yet to actually learn it. Just saying this is hysteresis is blowing past so many details it's not even useful.

  • @rpasco9352
    @rpasco9352 ปีที่แล้ว

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

  • @petermuller608
    @petermuller608 4 หลายเดือนก่อน

    Nice idea! However, I never got all this effort doing denounce in hardware instead of software

  • @mr.satishfy
    @mr.satishfy 2 ปีที่แล้ว

    Is it termed as parasitic R L C.
    As

  • @elektron2kim666
    @elektron2kim666 9 หลายเดือนก่อน

    What is the "standard" for high/low? You say switch on = 0.

  • @CuriousAldo
    @CuriousAldo 3 หลายเดือนก่อน

    How about a Schmitt Trigger? Isn’t that the same?

  • @amitkhulbe
    @amitkhulbe 2 ปีที่แล้ว

    Why not use a opamp smitz trigger

  • @cphank3722
    @cphank3722 หลายเดือนก่อน

    You have created a Schmitt trigger. It has hysteresis.

  • @rleonmx
    @rleonmx หลายเดือนก่อน

    sacan de onda sus audífonos, pareciera que tiene un agujero en la cabeza

  • @RealThunder81
    @RealThunder81 2 ปีที่แล้ว

    exchange the 555 timer with a schmitt trigger? actually the way it ment to be

  • @irgski
    @irgski 11 หลายเดือนก่อน

    Problem is, the 555 timer costs abt $1.00! Nvr have understood why.

  • @billbyrd9845
    @billbyrd9845 2 ปีที่แล้ว

    I have a rather lengthy question about switch bounce. Are you open to a private message using your TH-cam business address? Thank you. Never mind. I see that there is no address. I guess TH-cam did away with that.

  • @alchemy1
    @alchemy1 2 ปีที่แล้ว

    Yea just tell that to the computer science nerds with thier two distinct binaly values, no such thing as wiggle or transition.

  • @edgeeffect
    @edgeeffect ปีที่แล้ว +1

    Yeah... it's a "stupid" example but isn't the real world just a huge conglomeration of stupid examples? ;)