Saturday, 8 December 2012

Night of the living dead Spectrum keyboards

I have started to do some groundwork for some simple 8-bit keyboard projects. The first goal is to connect an original Spectrum keyboard to the ZX Evolution computer I discussed previously. The Evolution has pins for connecting the original keyboard, and this way, a Spectrum keyboard could be used for an authentic gaming experience.
ZX evolution keyboard input pins.
1-8 for rows, 10-14 for columns. (9 is for Reset) The rest are for Joysticks.
The figure is borrowed from the ZX Evolution manual.


Spectrum keyboard membrane, colour coded for columns and rows. 
Each of the 40 keys completes an unique connection between the 5-lane and 8-lane pathways.

With the original Spectrum, the 40 key switches are connected to the motherboard with two pathways, one with 5 lanes and the other with 8. Crossing these forms a matrix that the computer can use to decipher which of the 40 switches are pressed at a time. For those interested in the Spectrum keyboard matrix and the membrane logic, I can refer to this blog post.

Yes, it's a bit crude.
The 20 pins in the ZXevo port handle both joystick input and the Spectrum keyboard inputs. For example, my first joystick adapter is pictured above. The thirteen not-yet connected wires ought to be continued to the membrane. My approach is to do this Franken-adapter first, and if it works, do a better and more interesting solution.

My perhaps biggest concern is how to continue the fragile membrane material with wires. This could be easier with the proper parts, but I usually go first to my existing collection of junk parts. (As can be seen from my joystick adapter.) There is a certain type of connector inside the ZX Spectrum that does the job, but I do not have those kind of parts available. So, I used the two connectors I happened to have:

This image shows the piece of balsawood that fastens the membrane to the connector.

These connectors are too wide so I insert the membrane pathways along with a piece of soft balsa wood. Notice also that the membranes are one-sided. There is also a possibility the connective material in the membrane wears off with too much inserting and removing. I used a broken membrane for practice so I would not ruin a working one. (It's very common for old Spectrum membranes to have some of the pathways broken.)

The "key" chosen for testing is marked with an arrow. This is the key "5" on the Spectrum.
The sharp-sighted might note that my connectors look like ZX Spectrum peripheral connector parts. Indeed they are cannibalized from old joystick adapters. Hopefully I do not need to waste both of the connectors for this project...

I have connected two chosen pins to a multimeter. This way, I can check one key on the membrane I want to use as a switch to complete the circuit.

Pictured from the other side, testing the connection. Give my creation life!

It's not so straightforward to understand how the 8-bit computer reads the keyboard. In this respect, the above test is a bit misleading, as there are no 40 inputs inside the Spectrum which could all be individually read. Thankfully, in this project, this does not need to be deciphered. My task is just to continue the membrane wires to the corresponding pins on the ZX Evolution motherboard. The test was only about the physical connection between the membrane and the electric cables. 


Connecting the keyboard membrane to the ZX Evolution

The test was promising enough so I went forward with building a complete keyboard connector. I cut one of the peripheral connectors in half, so I do not have to waste both of them. I am using a raster board for keeping the connectors in place, and some terminal blocks for joining the cables at the other end to the same plug. I did not want to solder anything at this stage. This turned out to be a good idea because the connections ended up wrong. My terminal blocks are a bit too large for this kind of work but I will eventually abandon them anyway so it does not matter.

A bit difficult to keep this all in position...
As the membrane is connected to the ZX evolution, it becomes apparent that something is wrong. Promisingly I can get some key reactions, but everything comes from the wrong place. At first I thought I might just have got the pathways in reverse order, but no.

I ended up checking the connections directly from the ZX evo pins, connecting each row pin with each column pin with a piece of wire to find out what letters are then displayed on the screen.


It turns out the ZX evolution manual could have been more helpful here. Although the five lanes are in a direct order, as implied by the manual, the eight lanes are really not. I clarified my findings on a piece of paper, tracing each connection explicitly to the motherboard pins. The order is shown below.

The ZX evolution keyboard input port. K1-K8 connect to the wide membrane pathway,
and the D0-D4 to the narrow. Pins 16-20 are for joystick.
As I rebuilt the connections, I could finally use a proper ZX Spectrum keyboard. Now, all the keys work. However, the keyboard can't be really used yet, as this version of the connector is so poorly built. The contraption now needs to be put inside the empty Spectrum case. 

I am already happy to note the Spectrum keyboard input does not disturb the PS/2 keyboard in any way. The Spectrum keyboard can be connected at all times, and all the Evo functions can be accessed from the PC keyboard if needed.

It looks slightly infernal...
Closing the case

I replaced the Spectrum motherboard with the electronics board. I also made sure I could screw the board in place if I want to. There is only one screw that connects the motherboard to the casing, so this whole thing is a very clean to do. I have in no way ruined the original Spectrum, and will probably return all the parts after I've toyed with this result.
The view from under the hood.

I soldered the connectors to the board. I turned the connectors sideways, because otherwise they would not fit inside the Spectrum casing. I had to bend the pins to do this. As the two membrane pathways have the contact surface on a different side, the connectors also face into different directions. I have removed the flat cable connectors and soldered wires directly using the board underside, and these wires now go to the screw terminal block that brings the wires to the ZX evolution. In some ways the setup is more comfortable for the membranes than in the original. These are a bit difficult to insert, though, but that's mostly because of the silly balsa wood solution.

Playing "Bruce Lee" on the ZX evolution with the rubber keyboard.
Carpal tunnel syndrome, I welcome thee!
Was it really worth it? I mean, back in the day people usually went through the trouble to replace the original keyboard with something else. But anyway, the keyboard works as intended. The squishy rubbery feeling is almost a part of the genuine Spectrum games. Playing with something else would be almost like cheating!

I still have some points to consider. If I really want an "authentic" experience, the sound ought to come from inside the case, too... I have assumed my board works with the Spectrum+ and 128 varieties, but I have not tried it out yet.

Eventually, I hope to understand the Spectrum keyboard for connecting some other keyboard to the original ZX Spectrum, or just generally swapping different 8-bit computer keyboards with each other. With computers such as Laser 200, Spectravideo and Spectrum this ought to be doable as the keyboard "modules" usually do not contain any electronic parts, just the connection matrix. The why of such a project might be a bit unclear, but at least in the case of Laser/Fellow it would improve the existing keyboard greatly, and it would be simpler to build than a PS/2 or USB adapter. Anyway, making such a swap would mean rewiring an entire keyboard matrix, so I am not going to do that just yet.

No comments:

Post a Comment