In the previous posts, I looked at the standard cassette inputs of the ZX80 and Jupiter Ace, and other machines, with the aim of designing a better circuit to add to the Minstrel 2, 3 and 4th computer kits.
Whilst trying out various different approaches, I came up with a design using an unexpected part.
This is what happened ...
Original Designs
The original circuits used various arrangements of two resistors and a capacitor. These were used to filter the input and remove any DC offset.
The resulting signal was then fed directly into a TTL logic gate, with the intention that the peaks in the signal would be large enough to register as logic 1, and the rest of the waveform would be in the logic 0 region.
That works, but generally needs a reasonably high voltage input, typical of that which you would get out of the 1980s cassette decks with 6V power supplies. There earphone outputs which were diverted from the built-in 2" 8Ω speakers, driven by an audio amplifier, with output in the range of up to 6V.
These days with inputs from phones and laptops etc. this is often more like 0-1V, and not large enough to trigger the input.
Some Ideas
I had tried using 74HC logic gate inputs, to match the rest of the parts used in Minstrel 3 and Minstrel 4th, with an extra resistor to pull the voltage up to 74HC levels.
That worked with some sources, but generally needed a higher input that the original 74LS TTL version did.
I also tried adding a 74HCT14 to the input.
The theory being the HCT has TTL level inputs, so would act the same as the original 74LS367, but also has CMOS outputs, so can drive the actual 74HC367 input port.
The 74HCT14 is six Schmitt trigger inverters, so I will need two of those to avoid inverting the signal.
These have some hysteresis to make sure the signal is clean.
The hysteresis made it slightly better than the original, but still with the same limitations about signal level.
Compare the Meerkat
Hmm, that doesn't sound like a meerket, let's just check around this corner....
AAARRGGGHH!!!
It wasn't a meerkat.
I tried various different options at this point, with op-amps and comparators to compare the input to a fixed reference.
The basic idea is all of the versions up until this point were reliant on detecting when the signal passed a certain voltage threshold.
This was different for 74LS and for 74HC, and some sources worked better with one or the other, and several were too low for both.
The levels in those digital logic chip were fixed, but it is possible to have any level you like, using a comparator.
Here the voltage level is set by the two resistors. When they have a 1:1 ratio, such as two 100KΩ resistors, the threshold could be set to 2.5V, like CMOS logic, or with a 3:7 ratio, say 33KΩ and 75KΩ (to pick the nearest common values), the threshold could be set to about 1.5V.
That should ideally be lower to support more sources, so 22KΩ and 100KΩ would give something closer to 1V, which might open up more lower inputs, but might be too low for some louder sources.
Picking the best value for all situations is tricky, so maybe the best option is to fit a variable resistor to set the threshold level?
Input Filter
Throughout all of that, one of the critical factors is the value of the input capacitor, and less so, the input resistance, and together, the high-pass RC filter they create.
Up until now, I had been trying both the Ace style 300Hz filter and the ZX80 style 3KHz filter, and several points in between, to see which would be better.
In all cases so far, the wave form was being decoupled and referenced to the 0V rail.
With careful setting of the level control, it is possible to recover data from various tape waveforms.
Although some were less successful.
And others were never going to work (is that an armadillo or a stegosaurus?)
The higher the resistance, the more of the signal gets through (height-wise). The higher the capacitance, the lower the cut-off frequency of the high-pass filter they form, and the more of the signal will get through (width-wise).
Those both need to stay within limits, or the the input will not correctly remove the DC offset and the signal will slowly float downwards, potentially missing the start of any data sequences.
One of the combinations that seemed to work well was 47KΩ and 1nF, which works out to the same 3.2KHz cut off as the ZX80 and ZX81.
When using smaller capacitance, such as 1nF, there were distinct peaks, with a nice positive spike at the start of the pulse, and a matching negative spike at the end of the pulse.
That was looking positive (and negative).
I could take that signal and boost the positive pulse with an amplifier with a large gain (I used x23) so that it would resemble the original square wave.
The comparator would trigger on the higher pulses to give a clean output.
The negative going spike was ignored, I had fitted a diode to block that to avoid damaging the op-amp or comparator inputs (and a second diode to block anything over 5V).
The boosted signal generally clipped at the top of the range of the op-amp (3.5-4V).
The comparator threshold was set at about 2/3 VCC (3.33V), so was checking the top of the spikes to miss out any rising or falling edges or noise.
I tested that with various inputs, and it was looking good.
Great, let's get the board made ....
Hang on, what about the Jupiter Ace.
Ah, no, that signal is rubbish, it's not loading at all.
This worked well for the ZX81, with, where there are runs of 4 or 9 pulses, it is the length of the group of pulses which is important, rather than the actual number of pulses or the pulse width.
For the Ace (and the ZX Spectrum) the pulse width is important. There are short pulses (~250µs) for a 0 and longer pulses (~500µs) for a 1.
Here, all the pulses were being converted into spikes, and boosted, so the output was the width of the spike at the start, not the width of the original pulse.
And Now For Something Completely Different
Looking back at those traces, there were two spikes.
The first was the positive one, where the pulse stated, and the second was a negative one, where the pulse ended.
If only I could make the output turn on with the first pulse and off with the second ...
Time passes ... cogs turn .... ideas float wildly around and begin to coalesce into a plan
Maybe I could use those to drive a flip-flop, so the first spike would toggle it on, and the second spike would toggle it off?
If I used two resistors to bias the input to 2.5V, then both of the spikes would both be present in the filtered signal.
All I would need then is two comparators and a flip-flop.
I didn't have two spare comparators, or a spare flip-flop, so I would need to add another chip or two.
In the previous circuits, the op-amp had been setup as an inverting amplifier (as that is easier), so the comparators are wired so the lower one will trigger on the negative spikes, which are the start of the pulse, and so drives the "set" pin of the flip-flop, and the positive spikes drive the top comparator which will drive the "reset" pin to clear the output again.
It would be something like this.
(I have not drawn the protection diodes to avoid it getting any more cluttered)
Does that design look familiar?
Then I had one of those mad ideas you try to persuade yourself is too silly.
I kept pondering it, and it kept sort of making sense, and still looked familiar.
Maybe if I redraw it slightly to combine the two comparator references.....
Anyone spotted it yet?
Maybe if I change the resistor values to be three 5KΩ resistors to give the 1/3 VCC and 2/3 VCC references.
5KΩ, 5KΩ, 5KΩ ?
5 5 5
Yes, that is the good old 555 timer, a 50 year old design.
This is not one of it's main uses, but I think it could work.
There is a built-in voltage divider made of the three 5KΩ resistors (not apparently responsible for the 555 moniker). This gives two voltage references 2/3 VCC and 1/3 VCC.
There are two comparators and a flip flop, just like my design.
The top comparator is fed the 2/3 VCC reference and the "Threshold" input. If this is over 2/3 VCC, the output is set low.
If the "Trigger" input to the bottom comparator is below 1/3 VCC, the output is set high.
That logic is reversed, so actually matches the design I already had with the inverting amplifier.
Up until this point, I had been working with chips soldered on top of chips with flying components and bodge wires, all sitting on a poor old Minstrel 4th board.
Not that I wasn't confident in the 555 idea, but I thought it might be best to try it out on a breadboard.
Not the neatest thing in the world.
Bit it worked.
Turns out the 555 is rather good at that.
Plus, it works with the Jupiter Ace signals.
The two voltage thresholds, make it act like a Schmitt-trigger, the hysteresis coming from the two thresholds. The output is set when the first peak passes it's threshold and not reset until the second peak passes it's own threshold.
It appeared to be working, but I had two problems.
Firstly, when working with lower level tape signals, it often seems to get into a state where it misses the final reset pulse, so it is left set high until the next block, and sometimes more noticeably, at the end of loading.
(more of an issue as I was looking at wiring the tape signal to the screen border as I did in the Minstrel 4D)
When it gets left high, you get a black border.
N.B. it is setup so the border is background colour when the tape signal is low, and text colour when the tape signal is high, so it also works in inverse mode (standard Jupiter Ace), there you get left with a white border when it get stuck high.
Secondly, and I am not sure if it is related, but when I was poking around looking at signals, the boosted signal was very odd.
The bottom half was OK but the upper half was distorted.
I know breadboards aren't ideal for analogue stuff, which I why I had been using direct soldered bodges for testing previously.
Maybe the messy wiring is the issue, or maybe I got something wrong that I can't see because of said wiring.
To rule that out, I rebuilt part of it on a smaller breadboard.
Even rewired with minimal parts installed, it was still doing it.
Then I realised.
The LM392 I was using was not a rail-to-rail op-amp, so the maximum output voltage is VCC-1.5V, or 3.5V.
It is centered around 2.5V, so I only get 1V above that line before it distorts.
Normally with something like that, you would have +/- 5V supplies, or even +/- 15V in traditional op-amp circuits.
I don't have a -5V rail on any of these boards.
Oh, but I do have 9V.
I wired the op-amp supply to 9V, leaving the all the references as they were, diving down the 5V rail. That should extend the range to 0V to 7.5V.
Well, it's not fixed, but it is different.
Hmm.
I know breadboards are not ideal, as you get stray capacitance between the rows of sockets on the breadboard, which can affect sensitive analogue signals like these.
As a last ditch test, I wired it up direct to the chips.
I liked the idea of having two 8 pin chips taking up the space of a 16 pin chip, so that line of chips would look neat.
Anyway, that didn't help.
I had been testing this out in CircuitLabs, but unfortunately the emulated op-amps are ideal, so this issue was not seen there.
It was looking fine on there.
Back to the Drawing Board
OK, I need to regroup and try to work out what my options are here.
I need to look over the whole circuit and see if I can find a way forward.
There was still the contentious issue of the input filter. I have been alternating between two main options here:
Option 1 - 1nF, 2x47KΩ
This is like a ZX80, with a high-pass filter set above 3KHz, so it will only get the harmonics as impulses.
If I remember correctly, you treat those two resistors as if they were in parallel when considering AC things, so that works out as 1nF, 23.5KΩ, so the cut-off frequency is 6773 KHz.
That works well with square waves, giving the high and low impulses to set and reset the output. Those peaks are hitting 5V and -5V.
With a signal from a tape, the results are less good, this is a smaller scale, the peaks are less than 1V and -1V.
Option 2 - 10nF, 2x47KΩ
This is more like the Jupiter Ace, the high-pass filter is set to well below 1KHz, which will let a lot of the signal through.
This looks better for both the square wave and the tape versions.
In fact, that signal looks like I don't need to amplify it.
Do I need the Op-Amp?
I was wondering if that signal would be strong enough to drive the input to the 555 directly.
The signal is biased around 2.5V, and the thresholds are at 1/3 and 2/3 of VCC (5V), which would be 3.33V and 1.67V.
That would mean the filtered signal needs to be over 0.83V to trigger the output and below -0.83V to clear it, but that seems achievable, based on the previous tests with 10nF input capacitance.
Solo 555
That simplified things quite a lot, getting rid of the op-amp entirely.
The only problem is the output is now inverted, threshold is triggered on the positive pulse and turns the output off, then trigger is triggered on the negative pulse and sets the output high again.
I don't have a spare inverting logic gate, so the simplest option would be to use a transistor to invert the output.
(N.B. I double checked, the discharge output is a transistor, but that is the same logic as output, so it is off when the output is high, so a pull-up resistor would make the output high).
The normal output (in green) has a well known spike when it switches on, using discharge with a 10KΩ pull-up (in yellow) has a cleaner rise.
Fixing the Black Border
That still leaves me with the problem of the output being stuck high, which wasn't resolved by removing the op-amp.
I spent a long time trying different arrangements of resistors and capacitors with the transistor on the output to try to try to make something that would limit the maximum on pulse length.
What I needed was something that could be triggered by a signal going active, and keep the output active for a maximum period (I was thinking about 2ms, equivalent to several or the longer pulses) and then deactivate it (even if the input was still active).
Ideally it would also invert the signal.
Hey, how about ... another 555!
And through the magic of buying two of them, I can do it.
(actually, I have a tube full ....)
I took a while to come up with an appropriate arrangement, but this was my solution.
There is a lot going on there, so let me break it down.
The first 555 is the same as before.
The trigger on the second is driven from the output of the first, via a high-pass filter.
This will mean there is an initial spike which will be low enough to trigger the second 555 (1/3 VCC), but after that, it will return back to 1/2 VCC and stay there even whilst the output of the first 555 is low.
When the first 555 goes back to high (inactive), there is a positive spike on the trigger pin, which it ignores, and then it goes back to 1/2 VCC again.
When the second 555 output is low, the discharge pin is pulled low. This shorts out the 10nF capacitor, and the threshold pin is left at 1/2 VCC.
When the second 555 is triggered, the output goes high and the discharge pin is released.
The 10nF capacitor starts to charge through the two 100KΩ resistors, until it reaches 2/3 VCC. This should be around 2ms.
When it reaches 2/3 VCC, the output is turned off, and the 10nF capacitor is shorted to ground again.
The output will remain low until the start of the next pulse from the first 555.
Got it?
Well, that's not quite all of it.
The output of the first 555 is also wired to the threshold pin via a diode. This means if the output of the first 555 goes high, it immediately turns the second 555 off (remember it is inverting the signal).
The middle trace here shows the capacitor charging up (centre) until the output of the first 555 (top) goes high, when it is pulled high by the diode, causing the little spike. That causes the second 555 output to go low (bottom trace) and that discharges the capacitor and the centre trace levels out at 1/2 VCC until the next pulse.
Testing it Out
I decided to build it up on breadboard, but this time, I did a neater job.
Well, I think that is the neatest thing I have ever made on a breadboard.
And there we have it, tested with some long pulses from the signal generator.
The output pulses are the correct polarity, and will return to low after 2 ms.
That was working nicely with ZX81 signals.
And with Jupiter Ace.
The middle trace there shows the threshold signal which is rising during the larger pulses, but always gets reset, so no problems there.
555 + 555 = ?
Time for some maths. 555 + 555 =
Yes, that's right, 556.
The 556 is a 14 pin dual 555. Perfect. That will make the PCB design neater.
I think we are ready for a PCB.
And as if by magic, some PCBs appeared.
(ignore the variable resistor, that is a volume control for the piezo speaker and not a threshold)
That has the NE556 fitted, although I plan to use the TLC556 in production, which is a CMOS version.
But why have you gone back to the NE556 in the photo Dave?
Well ....
It doesn't work.
Well, no, that's not right.
It doesn't work very well.
And I wanted to check if it was the CMOS chip that was the problem (it wasn't)
You might have noticed I had changed some of the values for the PCB, tweaking the RC filter again, back to 2x47KΩ and 1nF.
(unrelated, I had also tried to replace the two 100kΩ resistors with a 220KΩ, but that didn't work out as there is a race condition where the diode and discharge transistor are pulling in opposite directions at the same time)
Even with the 100KΩ resistors and 1nF capacitor reinstated, it still isn't great.
I think the problem is back almost full circle, the filtered input signal is not always high enough to reach the 1/3 VCC and 2/3 VCC thresholds.
Almost as if I need to amplify the signal.....
Stop that, it is getting silly.
Reader, I didn't stop.
I tried bread boarding the circuit with two 555s, but it was no better.
I tried the op-amp and 555 again, but again hit the same problems with the amplifier.
Maybe the breadboard is the problem, let's try the direct approach.
Nope.
I even tried the 74HCT14 again, certainly highlights how many parts the 556 circuit was adding.
(bonus points if you spot the unusual component in that photo and tell me what it is doing)
Where Now?
I am conscious of the sunken cost fallacy. Just because I have spent a lot of time and effort on these designs does not make them any good, and I don't think there is any point in spending any more time on them.
I have now come up with a new, better design, that appears to be working well. More on that next time.
I have ordered new PCBs, which should be here sometime this week.
The new design does not cover every eventuality, but it works with most sources, and only the demonstrably badly recorded or degraded tapes were failing, so I think this is good to go.
I have updated the Tindie listing if anyone wants to pre-order one of these new board.
The photos show the 556 version for now, as a placeholder. The ones that will ship will be the new design and all being well they should be shipping next week.
Also, final call for the last of the outgoing V4.28 boards. I have one left, which comes ready assembled with keyboard and all IC sockets. This had the original tape loading option, which is fine as long as your output is loud enough or you are using an Arduino based player.
Since that is the old version, I am open to offers if anyone wants a bargain.
There are also all sort of kits, test gear and upgrades and recreations of the ZX80, ZX81, Jupiter ACE and Commodore PET in my Tindie store.
Patreon
If you enjoy posts like these, you can support me via Patreon, and get access to advance previews of blog posts. Part 4 of this series (which will become parts 5 and 6, is already on there, plus an earlier post which will become part of a new part 4), and exclusive posts.
You also get progress updates on new projects and other behind the scenes updates, as well as access to my Patreon only Discord server for even more regular updates, and to discuss your own projects.

