Friday, 20 January 2017

ZX Spectrum Issue 2 Testing with DivMMC Future

This is an old post, preserved for reference.
The products and services mentioned within are no longer available.

The classic rubber keyed Sinclair ZX Spectrum came in many versions. This one is issue 2, the first one produced in any volume.
I've dug this one out to answer a question posed on twitter:
This was part of a discussion about the new DivMMC Future board, which I have been tweaking the design of to make it work with all the different versions of the Spectrum.
Most of the issue 2 Spectrums you see will look like this. A ZTX313 transistor is soldered across the Z80 CPU to fix a bug in the ULA.
It responds to IO requests at all addresses, rather than just all even addresses as on the ZX80 and ZX81. To fix this, this transistor pulls the IOREQ line high when A0 is high so the ULA will not respond.
The schematic shows two versions, the ZTX313 and the 'alternative to TR6'. This uses a diode which will do the same thing, and rather alarmingly, pulls the A0 line up to 12V.
Looking at the photos provided by Brendan Alford on twitter, it is actually pulled up to 9V. But still that is A0, a 5V TTL line pulled up to 9V. The pad on the left is A0, and IOREQ is picked up at the pad at the bottom of the CPU.
I've looked through my collection of Issue 2 Spectrums, and I couldn't find one with that modification. I tried to find one that was a close match, a factory 48K model with the Hitachi ROM.
I found this one which looked a likely candidate, and it seemed to work, but I found that I was having problems with some games. JetPac was fine, as that only needs 16K, but others were failing. I loaded a RAM tester (from zx.zigg.net). That confirmed the lower 16K RAM was fine, but there was a fault (or rather several faults) in the upper 32K RAM.
So first job was to replace the RAM. This took a while as there were initially 4 faulty RAM chips, and one more which failed after a few minutes testing. I ended up replacing all 8 RAM chips to be safe.
In common with many issue 2 boards, the colours are all wrong when viewed on a colour TV. They are normally blue or yellow, but this one has gone green.
There are lots of adjustments here, and even then it can be tricky. Here I've clipped on a temporary composite video modification.
To the left of the ULA, there are four adjustments. The top variable capacitor needs to be adjusted so the clock is 14MHz (here checked at the CPU clock which is that divided by 4)
The second one adjusts the colour burst frequency to 4.433619MHz.
The two variable resistors are adjusted to find the sweet spot between yellow and blue, and at last, we have white.
With the RAM working and the picture sorted, I could get back to the testing. My plan was to test this issue 2 Spectrum with a selection of DivMMC boards. The three candidates will remain anonymous, but I can tell you that the green board on the right is the DivMMC future. Neat isn't it?
First up, all three boards worked. I tried several games, going in and out of the menu, saving and loading etc. Also using the Kempston joystick port that all three provide. No problems.
The next step was to try to replicate the 'alternative to TR6'. I carefully removed the transistor and installed a diode and resistor as per the photos.
I cautiously powered on the Spectrum, but no need to panic, it came on fine, and seemed to work OK. Time for some testing. Again all was fine, all three boards worked. No problem. So why are people saying the DivMMC will not work on an issue 2 with the diode-resistor mod?
The photo on the left is the one from Twitter, on the right is my modified board. Can you spot the difference? There is a 1K resistor on the board I was testing. This wasn't present on the one in the photo. That is part of another mod on the issue 2 schematic.
This one isn't that clear from the schematic, there is a join to the 5V line above TR6 which really shouldn't be there. I've tidied it up a little.
What it's saying is change the value of R24 from 3K3 to 1K, replace D14 with a 100pF capacitor, and add a 1K pullup to the clock line. The capacitor should speed up the transition time of the clock signal, and the reduced value and pullup should make it a stronger signal. Ah, now this is making sense. It looks like my board has this mod fitted, and the early ones do not.
Here R24 is indeed 1K, and two below that, the light green part is a 100pF axial capacitor. Before I revert the clock circuit, here is how the clock signal currently looks on the scope. 3.5MHz, around 3V peak to peak, not a very good square wave. Remember, this is the improved version!
With those removed you can see the silkscreen still shows the legend D14.
I've now replaced those with the parts on the original schematic.
The 1K pullup is also gone, so now it is back to the original clock circuit, which should match the one in the photo from twitter.
OK that powers on, so far so good. Let's check the clock on the scope. A bit worse now, down to a bit over 2V peak to peak and an even worse square wave. This is good enough to drive the Z80, but anything else plugged into this line will have difficulty working with that clock signal.
Over the last few months, I've spent rather a lot of time looking a clock signals from various issues of Spectrum. There is a great variance from this sort of thing all the way up to perfect 5V peak to peak square waves, so it is difficult for a plug in board to work across the range. There is a more detailed blog to follow on all the fun we have had getting the DivMMC future to work on boards like this.
With the issue 2 board reverted back to the early releases with the diode-resistor mod and no clock mod. Time to test with the DivMMC boards.
Black screen from the black board, sometime with various patterns, occasionally trying to start but locking up on the detection screen. Same from the blue board.
I tried several SD cards, as this can make a difference, and once got a bit of a menu.
Time to test the DivMMC future.
Great, menu loaded, games running. All games loading fine.
So, to answer the original question. Will the DivMMC future run on boards with the diode-resistor mod? Yes, but so will some other DivMMC boards.
The question to ask is will the DivMMC future work on early issue 2 boards without the clock mod? The answer is Yes. Will the other boards, not really.
Addendum: Thinking about the issue here, I remembered the Spectrum 128K+ Toastrack also has a rubbish clock signal, and some of these boards have a special switch to cope with the Toastrack, which adds a pullup to the clock line to try to get it into range. With the other units switched into Toastrack mode, it was a bit better, not 100%, but it was usable, you just need to remember to set the appropriate switches.
That's the nice thing about the DivMMC future, it did that automatically, no dip switches or jumpers, only the menu and reset buttons.
The DivMMC future will be available to pre-order soon. For the moment, watch this space, follow @futurewas8bit on twitter or sign up for the Future was 8 bit newsletter (link at the bottom of that page).

2022 Update: The production version of the DivMMC future is now available from  The Future Was 8 bit

Sunday, 8 January 2017

Minstrel ZX80 Clone Video Output Enhancement

This is an old post, preserved for reference.
The products and services mentioned within are no longer available.

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.
Update:
Issue 2 boards are available now, see the new blog post for more info and buy it now links.

Update:
I have found some TVs work better with a lower video level, so I have adjusted the values of the two summing resistors to reduce the signal level. Current revisions of the board and kit include these new values.

2022 Update: There are PCBs for the Minstrel 2 (ZX80), Minstrel 3 (ZX81) and Minstrel 4th (Jupiter Ace), as well as the Mini PET available from my SellMyRetro store. (also a few built units, while stocks last!)