How to Debounce a Button Input Using Programmable Logic

資料提供者:DigiKey

Programmable logic offers a level of flexibility that is unavailable with traditional discrete logic ICs. Readily available development tools make it easy to take advantage of creating application-specific functions with field programmable gate arrays and complex programmable logic devices.  An example of such a function is that of debouncing a push-button switch input.

Figure 1 below illustrates an effective debouncing logic circuit.  The circuit continuously clocks the button’s logic level into FF1 and subsequently into FF2, resulting in FF1 and FF2 always storing the last two logic levels of the button.  When these two values remain identical for a specified time, then FF3 is enabled, and the stable value is clocked through to the result output.

Diagram of debouncing logic circuit

Figure 1: Debouncing logic circuit.

The XOR gate and N-bit counter accomplish the timing.  If the button’s level changes, the values of FF1 and FF2 differ for a clock cycle, clearing the N-bit counter via the XOR gate.  If the button’s level is unchanging (i.e. if FF1 and FF2 are the same logic level), then the XOR gate releases the counter’s synchronous clear, and the counter begins to count.  The counter continues to increment in this manner until it (1) reaches the specified time and enables the output register, or (2) is interrupted and cleared by the XOR gate because the button’s logic level is not yet stable.

The counter’s size determines the time required to validate the button’s stability.  When the counter increments to the point that its carry out bit is asserted, it disables itself from incrementing further and enables the output register FF3.  The circuit remains in this state until a different button value is clocked into FF1, clearing the counter via the XOR gate. 

 
DigiKey logo

聲明:各作者及/或論壇參與者於本網站所發表之意見、理念和觀點,概不反映 DigiKey 的意見、理念和觀點,亦非 DigiKey 的正式原則。

關於出版者

DigiKey

DigiKey 總部位於美國明尼蘇達州錫夫里弗福爾斯市,是全球化的全方位服務供應商,能夠滿足電子元件的原型開發/設計以及量產需求,並透過 DigiKey 網站提供超過 750 家優質知名品牌製造商的 650 多萬款產品。