ZX Spectrum Turned Into A USB Keyboard

ZX

They’re a little hard to find in the US, but the ZX Spectrum is right up there with the Commodore 64 and the Atari 8-bit computers in England. [Alistair] wanted to recreate the feeling of sitting right in front of the TV with his Speccy, leading him to create the ZX Keyboard, a Spectrum repurposed into a USB keyboard.

While most projects that take an old key matrix and turn it into a USB keyboard use the TMK firmware, [Alistair] wanted to flex his programming muscles and wrote the firmware from scratch. It runs on an Arduino Pro Mini, scanning the matrix of five columns and eight half rows to turn combinations of keypresses into an astonishing number of commands, given the limited number of keys on the ZX.

The firmware is available on [Alistair]‘s repo, available to anyone who doesn’t want to pay the £50 a new ZX Spectrum keyboard will cost. As far as the usability of a Spectrum keyboard goes, at least [Alistair] didn’t have an Atari 400 sitting in the attic.

Comments

  1. gregkennedy says:

    Wasn’t the ZX keyboard notoriously horrible? This mod seems to be going the wrong way : ) Also, why not program the ZX to dump keypresses out some port, and translate from there? Then you wouldn’t need to modify the original machine at all.

    • Hirudinea says:

      That was the ZX81 ( http://en.wikipedia.org/wiki/Sinclair_ZX81 ) which had a horrendous membrane keyboard, that was so bad that hackers started adding proper keyboards about 10 seconds after it came out. The one above is the ZX Spectrum, which although it has a horrible keyboard it makes the ZX81 “keyboard” look like an old mechanical IBM keyboard! And I think he did the hack this way because he said the Spectrum itself wasn’t working.

    • Programming would involve saving to and loading from a cassette drive (or ZX Microdrive). Not something you would want to go back to in these days of flash drives!
      I vaguely remember building an interface for one of these. The I/O port / Address lines were brought out to the edge of the PCB and available at the back of the machine. Did the Spectrum have a Z80 SIO chip?

      • RunnerPack says:

        Not necessarily. You could just replace the boot PROM in the Speccy with a custom one (in a socket, so you could undo the mod). Ben Heckendorn is in the middle of a series about modding the Spectrum, and did something very similar.

        • Rob says:

          Since you’re going to need to plug into the expansion bus can’t you do whatever this board does to override the internal ROM: http://www.fruitcake.plus.com/Sinclair/Spectrum/Spectra/SpectraInterface.htm

          That would mean you wouldn’t need to butcher your Spectrum.

          • Greenaum says:

            I think it’s just about as simple as connecting a ROM chip up to the Z80 bus, to respond to the bottom 16K of addresses. Then hold _ROMCS high to disable the internal ROM.

            The Speccy was designed completely the other way round from most 8-bit home micros. The correct way! Same way early consoles used clever hardware tricks to get more out of themselves.

            The Spectrum’s “expansion port” was basically the entire Z80 CPU bus, every signal I think, plus a few extra like _ROMCS I mention, and IORQGE, a gate-enable of IORQ which you could use to stop the internal ULA (which was basically contained ALL the hardware that wasn’t RAM, ROM, or CPU) responding to requests.

            So you could over-ride, under-ride, and slip between any bits of the Spectrum you like. The manual even pointed out you could do almost anything you could do with a bare Z80, “sometimes, though, the Spectrum’s hardware might get in the way” (and that’s me remembering verbatim after 20-odd years).

            Everything was connected to the expansion connector. Similarly the Z80 bit-banged most of the hardware it drove, including operating the head and motor of it’s printer, and the same of the microdrives, and the serial port. All bit-banged through ULAs that basically just decoded addresses and sent the data bus off to the right set of pins according.

            One ULA was the machine’s internal, the second came in “Interface 1″, which brought the microdrive interface, serial port, and local-area network (using jack plugs!).

            Most popular add-on would be a Kempston-compatible joystick interface. Just connected the data bus to the joystick when Z80’s A5 and _IORQ was low (IN 31 in BASIC). Simple stuff but powerful.

            The only real cleverness was in Interface 1’s interfacing with BASIC. There were 2 or 3 addresses in the standard computer’s ROM which, if accessed with an IF-1 fitted, caused a quick ROM-swap from internal to IF-1. It would then do a bit of jumping, run the routine from it’s own ROM, then bow out, switch back, and leave everything as it should be.

            It also had the handy benefit of letting you divert illegal-BASIC-instruction traps to your own code, indeed, that’s how it worked at all, in an unexpanded machine the IF-1’s microdrive instructions gave an error, the ROM error-handling routine was the address IF-1 patched onto.

            What the hell was my point? Oh yes… you can do anything with Spectrum hardware! So reading it’s keyboard could be done a number of ways, with or without the CPU’s cooperation, with or without some nice software. With or without extra hardware! A simple program might scan the keyboard and send some audio pulses through the tape socket. Have a ‘ino listen to these and you’ve got it!

          • RunnerPack says:

            Since when is replacing a chip with a socketed chip “butchering”? :P

        • Greenaum says:

          Not PROM, ROM! These were mass-production machines that sold millions!

          As I mention at length lower down, there’s a chip-select pin for the internal ROM brought out to the edge connector. So just hold that high (ie disabled), and provide your own ROM chip to respond to the first 16K of address space. Very considerate of the designers.

          • Rob says:

            I just ran across this blast from the past:

            http://freestuff.grok.co.uk/rom-dis/

            Also this, which isn’t the book I saw but has a lot of good info:

          • RunnerPack says:

            1. You know what I meant :P

            2. I know next to nothing about the system, so I was just passing on something related I had seen recently. That exposed !CS line is indeed quite handy, and shows that a lot of thought went into this little system.

  2. Rob says:

    I think Sinclair actually have the monopoly on worst keyboards. The Spectrum is bad but the ZX80 and ZX81 were even worse and for size and amount of crap crammed on a keyboard they’re probably worse than the Atari 400.

    • OlDrunk says:

      The chicklet keyboards that first came with the IBM PC Jr where much worse as it wasn’t even really useable and make the Spectrum keyboard look fairly good.

    • Lwatcdr says:

      The ZX-81 and Timex Sinclair 1000 where the worst I ever used with one exception. The Basic keyboard “using two multi button controllers” that you used with the basic cart on the atari 2600. Don’t forget the calculator keyboard on the 99/4 and keyboard on the first CoCo’s It seems to took the a while to figure out how to make really cheap but usable keyboards. Commodore seemed to get the keyboard okay pretty early as did Apple,

      • +1 for the Atari 2600. I thought my ZX81 was bad until I had to handle that abomination.

      • Chris C. says:

        Woah, I’d forgotten all about Atari 2600 BASIC! It had ridiculously low RAM, 100 bytes or less if I recall, translating to even fewer program commands. It was really just a “programming game”, not a computer. A proper keyboard wasn’t required. The funky controllers probably added to how long I enjoyed toying with it, like some additional puzzle to figure out.

        Can’t say that for the others. I never used the Sinclair (or Timex), but did use the Atari 400. The “peanut butter proof” keyboard was responsible for some VERY sore fingers after long hacking sessions. Did the term repetitive stress injury even exist back then? For that matter, who coined the term “peanut butter proof”, and why? “Mountain Dew proof” would have been more relevant…

        • Greenaum says:

          I think the con there was, “basic programming” is not the same as BASIC programming! And yes, 24 keys! Not even enough for an alphabet! That and the screen could only fit maybe 40 pixels on it’s horrible interlaced lines. I once tried to implement even a 1-D Pong. Couldn’t do it, ran out of RAM. The machine itself had 128 bytes, who knows how many “basic programming” left to use.

          It’s certainly an “interesting” solution to “how the flip do we get programming on a stock 2600!?”. Sure there could have been others. None of them would have worked, either!

    • Paul says:

      Sinclair computers were very affordable at £129 for a 48K model. The Commodore 64 was £399.

      £129 is about £400 at today’s prices, £399 is £1,230.

      • Rob says:

        Yeah, £399 was the price of a BBC Model B too. My dad wouldn’t buy us a speccy but got me an Acorn Electron instead at £199 because it was considered educational and less expensive than the BBC Model B. I’ll have to admit, BBC Basic was much nicer than the Sinclair one and even though you had to type the keywords out it was worth it for the nicer keyboard.

        The advantage of the Spectrum Keyboard is that I think the rubber is one big piece under the case so it would have probably resisted the glass of coke that someone spilt on our Electron causing the delete key to stick.

        • Greenaum says:

          I used to have a Cambridge Z88, another of Sinclair’s brainchildren. From 1987, it had a something-like-100 column by 8 row screen. The columns were basically standard 80, plus extra for a little status window.

          Ran on a CMOS Z80, with 32K pseudo-static RAM, and a 128K addon that pretty much everyone got. Ran a great and clever custom OS and got 20 hours use from 4xAA batteries. Had task-switching, and a really great, if bizarre, spreadsheet-wordprocessor, it did both at once!

          The whole machine weighed under a kilo and was about the size of A4 paper, less than an inch deep.

          Anyway, point is, look up a picture. Most of the machine’s surface was covered in keyboard, a single soft-ish flexible rubber sheet, overlaying a plastic membrane. Nothing too exciting in principle, but just the exact shape of the moulding, of the keys, the exact qualities of the rubber. It was great! You could touch-type on it. Keys about the same size and spacing as a modern PC, with maybe a couple mm travel. But it felt great, and was of course, being one rubber sheet, utterly waterproof, even washable! Well, with a damp cloth at least.

          Add a nice little fold-down flap underneath to tilt for the ideal typing angle. So much from quite little, achieved basically by getting it right. Dunno how many iterations of prototypes it took, Clive Sinclair had phenomenal luck in fluking the perfect solution that the customer didn’t even know he wanted!

  3. Greenaum says:

    NNniiice! Did you know that Spectrum BASIC managed to get 240 functions out of those 40 keys? You didn’t type keywords like PRINT in, the keywords popped up whole from each key, depending on what mode the interpreter was in. And it had lots of modes!

    Or, as all Spec-chums remember, J symbol-shift P P

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 97,808 other followers