Wednesday, 18 July 2012

ZX81 USB Keyboard Mark II + Raspberry Pi

This is an old post, preserved for reference.
The products and services mentioned within are no longer available.

Following on from my earlier posts about turning a dead ZX81 into a USB Keyboard here, a reader of this blog asked me to make him one. His plan was to also fit in his Raspberry Pi and produce an all in one unit complete with working keyboard. A few days later, a ZX81 arrived from him in the post and I set to work.

The first task was to try to fit everything in. Space is limited inside there, after all the original unit always boasted there were only 4 chips inside (although some ZX81's had 2x2114 RAM chips instead of the single 4016 which took the total to 5). The Raspberry Pi has three (there's a RAM chip sandwiched with the Broadcom chip). Four if you count the SD card. Five when you add the ATMega 328 on my USB Keyboard board. So we're on a par, and the chips are smaller, so it should fit fine....

This seems to be the best option so far, the audio and composite are poking out of the ear and mic sockets, and the rest of the cables can run out of the back. You can even see the LED's through the TV connector cutout. There are a couple of pillars to remove, but otherwise there's no cutting. It does actually close properly, it's just slightly open in the picture.

The USB plug at the top doesn't quite fit, but you can just see from the transparent one in the photo, it should be possible to cut one down to fit. That didn't leave much space for the keyboard. It also introduced the issue to wear and tear on the delicate membrane tails from the keyboard. If the case had to be opened to access cables and change the SD card, it was going to get a lot of activity, and this ZX81 still had the original membrane which was more delicate than mine which had one of RWAP's new ones.

To get around this, I turned the idea on it's head and mounted the board on the underside of the lid, so the only connection between the two halves of the case would be a USB cable. The membranes had been cut down once already, and needed to be cut again to restore one missing column of keys, so they were short anyway and fit nicely.

When I designed the original, I had wired the rows and columns to whichever of the ATMega328's I/O pins were the most convenient, and had a lookup table in code to store which pin was connected to which row or column. In this case, the connections were reversed (because it was upside down), and layed out differently, so all I had to do was update that one lookup table and away it went.

Now time to fit it all into the shell of the ZX81.

I found some right angled USB cables and cut one of those down for the keyboard, and installed a small USB hub sticking three ports out of that back, and tied everything down with sticky tie bases.

In use it's much like the original ZX81, just slightly more powerful. No RAM pack hanging precariously off the back, so it's not likely to crash if you sneeze within 10 yards of the unit, which some of the originals were unfortunately prone to.

Just a note to add, I'm a great fan of old technology, and have rebuilt and restored many classic computers of the 80's, so I wouldn't normally condone this sort of thing. The original had a faulty ULA, and when they go, the only real option is to get another ZX81, so it seemed a good use for the case. The owner of the Raspeerry81 had a better ZX81 with composite mod etc., so this was a spare, but did come with a working board. That's been put aside for later -  I have other plans for that - watch this space.

2022 Note, I don't do these sorts of things anymore, the opposite in fact. If you want a ZX81 clone (not in a ZX81 case), then check out this more recent post on my Minstrel 2 and Minstrel 3 kits.