I decided that rather than attempt to replace the soundbox, I would initially do a replacement for the NeXT keyboard and mouse combination. This is partly because the NeXT monitor bus appears to operate at around 20MHz making it that much harder to reverse engineer, and partly because I wanted to get back into practice programing MCUs (it has been a while). So, I broke out my box of PIC processors… for this, I’m attempting to use the PIC16F88, but there are options like the PIC18, PIC24 and PIC32 that are quite appealing for different reasons, not the least of which is USB support. So, I set up a little lab that looks like the following.
Nestled under the display is a NeXTStation Color (not the Turbo because I’m working with non-ADB). In the far background is a machine I used to repair NeXT MO drives. On the right you can see the breadboard I’m using, and behind that, the NeXT soundcard for a non-ADB system. This allows me to flip between machines on my KVM, and the NeXT slab. I bought some connectors from DigiKey that match the NeXT keyboard, and have breakouts from the NeXT to the breadboard. This allows me to easily attach a scope/logic analyser to the keyboard to see what’s going on. I actually use 2 different LA/MSO, the MSO19 (http://www.linkinstruments.com/mso19.htm) which is very nice, though the sample window is a bit small, and the Chronovu (http://www.chronovu.com/) which has a nice big sample window. I also have a bus pirate and started out with an OpenBench Logic Sniffer (http://dangerousprototypes.com/) but found that for my purposes, especially in reverse engineering the monitor bus, it’s too limited.
I started my investigation by reading what someone before me has done (NeXT keyboard bus on 68k.org), because I don’t see the need in repeating effort unecessarily! This appears to have all the information needed, but it didn’t seem to match what I was seeing. Given how long ago this was done, and how little time was spent on it, it’s quite a nice bit of reverse engineering, but it is inaccurate. By adding power to the NeXT keyboard and then hooking up my scope/LA, I could see that it needs some signal from the host in order to transmit data: it depends on a clock from the host, whereas the PS/2 devices generate their own clock. This is what things looks like when the host is turned on and a key is pressed:
The red line is the clock line, and the orange line is the data line. The bit width is about 50us, and there appears to be 9 bits in the clock line, and 16 bits in the data line. The clock line is interesting… we might almost call it a device selection line, because over a longer window, you can see this pattern:
The clock like flips back and forth between two basic patterns, and guess what, mouse data is transmitted after the pattern with 2 bits set, and the keyboard data is sent after the pattern with one bit set. If there is data in neither, then an empty data packet is sent. Apart from missing the need for, and the importance of the clock/device selection line, the information on the keyboard/mouse that degs reverse engineered so long ago seems fairly accurate. Over time I will generate a complete protocol specification, but the next step (NeXTStep?) is to use the above to:
For people with a soundbox, step ‘3’ will allow them to connect a PS/2 mouse and keyboard, and a VGA display, to a NeXT non-adb system.
Eventually this effort might also lead to USB, PS/2 and ADB devices being adapted to non-ADB NeXT machines. ADB support is interesting only because it’s an option for Turbo systems only, and because of the incompatibility of ADB devices with some software on the NeXT.