ZX Spectrum USB Adapter for Raspberry Pi RetroPie Builds

by CameronCoward in Circuits > Computers

12966 Views, 41 Favorites, 0 Comments

ZX Spectrum USB Adapter for Raspberry Pi RetroPie Builds

retropie_title.png
ZX Spectrum USB Adapter for Raspberry Pi RetroPie Builds
20200220_182222.jpg
20200220_182242.jpg
20200321_131417.jpg

RetroPie is a special Linux distro that is designed specifically for emulating retro video game systems on Raspberry Pis and other single-board computers. I've been wanting to go all-out on a RetroPie build for a while now, and when I saw that reproduction Sinclair ZX Spectrum were available I knew they would be perfect.

It would have been simple enough to cram a Raspberry Pi into the case, but I wanted the ZX Spectrum keyboard to be functional. That's why I designed this USB keyboard adapter board. The standard ZX Spectrum keyboard ribbons plug into the adapter, and it connects to any keyboard as a standard USB keyboard. There is also a DC barrel jack to supply power to the Raspberry Pi and to an optional fan.

Supplies

For the adapter:

For the entire RetroPie build:

Program the Teensy 3.2

retropieteensyusb.png
matrix.gif

Upload the provided Arduino sketch to your Teensy 3.2. When you upload the code, you have the option to configure your Teensy 3.2 to as a USB HID. This will ensure that computers automatically recognize it as a plug-and-play device. In this case, you want it to show up as a USB keyboard. To do that, make sure you sketch is open and ready to upload. Then select "keyboard" from the USB Type submenu in the Tools menu. Then upload your sketch as you normally would with a Teensy board and proceed to the next step.

A quick note about how the keyboard matrix is handled: the ZX Spectrum keyboard is obviously a lot different than a modern keyboard. It has far less keys, punctuation and special characters are in different places, and special functions (like "Print") are used by default when you're in BASIC on the real ZX Spectrum. For that reason, I have made a number of compromises for usability.

Take a look at the keyboard matrix layout in the attached image. With that as a reference, you can edit the Arduino code to send whatever key press you like when a physical key is pressed. It's a standard keyboard matrix, and in the code I have columns labeled A-H and rows labeled 1-5.

PCB Design and Fabrication

20200220_182222.jpg
20200220_182242.jpg
retropieschematic.png
Annotation 2020-03-25 155058.png

Get PCBs Fabricated:

You can find the complete Gerber files in a .zip folder at this link: https://drive.google.com/file/d/1BaLNvOiBaTPo4T3Lt...

You can have the PCBs fabricated by whichever service you prefer. I used JLCPCB, as they're affordable, quick, and the quality is great.

Notes on PCB Design:

I designed the PCB using KiCAD, which is fantastic open source design software. It does have a steep learning curve, but there are many tutorials online. Once you get the hang of it, it's quite powerful.

I started by taking measurement of the reproduction ZX Spectrum case. I created a simple sketch of the mounting hole locations in Autodesk Fusion 360. I then created a simple 3D model of the basic outline of the PCB. My two main goals were for the PCB to fit and mount the PCB without any modifications, and for the two ribbon connectors to be placed appropriately. I then exported the outline of the PCB to be used within KiCAD.

In KiCAD, I started by creating my schematic. Then I started creating the actual PCB layout (using the DXF board outline). After placing all of the components and routing the traces, I decided to get creative with the artwork. The bottom of the board is covered in silly text, and the top has some graphics. "Resist!" plus a fist next to the resistors for giggles, and stripes on the corner to mirror the stripes on the ZX Spectrum case.

Assemble the PCB

20200220_182222.jpg
20200220_182242.jpg

This step should be very easy if you have basic soldering experience. All of the components are through-hole and easy to solder. Make sure your Teensy 3.2 has all of the outer header pins in place. Not all of them are actually used, but it's easiest just to solder them all. The resistors don't have a polarity, so you don't have to worry about the orientation.

After all of the components are in place, use some snips to trim off the excess from the pins on the backside. This will ensure that the PCB lies flat when it is inside of the enclosure.

Install RetroPie

Before moving onto final assembly, it's best to setup RetroPie so you can test everything.

Download the latest RetroPie image from this link: https://retropie.org.uk/download/

Burn the image to your SD card using a utility like Etcher. (https://www.balena.io/etcher/)

Insert the SD card in your Raspberry Pi, plug in the wireless controller receivers and the USB cable to your adapter board, the HDMI cable to your TV, and then connect power.

Follow the setup steps to configure RetroPie. Afterwards, you can follow the standard steps (documented on the RetroPie website) to setup whichever emulators you want to use and copy your library of ROMs.

The ZX Spectrum emulator is quirky, and it's tricky to get it working with any keyboard (this one included). This link provides some advice: https://retropie.org.uk/forum/topic/16119/keyboard...

You will likely need to do some tweaking to get everything working properly, but that's the case with any keyboard.

Final Assembly

ZX Spectrum USB Adapter for Raspberry Pi RetroPie Builds
raspberry_pi_3_model_b_plus_gpio.jpg
20200321_131444.jpg

The final assembly is straightforward, but you may want to take another look at my video to see how everything should fit together. You'll solder two wires from the 5V and GND Raspberry Pi pins to the power terminals on the PCB. Then plug the short right-angle USB cable from the Teensy 3.2 to the Raspberry Pi. The HDMI extension cable should run from the HDMI port out the back of the case. Finally, plug the ZX Spectrum keyboard ribbon cables into the connectors.

If you want to, you can use hot glue or double-sided tape to secure the Raspberry Pi in place, but it's not necessary (everything is pretty snug). While being careful to keep the PCB in place, push your screws through the bottom of the case, through the PCB holes, and then thread them into the mounting holes. If anything binds, then adjust the position of the Raspberry Pi and/or the USB and HDMI cables, then try again.

That's it! Just plug in your power cable and HDMI cable and start gaming!