Oscilloscope capture 4: Button bouncing and mitigation

in electronics •  6 years ago  (edited)

Problem: LED turned on by a mechanical switch causes "bouncing" of voltage

bouncing_schematic.png

20180724_225636.jpg

  • An LED is turned on and off by a rocker switch.
  • Voltage is measured across the LED.
  • The switch, as with other mechanical switches, make tiny vibrating contacts as it turns on. Such mechanical vibration (bouncing) is large enough to disturb the voltage.
  • When this erratic change in voltage is applied to a digital component, it could output random results.

Mitigation: hardware de-bouncing using inverted Schmitt trigger & RC circuit

debouncing_schematics.png

20180724_232057.jpg

  • In a very simple Arduino project, one could get away with using delay() function to wait for the bouncing to end until resuming the loop. However, this create another problem of halting other processes.
  • Hardware solution such as this is simple and reliable.
  • Voltage is measured at the LED, referencing the common ground. (purple)
  • Another voltage is measured at the capacitor, referencing the common ground. (yellow)
  • When the switch is turned off, the capacitor is fully charged, and the inverting Schmitt Trigger (ST) inverts the output voltage from HIGH to LOW.
  • When the switch is turned on, the voltage at the ST input is slowly decreased because of the capacitor. The ST still outputs LOW as the input voltage has not reached the threshold voltage, which is 2V.
  • When the input voltage decreases below 2V, the ST output is HIGH, turning on the LED.
  • Notice that the bouncing happens and finishes before the input voltage to ST reaches 2V. ST is effectively delaying the switching of the LED until the erratic bouncing is over.
  • The time to reach the ST threshold voltage can be controlled by the RC circuit.
  • It is important to avoid making the RC time constant too big for safety margin as it will compromise fast switching response.
Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

At last we get the solution for bouncing of viltage.