Close

Debouncing the Pushbuttons

A project log for 8 Bit Computer Front Panel

VHDL code for I2C Control of Front Panel with 32 pushbuttons and 32 LEDs

land-boardscomland-boards.com 06/15/2021 at 20:330 Comments

The last log resulted in a loopback of the pushbuttons to the LEDs. There's no switch debouncing. 

This step will add switch debouncing to the pushbuttons. It will still do loopbacks (baby steps), but the pushbuttons will be debounced.

It would be helpful to know when the scan is completed. This will also reduce the effort to debounce since the switches are read every ~1 mS. To do this, a signal should be sent to the peripheral bus. A single write to a defined address should do the job.

IOP16 Memory Map

AddressR/WFunction
0X00RPushbuttons(31..24)
0X01RPushbuttons(23..16)
0X02RPushbuttons(15..8)
0X03RPushbuttons(7..0)
0X04RI2C Data
0X05RI2C Status
0X06RI2C Interrupt (polled)
0X00WLEDs(31..24)
0X01WLEDs(23..16)
0X02WLEDs(15..8)
0X03WLEDs(7..0)
0X04WI2C Data
0X05WI2C Control
0X06WSCAN STROBE

The SCAN STROBE address signals a frame was just scanned.

Created a new branch which latches the pushbuttons every scan. It runs the code FP01_LOOP2. The result is still not debounced, but the 32-bits of pushbuttons are latched every frame.

Debouncing

Debouncing consists of counting the number of consecutive frames the button is pressed. With an ~1 mS frame rate that would be a count of maybe 50 or so. That's long enough for the switches to settle and short enough that the delay time is reasonable.

A six bit counter would be 64 mS. Seems about right. Start the counter when the button is pressed. Reset the counter if the pushbutton is un-pressed (or still bouncing).

Created a new branch with the debounced pushbuttons. It runs the same FP01_LOOP2 code.

Discussions