19 Jul 2020, 17:18

This is a keyboard from an NEC APC.
NEC-APC-top.jpg (322.13 KiB) Viewed 238 times
The keyboard has yellowed in an inconsistent way, I suppose because of how it was stored before I came upon it.

It differs from the one in the wiki in not having stepped key caps for the extra-wide keys. It is dated 56年7月, that is, July 1982, so I am not sure what determines which was used.

Some other '80s features of the keyboard itself:
  • There are 22 half-height programmable function keys (like on some HP keyboards) and an area above them for holding a custom plastic template showing how they were to be used.
    NEC-APC-template.jpg (398.06 KiB) Viewed 238 times
  • There are 4 physically locking shift keys: CAPS LOCK, as expected, but also GRPH 1, GRPH 2, and ALT. The two SHIFT keys send identical codes, so, with FNC and CTRL, there are either an equal number or one fewer non-locking, depending on how you count.
  • Most of the keys are laser-etched. The D key on this board has some of the printing worn off, so I may try to take a lacquer stick to it. But the digit keys in the number pad are double shot. I can't tell for certain, but I think this is the case with the one in the wiki, too. I have to suppose they were shared with some other keyboard.
  • It connected to the PC with a 24-pin Centronix-style connector on the end of a monstrously huge coiled cable.
    NEC-APC-cable.jpg (235.86 KiB) Viewed 238 times
The protocol is also a little odd. The System Reference Guide has the keyboard schematic (with a few typos) and a brief theory of operation. But this is quite hard to follow because it isn't careful to distinguish what the keyboard sends to the PC and what the PC presents to programs or sends when acting as a terminal. Also, all the descriptions are of the 26-pin internal header and not the external cable that actually plugged into the PC.

There is an 8-bit parallel data output and three open collector strobe signals that go with it. The text only explains what two of these do and likewise omits the third in Table 2-11 Keyboard Interface Lines. The keyboard schematic B-3 shows all three coming from the 8048 and the PC schematic B-11 shows how they were handled there, namely loading three latches, which are read, in turn, as I/O ports listed in Table E-9. This table implies that there are four shifts; there are in fact five: FNC, CTRL, GRPH 1, GRPH 2, and ALT, with the last being SD6. The mysterious Book/Page register, shown as two nibbles, seems, in fact, to be just two bits: SHIFT on SD1 and CAPS LOCK on SD3.

There are no up transitions. The shifts are only sent when a non-shift key is pressed.

The sequence is:
  • SWSTB with the first half of the shifts.
  • DSTD with the scan code, which is mostly ASCII matching the legend, with slightly different codes for the numpad digits and 8-bit characters for the function keys.
  • For some keys, DSTB with zero. Maybe to inhibit auto-repeat?
  • PBSTB four times(?) with the second half of the shifts.
There is no input because there are no LEDs or buzzer.

In the wiki photo, one can see that there is a switch in the upper-right of the PCB and a rubber gasket on the back of the top keyboard cover. If the gasket is removed, one can reach inside (or use a pen) to push the button. This controls a fourth open collector signal, which is low (active) when the switch is neither all the way in nor all the way out. This was the PC's debug switch, like the programmer key on classic Macs. It doesn't make sense to have this jump to the bootloader, since I am using a Teensy (there aren't any other readily available ATMega32U4 boards that have all eight signals of any one port -- B in the case of Teensy -- and that doesn't also drive an LED on any of them). So I have the switch enable debug output for hid-listen.

It took a bit of digging to find the necessary connector.
NEC-APC-converter-open.jpg (246.61 KiB) Viewed 238 times
NEC-APC-converter.jpg (229.49 KiB) Viewed 238 times
Code is here.

Post Reply

Return to “Workshop”