• Re-mapping the Key Matrix

    Julian Calaby2 days ago 0 comments

    When I initially built this, I mapped out the matrix of the USB keyboard controller by attaching wires to the pads for the 8 rows and 18 columns to a bunch of switches and used those to map out the entire matrix.

    I did this by building a piece of protoboard with 26 switches all wired to a common wire, then wiring the rows to 8 and the columns to the remaining 18. I could then simulate a key at a particula row and column by pressing the switches for the row and column simultaneously.

    I wrote this up in an Excel spreadsheet which I've lost somewhere on one of the dead hard disks from my first computer.

    I then cut traces and soldered wires to convert the matrix of the AEK into that particular matrix.

    Now, 15 years later, I'm having to reverse-engineer the bits I need from that map by beeping out the keyboard.

    I ended up with this:

    (Colours indicate rows of physical keys, blank cells are rows and columns that don't have a corresponding key.)

    I'm going to need to make some modifications to improve this to make the microcontroller selection a touch easier:

    • Combine columns 9 and 15: this moves the shift keys into the gap in column 9.
    • Combine columns 14 and 16: this moves the left alt key into a gap in column 14.
    • Combine columns 0 and 17: this moves the right alt key into a gap in column 0.
    Then I also need to split the keypad equals key from the keypad enter key. I'll probably put it at row 4, column 14 so I don't have to re-solder both wires.

    This leaves me with 8 rows and 15 columns requiring a total of 23 GPIOs to produce a total of 105 keys. Adding in the three LEDs, I need 26 GPIOs.

    Frustratingly my LeoStick has only the Arduino standard 14 + 6 = 20 GPIOs and even if I use the 3 in the programming port, I'm still 3 GPIOs short, so I'm going to have to buy a microcontroller for this.

  • Design Compromises

    Julian Calaby3 days ago 0 comments

    Hacking two keyboards together requires making compromises between what is available on the controller and which keys are present on the keyboard.

    I got somewhat lucky by buying a keyboard with a Windows compatible power key, so I was able to wire that to the power key on the keyboard.

    However there were a couple of other compromises that I made to make it all work properly:

    Modifier Keys

    Apple keyboards have their modifier keys arranged as Ctrl, Option / Alt, Command / Apple and PC keyboards have them arranged as Ctrl, Windows, Alt.

    As a PC user, I made the decision when hacking the matrices together to ignore the labels on the keys and wire the modifiers in the PC fashion. Thankfully, this isn't a big deal as QMK lets me map the keys however I like.

    Keypad Equals Key

    Numpads on Apple Keyboards have a "=" key next to the numlock / clear key and all of the operator keys (+, -, * and /) get moved around to fit it in.

    This isn't something that's done on PC keyboards so the controller I used didn't have any sensible place on it's matrix to wire this to.

    Consequently I made the decision to make it work with most calculator applications so I wired it in parallel with the numpad enter key.

    This is something that I'll have to rectify when re-wiring the matrix.

  • The Plan

    Julian Calaby3 days ago 0 comments

    My knowledge of custom keyboards and the community around them has grown immensely in the past 15 years. Concepts like easy-to-program microcontrollers with USB ports and big community led projects to make easily customisable keyboard software were unheard of when I started.

    Back then Arduinos were barely a thing, let alone stuff like the Arduino Leonardo or Teensy.

    So ultimately the sensible path forwards was to acquire a board that did what I wanted and hack stuff to make it work.

    However today, I have desires to build designs of keyboard I can't get elsewhere (I want a full-size Thinkpad-style keyboard with Cherry MX Blues or an Ergodox style split one with a built-in Trackpoint) and maybe a simple step towards that would be to take my slightly annoying old AEK and modernise it's internals.

    What's even better is that I already have a QMK compatible microcontroller on hand: a LeoStick, essentially a thumb-drive sized Arduino Leonardo with an ATMEGA32U4 (Freetronics is an Australian manufacturer of Arduino compatible boards)

    So now all I need to do is modify the matrix to be compatible (which I believe will be adding diodes to prevent ghosting) and replace the existing controller board with the LeoStick.

    Simple!

    Except it won't be, I'll have to map out the entire matrix, figure out where I can hack in the diodes, then modify it.

    Mapping out that matrix will be the next step.

  • 15 Year Review

    Julian Calaby3 days ago 0 comments

    Ultimately the fate of the AEK was that I barely used it. My computer at the time required a PS/2 keyboard, so I used a Microsoft Multimedia Keyboard on that (also excellent to type on) and shortly after I upgraded it to a motherboard that fully understood USB keyboards my partner bought me an (excellent) DAS keyboard which immediately became my daily driver.

    The AEK then ended up in my pile of computer stuff in my wardrobe and was mostly forgotten about until, almost 10 years after I built it, I ended up working for a company that provided me with a MacBook Pro for my development computer, and as the supplied external keyboard (an Apple Magic Keyboard - I still don't know what made it magic) was a poor typing experience, the only obvious solution was to dig out my old Apple Extended Keyboard and plug it back into a Mac.

    My colleagues loved it, I loved it, but as I got used to it's shape and layout I started typing faster and faster and discovered that while it was lovely to type on, it had a pretty glaring flaw: certain combinations of keys, ones which I hit fairly regularly, wouldn't work every time. I think that the issue is that there's a maximum number of keys the controller can detect at once and when I typed fast enough, I was hitting that limit.

    I replaced it with a Logitech one which didn't have that issue.

    So back into the cupboard it went until 2020 when I started working from home full-time and needed a good keyboard. My partner has an old Acer keyboard from forever ago which got her through an essay heavy university course without a single hiccough, but somewhere in the past 15 years the spacebar's springs had failed so it wouldn't pop back up reliably. I tried to fix it, but nothing I did worked reliably.

    Faced with the possibility of having to steal a fairly cheap Logitech keyboard from another computer, I remembered my AEK and pressed it back into service almost 15 years after I built it.

    And it's excellent, the keys are wonderful to type on, not quite as nice as the Cherry MX Blues in my DAS, but still pretty damn good, and once again, I've started running into the limitations of it's hardware: every now and again it misses a keypress. I'm clearly typing slower now than I was before, because it doesn't happen as often as it used to, but it's still bothering me.

    So it's time to do something about it.

  • The Beginning

    Julian Calaby3 days ago 0 comments

    Back when I was a poor university student, I came across a bunch of Apple peripherals in a dumpster, this included this Apple Extended Keyboard, a couple of mice and one of their smaller keyboards.

    I'd never really spent any time with Apple hardware (my family is firmly IBM PC compatible) so I'd never typed on one, but it felt nice and after opening it up, I concluded that it would be possible to make it a USB keyboard by the simple process of completely re-wiring the matrix to suit a USB keyboard controller and wiring all of that together.

    I was technically right, it was possible to do all of that, but it was a heck of a lot more effort than I'd expected and produced a far inferior result than I'd hoped for.

    The parts required were pretty trivial:

    1. A USB keyboard (I got what was, at the time, an unbelievably cheap one for $7)
    2. A USB hub (this was so I could replace the ADB port on the far side with two USB ports)
    3. Some USB connectors (I bought the USB-B one and the dual-USB-A one came from a PC case)
    4. Wire (some is breadboard wire I purchased for the project, the rest is misc wire from ... well anywhere I could pull it from)
    5. USB cabling (all recycled from the $7 keyboard's cord)

    And the process was simple, but time consuming:

    1. Map out the entire matrix of the USB keyboard (it had a bunch of bonus keys that the hardware recognised but didn't have a physical key, presumably for international layouts)
    2. "Apply" that onto the AEK's PCB
    3. Wire between the new controller, USB connectors and hub
    4. Cut out some of the standoffs and supports in the base so the wires would actually fit
    5. Expand the far-side ADB hole so two USB plugs would fit
    6. Glue everything down (hot snot FTW)
    7. Plug it in and enjoy it

    The "application" of the new matrix onto the PCB was, by far, the most complicated and time consuming part.

    I did this by doing three major operations: de-populating the board of anything that got in the way (essentially all the controller chips) cutting traces on the board where they didn't fit and wiring between pads to build out new bits of matrix where needed.

    It was rather time consuming.

    I can't remember exactly how I did it, but I do remember that I couldn't remove the metal plate that holds the keyswitches in position, so I couldn't remove the wire links that allowed some of the traces to jump over other traces, so I had to cut those traces by cutting the copper on the board. I estimate that I made well over 100 cuts to split the nets up into the few bits that corresponded with the matrix of the USB controller.

    While I was doing that, I was also wiring between keyswitches to link the various chunks of net together to form the matrix the USB controller was expecting. I think I marked each keyswitch off as I wired it in by putting a black sharpie mark covering the copper next to the pad.

    Each net got either a yellow or black wire attached to it which then connected it to the relevant pad on the USB Keyboard controller board. The USB keyboard I bought was a cheap membrane keyboard so it had some black substance on the pads which I had to scrape so I could solder to them.

    The black (row?) nets also got a resistor in series with them (harvested from somewhere) to simulate the resistance of the membrane traces. (This was probably unnecessary, but I didn't want to risk it)

    Finally I wired the original LEDs up to the LED pads on the controller board, wired in the USB hub, glued everything down closed it up, plugged it in and marvelled at how awesome it was to type on what was one of my first a mechanical keyboards.