Keyboard firmwares for Atmel AVR and Cortex-M
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.

HHKB.txt 9.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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 TMK pin usage
  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 is pressed PD7 input(with pullup)
  32. 4 4 5 TP1684 HYS: High(1) when key is pressed PB7 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 PC6
  44. 15 HC4051(Z3) ~Enable of Z3 row8-15 PC7
  45. NOTE: Probably HYS changes threshold for upstroke and makes hysteresis in the result.
  46. NOTE: HYS should be given High(1) when previous KEY state is Low(0).
  47. NOTE: 1KOhm didn't work as pullup resistor on KEY. AVR internal pullup or 10KOhm resistor was OK.
  48. NOTE: JP has two HC4051(Z2,Z3) and line 5, 6 and 7 are connected to both of them.
  49. (HHKB_connector.jpg)
  50. Keyswitch matrix
  51. ----------------
  52. HHKB switch matrix is ghost-free and bounce-free.
  53. Pro/Pro2(8x8):
  54. COL 0 1 2 3 4 5 6 7
  55. ROW ---------------------------------------------------------------
  56. 0| 2 q w s a z x c
  57. 1| 3 4 r e d f v b
  58. 2| 5 6 y t g h n _NONE_
  59. 3| 1 Esc Tab Control LShift LAlt LMeta Space
  60. 4| 7 8 u i k j m _NONE_
  61. 5| \ ` Delete Return Fn RShift RAlt RMeta
  62. 6| 9 0 o p ; l , _NONE_
  63. 7| - + ] [ ' / . _NONE_
  64. JP(16x8):
  65. COL 0 1 2 3 4 5 6 7
  66. ROW ---------------------------------------------------------------
  67. 0| ESC TAB LFn LShift LCtrl
  68. 1| 4 E MuHKN C D
  69. 2| 3 W LAlt X S
  70. 3| 1 HHK
  71. 4|
  72. 5| 5 R V F
  73. 6| 2 Q LGui Z A
  74. 7| 6 T Space B G
  75. 8| 9 I Kana , K
  76. 9| 8 U Henkan M J
  77. A| 7 Y N H
  78. B| 0 O RAlt . L
  79. C| BS Right RShift Enter
  80. D| \ [ Down Up ]
  81. E| - P RFn / ;
  82. F| ~ @ Left Ro :
  83. Matrix diagram:
  84. Pro/Pro2:
  85. +-------------------------+-+-+-+-+-+-+-+ Vcc
  86. |bias control? - - - - - - - - ---
  87. | 3.9K*8 R R R R R R R R |
  88. +--------^+ +--------+ - - - - - - - - |
  89. | 2| | HC4051 <0-------|-|-|-|-|-|-|-|--|R|-+
  90. | |capa. | <1-------|-|-|-|-|-|-|-|--|R|-+
  91. | TP1684 |sense | <2-------|-|-|-|-|-|-|-|--|R|-+
  92. | 11<------| <3-------|-|-|-|-|-|-|-|--|R|-+
  93. | | | <4-------|-|-|-|-|-|-|-|--|R|-+
  94. | | | <5-------|-|-|-|-|-|-|-|--|R|-+
  95. | <-+ | <6-------|-|-|-|-|-|-|-|--|R|-+
  96. | 1 4 | | | <7-------|-|-|-|-|-|-|-|--|R|-+
  97. +---V---^-+ | +-^-^-^--+ 0 1 2 3 4 5 6 7 33K*8
  98. KEY HYS | A B C +-----------------+
  99. | | +-^----+ | | | | LS145 |
  100. Vcc | | |BU9831| | | | +-^--^--^--^------+
  101. --- | | +------+ | | | A B C D +-------+
  102. | | | | | | | | | | | |
  103. 1-3 4 5 6 7 8 9 10 11 12 13-15 Pro |
  104. 1-2 3 4 5 6 7 8 9 10 11 12-13 Pro2|
  105. +--------------------------------------------------+ |
  106. | connector | ---
  107. +--------------------------------------------------+ GND
  108. JP:
  109. +-----------------------------+-+-+-+-+ Vcc
  110. |bias control? - - - - - ---
  111. | 3.9K*5 R R R R R |
  112. +--------^+ +--------+ - - - - - |
  113. | | | HC4051 <0-----------|-|-|-|-|----|R|-+
  114. | |capa. | Z2 <1-----------|-|-|-|-|----|R|-+
  115. | TP1684 |sense | <2-----------|-|-|-|-|----|R|-+
  116. | <---+--| <3-----------|-|-|-|-|----|R|-+
  117. | | | | <4-----------|-|-|-|-|----|R|-+
  118. | | ~En| <5-----------|-|-|-|-|----|R|-+
  119. | | +----> <6-----------|-|-|-|-|----|R|-+
  120. | | | | | A B C <7-----------|-|-|-|-|----|R|-+
  121. +---V---^-+ | | +-^-^-^--+ | | | | | |
  122. KEY HYS | | | | | | | | | | |
  123. | | | | +--------+ | | | | | |
  124. | | | | | HC4051 <8-----------|-|-|-|-|----|R|-+
  125. | | | | | Z3 <9-----------|-|-|-|-|----|R|-+
  126. | | | +--| <A-----------|-|-|-|-|----|R|-+
  127. | | | | <B-----------|-|-|-|-|----|R|-+
  128. | | | | <C-----------|-|-|-|-|----|R|-+
  129. | | | ~En| <D-----------|-|-|-|-|----|R|-+
  130. | | | +-> <E-----------|-|-|-|-|----|R|-+
  131. | | | | | A B C <F-----------|-|-|-|-|----|R|-+
  132. | | | | +-^-^-^--+ 0 1 2 3 4 5 6 7 33K*8
  133. | | | | | | | +-----------------+
  134. | | | | | | | | LS145 |
  135. Vcc | | | | | | | +-^--^--^--^------+
  136. --- | | | | | | | A B C D +-------+
  137. | | | | | | | | | | | | | |
  138. 1-2 3 4 14 15 5 6 7 8 9 10 11 12-13 |
  139. +--------------------------------------------------+ |
  140. | connector | ---
  141. +--------------------------------------------------+ GND
  142. Signals charts
  143. --------------
  144. While pressing space bar, watched HHKB Pro original controller signals by logic analyzer.
  145. Row and column is looping between 0-7 each for selecting a key.
  146. A key is scaned every about 15ms, so scan rate is 66Hz.
  147. (HHKB_chart1.jpg)
  148. Space bar locate at ROW:3 COL:7. A key is selected by HC4051(C,B,A) and LS145(C,B,A).
  149. Key state can be read on TP1684(4/KEY) while asserting low on LS145(D).
  150. (HHKB_chart2.jpg)
  151. Signal of JP:
  152. 1) Select row
  153. rowC ____~~~~____~~~~ 3.8/3.8ms(JP) 7.7/7.7ms(Pro) S2 of HC4051
  154. rowB __~~__~~__~~__~~ 1.9/1.9ms(JP) 3.8/3.8ms(Pro) S1 of HC4051
  155. rowA _~_~_~_~_~_~_~_~ 1.0/1.0ms(JP) 1.9/1.9ms(Pro) S0 of HC4051
  156. 0123456701234567 selected row(Pro)
  157. 0123456789ABCDEF selected row(JP)
  158. rowEn0 ________~~~~~~~~ 7.7/7.7ms(JP only) ~Enable of Z2 HC4051(JP only)
  159. rowEn1 ~~~~~~~~________ 7.7/7.7ms(JP only) ~Enable of Z3 HC4051(JP only)
  160. 2) Select column
  161. colC ____~~~~____~~~~ 550/410us(JP) / us(Pro)
  162. colB __~~__~~__~~__~~ 200/210us(JP) 450/460us(Pro)
  163. colA _~_~_~_~_~_~_~_~ 100/110us(JP) 220/230us(Pro)
  164. 0123456701234567 selected column
  165. 3) Wait 5us after column select, then set prev, strobe colD to spit out key status and read it.
  166. hys _~~~~_____ 20us if previous key state is low
  167. colD ~~~__~~~~~ 10us strobe
  168. key ~~~____~~~ 22us indicates current state of the key
  169. NOTE: JP scans twice fast as Pro/Pro2 does. So Pro/Pro2 scans 8x8 matrix in 15.4ms while JP scans 16x8 in that time.
  170. EOF