Wednesday, 21 August 2013

ZX81 Clone Part 1

For many years, I planned to build a ZX80 clone. It's all standard parts (no custom ULA like the ZX81 or ZX Spectrum), and it's a well known and well documented circuit. However, I never quite got around to it. And then, I got my hands on an actual ZX80 (read about the repair of the ZX80), so the idea lost momentum.
Recently I've come across a few more ZX81's with dead ULA's, which is great for turning them into ZX81 USB keyboards, but not great if you play 3D Monster Maze. So back to the idea, but this time, make a ZX81 Clone. OK, it's reinventing a wheel that's already been reinvented, but it should be an interesting project, and I plan to make some modifications along the way.
The idea is to build something along the lines of a ZX81, using standard components i.e. without using the custom ULA chip. I've talked about that a few times before, it's basically all the chips on the ZX80 that weren't the ROM, RAM or CPU rolled into one. The ZX81 ULA also added some extra functionality over the ZX80, so it's even more chips to replace. It was a marvel at the time, only problem is they ran hot and eventually failed, and you can't easily get replacements. The inner working are now well understood and well documented, thanks to the work of various Sinclair fans. The following sites have provided excellent points of reference, and are well worth a read:


It seemed the fist stage was just to try to build up the ZX81 circuit away from a ZX81 board, but using the original ZX81 chips. This was just a test of how practical it would be. It worked, not particularly well due to clock issues, but sufficient to move onto the next stage.
This used parts borrowed from an issue 1 ZX81, a Z80 A CPU, Mostek MK36809N (8K mask ROM) and Mostek MK4118N (1K SRAM), and the Feranti 2C184E ULA is the one at the bottom with the heatsink on. The next step was to replace everything but the ULA with modern equivalents. I used a modern Z80 CPU, the Z84C0006PEG (which is limited to 6MHz, I need to order a faster one if I want to enable turbo mode). The mask ROM was replaced with a 27C64 (8K EPROM), and the RAM with a 62256 (32K SRAM). Although it is a 32K chip, without extra logic, only the first 16K can be used. Even though this is more RAM, the supply current is almost half with the modern chips.
I had a few problems with V1 above with the clock, and the same here on V2. I ended up building an Arduino based frequency counter to keep track of the frequency fluctuations. Since the video signal is directly tied to this frequency, if this drifts, the TV signal goes out of range. I tried both a 6.5MHz ceramic resonator on the ULA, and also a 6.5MHz crystal oscillator made with a 74LS04. I eventually traced the issues to the transistor which buffers (and inverts) the clock between the ULA and the Z80 CPU. I tried an assortment of different transistors, including a ZTX313 from a ZX81. I finally changed to using a gate from a 74LS04 inverter, and the clock issues all went away, I got a stable 6.5MHz main clock and a stable 3.25MHz CPU clock. And that lead to a stable TV display.
The video output isn't bad considering this is constructed with long wires on breadboard, with a simple transistor amplifier on the video out, and it is being displayed on a modern LCD TV. Just a word at this point about ULA versions. There were two, the original 2C184E, like the one I am using here, and the later 2C210E. The main difference between them was an improvement to the video signal, adding the missing 'back porch' signal to properly set the black level. So that's about as good as I'd expect from a lashed together circuit with the older ULA.
So now that's working it's onto the next stage....