Why did the Sinclair ZX-Spectrum use edges for its standard tape storage routines?

I can see that frequency modulation was likely necessary in order to account for the inaccurate timings when running off the lower 16Kbs in the lower-end models.

However, as I understand it, EAR/MIC I/O was level based. Analog tapes also appear to have been based on amplitude modulation.

Given that both elements are amplitude based, it seems unnecessary if not dangerous to rely on edges when levels would appear to be fine after applying some chattering removal.

Was it related to the polarity of the tape recorders or something else entirely?

  • 1
    My understanding was that it enabled the use of cheaper circuitry - although at the expense of accuracy. – Chenmunka Feb 7 '17 at 12:49
  • 2
    I'm not sure you could call the tape input "edge-based" - The input signal is apparently sampled with the CPU clock, not with the tape signal's edge. At least the Harlequin schematics look like that. – tofro Feb 7 '17 at 15:01

I'm not sure what you mean with "EAR/MIC I/O was level based". In the ZX Spectrum, the EAR input is a digital input, so it can only be 1 or 0. You cannot measure the input level beyond that.

The main reason to use edges is for the system to work independently of the audio source. Other systems, such as the Commodore 64, need the datasette to supply a signal with the correct polarity, or the program won't load (this is because the CIA only detects falling edges and starts measuring time from those). The ZX Spectrum doesn't matter if it is a rising or falling edge. It just has to be an edge.

Working with levels in a polarity independent way may require more complex code, and one distinctive feature of the ZX Spectrum ROM loader is that it doesn't require any memory location to hold temporary variables while it is executing. Everything (byte being loaded, bit being added to the current byte, time constants, counters, checksum, length of data to load, current address to store the loaded byte to, etc, are held in registers. Only the stack is used as the routine calls several sub-routines. A more complex code might break that.

"it seems unnecessary if not dangerous to rely on edges when levels would appear to be fine after applying some chattering removal". Chattering removal would need a better input filter, and/or a hysteresis driven input. None of that is present in the ZX Spectrum.

Of course, an edge based loader has the inconvenient of triggering load errors if an edge is read when it shouldn't. The ZX Spectrum tries to minimize the effect of spureous signals by forcing the user to use a volume setting of about 70-75%, which is pretty loud.

  • Anything over about 0.7V is a 1, right? What I don't understand is why a "1" could be a read as a "0" and vice-versa. Is it a property of the tape recorder, the tape itself or the input circuit? – user4433 Feb 7 '17 at 21:16
  • If you are writting a tape loader that is based on levels, and do care about polarity (note that the problem here is not levels per se, but polarity), then your loader may expect to read a positive semiwave (1) followed by another one negative (0). It would measure its period and would deduce that the complete wave encodes a 0 or a 1. – mcleod_ideafix Feb 7 '17 at 21:30
  • 1
    But if your tape player inverts the audio signal respect to the polarity it reads from the tape head (on audio, polarity inversion is not an issue so the tape amplifier may do just that), the effect is that the complete signal is shifted half period, and what should be a 0 may be turn to 1. – mcleod_ideafix Feb 7 '17 at 21:30

It's the normal way to do it. In fact floppies and hard drives work this way too.

In an analog signal recording on a magnetic media:

  • Amplitude is unreliable since the chemistry of the tape, the recording bias, the read/write head amp, the length of the cable, the output volume, etc can all affect amplitude.

  • Frequency, on the other hand, has only the tape speed as a variable.

As tylisim hinted in a comment above, there is another factor which is due to the nature of the head: the signal needs to be cycled regularly, otherwise the surface of the head will resist change and playback will be altered.

Recordings on magnetic media therefore encode data as flux reversal over time. This is very convenient since time is quite reliable, and edge changes are much easier to deal with, from an electronics' perspective, than amplitude levels.

This also allows to encode synchronization marks into the signal so that the timing loop knows the actual speed of the tape and can re-calibrate itself at regular interval during the read operation.

The most common format for floppies was MFM, where 50% of the data actually written on the disk was to keep the head from staying too long in the same state, and also synchronize the controller with the actual read speed. Apple used another format called GCR but it was an exception.

Tapes do not have the same density as floppies and the heads have a larger mass, so they do not need flux reversal as often, but the theory is the same.


Physical magnetic media doesn't deal well with DC (or near DC) signals, which a long string of 0s or 1s would be if they were level sampled (there is a minimum frequency the tape can store). Edge triggering forces the signal to transition at a suitable rate to store on tape because both zeroes and ones include transitions.

  • This explains why they didn't just record unstructured data. However, a UART-like protocol with start/end bits would also switch at switch at least at 120Hz assuming the same baud-rate as the standard loader, is that not viable with magnetic tapes? – user4433 Feb 14 '17 at 11:26
  • 2
    I'm not entirely sure what the limit is for regular tape, but with floppies the general rule is that you shouldn't have more than 2 or 3 bits without flux reversal. – tylisirn Feb 14 '17 at 13:54
  • 1
    @jbcreix - I wouldn't want to rely on it. Even some modern, high quality tape decks have lower quality than optimal reproduction on frequencies around that range (this one, for example), so would imagine that a lot of the cheap old tape decks we used to use back in the 80s had serious issues with this ... particularly the kind that had a small integrated speaker, which would likely vibrate badly if driven too hard at this kind of frequency, so may well have used a high pass filter to avoid that. – Jules Oct 31 '17 at 15:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy