Skip to main content

How to Reduce Switch Bounce

SMD components

Whenever a switch is triggered in an electronic system, there is not always a smooth transition between ON and OFF states. Mechanical switches in particular are susceptible to something known as switch bounce, where the switching signal exhibits some oscillatory behavior when the switch is flipped. It’s easy to see how this can result from a mechanical vibration when a switch changes its contact and collides with the other pole in the switch assembly.

In some circuits, this is innocuous and may not be noticeable until you take a measurement with an oscilloscope. In some systems, switch bounce creates noticeable problems and would need to be eliminated, such as when the switch is used to trigger a critical signal to another piece of equipment. Another important instance deals with power delivery with a relay, where switch bounce causes inrushes of current that can damage powered equipment in the system.

Whether you’ve identified switch bounce as a critical performance parameter, or you just find it annoying, there are some simple steps that can be used to reduce or eliminate it. The approach being taken depends on the type of system where the solution will be implemented.

Visualizing Switch Bounce

Switch bounce (also known as contact bounce) results from contacts being closed in a mechanical switch, and the resulting vibration when the switch contacts collide. The vibration in the contacts can cause variations in the electrical output from the switch, and the variation in the signal or power being delivered can appear at the load component or equipment.

Switch bounce is easily seen in an oscilloscope trace as shown below. In this example, switching a circuit HIGH results in contact bounce, during which the output power attempts to settle to the HIGH output value. After the initial bounce dies out, the signal rises to its HIGH output, but it also exhibits ringing. The switch bounce portion is the initial pseudorandom low-voltage portion of the waveform, while the underdamped ringing appears due to an LC resonance somewhere along the signal path.

switch bounce oscilloscope

Whether this is a circuit supplying power or one supplying a signal at low current, the switch bounce and subsequent ringing seen here might be problematic. However, it could be eliminated with some simple techniques, known as switch debounce. Here are three simple methods that can be used:

1: Sliding or Parallel Contacts

Some switches do not use the common types of colliding contacts, and thus the kinetic energy of the switch assembly could produce less vibration. For example, sliding contact switches are available that can produce much lower bounce because the contacts rub across each other. However, this will wear down the contacts after repeated toggling, and these switches could have lower lifetimes.

Other switches have multiple contacts in parallel. When flipped, only one contact needs to make a solid connection to provide low switch bounce, even if the other contacts are vibrating. This is one simple way to create a low-bounce electromechanical connection, which will typically operate with signals at low currents.

2. Add a Low-Pass RC Circuit

Adding an RC circuit will create a low-pass filter, which will shunt the oscillating portion of the switching signal to ground. In other words, it slows down and smooths the transition between OFF and ON states. The transition time is given by the RC time constant for the circuit. In some cases there will be a pull-up resistor that sets the current limit.

RC circuit switch

For power lines, this could require using larger components to ensure reliable power delivery. For power and signal, this may also be a problem because the addition of these components might modify the input impedance looking into the load component. Make sure to consider these points before adding an RC circuit, especially if phase and transition time are important.

3. Add Delay in Your Embedded Firmware

If the switch is connecting to a GPIO on a microcontroller, then it’s possible to delay processing of the received signal until the bounce dies off. When the switch initially closes and the received signal rises above the threshold for logic HIGH, the clock will cause the buffer I/O to latch. In the case of a microcontroller with a fast clock, switch bounce after the initial latch could cause the I/O buffer to change state, which would be read by the GPIO as intentional switching instead of unintentional switch bounce.

This requires programming a multiple clock cycle delay after the switch causes the I/O buffer to latch. For example, suppose that switch bounce lasts on the order of ~1 ms; if the clock frequency is 100 MHz, then the delay needs to be set to at least 100,000 clock cycles. This allows the GPIO to tolerate potentially large bounces that would bring the input above and below the HIGH and LOW logic thresholds.

Summary

The table below summarizes some common options for switch debounce removal for power and signal connections.

Switch Bounce

Advantages

Disadvantages

Sliding contact switches

  • Sliding switches do not have collide with each other and cause vibration
  • Contacts experience more wear over time

Parallel contact switches

  • The bounce signal is “spread” over multiple contacts
  • These could be physically larger or more expensive than a comparable sliding switch or other solution

Parallel capacitor or RC circuit

  • Simple to design the desired delay based on RC time constant
  • For power lines, these components can be quite large in order to handle high voltage/currents

Software switch debounce

  • Simple to add into code, just delay by a set number of clock cycles
  • Only applicable to embedded systems, not applicable to power unless a PMIC includes some delay mechanism

One other option that was not presented above is simple: buy a low-bounce switch. There are more expensive switches available that are built to produce lower bounce than simpler switches. For example, there are spring contact switches or even liquid (mercury) contact switches that can produce much lower bounce. Consider all options before implementing a switch debounce method.

When you’re ready to place switches and design debounce circuits for your PCB, use the complete set of CAD tools in OrCAD from Cadence to build your circuit board. Only Cadence offers a comprehensive set of circuit, IC, and PCB design tools for any application and any level of complexity. OrCAD users can also integrate their schematic capture utilities with PSpice to access the industry’s best simulation capabilities.

Subscribe to our newsletter for the latest updates. If you’re looking to learn more about how Cadence has the solution for you, talk to our team of experts.