【正文】
moment is the designer must consider the problem. This paper analyzes the hardware and software of two keyboard shaking elimination method, using the RS trigger hardware method, using software method, parison between two methods of different strengths and weaknesses. The hardware method will increase the cost and volume for the key, more matrix keyboard, with hardware method。 software method to use in the more mon, but there is a plus fixed delay dithering method minimum efficiency, it needlessly consuming machine to achieve jitter. Key words: button buffeting extinction。 RS flipflop。 software algorithm 5 一 清除鍵盤機械抖動方法的基本原理 按鍵消抖:通常的按鍵所用開關(guān)為機械彈性開關(guān) ,當機械觸點斷開、閉合時 ,電壓信號小型如下圖。由于機械觸點的彈性作用 ,一個按鍵開關(guān)在閉合時不會馬上穩(wěn)定地接通 ,在斷開時也不會一下子斷開。因而在閉合及斷開的瞬間均伴隨有一連串的抖動 ,如下圖。抖動時間的長短由按鍵的機械特性決定 ,一般為 5ms~ 10ms。 按鍵穩(wěn)定閉合時間的長短則是由操作人員的按鍵動作決定的 ,一般為零點幾秒至數(shù)秒。鍵抖動會引起一次按鍵被誤讀多次。為確保 CPU 對鍵的一次閉合僅作一次處理 ,必須去除鍵抖動。在鍵閉合穩(wěn)定時讀取鍵的狀態(tài) ,并且必須判別到鍵釋放穩(wěn)定后再作處理。按鍵的抖動 ,可用硬件或軟件兩種方法。 軟件方法:運用運算方法,通過運算邏輯表達式: Keradyn=Ktemp Kinput+Kreadyn1 (Ktemp ⊙Kinput) (1) Ktemp=Kinput (2) 可以獲得消除抖動的按鍵消息。 設(shè)置 3個變量 Kready、 Ktemp和 Kinput,并設(shè)置定時中斷周期為 20ms。在定時中斷服務(wù)程序中讀取按鍵,并把讀取的數(shù)據(jù)存于變量 Kinput中。變量 Kready中是所需要的穩(wěn)定的按鍵信息; Ktemp是中間變量,它的值是上一次的 Kinput。 根據(jù)當前按鍵的狀態(tài),考慮到 Kready中是 20ms抖動后的有效鍵信息,則 Kready、 Ktemp和 Kinput之間,在不同時刻的狀態(tài)關(guān)系如表 1所列。 表 1 6 時 刻 Kready Ktemp Kinput 1 0 0 0 2 0 0 1 3 0 1 0 4 0 0 1 5 1 1 1 6 1 1 1 7 1 1 0 8 1 0 1 9 1 1 0 10 0 0 0 11