]> git.gir.st - tmk_keyboard.git/blob - keyboard/hhkb/doc/HHKB.txt
Add HHKB JP support
[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.ti.com/lit/ds/schs122j/schs122j.pdf
16 LS145 BCD Decoder: select a column line.
17 http://www.ti.com/lit/ds/symlink/sn74ls145.pdf
18 BU9831 Non-volatile electronic potentiometer: for calibration?
19 https://www.spezial.com/doc/rohm-a/bu9831.pdf
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 lines are for keyboard signaling.
32
33 HHKB connector lines:
34 JP Pro2 Pro Function Description Teensy++ pins
35 --------------------------------------------------------------------------------------------
36 1 Vcc(5V) 5V
37 1 1 2 Vcc(5V) 5V
38 2 2 3 Vcc(5V) 5V
39 3 3 4 TP1684 KEY: Low(0) when key pressed PE6 input(with pullup)
40 4 4 5 TP1684 KEY_PREV: make threshold PE7 output
41 5 5 6 HC4051 A(bit0)\ PB0 output
42 6 6 7 HC4051 B(bit1) > select row 0-7 PB1 output
43 7 7 8 HC4051 C(bit2)/ PB2 output
44 8 8 9 LS145 A(bit0)\ PB3 output
45 9 9 10 LS145 B(bit1) > select column 0-7 PB4 output
46 10 10 11 LS145 C(bit2)/ PB5 output
47 11 11 12 LS145 D(enable) Low(0) enables selected column PB6 output
48 12 12 13 GND GND
49 13 13 14 GND GND
50 15 GND
51 14 HC4051(Z2) ~Enable of Z2 row0-7
52 15 HC4051(Z3) ~Enable of Z3 row8-15
53
54 NOTE: guessing pin5(KEY_PREV) may work for hysteresis of capacitive sensing.
55 NOTE: 1KOhm didn't work as pullup resistor on KEY. AVR internal pullup or 10KOhm resistor was OK.
56 NOTE: JP has two HC4051(Z2,Z3) and line 5, 6 and 7 are connected to both of them.
57
58 (HHKB_connector.jpg)
59
60
61 Keyswitch matrix
62 ----------------
63 HHKB switch matrix is ghost-free and bounce-free.
64
65 Pro/Pro2(8x8):
66 COL 0 1 2 3 4 5 6 7
67 ROW ---------------------------------------------------------------
68 0| 2 q w s a z x c
69 1| 3 4 r e d f v b
70 2| 5 6 y t g h n _NONE_
71 3| 1 Esc Tab Control LShift LAlt LMeta Space
72 4| 7 8 u i k j m _NONE_
73 5| \ ` Delete Return Fn RShift RAlt RMeta
74 6| 9 0 o p ; l , _NONE_
75 7| - + ] [ ' / . _NONE_
76
77
78 JP(16x8):
79 COL 0 1 2 3 4 5 6 7
80 ROW ---------------------------------------------------------------
81 0| ESC TAB LFn LShift LCtrl
82 1| 4 E MuHKN C D
83 2| 3 W LAlt X S
84 3| 1 HHK
85 4|
86 5| 5 R V F
87 6| 2 Q LGui Z A
88 7| 6 T Space B G
89 8| 9 I Kana , K
90 9| 8 U Henkan M J
91 A| 7 Y N H
92 B| 0 O RAlt . L
93 C| BS Right RShift Enter
94 D| \ [ Down Up ]
95 E| - P RFn / ;
96 F| ~ @ Left Ro :
97
98
99 Matrix diagram:
100
101 Pro/Pro2:
102 +-------------------------+-+-+-+-+-+-+-+ Vcc
103 |bias control? - - - - - - - - ---
104 | 3.9K*8 R R R R R R R R |
105 +--------^+ +--------+ - - - - - - - - |
106 | 2| | HC4051 <0-------|-|-|-|-|-|-|-|--|R|-+
107 | |capa. | <1-------|-|-|-|-|-|-|-|--|R|-+
108 | TP1684 |sense | <2-------|-|-|-|-|-|-|-|--|R|-+
109 | 11<------| <3-------|-|-|-|-|-|-|-|--|R|-+
110 | | | <4-------|-|-|-|-|-|-|-|--|R|-+
111 | | | <5-------|-|-|-|-|-|-|-|--|R|-+
112 | <-+ | <6-------|-|-|-|-|-|-|-|--|R|-+
113 | 1 4 | | | <7-------|-|-|-|-|-|-|-|--|R|-+
114 +---V---^-+ | +-^-^-^--+ 0 1 2 3 4 5 6 7 33K*8
115 KEY PREV | A B C +-----------------+
116 | | +-^----+ | | | | LS145 |
117 Vcc | | |BU9831| | | | +-^--^--^--^------+
118 --- | | +------+ | | | A B C D +-------+
119 | | | | | | | | | | | |
120 1-3 4 5 6 7 8 9 10 11 12 13-15 Pro |
121 1-2 3 4 5 6 7 8 9 10 11 12-13 Pro2|
122 +--------------------------------------------------+ |
123 | connector | ---
124 +--------------------------------------------------+ GND
125
126
127 JP:
128 +-----------------------------+-+-+-+-+ Vcc
129 |bias control? - - - - - ---
130 | 3.9K*5 R R R R R |
131 +--------^+ +--------+ - - - - - |
132 | | | HC4051 <0-----------|-|-|-|-|----|R|-+
133 | |capa. | Z2 <1-----------|-|-|-|-|----|R|-+
134 | TP1684 |sense | <2-----------|-|-|-|-|----|R|-+
135 | <---+--| <3-----------|-|-|-|-|----|R|-+
136 | | | | <4-----------|-|-|-|-|----|R|-+
137 | | ~En| <5-----------|-|-|-|-|----|R|-+
138 | | +----> <6-----------|-|-|-|-|----|R|-+
139 | | | | | A B C <7-----------|-|-|-|-|----|R|-+
140 +---V---^-+ | | +-^-^-^--+ | | | | | |
141 KEY PREV | | | | | | | | | | |
142 | | | | +--------+ | | | | | |
143 | | | | | HC4051 <8-----------|-|-|-|-|----|R|-+
144 | | | | | Z3 <9-----------|-|-|-|-|----|R|-+
145 | | | +--| <A-----------|-|-|-|-|----|R|-+
146 | | | | <B-----------|-|-|-|-|----|R|-+
147 | | | | <C-----------|-|-|-|-|----|R|-+
148 | | | ~En| <D-----------|-|-|-|-|----|R|-+
149 | | | +-> <E-----------|-|-|-|-|----|R|-+
150 | | | | | A B C <F-----------|-|-|-|-|----|R|-+
151 | | | | +-^-^-^--+ 0 1 2 3 4 5 6 7 33K*8
152 | | | | | | | +-----------------+
153 | | | | | | | | LS145 |
154 Vcc | | | | | | | +-^--^--^--^------+
155 --- | | | | | | | A B C D +-------+
156 | | | | | | | | | | | | | |
157 1-2 3 4 14 15 5 6 7 8 9 10 11 12-13 |
158 +--------------------------------------------------+ |
159 | connector | ---
160 +--------------------------------------------------+ GND
161
162
163 Signals charts
164 --------------
165 While pressing space bar, watched HHKB original controller signals by logic analyzer.
166 Row and column is looping between 0-7 each for selecting a key.
167 A key is scaned every about 15ms, so scan rate is 66Hz.
168
169 (HHKB_chart1.jpg)
170
171 Space bar locate at ROW:3 COL:7. A key is selected by HC4051(C,B,A) and LS145(C,B,A).
172 Key state can be read on TP1684(4/KEY) while asserting low on LS145(D).
173
174 Usage of TP1684(5) is not clear. Controller seemed to output previous key state on this line.
175 However key state can be read without using this signal.
176
177 (HHKB_chart2.jpg)
178
179 5us after setting colA-C
180 colA _~~~~~~~~~~~~~~~~~~
181 prev _~~~~_____ 20us if previous key state is low
182 colD ~~~__~~~~~ 10us column enabled
183 key ~~~____~~~ 22us hold state of the key
184
185 prev ____~~~~__________ 20us(JP)/17us(Pro2)
186 key ~~~~~~_____~~~~~~~ 22us
187 colD ~~~~~~__~~~~~~~~~~ 10us(LS175)
188
189 colC ____~~~~____~~~~ 550/410us(JP)
190 colB __~~__~~__~~__~~ 200/210us(JP)
191 colA _~_~_~_~_~_~_~_~ 100/110us(JP) 200/210us(Pro2)
192 0123456701234567 selected column
193
194 rowC ____~~~~____~~~~ 3.8/3.8ms(JP) S2 of HC4051
195 rowB __~~__~~__~~__~~ 1.9/1.9ms(JP) S1 of HC4051
196 rowA _~_~_~_~_~_~_~_~ 1.0/1.0ms(JP) S0 of HC4051
197 0123456701234567 selected row(Pro/Pro2)
198 0123456789ABCDEF selected row(JP)
199 rowEn0 ________~~~~~~~~ 7.7/7.7ms ~Enable of Z2 HC4051(JP only)
200 rowEn1 ~~~~~~~~________ 7.7/7.7ms ~Enable of Z3 HC4051(JP only)
201
202 NOTE: JP scans twice fast as Pro2 does. So Pro2 scan 8x8 matrix in 15.4ms while JP can 16x8 in that time.
203
204
205
206
207 Matrix scan pseudo code
208 -----------------------
209 for (row: 0-7) {
210 SELECT_ROW(row); // set HC4051(A,B,C)
211
212 for (col: 0-7) {
213 SELECT_COL(col); // set LS145(A,B,C)
214
215 _delay_us(40);
216
217 if (prev_key_state(row, col)) {
218 KEY_PREV_ON;
219 }
220
221 _delay_us(7);
222
223 ENALBLE_COL(); // set LS145(D) to low
224
225 _delay_us(10);
226
227 if (KEY == 0) { // read TP1684(KEY)
228 // key pressed
229 } else {
230 // not pressed
231 }
232
233 KEY_PREV_OFF;
234 UNALBLE_COL(); // set LS145(D) to high
235
236 _delay_us(150);
237 }
238 }
239
240
241
242 EOF
Imprint / Impressum