You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

HHKB.txt 10KB

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