If you’ve ever tried to press a button on an FPGA board, you might expect a response similar to Fig 1 below:

Fig 1: A Simple button press
A Simple Button Press on the Arty

You want the button to transition from low (idle) to high (pressed) once for every time your finger pushes the button. You also want the button to return to zero in a similarly simple fashion. In Fig 1 above, i_btn does just that, although only the button press (i_btn rises) is shown and not the button release.

In reality, electrical contacts don’t work that way.

The following several images show examples of what happens when a button is either pressed or released. In each of them, i_btn is the raw input from the external port, whereas debounced is the result of a debouncing circuit that we’ll discuss over the next couple of posts. Further, you may notice that the number of wires in i_btn and debounced changes from board to board–this is just a reality of different boards having different numbers of buttons.

For example, Fig 2 shows the logic read when a button was released on Digilent’s Arty development board.

Fig 2: A not so simple release
A trace of a button release from the Arty

Notice how i_btn doesn’t simply transition back to zero (off) when the button is released, but rather bounces on its way down. It’s not that the board is broken, its not. The board actually works quite well. Rather, the signal from a changing button doesn’t always simply change. It tends to bounce as well.

Figs 3 and 4 show bouncing as measured on the ICO board.

Fig 3: ICO Board Button Press with Bounce
Example FIFO read/write pointers
Fig 4: ICO Board Button Release with Multiple Bounces
Example FIFO read/write pointers

Notice that, though we’ve switched boards, the button on this other board still bounces.

In case you think the reason for the bounce might be because both the Arty. and the ICO Board use similar buttons, Figs 5-8 show example button bounces from the PMod Keypad as measured by a CMod S6 board. Since the keypads logic is inverted from that of the buttons above, the events presented are actually keypad releases, and not keypad presses.

Of these, Fig 5 (below) may show the most severe bounce from the keypad.

Fig 5: PMod Keypad Severe Bounce on Release
A trace of a severe bounce when a keypad button is released

Fig 6 appears to be fairly benign, but the key still bounces.

Fig 6: PMod Keypad Bounce on Release
Tracing a button release from a 16-character numeric keypad

Fig 7 shows another two bounces.

Fig 7: PMod Keypad Bounce on Release
Another example trace of a button release from a numeric keypad

Fig 8 shows that the locations appear fairly random–even though it represents the same number of bounces Fig 7 had.

Fig 8: Another PMod Keypad Severe Bounce on Release
Last example trace from a keypad button release

Measuring this sort of contact bounce isn’t really that hard at all—especially once you have access to a debugging bus such as the one we built together on this blog.

Stick around, and we’ll discuss not only how to debounce a set of buttons, but also how to measure the effects of button bounce, and how to modify the debugging bus project to handle a task such as this one.