Sunday, 8 January 2017

Minstrel ZX80 Clone Video Output Enhancement

There has been a lot of interest in the Minstrel ZX80 clone I announced in the last blog post.
The issue 1 boards were a pretty faithful replica of the ZX80 schematic, and as such, did suffer with the same problem as a real ZX80, a non quite up to spec video signal. The plan was this would be the starting point, get the plain ZX80 working first. Now that's done, it's time to make it better.
The signal from the original ZX80 circuit resulted in the black parts of the picture not being black, but varying shades of grey, and also the whites not really being white, but also a shade of grey, so the picture varied between a reasonable dark grey on white and grey on grey, and on my monitor would cycle between the two every few minutes. Older monitors cope better, it depends on how tolerant the monitor is of the poor signal.
The reason for this is the video signal is missing an element called the 'back porch'. Basically as part of each line of the display, there is a sync pulse, and the picture information. The picture information is meant to be preceded by a short period showing the level black would be, followed by the picture data varying from that level for black to a higher level for white. This is a still from an excellent video by JoulesperCoulomb on a solution to a similar problem on the ZX81, which explains the requirements in more detail.
The signal generated by the ZX80 is lacking this, and goes straight into the video information. The analogue circuitry of older TV sets would cope with this sort of poor signal quite well, but modern LCD TVs have digital processing which needs more information. The ZX80 signal goes straight from the line synchronisation pulse into the picture information, and also the proportions are wrong, the black level is about 40% down from the white level, it should be more like 70%
On the original ZX80 circuit (this extract from Grant Searle's redrawn version), the video signal is a signal with either 0V for black and 5V for white, and sync is 0V when a sync pulse is required, 5V normally. (N.B. these are TTL, so it's not quite 0V or 5V, but good enough for the purpose). These two TTL level signals were merged together with two resistors and fed to the UHF modulator.
On the Minstrel issue 1 board, I kept the same resistors, but fed these to a single transistor amplifier to drive the video output with a 75 ohm impedance matching resistor.
There are various circuits around for solutions to this, mainly for the ZX81. There is more of a problem there as the only signal available comes out of the ULA already merged together on a single pin. On the ZX80, the sync and video signals are available separately, so is easier to do something with those.
This is part of Grant Searle's NMI mode add on for the ZX80, and adds a back porch to the ZX80 signals. It buffers the sync signal and passes it through an RC filter to generate a short negative pulse just after the sync. This in ANDed with the video, which has the effect of making the video signal black for a short period just after the sync, which is exactly what we need.
To test this, I've made some slight modifications to a Minstrel Issue 1 board. I've also added a reset button which has been quite useful.
With that in place, I get a more stable picture, no more fading in and out, but it is quite a grey picture on white. It's better, but not quite there yet.
The trace at the top is the input to the AND gate, the bottom is the new video signal. Compare that to the spec we are looking for and it is a lot better, but there are two problems, one there is a small spike at the start of the back porch, which may affect the level detection, and the ratios are still wrong as it is still using the original values for R30 and R32.
This is my version of the circuit. I have used a 74LS08 quad AND gate. Two gates form the pulse stretcher, and I have used the spare two gates to delay the sync signal slightly to get rid of the small spike. I've changed the two resistor values to make the ratio more like 70%, and reduce the overall level a bit.
The waveform is now more like the specification, there is a back porch, the spike has gone and the ratio of black to white is about 70% of the signal. The width of the back porch pulse is a bit less than 4uS, which again is close enough.
The LCD TV seems happy with this, I get a very crisp stable picture, with deep black giving excellent contrast.
This is the test pattern I have been using on the scope traces.
Trying the ZX81 Kong game again, you can see the difference. That circuit would be useful for any ZX80 style clone which needs the video signal improved.
The normal / inverse mode now looks equally good.
NTSC mode is also available. The number of lines used by the display is the same, there are just less lines at the top and bottom to cope with the lower resolution of NTSC. This does not affect the ZX80, but the ZX81 in slow mode does processing at the top and bottom of the screen, so effectively runs slower in NTSC mode.
You may have noticed from the screenshots that I have now had more success loading games. The previous problems seem to be down to the way I was generating wav files to write to tape. I am still looking for suggestions for a simple command line program which will convert .o, .p or .p81 files to .wav files to play direct or write to tape.
Lots more ZX80 / ZX81 games to try.
These all came from Paul Farrow's website.
I have added this video circuit to the next version of the Minstrel, which will be available soon. Still needs a bit more tidying up of the routing, but it's almost ready.
Other changes include:
  • Fixes from Issue 1 - A6-INT link and keyboard connector pinout now corrected
  • Edge connector - several people have asked for this, so I have added an edge connector, complete with the ROM_CS line which was not present on the ZX80.
  • Reset button - I've found this useful, so have added one, can be wired to an external switch if you prefer.
  • Integral functions list - Several keywords on the ZX80 (such as PEEK which confused me last time) need to be typed in separately. There is a list on the ZX80 case, so I have added one  to the PCB silkscreen.
  • ROM selector jumpers - There is now the option to select form up to 8 ROM images, so you can have ZX80, ZX81, Forth, Assembler etc. if you choose.
  • Regulator position - I've shuffled the power input around so it can be bolted to the board and to any random bit of metal such as a ZX81 heatsink.
The new board will be available in a two to three weeks time, if you want to order one now, you can click below. I will look at offering this as a built and tested unit, as well as bare PCB only. Price to be determined, once I've added it all up. You can preorder a board now, note this will not be dispatched until February 2017.
Minstrel ZX80 Clone Issue 2
  
If you want to support this blog, you can donate via Patreon or Paypal, or buy something from my store.

Saturday, 31 December 2016

Minstrel ZX80 Clone

Here is a new ZX80 clone that I have called the Minstrel. It is a fairly accurate clone electrically to the ZX80, using the same chips and the original schematic with only a few concessions to the modern world. All the parts are the same, the part numbers and pins are the same, other than the ROM and RAM, I've only added a few extra decoupling capacitors and a one resistor / one transistor composite video amplifier.
The first thing is that is not the same size as a ZX80, but has been designed to be the same form factor as the ZX81, with the same mounting points and connectors. The big silver box of a UM1233 UHF modulator is missing. I have replaced that with the single transistor composite video buffer. The phono connector is composite video out in the same location as the original UHF out.
The four connectors are in the same positions as on the ZX81, with the two ear and mic audio in and out jacks. In this case these are stereo with the signal taken from the tip, so either mono or stereo jacks can be used. The power jack has been replaced with a 2.1mm DC jack, with jumpers to select centre negative (ZX Spectrum style) or centre positive (everything else). This is more reliable than the 3.5 mm jack originally used.
The two 2114 RAM chips have been replaced with a single 62256 chip. This is wired for 16K. 32K is possible, but would require changes to the decoding logic, 16K just needed additional address lines wiring up. The 24 pin mask ROM or 2532 EPROM used in the original has been replaced by a 28 pin ROM socket which can accept a 27C64 up to a 27C512. Upper address lines are tied high, but two 8K ROM images can be selected by a jumper, allowing original 4K ZX80 ROM or 8K ZX81 ROM to be selected.
In the first build, I used a 7805 linear voltage regulator, but this can be replaced with a switch mode version to reduce heat and current consumption. The heatsink borrowed from a ZX81 barely gets warm, current draw is about 200mA with a 7805, 110mA with a switch mode unit. The board was designed to accept either a 6.5MHz ceramic resonator or a 6.5MHz crystal, I started with a ceramic resonator to stay true to the original.
On first power up, this is what I got. Sometimes this, sometimes no video sync at all. The ZX80 design requires the Z80 to run appropriate code to generate the screen, and that is what it does about 95% of the time. But in this case it wasn't. Logically either the original ZX80 schematic I had used was wrong (unlikely as it came from Grant Searle's excellent site), or I had transcribed it wrongly in my PCB design (possible), or messed up the build (also possible).
After an extensive check of every connection on the schematic, I finally found the bit I had missed out. There is a direct connection from A6 to INT (part of the display generation system). That was a simple fix just wire the pins together on the back of the board.
It's not perfect, there is a moving diagonal line of interference, but I finally had an inverse K on the screen. I've built a computer from a bag of TTL chips and a Z80!
The distortion seem to come and go, and on some occasions I had a really nice clear picture, although the alignment was a bit off.
I did a lot of probing around and found the frequency of the ceramic resonator was drifting around, and the closer it got to 6.5MHz, the better the picture. I swapped that out for a 6.5MHz crystal and the distortion went away.
The brightness does vary a bit on this LCD monitor, but that's due to the video signal from the ZX80 missing some parts which a modern TV needs to set the black and white levels. (Update - this is much improved in the Issue 2 Minstrel boards)
The chips used are all 74LS TTL chips. I have tried this with 74HCT parts, and it does work, but the signal isn't as strong, the design does rely on the analogue properties of these chips, so best stick to 74LS. (and no, don't use 74HC. Ever. For anything. Please). These chips are still available, as is the Z80 and the selected ROM and RAM, meaning this can be completely constructed with new modern parts.
I've tried to keep things neat with all the passives lined up neatly. One thing I was pleased with, which will only please me and people like me is I used all Texas Instruments chips, and they use the same moulding for 14 and 16 pin chips, so all the chips look lined up and matching, even though the second column has a mix of 14 and 16 pin chips. The top two on the right hand side are 14 pin 74LS05 chips which are are centred so they line up with the 16 pin chips below. No? Only me? Well at least I'm happy.
The original plan was to use a ZX81 membrane, and the connectors were setup for this. However, it didn't work out, the wrong keys were pressed. Unfortunately, it seems I messed up the pinout of the keyboard connector. Both the ZX80 and ZX81 schematics lay the connections out in one order (the one I used), but this is not the one used on the membrane, so I had to build up a small bodge board to fix the order of the rows connector.
I did get a ZX80 replacement keyboard, that uses the same ZX81 style pinout, so I will need to build a suitable board for that as well. The ZX81 keyboard has the same letters and numbers, but the keywords are on different keys  (PRINT " is O shift+Y on the ZX80, P shift+P on the ZX81. The ZX80 originally came with a 4K BASIC ROM, but later on they offered an 8K BASIC ROM and a keyboard overlay which was pretty much the same as the ZX81.
For testing, I fitted pin headers and used an RC2014 mini keyboard. It turns out that has the same pinout I had on my board, only with both the 5pin and 8pin connectors reversed. So with some twisted leads, I can use this keyboard.
A jumper on the board selects the 4K ZX80 BASIC or 8K ZX81 BASIC ROM. So this can become a ZX81, albeit with the screen flicker on every key press like a ZX80.
The ZX81 has additional hardware to generate a 'slow' mode where the CPU can run a small amount of code during the screen draw cycles (whilst the CRT beam is moving back from bottom right to top left). The ZX80 does not have that so has to stop drawing the screen when it needs to think what to do with your keypress.
ZX81 ROM, ZX81 membrane, ZX81 sized board. Guess what's coming next. Yes, the plan is this board can be installed in a ZX81 case and makes this a ZX81 replacement. This means you can take a dead ZX81 where the ULA has failed and drop in this board as a replacement. (in later versions, hopefully a superior replacement)
Anyone who has taken a ZX81 apart, or more importantly put one back together will know there are 5 screw holes on the board, but only two are screwed in from the back of the PCB, so you need to remember who two to fit and which ones to leave and screw it from the back of the case. I've put white silkscreen around the two important ones to make it clear. The membrane should connect direct, but my little bodge board is underneath.
I've fitted a reset switch on one of these as it's quite useful. I was planning to add one to the board, but decided not to. On reflection it is useful, so I will at least add pads to fit one. There is a jumper to select PAL or NTSC mode (on the original ZX80 a diode was fitted for NTSC mode and a resistor on the ZX81).
As on a ZX80, you can also select normal or inverse video. Inverse video is sometimes better if the LCD doesn't detect the black level too well, so you get white on dark blue / grey which can be more readable.
I haven't found much ZX80 software out there, but I did find some on Paul Farrow's website, including PacMan and Space Invaders.
Not all the games I tried worked. PacMan loaded successfully, but didn't run? (Update - this was due to bad audio files - read more in the Minstrel Issue 2 blog post)
Time to load some ZX81 games. You even get the old loading stripes. Simple games loaded, but anything relying on slow mode (including 3D monster maze) will not work until I add in the NMI slow mode for full ZX81 compatibility.
I've checked the RAM, although I had to switch to ZX81 mode, as I couldn't find PEEK on the ZX80 keyboard.
UPDATE:
Thanks to Geoff Wearmouth for reminding me these are typed directly on the ZX80, as per the label on the case. I've added that list to the silk screen on the next revision of the board.
Back to the 8K ROM ZX81 mode.
PRINT PEEK 16388+256*PEEK 16389
Yes, the top of RAM is 32768, meaning 16K is working. Not sure if these simply won't work without the ZX81 fast/slow mode NMI changes? I need to investigate further.
The plan for this was always for several versions of thise board. This first run is pretty much following the original ZX80 schematic. Now that's working and I've ironed out a few little issues with the keyboard connector etc. I can get on with the next phase. I plan to rearrange the logic to use more common TTL chips (some of these are a little obscure these days), and add the ZX81 style NMI functionality. This is the current list of planned changes:

  • ZX81 fast/slow mode NMI circuit
  • Full 32K RAM (at 8K-40K for high resolution graphics mode compatibility)
  • Fix composite video with back porch black level setting by changing line counting logic
  • Reduce chip count and replace less common chips
  • Add input amp to improve tape recorder input
  • Add reset switch
  • Consider edge connector, probably not.
  • May look at joystick connector instead - but is there any software support?

There are a few things I probably won't be doing

  • Surface mount at this stage, at least one more through hole revision before size reduction
  • FPGA, lets stick with real chips for the moment
  • Jupiter Ace / ZX Spectrum video generation - the ZX81 timings would change too much
  • SD card disk drive - maybe?
  • HDMI output - probably not
  • AY3 sound chip - again, is there any software that would use it?
  • 3D monster maze in ROM - hmm, possibly.


As it stands, if anyone is interested in one of these boards, I have (now only a few) left. They take a while to build up due to all the passive components and IC sockets, so I'll probably just sell these as PCB only, rather than assembled or kits. Note the keyboard connector issue and the bodge wire on the Z80. If there is enough interest, I may respin this version with those things fixed before I progress to the optimised ZX81 design.
UPDATE:
The issue 1 boards are now sold out. Issue 2 is on the way. More issue on the issue 2 board, and a preorder button.
I have fixed the two PCB errors on this board, and also added a back porch video circuit which gives a much better video output
I have also addressed the problems loading games, which was down to the software I was using to generate the audio files to play into the ZX80.

If you want to support this blog, you can donate via Patreon or Paypal, or buy something from my store.