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 |
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.
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.
Hi David,
ReplyDeleteI'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!
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.
DeleteThe 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.
Wilf_Rigters_ZXKBDv3_keyboard_Interface
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.
ReplyDeleteIt 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).