Weird behavior on ZX81 keyboard interface

Tell us about your other hobbies & none QL related items here :)
Post Reply
User avatar
bwinkel67
QL Wafer Drive
Posts: 1202
Joined: Thu Oct 03, 2019 2:09 am

Weird behavior on ZX81 keyboard interface

Post by bwinkel67 »

Very off-topic question here. I recently tried to add a gamepad to my TS1000 (this idea came from an article in an old Sinclair magazine from the 80's that had you create just a physical connection to attach a joystick). I had previously modified my TS1000 successfully by adding a real ribbon cable to fix a broken membrane (maybe that's adding to the problem?) I did a 20-minute video on the gamepad mod here, though it's not really necessary to watch to understand the problem (hopefully I explain it well enough below):

https://www.youtube.com/watch?v=rwQeQ-kvaas

What I discovered after the fact is that parts of the keyboard refused to work. I realized that partially in my video, assumed it was due to the fine gauge of the 10-wire cable I was using (about 1.5mm thick), and added 1.6K resistors to the connectors for the columns (k0 to k4) to fix it -- note that from its membrane diagram, the ZX81 keyboard is divided into 4 rows of 10 keys with each row split into 2 halves (groupings of 5), and each of the 5 connectors for k0 to k4 connect one of the columns of the groupings of 5. However, digging more into it, I realized some key combinations were completely dead with the gamepad mod.

To figure out how to fix it, I simplified things and used a better cable (one from an old PS-2 mouse). I Just connected 2 wires from a 3 foot length cable (and no gamepad) to k0 and k1 and again, some key combinations didn't work. I added some variable resistors and discovered that there was no sweet spot (i.e. either I'd get the keys for the gamepad cable to work or the key on the keyboard to work but not both).

Finally, after cutting the cable to a little over 2 feet, I got both to work (with 1.6K resistors). I would have thought that the variable resistors would have achieved the same thing, but they didn't. I don't have sensitive enough equipment (I have a cheap digital multi-meter and an old analog one) that can measure any resistance between the two wires in my gamepad cable, though when I use two twisted pair wires of about 3 feet, the issue disappears.

So what's going on here? Anyone here have a good understanding of the ZX81? Which chip reads the keyboard presses on the ZX81 (presumably its ULA) and why does adding two wires to k0 and k1 (just two wires, no gamepad) cause some keys to stop working (usually shift-S to get LPRINT is the last combo that refused to work). Those two wires are acting like an antenna, I'm guessing, though the PS-2 cable is shielded. When I use the twisted pair wires, they are not in a sheath, just by themselves.

I'll eventually post this on a couple of ZX81 forums but thought I'd ask here first as I may get help in clarifying my question -- AND the lot of you are more technical than I find sometimes on other forums.


User avatar
bwinkel67
QL Wafer Drive
Posts: 1202
Joined: Thu Oct 03, 2019 2:09 am

Re: Weird behavior on ZX81 keyboard interface

Post by bwinkel67 »

Giving it more thought (after having had to formulate my question above), perhaps the cause is that interference is being added into the keyboard signal lines, even with a shielded cable. So the question is, what can i do at the connection end to reduce that interference? Obviously adding resistance doesn't fix it. Do I have to coil the wire around a magnet maybe?


ones' complement
Over Heated PSU
Posts: 131
Joined: Tue Nov 30, 2021 1:19 am

Re: Weird behavior on ZX81 keyboard interface

Post by ones' complement »

If you have one handy - try looping wires through ferrite toroid ?


User avatar
bwinkel67
QL Wafer Drive
Posts: 1202
Joined: Thu Oct 03, 2019 2:09 am

Re: Weird behavior on ZX81 keyboard interface

Post by bwinkel67 »

I did try a ferrite toroid (ended up trying multiples) and it had no impact. Asked Charlie Ingley, since he developed a ZX81 ULA substitute and he pointed me in the right direction. The extra gamepad cable is adding too much additional capacitance for the ULA to properly identify the key presses. So a passive approach isn't going to work. However, add a few transistors and 5 volts and should easily add an active circuit to do the same thing.

Here is a diagram of one that Charlie found for me, though mine will have 8 transistors and be wired directly to the 8-button gamepad:

keyboard.png


User avatar
Pr0f
QL Wafer Drive
Posts: 1308
Joined: Thu Oct 12, 2017 9:54 am

Re: Weird behavior on ZX81 keyboard interface

Post by Pr0f »

The problem with the speccy and Zx81 is they both use the same method for addressing the keyboard - they use the top 8 address lines to provide rows and then read in the 5 bit code representing keys pressed in that row into the ULA - there is minimal protection from any extended cables that may introduce noise / crosstalk / or static

In the original designs - the length of wires attached to these connections was pretty short - it was the matrix tails plus the length of the tracks in the membrane itself, so these issues were minimised.

You could modify the ZX81 to use a bank of transistors to boost the signal available on the address lines that scan the keyboard, or use a TTL buffer chip - this also helps protect the CPU too.

You could also use protection resistors and diodes on the input side going into the ULA, - this should also help.


Post Reply