Changing buses
Dig your old Apple keyboard out of the attic and modify it to work over USB
The Apple Desktop Bus (ADB ) first appeared on the Apple IIGS in 1986 and was also used on every Mac
from then until the iMac in 1998. Like USB, it’s a serial connector that can be daisychained from one device to another. The old Apple keyboard has an ADB port on each side: you use one to connect the keyboard to the Mac and the other is used by the ADB mouse.
The connector uses an S-Video plug, which can only plug in one way round, so there’s no need for the infuriating USB ritual of trying it one way, then the other way, then back to the first way. ADB uses four wires: two for power and ground, one for the data, and one to carry the power-on signal that enables the keyboard to be used to turn on the Mac.
USB devices also use four wires. However, they lack a power-on pin. Also, there are two data wires instead of one, both of which carry the same data, just with reversed voltages to help eliminate noise. So in practice USB and ADB are both single-channel serial interfaces, and they should be electrically compatible.
The catch is that the ADB controller formats the data for each key press in a different way than USB. I could deal with this at the Mac end by writing a low-level OS X keyboard driver that identifies which port I’m using and decodes the signals directly. However, this would be quite tricky to do, prone to breaking with future operating system upgrades, and I’d need to install it on each computer to which I connect the ADB keyboard. A better solution is to reformat the signals into USB-speak on the keyboard itself.
As luck would have it, someone who goes by the name of Hasu over on the geekhack.org forum wrote a program to do this several years ago. The program runs on the Teensy 2 microcontroller, which is like an Arduino but smaller. I bought one from Amazon (£11.50,
amzn.to/2j343NA) and it arrived with me about three weeks later, having travelled all the way from China.
Probing pins
The wiring side is fairly straightforward. The keyboard opens up with three Phillips screws on the underside and each ADB port has a small circuit board for the ADB controller. The Wikipedia page for ADB has a pin diagram for the connector, and I used the continuity tester on my multimeter to work out the corresponding points on the circuit board for the power and ground pins. I soldered leads to each of these and connected them to the VCC (+5V) and GND (ground) pins on the Teensy. Then I soldered a data wire to the F0 pin on the Teensy but left it unconnected at the other end. Before I soldered it onto the keyboard, I wanted to check which side of the ADB controller I needed to connect it to. To do that I needed to install the program on the Teensy and run some tests.
And so we arrive at this instalment’s Tricky Problem. The procedure for compiling code for the Teensy and transferring it to the board is theoretically easy enough (see the step-bystep guide on page 78), but I just couldn’t persuade my desktop Mac to recognise that there was a Teensy on the other end of the USB cable. The Teensy powered up just fine, and apparently reacted correctly when I pressed the reset button. But to the Mac, it was as though I’d stuck the other end of the USB cable in my ear.
Unbelievable coincidence
The page at bit.ly/2iZJ2Dc suggests that the most likely explanation is that the USB cable is faulty, which is ridiculous because I use that cable all the time, but I changed it anyway for one from my big box of spares. That didn’t work either, and neither did two others. Now, obviously, it is implausible that four separate cables would all be faulty, so I spent a couple of hours searching online and trying various different options for TeensyLoader. Nothing worked. It was at this point that it occurred to
USB and ADB are both single-channel serial interfaces and should be electrically compatible
me that although I use that USB cable all the time, I only ever use it to charge devices; I don’t actually send any data down the cable. Connecting phones and quadcopters and cameras directly to a Mac with a USB cable is so ’90s. So I checked the cable with my SLR camera and, sure enough, the Mac didn’t see it as a storage device. With growing incredulity, I tried the other three cables in turn and none of them worked – they were all just cheap charging cables without their data pins connected. After a quick trip to Amazon to order a replacement (£4.49, Amazon Basics), I gave up for the day.
Adios, ADB
The next morning, I tore open the utilitarian cardboard package and double-checked all the pin connections on the new cable: all looked good. After that, uploading the ADB converter program was done in three clicks of a mouse. With the Teensy running, I held down a key on the ADB keyboard and probed with the unsoldered end of the data wire on the ADB controller board until I started seeing letters appear on the Mac’s screen.
Next, I soldered in this connection properly and added a 10,000-ohm pull-up resistor between the data and power pins. This helps the signal voltages to stabilise quickly between key presses. The internal pull-up resistor on the Teensy might be strong enough to do this on its own, but adding an external one can help to eliminate noise from the data line.
To run the USB cable out of the keyboard case, I could have drilled a new hole in the case to accommodate it, or enlarged the existing one for the ADB port. Instead, I decided to desolder and remove one of the ADB ports altogether. I might change my mind about this conversion in the future, of course, and it would be easier to solder the old ADB connector back on than to fill in a hole in the keyboard’s plastic case.
Even after this hardware modification, the ADB port on the other side continues to work, so I’m still able to use the keyboard with my Macintosh SE when I need to. I could even use it to run my old ADB ‘ball’ mouse with my Intel Mac mini if I wanted – but even I’m not that nostalgic for the ’80s!