Spencer Nelson's USB-NeXT Is an Arduino NeXT Keyboard Adapter — Built Through Reverse Engineering
Odd timing issues lead down a rabbit-hole of oscilloscope probing, logic analyzing, and AM/FM radio theory.
Developer Spencer Nelson has gone a step further than most in search of the perfect desktop keyboard: reverse engineering the protocol used for the NeXT peripherals back in the late 1980s.
"Steve Jobs’s NeXT computer company made a keyboard in 1988," Nelson explains, referring to the company Jobs set up after being ousted from Apple Computers in 1985. "With no prior electronics experience, I tried to get it to work over USB. To do so, I had to go way deeper than I ever expected — all the way back over 100 years to broadcast radio standards from the 1920s. I learned tons and tons, and had a lot of fun."
Superficially, the target keyboard looks a lot like any modern 104-key: There's a main letter-and-number section to the left, a four-way cursor block, a number pad, and even a set of multimedia keys for volume, brightness, and power — located where the Home block would traditionally be found. There's no sign of function keys, though, and the device definitely pre-dates the Windows/Super key and, of course, USB connectivity.
Nelson's first step: Already-available code for turning an Arduino into an adapter. "Nothing really worked quite right," he recalls. "Keys sometimes worked, but sometimes didn’t. The 'A' key worked great, but if I pressed 'X' or 'C' then I would never get any signals again until I unplugged it and replugged it. Something was wrong."
The problem appeared to be one of timing. There were several possibilities: Claims made regarding a 51-microsecond pulse width were called into question, possibilities regarding the original controller's baud rate raised, and even the possibility that things had drifted from their original factory specification. "This was a 33 year old keyboard," Nelson admits. "Maybe the electronic components in it had just worn out, drifting over time to work at a slightly slow speed."
With the Arduino Micro proving too slow to perform easy signal analysis, Nelson picked up an oscilloscope — and found a 52 microsecond pulse width. This was then verified with a low-cost logic analyzer, revealing a stable 52.74 microsecond pulse width from the keyboard — but a very variable sleep period on the Arduino, which "seemed to be easily bad enough to cause lot of problems."
Having calculated an 18.960kHz clock speed, though, Nelson had further questions — which led to opening up the keyboard for a closer look. The clock source: a 455kHz resonator. "The NeXT non-ADB keyboards have a pulse width of 52.74 microseconds," Nelson concluded, "because they send data every 24 ticks of a 455kHz clock."
Nelson's full write-up, which includes a guess at why 455kHz was picked, on his journal site; the source code for the project, designed for an Arduino Nano, is available on GitHub under the permissive BSD three-clause license.