[go: up one dir, main page]

0% found this document useful (0 votes)
180 views15 pages

Pocket ZX Handheld ZX Spectrum

The document describes the construction of a portable, handheld device that emulates a ZX Spectrum home computer from the 1980s. Key requirements were that it be cheap, portable, have a keyboard and joystick, and not require tape loading. The author outlines building a USB keyboard and joystick controller with an Arduino, connecting a Raspberry Pi to a 320x240 LCD touchscreen, adding wireless capability with Bluetooth, powering it with a rechargeable LiPo battery, and connecting all the components together in a compact case to achieve a "Pocket ZX Spectrum" emulator.

Uploaded by

David Clode
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
180 views15 pages

Pocket ZX Handheld ZX Spectrum

The document describes the construction of a portable, handheld device that emulates a ZX Spectrum home computer from the 1980s. Key requirements were that it be cheap, portable, have a keyboard and joystick, and not require tape loading. The author outlines building a USB keyboard and joystick controller with an Arduino, connecting a Raspberry Pi to a 320x240 LCD touchscreen, adding wireless capability with Bluetooth, powering it with a rechargeable LiPo battery, and connecting all the components together in a compact case to achieve a "Pocket ZX Spectrum" emulator.

Uploaded by

David Clode
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

instructables

Pocket ZX (Handheld ZX Spectrum)

by stuartm210

I'm a child of the 80s and have fond memories of the 8-bit computers of that era. My first computer - one which
holds a special place in my heart - was a Sinclair ZX Spectrum 48K. Having recently discovered some
communities focused on older computers on the web, I decided I wanted to relive some of that nostalgia for myself
and installed the Fuse emulator on my MacBook. This was fun for a while but I really wanted a dedicated device -
preferably something small, portable and self-contained to fit in with my lifestyle. The choice at this stage was to
either follow the path of the awesome Ben Heck and shrink original ZX hardware into something portable or to
cheat and use emulation on a small single-board computer. I'm going to cheat :)

So, what do I want from my portable ZX Spectrum?

Cheap: I have far too many projects to spend large sums of money on a bit of fun nostalgia.
Portable: It needs to be something I can play with on the sofa or on a lazy afternoon in the garden.
Keyboard: I don't just want to play games, I also want to program it. To get the full experience, it
needs to have those wonderful keyword keys.
Joystick: I was never into playing platform games with a keyboard. Adventure games, sure, but I
don't just want to play adventure games so it's going to need a joystick.
Instant: I hated tape loading in the 80s and I can't imagine I've grown any fonder of it in the
intervening years.

With all this in mind, I drafted a block diagram to help me understand the various components. So let's get
building.

Pocket ZX (Handheld ZX Spectrum): Page 1


Step 1: USB Keyboard & Joystick

Pocket ZX (Handheld ZX Spectrum): Page 2


Getting the keyboard right is the key to capturing the a mouse for interacting with the underlying Linux
look and feel of the original ZX Spectrum. We may be system, so I also added a small secondary button.
building a handheld emulated device which shares
nothing in common with the original Spectrum The microcontroller for the keyboard is an Arduino
internals but, with careful design, it should be Pro Micro. This is a small board which can be
possible to create something which feels reminiscent programmed as a USB human interface device (HID)
of the 80s computing experience. such as a keyboard, mouse or joystick.

Starting with some protoboards and a big pile of Once the switches were soldered in place, the matrix
tactile switches, I experimented with a few ideas and which connects the rows and columns of switches to
settled on the staggered layout shown in the photos. the microcontroller needs to be built. This matrix will
The protoboards we're using are a standard 7x9cm enable us to connect all 40 keys plus the 7 joystick
(26x31 holes) available online from many retailers. buttons to the Pro Micro's 18 I/O pins. The Spectrum
The switches are surface mount versions which have keyboard doesn't need to handle multiple key-presses
a softer feel and are less noisy than their more except for the Caps Shift and Symbol Shift keys so
common through-hole counterparts, but either should we're going to put those on dedicated pins, then we
work as their body sizes are almost identical. won't need to worry about using diodes to prevent
phantom key-presses. I've included a schematic to
The joystick controls then went into the remaining show how the keyboard, including the matrix, is
space immediately above the keyboard. I decided to wired-up. First, each column is linked with a length of
use a 5-way tactile navigation switch on the left and a single-core wire and then the rows are connected
large fire button on the right. The joystick will double- using single-core wire which is carefully shaped to
up as a controller for the emulator's menu system and cross over the columns without shorting. This can be

a bit tricky because you need to get the row wires connect a LED to the Pi's UART TX pin as that will
high enough to avoid contacting the columns but low constantly be sending data while the device is on.
enough to leave room for all the wiring we need to
stuff in during the final assembly. Finally, the rows To prevent the loose wires from fraying in use, or the
and columns are connected to the Arduino pins with matrix wires from shorting, everything is liberally
wires from old IDE cables. covered in hot glue - ugly but effective!

As mentioned above, the joystick controller is also The last step to get the keyboard working is to
going to function as a cursor controller and a mouse program the Arduino with the
so we'll need to be able to switch between modes. ZX_Spectrum_Keyboard code from my repository.
The default mode will be cursor mode, a combination With that done, you can actually put the soldering iron
of Caps Shift + the Fire button will switch to joystick down, plug the keyboard into a regular computer and
mode and the Symbol Shift + Fire button combination use it with a Spectrum emulator like Fuse or
will switch to mouse mode. To show which mode it's Spectaculator. But we're not stopping here, so let's
in, there are a couple of 3mm LEDs in the middle of move on ...
the joystick panel. A Power LED will also be useful
and a good way to provide this with the Pi is to

Pocket ZX (Handheld ZX Spectrum): Page 3


Pocket ZX (Handheld ZX Spectrum): Page 4
Step 2: LCD Screen

The original Spectrum has a screen resolution of We only need to connect the SPI, power and
256x192 pixels. To keep (approximately) this ratio touchscreen I/O pins to the Pi - it can be quite tricky
and avoid having black bars down both sides, I to track down which pins are actually needed but the
selected a Waveshare 3.2" 320x240 TFT LCD information is out there if you look hard enough. The
touchscreen designed for the Raspberry Pi. It isn't Waveshare screen uses 10 pins: 4, 6, 9, 13, 15, 19,
going to be connected directly to the Pi's GPIO 21, 23, 24 and 26. Obviously, if you're making this
header so we can remove the connector's plastic with a different screen, you'll need to verify the correct
surround and trim the pins. I trimmed a 7x9cm pins before grabbing your soldering iron.
protoboard down to 2.1x9cm (the exact size doesn't
matter as long as the two remaining corner holes There's no special software configuration needed -
align with the top keyboard holes and there's enough just install the manufacturer's driver software and it's
space to solder the GPIO header pins) and soldered ready to use.
the pins in position, which will give us an easy way to
mount the screen above the keyboard.

Pocket ZX (Handheld ZX Spectrum): Page 5


Step 3: Wireless (Bluetooth)

The Raspberry Pi Zero board has no wireless allow us to add a useful wireless capability. By
capability, only one useful USB port and there's not attaching a cheap HC-05 Bluetooth serial module to
going to be enough room in the case for a USB hub the Pi's UART pins and tweaking the system
so I had to get a bit inventive to add some kind of configuration, it's possible to get wireless access to
wireless capability for my build. If you're building this the command line terminal using serial-over-
with the Zero W then you can skip this step. Bluetooth. We can then use common tools to send
files to the device and manage the filesystem.
There's a neat feature of the Raspberry Pi which will

Pocket ZX (Handheld ZX Spectrum): Page 6


Step 4: Power

I chose my battery at the end of development so completely off, there's a slide switch between the
needed to pick a cell which would fit into the available output of this module and the Pi which ensures that
space. The one I chose was a 2000mAH 25C 1S Lipo the battery can still be charged even when the device
(dimensions: 81x34x9mm) sold as a replacement for is turned off. The Pi needs to be shut down properly
the Walkera Syma X5 drone. It would be good to be to avoid data corruption issues. Rather than needing
able to charge the battery in-situ with a regular USB to log in over Bluetooth serial, we can connect a
connection and to be able to use the device while it's tactile switch to the Pi's pin 5 (GPIO3) and write a
being charged. We don't really want to be fiddling small script which watches this and initiates a
with complex power control circuitry so we're going to shutdown when it's pressed. The power and wireless
use a ready-made module which provides USB components were soldered to another 7x9cm
charging and also a stepped-up 5V output to power protoboard which will sit directly below the keyboard.
the Pi directly. To ensure the device can be turned

Pocket ZX (Handheld ZX Spectrum): Page 7


Step 5: Connecting It All Together

With all the various parts built, we can assemble the We'll be keeping the boards together with M3 nylon
internals. The biggest issue I ran into during standoffs. We need 2x 9mm standoffs to connect the
assembly was that the USB port broke off my Arduino bottom holes between the keyboard and the power
Pro Micro, requiring me to solder wires directly to the board. The top holes also retain the screen so we
solder pads rather than using a USB cable. This is a want 2.5mm standoffs between the keyboard and the
notorious weak point on the Pro Micro boards so it's screen, and 4.5mm standoffs between the screen and
probably worth applying a good glob of hot glue to it the power board. The side photo shows how this
before assembly to avoid this. Assuming this looks. The standoffs will need a little careful trimming
particular misfortune doesn't befall you, you have a to get everything parallel - it can be a bit of a tight fit
choice: you can either make a super-slim micro USB with all the keyboard wires but it should go together.
to micro USB cable to connect your keyboard to the As can be seen from the photos, the device can be
Pi or you can solder one or both ends directly to the powered-up and used after assembly, without
boards. As I needed to solder the Arduino side, I also needing an actual enclosure. We'll be printing an
soldered the Pi side directly to the test points on the enclosure soon but, before we get to that, we'll need
rear of the board. There are pros and cons to each to install the operating system and get it configured.
option so it's up to you which you prefer.

Pocket ZX (Handheld ZX Spectrum): Page 8


Step 6: Software

With the internals assembled, we can go ahead with following line to /boot/config:
the software installation and configuration. The
Raspberry Pi will run on a standard Raspbian enable_uart=1
installation The only extra software which needs to be
installed, apart from the TFT screen drivers, is the We'll want our shutdown script and the Fuse emulator
Fuse application. We're using the SDL version to get to run on launch so add these lines to
proper full-screen functionality, which can be installed /etc/xdg/lxsession/LXDE-pi/autostart:
with:
@/home/pi/shutdown
sudo apt-get install fuse-emulator-sdl
@fuse-sdl --no-sound --kempston --no-auto-load
To handle our shutdown button presses, copy the
'shutdown' script from my code repository to /home/pi/ Reboot the Pi after making these changes and you
should be done.
To get a serial console over Bluetooth, add the

Pocket ZX (Handheld ZX Spectrum): Page 9


Step 7: Enclosure and Final Assembly

The enclosure was modelled in Fusion 360 (how to To fit the boards, we first need to create the mounting
do that is outside the scope of this instructable). posts. Remove the heads from some M3 nylon
There are 5 parts: the case back, screen front, screws and glue the threaded parts into the lower
keyboard front, power button and control panel cover. holes of each of the front panels. When these have
The control panel cover should be printed in a flexible dried, the 2 front panels can be glued together and
filament (I used flexible PLA but a softer material like the keyboard can be fixed in place using the 9mm
NinjaFlex might be better); everything else should be and 2.5mm standoffs. Next, With this in place, the
printed in a rigid plastic (I used Filamentum black screen can be placed onto the upper posts and the
PLA). 4.5mm standoffs can be added. Finally, the power
board can be placed in position and the wires
To give the power button some resistance and to arranged to allow the back to be fitted.
prevent it from rattling, stick some 3mm adhesive
foam to its back and then punch-out a 4mm hole to The battery should be stuck in place with some
allow it to sit snugly over the vertical tac switch on the double-sided tape or foam sheet and plugged into the
power PCB. You may need to trim one edge slightly, power connector. Now the two halves can be brought
as can be seen in the photos, to avoid snagging the together and some short countersunk M3 machine
power board. I also found it helpful to use a small dab screws used to secure everything in place.
of glue to hold the button to the power switch.
Finally, flip it over and glue the control panel cover to
We need to glue a couple of nylon standoffs into the the keyboard panel. I did this with a two-part epoxy
upper mounts on the screen front panel to allow the adhesive for a strong bond.
top parts of the enclosure to be fastened securely.
Once dried, trim the standoffs flush.

Pocket ZX (Handheld ZX Spectrum): Page 10


Pocket ZX (Handheld ZX Spectrum): Page 11
Step 8: Keyboard Overlay

We're almost done. All that's missing are some key permanent marker to colour them in - this can be
markings and an overlay so we know how to get to all seen in the bottom row of one of the photos.
those wonderful keywords.
I designed the printed overlays in the open source
The primary letters and numbers are on the actual GIMP graphics program and then printed them onto
switch tops. I found some really small 2.5mm letter photo quality matt paper. Ideally, the overlays will be
transfers which fit perfectly on the 4mm diameter as thin as possible - I was able to peel the backing
tops. They're a bit tricky to apply because the tops from the Epson branded paper I used very easily
move as you rub them but you get quite a few letters although this won't be the case with all brands. To
in a pack so it's fine to make some mistakes. I ended protect the print, I covered the paper in clear adhesive
up touching a few up with a fine permanent marker vinyl sheet and applied double-sided tape to the back
although, in hindsight, I should have tried soaking to stick it to the case. Before sticking the overlays
them in warm water and sliding them into place (if down, however, we need to punch out the holes. I
you've ever built a model kit, you'll be familiar with used a cheap 4mm leather hole punch and got the
this process). To protect the letters during use, I best results by sharpening the punches and cutting
dabbed some clear nail varnish onto each key top. directly against some scrap 3mm aluminium sheet.
Then the overlays just need to be lined-up and stuck
To prevent the silver bodies of the switches from down.
showing through the gaps in the overlay, I used a

Pocket ZX (Handheld ZX Spectrum): Page 12


Pocket ZX (Handheld ZX Spectrum): Page 13
Step 9: Conclusion

And we're done! This has been quite a large project Fuse interface, and it should be possible to
demanding a range of skills including basic streamline the process further by writing a client-side
electronics, soldering, 3D modelling, programming script to send a file to the device. I would prefer to be
and even a little graphical layout. It's ultimately been able to use the standard Bluetooth "send to device"
very rewarding and the finished device is great fun to file transfer feature built into most operating systems,
play with, but how does it fare against my original or a proper file sharing system like Samba. However,
criteria? those are only going to be available with the Pi Zero
W board and I didn't use that for this build.
Cheap: The overall cost of everything, including
current retail prices of items I already owned and the In addition to the items noted above, if I started this
stationery items like double-sided tape which will last project again from scratch, I'd choose a thinner
well beyond this project, is around £80 which make it battery with a larger capacity early in the project and
an affordable project. design around it rather than needing to select a
suitably-sized battery at the end of the project. I'd also
Portable: It's definitely portable. This device fits use a Pi Zero W rather than a Bluetooth serial module
comfortably in a pocket and is completely self- to expand the options for sending files to the device.
contained so it can be used anywhere. If I were to Another obvious improvement would be some kind of
build it again, I'd make a flat 4-way joypad-style hardware battery state indication as there's currently
controller rather than using the navigation stick as it no way to see how much charge is left. I'd also
protrudes above the line of the device leaving it consider using a Ramdisk-based OS like Alpine Linux
vulnerable to damage. I'd also like to see if a non- which would be more tolerant to hard shutdowns and
touch screen of similar size and ratio is available with should allow for a single on/off switch without the
a more scratch-resistant cover as I don't need the need for a separate shutdown button - much more
touchscreen interface and the resistive surface is like the original ZX Spectrum, just unplug it when
particularly prone to damage. you're finished.

Keyboard & Joystick: I'm really pleased with how It might be interesting to design a custom PCB for
these worked out. Although it doesn't have the dead- this device which would, potentially, allow us to put
flesh feel of the original, using the keyboard feels the power components on the back of the keyboard
surprisingly reminiscent of the old ZX Spectrum - the rather than having a separate board. This could
layout, overlay and keyword implementation work significantly reduce the depth of the finished device. It
well together to achieve this. The USB keyboard can would also make assembling the device easier and
also be used on its own with a computer running the offer the potential of some kind of self-assembly kit. If
Fuse emulator to provide the same experience. there's enough interest in this project, I might do a
version 2 which addresses these issues.
Instant: Using the Bluetooth serial module makes it
relatively easy to transfer tape archives to the device
from another computer without needing to exit the

Pocket ZX (Handheld ZX Spectrum): Page 14


Step 10: Resources

The following resources are needed to build this project:

3D printable case files (Thingiverse): https://www.thingiverse.com/thing:3586307

Code (Github): https://github.com/stuartm2/Handheld_ZX_Spectrum

This came out really well! Thanks for sharing how you made it :)

Thanks! I'm really pleased with how well it worked out, and it's great fun to play on too :)

Pocket ZX (Handheld ZX Spectrum): Page 15

You might also like