201123719 六、發明說明: 【發明所屬之技術領域】 [0001] 本發明涉及一種電子設備,特別涉及一種鍵盤掃描電路 及方法。 【先前技冬奸】 [0002] 鍵盤是電腦、PDA (個人數位助理)、移動電話等電子產 品中主要的人機對話輸入設備。鍵盤藉由内部的矩陣掃 描電路對鍵盤上的按鍵進行掃描,從而確定按鍵的位置 。現有矩陣鍵盤掃描電路大多使用單片機I/O埠來進行鍵 盤掃描。隨著電子產品功能的增加,要完成複雜多樣的 控制功能,需要鍵盤提供足夠的按鍵。由於按鍵的增加 常會導致用於進行鍵盤掃描的I/O槔的增加,例如有N*M 個按鍵,就需要N + M個I/O埠,這樣就導致鍵盤掃描電路 佔用過多的I/O埠資源,從而增加鍵盤的成本。 【發明内容】 [0003] 有鑒於此,有必要提供一種用少量的I/O埠實現多按鍵之 鍵盤掃描電路。 [0004] 此外,還有必要提供一種鍵盤掃描方法以及一種採用該 鍵盤掃描電路之電子設備。 [0005] 一種鍵盤掃描電路,用於與一具有複數輸入輸出埠的控 制器相連,該鍵盤掃描電路包括N條行線、Μ條列線、M-2 個單向導通開關管、Μ-2個第一電阻、及一個第二電阻, 其中Ν為自然數,Μ為大於或等於3的自然數。該Ν條行線 分別與該控制器的Ν個輸入埠電性連接。該Μ條列線中的 第一條列線一端可藉由Ν個按鍵與Ν條行線電性連接,另 098143999 表單編號Α0101 第4頁/共25頁 0982075328-0 201123719 〇 _ 一端接地。該Μ條列線中的第M條列線一端可藉由N個按鍵 與N條打線電性連接,同時還與M_2個單嚮導通開關管的 第一端電性連接’另一端藉由第二電阻接地。該Μ條列線 中的其餘Μ-2條列線一端可藉由Ν個按鍵與1^條行線電性連 接,同時還分別與Μ-2個單嚮導通開關管的第二端電性連 接,並分別藉由Μ-2個第一電阻與一電源電性連接,另一 端與該控制器的Μ-2個輸出埠電性連接。該單嚮導通開關 管在其第-端電|小於第二端時導通。 -種應用於鍵盤掃描電路的鍵讎描方法,藉由設置輸 出谭的電平狀態來進行每—列的掃描,讀取輸入埠的電 平狀態,進而判斷鍵盤按鍵,、包#以下步驟:' [0007] 讀取該Ν個輪入埠的初始電平狀態; [0008] »又置Μ 2個輸出琿均為㊉電平’再次讀取請輸入痒的電 平狀態; [0009] 判斷該Ν個輸入埠是否有電平狀態發生變化; 〇 [0010] 若發生變化,記料化的輸人琿並確定被許的按鍵位 於第-列’且為與變化的輸入埠對應的按鍵; [0011] 右未發生變化’設置Μ_2個輸出蜂中的第i個輸出蜂為低 電平’並保持其他輪出璋為高電平不變,再次讀取N個輸 入槔的電平狀態,其中i為2到M-2間的自 [0012] 判斷該N個輸入埠是否有電平狀態發生變化; [0013] 若發生變化’記錄變化的輸人埠並判斷是否第一列的按 鍵被按T #不是’確定被按下的按鍵位於第丨列’且為 098143999 表單編號A0101 第5頁/共25頁 0982075328-0 201123719 與變化的輸入埠對應的按鍵; [0014] 若未發生變化,設置M-2個輸出埠為低電平,再次讀取N 個輸入埠的電平狀態; [0015] 判斷該N個輸入埠是否有電平狀態發生變化; [0016] 若發生變化,記錄變化的輸入埠,並判斷是否為第一列 的按鍵被按下,若不是,確定被按下的按鍵位於第Μ列, 且為與變化的輸入埠對應的按鍵。 [0017] —種電子設備,包括一控制器、複數按鍵及一鍵盤掃描 電路,該控制器包括Ν個輸入埠及Μ個輸出埠,該鍵盤掃 描電路包括Ν條行線、Μ條列線、Μ-2個單嚮導通開關管、 Μ-2個第一電阻、及一個第二電阻,其中Ν為自然數,Μ為 大於或等於3的自然數;該Ν條行線與該Μ條列線以陣列形 式排列,形成Ν*Μ交叉點;該複數按鍵設置於該Ν*Μ交叉 點上,其一端與對應行線電性連接,另一端與對應列線 電性連接;該Ν條行線分別與該控制器的Ν個輸入埠電性 連接;該Μ條列線中的第一條列線一端藉由相應按鍵與對 應行線電性連接,另一端接地;該Μ條列線中的第Μ條列 線一端藉由相應按鍵與對應行線電性連接,同時還與Μ-2 個單嚮導通開關管的第一端電性連接,另一端藉由第二 電阻接地;該Μ條列線中的其餘Μ-2條列線一端藉由相應 按鍵與對應行線電性連接,同時還分別與Μ-2個單嚮導通 開關管的第二端電性連接,並分別藉由Μ-2個第一電阻與 一電源電性連接,另一端與該控制器的Μ-2個輸出埠電性 連接;該單嚮導通開關管在其第一端電壓小於第二端電 098143999 表單編號Α0101 第6頁/共25頁 201123719 壓時導通。 [0018] 鍵’減少了鍵盤對私 隼實現掃描N*M個按 子輪入埠資源的佔 按鍵的掃描。同時,# 用’並且實現了複數 法。 、料—種該掃描料採㈣掃描方 [0019] ❹ [0020] ❹ 【實施方式】 請參閱圖卜其為-種較 的電路圖。該鍵盤掃描電路_可式的鍵盤掃描電路200 單片機的N個輸入埠〖 利用—控制器1G ’例如 _個按鍵S ~s :‘V 2個輸出埠W2〜w(-"對 1-1 進行掃描識別。 該= 電路2。。包括N條行 2 m-l、Μ一 2個第一電阻R2〜R(m_i )及一 :第二電阻Rs,其中N為瞻,_於 數。M條列咖條行線交錯排列,形伽個交又I Μ個交又點分別對應放置該_個按鍵s_。_ 個按鍵S卜1〜S"的—端分別與對應行線電性連接,另一 端分別與對應的列線電性連接。在本實施方式中,N個輸 入埠〇,勝2個輪出物〜心」)為一控制器ι〇上的 輸入輸出埠,藉由控制器1G可設定輸人輸出埠 W2〜W(m-1)的電平狀態。 [0021] 第-條列線P1-端藉㈣個按鍵s s 一,另一端接地。第㈣列線;1端藉條二線個按鍵 Sl-πΓSn-m與N條行線L1〜Ln連接,同時還與M〜2個二極鱧 〇2〜Dm-1的陰極電性連接,另—端藉由第二電阻1^接地。 098143999 其餘M-2條列線P2〜P(m-i)的一 表單編號A0101 第7頁/共25頁 端分別藉由藉由N個按鍵 0982075328-0 201123719 與N條行線L卜Ln連接,同時還分別與M-2個二極體 D2〜Dm-i的陽極電性連接,並藉由第一電阻R2~R(m-l)與 一電壓源Vcc電性連接。其餘M-2條列線P2~P(m-l)的另 一端與輸出埠W2〜W(m-l)電性連接。 [0022] 第一電阻R2〜R(m-l)的阻值相同或相近,且遠小於第二 電阻Rs的阻值,以使得第二電阻Rs與一個第一電阻對電 壓源Vcc的輸出電壓進行分壓後,第二電阻Rs上的電壓可 被控制器10識別為高電平。 [0023] 二極體D9〜D ,具有單嚮導通的特點,當輸出埠 W2〜W(m-l)中至少一個為高電平時,與輸出璋 W2~W(m_l)對應的二極體D^D ,導通。由於第一電阻 R2〜R(m-l)遠小於第二電阻Rs,使得第二電阻Rs兩端的 電壓降遠大於第一電阻R2~R(m-l)兩端的電壓降,即控 制器10識別第Μ列按鍵S,〜S 的一端與高電平連接。 因此在掃描第一到第Μ-l列的過程中,,排除第Μ列對輸入 埠Κ^Κ的影響。 1 η [0024] 在執行按鍵掃描程式時,藉由設置輸出埠W2〜W(m-l)的 電平狀態對鍵盤掃描電路200進行列掃描,同時讀取輸入 埠Κ^Κ的電平狀態,判斷是否有按鍵按下。為了清楚地 1 η 描述鍵盤掃描程式,以下該電平狀態的變化均是相對於 輸入埠κ^κ的初始電平狀態而言。首先讀取輸入埠 1 η Κ^Κη初始電平狀態。然後,掃描第一列:設置輸出埠 W2〜W(m-l)均為高電平狀態,再次讀取輸入埠Κ^Κ的電 1 η 平狀態,並判斷輸入埠κ^κ是否有電平狀態發生改變。 1 η 若發生改變,記錄變化的輸入埠並確定按鍵為第一列按 098143999 表單編號Α0101 第8頁/共25頁 201123719 鍵被按下,且為與變化的輸入埠對應的按鍵。 [0025] 若未發生變化,依次掃描第二到第列. 呔置輪出埠 ^〜WU-D中第丨個輸出琿為低電平’同時保持其他輸出 埠為高電平不變,再次讀取輸入埠κ ~κ的雷巫也 1 n J电十狀態。判 ❹ 斷輪入埠κΓκη是否有電平狀態發生改變。若發生變化, 記錄變化的輸入埠並判斷是否第一列的按鍵被按下。判 斷是否是第一列的按鍵被按下的方法與掃描第一列的方 法相似:將第i個輸出埠切換為高電平,再次讀取輸入埠 狀態,其中,i為2到M-1中的自然數。如果輪入埠 K卜κη的電平狀態發生變化,判斷為第一列的按鍵被按下 ’且為與變化的輸入痒對應的...按.鍵。如'.果輸入埠κ 的 電平狀態未發生變化,判斷不是第一列的按鍵被按下。 若不是第一列的按鍵被按下,確定被按下的按鍵位於第i 列,且為與變化的輸入埠對應的按鍵。 [0026] Ο 若未發生變化,掃描第Μ列:設置輸出埠W2〜W(m-l)均為 低電平狀態,依次讀取輸入埠的電平狀態》判斷輸 入埠是否有電平狀態發生改變。若發生變化,記錄 變化的輸入埠,並判斷是否第一到第M-1列的按鍵被按下 。其中,判斷是否為第一列的按鍵被按下的方法與上面 描述的相同,判斷是否為第二到第M-1列的按鍵被按下的 方法與掃描第二到第M-1列的方法相同:依次設置M-2個 輸出璋中的一個為低電平,其餘為1¾電平,如果輸入淳 Κι~Κ的電平狀態未發生改變’則判斷不是第二列到第M-η 1列的按鍵被按下’如果在第i個輸出埠為低電平時’輸 入埠K ~K的電平狀態發生變化,則確定被按下的按鍵位 1 η 098143999 表單編號Α0101 第9頁/共25頁 0982075328-0 201123719 於第i + l列,且為與變化的輸入埠對應的按鍵。若判斷不 是,確定被按下的按鍵位於第Μ列,且為與變化的輸入埠 對應的按鍵。 [0027] 在實際操作中’由於控制器1〇的掃描速度非常快,掃描 第Μ列時,可以直接排除第二列到第Μ-1列的干擾。即: 省略判斷是否為第二到第Μ-1列的按鍵被按下的步驟,在 排除不是第一列的按鍵被按下後即可確定被按下的按鍵 位於第Μ列。 [0028] 請參閱圖2,其為Ν = Μ = 4時的一較佳實施例的鍵盤掃描電 路201的電路圖。該鍵盤掃描電路201包括4條行線L1〜L4 、4條列線Ρ卜Ρ4、2個二極錄D2;~D3、2個第一電阻R2~R3 及一個第二電阻Rs。4條列線與4條行線交錯排列,形成 4*4個交叉點。4*4個交又點分別對應放置該4*4個按鍵 S卜1~s4_4。4*4個按鍵的一端分別與對應行線 電性連接’另一端分別與對應的列線霣性率接。在本實 施方式中,4個輸入埠K卜p及2個輪出#W2〜W3為一控制 器10上的輸入輸出埠、藉由控制器1 〇可設定輸入輪出埠 W2〜W3的電平狀態。 [0029] 第一條列線P1 —端藉由4個按鍵與N條行線 L1〜L4連接’另一端接地。第4條列線的一端藉由4個按鍵 \-4〜54-4與1^條行線1^~1^4連接’同時還與2個二極體 〇2〜〇3的陰極電性連接,另一端藉由第二電阻1^接地。其 餘M-2條列線P2〜P3的一端分別藉由藉由4個按鍵與4條行 線L1~L4連接,同時還分別與2個二極體D〜的陽極電性 連接’並藉由第一電阻R2~R3與一電壓源Vcc電性連接。 表單編娩A0101 098143999 第10頁/共25頁 201123719 其餘2條列線P2〜P3的另一端與輸出埠W2〜W3電性連接。 [0030] 第一電阻R2~R3的阻值相同或相近,且遠小於第二電阻Rs 的阻值,以使得第二電阻Rs與一個第一電阻對電壓源Vcc 的輸出電壓進行分壓後,第二電阻rs上的電壓可被控制 器10識別為高電平。 [0031] 在執行按鍵掃描程式時,如果按鍵s 被按下,其掃描過 3-3 程為·為了清楚地描述鍵盤掃描程式,以下所述電平狀 態的變化均是相對於輸入埠κ 的初始電平狀態而言。 1 4 [0032] 首先讀取輸入埠、〜!^初始電平狀態。然後,掃描第一列 :設置輸出埠W2〜W3均為高電乎:狀態,.,再次讀取輸入埠 的電平狀態’並判斷蛱入埠£;二&是否有電平狀態 發生改變。 \; [0033] ❹ [0034] 若輸入埠ΚΓΚ4電平狀態未發生變化,掃描第二列:設置 輸出蜂W2為低電平’同時保持輪出埠…為高電平不變, 再次讀取輸入琿κ广κ4的電乎狀態。判斷輸入淳是 否有電平狀態發生改變。 若輸入埠1^〜1[4電平狀態未發生變化,設置輸出埠W3輸出 埠為低電平,同時保持輸出埠W2為高電平不變,再次讀 取輸入埠Κ「Κ4的電平狀態。判斷輸入埠ΚΓΚ4是否有電 平狀癌發纽變。若輸人琿Κ3的電平狀態發生變化,進 一步判斷是否是第—列的按鍵被按下。判斷是否是第一 列的按鍵被按下的方法與掃描第—列时法相似:將輸 出淳W3切換為高電平,再次讀取輸入埠ΚΓΚ4狀態,若輸 入琿W電平狀態未發生變化,觸料第—列的按 098143999 表單編號Α0101 第11頁/共25頁 0982075328-0 201123719 鍵被按下。若不是第一列的按鍵被按下,確定被按下的 按鍵位於第三列,且為與變化的輸入埠對應的按鍵sq q ο ο - ο 被按下。 [0035] 請參看圖3,其為圖1中鍵盤掃描電路的掃描方法300的流 程圖。掃描程式啟動後,控制器10開始對輸入埠Κ^Κ進 1 η 行掃描。 [0036] 步驟301,讀取輸入埠Κ^Κ的初始電平狀態。為了清楚 1 η 地描述鍵盤掃描方法300,以下所述電平狀態的變化均是 相對於所述初始電平狀態而言。 [0037] 步驟302,設置輸出埠W2〜W(m-l)均為高電平,再次讀取 輸入埠Κ^Κ的電平狀態。201123719 VI. Description of the Invention: [Technical Field] The present invention relates to an electronic device, and more particularly to a keyboard scanning circuit and method. [Previous technical winter rape] [0002] The keyboard is the main human-machine dialogue input device in electronic products such as computers, PDAs (personal digital assistants), and mobile phones. The keyboard scans the keys on the keyboard by an internal matrix scanning circuit to determine the position of the keys. Most existing matrix keyboard scanning circuits use a single-chip I/O port for keyboard scanning. As the functionality of electronic products increases, complex and diverse control functions are required to provide sufficient keys for the keyboard. Since the increase of the button often leads to an increase in the I/O槔 for keyboard scanning, for example, N*M buttons require N + M I/O埠, which causes the keyboard scanning circuit to take up too much I/O.埠 Resources, which increases the cost of the keyboard. SUMMARY OF THE INVENTION [0003] In view of the above, it is necessary to provide a keyboard scanning circuit that implements multiple keys with a small amount of I/O 。. Further, it is also necessary to provide a keyboard scanning method and an electronic device using the keyboard scanning circuit. [0005] A keyboard scanning circuit for connecting to a controller having a plurality of input and output ports, the keyboard scanning circuit comprising N row lines, a string line, M-2 single-conducting switches, and Μ-2 a first resistor, and a second resistor, wherein Ν is a natural number and Μ is a natural number greater than or equal to 3. The winding lines are electrically connected to the input ports of the controller. One end of the first column line of the string line can be electrically connected to the string line by one button, and another 098143999 Form No. 1010101 Page 4 of 25 0982075328-0 201123719 〇 _ One end is grounded. One end of the Mth column line in the string line can be electrically connected to the N lines by N buttons, and is also electrically connected to the first end of the M_2 single-conducting switch tubes. The two resistors are grounded. One end of the remaining Μ-2 line lines in the string line can be electrically connected to the 1^ line line by one button, and also electrically connected to the second end of the Μ-2 single-conducting switch tubes respectively. Connected and electrically connected to a power supply by Μ-2 first resistors, and the other end is electrically connected to Μ-2 outputs of the controller. The one-way switch is turned on when its first terminal is lower than the second terminal. - A key scanning method applied to a keyboard scanning circuit, by setting the level state of the output tan to perform scanning of each column, reading the level state of the input port, and then determining the keyboard button, and the following steps: [0007] Read the initial level state of the wheel 埠; [0008] » Set Μ 2 outputs 十 are all ten levels 'Read again, please input the level state of the itch; [0009] Whether the input state has a change in level state; 〇[0010] If a change occurs, the input user is recorded and it is determined that the pressed button is located in the first column and is a button corresponding to the changed input port; [0011] The right does not change 'set Μ_2 the output i of the output bee is low level' and keep the other rounds out of the high level, and read the level state of the N input 再次 again, Where i is between 2 and M-2 from [0012] to determine whether the N input 有 has a change in level state; [0013] If a change occurs, the input change of the record is recorded and it is determined whether the button of the first column is Press T# is not 'OK' the pressed button is in the second column' and is 098143999 form No. A0101 Page 5 of 25 0982075328-0 201123719 Button corresponding to the changed input ;; [0014] If there is no change, set M-2 output 埠 to low level, read N input 再次 again Level state; [0015] determining whether the N input states have a change in level state; [0016] if a change occurs, recording the changed input port, and determining whether the button of the first column is pressed, if not, It is determined that the pressed button is in the third column and is the button corresponding to the changed input port. [0017] An electronic device includes a controller, a plurality of buttons, and a keyboard scanning circuit. The controller includes a plurality of input ports and a plurality of output ports. The keyboard scanning circuit includes a row line, a string line, and Μ-2 single-conductor switching tubes, Μ-2 first resistors, and a second resistor, where Ν is a natural number, Μ is a natural number greater than or equal to 3; the 行 row line and the Μ column The lines are arranged in an array to form a Ν*Μ intersection; the plurality of buttons are disposed at the intersection of the Ν*Μ, one end of which is electrically connected to the corresponding row line, and the other end is electrically connected to the corresponding column line; The wires are respectively electrically connected to the input terminals of the controller; one end of the first column line of the string line is electrically connected to the corresponding row line by the corresponding button, and the other end is grounded; the string line is in the line One end of the second column line is electrically connected to the corresponding row line by corresponding buttons, and is also electrically connected to the first end of the Μ-2 single-conducting switch tubes, and the other end is grounded by the second resistor; One of the remaining Μ-2 column lines in the line is electrically connected to the corresponding line by the corresponding button At the same time, it is also electrically connected to the second end of the Μ2 single-conductor switch tubes, and is electrically connected to a power source by Μ-2 first resistors, and the other end is connected to the controller Μ-2 The output is electrically connected; the single-conducting switch is turned on at the first terminal voltage less than the second terminal 098143999 Form No. Α0101 Page 6 / Total 25 Page 201123719. [0018] The key 'reduces the scan of the keyboard for privately scanning the N*M button-input resources. At the same time, # uses 'and implements the plural method. , material - the scanning material mining (four) scanning side [0019] ❹ [0020] 实施 [Embodiment] Please refer to the figure for the comparison of the circuit diagram. The keyboard scanning circuit _ keyboard scanning circuit 200 M input N 埠 〖 Use - controller 1G 'such as _ a button S ~ s : 'V 2 outputs 埠 W2 ~ w (- " 1-1 Scanning identification is performed. The circuit 2 includes N rows of 2 ml, two first resistors R2 RR(m_i) and one: second resistor Rs, where N is a continuation, _ is a number. The line of the coffee bar is staggered, the shape of the gamma is one and the other is the intersection of the _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ They are respectively electrically connected to the corresponding column lines. In the present embodiment, N inputs 埠〇, wins 2 rounds of output ~ heart") is an input/output port on a controller ι, which can be controlled by the controller 1G Set the level state of the input output 埠W2 to W(m-1). [0021] The first column line P1-ends one (four) buttons s s one, and the other end is grounded. The fourth (fourth) column line; the one end of the two-line button S1-πΓSn-m is connected to the N line lines L1~Ln, and is also electrically connected to the cathodes of M~2 diodes 2~Dm-1, The other end is grounded by the second resistor 1^. 098143999 A form number A0101 of the remaining M-2 column lines P2~P(mi) Page 7/25 pages are connected to the N line lines Lb Ln by N buttons 0982075328-0 201123719, respectively. They are also electrically connected to the anodes of the M-2 diodes D2 to Dm-i, respectively, and are electrically connected to a voltage source Vcc by the first resistors R2 R R (ml). The other end of the remaining M-2 column lines P2 to P(m-l) is electrically connected to the output ports W2 to W(m-1). [0022] The resistances of the first resistors R2 R R (ml) are the same or similar, and are much smaller than the resistance of the second resistor Rs, so that the second resistor Rs and a first resistor divide the output voltage of the voltage source Vcc After pressing, the voltage on the second resistor Rs can be recognized by the controller 10 as a high level. [0023] The diodes D9 to D have the characteristics of a single conduction. When at least one of the outputs 埠W2 to W(ml) is at a high level, the diode D^ corresponding to the output 璋W2~W(m_l) D, conduction. Since the first resistors R2 R Rm (ml) are much smaller than the second resistor Rs, the voltage drop across the second resistor Rs is much larger than the voltage drop across the first resistors R2 R R (ml), that is, the controller 10 recognizes the third column. One end of the buttons S, ~S is connected to the high level. Therefore, in the process of scanning the first to the Μ-l columns, the influence of the third column on the input 埠Κ^Κ is excluded. 1 η [0024] When the key scan program is executed, the keyboard scan circuit 200 is scanned by setting the level state of the output 埠W2 〜W (ml), and the level state of the input 埠Κ^Κ is read at the same time. Is there a button press? In order to clearly describe the keyboard scanning program, the following changes in the level state are relative to the initial level state of the input 埠κ^κ. First read the input 埠 1 η Κ ^ Κ initial level state. Then, scan the first column: set the output 埠W2~W(ml) to a high level state, read the input 埠Κ^Κ electric 1 η flat state again, and judge whether the input 埠κ^κ has a level state. changes happened. 1 η If there is a change, record the change input 埠 and confirm that the button is in the first column. 098143999 Form No. Α0101 Page 8 of 25 The 201123719 button is pressed and is the button corresponding to the changed input 埠. [0025] If there is no change, the second to the second column are sequentially scanned. The first output of the 轮^~WU-D is LOW, while keeping the other outputs 高电平 high, again The reading of the input 埠κ ~κ is also 1 n J electric ten state. It is judged whether or not there is a change in the level state of the 埠κΓκη. If there is a change, record the changed input and determine if the first column of buttons is pressed. The method of determining whether the button of the first column is pressed is similar to the method of scanning the first column: switching the ith output 埠 to a high level, and reading the input 埠 state again, where i is 2 to M-1 The natural number in . If the level state of the wheel 埠 K κη changes, it is determined that the button of the first column is pressed ’ and is the ... button corresponding to the changed input itch. If the level state of '. input 埠 κ has not changed, it is judged that the button of the first column is not pressed. If the button in the first column is not pressed, it is determined that the pressed button is in the ith column and is the button corresponding to the changed input 埠. [0026] Ο If there is no change, scan the third column: set the output 埠W2~W(ml) to the low state, and read the level state of the input 依次 in turn” to determine whether the input 有 has a level change. . If there is a change, record the changed input 埠 and judge whether the buttons in the first to the M-1th column are pressed. Wherein, the method of determining whether the button of the first column is pressed is the same as described above, and determining whether the button of the second to the M-1th column is pressed and scanning the second to the M-1th column The method is the same: one of the M-2 output ports is set to be low level, and the rest is 13⁄4 level. If the level state of the input 淳Κι~Κ has not changed, then the judgment is not the second column to the M-n. The button of column 1 is pressed. 'If the level of input 埠K ~K changes when the ith output 埠 is low, then the pressed button bit is determined to be 1 η 098143999 Form No. 1010101 Page 9 / A total of 25 pages 0982075328-0 201123719 in the i + l column, and is the button corresponding to the changed input 埠. If the determination is not, it is determined that the pressed button is in the third column and is the button corresponding to the changed input 埠. [0027] In actual operation, since the scanning speed of the controller 1〇 is very fast, the interference of the second column to the Μ-1 column can be directly excluded when scanning the third column. That is, the step of judging whether the button of the second to the Μ-1 column is pressed is omitted, and it is determined that the pressed button is located in the Μ column after the button that is not the first column is pressed. Please refer to FIG. 2, which is a circuit diagram of a keyboard scanning circuit 201 of a preferred embodiment when Ν = Μ = 4. The keyboard scanning circuit 201 includes four row lines L1 to L4, four column lines Ρ Ρ 4, two two-pole records D2, ~D3, two first resistors R2 R R3 and one second resistor Rs. The four column lines are interleaved with the four line lines to form 4*4 intersections. 4*4 intersections and points respectively place the 4*4 buttons Sb1~s4_4. One end of the 4*4 buttons is electrically connected to the corresponding row line respectively, and the other end is respectively connected with the corresponding column line rate. . In the present embodiment, four inputs 埠Kb and two wheeled #W2~W3 are input/output ports on a controller 10, and the controller 1 设定 can set the input wheel 埠 W2 W W3 Flat state. [0029] The first column line P1 is connected to the N row lines L1 to L4 by four buttons, and the other end is grounded. One end of the fourth column line is connected by the four buttons \-4~54-4 and the 1^ line line 1^~1^4', and also the cathode electrical properties of the two diodes 〇2~〇3. Connected, the other end is grounded by a second resistor 1^. One ends of the remaining M-2 column lines P2 to P3 are respectively connected to the four row lines L1 to L4 by four buttons, and are also electrically connected to the anodes of the two diodes D~ respectively. The first resistors R2 R R3 are electrically connected to a voltage source Vcc. Form Birth A0101 098143999 Page 10 of 25 201123719 The other two ends of the two column lines P2 to P3 are electrically connected to the outputs 埠W2 to W3. [0030] The resistances of the first resistors R2 R R3 are the same or similar, and are much smaller than the resistance of the second resistor Rs, so that after the second resistor Rs and a first resistor divide the output voltage of the voltage source Vcc, The voltage on the second resistor rs can be recognized by the controller 10 as a high level. [0031] When the button scanning program is executed, if the button s is pressed, it scans 3-3. In order to clearly describe the keyboard scanning program, the following changes in the level state are relative to the input 埠κ. In terms of the initial level state. 1 4 [0032] First read the input 埠, ~! ^ initial level state. Then, scan the first column: set the output 埠W2~W3 to be high: state, ., read the level state of the input ' again and judge the input ;;; 2 & whether there is a change in the level state . [0033] ❹ [0034] If the input 埠ΚΓΚ4 level state has not changed, scan the second column: set the output bee W2 to low level 'while keep the wheel 埠... is high level, read again Enter the electrical status of 珲κ广κ4. It is judged whether the input 淳 has a level change. If input ^1^~1[4 level state has not changed, set output 埠W3 output 埠 to low level, while keeping output 埠W2 at high level, read input 埠Κ “Κ4 level again] State. Determine whether there is a level of cancer in the input 埠ΚΓΚ4. If the level state of the input 珲Κ3 changes, it is further determined whether the button of the first column is pressed. It is determined whether the button of the first column is The method of pressing is similar to the method of scanning the first column: the output 淳W3 is switched to the high level, and the input 埠ΚΓΚ4 state is read again. If the input 珲W level state has not changed, the touch column - 098143999 Form No. 1010101 Page 11 of 25 0982075328-0 201123719 The key is pressed. If the button in the first column is not pressed, it is determined that the pressed button is in the third column and corresponds to the changed input 埠The button sq q ο ο - ο is pressed. [0035] Please refer to FIG. 3, which is a flowchart of the scanning method 300 of the keyboard scanning circuit of FIG. 1. After the scanning program is started, the controller 10 starts to input 埠Κ^Κ Into 1 η line scan. [0036] Step 301, read and lose The initial level state of the UI. In order to clearly describe the keyboard scanning method 300, the change in the level state described below is relative to the initial level state. [0037] Step 302, setting the output埠W2~W(ml) are both high level, and the level state of the input 埠Κ^Κ is read again.
In [0038] 步驟303,判斷輸入埠K,~K是否有電平狀態發生變化, 1 η 若無變化,則執行步驟304 ;若有變化,則執行步驟314 〇 [0039] 步驟304,設置輸出埠W2〜W(m-l)中第i個為低電平,並 且保持其他輸出埠狀態為高電平不變,再次讀取輸入埠 K卜K的電平狀態。i從2〜(m-1)依次取值。 η [0040] 步驟305判斷輸入埠是否有電平狀態發生變化,若 有變化,則執行步驟306 ;若無變化,則執行步驟308。 [0041] 步驟306,將第i個輸出埠W2~W(m-1)切換為高電平,再 次讀取輸入埠K n ~ K的電平狀態。 1 η [0042] 步驟307,判斷輸入埠Κ,〜Κ是否有電平狀態發生變化, 1 η 若有變化,則執行步驟314 ;若無變化,則執行步驟315 098143999 表單編號Α0101 第12頁/共25頁 201123719 [0043] [0044] . [0045] ο [0046] [0047] [0048] [0049] 步驟308,設置輸出埠W2~W(m-l)均為低電平,再次讀取 輸入埠Κ^Κ的電平狀態。 1 η 步驟309,判斷輸入埠Κ^Κ是否有電平狀態發生變化, 1 η 若有變化,則執行步驟310 ;若無變化,則本次鍵盤掃描 結束。 步驟310,設置輸出埠W2〜W(m-l)均為高電平,再次讀取 輸入埠Κ^Κ的電平狀態。 1 η 步驟311,判斷輸入埠Κ,-Κ是否有電平狀態發生變化, 若無變化,則執行步驟312 ;若有變化,執行步驟314。 步驟312,依次將輸出埠W2~W(m-l)切換為高電平,再次 讀取輸入埠Κ^Κ的電平狀態。 1 η 步驟313,判斷輸入埠Κ,〜Κ是否有電平狀態發生變化, 1 η 若有變化,則執行步驟315 ;若無變化,執行步驟316。 步驟314,記錄變化埠並確定按鍵為第一列,且為與變化 埠對應的按鍵被按下。 [0050] [0051] 步驟315,記錄變化埠並確定按鍵為低電平輸出埠對應列 ,且為與變化埠對應的按鍵。 步驟316,記錄變化埠並確定按鍵為第Μ列,且為與變化 埠對應的按鍵。本次鍵盤掃描結束。 在其他實施例中,步驟312~313可省略,步驟311需改為 :判斷輸入埠Κ^Κ是否有電平狀態發生變化,若無變化 1 η 098143999 表單編號Α0101 第13頁/共25頁 0982075328-0 [0052] 201123719 ,則執行步驟316 ;若有變化 及化,執行步驟314。 [0053] [0054] 請參看圖4 ’其為圖2中鍵盤掃描 10開始對輸入埠Κ 進 1 4 ^ &電路的掃描方法4〇〇的流 私圖。掃描程式啟動後,控制器 行掃描。 步驟401,讀取輸入埠Κ〜Κ , 1 \的仞始電平狀離、 地描述鍵盤掃描方法400,以下 〜、。為了清楚 r所迷電平妝 相對於所述初始電平狀態而言。 I、的變化均是 [0055] 步驟402,設置輸出埠W2 埠的電平狀態。 14 W 3 ii) & V >>ySl 今電平, 再次讀 取輪 入 [0056] 步驟403,判斷輸入埠Κ^Κ暑不士 1 4乂占有電平肤餘 若無變化’則執行步驟404 ;若古银 想發生變化, 。 則執行步驟414 [0057][0038] Step 303, determining whether the input 埠K, ~K has a level change, 1 η if there is no change, proceed to step 304; if there is a change, perform step 314 〇 [0039] step 304, set the output第W2~W(ml) The ith is low level, and the other output 埠 state is kept at a high level, and the level state of the input 埠KBu K is read again. i takes values from 2 to (m-1) in order. [0040] Step 305 determines whether the input state has a change in the level state. If there is a change, step 306 is performed; if there is no change, step 308 is performed. [0041] Step 306, the i-th output 埠W2~W(m-1) is switched to a high level, and the level state of the input 埠K n ~ K is read again. 1 η [0042] Step 307, it is judged whether the input state Κ, Κ 有 has a level state change, 1 η if there is a change, step 314 is performed; if there is no change, then step 315 098143999 form number Α 0101 page 12 / [0049] [0049] [0049] Step 308, set the output 埠W2~W (ml) are low level, read the input again埠电平^Κ level status. 1 η Step 309, it is judged whether the input 埠Κ^Κ has a level state change, if 1 η changes, step 310 is performed; if there is no change, the keyboard scan ends. In step 310, the output 埠W2~W(m-l) is set to a high level, and the level state of the input 埠Κ^Κ is read again. 1 η Step 311, it is judged whether the input 埠Κ, -Κ has a level state change, if there is no change, step 312 is performed; if there is a change, step 314 is performed. In step 312, the output 埠W2~W(m-l) is sequentially switched to the high level, and the level state of the input 埠Κ^Κ is read again. 1 η Step 313, it is judged whether the input 埠Κ, Κ 有 has a level state change, 1 η If there is a change, step 315 is performed; if there is no change, step 316 is performed. In step 314, the change is recorded and the button is determined to be the first column, and the button corresponding to the change 埠 is pressed. [0051] Step 315, recording the change 埠 and determining that the button is a low level output 埠 corresponding column, and is a button corresponding to the change 埠. In step 316, the change is recorded and the button is determined to be the third column and is the button corresponding to the change 埠. This keyboard scan ends. In other embodiments, steps 312-313 may be omitted, and step 311 needs to be changed to: determine whether the input state has a level state change, if there is no change 1 η 098143999 Form number Α 0101 Page 13 / 25 pages 0992075328 -0 [0052] 201123719, step 316 is performed; if there is a change, the step 314 is performed. [0054] Please refer to FIG. 4' which is a flow chart of the scanning method 4〇〇 of the circuit for starting the input of the keyboard 4 in FIG. After the scanner is started, the controller scans. In step 401, the input input 埠Κ~Κ, 1 \ is initially leveled, and the keyboard scanning method 400 is described below, and the following ~. In order to be clear, the level makeup is relative to the initial level state. The change of I, is [0055] Step 402, setting the level state of the output 埠W2 埠. 14 W 3 ii) & V >>ySl Current level, read the round again [0056] Step 403, judge input 埠Κ^Κ暑不士1 4乂Occupy level if there is no change in the skin' Go to step 404; if the ancient silver wants to change, Then execute step 414 [0057]
步驟404,設置輸出埠W2〜W3中第η持其他輸出埠狀態為高電平不變’ ’低電平,並卫 冉次讀廒鉍 的電平狀態。i從2〜3依次取值。 輸入埠K Κ [0058] [0059] [0060] 步驟405判斷輪入琿κΓΚ4是否有電平狀餘 有變化,則執行步驟406 ;若無變化,L發生變化,若 則執行步驟4 η 步驟406,將第i個輸出埠界2〜货3切換為* 哪4〇8。 取輸入埠KrK4的電平狀態。 阿電平,再次讀 步驟407,判斷輸入埠κΓΚ是否古泰 1 4 有電平狀餘总 若有變化,則執行步驟414 ;若無變4 〜發生變化, » ’、、、t,則執行歩驟415 098143999 步驟408,設置輸出埠W2〜W3均為低電平 .…一 第14買/共25頁 再二欠讀取輪入 表單編號A0101 [0061] 201123719 埠I ~Κ的電平狀態。 1 4 [0062] 疋否有電平狀態發生變化, 居無變化’則本次鍵盤掃描 步驟409,判斷輸入埠Κ〜Κ 1 4 若有變化,則執行步驟410 ; 結束。 [0063] 步驟410,設置輸出埠ff2〜W3岣為高電平 埠1^~1(4的電平狀態。 ’再次讀取輸入 [0064] Ο [0065] 步驟411,判斷輸入埠Ί 若無變化,則執行步驟412 ; 是否有電平狀態發生變化, 右有變化,執行步驟414。 步驟412,依次將輸料W2〜W3切換為高電平,再次讀取 輸入埠1^~瓦4的電平狀態。:: [0066] 步龍3,判斷輸入埠ΚΓΚ4是否有電平狀態發生變化, 若有變化’則執行步驟415;若無變化,執行步驟416。 [0067] ❹ _ 步驟414 ’記錄變化痒並確找鍵為第-列,且為與變化 埠對應的按鍵被按下。 步額5,記錄變化琿並確定按鍵為低電平輸出谭對應列 ’且為與變化埠對應的按鍵。 [0069] [0070] 098143999 步驟416 ’記錄變化埠並確定按鍵為第4列,且為與變化 埠對應的按鍵。本次鍵盤掃描結束。 綜上所述’本發明符合發明專利要件,爰依法提出專利 申請。惟,以上所述僅為本發明之較佳實施方式,舉凡 熟悉本案技藝之人士,在援依本案創作精神所作之等效 修飾或變化,皆應包含於以下之申請專利範圍内。 【圖式簡單說明】 表單蹁號Α0Ι0】 第15頁/共25頁 0982075328-0 201123719 [0071] 圖1為一種較佳實施方式之鍵盤掃描電路圖。 [0072] 圖2為輸入埠為4時,一較佳實施方式之鍵盤掃描電路圖 [0073] 圖3為圖1中鍵盤掃描電路之掃描方法之流程圖。 [0074] 圖4為圖2中鍵盤掃描電路之掃描方法之流程圖。 【主要元件符號說明】 [0075] 鍵盤掃描電路:200In step 404, the output 埠W2~W3 sets the other state of the output 埠 state to a low level ’ low level, and maintains the level state of the 廒铋 read 廒铋. i takes values from 2 to 3 in order. [0058] [0060] Step 405 determines whether there is a change in the level of the wheel 珲 ΓΚ ΓΚ 4, then step 406 is performed; if there is no change, L changes, if yes, step 4 η is performed. , switch the i-th output boundary 2 to the goods 3 to * which 4〇8. Take the level of the input 埠KrK4. A level, read step 407 again, to determine whether the input 埠 ΓΚ 古 has a level change, if there is a change, then step 414; if no change 4 ~ change, » ',,, t, then execute Step 415 098143999 Step 408, set the output 埠W2~W3 are low level.... One 14th buy/Total 25 pages and then two owe read round entry form number A0101 [0061] 201123719 埠I ~ Κ level status . 1 4 [0062] If there is a change in the level state, there is no change, then the keyboard scan step 409, judge the input 埠Κ~Κ 1 4 If there is a change, execute step 410; [0063] Step 410, setting the output 埠 ff2 〜 W3 岣 to a high level 埠 1 ^ ~ 1 (level state of 4. 'Read input again [0064] Ο [0065] Step 411, determine the input 埠Ί if no If the change is performed, step 412 is performed; if there is a change in the level state, and there is a change in the right, step 414 is performed. Step 412, the feeds W2 to W3 are sequentially switched to the high level, and the input 埠1^~4 is read again. Level state:: [0066] Step 3, judge whether input 埠ΚΓΚ4 has a level change, if there is a change, then step 415 is performed; if there is no change, step 416 is performed. [0067] _ _ step 414 ' Record the change itch and make sure the key is the first column, and the button corresponding to the change 被 is pressed. Step 5, record the change 珲 and determine that the button is low output tan corresponding column 'and corresponds to the change 埠[0070] [0070] [0070] 098143999 Step 416 'record changes 埠 and determine that the button is the fourth column, and is the button corresponding to the change 。. This keyboard scan ends. In summary, the invention meets the requirements of the invention patent,提出Proposed a patent application according to law. However, the above description is only preferred of the present invention. For the implementation of the method, the equivalent modifications or changes made by the person who is familiar with the skill of the case in the spirit of the creation of the case shall be included in the scope of the following patent application. [Simple description of the drawing] Form number Α0Ι0] Page 15/ A total of 25 pages 0982075328-0 201123719 [0071] FIG. 1 is a circuit diagram of a keyboard scanning circuit of a preferred embodiment. [0072] FIG. 2 is a circuit diagram of a keyboard scanning circuit of a preferred embodiment when the input port is 4. [0073] FIG. Figure 1 is a flow chart of a scanning method of the keyboard scanning circuit of Figure 1. [0074] Figure 4 is a flow chart of a scanning method of the keyboard scanning circuit of Figure 2. [Key element symbol description] [0075] Keyboard scanning circuit: 200
[0076] 控制器:1 0 [0077] 輸入埠 1 η [0078] 輸出埠:W2〜W(m-l)[0076] Controller: 1 0 [0077] Input 埠 1 η [0078] Output 埠: W2 〜 W (m-l)
[0079] 按鍵:S,,〜S 1-1 n-m [0080] 行線:L1 〜Ln [0081] 列線:P1 〜Pm[0079] Button: S,, ~S 1-1 n-m [0080] Line: L1 ~ Ln [0081] Column line: P1 ~ Pm
[0082] 二極體:D^D , 2 m-1 [0083] 第一電阻:R2〜R(m-1 ) [0084] 第二電阻:Rs [0085] 電壓源:Vcc [0086] 鍵盤掃描電路:2 01 [0087] 輸入埠 1 4 [0088] 輸出埠:W2〜W3 098143999 表單編號Α0101 第16頁/共25頁 0982075328-0 201123719 [0089] 按鍵:S,λ 1-1 4-4 [0090] 行線:L1~L4 [0091] 列線:PI 〜P4 [0092] 二極體:】 [0093] 第一電阻:R2〜R3 〇 098143999 表單編號A0101 第17頁/共25頁 0982075328-0Diode: D^D , 2 m-1 [0083] First Resistor: R2 R R (m-1 ) [0084] Second Resistor: Rs [0085] Voltage Source: Vcc [0086] Keyboard Scanning Circuit: 2 01 [0087] Input 埠 1 4 [0088] Output 埠: W2~W3 098143999 Form No. 1010101 Page 16/Total 25 Page 0982075328-0 201123719 [0089] Button: S, λ 1-1 4-4 [ 0090] Line: L1~L4 [0091] Column line: PI~P4 [0092] Diode:] [0093] First resistance: R2~R3 〇098143999 Form No. A0101 Page 17 of 25 0982075328-0