Debouncing switches

I made a little exercise out of compacting the example "switch debounce" code that the PIC tutorial examples uses. My next exercise will be to improve the debouncing in the "reverse variable speed LED rotation by pressing switch" by interleaving the debouncing check into the delay loop. As it stands, when the rotation is slow, the example can miss brief switch pushes.

My glorious savings of three instructions is documented on a separate page.

One nifty trick I found through Google that might be very helpful if I have to debounce 88 keys on a Symbolics keyboard (naturally, the same number as on a piano) is called "vertical counters." This consists basically of replacing counter increments with boolean operations, which can be easily performed in parallel, if the corresponding bits for multiple counters are grouped in register-sized words.

This page shows how to use a four-count two-bit vertical counting scheme to debounce eight switches in parallel.

Comments

Popular posts from this blog

Open Genera VLM on Linux

Restoring the Heathkit Jr 35

FPGA selection for beginners