]> git.friedersdorff.com Git - max/tmk_keyboard.git/blob - keyboard/hhkb/doc/HHKB.txt
Fix README.md of hhkb
[max/tmk_keyboard.git] / keyboard / hhkb / doc / HHKB.txt
1 Internal of HHKB pro
2 =====================
3 HHKB pro has MCU and some chips on separate two PCBs.
4
5 Controller PCB
6 --------------
7     M38K07M4    Renesas MCU with USB function
8                 http://documentation.renesas.com/eng/products/mpumcu/rej03b0192_38k0ds.pdf
9
10     (HHKB_controller.jpg)
11
12 Keyswitch PCB
13 -------------
14     HC4051      Analog Multiplexer: select a row line.
15                 http://www.alldatasheet.com/datasheet-pdf/pdf/203989/KODENSHI/KK74HC4051A.html
16     LS145       BCD Decoder: select a column line.
17                 http://www.alldatasheet.com/datasheet-pdf/pdf/27373/TI/SN74LS145D.html
18     BU9831      Non-volatile electronic potentiometer: for calibration?
19                 http://www.alldatasheet.com/datasheet-pdf/pdf/36387/ROHM/BU9831.html
20     TP1683/4    Capacitive Sensing controller: no datasheet available.
21
22     (HHKB_keyswitch.jpg)
23
24     Topre original chip?
25     (HHKB_TP1684.jpg)
26
27
28 Connector Cable
29 ---------------
30 Two PCBs are connected by 15 lines(13 in case of Pro2).
31 Vcc and GND use 3(2) lines each, other 9 lines are for keyboard signaling.
32
33     Keyswitch connector
34     pro  pro2           Description                               Teensy++ pins
35     --------------------------------------------------------------------------------------------
36      1       Vcc(5V)    Not exist on Pro2                         5V
37      2   1   Vcc(5V)                                              5V
38      3   2   Vcc(5V)                                              5V
39      4   3   TP1684     KEY: Low(0) when key pressed              PE6 input(with pullup)
40      5   4   TP1684     KEY_PREV: make threshold                  PE7 output
41      6   5   HC4051     A(bit0)\                                  PB0 output
42      7   6   HC4051     B(bit1) > select row(0 to 7)              PB1 output
43      8   7   HC4051     C(bit2)/                                  PB2 output
44      9   8   LS145      A(bit0)\                                  PB3 output
45     10   9   LS145      B(bit1) > select column(0 to 7)           PB4 output
46     11  10   LS145      C(bit2)/                                  PB5 output
47     12  11   LS145      D(enable) Low(0) enables selected column  PB6 output
48     13  12   GND                                                  GND
49     14  13   GND                                                  GND
50     15       GND        Not exist on Pro2                         GND
51
52     NOTE: guessing pin5(KEY_PREV) may work for hysteresis of capacitive sensing.
53     NOTE: 1KOhm didn't work as pullup resistor on KEY. AVR internal pullup or 10KOhm resistor was OK.
54
55     (HHKB_connector.jpg)
56
57
58 Keyswitch matrix
59 ----------------
60 60 keyswitches in 8*8 matrix. It is ghost-free and bounce-free.
61
62       COL 0     1       2       3       4       5       6       7
63     ROW ---------------------------------------------------------------
64       0|  2     q       w       s       a       z       x       c
65       1|  3     4       r       e       d       f       v       b
66       2|  5     6       y       t       g       h       n       _NONE_
67       3|  1     Esc     Tab     Control LShift  LAlt    LMeta   Space
68       4|  7     8       u       i       k       j       m       _NONE_
69       5|  \     `       Delete  Return  Fn      RShift  RAlt    RMeta
70       6|  9     0       o       p       ;       l       ,       _NONE_
71       7|  -     +       ]       [       '       /       .       _NONE_
72
73
74 Matrix diagram:
75
76              +-------------------------+-+-+-+-+-+-+-+     Vcc
77              |bias control?            - - - - - - - -     ---
78              |                  3.9K*8 R R R R R R R R      |
79     +--------^+      +--------+        - - - - - - - -      |  
80     |        2|      | HC4051 <0-------|-|-|-|-|-|-|-|--|R|-+
81     |         |capa. |        <1-------|-|-|-|-|-|-|-|--|R|-+
82     | TP1684  |sense |        <2-------|-|-|-|-|-|-|-|--|R|-+
83     |       11<------|        <3-------|-|-|-|-|-|-|-|--|R|-+
84     |         |      |        <4-------|-|-|-|-|-|-|-|--|R|-+
85     |         |      |        <5-------|-|-|-|-|-|-|-|--|R|-+
86     |         <-+    |        <6-------|-|-|-|-|-|-|-|--|R|-+
87     |   1   4 | |    |        <7-------|-|-|-|-|-|-|-|--|R|-+
88     +---V---^-+ |    +-^-^-^--+        0 1 2 3 4 5 6 7  33K*8
89        KEY PREV |      A B C         +-----------------+
90         |   | +-^----+ | | |         |      LS145      |
91     Vcc |   | |BU9831| | | |         +-^--^--^--^------+
92     --- |   | +------+ | | |           A  B  C  D   +------+
93      |  |   |          | | |           |  |  |  |   |      |
94     1-3 4   5          6 7 8           9 10 11 12 13-15    |
95     +--------------------------------------------------+   |
96     |                connector                         |  ---
97     +--------------------------------------------------+  GND
98                     to controller
99                                     
100
101 Signals charts
102 --------------
103     While pressing space bar, watched HHKB original controller signals by logic analyzer.
104     Row and column is looping between 0-7 each for selecting a key.
105     A key is scaned every about 15ms, so scan rate is 66Hz.
106
107     (HHKB_chart1.jpg)
108
109     Space bar locate at ROW:3 COL:7. A key is selected by HC4051(C,B,A) and LS145(C,B,A).
110     Key state can be read on TP1684(4/KEY) while asserting low on LS145(D). 
111
112     Usage of TP1684(5) is not clear. Controller seemed to output previous key state on this line.
113     However key state can be read without using this signal.
114
115     (HHKB_chart2.jpg)
116
117
118 Matrix scan pseudo code
119 -----------------------
120     for (row: 0-7) {
121         SELECT_ROW(row);        // set HC4051(A,B,C)
122
123         for (col: 0-7) {
124             SELECT_COL(col);    // set LS145(A,B,C)
125
126             _delay_us(40);
127
128             if (prev_key_state(row, col)) {
129                 KEY_PREV_ON;
130             }
131
132             _delay_us(7);
133
134             ENALBLE_COL();      // set LS145(D) to low
135
136             _delay_us(10);
137
138             if (KEY == 0) {     // read TP1684(KEY)
139                 // key pressed
140             } else {
141                 // not pressed
142             }
143
144             KEY_PREV_OFF;
145             UNALBLE_COL();      // set LS145(D) to high
146
147             _delay_us(150);
148         }
149     }
150
151
152
153 EOF