Friday 18 January 2008

Keyboard Hacking!

As mentioned previously, I want to build my own keyboard interface. I think I'm a fairly bright guy, so I should be able to figure out how a keyboard works and how to hack (the old version of the word, as in "opening something up, figuring out how it works, and possibly modifying it to do something different/better") one, right?

This ended up being not as difficult as I thought it might be. A warning for the faint-hearted though - the pictures in the blog show that the final product is by no means pretty - I'm sure with funds, time, effort the resultant object could be significantly prettier, but that isn't a priority for me - if it is for you, check out the I-PAC from Ultimarc.

I've used my own terminology in the process that I know is wrong, but it makes sense to me, and maybe it'll make sense to you.

The process:
1. get an old/unused keyboard and open in up
I used an unused PS2 keyboard - I think this process would work fine for USB but I've never opened a USB keyboard so I'm not sure.

2. de-construct the keyboard paying careful attention to what goes where

First Open the Keyboard
In the top right hand corner (looking at the "opened" keyboard the way you would use it, if it were closed) is the brains circuit board - notice the little metallic "tabs" in a line across the bottom - these connect to the "nervous system"

3. seperate the "brains" from the "nervous system"
The nervous system is the term I use to describe the two thin, plastic sheets with circuits drawn on them - we'll call these the "membranes". Membrane Package

The two sheets are stamped "upper" Upper Membrane and "lower"Lower Membrane - the upper sheet connects to the "brain" by contact with 8 of the 26 metallic tabs Upper Membrane - Contacts, the lower sheet has contacts that rest on metallic tabs 9 through 26 Lower Membrane - Contacts - there is a layer in between to separate the upper from the lower with holes under each of the keys on the keyboard Membranes Exploded!, effectively masking out the tracks except for the holes where the upper track can be pushed down to make contact with the lower track.

EUREKA!

It's at this point that I realise for the first time in my life how a keyboard works (call me naive if you like, but I've never had need to know before)

When you press a key, the upper track and lower track connect. Let's take my RETURN key - on the upper layer, if I trace all the way back to the contact points, the upper track for the RETURN key connects to the "brain" at tab 4, and the lower track connects at tab 14. Thus, when I press RETURN, connections 4 and 14 are joined - this is read by the brain and the "RETURN key signal" is sent by the keyboard's "brain" to the PC.

4. figure out which "nerve combination" sends what keypress to the PC
I have good eyesight (I don't wear glasses) and was always good at the "first out which string is connected to the balloon" drawings in kids books. This skill, I hadn't realised until now, is a critical life skill if you want to trace keyboard "nerves" back to the brain.

I set the wife up with a bottle of Merlot and a "chick flick" and I sat next to her on the sofa for 2 hours, with the keyboard nervous system on one knee, and an A4 pad on the other, and traced the combinations for each and every key on my board. I started out with the intention of tracing only the keys I needed for 2 players worth, and some interface controls, but at some it either became easier to do them all, or my notorious OCD kicked in.

I found the best method to do this was to draw the keyboard keys onto each "membrane", then process them a layer at a time. I took the upper layer, started with connection tab 1, then traced tab one writing down every key on the tab 1 path. When finished, I started with tab 2, and so on until the top layer was finished at tab 8.

I repeated this for the lower layer, which started at tab 9 through to 26.

5. map out all the "nerve combinations" (or just the ones you need)
At this point, I have 2 sheets of A4 - one with upper layer listings Tracing - Keyboard Contact Pairings, and one with lower Tracing Summary Page 2. I took a third sheet of A4, wrote out all the keys in some order that made sense to me (left to right, top to bottom) then created two columns - I went through the upper layer listings jotting the tab number into the first column for each key, then the lower layer in the second column. I now have a sheet that tells me every nerve combination for every key on my keyboard Tracing Summary Page 1. I can now dispose of the membranes (actually I mounted them on the wall near my PC as some form of trophy, testifying to the effort required to trace these combinations)

5.5 the big test
Full of excitement, I grab a paper-clip, stretch it out, plug the remaining "brain" into my laptop, and hesitantly try connecting "tabs" together to send key presses to the computer. The first one works exactly as I thought it would, and I could not contain a small "woo-hoo!" 5 minutes later and I've spelled my name in a text editor using my paper-clip - I feel like I've just built a rocket ship!

6. replace the "nerves" with screw connector blocks
Now this is one of those points in this process where I'll point out things I would do differently second time around - i strip both ends from a series of 26, 6 inch "bell wire" (anything fairly small diameter, up to 1mm per wire) and start to solder the wires onto the metallic tabs.

DO THIS DIFFERENTLY - the wires liked to move around a lot as they were only resting on top of the tabs as I soldered. I have a 1mm drill bit and a small, rotary drill tool used for engraving, etc. (like a Dremel) and I would have drilled little holes through each of the tabs, to make soldering the wires a lot(!) easier.

I used a hot glue gun and blurbed all over the connections to make sure they stayed in place and as insulation - seemed like a good idea at the time, but not pretty to look atHot Glue Blub.

DO THIS DIFFERENTLY - the PS2 wire into the "brain" was very secure whilst in the keyboard housing, but very fragile now out of the housing - use some insulation tape or hot glue to prevent accidentally twisting or pulling this loose (like I did, and had to trim and re-solder these wires back into placeFragile PS2 Connection.

At the other end of the 26 wires, screw them into screw-block connectors and you have your I-PAC equivalent board, ready to go (looks nowhere near as nice as the I-PAC, but YOU built it, and that's got to count for something?)Dodgy Wiring 1

I mounted mine on a firm piece or corrugated card (again, liberal use of the glue gun) and trimmed - isn't she a beauty?Controller Mounted on Cardboard!

4 comments:

  1. Great - I just started to plan my own mame machine. This site is great with good info and I cant wait to get home and rip some old keyboard apart.
    Keep posting more!

    ReplyDelete
  2. Thank you - nice to know that someone, somewhere might find this useful.

    ReplyDelete
  3. wow that is very pretty. I am building a MAME cabinet myself and this helped out a ton!

    ReplyDelete
  4. GOOD BLESS YOUU!!! I WILL CONECT WIRES COMBINATIOS TO A HOMEMADE PIEZOELECTRIC DRUM... I THINK THAT IT WOULD ACTIVATE THE KEY, FOR EXAMPLE "G" AND TOONTRACK SUPERIOR DRUMMER WILL HIT A SOUND... WISH ME LUCK... THANKS FOR THE HELP... =)

    ReplyDelete