A Better ThinkPad USB Keyboard Adapter

by rampadc in Circuits > USB

15423 Views, 45 Favorites, 0 Comments

A Better ThinkPad USB Keyboard Adapter

20140609_011339.jpg
USB ThinkPad keyboard Adapter - Final version

When I first got started with microcontrollers, the one thing that I wanted to make the most was a USB adapter for my ThinkPad T60 keyboard. I've always enjoyed typing on my T60 keyboard and I would love to use it on all the laptops I may buy in the future.

Since then, I started to develop two solutions: an Arduino implementation and a MSP430 implementation. It was easy and straightforward to create an adapter using an Arduino but due to the limited pins count, I had to resort to external counters and ICs making keyboard scanning was unbearably slow. The footprint was too big, there were wires everywhere. In short, I didn't like it.

So I pushed on with my MSP430 implementation and finally, the project came to fruition. Despite being significantly harder to develop, this approach offers much greater benefits: faster keyboard scanning time, NumLock keypad toggling, remote wake-up and full keycodes support. And of course, the TrackPoint works too.

Please note that this is written more as a project log, rather than a tutorial. Links to PCBs and receptacle, and firmware code will be provided at the end.

The Hardware

2014-06-07 06.33.07.png
t60-pcb-revisions.jpg

I got into the microcontroller world with Texas Instruments MSP430 Launchpad so I chose to use their USB chips. This turned out to be a fairly poor investment. Firstly, since the keyboard will be plugged in to the computer all the time, there is no need for the MSP430's super low power feature. Secondly, the TrackPoint is essentially a PS/2 mouse. It uses 5V for power source. Using a MSP430 at 3.3V requires logic level converters. Thirdly, USB chips are expensive. During the development, I learnt of AVR's V-USB, which can turn most Atmel 8-bit microcontrollers into USB microcontrollers. It uses 5V power lines, the same as the TrackPoint and the chips would be cheaper. But it was late as I've already invested a lot of time into learning the MSP430 family and getting AVR development boards and programmers were out of my budget at the time.

In general, the keyboard requires a minimum of 28 input/output lines for 16 rows, 8 columns, 1 FN line and 3 PS/2 lines. Although 3 PS/2 lines are required, one of the line is for the controller to reset the TrackPoint, thus only 2 logic level converters are needed.

The final hardware design is the bare minimum to use USB functionality on MSP430 line. The button is used to flash firmware over USB using MSP430's Bootstrap Loader mode. This eliminates using an external programmer, great for the end-user.

From schematics of the ThinkPad T60 computer, it is found that the keyboard receptacle used is manufactured by JAE with part number of AA01B-S040VA1.

The goal is to save as much money during the prototyping stage as possible. Since 50x50mm is the smallest and cheapest option available from most cheap PCB manufacturers, the PCB design is made to fit into these boundaries.

The Software

Capture.PNG
T60 matrix.PNG
Capture.PNG

In code, the keyboard matrix is consisted of keycodes from the USB HID Usage Table, from page 53. It is written as a single dimension array, organized in a similar fashion to the table as shown: 8 rows by 16 columns. In the firmware provided (next step), this matrix will be listed from address 0xF000. The numbers are hex codes of the corresponding key from the matrix. You can edit the hex codes in this firmware file to change the matrix accordingly to your keyboard matrix if needed.

Originally, I planned to write a PC software that allows user to customize the matrix, add custom keyboard combinations, etc. However, given that not a lot of people would know if their keyboard receptacle for their laptop is the same as mine, it wouldn't be useful, and by adding custom keyboard combinations, it may slow down keyboard scanning. The final result may not be worth it.

Downloads

This project is closed-source. Although the source code is written in C, it is split into many source files and quite hard to navigate through. Without proper documentation, it is more beneficial in my opinion to learn from application notes provided by microcontroller vendors.

You can get the PCBs from Tindie. They are available in 2 flavours. Have your pick:

ThinkClamp v0.6.1 Rev 1.1

ThinkClamp v0.6.2

The version number difference is based on the components types used. They both work well, v0.6.1 has may have better stability electrical wise, but it uses smaller components so they maybe harder to solder, while v0.6.2 sticks to the bare minimum and can be easier to solder.

Firmware: http://www.mediafire.com/view/15cu8yu3ymbgnbh/Thin...

To upload the firmware:



• Start TI MSP430 USB Firmware Upgrade Example software, click Next and accept the terms
• Unplug USB cable from device if plugged in
• Hold down BSL button, then insert the cable
• Release BSL button The software should now detect the device.
• Choose 'Select firmware' and browse to ThinkClamp_v0.6.txt
• Click 'Upgrade firmware' to flash the device