Wednesday 17 August 2016

Redesigning the ZX Spectrum 128k - My childhood dream :)

The ZX Spectrum was my favourite thing in the whole world when i was 8. It's what led me into a world of software and hardware design. Every since i first got a rubber keyed 48k, i always thought one day i'll make my own, never really thinking that it would be possible. However with my lifetime of 8-bit pinball hardware repair knowledge always expanding and with me developing my own range of replacement cpu and sound board hardware for various pinball systems over the last few years the thought reappeared in my mind and now didn't feel to far away :)

The thought of being able to redesign and make my own computer that could load and play games, connect up to modern TVs and be still affordable to buy or self build for the hobbits was my goal. Having spent many years with a 48k model and having pictures of the original Sinclair designed 128k machine on my bedroom wall, the 128k model had to be the one to remake and hopefully improve.  Later on in my spectrum days is did manage to get myself a +2A and +3, and even though i couldn't love them like the 'proper' Sinclair made versions i did love the 128k music and games. The AY-8912 chip is a thing of beauty and is featured in many arcade and pinball pieces of hardware from the same era.

Thinking about my redesign and remake, I wanted to approach this in the same way as my pinball hardware redesigns, so this would be:
  1. Simplify the design taking advantage of modern electronics
  2. Reduce the chip count especially within the ram chips
  3. Add additional functionality to avoid as many plug on modules being needed
    1. Kempston Joystick Interface
    2. IDE interface
  4. Maintain a fully plate through design
  5. Add power leds and test points
  6. Enable better connection to modern TVs
  7. Reduce power consumption where possible
I set to work on creating a design that would encompass the above and thought about how i would like to case this new board. I wanted to be able to offer a pcb that would fit within the original spectrum + cases or the spectrum 128k case. Of course some small modifications to the lower case edges would be needed for the different connections but would be nice to still fit within an original case.

The first design was completed and it filled me with excitement to get the board made and try it out.




PCBs arrived a few weeks later and i assembled the first prototype. I had to make a few modifications to the design, but this is all part of the design process and is how i build up my board designs. You have to start with a pcb design and modify as required, as its too complex to breadboard with full thing to begin with.


A picture of sorts was displayed and initially i was quite pleased to get something visible. My TV also correctly identified the incoming signal as RGB so that was good to. I realised that the sync line to the tv need more investigation and had another look at the SCART pinout diagrams i had.


After swapping round the input and output composite sync pins i got a nice stable and crisp picture :) though it was clear more work was needed.



Some more research was needed and cross referencing various old schematics form the original spectrum 48k revisions. The address multiplexing for the ram ics is individual 74 logic in the same way before the custom ZX8401 ic was introduced and was based on the design by here - http://trastero.speccy.org/cosas/JL/pcf1306p/PCF1306P.html. A mistake with my conversion on A15 was identified and fixed and also an error with the VA-14 and VA-15 outputs being reserved from the custom PAL memory banks ic were resolved.

Also after some advice from fellow hardware and software designer Tynmouth Software i located some ram test and hardware test programs to try out including the excellent full machine test from Retroleum. Burned some new ics and tried them out.



The first real image appeared, which was a major milestone. This proved that large parts of the design were working and i could now concentrate of specific areas resolve the remaining issues. There appeared to be a problem displaying half the screen graphics, which seems to be every odd column and by deciphering the missing screen graphics there was a bank or ram issue.

I rechecked the original 128k schematics and the +2 schematics using a couple of versions and noticed some errors on there to do with the type of clock inverter ic used. So I experimented with various types of 7404 ic to reduce proportion delay 74AS04 (from 74LS04). I also hooked up my oscilloscope to check the clock pulses being generated into the ULA, out of the ULA and into the CPU.



I checked the video RAS and CAS signals. I realised from more research (and re-reading sections of the excellent The ZX Spectrum ULA: How to design a microcomputer book by Chris Smith) that the screen is built up from video fetches that take 2 complete sets of character blocks at a time (a set is made up of a RAS address read and 2 CAS address reads to load the pixel data and attribute data for 1 character block. The screen is made from 32 x 24 character blocks)

This made me wonder if my graphics issue was related to timing issues with the ram and the delay to the start of the second character set.



The pulses looked good though there was a question over the start of the second RAS pulse in relation to the end of 2nd CAS and before the start of the 3rd CAS. Trying the ram tester rom again now gave a successful result but the screen was still messed up.






Back to the drawing board with the video ram fetch. Lots of late nights and weeks passed whilst i retraced all my designs and checked over all schematics, as well as experimenting with some capacitor values on the ras and cas lines to modify the timing signals slightly. I also tried various different ram chip speeds. My design uses 41464 dynamic ram ics as only 4 ics are needed for the full 8 pages of 16k (128k total)

Then....  late..... very late one evening the magic capacitor value was found !! A single additional capacitor  was required ion the video ram RAS select line n conjunction with some logic gate buffering delay to the multiplexing video address select line. (taken from the 48k schematic rev 4b)








To see the familiar operating menu appear is all its crisp glory was such a rush! I think i must have just sat down and starred at it for around 1 hour! I created a quick test

Next up was to load a game and see whether i could actually play something and also test the ay sound & music generator :) I populated these sections ...






There's more to talk about in terms of the sound input side and how i loaded wav files into the system using just a usb stick but i'll leave that for another post, as well as going into more technical detail on a few other areas.

The project works, has been a major learning curve with some tricky moments, but has been so rewarding. I'll be making my first batch of assembled boards and kits soon so you to can have a new 128k Spectrum in and old case :) The boards will be available like all my other pcbs and products on my web store here.


The new boards will feature:

  • Reduced chip count and power consumption
  • Reduced custom chip usage
  • Fully spectrum 128k compatible
  • 8 pages of 16k ram 128k total 
  • High quality picture - RGB scart socket with proper tv identification capability. 
  • Standard female 21 pin socket for use with stock fully wired scart cables
  • Built in kempston joystick port
  • Built in IDE 40 pin connection
  • Uses the 128k ULA IC - Ferranti 7K010E/Amstrad 40056
  • Full set of test pads
  • Power leds
  • Low power 5v regulator
  • Single 12v supply power in
  • Modern reset chip and on board reset button
  • AY-8912 sound generator on board for retro 80s music
  • AY-8912 expansion connector for 3rd party dev
  • Sound line in for Tape loading or loading wav files
  • Sound line out for connection to amps and playing music
  • Fully compatible card extension port
  • Full plate through design, no SMD
  • Designed and assembled in UK

Now for some videos with music and more screen shots :)

























Thanks to:

Tynemouth Software
Retroleum
The ZX Spectrum ULA - How to design a microcomputer book by Chris Smith








3 comments:

  1. You should have 180 pf on cas and 25 pf on ras line.
    on system ram cas and ras are direct conected.
    Plus using ls157´s in conjunction with the inverted gates for the select signal is an option ,but the main reason in my idea is that 41464 has diferent cas and ras timings in comparison with 4164 ram´s and pcf1306 is designed for that type of ram timmings.

    Best Regards

    JOSÉ GONÇALVES

    ReplyDelete
  2. Great work! Congtars! Is it possible to buy it?

    ReplyDelete