Arduino interface USB keyboard to 8x5 matrix vintage computer

A year ago I posted a request for a solution to use an Arduino to interface a USB keyboard to a Sincair ZX81. This Z80 computer from 1981 uses an 8x5 matrix keyboard (membrane). After so many years many of these keyboards have broken. Solutions for PS/2 keyboard exist, but nobody could help me with USB, so I started my own project.

The solution I have made is based on the Arduino Uno and USB Shield, using the USB Host 2.0 library (downloaded from GitHub) and from that the USBHIDBootKbd example as basis.
The Arduino reads the key pressed on the USB keyboard and translates this into an 8-bit column and 5-bit row code, plus a special bit for the Shift-key.
Some hardware is needed to interface with the ZX81 signals, which can either be done with a crosspoint switch or, in my case, a cheaper option with 74HC4051’s and a 4066 for the Shift bypass. This design makes the signals independant of timing factors on the ZX81.
If anyone needs more details I can provide the schematic for the 4051’s.

The Arduino code is pretty straightforward, any improvement suggestions are welcome.
Comments and questions are welcome too.

See attachment for the code. Even if you don’t own a Sinclair ZX81, this code shows how to use the USB keyboard functions and could easely be adapted for other systems.

Martin

ZX81_USBHIDBootKbd_testing_coder_v3.ino (10.4 KB)

I wonder if my parents still have my old zx81 in a box somewhere in the loft… Its keyboard is broken, of course.

Can you post that schematic? Can’t quite picture how your 4051s are used.

Of course its highly ironic that you are fixing a simple membrane keyboard using considerably more computing power than the '81 has in the first place!

I remember back in the day that keyboards were sold equipped with mechanical keys to replace the membrane.

Paul

PaulRB:
Can you post that schematic? Can't quite picture how your 4051s are used.

If you do not want n-key roll-over (which almost certainly was not practical in the ZX81), you use two connected "back to back" One selects to a row and the other selects a column in the keyboard matrix. Seven bits (including enable) encode any (single) combination in an 8 by 8 matrix.

For an additional specific key-press such as shift, you just need one switch - a 74HC4066 has four available.

Okay, see attachment for the schematic of the 4051’s (E is pin3).

regards,

Martin

schematic_ZX81KBD.jpg

[

PaulRB:
Of course its highly ironic that you are fixing a simple membrane keyboard using considerably more computing power than the '81 has in the first place!

I remember back in the day that keyboards were sold equipped with mechanical keys to replace the membrane.

Paul

Yes there are other options:

  • You can buy a new membrane for about 15 GBP, use hot steam to have the old one unglue and stick the new one in place
  • You can try to get the PS/2 keyboard solution hardware somewhere
  • You can try get one of the DK'Tronics or other type ZX81 real keyboards, I sometimes see them on eBay, not very cheap however

As I never saw a USB solution I thought it would make a nice project.
The computing power of the Arduino is much more of course, but then again I do not lose the Arduino and can use it in different other projects if I like.

Another (next step) challenge would be to increase the functions (I could use one more port of the 4066 and Arduino for reset of the ZX81 for example or program functions keys) and have a hardware connector on the back side of the ZX81 instead of using the membrane connectors inside.

Regards, Martin