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 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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.alldatasheet.com/datasheet-pdf/pdf/203989/KODENSHI/KK74HC4051A.html
  13. LS145 BCD Decoder: select a column line.
  14. http://www.alldatasheet.com/datasheet-pdf/pdf/27373/TI/SN74LS145D.html
  15. BU9831 Non-volatile electronic potentiometer: for calibration?
  16. http://www.alldatasheet.com/datasheet-pdf/pdf/36387/ROHM/BU9831.html
  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 9 lines are for keyboard signaling.
  25. Keyswitch connector
  26. pro pro2 Description Teensy++ pins
  27. --------------------------------------------------------------------------------------------
  28. 1 Vcc(5V) Not exist on Pro2 5V
  29. 2 1 Vcc(5V) 5V
  30. 3 2 Vcc(5V) 5V
  31. 4 3 TP1684 KEY: Low(0) when key pressed PE6 input(with pullup)
  32. 5 4 TP1684 KEY_PREV: make threshold PE7 output
  33. 6 5 HC4051 A(bit0)\ PB0 output
  34. 7 6 HC4051 B(bit1) > select row(0 to 7) PB1 output
  35. 8 7 HC4051 C(bit2)/ PB2 output
  36. 9 8 LS145 A(bit0)\ PB3 output
  37. 10 9 LS145 B(bit1) > select column(0 to 7) PB4 output
  38. 11 10 LS145 C(bit2)/ PB5 output
  39. 12 11 LS145 D(enable) Low(0) enables selected column PB6 output
  40. 13 12 GND GND
  41. 14 13 GND GND
  42. 15 GND Not exist on Pro2 GND
  43. NOTE: guessing pin5(KEY_PREV) may work for hysteresis of capacitive sensing.
  44. NOTE: 1KOhm didn't work as pullup resistor on KEY. AVR internal pullup or 10KOhm resistor was OK.
  45. (HHKB_connector.jpg)
  46. Keyswitch matrix
  47. ----------------
  48. 60 keyswitches in 8*8 matrix. It is ghost-free and bounce-free.
  49. COL 0 1 2 3 4 5 6 7
  50. ROW ---------------------------------------------------------------
  51. 0| 2 q w s a z x c
  52. 1| 3 4 r e d f v b
  53. 2| 5 6 y t g h n _NONE_
  54. 3| 1 Esc Tab Control LShift LAlt LMeta Space
  55. 4| 7 8 u i k j m _NONE_
  56. 5| \ ` Delete Return Fn RShift RAlt RMeta
  57. 6| 9 0 o p ; l , _NONE_
  58. 7| - + ] [ ' / . _NONE_
  59. Matrix diagram:
  60. +-------------------------+-+-+-+-+-+-+-+ Vcc
  61. |bias control? - - - - - - - - ---
  62. | 3.9K*8 R R R R R R R R |
  63. +--------^+ +--------+ - - - - - - - - |
  64. | 2| | HC4051 <0-------|-|-|-|-|-|-|-|--|R|-+
  65. | |capa. | <1-------|-|-|-|-|-|-|-|--|R|-+
  66. | TP1684 |sense | <2-------|-|-|-|-|-|-|-|--|R|-+
  67. | 11<------| <3-------|-|-|-|-|-|-|-|--|R|-+
  68. | | | <4-------|-|-|-|-|-|-|-|--|R|-+
  69. | | | <5-------|-|-|-|-|-|-|-|--|R|-+
  70. | <-+ | <6-------|-|-|-|-|-|-|-|--|R|-+
  71. | 1 4 | | | <7-------|-|-|-|-|-|-|-|--|R|-+
  72. +---V---^-+ | +-^-^-^--+ 0 1 2 3 4 5 6 7 33K*8
  73. KEY PREV | A B C +-----------------+
  74. | | +-^----+ | | | | LS145 |
  75. Vcc | | |BU9831| | | | +-^--^--^--^------+
  76. --- | | +------+ | | | A B C D +------+
  77. | | | | | | | | | | | |
  78. 1-3 4 5 6 7 8 9 10 11 12 13-15 |
  79. +--------------------------------------------------+ |
  80. | connector | ---
  81. +--------------------------------------------------+ GND
  82. to controller
  83. Signals charts
  84. --------------
  85. While pressing space bar, watched HHKB original controller signals by logic analyzer.
  86. Row and column is looping between 0-7 each for selecting a key.
  87. A key is scaned every about 15ms, so scan rate is 66Hz.
  88. (HHKB_chart1.jpg)
  89. Space bar locate at ROW:3 COL:7. A key is selected by HC4051(C,B,A) and LS145(C,B,A).
  90. Key state can be read on TP1684(4/KEY) while asserting low on LS145(D).
  91. Usage of TP1684(5) is not clear. Controller seemed to output previous key state on this line.
  92. However key state can be read without using this signal.
  93. (HHKB_chart2.jpg)
  94. Matrix scan pseudo code
  95. -----------------------
  96. for (row: 0-7) {
  97. SELECT_ROW(row); // set HC4051(A,B,C)
  98. for (col: 0-7) {
  99. SELECT_COL(col); // set LS145(A,B,C)
  100. _delay_us(40);
  101. if (prev_key_state(row, col)) {
  102. KEY_PREV_ON;
  103. }
  104. _delay_us(7);
  105. ENALBLE_COL(); // set LS145(D) to low
  106. _delay_us(10);
  107. if (KEY == 0) { // read TP1684(KEY)
  108. // key pressed
  109. } else {
  110. // not pressed
  111. }
  112. KEY_PREV_OFF;
  113. UNALBLE_COL(); // set LS145(D) to high
  114. _delay_us(150);
  115. }
  116. }
  117. EOF