Wednesday, 21 January 2015

ZX81 USB keyboard

I've been refreshing the range of USB keyboards I sell in my Etsy store. Every time I get a new batch of boards, I always tweak the design a bit. I'm refining the design, and adding new features each time. This time, I updated all of them to bring them all up to a similar level. I had added mode switches to the Commodore 64 and ZX Spectrum, but in various different ways. I have now settled on one standard set of options and rolled that out across all the designs.
Coupled with this, I've rewritten a lot of the firmware so that things like mode selection are all handled by the common code. It's take a while to move everything across, but the main ones are done now. There is also a special version of the Spectrum board for use with a Raspberry Pi.
I'm going to go through each of the keyboards, build up a new one and show off the new features. The first USB keyboard I built was the ZX81, about 4 or 5 years ago. I wrote it up a year or so later on the blog. Things have changed quite a bit since then.
The board was hand wired pad board, and used a software level USB stack, V-USB, on the ATmega328P. It was programmed in the Arduino environment, and the arduino serial programmer can be seen above. I used a new membrane as the original was damaged beyond repair, so had the luxury of long tails and mounted the board on the bottom of the case (not sure why though?). This evolved over the years, firstly to Arduino Leonardo based boards, then to custom boards. The software also evolved as there were issues with the various frameworks I used and how they dealt with the keypresses and key mapping, so I went my own way.
Now we move to 2015. and things have changed quite a bit. I'm now using ATmega8U2 microcontrollers with hardware USB implementation, running my own firmware on a custom PCB, there is even a USB PID for 'Tynemouth Software USB keyboard'. The board is now mounted on the underside of the lid, which is more sensible, and means I can make use of membranes with damaged tails. These have a tendency to crack a centimeter or so from the end, and need to be cut back to get a solid connection. However, when cut back they wouldn't be long enough to use with a normal ZX81 board, but can still reach the connectors on the USB keyboard PCB.
In common with the other boards, this can have the option to switch the mode in use, or can have the mode preset via jumper. On the ZX81, the mode switches between direct mode which is one to one key mapping. There are only 40 keys, so A-Z, 0-9, shift, enter, space and fullstop. The remapped mode uses shift to select various symbols and function keys.
There is no LED to indicate mode in the way I do on the Commodore keyboards, so I use a small sounder to beep when the mode is changed. This also allows me to use an idea borrowed from the spectrum, whenever a key is pressed, it makes a click sound. This does seem to make typing on the membrane keyboard a more pleasant experience (I am typing this on the ZX81 now).
I have a soft spot for the ZX81 as it was the first computer I programmed back in the early 1980s, and indeed the first computer I repaired when it died a few years later. So it is nice to be able to have one around, I still use one to control a living room media PC. You can buy one of these now at the Tynemouth Software Etsy store, or get one with an integrated Raspberry Pi.