Tuesday, 31 July 2018

ZX Spectrum IO Interface

I have added a new product to my Tindie store, simple IO board for the ZX Spectrum,

This gives 16 digital input lines and 16 digital output lines. I've been meaning to build one of these for a while. For quite a while actually. Back in the 1980s in fact. There were some great computer books in those days from a company called Usborne, and they have made several of those titles available online.
I remember these from the time, and read through many of them from cover to cover, over and over again at the time. Very simple books, but they taught me a lot about BASIC. The programs were generally written for the ZX81, with a list of symbols at the side.
At the end of the listing, these would be expanded and would show you lines that needed to be substituted for Commodore, BBC, TRS80 etc. And it was reading those that then allowed me to go and get some of the other books my local library had like '20 games for your TRS80' and convert them to run on my ZX81 (or my 800XL or my Electron etc.)
Where is this going then? Well, there were a couple of books in that range which talked about interfacing with computers, the 'Usborne Electronic Workshop'. One about building Computer Controlled Robots.
And one about Computer Model Controllers. These told you how to interface switches and lights and motors to your computer, and using those to control a train set and things like that. This was great for BBC, VIC20 and Commodore 64 owners, as they had user ports.
But ZX Spectrum owners didn't have user ports, and had to buy 'a special interface circuit', which I don't remember ever seeing. So I made now one. (and yes, that is my own rather battered copy of 'Computer Model Controllers' from the 1980s)
This plugs into the edge connector and gives two 8 bit input ports, and two 8 bit output ports. More than enough to drive your robot or train set.
This is quite a simple unit, the 16 outputs are 74HCT series output, so can sink or source 6mA, enough for LEDs, but needs a transistor or driver chip if you want to control relays or motors. The inputs are TTL level, and will need pull ups or downs as required. There is no protection on any of these pins, so use with care. Each of the four 10 pin headers has 0V, 5V and the 8 input or output lines.
The ports are at 0x01 and 0x03, and can be accessed from BASIC using the OUT and IN commands.
OUT 1, 255
This will turn all of the pins of output port 1 on (5v).
OUT 3, 0
This will turn all the pins of output port 2 off (0v). The output is latched, and will retain this setting until it is changed.
The input command is
IN 1
So for example,
PRINT IN 1
will print the value read from input port 1
IF IN 3 AND 8 THEN GO TO 100
Will test to see if digital input pin 4 on port 2 is high
The ZX Spectrum IO board is available from my Tindie store as PCB only, kit or fully assembled.

Update:
Yes, this will work on later +2/+3 machines but some adjustment to the port numbers may be necessary to avoid port numbers assigned to the internal hardware on these machines.

2023 Update:

These PCBs are now available from my SellMyRetro store.