Custom bluetooth keyboard

From SkullSpace Wiki
Revision as of 19:26, 27 November 2012 by Benbergman (talk) (Key Matrix)
Jump to navigation Jump to search

Bluetooth conversion of a Kinesis contour keyboard to a bluetooth keyboard.

Brainstorming

Available approaches

Options Pros Cons
USB HID to bluetooth adapter
  • No modification of the keyboard necessary (for USB versions of the keyboard)
  • Usable on any USB keyboard
  • USB HID host chips are uncommon and expensive
  • Programming USB HID host may be complicated
  • PS/2 version of keyboard may or may not have USB output (though there are USB related markings on the PCB)
    • If capable, would likely require modifications to the original controller board
PS/2 to bluetooth adapter
  • Simpler to decode than USB HID
  • Any microcontroller can be used
  • No modification of the keyboard necessary (for PS/2 versions of the keyboard)
  • Usable on any PS/2 keyboard
  • USB version of keyboard may or may not have PS/2 output
    • If capable, would likely require modifications to the original controller board
Custom replacement keyboard controller with integrated bluetooth
  • Getting data directly from button matrix is likely simpler than decoding some other protocol
  • Opportunity to add extra features
  • Likely better battery life
  • Any microcontroller (with enough IO) can be used
  • Supposedly replacement key wells can be had for < $90 directly from Kinesis. Add on some extra keycaps and the thumb boards and the custom controller and you could have a brand new, bluetooth Kinesis for much less than a brand new one.
    • A case would need to be made, but many people have modded their existing cases so the two halves are physically separated anyway, plus I personally think that the the thumb buttons could be at a slightly better angle, so that could be considered another pro (good use for AsentWorks 3D printer)
  • Kinesis keyboards have some advanced programmability - reimplementing that on a custom controller could take some time
  • Requires interfacing with the key matrix directly which either requires special connectors or soldering to the key matrix

Features

  • Bluetooth module might have audio capabilities in addition to the required HID function
    • Use keyboard as audio extender - include a headphone port in keyboard
    • Kinesis has a key recognition click speaker built in which can be hard to hear when listening to music, but might still annoy others
    • WT12 will do low-fi audio such as a typical BT headset, but does not support analog A2DP (use WT32 instead)
      • Overlay key click sound over bluetooth audio signal
  • USB interface for charging
    • disable bluetooth while charging and instead use the USB connection
  • Saving, editing, and uploading custom keyboard layouts to the keyboard from the computer
    • Cross platform application
    • Keyboard layers could be saved, exported, and uploaded individually
      • Example:
        • Standard keyboards have "qwerty" on the base layer and the shift key brings them to the next layer containing "QWERTY" (assuming qwerty keyboard)
        • The Kinesis firmware has a keypad layer, so when you press the keypad button, the keys under the right hand become a numpad and the shift key moves between the layers of the numpad (numbers or arrows)
      • Separate keys and their shifted values for more finely tuned layouts (can be done in xmodmap in Linux, but this isn't portable/cross platform)
        • May not act as expected in some programs as normally it is the computer that determines the shift's effect on the key, not the keyboard
        • Probably need to take special consideration into key sequences (eg pressing shift then x as opposed to x then shift)
  • Integrated pointing device
  • Bluetooth pedal
    • Needs to connect to the controller directly for most functions, so really only feasible with the custom controller
    • Need to verify keyboard's bluetooth controller can connect to two devices at once (PC and pedal(s))
  • Battery status report via bluetooth
    • Might be able to do this with just the ADC on the micro, but might need something like this for detection
    • WT12 does not directly read battery level (use WT32 instead), though reading with MCU and reporting over SPP link would work

Prototype

The Kinesis Advantages was found to natively support PS/2 output. This was tested using the PS/2 cable from a Kinesis Essential 132 (the 132 was also found to be capable of outputting USB using the Kinesis Advantages USB cable/board). The USB Kinesis Advantage is the first board that is going under the knife. Because of the relative simplicity of reading PS/2 data, this is the method that will be used.

PS/2 communication (according to the Arduino PS/2 library) only requires an interrupt pin and a generic IO pin. The WT12 requires a serial channel. These requirements are pretty basic, so any microcontroller should work fine. Additional IO might be desirable for a BT pairing button, but this feature could also be embedded into a special key combination on the keyboard itself.

To-Do list

  • Order prototype parts
  • Assemble prototype
  • Test PS/2 data aquisition
  • Test bluetooth HID output
  • Determine power consumption (will probably be somewhat high as the keyboard is likely going to not have any kind of power saving mode)
  • Find an appropriate battery
  • Design custom PCB for a final version
  • Order final version parts
  • Assemble final version

Parts

  • Bluegiga WT12 Bluetooth module (serial only breakout board - $40, full breakout board - $50, just the module - $28)
  • Microcontroller development board
    • Arduino (easy to use, PS/2 libraries) - $10-$50
    • ATmega32u4 based dev board (native USB HID output which can be used while plugged in and charging for improved reliability and charging speed) - $15-$40
    • MSP430 (specialize in low power, great for battery operation) - $5+
  • Logic level converter (PS/2 device requires 5v and WT12 requires 3.3v; microcontroller could use either) - $2
  • Power supply (for testing could use bench supply but USB charged Lithium Ion would be good to prototype too)
  • 3v3 voltage regulator - $2
  • Right angle SPDT slide switch with 3mm spacing between pins - for enabling memory lockout feature of the Kinesis pro on other versions of the keyboard - $0.50

Schematic

Block diagram:

VCC1 = 5V     VCC2 = 3V3
------------------------
              VCC1                  VCC1  VCC1               VCC2  VCC2                     VCC1                  VCC2      
 _____________  ^      _____________  ^     ^  _____________  ^     ^  ____________           ^                     ^      
|             |-'     |             |-'     '-|             |-'     '-|            |          |                     |      
|             |       |             |   RTS   |             |   RTS   |            |          |     ___________     |      
|             |       |             |---------|             |---------|            |          |    |           |    |      
|             | CLOCK |             |   CTS   |  LOGIC      |   CTS   |            |          |----|  Voltage  |----|      
|   KINESIS   |-------|   ARDUINO   |---------|  LEVEL      |---------|  BLUEGIGA  |          |    | Regulator |    |      
|             | DATA  |             |   TXD   |  CONVERTER  |   RXD   |  WT12      |         ===   |___________|   ===     
|             |-------|             |---------|             |---------|            |          |          |          |      
|             |       |             |   RXD   |             |   TXD   |            |          '----------+----------'      
|             |       |             |---------|             |---------|            |                     |                 
|_____________|-,     |_____________|-,     ,-|_____________|-,     ,-|____________|                     |                 
                v                     v     v                 v     v                                    v                 
               GND                   GND   GND               GND   GND                                  GND                

Key Matrix

The creator of the HumbleHacker keyboard replaced the controller in his keyboard and kindly posted his reverse-engineered key matrix. I have copied them below, with some basic modifications.

Left Keywell
Pin 6 7 8 10 11 12
1 \ IN LT RT
2 LS Z X C V B
3 CP A S D F G
5 TB Q W E R T
13 = 1 2 3 4 5
Right Keywell
Pin 1 2 3 6 12 13
4 UP DN [ ]
7 N , M RS . /
8 H K J ' L ;
9 Y I U \ O P
1 6 8 7 - 9 0

Reference