My IBM Model-M Keyboard mod

This is the famous IBM Model-M "clicky" keyboard. This model (Part. no. 1395665) originally was made for IBM mainframe terminals, and had an RJ45 (like ethernet) connector. As Model-M funs know, this keyboard is not compatible with the PC PS/2 or USB keyboard standard. It uses the PS/2 protocol, but instead of the scan code set #2 it uses scan code set #3.

Though it seems like a standard US keyboard layout, some differences are noticable if you have a closer look. The key names are a bit different:

Can you see the LEDs? Well, there are no LEDs at all...

Well, this keyboard - apart from these differences - is a perfect clicky keyboard, and the layout is almost the same as the PC's original PS/2 standard. So I wanted to use it as my de facto keyboard. Why? Because it lasts forever, and the typing experience is unique. Ask for some Model-M funs, if you do not beleive. (Actually, I am typing this manual with this keyboard, and it does its job well. Clicky as hell.)

So I decided to interface it with my PC, no matter what it takes. Fortunately I am not the only one, so I have found some good references about this topic on the Internet. See the links at the bottom of the page. The first idea was to encode the scan code set #3 to something that PC undestands. But then I realized that the orginal hardware inside the keyboard is quite old, it consumes a lots of current, so replacing the entire internal PCB would be better. I had some experience with PIC microcontrollers, and knew that there are USB capable devices. From software point of view, Microchip is also a good choice. There are good example codes in the freely downloadable libraries.

This is the original PCB in the keyboard: (the FPC connectors are already removed)

And this one is my new one, using a PIC24FJ128GB microcontroller:

Actually this PCB was intended to use for something else, but then I found some spare boards, and realized that they will be good for a prototype.

The schematic would be something like this. Even if it looks complex, it really isn't. It's just a simple PIC24 microcontroller with power and connections to the keybaord rows and columns, also for the USB port. There are some passive parts, like resistors and capacitors, plus a quartz for clocking the PIC. A programmer port is also added for the device. The rest is done by the software.

Click on the picture to view in larger size

A possible board (I haven't done this yet, only planned):

The software

As I mentioned above, the orignal idea came from this page: - Many thanks to Chris Lee for this excellent work.

This project is interfacing the PS2 Clicky keyboard with an AtMega microcontroller. However that works, I've choosen the PIC version anyway, since I know the PIC's framework better. In the framework - what is called earlier as Microchip Solutions, now it's rather Microchip Libraries for Applications - has a USB Keyboard Device example, that is the one I used.

For the keyboard scanning and decoding, I used one function from the project RUMP. This function uchar scankeys(void) is scanning the keyboard matrix periodically, and if detects any keypress or release, it constructs the USB HID report, which is sent to the USB HOST (PC) by the USB stack.

Obviously there are many differences between the AtMega and the PIC implementation. It's just because the hardware is different.

There are no LED indicators on this keyboard, but the firmware supports them, so it is possible to use 3 LEDs for the Caps Lock, Num lock and Scroll Lock keys. But my keyboard is in an excellent shape, I did not want to hurt the plastic case. Any kind of drilling, cutting, glueing should be a vandalism I think. :-)

This is, how the prototype board fits into the case:


My modified USB capable Model-M keyboard works fantastic. It is quite noisy when I am typing, my son loves that sound. It makes my wife a bit upset, too. What a good device!

Future plans....
If there was enough interest, I would make this board officially as a product. It all depends. Let's see how other Model-M crazy people like it.
You can contact me, if you have any questions or comments:


References and links: