Wednesday, February 27, 2019

ZX-Key, External Keyboard For ZX81s and Other Micro Computers: Part 2

This blog entry I'll take a quick look into the ZX-Key Expansion interface required to get the ZX-Key Keyboard working with a ZX81.

Final Production ZX-Key Expansion Interface

The ZX-Key Expansion Interface for the ZX81

Primarily the expansion board is based on Wilf Rigters' designs. Changes I've made along the way have been minor, and don't on the whole modify how the original design works. Best refer to Wilfs article for an excellent account and explanation. It's enough to say that there are two 74HC245 ICs that handle the decoding of the ZX81s BUS and afford the implementation of a matrix keyboard.

The modifications I've ended up making to the original design have been necessitated by the desire to use the Keyboard component of the project with ZX81s, the RC2014, (or other mircos) and PCs via USB.

First Iterations

Initially I breadboarded a portion of the circuit for some basic testing, just for a bit of satisfaction. Unsurprisingly that worked perfectly fine, so went ahead and built up a prototype PCB version.

Breadboard Test
For the PCB I added a +5v rail for powering an Arduino Pro Micro which is located on the keyboard PCB and also broke out the ZX81s reset line. In addition diodes used on the row lines have been moved from the Interface to the Keyboard PCB (See the Keyboard Blog Entry - Coming in Part 3).

All seemed to work just fine (after a stupid layout issue and a bit of trace cutting), however on deeper inspections I ran into a major problem when using the popular ZXpand SD card reader in conjunction with the keyboard. The ZXPand would often not read an SD card, or if it did would load corrupted applications or files.

This seemed to be a power related issue, as powering the Arduino Micro via USB instead of through the ZX81 mostly resolved the problem. Removing the Arduino entirely completly solved the issue, with the keyboard working normally. In summary while the decoder interface worked fine, it didn't in combination with the enhanced keyboard.

Testing the ZX-Key Prototype Keyboard and Interface with a ZX81
The First Iteration: Well it seemed to work fine, but a ZXPand looms in the background.

Second Iterations 

To resolve the power problems I added voltage regulator, this takes power from the +9v rail supplying both the interface and the attached keyboard. Additional diodes on the column lines were also added to the keyboard PCB.  Thankfully these changes solved all the niggling issues with the ZXpand.

Due to the additional diodes on the Keyboard increasing the voltage drop, the CMOS 74HC245 ICs were replaced with 74HCT245 ICs, the TTL level equivalents. TTL signals provide an extended logic level voltage range counteracting the voltage drop in the signals coming from the Keyboard.

Interestingly, the changes made to the keyboard and the changes made to the interface both worked independently. So I've managed to solve the problem twice.

ZX-Key Expansion Card Schematic

See more entries for this project: Part 1Part 2Part 3Part 4Part 5

If You Enjoyed This Share It And Buy Me A Coffee

  • Follow Me on Masterdon
  • Buy Me A Coffee


  1. Hi David,

    I'm trying to develop my own keyboard for the ZX Spectrum, and reading your schematics, I'm wondering what would happen if the original keyboard has a key pressed in a column, and your keyboard does not?

    It seems to me that both the ULA's and your keyboard interface's logic will be enabled through decoding the same address, and ULA would be pulling down the column's data line for the key, while your interface would be driving the same bit high (as no key is pressed). Wouldn't this effectively short a 74hc245 output to ground, overloading it? And shouldn't the interface instead put the data lines in high-impedance state when no key is pressed?

    Am I missing something? Do you think you could help me understand this? Thank you!

    1. Address lines are first buffered with 74HC245, (connected through diodes, which are on the keyboard PCB). Preventing the keyboard from overloading ZX system address signals.

      The ZX-keys interface and keyboard are based on Wilf Rigters', have a look here for a very thorough in depth description of how the circuit works as it's essentially the same.


  2. Thanks for your reply, David! I read your schematics, as well as Wilf's schematics and description, and I see the same problem in both.

    It has nothing to do with the fact that the keyboard matrix itself is buffered from the bus, actually it's the choice of the buffer that is the problem. I think that it should have open-collector outputs instead of push-pull outputs.

    The ULA uses open-collector outputs on the data bus, and the data bus is pulled high by 8.2K resistors. When a key is pressed on the system's keyboard, the ULA pulls *down* the corresponding data line. When no key is pressed, the ULA outputs are high-impedance, and the data bus remains pulled high.

    However, the 74HC245 used in your and Wilf's design will actively pull the data bus *high* when no key is pressed.

    So, when a key is pressed on the system keyboard, ULA pulls the data line *low*, but if the corresponding key is not pressed on your keyboard the 74HC245 will pull the same line *high*. The current will flow between the 74HC245 output and the ULA output, unimpeded by any resistors, potentially damaging either or both.

    However, the scan time is normally short and infrequent (unless a key is stuck), and I don't really know how each chip will handle this. It seems that the Ferranti's ULA 2000 at least will sink 40mA, and the 74HC245 will source 35mA, which is quite close, but I don't know if there's any current limiting there.

    In any case, if I got this right, I wouldn't use this approach in a design, but instead would pick an open-collector output transceiver (SN74LS641? perhaps).